Skip to content

feat(native): one-click connect to T3 Code on this Mac, saved environments, connection status - #44

Merged
rynfar merged 4 commits into
nativefrom
nw/w13-connect
Nov 2, 2026
Merged

rynfar merged 4 commits into
nativefrom
nw/w13-connect

Conversation

@rynfar

@rynfar rynfar commented Nov 2, 2026

Copy link
Copy Markdown
Owner

The first thing a new user does with the native app is connect it to T3 Code on the same Mac. That took a pairing link copied out of Settings, and the app could only remember one server.

What changed

One-click local connect (CN-LOCAL). The connect screen finds a running server the same way t3 pair does: <T3 home>/{userdata,dev}/server-runtime.json ($T3CODE_HOME or ~/.t3), skipping dead PIDs, then reads /.well-known/t3/environment for its label, version, and protocol. "Connect to T3 Code on this Mac" runs the installed CLI, t3 pair --label "T3 Code Native" --ttl 2m (plus --base-dir when the home isn't the default), which is the supported way to pair a device. It parses the Token: line and redeems the token at the server's loopback origin. The CLI is looked up at <home>/bin/t3 (the launcher the desktop app installs), then ~/.t3/bin/t3, PATH, and the Homebrew prefixes, because apps opened from the Finder don't get the shell's PATH. T3_NATIVE_T3_BIN overrides the lookup completely. Each failure has its own message: CLI missing, server gone, server not answering, protocol too old or too new, and t3 pair failures (shows the error line it logged). If this Mac is already saved, the button reuses that credential instead of minting a new one.

Saved environments (CN-MULTI, partial). environments.json (owner-only, written atomically) holds every paired server: label, address, credential, environmentId, version, and whether it is local. Pairing a server that is already saved updates its entry instead of adding a second one. Labels follow what the server reports. The old connection.json is still read and migrated, and the probes and examples keep working through store::load/save. The connect screen lists saved environments with Connect / Pair again / Remove (Remove asks to confirm), and it doubles as the switcher: T3 Code → Switch Environment..., the palette command "Switch environment...", and Settings → Environments (Switch, Disconnect, Remove). One environment is connected at a time.

Connection status (CN-STATUS) and re-pair (CN-REPAIR). While the app isn't connected, the titlebar shows a status dot and the web's title ("Connecting...", "Failed to connect. Reconnecting..."). The tooltip carries the direct-route diagnosis from diagnosis.ts, and a Retry button skips the backoff. The supervisor now remembers the last failure while it reconnects. A server on a different orchestration protocol is blocked ("Client not supported" / "runs an older T3 Code") and waits for Retry instead of looping. When a server rejects the credential, the app drops the token but keeps the entry, then returns to the connect screen with "T3 Code on X did not accept this device" and Pair again (one click for the local server).

Compatibility (CN-COMPAT). core::compatibility ports orchestrationProtocolCompatibilityError. It runs before a pasted link spends its token, before the local pairing, and on every connect.

Also: the settings Button gets Default (primary) variant and size. The composer button cut labels at 160px. The snapshot tool now copies environments.json and renders the connect screen when the home has nothing saved.

Ledger

CN-PAIR, CN-COMPAT, CN-STATUS, CN-MULTI, CN-LOCAL, CN-REPAIR → partial, with Native paths. Not done yet: multi-connect, environment badges, the run-on picker, host freeze, the animated status ping (the dot is static so it never repaints), offline detection, the legacy-permissions notice, and host + code as separate fields.

Evidence

Tests: discovery parsing and liveness, CLI argument building, CLI lookup, output and error parsing (from real CLI output), migration and the saved-environments store (upsert/dedupe, revoke, remove, 0600 round trip), status presentation and diagnosis, protocol check, and a supervisor test where a newer-protocol server blocks until retry_now. Gates pass: cargo test --workspace, cargo clippy --workspace --all-targets -D warnings, gen-theme --check, parity/sync.test.ts, conformance --check.

Headless one-click run against the isolated smoke server (fake T3CODE_HOME, T3_NATIVE_T3_BIN wrapper around the smoke server's bin.ts pair):

$ probe -- --local --seconds 3
found MacBook Pro at http://127.0.0.1:14658 (version 0.1.6)
paired with http://127.0.0.1:14658 as Some("MacBook Pro")
status: Connecting
status: Connected
shell: snapshot seq=2302 projects=1 threads=15
final: 1 projects, 15 threads, synchronized=true

Real app window with the same setup, using a temporary local trigger in place of the click (not committed):

INFO t3_native::environments: found T3 Code on this Mac origin=http://127.0.0.1:14658 version="0.1.6"
INFO t3_native::environments: paired origin=http://127.0.0.1:14658 source=Local
phase=Online(Connecting) → phase=Online(Connected)

Offscreen snapshots (--features snapshot, 1280×840 @2x):

  • First run, local server found (light): /private/tmp/claude-501/-Volumes-DevSSD-t3code/7a9093f7-05bd-4183-ab15-c4265aa48126/scratchpad/w13-shots/connect-first-run-light.png
  • First run (dark): /private/tmp/claude-501/-Volumes-DevSSD-t3code/7a9093f7-05bd-4183-ab15-c4265aa48126/scratchpad/w13-shots/connect-first-run-dark.png
  • Saved environments, one needing pairing again: /private/tmp/claude-501/-Volumes-DevSSD-t3code/7a9093f7-05bd-4183-ab15-c4265aa48126/scratchpad/w13-shots/connect-saved-light.png
  • Titlebar status while reconnecting, with Retry (dark): /private/tmp/claude-501/-Volumes-DevSSD-t3code/7a9093f7-05bd-4183-ab15-c4265aa48126/scratchpad/w13-shots/status-reconnecting-dark.png

Not verified at runtime: actual clicks (the screen is locked), and t3 pair against the live desktop install, which was deliberately never run. That path runs ~/.t3/bin/t3 pair --label "T3 Code Native" --ttl 2m with no --base-dir, from ~.

Built by Claude Opus 5.5 (worker W13) in Claude Code.

…blocked-protocol status

Find the running server from <T3 home>/{userdata,dev}/server-runtime.json the way t3 pair does,
check its descriptor speaks our orchestration protocol, mint a token with the installed t3 pair,
and redeem it at the server's origin. Saved environments replace the single connection.json
(still read and migrated). The supervisor blocks a server on another protocol until Retry, keeps
the last failure while reconnecting, and can skip its backoff. status.rs ports the web's
connection presentation and direct-route diagnosis.
…t switcher, status indicator

The connect screen offers Connect to T3 Code on this Mac when a server is running, lists saved
environments (connect, pair again, remove), and keeps the paste-a-link flow. It doubles as the
switcher (app menu, command palette, Settings). The titlebar shows connecting/reconnecting with
the diagnosis as a tooltip and Retry; a rejected credential returns to the connect screen with a
re-pair prompt.
…r unpaired homes

A primary and default size on the settings Button replace the composer one, whose 160px label cap
cut off Connect to T3 Code on this Mac. The pasted link clears once it pairs. The snapshot tool
copies saved environments and renders the connect screen when there are none.
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