web/chat: lazy "new chat" creation + per-chat draft persistence#136
Open
GrigoryPervakov wants to merge 1 commit into
Open
web/chat: lazy "new chat" creation + per-chat draft persistence#136GrigoryPervakov wants to merge 1 commit into
GrigoryPervakov wants to merge 1 commit into
Conversation
964ed65 to
e15cea9
Compare
The + button no longer POSTs a session up front. It mints a local "virtual" chat (temp UUID, never sent to the backend) and defers the POST /api/sessions to the first message, then adopts the server-minted id for the turn — so a session is created only when you actually send, and it becomes a real, selectable chat that survives switching away. Unsent input is stored per session id, so switching chats shows an empty composer and returning restores the unfinished message (fixing the single shared textarea that leaked text across sessions). A pencil glyph marks non-active chats that hold a draft, the virtual chat pins to the top of the sidebar, and switching to any chat focuses the composer. Also scope view-mutating WS events (stream/panels/interaction) to the active session, so a reconnect that rebinds the socket to another session can't hijack the current view with a phantom "Thinking..." badge or a disabled composer. POST /api/sessions returns a partial row (no updated_at), so the promoted session fills the fields the sidebar needs locally, and getDateGroup tolerates a missing date instead of throwing. Frontend-only; no API or schema changes.
e15cea9 to
347ad53
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Defer session creation to the first message, and remember unfinished input per chat.
POSTs a session up front — it opens a local virtual chat (temp id, never sent to the backend) and only callsPOST /api/sessionswhen you send the first message, then adopts the server id for the turn. The virtual chat pins to the top of the sidebar, auto-discards on switch-away when its draft is empty, and becomes a real, selectable session on first send (survives switching away mid-turn).session_status) are dropped when theirsession_id≠ the active session, so a reconnect that rebinds the socket to another session can't bleed a phantom "Thinking…" badge or a disabled composer into the chat you're viewing.Frontend-only — no REST API or DB schema changes. Uses the existing
POST /api/sessions;getDateGroupis also hardened to tolerate a missing date.Test plan
POST /api/sessions