Skip to content

fix(chat): ask for a sign-in when a resume is refused, and sign in the session's own account - #7993

Merged
illegalcall merged 8 commits into
mainfrom
ao/agent-orchestrator-1-365/login-resume-account-remove
Nov 10, 2026
Merged

illegalcall merged 8 commits into
mainfrom
ao/agent-orchestrator-1-365/login-resume-account-remove

Conversation

@illegalcall

@illegalcall illegalcall commented Nov 8, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Three problems hit when a Claude login expired on an older session:

  1. Raw error instead of a sign-in prompt. Opening the chat ran a resume. The persistent ACP host wraps the refused login, so the error chain was ErrChatDriverUnavailable → ErrAgentAuthRequired. mapSessionError checked the driver/recovery sentinels first, so the user saw CHAT_DRIVER_UNAVAILABLE with "chat driver unavailable: persistent ACP host: agent requires authentication". A refused launch also has no chat controller, so nothing recorded the chat's login demand and the "Log in again" bar never appeared.
    • For a resume (RelaunchError), the auth sentinels now map before the driver/recovery ones, so it returns AGENT_AUTH_REQUIRED. A refused chat spawn keeps CHAT_DRIVER_UNAVAILABLE and its terminal fallback.
    • A chat start refused for its login calls the new Store.RequireSessionLogin, which sets the same demand a refused turn sets (ConversationAccount.RequireLogin, shared with the controller) and records which refusal it was. A pending demand is left untouched. No demand is raised while an account move launches on its target account. The existing ConfirmConversationLogin clears the demand once a reading shows the account is signed in.
    • The bar has no close button. For a local Claude Code or Codex session, the stopped-agent banner (Resume agent, Open shell) is hidden while the bar shows: neither action can fix a login, and an account reading clears the request once the login works, after which Resume agent returns. While the agent is stopped for it, the composer says "Log in to continue" instead of "The controller is not connected". Other harnesses, remote hosts and cloud sessions keep that banner, since resuming is how they find out the login works. Open shell stays on the session's terminal button.
    • RedactError keeps errors.Is matching, so a refusal whose text contains a project env value still maps to a sign-in.
    • Reading a chat that waits for a sign-in no longer takes the writer lock unless a verified turn can clear the demand.
  2. "Log in again" signed in the wrong login. The bar always started this computer's CLI login. It now sends the session's bound account: a saved account starts its sign-in in its own folder (POST /agents/accounts/{id}/login), and this computer's login starts the CLI sign-in from its row once that row can. The button waits until it knows the session's account. Sessions on a remote host or in the cloud keep the existing flow. The request travels as accountLogin in the ui-store, and AgentAccountsPanel takes it once the row has loaded; closing settings drops it.
  3. Removing an account looked stuck. Removal stops the account's agents first, one at a time, and the dialog locks while it runs. ExitAgentsOnAccount now stops them concurrently, and the confirm button reads "Removing…" while the request runs (all 9 locales).

Screenshots

Desktop app in a lab, real Claude Code, same steps on main (8912917478) and on this PR. The email of this computer's own login is replaced with you@example.com.

Before (main) After (this PR)
Opening an older chat whose account's login expired Before: raw driver error, no sign-in bar After: only the Log in again bar, and the composer says Log in to continue
"Log in again" on a chat that runs on the saved account lab-expired Before: the CLI's own sign-in method picker After: lab-expired's sign-in terminal in the accounts list
Removing an account that runs 2 busy chats, 1.2 s after confirming Before: Remove account greyed out, no progress After: Removing…
  • Resume: main shows the raw chat driver unavailable: persistent ACP host: agent requires authentication and no bar. This PR shows only the sign-in bar, and the composer says "Log in to continue"; the daemon itself records the demand from the refused resume. This shot is from bc3cccdb81; the other two are from 00d60ee700.
  • Log in again: main shows no bar for a refused resume, so that shot records the demand by hand. Its click opens the CLI's own sign-in and sends no request for the session's account. This PR sends POST /api/v1/agents/accounts/lab-expired/login (202 in the daemon log), and the sign-in opens in that account's folder.
  • Remove: main keeps "Remove account" greyed out for 5.2 s. This PR says "Removing…" and finishes in 3.2 s.

Evidence (daemon-only lab, real Claude, before/after binaries)

before after
Resume of a chat whose login is refused 409 CHAT_DRIVER_UNAVAILABLE, raw driver message, no demand recorded 409 AGENT_AUTH_REQUIRED, account_json.authenticationState = "required" with reauthRequiredAt
After signing in again + account refresh n/a demand cleared, resume → 200
Remove an account running 4 busy chats 9.15 s 5.55 s

Tests

  • Go: mapSessionError cases for a resume refused for its login (AGENT_AUTH_REQUIRED) and a spawn refused for its login (CHAT_DRIVER_UNAVAILABLE); TestResumeChatRefusedLoginAsksForSignIn (refused login records a demand with its own reason, a Codex-style refusal records the chat reason, an account move and provider down record none); TestLaunchRefusalRaisesTheChatLoginDemand (demand set, plan kept, a repeat refusal keeps the same failure ID, reading the chat while the writer is held returns, login check clears it, a later refusal raises a new demand, unknown session is a no-op); RedactError hides the value and keeps the sentinel.
  • Frontend: ReauthBanner passes the bound account (saved or this computer's), waits for it, and has only Log in again; ChatWorkspace hides Resume agent and says "Log in to continue" in the composer while a Codex login is refused, keeps Resume for opencode, and shows it again once the login works; AgentAccountsPanel starts a requested sign-in exactly once, signs this computer's login in through the CLI once it can, and clears the request; closing settings drops it; the remove dialog shows "Removing…" until the DELETE resolves.

Risks / follow-ups

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

🏆 Review leaderboard

Nov 1–8, 2026 · UTC

Rank Reviewer PRs reviewed Review rounds PR comments
🥇 @ronishrohan @ronishrohan 58 103 17
🥈 @Rishet11 @Rishet11 23 45 19
🥉 @nikhilachale @nikhilachale 12 42 4
4 @somewherelostt @somewherelostt 11 46 1
5 @Meraj-08 @Meraj-08 11 18 0
6 @illegalcall @illegalcall 10 19 3
7 @Prasad-D-Ware @Prasad-D-Ware 10 15 0
8 @Vaibhaav-Tiwari @Vaibhaav-Tiwari 8 9 1
9 @Annieeeee11 @Annieeeee11 7 9 2
10 @Pritom14 @Pritom14 6 7 3

Ranked by distinct external PRs reviewed, then review rounds, then PR comments. Self-activity and bot activity are excluded.

Show 7 more reviewers
Rank Reviewer PRs reviewed Review rounds PR comments
11 @mohakchakraborty2004 @mohakchakraborty2004 4 5 2
12 @neversettle17-101 @neversettle17-101 3 4 3
13 @ApexYash11 @ApexYash11 2 3 0
14 @codebanditssss @codebanditssss 2 2 0
15 @wesleymatosdev @wesleymatosdev 1 2 1
16 @harshitsinghbhandari @harshitsinghbhandari 1 2 0
17 @Vansh-Singhal @Vansh-Singhal 1 2 0

@OrcInc OrcInc added bug Something isn't working comp/daemon Go daemon, process lifecycle, and backend control plane. labels Nov 8, 2026

@illegalcall illegalcall left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: changes requested (one small fix).

Backend looks right: auth sentinels now map before the driver/recovery ones, RequireSessionLogin follows the ConfirmConversationLogin lock+tx pattern and leaves a pending demand alone, the daemon login-confirmed hook clears it, and ExitAgent is gated per session by beginAgentOperation, so stopping different sessions concurrently is safe.

One required change inline: the accountLogin request outlives the settings modal.

Optional (not required):

  • ReauthLogInButton falls back to startLogin (this computer CLI login) while the session/account queries are still loading, so a very fast click still opens the wrong login. Disabling the button until both queries settle would close that gap.
  • requireChatLogin records ErrAgentAuthRequired.Error() as the reason even for ErrChatAuthRequired; harmless since the banner hides the reason.

@illegalcall illegalcall left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: approved.

8aa6325 resolves the previous finding: closeSettings and openProjectSettings now clear accountLogin, and the new ui-store test covers both paths. The rest of the PR is unchanged since the last review.

Optional (from the last review, not required): ReauthLogInButton still falls back to the CLI login while the session/account queries load, so a very fast click can open the wrong login.

@OrcInc OrcInc added this to the Agents & orchestration milestone Nov 8, 2026
@illegalcall
illegalcall force-pushed the ao/agent-orchestrator-1-365/login-resume-account-remove branch from 8aa6325 to 5d1d742 Compare November 9, 2026 05:48

@illegalcall illegalcall left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: approved.

5d1d742 is a rebase of the previously approved head (8aa6325) onto main. git range-diff shows the only change is the icon imports in ChatStatusBanners.tsx and AgentAccountsSection.tsx, which now come from @/components/app-icons after #7903. All icons used (KeyRound, TriangleAlert, LoaderCircle, Trash2, etc.) are exported there. The other three commits are identical, and ChatWorkspace is still the only ReauthBanner call site.

Optional (not required): ReauthLogInButton still falls back to the CLI login while the session/account queries load.

@illegalcall illegalcall left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: approved.

Reviewed e0a3333 on top of the previously approved head:

  • mapSessionError: the auth codes go first only for a RelaunchError (resume), so a refused spawn keeps CHAT_DRIVER_UNAVAILABLE and its fallback; the new test covers both. relaunchErr is the same value the later RelaunchError case reads, so the extra errors.As has no side effect.
  • RedactError: redactedError has no Unwrap, so the cause is still unreachable by errors.As/telemetry; only errors.Is sees through, which exposes no text.
  • ReconcileConversationAuthentication: the read-only evidence check now runs on the reader, and only a verified turn takes the writer, where the tx path re-checks the evidence, so there is no TOCTOU. The new held-writer test proves the read path no longer blocks.
  • requireChatLogin skips a session with a pending account move and records the matching sentinel as the reason.
  • Frontend: the button is disabled until the session account query settles and passes the bound account id, device included. AgentAccountsPanel waits for cliLogin to be enabled before calling onSignIn for the device row, and uses the per-account sign-in otherwise. HarnessAccountTab renders the panel for any local installed Claude/Codex harness, so the request is consumed, and closeSettings drops it otherwise.

No changes required.

@illegalcall illegalcall left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: changes requested.

ca04e72 hides the stopped-agent banner (Resume agent / Open shell) while a sign-in demand is pending, and removes the bar dismiss button. This can leave a chat stuck with no way forward; details inline.

The rest is fine: needsReauth matches ReauthBanner own required check, so the two never disagree, and both render under the same HoldWhileHidden.

@illegalcall illegalcall left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: approved.

5ae8079 resolves the previous finding. Resume agent is hidden only when needsReauth holds for a local Claude Code/Codex session (agentAccountProviderFor(harness) !== null, no remote host, not cloud), which is exactly where the daemon login-confirmed hook can clear the demand. ACP-family harnesses, remote hosts and cloud sessions keep the stopped-agent banner with Resume. The parameterised test covers codex (hidden) and opencode (kept).

Optional (not required): a local Claude/Codex login that no account reading can confirm (for example a token login with no usage reading) would still rely on the hook. If that shows up in practice, a secondary Resume under the sign-in bar would cover it.

@illegalcall
illegalcall force-pushed the ao/agent-orchestrator-1-365/login-resume-account-remove branch from 5ae8079 to 2fcca42 Compare November 9, 2026 11:49

@illegalcall illegalcall left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: approved.

2fcca42 is a rebase of the previously approved head (5ae8079) onto main (6f4f941). git range-diff shows only the conflict resolutions, and each one keeps main side:

  • context lines from main AO to Orchestrator rename (CHAT_RESUME_FAILED message, settings.agentAccounts.removeDescription in all 9 locales); the new removing keys are unchanged.
  • the Log in again button now uses main variant="secondary" in place of outline, still with the isPending disable.

Commits 3, 4, 6 and 7 are identical. No changes required.

@illegalcall illegalcall left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at bc3cccdb81. Nothing needs to change.

The new commit lifts the existing sign-in condition into one signInRequired const, which the controller banner and the composer now share. While that condition holds and the controller is stopped, the composer placeholder becomes "Log in to continue" instead of "The controller is not connected". This branch sits after the terminated, resuming and reconnecting branches, so those states keep their own text. ACP-family, remote and cloud chats keep the old text, matching where Resume agent stays visible. The new key is in all 9 locales, and the updated test covers both harness cases and the return to the old text after authentication.

This head is the same as the previously approved 2fcca4225b plus this commit. No other files changed.

illegalcall and others added 8 commits November 10, 2026 16:41
…e session's own account

Opening an older chat whose Claude login had expired showed the raw
"chat driver unavailable: persistent ACP host: agent requires
authentication" error, and no sign-in prompt. The resume error now maps
to AGENT_AUTH_REQUIRED before the driver/recovery wrappers, and a launch
refused for its login records the chat's login demand, so the "Log in
again" bar shows until a reading confirms the account is signed in.

"Log in again" now signs in the saved account the session runs on, in
its own folder, instead of this computer's CLI login. Sessions on the
CLI's login, remote hosts and the cloud keep the existing flow.

Removing an account stops its agents concurrently (9.2 s -> 5.6 s for
four busy chats in the lab), and the dialog's button reads "Removing…"
while it runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hows

ReauthBanner mounts for every chat that has account state, so its query
hooks ran on chats with no login demand and broke chat tests rendered
without a QueryClientProvider. The lookup now lives in the bar's button,
which mounts only when a sign-in is required.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A "Log in again" request the accounts list never took stayed in the
store after Settings closed or project settings opened, so a later
mount of that account's row could start a sign-in nobody asked for.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Only a refused resume maps to the sign-in codes first; a refused chat
  spawn keeps CHAT_DRIVER_UNAVAILABLE and its terminal fallback.
- Log in again passes the session's bound account, including this
  computer's login, which the accounts panel signs in through the CLI;
  the button waits for the session's account instead of guessing.
- Reading a chat that waits for a sign-in no longer takes the writer
  unless a verified turn can clear the demand.
- An account move's refused launch no longer raises a demand on the
  account the session still runs on.
- A redacted launch error keeps errors.Is matching, so a refusal that
  mentions a project env value still reads as a sign-in.
- The demand records which refusal it was.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A refused login stops the agent, and neither Resume agent nor Open shell
can fix it. While the sign-in bar shows, the stopped-agent banner stays
hidden, and the bar has no close button: signing in is the one way on.
Once the login works the bar goes away and Resume agent returns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only a local Claude Code or Codex session gets its sign-in request
cleared by an account reading. Other harnesses (the ACP family), remote
hosts and cloud sessions keep the stopped-agent banner with Resume
agent, which is their way back once the login works.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s required

The composer said "The controller is not connected" under the sign-in bar.
While the login is refused and the agent is stopped, it now asks for the
sign-in that unblocks the chat.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@illegalcall
illegalcall force-pushed the ao/agent-orchestrator-1-365/login-resume-account-remove branch from bc3cccd to ab6748b Compare November 10, 2026 11:15

@illegalcall illegalcall left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at ab6748b594. Nothing needs to change.

This head is the previously approved bc3cccdb81 rebased onto main d429710c18. The range-diff shows only conflict resolutions, and each keeps both sides:

  • chat_spawn.go resumeChatController: main's imported-session ErrSessionOpenElsewhere return now runs before requireChatLogin. That order is right: another app holding the chat is not a refused login, so it must not record a sign-in demand.
  • ChatStatusBanners.tsx: the Download import and ImportedAgentBlocked from main stay next to the ReauthBanner changes.
  • ChatWorkspace.tsx: main's open-elsewhere recheck and the ImportedAgentBlocked / AgentBlock imports stay next to the signInRequired prop and agentAccountProviderFor import.

Commits 2-4 and 8 are unchanged.

Optional: if one chat shows both a pending sign-in and "open elsewhere", the sign-in bar hides the open-elsewhere banner while its timed recheck keeps running. That combination is unlikely and harmless, so it does not need a change here.

@illegalcall
illegalcall merged commit d1143d5 into main Nov 10, 2026
50 of 52 checks passed
Annieeeee11 added a commit that referenced this pull request Nov 12, 2026
Brings in main's deflake of the session-switch streaming smoke test
(#8044), which failed renderer-smoke here, and resolves the conflicts
with main's sign-in work (#7993):

- The chat's Log in (band and banner) now signs in the saved account the
  session runs on, as main's banner does, and falls back to the CLI login
  only when that account is not known yet. The chat reads the account as
  soon as a login is on offer, so the click needs no wait.
- The banner keeps main's shape (no dismiss button); a chat passes its own
  Log in, and other uses keep main's account lookup.
- Both sides' i18n keys, store types and Timeline props are kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working comp/daemon Go daemon, process lifecycle, and backend control plane.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants