Skip to content

feat(sessions): follow a provider-originated session switch (Claude /clear, OpenCode /new) instead of quarantining it #894

Open

Description

@Juliusolsson05

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: /clear or /resume.
  • OpenCode: /new, /sessions or 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:

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.providerSessionId with a new source;
    • reset the per-session JSONL provider stream state;
    • clear or replace the entries;
    • load history for the new session.
  • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    class:C2-identityIdentity/ownership across reload, replace, restore, wakeprovider:claudeAffects Claude Code integrationprovider:codexAffects Codex integrationprovider:opencodeAffects OpenCode integrationtype:featureNew capability (out of quality-loop fix scope)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions