Bug Description
When interacting with the main chat input field, I am experiencing two related UI/state-sync bugs:
- Double Paste: Pasting text into the input field (via Cmd+V or the right-click context menu) inserts the clipboard content twice.
- Ghost Text Remnant: After pressing Enter to submit the prompt, the API request goes through successfully and the AI begins responding, but a visual remnant of the submitted text remains stuck in the input box instead of clearing.
Deployment Type
Steps to Reproduce
- Navigate to a new or existing chat (e.g.,
http://localhost:3929/dashboard/[id]/new-chat).
- Copy any string of text to the clipboard.
- Paste the text into the chat input box -> Observe the text is duplicated.
- Press Enter to submit the message -> Observe the message sends, but the text remains visually stuck in the input field.
Expected Behavior
- Pasting should insert the clipboard content exactly once.
- Submitting the chat form should completely clear the input field's visual and internal state.
Actual Behavior
When pasting via keyboard shortcut or context menu, the clipboard string is inserted twice into the rich-text input area. Furthermore, upon pressing Enter, the network request to the backend successfully fires and the AI generates a response, but the DOM/input state fails to clear, leaving the previously submitted text visually stuck in the chat box as "ghost text".
Environment Information
- Browser: Safari 26.5.2 (21624.2.5.11.8) and Chrome 150.0.7871.129 (arm64)
- Operating System: macOS (Apple Silicon M2 Pro)
- SurfSense Version: 0.0.34
Additional Environment Details (for Self-hosted only)
- Python Version: 3.12.13
- Node.js Version: v20.20.2
- Database: PostgreSQL 17 (
pgvector/pgvector:pg17)
- Deployment Method: Docker Compose (via official
docker-compose.yml)
Additional Context
I have already performed extensive troubleshooting to isolate this issue and confirm it is a core frontend code bug, not a local environment glitch:
- Tested in Incognito/Private Windows: To completely rule out browser extensions (like Grammarly, clipboard managers, etc.). The bug still occurs.
- Cleared Cache & Storage: Cleared browser cache, LocalStorage, and unregistered Service Workers to ensure the absolute newest frontend assets were loaded.
- Cross-Browser Testing: Reproduced on both Chromium-based browsers (Chrome) and WebKit (Safari).
Suspected Technical Root Cause (Jotai State Desync):
Checking the browser console reveals a critical warning: Detected multiple Jotai instances. It may cause unexpected behavior with the default store.
Because SurfSense uses Jotai for React state management, loading duplicate instances of the library causes the chat input's state to desync. This explains why the UI fails to clear the text box upon submission (one instance clears, the other retains the DOM state) and why paste events are duplicating (race conditions between the split stores and native browser events). This is likely a Webpack/bundling issue in the surfsense-web Docker image where Jotai is being bundled into a shared component library as well as the main app.
Logs/Error Messages
0fd38ba2f10381f4.js:5 Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044
88184a3b3a5f6ad0.js:6 Tooltip is changing from controlled to uncontrolled. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.
0317e851df8fc883.js:1 Error: <circle> attribute r: Expected length, "undefined".
# Checklist
- [x] I have searched existing issues to ensure this is not a duplicate
- [x] I have provided all the required information above
- [x] I have added appropriate labels (bug, deployment type)
Bug Description
When interacting with the main chat input field, I am experiencing two related UI/state-sync bugs:
Deployment Type
Steps to Reproduce
http://localhost:3929/dashboard/[id]/new-chat).Expected Behavior
Actual Behavior
When pasting via keyboard shortcut or context menu, the clipboard string is inserted twice into the rich-text input area. Furthermore, upon pressing Enter, the network request to the backend successfully fires and the AI generates a response, but the DOM/input state fails to clear, leaving the previously submitted text visually stuck in the chat box as "ghost text".
Environment Information
Additional Environment Details (for Self-hosted only)
pgvector/pgvector:pg17)docker-compose.yml)Additional Context
I have already performed extensive troubleshooting to isolate this issue and confirm it is a core frontend code bug, not a local environment glitch:
Suspected Technical Root Cause (Jotai State Desync):
Checking the browser console reveals a critical warning:
Detected multiple Jotai instances. It may cause unexpected behavior with the default store.Because SurfSense uses Jotai for React state management, loading duplicate instances of the library causes the chat input's state to desync. This explains why the UI fails to clear the text box upon submission (one instance clears, the other retains the DOM state) and why paste events are duplicating (race conditions between the split stores and native browser events). This is likely a Webpack/bundling issue in the
surfsense-webDocker image where Jotai is being bundled into a shared component library as well as the main app.Logs/Error Messages