Repository navigation
feat: pair machines with keys, and a Machines page that says what's true - #177
Merged
Merged
Conversation
A server now keeps a token in <home>/token and refuses a WebSocket upgrade that does not offer it, or that comes from a foreign Host or Origin. The token is published in service.json, and the CLI, the app server and the desktop renderer send it when they connect. - The CLI sends the token only to the server its home registered, and prints a plain error for any other --server URL. - The app server takes its own token per start and stores one on each remote server row. - server.info reports the machine id. - Machine test fixtures install from the checkout under test. - Fix a reads test that assumed the first chunk arrives as a delta. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…used connections - A session id that is not a session id printed a schema stack; every command that takes one now prints one error line. - A handler failure raised before its own catch reached the runtime's logger with a stack. The command wrapper now renders every handler failure as an error line. - A failed connection named no cause. The CLI now asks the home's server why and says when it refused the token or the host. - Give the CLI tests a 30 second timeout: they spawn the real CLI and server, which start slowly when many run at once. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ally The live sync suite assumed the main thread never commits last among four concurrent writes. When it does, its revision is the store head, which is legal. The stale-write check now targets whichever thread is older. The live suites share the OrbStack machines, so they are now a test project of their own that runs one file at a time. Co-Authored-By: Claude Fable 5.2 <[email protected]>
A remote client no longer stores a copy of the machine's token. It pairs once with a code a person reads from `codework service pair`, and gets a session only it holds. - `POST /pair` exchanges a one-time code (10 minutes) for a session token. The machine keeps a hash of it in <home>/devices.json. - `POST /ticket` takes the session token in Authorization and answers a ticket that opens one socket within 60 seconds. A session unused for 30 days is refused. - `codework service devices` lists devices; `codework service revoke` removes one and closes its open sockets. - The home's token is made per server start again and is accepted from loopback only. <home>/token is gone. - A device may call everything a local caller may, except pairing and device management. - The app server adds a remote server with a pairing code, takes a ticket for every connection, and reports a lost pairing as `paired: false`. - `--server` now defaults to the home's server, and a server bound to every address answers to this computer's loopback names. Co-Authored-By: Claude Fable 5.2 <[email protected]>
- Rename the settings group to Workspaces and drop Setup from the sidebar. Setup is reached from the Machines page, where its row is always present, and Set Up Later returns there. - Show the hostname in its own row with a copy button, since it is the name used when none is given, and shorten the row descriptions so a long hostname cannot wrap them. - Show the ID in the copy field once assigned, and as "Not Assigned" until then. - Hold the card's four rows while it loads and wait for the workspace before showing them, so the sections below no longer jump. - The copy field truncates a long value and shows it in full on hover. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Escape on a settings page returned to the app, which also fired when a key press missed the dialog or field it was meant for. Settings is left with Back to App or the close button. Co-Authored-By: Claude Fable 5.2 <[email protected]>
A paired machine's status now carries its label, hostname and version as the machine last reported them, whether it is answering, and when it last did. They are kept in the app database, so they show while the machine is offline, and a change reaches watchers without a manual check. - `servers.label` sets the label stored on the machine, over its paired connection. Pairing is direct access to the machine, so nothing more is asked. - The private per-app name of a paired machine is gone; its label replaces it. A migration clears the old names. - An address nobody answers at now says so in plain words. - `codework service pair` notes on stderr that the code gives full access to the machine. Co-Authored-By: Claude Fable 5.2 <[email protected]>
A machine has a hostname, which is the computer's own name, and one label, which is stored on the machine. Pairing reaches a machine directly; linking puts it in a workspace. - Application > Paired Machines lists the machines this computer is paired with. Each opens a page of its own with its label, hostname, address and version, pairing again when the machine no longer accepts this computer, and removal. - Pair a Machine is a dialog laid out like Add Provider's, with each error under its own field. - Workspaces > Machines says Label, Linked and Unlink. - The settings sidebar keeps a section highlighted on its sub-pages. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Removing a paired machine only forgot it in the app, so the machine kept listing the computer as a device until the session lapsed. - A paired device can end its own pairing with `device.leave`. It removes that device alone and closes its sockets, the one the call came in on included, so a client takes a reply or the connection ending as done. - The app calls it before removing the row, for at most three seconds, and removes the row whether the machine answers or not. - The empty Paired Machines list has one Pair a Machine button, in the header. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…page Settings has one Machines page under Application. Every machine appears once: This Machine, Paired Machines, Waiting to Join, and the workspace's machines this computer is not paired with. A paired machine's page links it to the selected workspace, or unlinks it. - The app server's machine.connect and machine.disconnect take an optional server id, so they reach a paired machine as well as the default one. - A paired machine's status carries its machine id and the workspaces it is linked to; both are stored and refreshed after a link or an unlink. - Setup moves under the new page. The Workspaces group and the Paired Machines entry leave the settings sidebar. - Settings sections gain a description line and more room between them. Descriptions no longer end with a full stop. - The settings pages that only showed mock data are removed, with the controls only they used. Co-Authored-By: Claude Fable 5.2 <[email protected]>
- A machine's pairing routes are POST /api/v1/devices and POST /api/v1/tickets, and answer 201. They were /pair and /ticket, with no version. The socket stays at /rpc/v1. - The relay's approve and decline sit under their workspace, beside the list of pending pairings; the workspace leaves the body. Both stay POST. The routes a machine signs are unchanged. Co-Authored-By: Claude Fable 5.2 <[email protected]>
The server stays plain HTTP; TLS ends at a proxy or tunnel in front of it. - Drop the Host check from the door, so a proxied request is not refused. The Origin and credential checks are unchanged. - Believe X-Forwarded-Proto only from loopback or a trusted proxy, named by --trusted-proxy, CODEWORK_TRUSTED_PROXY or server.trustedProxy in the user settings, in that order. A project's settings cannot set it, and an entry that is not an address or range stops startup. - Record on each paired device whether its last connection was encrypted, and show it in `codework service devices`. - The pair dialog takes a scheme: a domain name defaults to wss, an IP, .local or single-word name to ws, and a typed scheme wins. A plain address shows "This connection is not encrypted". - Document the proxy setup. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…othing The link fails as not answering within a bound, on the connection's own liveness check. Co-Authored-By: Claude Fable 5.2 <[email protected]>
A paired device proved itself with a long-lived bearer token, sent on every ticket request: one capture on a plain route gave lasting access. Pair as SSH does instead, so only signatures cross the wire. - The app holds one Ed25519 device key; the machine keeps its public half in devices.json and answers pairing with its identity key. - A ticket request is a proof signed by the device key, naming the machine it is for, good once and within five minutes. - The machine signs every grant and refusal. The app opens a socket only for a grant signed by the key it stored at pairing, and drops a pairing only on a refusal signed by that key. - Another key at the address shows "Different Machine"; a clock outside the window shows "Clock Is Off". Both keep the pairing. - `service pair` prints the machine key's fingerprint, `service devices` lists each device's, and the machine page shows the machine's. - A plain address says it is not encrypted on the machine page and list. Devices paired before this pair again. Co-Authored-By: Claude Fable 5.2 <[email protected]>
The splash now stays up until the setup check has opened the first page, so a new account or workspace goes straight to Set Up. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…honest The app server now sends the key a mismatched address answers with and the clock difference, and the Machine page shows them in one Notice with Pair Again inside it. The Workspace row only offers Link when the Machine answers as itself, and says what to do otherwise. Unlink always works: a Machine that can't be asked has its link removed at the relay, and the app server forgets it through the new servers.unlinked. Dialog failures sit inside the dialog with an icon. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…copy A paired machine's workspace link now comes from the relay's list, which is never behind the machine: a machine hears a link ended elsewhere only on its next heartbeat, and the app hears from it only when it connects. Its own last word stands in while the relay can't answer. The Machine page asks the relay again every 15 seconds, and Unlink goes through the machine only while it answers and holds the listed key. A plain connection reads "Insecure" in the paired list and is a warning on the Machine page and in the Pair dialog. Settings copy follows one rule: title case for titles, buttons, tooltips and status labels; sentence case for descriptions and messages. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Machine page is keyed by machine, so a failed Link on one never shows on the next one opened. The Machine Key row is a copyable chip on one line, the Remove dialog says pairing again takes a new code, and app server messages name commands without markdown backticks. Co-Authored-By: Claude Opus 5.5 <[email protected]>
An unlink while Relay can't be reached used to forget the link and its key on the machine, while Relay kept listing it with nothing left to revoke it. The link now stays, marked leaving, and each heartbeat asks Relay to revoke it again until Relay confirms. Machines report leaving with each link; older machines don't send it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Whether a machine is in a workspace now comes from Relay alone, on This Machine, paired machines, Setup and the startup check. While Relay can't be reached, its last status shows, marked as such, or Unknown Link, and Link and Unlink are off. The machine's own record only adds a note: a key it no longer holds, or an unlink on its way. Setup's last step is Link, and it can be skipped; the machine works without it. This Machine offers Link instead of Set Up. servers.unlinked goes: the app server's copy of a machine's links no longer decides membership. User-facing copy calls the broker Relay. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Defaults to 127.0.0.1; HOST=0.0.0.0 for tests with VMs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A revoke Relay committed but whose reply was lost leaves the link leaving too, and the CLI can't tell the two cases apart, so it no longer claims Relay still lists the machine. The relay suite now covers that case: the link is kept after the lost reply, and a retry that reaches Relay removes it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Through the app server, as the desktop app does: connect, approve as a signed-in person, see the link in the app's status and at Relay, unlink. Then an unlink while Relay is down keeps the link leaving, and once Relay is back the machine's heartbeat revokes it. The relay test helper can now take Relay down and bring it back at the same address; watchOf moves to the shared fixtures. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 23, 2026
sanchitrk
added a commit
that referenced
this pull request
Nov 23, 2026
Accounts and workspaces through Clerk and the relay, and machines that connect, link and pair: - The relay holds accounts, workspaces and machine links; machines pair with it by a code a member approves, bound to one identity key per home (#172). - Local listeners take a per-home token; remote clients pair keys of their own and use short-lived tickets (#173, #175, #177). - One Machines page for this machine, paired machines and the workspace's machines (#176, #177). Relay alone decides membership; an unlink while Relay can't be reached finishes once it can. - Plain CLI errors for bad ids, flag checks and refused connections (#174). - E2E coverage: the relay suite, and a paired machine linked through a real Relay from the app server. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #171: it merges into
feat-oauth-clerk.Pairing
codework service pair, then short-lived tickets signed with that key. A per-home token guards the RPC listener.Links: Relay decides
servers.unlinkedis removed: the app server's copy of a machine's links no longer decides membership.Machines settings
Relay
HOST(default127.0.0.1);HOST=0.0.0.0lets machines on other hosts, such as test VMs, reach it.Testing
vp checkandvp run typecheckpass.paired,doorandschemaserver tests pass with regenerated artifacts.apps/server/test/link.test.ts(artifactlink.json): a real Relay and a Clerk test user; through the app server, connect, approve, the link in the app's status and online at Relay, unlink; then an unlink while Relay is down stays leaving and the machine's heartbeat revokes it once Relay is back. The relay suite now covers a revoke whose reply is lost: the link is kept, and a retry removes it.codework disconnectwhile Relay is down and the unlink finishing on the next heartbeat, a key removed outside CodeWork, and a paired machine's unlink falling back to Relay.🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.