fix(web): Address review findings for M4-LLM integration
- Sanitize user-facing error messages (no raw API/DB errors) - Remove dead try/catch from Chat.tsx handleSendMessage - Add onError callback for persistence errors in useChat - Add console.error logging to loadConversation - Guard minimize/toggleMinimize against closed overlay state - Improve error dedup bucketing for non-DOMException errors - Add tests: non-Error throws, updateConversation failure, minimize/toggleMinimize guards Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -83,7 +83,12 @@ function saveState(
|
||||
try {
|
||||
window.localStorage.setItem(STORAGE_KEY, JSON.stringify(state));
|
||||
} catch (error) {
|
||||
const errorName = error instanceof DOMException ? error.name : "UnknownError";
|
||||
const errorName =
|
||||
error instanceof DOMException
|
||||
? error.name
|
||||
: error instanceof Error
|
||||
? error.constructor.name
|
||||
: "UnknownError";
|
||||
console.warn("Failed to save chat overlay state to localStorage:", error);
|
||||
|
||||
if (onStorageError && !notifiedErrors.has(errorName)) {
|
||||
@@ -119,7 +124,7 @@ export function useChatOverlay(options: UseChatOverlayOptions = {}): UseChatOver
|
||||
}, []);
|
||||
|
||||
const minimize = useCallback(() => {
|
||||
setState((prev) => ({ ...prev, isMinimized: true }));
|
||||
setState((prev) => (prev.isOpen ? { ...prev, isMinimized: true } : prev));
|
||||
}, []);
|
||||
|
||||
const expand = useCallback(() => {
|
||||
@@ -134,7 +139,7 @@ export function useChatOverlay(options: UseChatOverlayOptions = {}): UseChatOver
|
||||
}, []);
|
||||
|
||||
const toggleMinimize = useCallback(() => {
|
||||
setState((prev) => ({ ...prev, isMinimized: !prev.isMinimized }));
|
||||
setState((prev) => (prev.isOpen ? { ...prev, isMinimized: !prev.isMinimized } : prev));
|
||||
}, []);
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user