Repository navigation
fix(chat): resume a background chat tab instead of opening a blank one - #8342
Conversation
The chat journal never stored the agent's session id on the session row, so listSessions/getSession always returned harnessSessionId: null. A chat adopted into a tab the user never opened had no agent session id. When its agent stopped, opening the tab recovered with session/new: a blank chat, and the pane then pointed at that empty session, so switching to the CLI failed with "No conversation found". - The journal projects harnessSessionId from session events, and backfills rows written before this from the journal. - AcpChatPane recovers with the host's stored id when the pane has none.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (5)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe chat runtime now captures harness session IDs from Claude and Codex events, retains them in the session projection and journal replay, and uses stored IDs for session lookup and pane resume when needed. ChangesHarness Session ID Persistence and Resume
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant HarnessAdapter
participant ChatJournal
participant SessionProjection
participant GetSession
participant AcpChatPane
HarnessAdapter->>ChatJournal: Emit session event with harnessSessionId
ChatJournal->>SessionProjection: Write projected harnessSessionId
GetSession->>ChatJournal: Read cursor and restore projection from replay
GetSession->>AcpChatPane: Return session with harnessSessionId
AcpChatPane->>AcpChatPane: Use stored ID when agent.sessionId is absent
Suggested reviewers: Merge Risk: ⚪ Minimal · up to No confirmed new defect blocks merging. A restart before an adapter reports the resumed session ID can still leave that session without a recoverable ID, but that limitation predates this change. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
|
|
Review verdict: minor issues (non-blocking). The fix is correct and CI is green.
chat-runtime tests pass at Full report: https://app.superset.sh/page/pr-8342-review-resume-background-chat-tab-pennbc |
Only the ACP adapter reported harnessSessionId. The Claude SDK and Codex app-server adapters accept a resume id but never reported one, so their chats hit the same blank-chat recovery. Claude now reports the session_id its stream carries, and Codex reports its thread id.
* docs: generate weekly changelog 2026-10-11 * docs(changelog): add 2026-10-11 hero and screenshots Replace the TODO markers with real captures from the dev desktop app: the PR page (hero), the Track tasks in setting, and the Plugins page. * docs(changelog): fix inaccurate 2026-10-11 copy from review Changes tab (not Code), drop in-pane review reply, #8326 is a file move, #8243 and #8342 are acp-chat only, drop 'again' for first-time fixes, inline the CLI commands instead of a non-runnable code block.
Summary
harnessSessionId) on the session row. Rows written before this get it from the journal the next timegetSessionreads them.AcpChatPanerecovers with the host's stored id when the pane has none, instead of starting a new agent session.session_id, and the Codex app-server adapter reports its thread id.Why / Context
A chat that the app adopts into a background tab could open blank later, and switching it to the CLI then failed with "No conversation found with session ID".
listSessionsandgetSessionalways returnedharnessSessionId: null, because nothing wrote it to the row (setHarnessSessionIdhad no callers). An adopted pane starts withagent: { id }and learns the agent session id only from the live stream, which runs while the tab is visible. If a background tab's agent stopped (host restart, agent exit), opening the tab ran recovery with no id. That issession/new: a chat with no history. The pane then saved the new session's id, which has no transcript because the session was never prompted, so the CLI could not resume it.How It Works
ChatJournalkeepsharnessSessionIdin its session cache liketitle: it takes it fromsessionevents, writes it with the projection, and counts a change as a listing change. When it rebuilds a cache from the journal and the row disagrees, it writes the journal's value to the row.getSessionreads the journal cursor before the row, so a row that this read backfills comes back filled.AcpChatPaneusesagent.sessionId ?? stored.session.harnessSessionId. Recovery only runs afterstoredloads. The host change alone is not enough: adoption happens when the chat is created, before the agent reports its id.Manual QA Checklist
Dev desktop over CDP,
acp-chaton. A chat was created on the host and adopted into a background tab, then its agent was stopped (closeSession), and the tab was opened:listSessionsreturns the agent session id; the tab shows the full history; the pane keeps the original id; CLI resumes the same conversationI ran the background-tab flow end to end for both Claude and Codex chats (
claude-acp,codex-acp); both resume their own session in chat and in the CLI. The direct Claude SDK and Codex adapter changes are covered by unit tests only.Testing
bun testinpackages/chat-runtime(243 pass). The new projection, Claude adapter and Codex adapter tests fail on main.bun run typecheckinpackages/chat-runtimebunx biome checkon the changed filesbun run typecheckinapps/desktopreports 28 errors, all better-auth type inference inpackages/authandpackages/trpc. None are in these files.Known Limitations
--resumeleaks a terminal query reply into the prompt.Summary by CodeRabbit
Follow-ups (from review)
createSessionwithresumedoes not store the resumed id on the row until the agent reports it, so a host restart in that short window still recovers blank. Passparsed.resume?.harnessSessionIdtojournal.open.listSessionsdoes not backfill old rows; they listnulluntilgetSessionreads them. Desktop recovery usesgetSession, but mobile's ended-chats list misses old chats until then. Mobile's resume list (NewSessionSheet) now shows entries it never showed before; not tested here.