mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-02-19 17:08:10 +01:00
💡 feat: Improve Reasoning Content UI, copy-to-clipboard, and error handling (#10278)
* ✨ feat: Refactor error handling and improve loading states in MessageContent component * ✨ feat: Enhance Thinking and ContentParts components with improved hover functionality and clipboard support * fix: Adjust padding in Thinking and ContentParts components for consistent layout * ✨ feat: Add response label and improve message editing UI with contextual indicators * ✨ feat: Add isEditing prop to Feedback and Fork components for improved editing state handling * refactor: Remove isEditing prop from Feedback and Fork components for cleaner state management * refactor: Migrate state management from Recoil to Jotai for font size and show thinking features * refactor: Separate ToggleSwitch into RecoilToggle and JotaiToggle components for improved clarity and state management * refactor: Remove unnecessary comments in ToggleSwitch and MessageContent components for cleaner code * chore: reorder import statements in Thinking.tsx * chore: reorder import statement in EditTextPart.tsx * chore: reorder import statement * chore: Reorganize imports in ToggleSwitch.tsx --------- Co-authored-by: Danny Avila <danny@librechat.ai>
This commit is contained in:
parent
ea45d0b9c6
commit
c0f1cfcaba
13 changed files with 528 additions and 186 deletions
|
|
@ -1,54 +1,21 @@
|
|||
import { atom } from 'jotai';
|
||||
import { atomWithStorage } from 'jotai/utils';
|
||||
import { applyFontSize } from '@librechat/client';
|
||||
import { createStorageAtomWithEffect, initializeFromStorage } from './jotai-utils';
|
||||
|
||||
const DEFAULT_FONT_SIZE = 'text-base';
|
||||
|
||||
/**
|
||||
* Base storage atom for font size
|
||||
* This atom stores the user's font size preference
|
||||
*/
|
||||
const fontSizeStorageAtom = atomWithStorage<string>('fontSize', DEFAULT_FONT_SIZE, undefined, {
|
||||
getOnInit: true,
|
||||
});
|
||||
|
||||
/**
|
||||
* Derived atom that applies font size changes to the DOM
|
||||
* Read: returns the current font size
|
||||
* Write: updates storage and applies the font size to the DOM
|
||||
*/
|
||||
export const fontSizeAtom = atom(
|
||||
(get) => get(fontSizeStorageAtom),
|
||||
(get, set, newValue: string) => {
|
||||
set(fontSizeStorageAtom, newValue);
|
||||
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
||||
applyFontSize(newValue);
|
||||
}
|
||||
},
|
||||
export const fontSizeAtom = createStorageAtomWithEffect<string>(
|
||||
'fontSize',
|
||||
DEFAULT_FONT_SIZE,
|
||||
applyFontSize,
|
||||
);
|
||||
|
||||
/**
|
||||
* Initialize font size on app load
|
||||
* This function applies the saved font size from localStorage to the DOM
|
||||
*/
|
||||
export const initializeFontSize = () => {
|
||||
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
const savedValue = localStorage.getItem('fontSize');
|
||||
|
||||
if (savedValue !== null) {
|
||||
try {
|
||||
const parsedValue = JSON.parse(savedValue);
|
||||
applyFontSize(parsedValue);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
'Error parsing localStorage key "fontSize", resetting to default. Error:',
|
||||
error,
|
||||
);
|
||||
localStorage.setItem('fontSize', JSON.stringify(DEFAULT_FONT_SIZE));
|
||||
applyFontSize(DEFAULT_FONT_SIZE);
|
||||
}
|
||||
} else {
|
||||
applyFontSize(DEFAULT_FONT_SIZE);
|
||||
}
|
||||
export const initializeFontSize = (): void => {
|
||||
initializeFromStorage('fontSize', DEFAULT_FONT_SIZE, applyFontSize);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue