fix(web): Address review findings for M4-LLM integration
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
ci/woodpecker/pr/woodpecker Pipeline was successful

- 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:
Jason Woltje
2026-02-06 20:25:03 -06:00
parent da1862816f
commit f64ca3871d
6 changed files with 130 additions and 28 deletions

View File

@@ -369,6 +369,37 @@ describe("useChatOverlay", () => {
});
});
describe("minimize/toggleMinimize guards", () => {
it("should not allow minimize when overlay is closed", () => {
const { result } = renderHook(() => useChatOverlay());
// Overlay starts closed
expect(result.current.isOpen).toBe(false);
act(() => {
result.current.minimize();
});
// Should remain unchanged - cannot minimize when closed
expect(result.current.isOpen).toBe(false);
expect(result.current.isMinimized).toBe(false);
});
it("should not allow toggleMinimize when overlay is closed", () => {
const { result } = renderHook(() => useChatOverlay());
expect(result.current.isOpen).toBe(false);
act(() => {
result.current.toggleMinimize();
});
// Should remain unchanged - cannot toggle minimize when closed
expect(result.current.isOpen).toBe(false);
expect(result.current.isMinimized).toBe(false);
});
});
describe("storage error handling", () => {
it("should call onStorageError when localStorage save fails", () => {
const onStorageError = vi.fn();