Skip to content

feat(claude-chat): native Claude chats are registry rows, follow the pool and move through the proxy - #37573

Closed
nachumi-a2zoperations wants to merge 24 commits into
stablyai:mainfrom
A2Z-Operations:pr/native-chat-account-coverage
Closed

nachumi-a2zoperations wants to merge 24 commits into
stablyai:mainfrom
A2Z-Operations:pr/native-chat-account-coverage

Conversation

@nachumi-a2zoperations

Copy link
Copy Markdown

ELI5

Native Claude chats now count as sessions: they appear in the account switcher and account list, they can start on the pool's choice, and they move to another account through the auth proxy without stopping. Chats without a proxy slot are left to #36649's carry-over.

What Changed

  • A chat is a registry row keyed by its structured pane key (the same key the hook status row uses), with surface: 'chat', providerSessionId, worktreeId, launchSelectionId, assignedAccountId, proxySlot, source.
  • Account order per turn matches a terminal launch: remembered resume account → recorded account while the selection is unchanged → new selection or pool. A user CLAUDE_CONFIG_DIR skips the pool; a user ANTHROPIC_BASE_URL is kept and the record pinned.
  • Slot reuse across turns (the fresh slot is released when the recorded one is live), forgotten only on a proved close so an unexpected exit can respawn the same session.
  • Mover: proxy strategy only for chats; no slot → skipped with structured-needs-proxy, no hand-off note. History records chat: true.
  • Surfaces: sessions: 3 (1 chat); move lines append chat; the chat tab gets the account chip; the phone's chatStatus.claudeAccountId carries the billed id.

Why

#36676. Composes with #36649 (which moves a slot-less chat on its next message by carrying the conversation over). Details in the #36676 comment.

Linked Issue

#36676, #36649. Stacked on the pool PR (the chat launch uses the pool's choice).

Visual Proof

account list with a (1 chat) row; a chat tab's account chip changing after a move while the conversation continues.

Testing

Structured launch home, pane-account choice, session key, close, registry, mover sessions/evaluation/history, list format, move line, mobile tab status, tab chip: 42 tests on the files this PR changes, plus the quality gate on the final sha; full check-changed on the gated sha 28/30 → the one quality finding (duplicate import) fixed on the final sha, unit = Mac-local.

  • I manually tested these changes locally
  • Automated tests added/updated

The registry names the account a pane consumes. Automatic switching stays off until it is turned on, and a headless host keeps usage polled while it is on.
The polling switch takes the settings it actually reads. Tests stamp a fixed expiry and a stepping file mtime so the flaky-clock ratchet stays at its baseline.
The command is already in the account spec and the site reference. The root help is the list a user sees first.
The account commands read --on and --off as bare switches, but registering them as global boolean flags broke `orchestration worker-start --on <server>`, whose --on takes a value. The argument parser already treats a flag followed by another flag or by nothing as a switch, so the account commands keep working without the global entry.
The data-account snapshot helpers move beside the controller.
The proxy stays off unless claudeAuthProxy is true. Each launch gets a loopback slot URL in ANTHROPIC_BASE_URL unless the user set one; the pane registry records the slot and the account it bills. The session mover's proxy move strategy is not part of this change.
A launch and a quota poll each kept a slot the pane never used, so a headless status listed leftovers while account list showed sessions: 0. Forget, status, and the spawn merge now drop those slots, and a reattach into an empty registry records the live account without storing a slot the process did not receive.
… policy RPCs within the line limit.

The pane registry learns a launch at spawn commit, so the proxy slot and billed account of every live pane are known. The Claude policy RPC handlers and the data-account snapshots move beside the account controller, and the account CLI group gets its own module, so no file exceeds the lint budget. The two proxy tests that time a real idle timeout and a real stop() say so; the slot prune test runs on a fixed clock.
The 200 ms idle timer and the socket reset can land late when the full suite runs; the test still proves the idle cut happened after the budget.
…a loaded machine.

The ticks come every 40 ms; a 2 s idle budget still proves a writing stream is kept while a loaded suite cannot cut it by delaying one tick past 200 ms.
The default is ask, and a headless host treats ask as move. A quiet wait lets background work finish, and the hand-off note still lists jobs when the job script is absent. With the auth proxy on, a move retargets the pane's loopback slot instead of restarting Claude.
The hand-off calls the durable-job listing through Reflect.apply, and the stop handle starts unset through a helper. Both stay typed without a cast.
orcad and the CLI import the language detector, so the desktop entry binds the Electron read. Root help now lists auto-switch and session-mover, the account commands this branch ships.
anti-slop rejects Reflect.apply. The hand-off note checks the script export and calls it.
The session-mover command reads them as bare switches; the parser already treats a flag followed by another flag or by nothing as a switch, so no global boolean entry is needed.
Off unless claudeAccountPool is 'on'. An Orca-made Claude launch then starts on the signed-in account with the most room left, the pane registry records the pool pick, and the rebalancer moves a session whose account runs out ahead of the others. `orca account pool --on|--off`, `orca account moves`, the Settings row, the status-bar Pool badge with per-account session counts, and the tab chip come with it.
…like terminal panes.

A chat session's launch records itself in the pane registry under its session key, so the pool can pick its account, the auth proxy gives it a slot that later turns reuse, the mover can move it, the account list counts it, and the tab chip and the phone show the account it bills. Closing the session forgets the record.
@nachumi-a2zoperations
nachumi-a2zoperations force-pushed the pr/native-chat-account-coverage branch from c8874dc to d6ebc61 Compare November 6, 2026 14:23
@nachumi-a2zoperations

Copy link
Copy Markdown
Author

Closing this stack (#37567 to #37573). We have since moved this account work into a plugin built on the Orca plugin system, so it no longer needs to live in core. What the plugin needs from Orca is proposed in #43379 and #43389. Thanks for the reviews along the way.

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