fix(desktop): keep running session visible after New Session - #38207
Closed
teknium1 wants to merge 1 commit into
Closed
fix(desktop): keep running session visible after New Session#38207teknium1 wants to merge 1 commit into
teknium1 wants to merge 1 commit into
Conversation
A running untitled session vanished from the Desktop sidebar after starting a New Session. The sidebar only renders rows from the loaded session list, which is repopulated by listSessions(limit, min_messages=1) to suppress empty draft clutter. An untitled session mid-turn has zero persisted messages, so the backend list query drops it — even though it is still alive in state.db with running tui_gateway workers and still tracked in $workingSessionIds. The working marker had no row to attach to, so the session disappeared. Render a synthetic row for any working session that isn't in the loaded list, keyed by stored session id, drawn from lightweight runtime metadata (cwd, model, started-at). The synthetic row is prepended and marked working; once the turn produces a message and the next refresh returns the real row, it replaces the synthetic one. No backend change, no min_messages relaxation, pure Desktop UI state. - store/session.ts: $workingSessionMeta atom, noteWorkingSessionMeta, mergeWorkingSessions (pure), meta pruned when a session stops working - use-session-state-cache.ts: record cwd/model when a session goes busy - chat/sidebar/index.tsx: merge synthetic rows before sort/index - store/session.test.ts: merge + meta-lifecycle coverage
Contributor
Author
|
Closing as redundant — this exact bug is already fixed on main by @OutThisLife in #37908 (commit 55a76ec, "fix(desktop): keep in-flight new chats from vanishing on refresh"). That fix uses the same approach keyed by working session id, but at the refresh layer: mergeWorkingSessions(previous, incoming, workingIds) preserves the real prior SessionInfo for any still-working session the server's listSessions(min_messages=1) omitted, which is cleaner than synthesizing a stub row. Thanks Brooklyn. |
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
A running session no longer disappears from the Desktop sidebar when you start a New Session.
Root cause: the sidebar only renders rows from the loaded session list, which is repopulated by
listSessions(limit, min_messages=1)to hide empty "Untitled" draft clutter. A running untitled session mid-turn has zero persisted messages, so that query drops it — even though it is still alive in state.db with runningtui_gatewayworkers and still tracked in$workingSessionIds. "New session" clears the active view, the next refresh replaces the list, and the working session's row vanishes (the working marker had no row left to attach to).Changes
store/session.ts: new$workingSessionMetaatom +noteWorkingSessionMeta(); puremergeWorkingSessions()that prepends a syntheticSessionInforow for any working id absent from the loaded list (keyed by stored session id, drawn from cwd/model/started-at); meta is pruned when a session stops workinguse-session-state-cache.ts: record cwd/model when a session goes busychat/sidebar/index.tsx: merge synthetic rows into the list before sort/index, so grouping, selection, and the working dot all work unchangedstore/session.test.ts: coverage for the merge selector + meta lifecycleThe synthetic row is marked working and shown at top. Once the turn produces a message and the next refresh returns the real row, it replaces the synthetic one (same id). No backend change, no
min_messagesrelaxation (empty-draft suppression preserved), pure Desktop UI state — no prompt-cache or message-flow invariants touched.Validation
tsc -b— cleaneslinton changed files — 0 errorsvitest run src/store/session.test.ts— 8/8 passingInfographic
Infographic