Skip to content

fix(desktop): keep running session visible after New Session - #38207

Closed
teknium1 wants to merge 1 commit into
mainfrom
hermes/hermes-26636c57
Closed

fix(desktop): keep running session visible after New Session#38207
teknium1 wants to merge 1 commit into
mainfrom
hermes/hermes-26636c57

Conversation

@teknium1

@teknium1 teknium1 commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

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 running tui_gateway workers 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 $workingSessionMeta atom + noteWorkingSessionMeta(); pure mergeWorkingSessions() that prepends a synthetic SessionInfo row 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 working
  • use-session-state-cache.ts: record cwd/model when a session goes busy
  • chat/sidebar/index.tsx: merge synthetic rows into the list before sort/index, so grouping, selection, and the working dot all work unchanged
  • store/session.test.ts: coverage for the merge selector + meta lifecycle

The 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_messages relaxation (empty-draft suppression preserved), pure Desktop UI state — no prompt-cache or message-flow invariants touched.

Validation

Before After
New Session while untitled agent running running session drops out of sidebar synthetic working row stays visible, keyed by stored id
Empty abandoned drafts hidden still hidden (unchanged)
Working session that is in the list rendered rendered (merge is a no-op)
  • tsc -b — clean
  • eslint on changed files — 0 errors
  • vitest run src/store/session.test.ts — 8/8 passing

Infographic

dashboard-check-before-update

Infographic

running-session-stays-visible

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
@teknium1

teknium1 commented Jun 3, 2026

Copy link
Copy Markdown
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.

@teknium1 teknium1 closed this Jun 3, 2026
@teknium1
teknium1 deleted the hermes/hermes-26636c57 branch June 3, 2026 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant