Skip to content

fix(providers): show rejected logins and sign in again from the app - #696

Merged
nixuuu merged 2 commits into
devfrom
fix/expired-provider-login
Nov 14, 2026
Merged

nixuuu merged 2 commits into
devfrom
fix/expired-provider-login

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Change

A Codex turn failed with "Your provider login was rejected or has expired" (unauthorized, refresh token expired), but Settings → Providers still said Authenticated · ChatGPT / Signed in: codex login status only reads auth.json. The built-in Device login instance had no in-app sign-in, so Sign in only opened settings and Retry failed the same way.

  • Gateway mark. A turn that ends with an auth_required failure makes the gateway re-read that instance's account on that worker and remember it (worker/provider/instance, in memory like the rest of the account report) with the login file's revision. While the mark holds, the account state is expired ("Sign-in expired", detail "The provider rejected this login during a turn. Sign in again."). The mark clears when the login file changes (sign-in from the app or a terminal, token refresh), when a turn on that instance succeeds, or, for logins without a file (macOS keychain), after a manual Refresh. Proxies and API keys never get it. Same for Claude and Grok.
  • Login revision. Workers report ProviderAccountStatus.login_revision (additive field 13): a hash of the login file's inode, size and mtime, never its content. The gateway strips it before clients.
  • Sign in from the error. For Codex device-login instances, Sign in under the failed turn starts the ChatGPT device-code sign-in in place and shows the code. New worker capability codex_device_login_linked: an instance on the device login signs the device's Codex in again (CODEX_HOME = the device's Codex home, as codex login would; no managed plugins written there). After a successful sign-in, the instance's Codex process restarts once it is idle.
  • Retry. Retry is disabled while the account is marked; the hint says "Sign in with ChatGPT, then retry."
  • Settings. Every Codex device-login instance shows Continue with ChatGPT / Sign in again with ChatGPT (with "This also signs in the Codex CLI on ." for the device login). The account row always offers the sign-in command ("Sign in again" when the account looks fine). The status line reads Sign-in expired.
  • Mobile. Provider accounts and the instance worker screen show "Sign-in expired" (mobile has no Retry or sign-in on the error card).
  • Worker capability list moved to apps/worker/src/capabilities.ts (main.ts was at the 400-line limit).

Security review follow-up (9d06ba6):

  • StartProviderLogin needs strict ownership: workers.owner_user_id must equal the caller. Platform-wide workers (owner_user_id IS NULL, visible to several owners) are refused. The method is no longer in SERVED or WORKER_SETTINGS, so linked computers can't start it, and the home refuses a direct call over the link.
  • Turn outcomes of one worker update its accounts in arrival order (a per-worker queue). A rejection still waiting on its forced account read can no longer overwrite a later successful turn.
  • Sign in under a failed turn first says which computer it changes: "This also changes the Codex CLI account on , as codex login does." It starts only after Continue with ChatGPT. Settings uses the same sentence.
  • The device code stays until that sign-in finishes or fails. The worker reports ProviderAccountStatus.login_id / login_outcome, and StartProviderLoginResponse.login_id names the sign-in to wait for. A failed sign-in shows "The sign-in did not finish. Start it again."
  • One sign-in per instance: the gateway shares concurrent starts per owner and target, and the worker returns the running sign-in's code instead of starting a second process.

Credentials stay where they were: tokens never leave the CLI home, nothing is logged, and every read stays owner-scoped.

Verification

  • bun install, bun run gen:check, bun run typecheck, bun run lint, bun run format:check: clean.
  • New gateway↔worker test tests/integration/provider-sign-in-expired.test.ts with a fake Codex app-server (fixtures/login-codex.ts): a turn fails with unauthorized / refresh-token-expired → ListProviderInstances and the overview show expired (no login_revision leaks); a forced Refresh keeps it; StartProviderLogin on the built-in device-login instance writes the device home's auth.json → signed_in; the next turn succeeds. A second case clears the mark with a successful turn when the login file did not change.
  • Follow-up tests: a held account read for a rejection plus a later successful turn ends signed_in (this test fails with the queue bypassed); concurrent starts share one login_id and the account reports signed_in for it; a platform-wide worker refuses sign-in; a linked computer can't start one, through its own API or directly over the link (config-sync-workers). Not checked in a browser: the new confirmation step.
  • Focused: provider-accounts.integration, provider-account-status, provider-instances, provider-error-turns, codex-connections, apps/worker/src/providers, apps/gateway/src/core: all pass.
  • Web build: OK. Mobile: typecheck OK, expo export iOS and Android OK, EAS fingerprints unchanged against dev (iOS f05d9756…, Android c0977af9…).
  • Browser check (review stack: gateway, worker and web built from this branch; Codex replaced by the fixture app-server with an expired device login; Claude and Grok off):
    • a Codex turn fails with unauthorized. The card shows "Sign in with ChatGPT, then retry.", Sign in, and a disabled Retry;
    • Settings → Providers shows "Sign-in expired" in the instance list, the status line and the account row (with the detail), plus Sign in again with ChatGPT and "This also signs in the Codex CLI on Review laptop.";
    • Sign in on the card shows the device code in place. When the worker reports the new login, the code goes away and Retry turns on. Retry then runs a turn that completes;
    • checked in light at desktop width and in dark at phone width (375 px). Nothing overflows, and the code panel wraps.
    • Not checked: very long worker names (the code panel and login hint use break-words).

Copy audit (docs/copy.md §8)

Where Before → after Why
Status line (Settings → Providers) Authenticated · ChatGPT → Sign-in expired (when a turn rejected the login) Says what happened; amber, not colour alone (text).
Account row state Signed in → Sign-in expired Same term as the status line.
Account row detail (new) — → The provider rejected this login during a turn. Sign in again. What happened, then what to do; active voice; 2 sentences ≤ 10 words.
Account row button Sign in (only when signed out/expired) → also Sign in again when signed in Verb first; re-login is always reachable.
Login panel (device-login instance, new) — → This also signs in the Codex CLI on <worker>. One sentence; names the side effect.
Turn error hint (Codex, app sign-in) Sign in from provider settings, or run codex login on the worker using this instance's CLI home. → Sign in with ChatGPT, then retry. Shorter; the button does the action; says why Retry waits.
Turn error, sign-in start failed (new) — → <reason> Open provider settings Error plus the action.
Sign-in confirmation (failed turn, new) — → This also changes the Codex CLI account on <worker>, as codex login does. / This signs in only this instance on <worker>. + Continue with ChatGPT, Cancel Names the affected computer before acting; same sentence as Settings.
Login panel note (Settings) This also signs in the Codex CLI on <worker>. → This also changes the Codex CLI account on <worker>, as codex login does. Says that the account changes, and how.
Sign-in failed (new) — → The sign-in did not finish. Start it again. What happened, then what to do.
Device code unchanged (Open the link, sign in with ChatGPT and enter this code. It expires in 15 minutes., Waiting for the sign-in on <worker>…) Reused as a shared component.

Glossary: "instance", "worker", "turn", "provider" used as defined; no banned synonyms. No new "soul" sentences. Long worker names wrap (break-words) in the code panel and login hint.

Fixes an earlier change: #125

codex login status only reads auth.json, so an expired refresh token still showed "Signed in" while every turn failed with unauthorized. A turn rejected for its login now marks the account as needing sign-in on the gateway until the login file changes or a turn succeeds; Sign in under the error starts the ChatGPT device login, also for instances on the device login, and Retry waits for it.

Fixes: #125
Device login replaces the CLI login of the worker's computer: only the worker's own owner may start it, never on a platform-wide worker or from a linked computer. Turn outcomes of a worker update its accounts in arrival order, the UI confirms which computer a sign-in changes and waits for that sign-in's own outcome, and concurrent starts share one login.

Fixes: #125
@nixuuu
nixuuu merged commit c8bf274 into dev Nov 14, 2026
10 checks passed
@nixuuu
nixuuu deleted the fix/expired-provider-login branch November 14, 2026 09:46
nixuuu added a commit that referenced this pull request Nov 14, 2026
Canopy previously showed no provider plan limits. This adds durable
account snapshots from official harnesses, compact provider settings
meters, composer warnings at 90%, reached-limit notices, and
limit-specific failure headings on web and mobile.

- Codex 0.164.0: read limits at app-server startup/account read and
forward account notifications. Preserve the reported 5-hour/weekly
percentages and resets; discard credit balances.
- Claude Agent SDK 0.3.316: merge rate-limit events, recognize official
warning/error/transition prefixes, and optionally read usage from an
existing active session at most once per 15 minutes. Paid-turn notices
stay visible outside collapsed activity, including after success.
- Store sanitized snapshots per worker/provider/profile and runtime/home
identity. Reject obsolete reports and enforce worker/instance ownership.
Deliver changed workers through the existing incremental overview
stream. Bot and text-generation harness events update the same source
account.
- Add migration 0141 and additive protobuf fields with generated
contracts. Keep expired-login handling separate.

### Billing boundaries

Codex reports credit availability, **not whether this turn uses
credits**. An exhausted plan with available credits therefore says “Plan
limit reached. Further turns may use credits.” Claude's explicit
extra-usage signal shows the account state and preserves “This turn uses
extra usage credits.” in the thread.

Neither pinned harness exposes a supported per-turn switch that prevents
paid fallback. There is no fake stop setting, direct provider API call,
reset-credit action, or inferred billing from token/cost data. Grok ACP
exposes no account plan windows, so nothing is shown. A harness may
report a transition after work starts; Canopy cannot promise pre-charge
prevention.

### Validation

- Install, generation consistency, whole-repo typecheck, lint,
formatting, and web production build passed.
- Focused checks passed: 57 tests covering official fake Codex/Claude
harnesses over WorkerHost/gRPC/Postgres, startup and account refresh
after notifications, changed runtime identity, incremental delivery,
restart/offline persistence, owner scoping, stale reports, error
mapping, bot collection, adapter shutdown, and schema checks. The final
turn/adapter rerun passed 9 tests.
- Full `check:tmp` completed with 2,978 passed, 175 skipped, and one SQL
diagnostics failure. The usage query now uses the existing
`workers.store` diagnostics family; its rerun passed. CI also caught
loss of Codex's original error code without a reported plan window; that
code is now preserved. All 41 bot/usage/diagnostics regression tests
passed after both fixes. The full suite was not repeated locally.
- iOS and Android exports passed. Native fingerprints exactly match dev:
iOS `138e0c6b171c82b4933e86808cdfef56da73b8c6`, Android
`906dc944f94eb8333fa384ed9f198834fdd30d13`.
- Manual browser review used real isolated gateway/worker fixtures:
light/dark, desktop/390 px phone, settings meters, 92% composer warning,
reached-limit heading, and visible paid-turn notice with activity
collapsed. Short, typical, and long labels stayed within the viewport.
Review services/container and temporary checkout were removed. Native
simulator visuals remain unverified: device discovery twice failed with
“Could not communicate with device support.” No live provider tests or
charges.

Rebased onto the expired-login change (#696), retaining its sign-in flow
and adding meters alongside it. Regenerated contracts preserve both
additive changes; migration 0141 remains the next number on dev. On the
rebased head, generation consistency, typecheck, lint, formatting, web
build, both mobile exports, and all 45
usage/bot/diagnostics/expired-login tests passed. New CI checks are
running; no review has been submitted.

### Copy audit (§8)

| Before | After | Reason |
|---|---|---|
| No usage text | “5-hour · 25% used”, “Weekly · 92% used”, localized
reset times | Name the reported window and keep meters compact. |
| No near-limit action | “Weekly limit 92% used · resets …” + “Check
usage in provider settings” | State the condition and provide an action
without blocking the composer. |
| Generic failure heading | “Weekly limit reached · resets …” | Preserve
the window/reset from the failed turn; retain existing actions and
technical details disclosure. |
| No billing notice | “Extra usage credits are active.” for account
state; “This turn uses extra usage credits.” for durable turn history |
Distinguish current account state from the specific turn, using explicit
harness signals. |
| No Codex credit warning | “Plan limit reached. Further turns may use
credits.” | Credit availability alone cannot establish that a charge
occurred. |

New copy uses short active sentences, sentence case, glossary terms,
localized numbers/dates, visible text alongside meter colours, and live
status announcements. No new empty states, destructive actions, jargon,
blame, or humour. Long-name and phone-width review passed; unavailable
data stays hidden.
nixuuu added a commit that referenced this pull request Nov 14, 2026
## Problem

Settings → Providers → Grok on two linked computers showed **Changed on
two computers** with two rows: "Connects with" (Endpoint) and "Proxy" (A
different proxy). **Restore** failed with "Computer link operation
failed. Check the address, code and Network access settings." The link
itself was fine.

## Root cause

Not #696. The remote policy and the device-login refusal are not
involved: Restore runs locally (`manageConfigNotice`).

- Restore wrote `kind` or `proxy` **alone** (one history row per field).
For example, the instance ended up `native` while still pointing at the
proxy. `applyInstance` stored `proxy_id` on a native instance.
`instanceSync` then copied the proxy's base URL and key onto it (`UPDATE
provider_instances … FROM proxies`), and Postgres refused the row:
`provider_instances_endpoint` (non-endpoint instances must have no base
URL and no key).
- `computerGuard` turned every error that is not a `ConnectError` (here
a `SqlError`) into the pairing message.

The field-by-field Restore of instance records comes from #164 (already
on stable), so this PR uses `Related:` and not `Fixes:`. Linking #164
would hold everything merged since 2026-11-05.

## Change

- **One connection notice.** An instance's `kind`, `proxy`, `baseUrl`
and `apiKey` that were lost in the same merge with the same computer are
one notice, `field = "connection"`. Its value is a JSON object (the key
shows only as "A different key"). Restore, **Use the other’s** and
**Keep this computer’s** write those fields together, taking the newest
lost version of each.
- **Defence in depth.** `applyInstance` sets `proxy_id` only on endpoint
instances. A record that combines `native` with a proxy (from Restore or
from a field-by-field merge) can no longer break the worker sync.
- **Whose value.** New additive field `ConfigNotice.own_value = 11`: the
kept value was set on this computer.
- **Errors.** `computerGuard(run, failure)`: only pairing and the link
service keep "Check the address, code and Network access settings". The
other actions name what failed (see the copy audit).
- **#696 untouched.** `StartProviderLogin` stays out of
`SERVED`/`WORKER_SETTINGS`.
- Docs: `docs/linked-computers.md` (notices).

## Verification

- New `tests/integration/config-sync-connection.test.ts` (two linked
gateways):
- A: Grok native → endpoint through a proxy. B: endpoint → back to
device login. After linking, B has **one** `connection` notice
(`choice`, `own_value=false`). Restore on B: both computers are endpoint
through the proxy, both workers get its address and key, and no notices
are left on either computer.
- A `merged` connection in A's history (as left by an earlier link): one
notice (`own_value=true`, "Studio B"). Restore: both converge, no
notices are left. **Keep current** (Dismiss) clears it and leaves both
on device login.
- Before the fix, the same scenario failed on the second Restore with
the `provider_instances_endpoint` violation, which the user saw as the
generic link message.
- The device-login refusal still holds: `config-sync-workers` (a linked
computer can't start `StartProviderLogin` through its API or directly
over the link), 9/9.
- Multi-gateway files run one at a time: `config-sync-connection` 2/2,
`-workers` 9/9, `-providers` 7/7, `-intent` 3/3, `-identity` 4/4,
`-recovery` 6/6, `-bootstrap` 4/4, `config-sync` 7/7, `-environment`
8/8.
- `bun install`, `gen:check`, `typecheck`, `lint`, `format:check`, web
build: clean. `check:tmp` (full run) was not run; only the focused files
above.
- **Not checked in a browser**: the change only replaces text in the
existing notice row, which already wraps (`break-words`, `flex-wrap`
buttons). Mobile still shows its plain notice list (field name and raw
value); the `connection` field shows there as raw JSON, as other fields
already do.

## Copy audit (docs/copy.md §8)

| Where | Before → after | Why |
|---|---|---|
| Instance notice title | `Connects with` + `Proxy` (two rows) →
`Connects with` (one row) | One thing changed: how the instance
connects. "Connection" is a banned synonym for instance, so the title
keeps "Connects with". |
| Connection value | `Endpoint` / `A different proxy` → `This computer’s
value: Endpoint through a different proxy` (also `Device login`,
`Endpoint at <url>`, `… with a different key`) | Says what differs and
whose value it is; proxies are never shown as ids. |
| Merged notice | `Merged with <computer>.` → `Replaced when this
computer linked with <computer>.` / `Not used when this computer linked
with <computer>.` | Says what happened; active voice; ≤ 10 words. |
| Restore button (merged/concurrent) | `Restore` → `Restore this
computer’s` / `Use the other’s` | Verb first; says what Restore does;
same wording as the existing choice notice. |
| Dismiss button (merged/concurrent) | `Dismiss` → `Keep current` | Says
the effect instead of hiding a notice. |
| Notice action failed | `Computer link operation failed. Check the
address, code and Network access settings.` → `Could not apply this
value on this computer. Try again, or change it in its settings.` | What
happened, then what to do; the link message fits only pairing. |
| Other linked-computer actions | same generic link message → `Could not
load linked computers. Try again.`, `Could not change this linked
computer. Try again.`, `Could not move the threads. Check that the other
computer is online, then try again.`, `Could not load moves. Try
again.`, `Could not load workers of linked computers. Try again.`,
`Could not read thread sync diagnostics. Try again.` | Each names the
failed action and ends with an action. |
| Settings → Linked computers fallback | `Computer link operation
failed` → `Could not update linked computers. Try again.` | Ends with an
action. |

Glossary: "instance", "proxy", "computer" used as defined; no new terms;
no "soul" sentences. Long computer names wrap (`break-words`).

Related: #164, #696
nixuuu added a commit that referenced this pull request Nov 14, 2026
The delayed-rejection test sometimes reads `expired` before the
successful turn's account update runs, even though the turn is already
committed. This is a test race: ingestion commits the turn, then awaits
settling, broadcasts and agent-bus handling before calling
`coreTurnLogin`. A database count therefore cannot establish that the
success has entered `ProviderAccounts.afterTurn`; the test's no-op queue
barrier can run ahead of it.

Observe the real account-update enqueue, keep the rejected account read
held until the success is queued, then wait for both real updates to
finish before asserting `signed_in`. Waiting for both independently also
catches a stale rejection when ordering is broken. Remove the
database-count helper and the two-second sampling loop. Product ordering
in `provider-accounts.ts` and `turn-logins.ts` stays unchanged.

Related: #696, #700, #703

### Verification

- Stress: **171 passed, 29 failed out of 200 (14.5% failures)** before;
**200 passed, 0 failed** after. Each repetition runs the focused file,
including the earlier device-login scenario this case depends on; the
target case executes once per repetition. The after run passed all
**800/800** tests in **310.99 s**. No retries, sleeps or timeout
increases were added.
- The baseline used 48 completed direct repetitions, then 152 with the
repository's shared-Postgres runner. The after run used `nice -n 10 bun
run check:tmp <focused-file> --rerun-each=200`; its identical source was
staged under a temporary test filename so the unchanged baseline could
run alongside it. Both used a private `TMPDIR` under `/var/tmp`.
- Mutation check: bypassing the real queue with `update()` makes the new
test fail with `Expected: signed_in / Received: expired`. The mutation
was confined to a temporary test copy and removed.
- `bun install`, `bun run typecheck`, `bun run lint`, `bun run
format:check`, and the final focused file: **passed**, all with `nice -n
10` and temp under `/var/tmp`. The shared-Postgres runner reported no
test temp directories left behind.

No UI, protocol or runtime behavior changes.
nixuuu added a commit that referenced this pull request Nov 14, 2026
Claude device logins stored in macOS Keychain appeared as **Not signed
in** because Canopy changed `CLAUDE_CONFIG_DIR` to its shadow home.
Claude scopes its keychain service by that directory; linking
`.credentials.json` cannot share a login that has no file. The existing
JSON parser already accepts the reported 2.1.325 response.

Select the login separately with Claude's
`CLAUDE_SECURESTORAGE_CONFIG_DIR` for both account probes and instance
turns. Preserve the empty value for the default, unhashed keychain
service, and preserve explicit config directories for scoped logins.
Sessions, settings, hooks and plugins remain in the isolated home.
Own-login instances and workers with device login disabled keep their
isolated credential store. Reserve this environment variable against
profile overrides; no tokens are read or exported by Canopy.

### Evidence

- Inspected #696 and #697: empty `login_revision` does not create a
signed-out state; rejected-login marks produce `expired`, and usage
reports stay separate. This predates those changes. Desktop already
preserves `HOME`, `USER` and `LOGNAME`.
- Fake CLI through real WorkerHost, gRPC and PostgreSQL covers the
reported keychain-backed JSON without a credentials file, a file-backed
login, signed out with exit code 1, and the older JSON shape without the
new optional fields. It also completes a real SDK turn while asserting
that shadow home and default keychain scope remain separate, and rejects
fallback from an empty own-login instance.
- Account adapter coverage uses the desktop's actual
`serviceEnvironment()` allowlist and the worker's process-governor spawn
path.
- macOS SSH check found Claude 2.1.325 and no credentials file. Both
plain `auth status --json` and the sanitized desktop-like environment
reported `loggedIn:false` in that SSH session, so a live GUI-session
keychain login and real model turn remain unverified. No keychain tokens
were read and no inference was requested.

### Validation

Run with `nice -n 10` and `TMPDIR=/var/tmp`:

- `bun install`, `bun run gen:check`, whole-repo `bun run typecheck`,
`bun run lint`, `bun run format:check`: passed. The integration
typecheck was repeated after the final test edits.
- Focused tests: **28 passed, 0 failed**, across
`provider-account-status`, `provider-accounts.integration`,
`provider-sign-in-expired`, `provider-usage`, `provider-usage-bots`, and
profile environment validation.
- No UI copy changed. No browser/E2E or live inference tests were run.

Related: #125
Related: #696
Related: #697
nixuuu added a commit that referenced this pull request Nov 14, 2026
Claude, Codex and Grok device-login instances now use the terminal's
live credential store while retaining isolated agent configuration. Web,
desktop and mobile can sign in and sign out through the official CLIs;
own-login instances mutate only their isolated store.

Claude uses `CLAUDE_SECURESTORAGE_CONFIG_DIR` for both keychain and file
storage, including bots and text generation. Codex keeps a refreshable
link instead of a stale copy; Windows can use a hard link when symlinks
are unavailable. Grok retains `GROK_AUTH_PATH` and reports saved
credentials without claiming their validity.

Auth commands require strict worker ownership, reject platform workers
and linked peers, share one flight per credential store, and keep
outcomes tied to a specific login. Confirmations name the computer and
explain terminal effects. The additive `provider_cli_auth_v1` capability
protects old workers. Authorization codes remain transient and CLI
output is never logged or forwarded.

Related: #696, #724.

Validation:
- Review regressions covered: custom `GROK_AUTH_PATH` makes the device
instance available while isolated homes remain separate; removing or
disabling a sibling during Claude sign-in still publishes that login's
completion. ConfigApplied also queues a fresh account read after an
older in-flight report.
- Install, gen:check, typecheck, lint, format:check, web build and both
mobile exports passed.
- Focused gateway↔worker tests cover start/complete/failure, logout,
ownership/platform/linked refusals, single-flight, own-login isolation
and refreshed source credentials. Codex link and bot/Grok
text-generation coverage passed.
- Native fingerprints match base dev: iOS
`138e0c6b171c82b4933e86808cdfef56da73b8c6`; Android
`906dc944f94eb8333fa384ed9f198834fdd30d13`.
- Browser review passed on an isolated stack with fake CLIs: light/dark,
desktop/phone, named-computer confirmations, Claude code submission,
Grok device code, completion/failure and sign-out status refresh. The
review found and fixed long computer names stretching the status table.
Browser console: no errors or warnings.
- Real accounts and native macOS/Windows sessions were not exercised.
Only the release workflow publishes OTA after merge into dev; this PR
does not publish updates, builds, tags or releases.

Copy audit (§8):

| Before → after | Reason |
| --- | --- |
| Codex-only sign-in → “Sign in”, “Sign out” for native instances |
Imperative actions, same words across web and mobile. |
| Terminal-only Claude/Grok guidance → named-computer confirmation and
explicit terminal effects | Explains the affected login before mutation;
own-login copy names the isolated instance. |
| ChatGPT-only device instructions → browser code or Claude code-paste
instructions | One action per sentence; password entry clears after
submission. |
| Unknown Grok account → “Login saved” / “Not signed in” | Reports file
presence without claiming a verified account. |
| Raw CLI errors → short actionable failure/update message plus
named-computer terminal fallback | No token, diagnostic output or
protocol jargon on the surface. |

All changed copy uses sentence case, action verbs and text cues
independent of colour. No empty states or personality copy were added.
Reviewed desktop/phone widths, both themes and short, typical and long
computer names; confirmations retain full names while the status label
truncates.
nixuuu added a commit that referenced this pull request Nov 14, 2026
## Why
Feedback from Settings → Providers → Codex (Device login): a signed-in
account offered **"Sign in again"**, which suggests something signed the
user out.

## What
One state-aware action label, shared by web and mobile through
`accountAction()` / `ACCOUNT_ACTION_LABELS` in
`@canopy/domain/provider-accounts`. It applies to every harness (Codex,
Claude, Grok).

| Login state | Action |
|---|---|
| none, error or unknown | **Sign in** |
| expired, or a turn rejected it (`expired`) | **Sign in again** |
| signed in, or login saved (Grok) | **Change account** |

- **Provider card (web LoginPanel, mobile ProviderLoginActions):** uses
the label. The confirm step keeps "This changes the CLI account on
<computer>, as <cli> does." Its button repeats the action (§8.3). **Sign
out** stays beside the action and hides only when the CLI is not signed
in.
- **Account status row (web):** the command popover uses the same label.
It is hidden when the in-app sign-in panel is next to it, so the action
does not show twice. It stays in "All workers" and Workers → Provider
accounts.
- **Failed turn card (web):** the login just failed, so the action is
"Sign in again", or "Sign in" when the CLI reports no login. The hint
("…, then retry.") and the confirm button match.
- **Summary line** ("Authenticated · ChatGPT") and the status labels
have no action, so they are unchanged. Mobile turn errors show only CLI
hints, with no button.
- Docs: `docs/provider-accounts.md` (status row) and a `provider
account` glossary entry in `docs/copy.md`.

Related: #696, #732

## Copy audit (docs/copy.md §8)
| Where | Before | After | Reason |
|---|---|---|---|
| Provider card button, signed in (web + mobile) | Sign in again / Sign
in | Change account | The login works. "Again" reads as a sign-out.
"Change" fits better than "Switch", because the new login replaces the
old one and there is no second account to switch back to. |
| Provider card button, expired/rejected | Sign in again (web) / Sign in
(mobile) | Sign in again | Correct here. Web and mobile now agree. |
| Provider card button, not signed in | Sign in | Sign in | Unchanged. |
| Confirm button (web SignInConfirm, mobile dialog) | Sign in | Sign in
/ Sign in again / Change account | A confirmation repeats the title's
verb (§8.3). |
| Mobile confirm title | Sign in? | Sign in? / Sign in again? / Change
account? | Matches the button. |
| Own-login confirm text | This signs in only this instance on X. | This
changes only this instance’s account on X. | Correct for all three
actions. One idea, 8 words. |
| Status row popover trigger (web) | Sign in / Sign in again | Sign in /
Sign in again / Change account | Same rule. Not shown next to the in-app
action (§2.12). |
| Failed turn hint + button (web) | Sign in, then retry. / Sign in |
Sign in again, then retry. / Sign in again (or Sign in) | The turn
showed the login was rejected. |
| Sign out (web + mobile) | Always shown | Hidden when not signed in |
Nothing to sign out. |

- Glossary: added `provider account`. Banned for its action: "switch
account", and "sign in again" while the login works.
- Buttons start with a verb, use sentence case and have no period. No
new errors or empty states. No sentences with "soul".
- Length: "Change account" is shorter than "Sign in again", so wrapping
is the same or better at phone width.

## Checks
- `bun install`, `gen:check`, `typecheck`, `lint`, `format:check`:
clean.
- Web build (`vite build`): clean.
- Mobile `expo export --platform all` (Android + iOS): clean.
- Expo fingerprint unchanged against `dev` (android `906dc944…`, ios
`138e0c6b…`). The change is JS only and ships OTA.
- Not run: `check:tmp` (full suite; no tests cover these labels and none
were added, per the no-UI-tests rule) and a live browser pass.
nixuuu added a commit that referenced this pull request Nov 23, 2026
A native Codex thread could keep a rejected ChatGPT login after its
owner signed in again in a terminal. Canopy could report the new account
as signed in while the next turn on the same thread still failed.

Account Refresh and worker reprobes now compare the selected credential
file's metadata with the last applied configuration. An affected
app-server restarts after its turns and background tasks drain.
Unchanged credentials keep the process running. Codex's reused or
revoked refresh-token diagnostics lead to the existing sign-in action. A
turn started after sign-out reports the selected instance's missing
login.

Isolated Codex homes share the device file store’s write lock and keep a
valid credential link across the gap between terminal sign-out and
sign-in. When device login is selected and available, a detached
credential file in a managed home is backed up before restoring the
link. Custom homes retain their existing protection.

Codex 0.171 serializes writes after the OAuth exchange. Two independent
clients sharing a ChatGPT grant can still request refresh concurrently.
A separate instance login gives Canopy its own grant when the terminal
is also in use. File sharing on Windows requires file-symlink
permission.

## Verification

- On Linux, Codex CLI 0.171.0 refreshed a synthetic ChatGPT login twice
against a local OAuth endpoint, first from the isolated home and then
from the device home. Both rotations reached the selected source file.
- Focused worker tests exercised logout/login, lock identity, nested bot
homes, legacy recovery and notification classification. Gateway↔worker
integration covered both private and linked logins, in-flight work and a
successful next turn on the original thread.
- Worker typecheck, edited-file lint and diff checks passed locally. CI
runs the store tests on Windows and macOS too. Interactive sign-in to a
real ChatGPT account was outside local verification.

## Copy audit

An account error for an unusable login lock explains the failure and
asks the owner to check the instance directory and permissions. The
existing sign-in action also covers rejected refresh tokens. The new
detail has two fixed-length sentences and carries no account identifiers
or paths.

Fixes: #696

Related: #1150
nixuuu added a commit that referenced this pull request Nov 28, 2026
## What changed

- Providers Summary now excludes workers whose instance account is
reported as expired or signed out. Other workers with an available
instance still count toward readiness. The worker detail shows the
specific sign-in state.
- A failed turn uses the worker's instance to show the correct sign-in
confirmation before starting the existing CLI flow. If in-place sign-in
is unavailable, the error links to that worker and instance in
Providers.
- The gateway-to-worker regression test now checks the readiness summary
before the mock Codex turn fails, after the gateway reports the rejected
sign-in, and after successful sign-in.

Thanks to @marcinniewinski for reporting the mismatch.

Fixes: #696

## Verification

- Locally on Linux, revision `1c80c45f2`: formatting, lint, and
whitespace checks passed for the changed files.
- Chromium on `b73bfc848` at 375 px and 1100 px with synthetic state and
a mocked login endpoint: mixed worker readiness, scoped confirmation and
request, and the scoped settings link passed. A long worker name wrapped
in the confirmation.
- GitHub CI runs the full static checks, the gateway-to-worker
regression, and applicable builds.

## Copy audit

- The Ready labels now reflect the account state. The worker detail uses
the existing “Sign-in expired” and “Not signed in” labels.
- The fallback link reads “Open provider settings” and the hint
describes the next step. The in-place confirmation keeps the existing
action label and names the login store it affects.
- Text conveys the status independently of colour. The synthetic narrow
and wide checks covered the confirmation text and actions.
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