Skip to content

feat(claude): select optional cswap accounts for local sessions - #217

Merged
firstintent merged 5 commits into
devfrom
feat/cswap-accounts
Nov 8, 2026
Merged

firstintent merged 5 commits into
devfrom
feat/cswap-accounts

Conversation

@firstintent

@firstintent firstintent commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Local Claude sessions can select an authorized account from a preinstalled cswap in the new-session model menu's advanced options. Default login and other vendors work without cswap. Selecting the current default account allows cswap's native fallback; isolated accounts retain their identity and profile across resumes, role switches and delegated children. Explicit grants are checked independently of project access.

The launcher wraps the existing stream-json argv with cswap run, using pipes and a child-local exec relay. The relay preserves binary overrides, keeps auth probes off SDK stdin, verifies the effective profile, and selects fresh/resume in that profile. cswap and Claude retain credential/refresh ownership. Public DTOs expose no profile paths or raw email. Account discovery rejects cswap's optional model-based quota probe. Remote, terminal and non-Claude selection are unsupported.

Maps to local issue docs-local/issues/#229. Based on dev and targets dev. No version bump or deployment.

Validation:

  • make check, make test, real-PTY make test-web, fmt and diff checks passed.
  • SPA production build and make web-check: 871 tests passed; DSH plugin npm test: 287 passed.
  • Playwright: 3 passed for installed/absent cswap and the existing lazy-create flow.
  • make perf-gate passed without changing thresholds: session-list p95 41.51ms, status p95 31.32ms, gateway lock hold p99 0.196ms.
  • Strict auth-probe stdin regression failed before the fix and passed after; offline adapter/relay tests also cover multiple turns, profile-bound resume, slot drift, metadata loss, default fallback, uninstall and account grants.
  • Installed cswap 0.29.0 + Claude Code 2.1.318 completed initialize through the real relay in temporary homes using a fake token; native PID registration was verified. No real subscription inference, OAuth rotation or spend was tested.
  • Independent checker found no remaining blockers after fixes.
  • Final commit CI: https://github.com/firstintent/ccteam/actions/runs/41819942198 (fmt/clippy/deterministic baseline all passed).

@firstintent firstintent closed this Nov 4, 2026
@firstintent firstintent reopened this Nov 4, 2026
@firstintent
firstintent changed the base branch from main to dev November 4, 2026 11:26
randd1024 and others added 3 commits November 6, 2026 11:30
…ide the model menu (#229)

Owner report: with cswap installed, a per-user web login still got
"No cswap accounts are assigned to this identity". Only the admin token
resolves to Operator; every personal-link login is a Tenant that needs an
explicit `cswap_account_grants` entry, and nothing could write one (a
tenant cannot even discover the ids first), so the feature was dead for
all personal logins and the picker blamed cswap for it.

- Admin-only GET/PUT /api/v1/users/{id}/cswap-accounts (inside the
  existing admin `/users*` family). Grants accept only the 64-hex stable
  account id, never a slot, alias or `*`; deleting a user drops its grant.
- Settings → Admin → Users gains a per-user Claude account editor that
  also lists grants cswap no longer reports so they can be revoked.
- Discovery returns `reason: "not_granted"` and the picker says who can
  grant access instead of "cswap unavailable".
- The account picker leaves the model menu and becomes its own composer
  button + drop-up beside it. On phones the row already overflowed at
  390px (send at 428px); HITL/account go icon-only, effort hides and the
  model label ellipsizes so mic + send stay on screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner decision 2026-11-06: per-account grants are dropped. The default
login is already the box owner's subscription and every identity that can
start a Claude session spends it, so a grant gated nothing the default
path did not already expose.

Removes config.yaml cswap_account_grants, identity::can_use_cswap_account,
the gateway CswapAccountDenied / cswap_account_access / authorize_cswap_account
checks, the admin GET/PUT /api/v1/users/{id}/cswap-accounts routes, the
Settings grant editor and the not_granted discovery reason. Keeps the
local-Claude-stream-json-only guard, the web-token gate, label redaction,
the discovery cache and isolated-profile drift refusal.

Refs: docs-local/issues/#229

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@firstintent
firstintent merged commit 60831d3 into dev Nov 8, 2026
@firstintent
firstintent deleted the feat/cswap-accounts branch November 8, 2026 07:51
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