Skip to content

feat(desktop): one Machines page, and machines behind a TLS proxy - #176

Closed
sanchitrk wants to merge 9 commits into
feat/pairingfrom
feat/machines-paired
Closed

sanchitrk wants to merge 9 commits into
feat/pairingfrom
feat/machines-paired

Conversation

@sanchitrk

@sanchitrk sanchitrk commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #175.

The model

  • Hostname: the computer's own name. Read-only everywhere.
  • Label: one friendly name per machine, stored on the machine.
  • Paired: this computer reaches a machine directly, with a pairing code. It is direct access, as an SSH key is, so a paired computer may set the machine's label and link it to a workspace.
  • Linked: a machine belongs to a workspace. A workspace is a member boundary, not a set of paired machines.

Application → Machines

One page replaces Paired Machines and Workspaces → Machines. Every machine appears once, grouped by what this computer can do with it. The workspace is the one selected in the app; without one, only the first two sections show.

  1. This Machine: Label, Hostname with copy, ID. Its last row is "Not Linked" with Set Up, or "Linked to " with Unlink.
  2. Paired Machines: name, address, whether it is linked, and Online, Last Seen, or Not Paired. A row opens the machine's page. Pair a Machine is a dialog: the command to run, Address, Pairing Code, each error under its own field.
  3. Waiting to Join : machines that ran codework connect, each with its code to approve.
  4. Linked to , Not Paired: the workspace's machines this computer is not paired with, each with Unlink in its menu.

A paired machine's page

  • Label is written to the machine itself. Hostname and Version are read-only. Address can be changed.
  • Workspace: "Link to " starts the connect on that machine and approves its code as the signed-in person, in one click. Once linked, the row offers Unlink, which is confirmed. A failure shows in the row.
  • Pair Again appears when the machine no longer accepts this computer.
  • Remove is confirmed, and ends the pairing on the machine too.
  • An id that matches nothing shows a not-found card with a way to the list.

Settings as a whole

  • The sidebar is Profile, Tabs, Themes, Providers, Machines. The Workspaces group is gone, and so are the pages that only showed mock data (General, Keybindings, Models, Chat, MCP, Skills, Plugins, Sandboxes, Archive), with the two "Manage" links that led to the MCP one.
  • Setup lives under the Machines page, and Set Up Later returns there.
  • Sections take a description line and a count, with more room between sections. Descriptions do not end with a full stop.
  • Escape no longer leaves Settings. The sidebar keeps a section highlighted on its sub-pages.

App server

  • machine.connect and machine.disconnect take an optional serverId, so they reach a paired machine as well as the default one. A machine that is not paired any more, or does not answer, fails in the app's own words; the machine's own connect error passes through unchanged.
  • A paired machine's status carries label, host, version, online, seenAt, machineId and the workspaces it is linked to. They are stored, so they show while the machine is offline, and are refreshed after a link or an unlink.
  • servers.label sets the label on the machine over its paired connection. servers.update refuses a name on a paired machine.
  • servers.remove tells the machine to end the pairing, best effort.
  • Migrations 202611200002_label and 202611210001_identity add the columns.

Also

  • codework service pair notes on stderr that the code gives full access to the machine. Stdout is still only the code.

Reaching a machine behind a proxy

codework serve stays plain HTTP; TLS ends at a proxy or tunnel in front of it.

  • The Host check is gone from the door, so a proxied request is not refused. The Origin and credential checks are unchanged.
  • X-Forwarded-Proto is believed only from loopback or a trusted proxy. A trusted proxy is an address or CIDR range from --trusted-proxy, then CODEWORK_TRUSTED_PROXY, then server.trustedProxy in the user settings. A project's settings cannot set it, and a bad entry stops startup with the value named.
  • server is a new block in the user settings file, holding only trustedProxy for now.
  • Each paired device records whether its last connection was encrypted; codework service devices shows it in an ENCRYPTED column.
  • The pair dialog takes a scheme. A domain name defaults to wss on 443; an IP, .local or single-word name defaults to ws on 7433; a typed scheme wins. A plain address shows "This connection is not encrypted".
  • New docs page: CLI → Behind a Proxy.

Routes

  • Pairing: POST /api/v1/devices and POST /api/v1/tickets, both answering 201. The socket stays at /rpc/v1.
  • Relay: workspace routes take the workspace in the path (/v1/workspaces/:workspaceId/...); approve, decline and remove stay POST.

Verified

Check Result
vp check, vp run typecheck pass
apps/server non-live suite 45 passed
knip for apps/web clean
packages/codework pairing and door tests 6 passed
infra/relay suite 8 passed

Driven by hand in the Electron app against a local relay and an OrbStack machine: Link, the row turning Linked, Unlink with its confirmation, and the machine's own error shown in the row when it cannot reach the relay. Earlier on this branch: labels, offline and online, revoke and pair again, pairing through the dialog, changing an address, removing, keyboard only, a narrow window, dark theme.

New E2E cases put a real reverse proxy in front of a real server: a device paired through it is recorded as encrypted, a forged header from an untrusted peer is ignored, a foreign Host is admitted with a valid credential, a foreign Origin is refused, and the flag, environment and settings precedence holds through the real CLI.

A link to a paired machine that is stopped, or that holds its connection open and says nothing, fails as not answering within seconds; the suite covers both.

Driven by hand in the Electron app against a remote Linux machine behind a hosting provider's HTTPS proxy: pairing by domain name, the machine Online over wss, the device recorded as encrypted only when the proxy is trusted, changing the address between a direct port and the HTTPS name without pairing again, and a chat that read a file and ran a command on the machine.

Known gaps

  • Starting a new thread or adding a project on a paired machine is not in the app yet; a thread already on the machine can be continued.
  • The home token is still accepted from any loopback peer, which includes every request arriving through a proxy on the same machine.
  • No automated test links a machine through a real relay, because no harness starts one. The suite covers the new status fields and the error paths.
  • A paired machine linked or unlinked from elsewhere (the CLI, or Approve) shows it only after it reconnects.
  • A machine links through the relay it is configured with; with a different relay than the app's, the link fails with the machine's own message.
  • A paired device may do everything a local caller may, except manage pairing.
  • No machine label on threads in the sidebar yet, and no pairing again from inside a thread.

🤖 Generated with Claude Code

sanchitrk and others added 6 commits November 20, 2026 19:03
- 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]>
@sanchitrk sanchitrk changed the title feat(desktop): Paired Machines, labels, and Linked wording in settings feat(desktop): one Machines page for paired and linked machines Nov 20, 2026
sanchitrk and others added 2 commits November 21, 2026 12:41
- 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]>
@sanchitrk sanchitrk changed the title feat(desktop): one Machines page for paired and linked machines feat(desktop): one Machines page, and machines behind a TLS proxy Nov 21, 2026
…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]>
sanchitrk added a commit that referenced this pull request Nov 23, 2026
…rue (#177)

Lands #173, #174, #175 and #176 with it: a per-home token on the RPC listener, plain CLI errors, a session per paired client, one Machines page and machines behind a TLS proxy.

- Every remote client pairs a key of its own: a one-time code from `codework service pair`, then short-lived tickets signed with that key.
- Relay alone decides whether a machine is in a workspace; while it can't be reached, its last status shows, or Unknown Link.
- An unlink while Relay can't be reached keeps the link, marked leaving, until a heartbeat's revoke is confirmed.
- Setup's last step is Link, and it can be skipped. User-facing copy calls the broker Relay.
- The relay listens on HOST; a new E2E test links a paired machine through a real Relay.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sanchitrk

Copy link
Copy Markdown
Contributor Author

Landed in #177 (squash-merged into feat-oauth-clerk as 00a8ac3), whose branch carried this change. Closing as merged through it.

@sanchitrk sanchitrk closed this 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]>
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