Repository navigation
Description
Status (quality-loop audit, 2026-09-25)
Landed: The contract exists: provider-session-changed on AgentSessionEvents, forwarded end to end (arrived with Pi, #1140).
Remaining: Only Pi emits it. Claude (/clear, /resume) and Codex never emit it. OpenCode Terminal still turns session-switched into a provider_session_switched error (opencodeTerminalSession.ts:286-295).
Acceptance: Claude, Codex and OpenCode emit it from signals the provider itself proves. Every surface follows the new session, and an unrelated id still quarantines.
Original report
What happens
A provider can move to a new session from inside its own TUI:
- Claude Code:
/clearor/resume. - OpenCode:
/new,/sessionsor fork.
Agent Code panes stay bound to the provider session they were launched with. There is no way to follow a provider-originated session change:
- Claude / Codex: the new session's committed entries hit the Claude JSONL transcript can disconnect while proxy/semantic stream stays live, breaking resume identity #290 quarantine (
decideJsonlProviderBurst/applyJsonlProviderSessionIdinuseIpcSubscriptions.ts). The pane shows "Ignored JSONL from provider session X because this pane is bound to Y". - OpenCode Terminal: since feat(opencode): OpenCode Terminal reports status, turns, conditions and history through opencode-terminal-headless #882 the switch is detected and shown as a pane error, but status, transcript, MCP reads and resume stay on the old session.
Why
Nothing in the session contract can say "the provider itself moved to session Y". Today a different provider session id is indistinguishable from a misattach, and #290 deliberately refuses those.
Suggested direction
- Add an explicit, provider-originated
provider-session-changed { from, to, locator }event to the AgentSession contract. Only an adapter that can prove the change from the provider's own signals emits it. - In main, update the resume id and the transcript locator.
- In the renderer:
- rebind
meta.providerSessionIdwith a new source; - reset the per-session JSONL provider stream state;
- clear or replace the entries;
- load history for the new session.
- rebind
- Keep Claude JSONL transcript can disconnect while proxy/semantic stream stays live, breaking resume identity #290's quarantine for everything else.
- For OpenCode, the package would also rebind its durable reader and live projector to the new session.
Acceptance
After a switch inside the TUI, a pane's status, transcript, MCP reads, phone view and restart-resume all follow the new session. An unrelated provider id still quarantines.
Refs #864
Activity
fix(opencode): stop losing prompts to a booting TUI, and admit sessio…