Skip to content

fix(desktop): load history when resuming a session#92

Merged
oratis merged 1 commit into
mainfrom
fix/desktop-session-resume
May 30, 2026
Merged

fix(desktop): load history when resuming a session#92
oratis merged 1 commit into
mainfrom
fix/desktop-session-resume

Conversation

@oratis

@oratis oratis commented May 30, 2026

Copy link
Copy Markdown
Owner

Bug

Picking a past session in the sidebar showed an empty chat — the prior conversation never loaded (reported live).

Root cause

  • window-shim.ts sessions.resume() was a stub returning { history: [], sessionId: '' }.
  • No Rust command read a session's messages (only session_create/append/list_sessions).
  • ReplScreen always started fresh with sessionId: 'default'.

Fix (full chain)

  • Rust — add session_read(id): parses the session JSONL, returns message lines (skips the session_meta header + any partial trailing line).
  • tauri-apisessionRead(id); window-shim — implement resume({id}): read messages, adopt into the agent (mac-agent.resumeSession sets module history + id so the next turn continues with full context and appends to the same file), return them.
  • repl-streamstoredToMsgs() reconstructs the chat view from stored messages (assistant text + tool_use → finalized turn; following tool_result blocks attach to cards by tool_use_id; thinking dropped).
  • ApponPickSession awaits resume and seeds the remounted ReplScreen; new-session / switch-project / ⌘N clear it.

Verified

  • tsc -b, 26 desktop tests (incl. 2 new storedToMsgs tests), format + 0 new lint warnings, Rust builds clean.
  • Live in tauri dev: selecting a session now renders its conversation; a follow-up message continues it.

🤖 Generated with Claude Code

Picking a past session in the sidebar showed an empty chat — the conversation
never loaded. Root cause: `sessions.resume()` in window-shim was a stub
(`{ history: [], sessionId: '' }`), there was no Rust command to read a
session's messages (only create/append/list), and ReplScreen always started
fresh with sessionId 'default'.

Wire the full path:
- Rust: add `session_read(id)` — parses the session JSONL, returns its message
  lines (skips the session_meta header + any partial trailing line).
- tauri-api: `sessionRead(id)`; window-shim: implement `resume({id})` to read
  the messages, adopt them into the agent (new mac-agent `resumeSession` sets
  the module history + id so the next turn continues with full context AND
  appends to the same file), and return them.
- repl-stream: `storedToMsgs()` reconstructs the chat view from stored messages
  — assistant text + tool_use become a finalized turn, the following user
  tool_result blocks attach to the cards by tool_use_id; thinking dropped.
- App: onPickSession now awaits resume, seeds ReplScreen (remounted via key)
  with the reconstructed messages; new-session / switch-project / ⌘N clear it.

Adds storedToMsgs tests (reconstruction + errored-result). Verified live in
tauri dev: selecting a session now renders its prior conversation, and a
follow-up message continues it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@oratis oratis merged commit f93efa6 into main May 30, 2026
5 of 6 checks passed
@oratis oratis deleted the fix/desktop-session-resume branch May 30, 2026 08:18
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