Open History to see the last commit
1# Remote access
2
3Connect a phone, browser, or another desktop app to T3 Code running on a different
4machine. That machine must stay running and reachable while you work.
5
6## T3 Connect
7
8T3 Connect makes an environment available to your other devices without setting
9up router forwarding. In the desktop app on the host, open **Settings →
10Connections**, sign in, and enable **T3 Connect** for that environment.
11
12For a command-line host, run:
13
14```bash
15npx t3@latest connect
16```
17
18Follow the sign-in instructions. Setup offers a
19[background service](./background-service.md); if you decline it, start the
20server with `npx t3 serve`. Saving your sign-in alone does not make the machine
21reachable.
22
23On your other device, sign in to the same T3 Connect account and choose the
24environment. Over SSH, the CLI prints a browser link and accepts the returned
25authorization code, so you do not need to forward an OAuth callback port.
26
27T3 Connect renews access credentials when needed without disconnecting a healthy
28connection. Pull request diffs and provider settings keep working after the
29previous credential expires. A failed renewal affects that request; it does not
30disconnect an otherwise healthy conversation.
31
32## Pair over a LAN or private network
33
34Use direct pairing when the other device can reach the host's network address.
35
36On a desktop host, open **Settings → Connections**, enable **Network access**,
37then create a pairing link using an address the other device can reach. Changing
38network access restarts the desktop app. You can turn it off in the same place.
39
40For a command-line host, replace `<private-ip>` with the host's LAN or tailnet
41address:
42
43```bash
44npx t3 serve --host <private-ip>
45```
46
47If a server is already running, generate a fresh link without restarting it:
48
49```bash
50npx t3 pair
51```
52
53Scan the QR code on your phone or paste the pairing URL into **Add environment**
54in the receiving app. Connection settings are under **Settings → Connections**
55on web and desktop and **Settings → Environments** on mobile. A loopback address
56such as `127.0.0.1` reaches only the device opening the link.
57
58Pairing authorizes that device for future connections. Use a fresh one-time link
59for each new device; you do not need the original token to reconnect. Links
60created in Settings can only be copied from the client that created them while
61its Connections page stays open. If you leave or reload that page, create
62another link to share.
63
64### Balance new threads across machines
65
66Auto balance is off by default. On web and desktop, enable it in
67**Settings → Connections → Load balancing** to automatically choose a machine for
68new threads in projects grouped across connected environments. The section
69appears once two or more machines are switched on.
70Each machine starts at **Normal**. Choose **Prefer** to favor it when it has CPU and
71memory available, **Less often** to reduce its share, or **Manual only** to exclude
72it from automatic selection. These are preferences, not fixed traffic percentages.
73Preferences are saved separately in each client.
74
75The composer checks eligible machines when choosing a draft's environment, then keeps
76that choice stable. Choose **Auto balance** again to check current resources, or choose
77a specific machine to override it. Choosing a branch or worktree also keeps the draft
78on that machine. Existing threads stay where they started. If resource checks are
79unavailable or all eligible machines are full, choose a machine manually to continue.
80Mobile keeps its manual environment selection.
81
82### Tailscale HTTPS
83
84Join both devices to the same tailnet. In the desktop app, enable **Tailscale
85HTTPS** in **Settings → Connections**. Turn it off there to remove that route.
86
87To start a command-line server with Tailscale HTTPS:
88
89```bash
90npx t3 serve --tailscale-serve
91```
92
93For an already-running server:
94
95```bash
96npx t3 pair --tailscale
97```
98
99The pairing link uses an address such as `https://machine.tailnet.ts.net/`.
100The mapping created by `pair --tailscale` persists across restarts. Remove its
101default-port mapping with:
102
103```bash
104tailscale serve --https=443 off
105```
106
107If that port is already in use, choose another with
108`--tailscale-serve-port`. See `npx t3 pair --help` for other pairing options.
109
110### Hosted web app
111
112[app.t3.codes](https://app.t3.codes) needs an HTTPS endpoint. It connects directly
113to your server; a hosted pairing link does not make an unreachable backend
114reachable or convert HTTP to HTTPS.
115
116For a plain HTTP LAN endpoint, use the direct pairing URL in a browser that can
117open it, or pair from the desktop app. On mobile, an IP address entered without a
118scheme uses HTTP, so include `https://` when your server uses HTTPS.
119
120## Desktop-managed SSH
121
122In the desktop app, open **Settings → Connections → Add environment**, choose
123**SSH**, and enter a host or SSH alias such as `user@example.com`. T3 Code starts
124or reuses a server there and opens the port forward for you. Projects, provider
125credentials, and agent work stay on the remote machine.
126
127The remote host needs a compatible [Node.js installation](./install.md#requirements)
128and [provider setup](./install.md#providers). If launch cannot find Node or reports
129an incompatible version, check it through a non-interactive SSH session:
130
131```bash
132ssh user@example.com 'sh -lc "command -v node && node --version"'
133```
134
135Configure your version manager for non-interactive shells if this differs from
136your normal terminal. With nvm, setting a compatible default, such as
137`nvm alias default 24`, can resolve the problem.
138
139If SSH reconnecting fails after an app update, retry the launch once. Removing
140the connection stops a server that T3 Code launched; a server that was already
141running is left alone.
142
143For Antigravity's Google callback on a remote host, see
144[remote sign-in](./providers-antigravity.md#sign-in-from-a-remote-device).
145
146## Manage or revoke access
147
148On the host, **Settings → Connections** lets authorized administrators create
149pairing links and revoke client sessions. Revoking an unused link prevents new
150pairings; revoke a device's session to remove its existing access. Command-line
151management is available through `npx t3 auth --help`.
152
153A session with an open connection stays listed after its access credential
154expires.
155
156To remove an environment from T3 Connect, open your account menu's **T3 Connect**
157page, or **Settings → T3 Connect** on mobile, and choose **Deregister**. This
158revokes its cloud access and frees its host space even when the environment is
159offline or has been wiped.
160
161On a command-line host, `t3 connect unlink` disables exposure while retaining
162your login; `t3 connect logout` also clears that login. Background-service
163[removal](./background-service.md#manage-the-service) is separate.
164
165Treat pairing URLs and authorization codes as passwords. Do not include them in
166screenshots, logs, or bug reports.
167
168## T3 Connect troubleshooting
169
170Run `t3 connect status` on the host to inspect saved authorization and link
171configuration. It is not a live reachability check. If the environment appears
172offline, run `t3 service status` and read the displayed log. If it disappears
173when SSH closes, see [background-service troubleshooting](./background-service.md#troubleshooting).
174
175| Error | Recovery |
176| --------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
177| `environment_link_limit_exceeded` or managed tunnel limit | Deregister an unused environment, then restart T3 Code on the host. |
178| `auth_invalid` or `invalid_bearer` | Run `t3 connect login`. If credentials were revoked, run `t3 connect logout`, then `t3 connect` again. Restart the server after signing in. |
179| Expired or invalid link proof | Check the host's date and time, update T3 Code, then restart it. |
180| HTTP 403 without a recognized error | Check relay access, proxies, and firewall rules. Keep any Cloudflare Ray ID for a bug report. |
181| HTTP 408, 429, or 5xx | Check network and relay availability. Startup retries temporary failures for up to ten minutes. |
182
183After fixing a permanent rejection, restart the host's server. On Linux, use
184`systemctl --user restart t3code.service` for the background service. For a
185foreground server, stop it and run `t3 serve` again with your usual options.
186Include the diagnostic message and trace ID when reporting a persistent failure.
187
188For a connection that still fails after linking, check the date and time on both
189devices. For server version warnings, follow [Updating T3 Code](./updating.md).
190
191## Using the Desktop App as a Remote Only
192
193If a computer should only drive work running elsewhere, turn off its local environment. In the
194desktop app, open **Settings → Connections** and switch off **Local
195environment**. T3 Code restarts without a local server: no local agents or terminals run, WSL
196backends stay off, and other devices can no longer connect to this computer. Your projects,
197history, and saved connections are kept, and you keep working through pairing, T3 Connect, or SSH.
198
199Switch **Local environment** back on in the same place to restart with your previous local
200settings.