Skip to content

Choose and switch accounts for an individual conversation #7984

Open

Description

@ozeitis

Updated October 9, 2026: I now have a local implementation; this replaces the initial pre-implementation proposal.

I use Superset daily with several Claude accounts. Sometimes one chat hits its limit while another account still has capacity. I want to continue that same conversation on the other account without changing my project default or the accounts used by my other chats.

I built a local version with:

  • A choice of existing accounts for new chats and a visible account label.
  • A saved account binding when reopening a chat.
  • An explicit switch for an existing conversation that resumes its saved session in the same working folder.
  • Recovery for ended conversations, with visible errors when identity or safe continuation cannot be established.

The intended scope covers terminals and Superset's native chat view. Switching resumes saved history; running tools and background jobs do not move between accounts. It does not automatically send a message.

I saw #7915, #7954 and #8005. I'd like to align this with that work and agree on how conversation choices interact with project and default accounts.

I can split the contribution into selection/binding first, then switching/recovery. Imports, usage improvements and optional account displays would be separate proposals. I've used and tested the local fork on macOS; each extracted PR would still need fresh checks and a reproducible recording.

Does this fit the direction you want, and which account/recovery work should I build on?

Activity

  1. github-actions commented on Sep 30, 2026

    @github-actions
    Contributor

    This is a feature request, but it points at a real gap that could be fixed on its own first: a Claude session started from a second, account-pinned agent config does not keep its account when resumed. I read the code (no tests run), and the problem is broader than the issue says. The config UUID is lost on every launch, not only on resume.

    Summary. The proposal is to let a user pick a Claude account (a Claude agent config pinned to its own CLAUDE_CONFIG_DIR) for each session. It also asks for a "Switch account" action that stops the process and resumes the same provider session under a different account, without changing the host-wide default account. The launch side already works per config. The resume side does not track which config a session came from, so a pinned session can come back under the wrong account.

    Affected code

    • Launch env. packages/host-service/src/terminal-agents/agent-config.ts:101-106: agentLaunchEnv puts config.env on top of resolveDefaultAccountEnv. So a config with its own CLAUDE_CONFIG_DIR launches under that account. This part works.
    • Config lookup. agent-config.ts:73-93: resolveHostAgentConfig matches by config UUID first. If that fails, it falls back to the first row with that presetId, ordered by displayOrder. With two Claude configs, looking up "claude" always returns the first one.
    • Binding on resume. packages/host-service/src/trpc/router/agents/agents.ts:469-486: bindResumedSession records agentId: presetId (for example "claude") and no config id.
    • Binding on any launch. packages/agent-setup/templates/notify-hook.template.sh:268: the hook payload sends only agentId and sessionId. notifications.ts:17-23 accepts definitionId, but no hook template sends it.
    • Resume lookup. terminal-agents.ts:135-138 (resumeTerminalAgentSession), :223-226 (listAccountRestartCandidates), :449-452 (resumeCandidate), and agents.ts:563-566 (continuationTarget) all look up binding.definitionId ?? binding.agentId.
    • Id format. terminal-agents.ts:369-372: agentDefinitionIdSchema only accepts builtin ids or custom:<name>. definitionId was not built to hold a HostAgentConfig UUID.

    Suspected root cause

    For a Claude session, the binding's definitionId is always empty, so resume falls back to agentId ("claude"). resolveHostAgentConfig then returns the first Claude config by displayOrder, not the one the session was launched with. Resume runs runAgent({ agent: config.id, resumeSessionId }) (terminal-agents.ts:154-159). So a session started from "Claude (work)" resumes under whatever CLAUDE_CONFIG_DIR the first Claude config resolves to, possibly the default account. The docstring at terminal-agents.ts:114-116 states this outright ("the pane comes back as the same agent on the current default account").

    What follows from that, depending on whether the two profiles share session state:

    • Profiles not shared (for example, not set up through usage.prepareAccount, usage.ts:296): the transcript lives only in the other config dir, and claude --resume <id> finds nothing.
    • Profiles shared: the conversation resumes, but under the wrong account.
    • "Never prompted" check: hasSession (bindingHasHarnessSession) resolves the same wrong config, so it may look in the wrong session store.
    • Bulk restart: listAccountRestartCandidates filters on the resolved config's presetId, so a pinned session also shows up as a candidate when the default account changes.

    The binding already stores account (store.ts:228-232, set from the hook's accountProfile). That records which account a session used, but resume never uses it to choose a config.

    Reproduction

    1. In Settings → Agents, create two configs with presetId: "claude". Set A's env.CLAUDE_CONFIG_DIR to profile X and B's to profile Y. A must have the lower displayOrder.
    2. Launch B in a workspace and send a prompt so a session id is captured.
    3. Kill the terminal or the host daemon, then let resume run (the pane's resume action or the automatic sweep).
    4. Expected: the process relaunches with CLAUDE_CONFIG_DIR=Y. Likely actual: it relaunches with X, labelled as A.

    A bun:test sketch next to terminal-agents.test.ts:

    • Set up: insert two Claude configs in a test HostDb, and record Attached then Stop for terminal T with agentId: "claude" (what the hook sends today).
    • Act: mark T as dead and call resumeTerminalAgentSession with a stub runAgent that captures its input.
    • Assert: runInput.agent equals config A's id, not B's. The same stub can show that bindResumedSession writes no config id.

    Fix direction

    This could ship before any of the UI work:

    1. Store the config UUID on every binding. Add a column (for example agentConfigId) instead of reusing definitionId, whose schema rejects UUIDs. Two ways to fill it:

      • Export the UUID into the PTY env at launch (next to launchId / the attribution token), and have notify-hook.template.sh send it back.
      • Or record it host-side in runTerminalAgent, keyed by launchId.

      Also pass it through bindResumedSession.

    2. Use it on resume. Have resumeTerminalAgentSession, resumeCandidate, continuationTarget, harness-session-ref.ts:40 and listAccountRestartCandidates prefer the stored UUID. They should fall back to definitionId ?? agentId only for old rows.

    3. Keep pinned sessions out of default-account restarts. In listAccountRestartCandidates, skip configs whose env sets their own CLAUDE_CONFIG_DIR / CODEX_HOME. Otherwise changing the default restarts pinned sessions for no reason.

    4. Build the switch on top. "Switch account" can then be resumeTerminalAgentSession with an explicit destination config id. It would add the safeguards the issue lists:

      • check the destination's auth before stopping the source;
      • keep model, effort and mode;
      • roll back to the source if the launch fails.

      The existing claim/unclaim and the in-flight guard in resumeInflight (terminal-agents.ts:123-201) already cover "only one writer" for a single terminal.

    5. Account registration. Creating a presetId: "claude" config after prepareAccount fits the existing model: duplicate preset ids are allowed, and model and effort validation keys off resolveAgentLaunchPresetId (agents.ts:395-406). The custom-agent form at NewCustomAgentDetail.tsx:69 hardcodes presetId: "custom", so it isn't the right entry point.

  2. changed the title [-]feat(desktop): select Claude accounts per session and switch through exact-session resume[/-] [+]Choose and switch accounts for an individual conversation[/+] on Oct 9, 2026
  3. ozeitis commented on Oct 11, 2026

    @ozeitis
    Author

    The implementation is now in focused, non-draft PRs. Each body links its focused review diff excluding prerequisites and test evidence.

    Change PR Prerequisite
    Persist terminal account identity #8401 Main
    Choose an existing account for new Claude/Codex terminals #8460 #8401
    Resume an ended native conversation with another account #8461 #8460
    Persist native ACP account context and recovery receipts #8402 Main
    Bind accounts to the existing native ACP chat path #8462 #8402 and #8460
    Invalidate quota caches when credentials change #8464 #8460

    The independent fixes are also ready: quota refresh ordering #8399 and composer acceptance #8400. Saved native Claude adoption and its storage are indexed in #8358.

    The final combined checkpoint passed the standard full suite: 29 tasks, 15,920 passing tests, zero failures, four skips and eight todo cases, plus lint and all 41 typecheck tasks. The real Node/PTY gate passed 56 tests with two unavailable fish-shell cases skipped. Qualification and recordings distinguish isolated Electron journeys from component demonstrations.

    This reuses the existing launchers, bindings, ACP commands/journal, queues and recovery UI. It respects the upstream ACP rollout flag. Recovery is for ended sessions with shared canonical history; it does not transfer live tools or send prompts. Codex also requires shared writer locks. Account-bound ACP forks/handoffs and terminal-to-ACP conversion remain outside this slice.

    Hosted workflows need maintainer approval for this first-contributor set. Authenticated Claude/Codex replay is not claimed. The PRs target main and include prerequisite ancestry until those prerequisites merge.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions