Skip to content

feat(clients): each client's own key, proof of use by that key, and how to connect it by hand - #98

Merged
fylorn merged 1 commit into
mainfrom
feat/clients-page
Sep 22, 2026
Merged

fylorn merged 1 commit into
mainfrom
feat/clients-page

Conversation

@fylorn

@fylorn fylorn commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Why

The desktop app's Clients page is being rebuilt as a table: status, the key each client uses, recent requests, and a way to connect any client by hand. Four facts it needs were missing or wrong in /clients:

  1. Which key belongs to which client. The config records it (clients[].client), the response did not.
  2. Whether a client is really going through the gateway. last_seen_ms came from the client name in request headers, which any program can claim. After adoption each client has its own key — that is the proof worth showing.
  3. How to connect a client that was not detected. Only the three manual-only clients had instructions, as one sentence with the address baked in.
  4. A dedicated key for a client configured by hand. Only adoption could make one.

What changes

  • DetectedClient gains key (the key generated for it, kept after a restore) and manual (how to connect it by hand); last_seen_ms is now the last request made with that key. Db::last_seen_by_hint is removed.
  • ManualSetup { steps, fields, endpoint }: for an adoptable client, "open this file and set these fields" plus exactly the fields adoption writes (tw_adopt::clients::edits), the key field flagged secret and never valued, and the address in the form the client wants (/v1 or not). Zed gets an extra step for its key, which lives in Zed's own settings.
  • ManualClient gains id, key, last_seen_ms and setup; how is gone. The steps no longer contain the address — the UI gives the address and the key their own copy buttons. Gemini CLI's steps now include GEMINI_API_KEY (the gateway already accepts x-goog-api-key).
  • POST /clients/{id}/key → ClientKey { name, key, created }: the key kept for that client, or a new one bound to it (free_name). Adoption's ensure_key now goes through the same prepare_key, so a key made while configuring Cursor by hand is recorded as Cursor's exactly like an adopted client's key.
  • PlanView gains key and key_created: which key an adoption will write and whether it is created at that moment; a restore plan names the key that stays, and now lists the fields it removes instead of none. FieldChange.secret replaces the path heuristic (token/key in the name) with the flag adoption itself uses.
  • The CLI's twcore clients prints the new steps and address.

CONTROL_API_VERSION → 7 (ManualClient.how removed).

Tests

  • tw-control/tests/adopt.rs: a manual client's key is made once, bound to it and listed; every client says how to connect it by hand (paths, /v1 or not, the key field never valued, no address inside a step); plans name the key and whether it is new, before and after adopt/restore; "in use" follows the client's own key while a request that only claims to be Claude Code does not count.
  • tw-adopt: every adoptable client has manual steps and an endpoint in the right form; Zed's extra step; every step carries a code.
  • tw-store: the observation-window test now asks by key.

cargo fmt --check, clippy -D warnings, cargo test --workspace and scripts/smoke.sh (51 passed) pass locally.

🤖 Generated with Claude Code

…ow to connect it by hand

- `/clients` gives every client the key generated for it and when that key
  was last used. "In use" was proven by the client name a request's headers
  claim, which any program can write; the key is something only the
  gateway assigns. `Db::last_seen_by_hint` goes with it.
- Every adoptable client now says how to connect it by hand (`manual`):
  which file to open, the fields adoption would write (the key field
  flagged `secret`, never valued) and the gateway address in the form that
  client wants. A client that is not detected can still be pointed at the
  gateway.
- Manual-only clients get an id and structured steps (`setup`) instead of
  one sentence with the address baked in (`how`), so the address and the
  key can each have a copy button. Gemini CLI's steps now include the key.
- `POST /clients/{id}/key` prepares the client's own key: the one kept for
  it, or a new one bound to it. Adoption goes through the same function,
  so a key made while configuring Cursor by hand is marked as Cursor's the
  way an adopted client's key is.
- Plans say which key goes in and whether it is made at that moment
  (`key`, `key_created`); a restore plan names the key that is kept and
  now lists the fields it removes. `FieldChange.secret` marks the key field.

CONTROL_API_VERSION goes to 7.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@fylorn
fylorn merged commit 5b0fc08 into main Sep 22, 2026
1 check passed
@fylorn
fylorn deleted the feat/clients-page branch September 22, 2026 05:20
@fylorn fylorn mentioned this pull request Sep 22, 2026
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