The best way to control Claude Code, Codex and more from any computer or phone
docs: split user and maintainer docs, fix 100+ stale claims (#4807)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Theo Browne committed
Jul 30, 2026 at 06:10 UTC
9dd425b2234c062b4767583e42d4b2c1aabab15d
41 files changed
+1482
-1400
AGENTS.md
+5
-5
@@ -28,7 +28,7 @@ T3 Code has 3 key app surfaces: **web**, **desktop**, and **mobile**.
28
29
**Desktop** is the main surface most users install first. It's a full Electron app that bundles the server runner as well. The desktop app can also be used as the host server, allowing remote connections from app.t3.codes or the mobile app.
30
31
-**Mobile** is a React native app for both iOS and Android. The mobile app allows for connecting to any T3 Code server to control work remotely. It is still in early access (Testflight), but it is pretty close to shipping globally.
31
+**Mobile** is a React Native app for both iOS and Android, available on the App Store and Google Play. The mobile app allows for connecting to any T3 Code server to control work remotely.
32
33
## A note from Theo
34
@@ -72,7 +72,7 @@ The most common defect in this repo is a change that works on the path you teste
72
- **Contracts.** Anything crossing the wire is typed in `packages/contracts`. Change the schema and the server, web, mobile, and desktop all follow.
73
- **Reverse states.** If you added a way in, add the way out and the way to see it. Snooze needs unsnooze. Close needs reopen. A one-way door is a bug.
74
- **Connection modes.** Local, remote/relay, and tunnel behave differently. Multi-device and multi-environment cases are real.
75
-- **Docs.** `docs/` mirrors this structure. Behavior changes that a user would notice belong in `docs/user/`; architecture changes in `docs/architecture/`; new vocabulary in `docs/reference/encyclopedia.md`.
75
+- **Docs.** `docs/` splits by audience. Behavior changes that a user would notice belong in `docs/user/` (shipped-product voice, no repo tooling or source paths); architecture and contributor changes in `docs/internals/`; runbooks in `docs/operations/`; new vocabulary in `docs/internals/glossary.md`.
76
77
## Dev servers
78
@@ -123,13 +123,13 @@ An empty database is a bad test. Seed your worktree's `.t3` with a copy of real
123
124
Clients send typed WebSocket requests. The server turns them into _commands_, a pure _decider_ turns commands into persisted _events_, and a _projector_ derives the read model the UI renders. Provider CLIs run as subprocesses; per-provider _adapters_ translate their native protocols into orchestration events. Side effects run in queue-backed _reactors_ that emit _receipts_ when milestones land. Each turn ends with a _checkpoint_, a hidden git ref, so the app can diff and restore.
125
126
-Full glossary with file links: `docs/reference/encyclopedia.md`
126
+Full glossary with file links: `docs/internals/glossary.md`
127
128
## Where code lives
129
130
-- `apps/server` - WebSocket, orchestration, providers, checkpointing. Effect-heavy: read `.repos/effect-smol/LLMS.md` and `docs/operations/effect-fn-checklist.md` before writing Effect code.
130
+- `apps/server` - WebSocket, orchestration, providers, checkpointing. Effect-heavy: read `.repos/effect-smol/LLMS.md` before writing Effect code.
131
- `apps/web` - React/Vite UI. `apps/desktop` wraps it, `apps/mobile` is React Native, `apps/marketing` is the site.
132
-- `packages/contracts` - Effect/Schema contracts. Schema only, no runtime logic.
132
+- `packages/contracts` - Effect/Schema contracts plus small derived helpers. No heavy runtime logic.
133
- `packages/shared` - shared runtime utils, subpath exports, no barrel.
134
- `packages/client-runtime` - client code shared by web and mobile.
135
- `.repos/` - vendored read-only references. Prefer their patterns over invented ones. Never edit or import from them. Sync with `vpr sync:repos` when bumping the matching dependency.
README.md
+14
-11
@@ -17,13 +17,13 @@ We wanted something performant, remote-ready, and truly open. If we ever go the
17
>
18
> - Codex: install [Codex CLI](https://developers.openai.com/codex/cli) and run `codex login`
19
> - Claude: install [Claude Code](https://claude.com/product/claude-code) and run `claude auth login`
20
-> - Cursor: install [Cursor CLI](https://cursor.com/cli) and run `cursor-agent login`
20
+> - Cursor: install [Cursor CLI](https://cursor.com/cli) and run `agent login`
21
> - Grok Build: install [Grok Build CLI](https://x.ai/cli) and run `grok login`
22
> - OpenCode: install [OpenCode](https://opencode.ai) and run `opencode auth login`
23
24
### Try it out (install-free)
25
26
-The easiest way to test T3 Code is to run the server in your terminal:
26
+The easiest way to test T3 Code is to run the server in your terminal (requires Node.js 22.16+, 23.11+, or 24.10+):
27
28
```bash
29
npx t3@latest
@@ -61,17 +61,20 @@ We are very very early in this project. Expect bugs.
61
62
We are (mostly) not accepting contributions yet. Small fixes may be considered. Big features will not be.
63
64
-There's no public docs site yet, checkout the miscellaneous markdown files in [docs](./docs).
65
-
64
## Documentation
65
68
-- [Getting started](./docs/getting-started/quick-start.md)
69
-- [Remote access](./docs/user/remote-access.md)
70
-- [Keeping T3 Code in sync](./docs/user/server-updates.md)
71
-- [Architecture overview](./docs/architecture/overview.md)
72
-- [Provider guides](./docs/providers/codex.md)
73
-- [Operations](./docs/operations/ci.md)
74
-- [Reference](./docs/reference/encyclopedia.md)
66
+Full docs live in [docs/](./docs). There's no docs site yet.
67
+
68
+- [Install and first run](./docs/user/install.md)
69
+- [Permission modes](./docs/user/permission-modes.md)
70
+- [Keyboard shortcuts](./docs/user/keybindings.md)
71
+- [Remote access from a phone or another machine](./docs/user/remote-access.md)
72
+- [Keeping app and server in sync](./docs/user/updating.md)
73
+- [Source control integrations](./docs/user/source-control.md)
74
+- Multiple accounts: [Codex](./docs/user/providers-codex.md) · [Claude](./docs/user/providers-claude.md)
75
+- Linux: [run T3 Code as a background service](./docs/user/background-service.md)
76
+
77
+Building from source? Start at [docs/internals/overview.md](./docs/internals/overview.md).
78
79
## If you REALLY want to contribute still.... read this first
80
docs/README.md
+41
-19
@@ -1,19 +1,41 @@
1
-# Documentation
2
-
3
-- [Getting started](./getting-started/quick-start.md)
4
-- Architecture
5
- - [Overview](./architecture/overview.md)
6
- - [Connection runtime](./architecture/connection-runtime.md)
7
- - [Remote environments](./architecture/remote.md)
8
- - [Server updates](./architecture/server-updates.md)
9
-- User guides
10
- - [Background service](./user/background-service.md)
11
- - [Remote access](./user/remote-access.md)
12
- - [Keeping T3 Code in sync](./user/server-updates.md)
13
- - [Keybindings](./user/keybindings.md)
14
-- [T3 Connect](./cloud/t3-connect-clerk.md)
15
-- [Integrations](./integrations/source-control-providers.md)
16
-- [Mobile](./mobile/app.md)
17
-- [Operations](./operations/ci.md)
18
-- [Providers](./providers/codex.md)
19
-- [Reference](./reference/encyclopedia.md)
1
+# T3 Code docs
2
+
3
+## Using T3 Code
4
+
5
+- [Install and first run](./user/install.md)
6
+- [Permission modes](./user/permission-modes.md)
7
+- [Keyboard shortcuts](./user/keybindings.md)
8
+- [Remote access](./user/remote-access.md)
9
+- [Keeping app and server in sync](./user/updating.md)
10
+- [Source control integrations](./user/source-control.md)
11
+- [Background service (Linux)](./user/background-service.md)
12
+- Providers: [Codex](./user/providers-codex.md) · [Claude](./user/providers-claude.md)
13
+
14
+Mobile app: [apps/mobile/README.md](../apps/mobile/README.md)
15
+
16
+---
17
+
18
+## Working on T3 Code
19
+
20
+Everything below is for maintainers. Setup lives in the [root README](../README.md);
21
+policy in [CONTRIBUTING.md](../CONTRIBUTING.md); agent rules in [AGENTS.md](../AGENTS.md).
22
+
23
+- [Architecture overview](./internals/overview.md)
24
+- [Workspace layout](./internals/workspace-layout.md)
25
+- [Glossary](./internals/glossary.md)
26
+- [Scripts](./internals/scripts.md)
27
+- [Connection runtime](./internals/connection-runtime.md)
28
+- [Providers](./internals/providers.md)
29
+- [Remote environments](./internals/remote.md)
30
+- [Server updates](./internals/server-updates.md)
31
+- [Resource telemetry](./internals/resource-telemetry.md)
32
+- [Environment auth](./internals/environment-auth.md)
33
+- [T3 Connect](./internals/t3-connect.md)
34
+- [CI gates](./internals/ci.md)
35
+
36
+### Runbooks
37
+
38
+- [Release](./operations/release.md)
39
+- [Observability](./operations/observability.md)
40
+- [Relay observability](./operations/relay-observability.md)
41
+- [Mobile app store screenshots](./operations/mobile-app-store-screenshots.md)
docs/architecture/connection-runtime.md
deleted
-140
@@ -1,140 +0,0 @@
1
-# Connection Runtime
2
-
3
-The connection runtime is shared by web and mobile. It owns connectivity,
4
-authentication, retries, transport lifetime, cached environment data, and
5
-environment-scoped operations.
6
-
7
-Web and mobile mount this runtime once at the application root. There is no
8
-legacy connection owner or supported mixed mode.
9
-
10
-## Ownership
11
-
12
-Each registered environment has one scoped Effect `Context` containing focused
13
-services:
14
-
15
-- `EnvironmentSupervisor` owns desired state, retry scheduling, and the active
16
- session scope.
17
-- `ConnectionBroker` prepares credentials and endpoints for primary, bearer,
18
- relay, and SSH targets.
19
-- `RpcSessionFactory` performs one transport attempt. It does not retry.
20
-- `EnvironmentRpc` exposes the active session without leaking the transport.
21
-- `EnvironmentProjectCommands` and `EnvironmentThreadCommands` construct
22
- orchestration commands, IDs, and timestamps.
23
-- `EnvironmentShell` and `EnvironmentThreads` own live subscriptions and cached
24
- snapshots.
25
-
26
-`EnvironmentServicesFactory` assembles that context, and `EnvironmentRegistry`
27
-owns its scope. There is no aggregate environment runtime facade. React
28
-components do not create connections, transports, retry loops, or RPC clients.
29
-
30
-## Connection State
31
-
32
-The supervisor is the only retry owner.
33
-
34
-1. A persisted or platform registration marks an environment as desired.
35
-2. If the device is offline, the supervisor releases the active session and
36
- waits without consuming retry attempts.
37
-3. When online, the supervisor asks the broker for one prepared connection and
38
- asks the session factory for one RPC session.
39
-4. Transient failures retry forever with exponential backoff capped at 16
40
- seconds.
41
-5. Connectivity changes, application activation, credential changes, and
42
- explicit user retry interrupt the current wait and trigger a fresh attempt.
43
- Application activation also resets the backoff ladder. Mobile briefly probes
44
- a session after short interruptions and replaces it immediately after a
45
- meaningful background suspension.
46
-6. Authentication or configuration failures remain blocked until an external
47
- wakeup changes the relevant input.
48
-7. An involuntary session close keeps the registration and cache, then retries.
49
-8. Explicit removal closes the session and deletes the registration,
50
- credentials, shell cache, and thread cache.
51
-
52
-The UI derives `available`, `offline`, `connecting`, `reconnecting`,
53
-`connected`, and `error` from supervisor state plus explicit data-sync state.
54
-It does not infer connection health from cached data or the existence of a
55
-transport object. An environment becomes `connected` after the socket opens and
56
-the initial config RPC succeeds, proving that the server is responsive. Shell
57
-and thread synchronization are independent data states. A healthy RPC
58
-transport with a failed shell subscription is shown as connected with a
59
-synchronization error, not as a reconnect that is not actually scheduled.
60
-
61
-## Data Boundary
62
-
63
-Finite requests, durable subscriptions, and commands are separate APIs:
64
-
65
-- Query atoms revalidate when the RPC generation changes.
66
-- Subscription atoms switch to replacement sessions.
67
-- Expected subscription failures update domain sync state and wait for a
68
- replacement session; they do not take down a healthy transport.
69
-- Mutations resolve the current environment runtime at execution time.
70
-- Shell and thread snapshots are available while offline.
71
-- A connected transport may have `empty`, `cached`, `synchronizing`, `live`, or
72
- failed shell and thread data independently.
73
-- Cached shell and thread projections are never allowed to overwrite newer live
74
- data during a fast reconnect.
75
-- Domain atom factories route effects through the environment registry and
76
- resolve the current scoped service at execution time.
77
-- Web and mobile own their Atom runtimes, React hooks, and feature composition.
78
-
79
-The Promise bridge exists only at the React/Atom boundary. Runtime and business
80
-logic remain Effect-native.
81
-
82
-## Platform Layers
83
-
84
-Web and mobile provide:
85
-
86
-- network status and network-change streams;
87
-- application lifecycle wakeups;
88
-- cloud session credentials;
89
-- device identity;
90
-- platform registrations;
91
-- persistent catalog, credential, shell, and thread stores;
92
-- HTTP, crypto, and telemetry layers.
93
-
94
-Platform layers adapt operating-system capabilities. They do not implement
95
-connection policy.
96
-
97
-## Source Boundaries
98
-
99
-The public package subpaths mirror the runtime layers:
100
-
101
-- `connection/core` contains state, catalog, retry policy, and connectivity.
102
-- `connection/transport` contains brokerage, authorization, attempts, and RPC
103
- sessions.
104
-- `connection/platform` declares capabilities and persistence contracts.
105
-- `connection/services` contains environment-scoped data services.
106
-- `connection/application` assembles registries, discovery, and startup.
107
-- `connection/atoms` adapts shared services to application-owned Atom runtimes.
108
-- `connection/presentation` contains pure UI projections.
109
-
110
-Other reusable state lives in domain subpaths such as `shell`, `threads`,
111
-`terminal`, and `vcs`. Applications must import explicit package subpaths; the
112
-package intentionally has no root export.
113
-
114
-## Application Boundary
115
-
116
-The application root mounts the shared connection application layer, creates
117
-its own Atom runtime, and selects the domain atom factories required by that
118
-platform. Web and mobile may expose different hooks and features without
119
-changing connection ownership.
120
-
121
-Application code must not construct `WsTransport`, RPC clients, retry loops, or
122
-raw orchestration commands. Persistence paths belong to the platform
123
-registration and cache stores, with explicit migration or invalidation policy.
124
-
125
-## Verification
126
-
127
-Core state-machine tests use `@effect/vitest` and deterministic service layers.
128
-Required coverage includes:
129
-
130
-- offline startup and online wakeup;
131
-- forever retry with the 16-second cap;
132
-- explicit retry interrupting backoff;
133
-- authentication wakeups;
134
-- involuntary close and reconnect;
135
-- explicit removal clearing all owned state;
136
-- relay token reuse and refresh;
137
-- progressive relay discovery;
138
-- shell and thread cache hydration;
139
-- durable subscriptions switching sessions;
140
-- command metadata and idempotent queued-command metadata.
docs/architecture/overview.md
deleted
-141
@@ -1,141 +0,0 @@
1
-# Architecture
2
-
3
-T3 Code runs as a **Node.js WebSocket server** that wraps `codex app-server` (JSON-RPC over stdio) and serves a React web app.
4
-
5
-```
6
-┌─────────────────────────────────┐
7
-│ Browser (React + Vite) │
8
-│ wsTransport (state machine) │
9
-│ Typed push decode at boundary │
10
-└──────────┬──────────────────────┘
11
- │ ws://localhost:3773
12
-┌──────────▼──────────────────────┐
13
-│ apps/server (Node.js) │
14
-│ WebSocket + HTTP static server │
15
-│ ServerPushBus (ordered pushes) │
16
-│ ServerReadiness (startup gate) │
17
-│ OrchestrationEngine │
18
-│ ProviderService │
19
-│ CheckpointReactor │
20
-│ RuntimeReceiptBus │
21
-└──────────┬──────────────────────┘
22
- │ JSON-RPC over stdio
23
-┌──────────▼──────────────────────┐
24
-│ codex app-server │
25
-└─────────────────────────────────┘
26
-```
27
-
28
-## Components
29
-
30
-- **Browser app**: The React app renders session state, owns the client-side WebSocket transport, and treats typed push events as the boundary between server runtime details and UI state.
31
-
32
-- **Server**: `apps/server` is the main coordinator. It serves the web app, accepts WebSocket requests, waits for startup readiness before welcoming clients, and sends all outbound pushes through a single ordered push path.
33
-
34
-- **Provider runtime**: `codex app-server` does the actual provider/session work. The server talks to it over JSON-RPC on stdio and translates those runtime events into the app's orchestration model.
35
-
36
-- **Background workers**: Long-running async flows such as runtime ingestion, command reaction, and checkpoint processing run as queue-backed workers. This keeps work ordered, reduces timing races, and gives tests a deterministic way to wait for the system to go idle.
37
-
38
-- **Runtime signals**: The server emits lightweight typed receipts when important async milestones finish, such as checkpoint capture, diff finalization, or a turn becoming fully quiescent. Tests and orchestration code wait on these signals instead of polling internal state.
39
-
40
-- **Server updates**: A connected environment advertises whether its server can replace itself. When client and server versions differ, the browser selects an automatic, desktop-managed, or manual update path without changing connection ownership. See [Server Update Architecture](./server-updates.md).
41
-
42
-Related design:
43
-
44
-- [Resource telemetry architecture](./resource-telemetry.md)
45
-
46
-## Event Lifecycle
47
-
48
-### Startup and client connect
49
-
50
-```mermaid
51
-sequenceDiagram
52
- participant Browser
53
- participant Transport as WsTransport
54
- participant Server as wsServer
55
- participant Layers as serverLayers
56
- participant Ready as ServerReadiness
57
- participant Push as ServerPushBus
58
-
59
- Browser->>Transport: Load app and open WebSocket
60
- Transport->>Server: Connect
61
- Server->>Layers: Start runtime services
62
- Server->>Ready: Wait for startup barriers
63
- Ready-->>Server: Ready
64
- Server->>Push: Publish server.welcome
65
- Push-->>Transport: Ordered welcome push
66
- Transport-->>Browser: Hydrate initial state
67
-```
68
-
69
-1. The browser boots `WsTransport` and registers typed listeners in `wsNativeApi`.
70
-2. The server accepts the connection in `wsServer` and brings up the runtime graph defined in `serverLayers`.
71
-3. `ServerReadiness` waits until the key startup barriers are complete.
72
-4. Once the server is ready, `wsServer` sends `server.welcome` from the contracts in `ws.ts` through `ServerPushBus`.
73
-5. The browser receives that ordered push through `WsTransport`, and `wsNativeApi` uses it to seed local client state.
74
-
75
-### User turn flow
76
-
77
-```mermaid
78
-sequenceDiagram
79
- participant Browser
80
- participant Transport as WsTransport
81
- participant Server as wsServer
82
- participant Provider as ProviderService
83
- participant Codex as codex app-server
84
- participant Ingest as ProviderRuntimeIngestion
85
- participant Engine as OrchestrationEngine
86
- participant Push as ServerPushBus
87
-
88
- Browser->>Transport: Send user action
89
- Transport->>Server: Typed WebSocket request
90
- Server->>Provider: Route request
91
- Provider->>Codex: JSON-RPC over stdio
92
- Codex-->>Ingest: Provider runtime events
93
- Ingest->>Engine: Normalize into orchestration events
94
- Engine-->>Server: Domain events
95
- Server->>Push: Publish orchestration.domainEvent
96
- Push-->>Browser: Typed push
97
-```
98
-
99
-1. A user action in the browser becomes a typed request through `WsTransport` and the browser API layer in `nativeApi`.
100
-2. `wsServer` decodes that request using the shared WebSocket contracts in `ws.ts` and routes it to the right service.
101
-3. [`ProviderService`][8] starts or resumes a session and talks to `codex app-server` over JSON-RPC on stdio.
102
-4. Provider-native events are pulled back into the server by [`ProviderRuntimeIngestion`][9], which converts them into orchestration events.
103
-5. [`OrchestrationEngine`][10] persists those events, updates the read model, and exposes them as domain events.
104
-6. `wsServer` pushes those updates to the browser through `ServerPushBus` on channels defined in [`orchestration.ts`][11].
105
-
106
-### Async completion flow
107
-
108
-```mermaid
109
-sequenceDiagram
110
- participant Server as wsServer
111
- participant Worker as Queue-backed workers
112
- participant Cmd as ProviderCommandReactor
113
- participant Checkpoint as CheckpointReactor
114
- participant Receipt as RuntimeReceiptBus
115
- participant Push as ServerPushBus
116
- participant Browser
117
-
118
- Server->>Worker: Enqueue follow-up work
119
- Worker->>Cmd: Process provider commands
120
- Worker->>Checkpoint: Process checkpoint tasks
121
- Checkpoint->>Receipt: Publish completion receipt
122
- Cmd-->>Server: Produce orchestration changes
123
- Checkpoint-->>Server: Produce orchestration changes
124
- Server->>Push: Publish resulting state updates
125
- Push-->>Browser: User-visible push
126
-```
127
-
128
-1. Some work continues after the initial request returns, especially in [`ProviderRuntimeIngestion`][9], [`ProviderCommandReactor`][13], and [`CheckpointReactor`][14].
129
-2. These flows run as queue-backed workers using [`DrainableWorker`][16], which helps keep side effects ordered and test synchronization deterministic.
130
-3. When a milestone completes, the server emits a typed receipt on [`RuntimeReceiptBus`][15], such as checkpoint completion or turn quiescence.
131
-4. Tests and orchestration code wait on those receipts instead of polling git state, projections, or timers.
132
-5. Any user-visible state changes produced by that async work still go back through `wsServer` and `ServerPushBus`.
133
-
134
-[8]: ../../apps/server/src/provider/Layers/ProviderService.ts
135
-[9]: ../../apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts
136
-[10]: ../../apps/server/src/orchestration/Layers/OrchestrationEngine.ts
137
-[11]: ../../packages/contracts/src/orchestration.ts
138
-[13]: ../../apps/server/src/orchestration/Layers/ProviderCommandReactor.ts
139
-[14]: ../../apps/server/src/orchestration/Layers/CheckpointReactor.ts
140
-[15]: ../../apps/server/src/orchestration/Layers/RuntimeReceiptBus.ts
141
-[16]: ../../packages/shared/src/DrainableWorker.ts
docs/architecture/providers.md
deleted
-30
@@ -1,30 +0,0 @@
1
-# Provider architecture
2
-
3
-The web app communicates with the server via WebSocket using a simple JSON-RPC-style protocol:
4
-
5
-- **Request/Response**: `{ id, method, params }` → `{ id, result }` or `{ id, error }`
6
-- **Push events**: typed envelopes with `channel`, `sequence` (monotonic per connection), and channel-specific `data`
7
-
8
-Push channels: `server.welcome`, `server.configUpdated`, `terminal.event`, `orchestration.domainEvent`. Payloads are schema-validated at the transport boundary (`wsTransport.ts`). Decode failures produce structured `WsDecodeDiagnostic` with `code`, `reason`, and path info.
9
-
10
-Methods mirror the `NativeApi` interface defined in `@t3tools/contracts`:
11
-
12
-- `providers.startSession`, `providers.sendTurn`, `providers.interruptTurn`
13
-- `providers.respondToRequest`, `providers.stopSession`
14
-- `shell.openInEditor`, `server.getConfig`
15
-
16
-Codex is the only implemented provider. `claudeCode` is reserved in contracts/UI.
17
-
18
-## Client transport
19
-
20
-`wsTransport.ts` manages connection state: `connecting` → `open` → `reconnecting` → `closed` → `disposed`. Outbound requests are queued while disconnected and flushed on reconnect. Inbound pushes are decoded and validated at the boundary, then cached per channel. Subscribers can opt into `replayLatest` to receive the last push on subscribe.
21
-
22
-## Server-side orchestration layers
23
-
24
-Provider runtime events flow through queue-based workers:
25
-
26
-1. **ProviderRuntimeIngestion** — consumes provider runtime streams, emits orchestration commands
27
-2. **ProviderCommandReactor** — reacts to orchestration intent events, dispatches provider calls
28
-3. **CheckpointReactor** — captures git checkpoints on turn start/complete, publishes runtime receipts
29
-
30
-All three use `DrainableWorker` internally and expose `drain()` for deterministic test synchronization.
docs/architecture/remote.md
deleted
-397
@@ -1,397 +0,0 @@
1
-# Remote Architecture
2
-
3
-This document describes the target architecture for first-class remote environments in T3 Code.
4
-
5
-It is intentionally architecture-first. It does not define a complete implementation plan or user-facing rollout checklist. The goal is to establish the core model so remote support can be added without another broad rewrite.
6
-
7
-## Goals
8
-
9
-- Treat remote environments as first-class product primitives, not special cases.
10
-- Support multiple ways to reach the same environment.
11
-- Keep the T3 server as the execution boundary.
12
-- Let desktop, mobile, and web all share the same conceptual model.
13
-- Avoid introducing a local control plane unless product pressure proves it is necessary.
14
-
15
-## Non-goals
16
-
17
-- Replacing the existing WebSocket server boundary with a custom transport protocol.
18
-- Making SSH the only remote story.
19
-- Syncing provider auth across machines.
20
-- Shipping every access method in the first iteration.
21
-
22
-## High-level architecture
23
-
24
-T3 already has a clean runtime boundary: the client talks to a T3 server over HTTP/WebSocket, and the server owns orchestration, providers, terminals, git, and filesystem operations.
25
-
26
-Remote support should preserve that boundary.
27
-
28
-```text
29
-┌──────────────────────────────────────────────┐
30
-│ Client (desktop / mobile / web) │
31
-│ │
32
-│ - known environments │
33
-│ - connection manager │
34
-│ - environment-aware routing │
35
-└───────────────┬──────────────────────────────┘
36
- │
37
- │ resolves one access endpoint
38
- │
39
-┌───────────────▼──────────────────────────────┐
40
-│ Access method │
41
-│ │
42
-│ - direct ws / wss │
43
-│ - tunneled ws / wss │
44
-│ - desktop-managed ssh bootstrap + forward │
45
-└───────────────┬──────────────────────────────┘
46
- │
47
- │ connects to one T3 server
48
- │
49
-┌───────────────▼──────────────────────────────┐
50
-│ Execution environment = one T3 server │
51
-│ │
52
-│ - environment identity │
53
-│ - provider state │
54
-│ - projects / threads / terminals │
55
-│ - git / filesystem / process runtime │
56
-└──────────────────────────────────────────────┘
57
-```
58
-
59
-The important decision is that remoteness is expressed at the environment connection layer, not by splitting the T3 runtime itself.
60
-
61
-## Domain model
62
-
63
-### ExecutionEnvironment
64
-
65
-An `ExecutionEnvironment` is one running T3 server instance.
66
-
67
-It is the unit that owns:
68
-
69
-- provider availability and auth state
70
-- model availability
71
-- projects and threads
72
-- terminal processes
73
-- filesystem access
74
-- git operations
75
-- server settings
76
-
77
-It is identified by a stable `environmentId`.
78
-
79
-This is the shared cross-client primitive. Desktop, mobile, and web should all reason about the same concept here.
80
-
81
-### KnownEnvironment
82
-
83
-A `KnownEnvironment` is a client-side saved entry for an environment the client knows how to reach.
84
-
85
-It is not server-authored. It is local to a device or client profile.
86
-
87
-Examples:
88
-
89
-- a saved LAN URL
90
-- a saved public `wss://` endpoint
91
-- a desktop-managed SSH host entry
92
-- a saved tunneled environment
93
-
94
-A known environment may or may not know the target `environmentId` before first successful connect.
95
-
96
-In the hosted web app, known environments are browser-local. A hosted pairing URL can create the saved entry, but it does not give the hosted app a server-side control plane or a copy of the session state.
97
-
98
-### AccessEndpoint
99
-
100
-An `AccessEndpoint` is one concrete way to reach a known environment.
101
-
102
-This is the key abstraction that keeps SSH from taking over the model.
103
-
104
-A single environment may have many endpoints:
105
-
106
-- `wss://t3.example.com`
107
-- `ws://10.0.0.25:3773`
108
-- a tunneled relay URL
109
-- a desktop-managed SSH tunnel that resolves to a local forwarded WebSocket URL
110
-
111
-The environment stays the same. Only the access path changes.
112
-
113
-### AdvertisedEndpoint
114
-
115
-An `AdvertisedEndpoint` is a server or desktop-authored candidate endpoint for an environment. It is how the backend tells the client which URLs may be useful for pairing and reconnecting.
116
-
117
-`AdvertisedEndpoint` is deliberately narrower than the full access model:
118
-
119
-- it describes a concrete HTTP and WebSocket base URL pair
120
-- it can mark the endpoint as default, available, or unavailable
121
-- it includes reachability hints such as loopback, LAN, private, public, or tunnel
122
-- it includes compatibility hints such as whether the endpoint can be used from the hosted HTTPS app
123
-
124
-Clients should treat advertised endpoints as hints, not as proof that a route works from the current device. The final connection attempt still decides whether the endpoint is reachable.
125
-
126
-The UI presents one default advertised endpoint in the network-access summary and keeps the rest behind an expandable advanced list. The default controls pairing QR codes and primary copy actions. Users can override it, but that override is a UI preference, not backend configuration.
127
-
128
-Persist the override by stable endpoint kind rather than raw URL whenever possible. For example, a LAN endpoint should be stored as the desktop LAN endpoint preference, not as `192.168.x.y`, because the address can change when the user switches networks. Provider endpoints should use provider-specific stable keys such as Tailscale IP or Tailscale MagicDNS HTTPS. Custom endpoints may fall back to their concrete identity.
129
-
130
-When no user default is saved, endpoint selection should prefer:
131
-
132
-1. endpoints compatible with the hosted HTTPS app
133
-2. explicitly default endpoints
134
-3. non-loopback endpoints
135
-4. loopback endpoints only for same-machine clients
136
-
137
-This keeps endpoint discovery centralized without making any one provider, such as Tailscale or a future tunnel service, part of the core environment model.
138
-
139
-### Endpoint providers
140
-
141
-Endpoint providers are add-ons that contribute advertised endpoints for the current environment.
142
-
143
-The provider boundary is intentionally outside the core environment model:
144
-
145
-- core owns `ExecutionEnvironment`, saved environments, pairing, and connection lifecycle
146
-- providers discover or synthesize endpoints
147
-- providers return normalized `AdvertisedEndpoint` records
148
-- the UI and pairing logic select from those records without knowing provider-specific commands
149
-
150
-The first provider is Tailscale. It can discover Tailnet IP and MagicDNS addresses from the local machine and publish them as additional endpoint candidates. Future providers, such as a hosted tunnel service, should plug into the same shape rather than adding a separate remote environment path.
151
-
152
-Provider-specific confidence should remain a hint. A Tailscale endpoint still needs a successful browser or desktop connection before the client treats it as connected.
153
-
154
-### Hosted pairing request
155
-
156
-A hosted pairing request is a bootstrap URL for the static web app, not a transport.
157
-
158
-Example:
159
-
160
-```text
161
-https://app.t3.codes/pair?host=https://backend.example.com:3773#token=PAIRCODE
162
-```
163
-
164
-The hosted app reads the `host` parameter and pairing token, exchanges the token directly with that backend, then saves the resulting environment record in browser local storage.
165
-
166
-Important constraints:
167
-
168
-- the hosted app does not proxy HTTP or WebSocket traffic
169
-- the backend must still be reachable directly from the browser
170
-- HTTPS pages can only connect to HTTPS/WSS backends
171
-- HTTP LAN endpoints should keep using direct desktop or CLI pairing URLs
172
-- the token belongs in the URL hash so it is not sent to the hosted app origin
173
-
174
-### RepositoryIdentity
175
-
176
-`RepositoryIdentity` remains a best-effort logical repo grouping mechanism across environments.
177
-
178
-It is not used for routing. It is only used for UI grouping and correlation between local and remote clones of the same repository.
179
-
180
-### Workspace / Project
181
-
182
-The current `Project` model remains environment-local.
183
-
184
-That means:
185
-
186
-- a local clone and a remote clone are different projects
187
-- they may share a `RepositoryIdentity`
188
-- threads still bind to one project in one environment
189
-
190
-## Access methods
191
-
192
-Access methods answer one question:
193
-
194
-How does the client speak WebSocket to a T3 server?
195
-
196
-They do not answer:
197
-
198
-- how the server got started
199
-- who manages the server process
200
-- whether the environment is local or remote
201
-
202
-### 1. Direct WebSocket access
203
-
204
-Examples:
205
-
206
-- `ws://10.0.0.15:3773`
207
-- `wss://t3.example.com`
208
-
209
-This is the base model and should be the first-class default.
210
-
211
-Benefits:
212
-
213
-- works for desktop, mobile, and web
214
-- no client-specific process management required
215
-- best fit for hosted or self-managed remote T3 deployments
216
-
217
-Browser security rules are part of this access method. A hosted HTTPS web client can connect to `wss://` backends, but it cannot connect to plain `ws://` or `http://` LAN backends because that would be mixed content.
218
-
219
-### 2. Tunneled WebSocket access
220
-
221
-Examples:
222
-
223
-- public relay URLs
224
-- private network relay URLs
225
-- local tunnel products such as pipenet
226
-
227
-This is still direct WebSocket access from the client's perspective. The difference is that the route is mediated by a tunnel or relay.
228
-
229
-For T3, tunnels are best modeled as another `AccessEndpoint`, not as a different kind of environment.
230
-
231
-This is especially useful when:
232
-
233
-- the host is behind NAT
234
-- inbound ports are unavailable
235
-- mobile must reach a desktop-hosted environment
236
-- a machine should be reachable without exposing raw LAN or public ports
237
-
238
-Tailscale-backed access sits here architecturally even though the current implementation is endpoint discovery rather than a T3-managed tunnel. It contributes private-network endpoints and lets the existing HTTP/WebSocket client path do the actual connection.
239
-
240
-### 3. Desktop-managed SSH access
241
-
242
-SSH is an access and launch helper, not a separate environment type.
243
-
244
-The desktop main process can use SSH to:
245
-
246
-- reach a machine
247
-- probe it
248
-- launch or reuse a remote T3 server
249
-- establish a local port forward
250
-
251
-After that, the renderer should still connect using an ordinary WebSocket URL against the forwarded local port.
252
-
253
-This keeps the renderer transport model consistent with every other access method.
254
-
255
-The desktop main process owns the SSH bridge because it can spawn local SSH processes, manage askpass prompts, write temporary launch scripts, and clean up forwards. The renderer receives a saved environment record and connects through the forwarded URL; it should not need SSH-specific RPC paths for normal environment traffic.
256
-
257
-## Launch methods
258
-
259
-Launch methods answer a different question:
260
-
261
-How does a T3 server come to exist on the target machine?
262
-
263
-Launch and access should stay separate in the design.
264
-
265
-### 1. Pre-existing server
266
-
267
-The simplest launch method is no launch at all.
268
-
269
-The user or operator already runs T3 on the target machine, and the client connects through a direct or tunneled WebSocket endpoint.
270
-
271
-This should be the first remote mode shipped because it validates the environment model with minimal extra machinery.
272
-
273
-### 2. Desktop-managed remote launch over SSH
274
-
275
-This is the main place where Zed is a useful reference.
276
-
277
-Useful ideas to borrow from Zed:
278
-
279
-- remote probing
280
-- platform detection
281
-- session directories with pid/log metadata
282
-- reconnect-friendly launcher behavior
283
-- desktop-owned connection UX
284
-
285
-What should be different in T3:
286
-
287
-- no custom stdio/socket proxy protocol between renderer and remote runtime
288
-- no attempt to make the remote runtime look like an editor transport
289
-- keep the final client-to-server connection as WebSocket
290
-
291
-The recommended T3 flow is:
292
-
293
-1. Desktop connects over SSH.
294
-2. Desktop probes the remote machine and verifies T3 availability.
295
-3. Desktop launches or reuses a remote T3 server.
296
-4. Desktop establishes local port forwarding.
297
-5. Renderer connects to the forwarded WebSocket endpoint as a normal environment.
298
-
299
-The saved environment should remember that it was created by desktop SSH launch only for reconnect and lifecycle UX. That metadata should not change the server protocol or the environment identity model.
300
-
301
-Failure handling should be explicit:
302
-
303
-- SSH authentication failure should surface before any environment is saved
304
-- remote launch failure should include remote logs or the launcher command output when available
305
-- forwarded-port failure should leave the saved environment disconnected rather than falling back to an unrelated endpoint
306
-- reconnect should attempt to restore the SSH bridge before reconnecting the normal WebSocket client
307
-
308
-### 3. Client-managed local publish
309
-
310
-This is the inverse of remote launch: a local T3 server is already running, and the client publishes it through a tunnel.
311
-
312
-This is useful for:
313
-
314
-- exposing a desktop-hosted environment to mobile
315
-- temporary remote access without changing router or firewall settings
316
-
317
-This is still a launch concern, not a new environment kind.
318
-
319
-## Why access and launch must stay separate
320
-
321
-These concerns are easy to conflate, but separating them prevents architectural drift.
322
-
323
-Examples:
324
-
325
-- A manually hosted T3 server might be reached through direct `wss`.
326
-- The same server might also be reachable through a tunnel.
327
-- An SSH-managed server might be launched over SSH but then reached through forwarded WebSocket.
328
-- A local desktop server might be published through a tunnel for mobile.
329
-
330
-In all of those cases, the `ExecutionEnvironment` is the same kind of thing.
331
-
332
-Only the launch and access paths differ.
333
-
334
-## Version Coordination
335
-
336
-Remote environments may stay online while web, desktop, or mobile clients move to a newer release.
337
-The environment descriptor therefore carries the running server version and may advertise a safe
338
-replacement path. The web and desktop UI use that information to show the appropriate action
339
-without making the connection transport responsible for process management.
340
-
341
-Published CLI servers on supported hosts can install and hand off to the client's exact version. A
342
-desktop-managed backend instead points the user to the desktop app on that machine, while older or
343
-unsupported servers fall back to a manual relaunch. The existing connection supervisor owns the
344
-disconnect and reconnect just as it would for any other involuntary socket close.
345
-
346
-See [Server Update Architecture](./server-updates.md) for capability detection, installation safety,
347
-and restart sequencing.
348
-
349
-## Security model
350
-
351
-Remote support must assume that some environments will be reachable over untrusted networks.
352
-
353
-That means:
354
-
355
-- remote-capable environments should require explicit authentication
356
-- tunnel exposure should not rely on obscurity
357
-- client-saved endpoints should carry enough auth metadata to reconnect safely
358
-
359
-T3 already supports a WebSocket auth token on the server. That should become a first-class part of environment access rather than remaining an incidental query parameter convention.
360
-
361
-For publicly reachable environments, authenticated access should be treated as required.
362
-
363
-Hosted pairing should be treated as a client-side convenience only. The hosted app must not receive pairing tokens through query parameters, must not store pairing state server-side, and must not imply that an HTTP backend is safe or reachable from an HTTPS browser context.
364
-
365
-## Relationship to Zed
366
-
367
-Zed is a useful reference implementation for managed remote launch and reconnect behavior.
368
-
369
-The relevant lessons are:
370
-
371
-- remote bootstrap should be explicit
372
-- reconnect should be first-class
373
-- connection UX belongs in the client shell
374
-- runtime ownership should stay clearly on the remote host
375
-
376
-The important mismatch is transport shape.
377
-
378
-Zed needs a custom proxy/server protocol because its remote boundary sits below the editor and project runtime.
379
-
380
-T3 should not copy that part.
381
-
382
-T3 already has the right runtime boundary:
383
-
384
-- one T3 server per environment
385
-- ordinary HTTP/WebSocket between client and environment
386
-
387
-So T3 should borrow Zed's launch discipline, not its transport protocol.
388
-
389
-## Recommended rollout
390
-
391
-1. First-class known environments and access endpoints.
392
-2. Direct `ws` / `wss` remote environments.
393
-3. Authenticated tunnel-backed environments.
394
-4. Desktop-managed SSH launch and forwarding.
395
-5. Multi-environment UI improvements after the base runtime path is proven.
396
-
397
-This ordering keeps the architecture network-first and transport-agnostic while still leaving room for richer managed remote flows.
docs/architecture/runtime-modes.md
deleted
-6
@@ -1,6 +0,0 @@
1
-# Runtime modes
2
-
3
-T3 Code has a global runtime mode switch in the chat toolbar:
4
-
5
-- **Full access** (default): starts sessions with `approvalPolicy: never` and `sandboxMode: danger-full-access`.
6
-- **Supervised**: starts sessions with `approvalPolicy: on-request` and `sandboxMode: workspace-write`, then prompts in-app for command/file approvals.
docs/getting-started/codex-prerequisites.md
deleted
-5
@@ -1,5 +0,0 @@
1
-# Codex prerequisites
2
-
3
-- Install Codex CLI so `codex` is on your PATH.
4
-- Authenticate Codex before running T3 Code (for example via API key or ChatGPT auth supported by Codex).
5
-- T3 Code starts the server via `codex app-server` per session.
docs/getting-started/quick-start.md
deleted
-22
@@ -1,22 +0,0 @@
1
-# Quick start
2
-
3
-```bash
4
-# Development (with hot reload)
5
-bun run dev
6
-
7
-# Desktop development
8
-bun run dev:desktop
9
-
10
-# Desktop development on an isolated port set
11
-T3CODE_DEV_INSTANCE=feature-xyz bun run dev:desktop
12
-
13
-# Production
14
-bun run build
15
-bun run start
16
-
17
-# Build a shareable macOS .dmg (arm64 by default)
18
-bun run dist:desktop:dmg
19
-
20
-# Or from any project directory after publishing:
21
-npx t3
22
-```
docs/internals/ci.md
new
+24
@@ -0,0 +1,24 @@
1
+# CI quality gates
2
+
3
+> For maintainers. Using T3 Code? See [docs/user](../user/).
4
+
5
+[`.github/workflows/ci.yml`](../../.github/workflows/ci.yml) runs four jobs on pull requests and
6
+pushes to `main`:
7
+
8
+- **Check**: `vp check` (format and lint; this repo sets `typeCheck: false` in its lint options),
9
+ then `vpr typecheck` for the workspace type check. The same job
10
+ builds the desktop pipeline (`vp run build:desktop`) and verifies the preload bundle exists and
11
+ still exports its expected symbols.
12
+- **Test**: `vp run test` across the workspace.
13
+- **Mobile Native Static Analysis**: `vp run lint:mobile` on macOS, wrapping
14
+ `scripts/mobile-native-static-check.ts`.
15
+- **Release Smoke**: exercises release-only workflow steps through `scripts/release-smoke.ts`, so
16
+ release breakage surfaces on PRs rather than at tag time.
17
+
18
+`.github/workflows/release.yml` builds macOS (`arm64` and `x64`), Linux (`x64`), and Windows (`x64`)
19
+desktop artifacts from a single `v*.*.*` tag and publishes one GitHub release. It auto-enables
20
+signing only when platform credentials are present. macOS passkey builds additionally require
21
+`APPLE_TEAM_ID` and the `MACOS_PROVISIONING_PROFILE` secret; Windows uses Azure Trusted Signing.
22
+Without the core signing credentials, it still releases unsigned artifacts.
23
+
24
+See [Release Checklist](../operations/release.md) for the full release/signing setup checklist.
docs/internals/connection-runtime.md
new
+183
@@ -0,0 +1,183 @@
1
+# Connection Runtime
2
+
3
+> For maintainers. Using T3 Code? See [docs/user](../user/).
4
+
5
+The connection runtime is shared by web and mobile. It owns connectivity,
6
+authentication, retries, transport lifetime, cached environment data, and
7
+environment-scoped operations.
8
+
9
+Web and mobile mount this runtime once at the application root and compose it
10
+identically: `apps/web/src/connection/runtime.ts` and
11
+`apps/mobile/src/connection/runtime.ts` differ only in the platform layer they
12
+supply. There is no legacy connection owner or supported mixed mode.
13
+
14
+## Composition
15
+
16
+[`connection/layer.ts`][layer] assembles the runtime:
17
+
18
+- `ConnectionResolver` ([resolver.ts][resolver]) resolves a catalog entry into a
19
+ prepared, authenticated endpoint for primary, bearer, relay, or SSH targets.
20
+- `ConnectionDriver` ([driver.ts][driver]) prepares through the resolver, opens
21
+ one RPC session, and reports `preparing`, `opening`, and `synchronizing`.
22
+- `RpcSessionFactory` ([rpc/session.ts][session]) performs one transport
23
+ attempt. It does not retry. `RpcSession` is the interface it returns,
24
+ exposing `client`, `initialConfig`, `ready`, `probe`, and `closed`.
25
+- `EnvironmentRegistry` ([registry.ts][registry]) owns the catalog and the
26
+ per-environment scopes.
27
+- `ConnectionOnboarding` and `RelayEnvironmentDiscovery` sit alongside the
28
+ registry. Startup calls `EnvironmentRegistry.start` and streams platform
29
+ registrations into `reconcilePlatform`.
30
+
31
+The registry creates one environment-scoped supervisor per environment.
32
+`acquireSupervisor` serializes access per environment, reuses an existing
33
+supervisor when the catalog entry is unchanged, and closes and recreates the
34
+scope when it changed. `createServiceScope` builds an `EnvironmentSupervisor`
35
+bound to a closeable scope and connects it; `run` and `runStream` execute caller
36
+effects with that supervisor provided.
37
+
38
+`EnvironmentSupervisor` owns desired state, retry scheduling, and the active
39
+session scope. React components do not create connections, transports, retry
40
+loops, or RPC clients.
41
+
42
+## Connection State
43
+
44
+The supervisor is the only retry owner.
45
+
46
+1. A persisted or platform registration marks an environment as desired.
47
+2. If the device is offline, the supervisor releases the active session and
48
+ waits for a signal without consuming retry attempts or running a timer.
49
+3. When online, it asks the driver for one prepared connection and one RPC
50
+ session.
51
+4. Transient failures retry forever with exponential backoff capped at 16
52
+ seconds (`RETRY_DELAYS_MS`). A connection stable for 30 seconds resets
53
+ accumulated backoff.
54
+5. Authentication or configuration failures remain blocked until an external
55
+ wakeup changes the relevant input.
56
+6. An involuntary session close keeps the registration and cache, then retries.
57
+7. Explicit removal closes the session and deletes the registration,
58
+ credentials, shell cache, and thread cache.
59
+
60
+### Wakeups
61
+
62
+Wakeup handling differs by phase, in [supervisor.ts][supervisor]:
63
+
64
+- During establishment, `waitForEstablishmentInterrupt` consumes and **ignores**
65
+ plain application activation. Restarting an in-flight attempt because the app
66
+ came to the foreground would only delay it. The exception is
67
+ `application-active-reconnect`, which mobile emits after a meaningful
68
+ background suspension; it interrupts establishment and resets the retry
69
+ ladder, because the OS may have silently killed the socket underneath the
70
+ attempt.
71
+- Credential changes interrupt establishment only for relay targets, where a new
72
+ credential changes what is being established.
73
+- Explicit disconnect, explicit retry, and going offline interrupt establishment
74
+ in every case.
75
+- While waiting out backoff, application activation resets the retry ladder so a
76
+ foregrounded app reconnects immediately instead of serving the remaining
77
+ delay.
78
+- Once connected, `monitorConnectedLease` handles plain activation by probing
79
+ the existing session (`lease.session.probe`, with a shorter timeout for
80
+ mobile's `application-active-probe`) rather than reconnecting; a healthy
81
+ session survives foregrounding. `application-active-reconnect` skips the probe
82
+ and replaces the lease outright.
83
+
84
+The UI derives `available`, `offline`, `connecting`, `reconnecting`,
85
+`connected`, and `error` from supervisor state plus explicit data-sync state.
86
+It does not infer connection health from cached data or the existence of a
87
+transport object. An environment becomes `connected` after the socket opens and
88
+the initial config RPC succeeds, proving that the server is responsive. Shell
89
+and thread synchronization are independent data states. A healthy RPC transport
90
+with a failed shell subscription is shown as connected with a synchronization
91
+error, not as a reconnect that is not actually scheduled.
92
+
93
+## Data Boundary
94
+
95
+Finite requests, durable subscriptions, and commands are separate APIs:
96
+
97
+- Query atoms revalidate when the RPC generation changes.
98
+- Subscription atoms switch to replacement sessions.
99
+- Subscription failure handling in [rpc/client.ts][client] distinguishes two
100
+ cases. A transport failure (`isTransportFailure`: every failure is an RPC
101
+ client error) ends the inner subscription without resubscribing, so the outer
102
+ stream waits for the supervisor to supply a replacement session. A handled
103
+ domain failure runs `onExpectedFailure` and, when
104
+ `retryExpectedFailureAfter` is set, sleeps and resubscribes on the **same**
105
+ session. A healthy transport is never torn down for a domain failure.
106
+- Mutations resolve the current environment runtime at execution time.
107
+- Shell and thread snapshots are available while offline.
108
+- Sync status is explicit and independent per domain. Shell status is `empty`,
109
+ `cached`, `synchronizing`, or `live`, with a separate `error` field; there is
110
+ no `failed` status. Thread status adds `deleted`.
111
+- Cached shell and thread projections are never allowed to overwrite newer live
112
+ data during a fast reconnect.
113
+- Domain atom factories route effects through the environment registry and
114
+ resolve the current scoped service at execution time. Project and thread
115
+ commands are Atom factories under `src/state`
116
+ (`createProjectEnvironmentAtoms`, `createThreadEnvironmentAtoms`), as are the
117
+ shell and thread state factories (`createEnvironmentShellAtoms`,
118
+ `createEnvironmentThreadStateAtoms`).
119
+- Web and mobile own their Atom runtimes, React hooks, and feature composition.
120
+
121
+The Promise bridge exists only at the React/Atom boundary. Runtime and business
122
+logic remain Effect-native.
123
+
124
+## Platform Layers
125
+
126
+Web and mobile provide:
127
+
128
+- network status and network-change streams;
129
+- application lifecycle wakeups;
130
+- cloud session credentials;
131
+- device identity;
132
+- platform registrations;
133
+- persistent catalog, credential, shell, and thread stores;
134
+- HTTP, crypto, and telemetry layers.
135
+
136
+Platform layers adapt operating-system capabilities. They do not implement
137
+connection policy. `EnvironmentOwnedDataCleanup` is part of this contract: on
138
+removal the registry clears its cache and calls the platform implementation, so
139
+web clears composer drafts and mobile clears drafts plus the thread outbox.
140
+
141
+## Source Boundaries
142
+
143
+Applications must import explicit package subpaths; the package intentionally
144
+has no root export. The subpaths are documented in
145
+[packages/client-runtime/README.md](../../packages/client-runtime/README.md),
146
+with the `exports` map in that package's `package.json` as the authoritative
147
+list. Files that are not exported are implementation details.
148
+
149
+## Application Boundary
150
+
151
+The application root mounts the shared connection layer, creates its own Atom
152
+runtime, and selects the domain atom factories required by that platform. Web
153
+and mobile may expose different hooks and features without changing connection
154
+ownership.
155
+
156
+Application code must not construct RPC clients, retry loops, or raw
157
+orchestration commands. Persistence paths belong to the platform registration
158
+and cache stores, with explicit migration or invalidation policy.
159
+
160
+## Verification
161
+
162
+Core state-machine tests use `@effect/vitest` and deterministic service layers.
163
+Required coverage includes:
164
+
165
+- offline startup and online wakeup;
166
+- forever retry with the 16-second cap;
167
+- explicit retry interrupting backoff;
168
+- authentication wakeups;
169
+- involuntary close and reconnect;
170
+- explicit removal clearing all owned state;
171
+- relay token reuse and refresh;
172
+- progressive relay discovery;
173
+- shell and thread cache hydration;
174
+- durable subscriptions switching sessions;
175
+- command metadata and idempotent queued-command metadata.
176
+
177
+[layer]: ../../packages/client-runtime/src/connection/layer.ts
178
+[resolver]: ../../packages/client-runtime/src/connection/resolver.ts
179
+[driver]: ../../packages/client-runtime/src/connection/driver.ts
180
+[registry]: ../../packages/client-runtime/src/connection/registry.ts
181
+[supervisor]: ../../packages/client-runtime/src/connection/supervisor.ts
182
+[session]: ../../packages/client-runtime/src/rpc/session.ts
183
+[client]: ../../packages/client-runtime/src/rpc/client.ts
docs/internals/environment-auth.md
renamed
+37
-9
@@ -1,5 +1,7 @@
1
# Environment Authentication Profile
2
3
+> For maintainers. Using T3 Code? See [docs/user](../user/).
4
+
5
The environment server and the relay use separate credentials, issuers, and trust
6
boundaries. They intentionally use a similar OAuth-shaped model so that permission
7
checks and token exchange behavior can be audited against established concepts.
@@ -61,26 +63,52 @@ The response has the token-exchange shape:
63
"access_token": "<opaque session token>",
64
"issued_token_type": "urn:ietf:params:oauth:token-type:access_token",
65
"token_type": "Bearer",
64
- "expires_in": 3600,
66
+ "expires_in": 2592000,
67
"scope": "orchestration:read orchestration:operate terminal:operate review:write relay:read"
68
}
69
```
70
71
+Sessions issued from a plain bearer exchange use the store's
72
+`DEFAULT_SESSION_TTL` of 30 days. The shorter one-hour `expires_in: 3600` applies
73
+only to DPoP-bound exchanges, where the token is additionally constrained by a
74
+proof key. See `SessionStore.ts` and `EnvironmentAuth.ts`.
75
+
76
Requested scopes must be a subset of the one-time bootstrap credential grant.
77
An ordinary paired client therefore cannot exchange its grant for
78
`access:read`, `access:write`, or `relay:write`.
79
80
+### DPoP-Bound Access Token
81
+
82
+The same `/oauth/token` exchange supports proof-of-possession tokens. A client
83
+that sends a `DPoP` header has its proof verified by `verifyRequestDpopProof`;
84
+the resulting JWK thumbprint is stored on the session, which is then issued with
85
+method `dpop-access-token` and a one-hour TTL instead of the bearer default. An
86
+invalid proof gets a DPoP challenge header and a credential error rather than a
87
+bearer token.
88
+
89
+`dpop-access-token` is advertised alongside `browser-session-cookie` and
90
+`bearer-access-token` in the descriptor's `sessionMethods`
91
+(`EnvironmentAuthPolicy.ts`), so clients can discover support rather than
92
+assume it. Relay-brokered clients use this mode so that a leaked token cannot be
93
+replayed without the corresponding key.
94
+
95
### WebSocket Ticket
96
97
`POST /api/auth/websocket-ticket` accepts any authenticated session and returns
76
-a short-lived, single-purpose WebSocket ticket. This keeps bearer tokens and
77
-browser cookies out of WebSocket URLs while allowing the socket handshake to
78
-authenticate. The ticket carries its session's scopes; each RPC method then
79
-enforces `orchestration:read`, `orchestration:operate`, `terminal:operate`,
80
-`review:write`, or `access:read` as appropriate. Review feedback submission
81
-currently dispatches an orchestration operation, so clients performing it also
82
-need `orchestration:operate`. Creating a ticket is not
83
-authorization to call every RPC method.
98
+a short-lived, single-purpose WebSocket ticket, issued through
99
+`EnvironmentAuth.issueWebSocketTicket` with a five-minute default TTL. The
100
+client presents its bearer or DPoP credential in headers to get the ticket, then
101
+appends only that ticket to the socket URL as `wsTicket`. This keeps long-lived
102
+tokens and browser cookies out of WebSocket URLs while letting the handshake
103
+authenticate.
104
+
105
+The ticket carries its session's scopes; each RPC method then enforces
106
+`orchestration:read`, `orchestration:operate`, `terminal:operate`,
107
+`review:write`, `relay:write`, or `access:read` as appropriate, through
108
+`RPC_REQUIRED_SCOPES` in `apps/server/src/auth/RpcAuthorization.ts`. Review feedback submission currently dispatches
109
+an orchestration operation, so clients performing it also need
110
+`orchestration:operate`. Creating a ticket is not authorization to call every
111
+RPC method.
112
113
## Standards Alignment
114
docs/internals/glossary.md
renamed
+41
-40
@@ -1,4 +1,6 @@
1
-# Encyclopedia
1
+# Glossary
2
+
3
+> For maintainers. Using T3 Code? See [docs/user](../user/).
4
5
This is a living glossary for T3 Code. It explains what common terms mean in this codebase.
6
@@ -16,7 +18,7 @@ This is a living glossary for T3 Code. It explains what common terms mean in thi
18
19
#### Project
20
19
-The top-level workspace record in the app. In [the orchestration contracts][1], a project has a `workspaceRoot`, a title, and one or more threads. See [workspace-layout.md][2].
21
+The top-level workspace record in the app. In [the orchestration contracts][1], a project has a `workspaceRoot` and a title. It does not contain threads: `OrchestrationProject` and `OrchestrationThread` are separate arrays on the read model, and a project can have zero threads. See [workspace-layout.md][2].
22
23
#### Workspace root
24
@@ -24,7 +26,7 @@ The root filesystem path for a project. In [the orchestration model][1], it is t
26
27
#### Worktree
28
27
-A Git worktree used as an isolated workspace for a thread. If a thread has a `worktreePath` in [the contracts][1], it runs there instead of in the main working tree. Git operations live in [GitCore.ts][3].
29
+A Git worktree used as an isolated workspace for a thread. If a thread has a `worktreePath` in [the contracts][1], it runs there instead of in the main working tree. Git operations live behind the VCS driver contract in `apps/server/src/vcs/VcsDriver.ts`, implemented by [GitVcsDriverCore.ts][3].
30
31
### Thread timeline
32
@@ -34,7 +36,7 @@ The main durable unit of conversation and workspace history. In [the orchestrati
36
37
#### Turn
38
37
-A single user-to-assistant work cycle inside a thread. It starts with user input and ends when follow-up work like checkpointing settles. See [the contracts][1], [ProviderRuntimeIngestion.ts][5], and [CheckpointReactor.ts][6].
39
+A single user-to-assistant work cycle inside a thread. It starts with user input and ends when the session leaves `running` status, which [projector.ts][4] treats as the authoritative completion signal (`settledTurnStateForSessionStatus`). Checkpoint and diff work may settle afterward without changing when the turn ended. See [the contracts][1] and [ProviderRuntimeIngestion.ts][5].
40
41
#### Activity
42
@@ -80,20 +82,19 @@ A side-effecting service that handles follow-up work after events or runtime sig
82
83
#### Receipt
84
83
-A lightweight typed runtime signal emitted when an async milestone completes. See [RuntimeReceiptBus.ts][13].
84
-Examples include `checkpoint.baseline.captured`, `checkpoint.diff.finalized`, and `turn.processing.quiesced`, which are emitted by flows such as [CheckpointReactor.ts][6].
85
+A typed signal emitted when an async milestone completes, such as `checkpoint.baseline.captured`, `checkpoint.diff.finalized`, or `turn.processing.quiesced`. Receipts are a test-only mechanism: the production `RuntimeReceiptBusLive` publish is a no-op and only the test layer is PubSub-backed. Do not build production behavior on them. See [RuntimeReceiptBus.ts][13] and [CheckpointReactor.ts][6].
86
87
#### Quiesced
88
88
-"Quiesced" means a turn has gone quiet and stable. In [the receipt schema][13], it means the follow-up work has settled, including work in [CheckpointReactor.ts][6].
89
+"Quiesced" means a turn has gone quiet and stable: follow-up work such as [CheckpointReactor.ts][6] has settled. It appears in [the receipt schema][13], so in practice it is something tests wait on rather than a production signal.
90
91
### Provider runtime
92
92
-The live backend agent implementation and its event stream. The main service is [ProviderService.ts][14], the adapter contract is [ProviderAdapter.ts][15], and the overview is in [provider-architecture.md][16].
93
+The live backend agent implementation and its event stream. The main service is [ProviderService.ts][14], the adapter contract is [ProviderAdapter.ts][15], and the overview is in [providers.md][16].
94
95
#### Provider
96
96
-The backend agent runtime that actually performs work. See [ProviderService.ts][14], [ProviderAdapter.ts][15], and [CodexAdapter.ts][17].
97
+The backend agent runtime that actually performs work. Five drivers ship built in: Codex, Claude, Cursor, Grok, and OpenCode. See [ProviderService.ts][14], [ProviderAdapter.ts][15], and [CodexAdapter.ts][17] as a representative adapter.
98
99
#### Session
100
@@ -101,15 +102,15 @@ The live provider-backed runtime attached to a thread. Session shape is in [the
102
103
#### Runtime mode
104
104
-The safety/access mode for a thread or session. In [the contracts][1], the main values are `approval-required` and `full-access`. See [runtime-modes.md][18].
105
+The safety/access mode for a thread or session. [The contracts][1] define four values: `approval-required`, `auto-accept-edits`, `auto`, and `full-access`. See [permission modes][18].
106
107
#### Interaction mode
108
108
-The agent interaction style for a thread. In [the contracts][1], the main values are `default` and `plan`. See [runtime-modes.md][18].
109
+The agent interaction style for a thread. In [the contracts][1], the values are `default` and `plan`.
110
111
#### Assistant delivery mode
112
112
-Controls how assistant text reaches the thread timeline. In [the contracts][1], `streaming` updates incrementally and `buffered` delivers a completed result. See [ProviderService.ts][14].
113
+Controls how assistant text reaches the thread timeline. In [the contracts][1], `streaming` updates incrementally and `buffered` accumulates text. Buffered delivery is not held until the turn completes: it spills once accumulated text would exceed 24,000 characters, and flushes at approval and user-input boundaries. See [ProviderRuntimeIngestion.ts][5].
114
115
#### Snapshot
116
@@ -143,38 +144,38 @@ The file patch and changed-file summary for one turn. It is usually computed in
144
145
- If you see `requested`, think "intent recorded".
146
- If you see `completed`, think "result applied".
146
-- If you see `receipt`, think "async milestone signal".
147
+- If you see `receipt`, think "async milestone signal, for tests".
148
- If you see `checkpoint`, think "workspace snapshot for diff/restore".
149
- If you see `quiesced`, think "all relevant follow-up work has gone idle".
150
151
## Related Docs
152
152
-- [architecture.md][24]
153
-- [provider-architecture.md][16]
154
-- [runtime-modes.md][18]
155
-- [workspace-layout.md][2]
153
+- [Architecture overview][24]
154
+- [Provider architecture][16]
155
+- [Permission modes][18]
156
+- [Workspace layout][2]
157
157
-[1]: ../packages/contracts/src/orchestration.ts
158
+[1]: ../../packages/contracts/src/orchestration.ts
159
[2]: ./workspace-layout.md
159
-[3]: ../apps/server/src/git/Layers/GitCore.ts
160
-[4]: ../apps/server/src/orchestration/projector.ts
161
-[5]: ../apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts
162
-[6]: ../apps/server/src/orchestration/Layers/CheckpointReactor.ts
163
-[7]: ../apps/server/src/orchestration/Layers/OrchestrationEngine.ts
164
-[8]: ../apps/server/src/orchestration/decider.ts
165
-[9]: ../apps/server/src/orchestration/commandInvariants.ts
166
-[10]: ../apps/server/src/orchestration/Layers/ProjectionSnapshotQuery.ts
167
-[11]: ../apps/server/src/orchestration/Layers/ProjectionPipeline.ts
168
-[12]: ../apps/server/src/orchestration/Layers/ProviderCommandReactor.ts
169
-[13]: ../apps/server/src/orchestration/Services/RuntimeReceiptBus.ts
170
-[14]: ../apps/server/src/provider/Layers/ProviderService.ts
171
-[15]: ../apps/server/src/provider/Services/ProviderAdapter.ts
172
-[16]: ./provider-architecture.md
173
-[17]: ../apps/server/src/provider/Layers/CodexAdapter.ts
174
-[18]: ./runtime-modes.md
175
-[19]: ../apps/server/src/checkpointing/CheckpointStore.ts
176
-[20]: ../apps/server/src/checkpointing/CheckpointDiffQuery.ts
177
-[21]: ../apps/server/src/persistence/Services/ProjectionCheckpoints.ts
178
-[22]: ../apps/server/src/checkpointing/Utils.ts
179
-[23]: ../apps/server/src/checkpointing/Diffs.ts
180
-[24]: ./architecture.md
160
+[3]: ../../apps/server/src/vcs/GitVcsDriverCore.ts
161
+[4]: ../../apps/server/src/orchestration/projector.ts
162
+[5]: ../../apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts
163
+[6]: ../../apps/server/src/orchestration/Layers/CheckpointReactor.ts
164
+[7]: ../../apps/server/src/orchestration/Layers/OrchestrationEngine.ts
165
+[8]: ../../apps/server/src/orchestration/decider.ts
166
+[9]: ../../apps/server/src/orchestration/commandInvariants.ts
167
+[10]: ../../apps/server/src/orchestration/Layers/ProjectionSnapshotQuery.ts
168
+[11]: ../../apps/server/src/orchestration/Layers/ProjectionPipeline.ts
169
+[12]: ../../apps/server/src/orchestration/Layers/ProviderCommandReactor.ts
170
+[13]: ../../apps/server/src/orchestration/Services/RuntimeReceiptBus.ts
171
+[14]: ../../apps/server/src/provider/Layers/ProviderService.ts
172
+[15]: ../../apps/server/src/provider/Services/ProviderAdapter.ts
173
+[16]: ./providers.md
174
+[17]: ../../apps/server/src/provider/Layers/CodexAdapter.ts
175
+[18]: ../user/permission-modes.md
176
+[19]: ../../apps/server/src/checkpointing/CheckpointStore.ts
177
+[20]: ../../apps/server/src/checkpointing/CheckpointDiffQuery.ts
178
+[21]: ../../apps/server/src/persistence/Services/ProjectionCheckpoints.ts
179
+[22]: ../../apps/server/src/checkpointing/Utils.ts
180
+[23]: ../../apps/server/src/checkpointing/Diffs.ts
181
+[24]: ./overview.md
docs/internals/overview.md
new
+152
@@ -0,0 +1,152 @@
1
+# Architecture
2
+
3
+> For maintainers. Using T3 Code? See [docs/user](../user/).
4
+
5
+T3 Code is a server runtime that owns agent sessions, workspaces, and version control, plus clients
6
+(web, desktop, mobile) that talk to it over one authenticated Effect RPC WebSocket. The server is the
7
+execution boundary: every provider process, terminal, git operation, and filesystem read happens
8
+there, never in the client.
9
+
10
+```
11
+┌────────────────────────────────────────────────┐
12
+│ Clients: apps/web, apps/desktop, apps/mobile │
13
+│ shared runtime: packages/client-runtime │
14
+│ connection supervisor, RPC session, Atom state│
15
+└──────────────────┬─────────────────────────────┘
16
+ │ Effect RPC over WebSocket (/ws)
17
+ │ contract: packages/contracts
18
+┌──────────────────▼─────────────────────────────┐
19
+│ apps/server │
20
+│ orchestration engine (event-sourced) │
21
+│ provider driver registry (5 built-in drivers) │
22
+│ checkpointing, VCS, terminals, filesystem │
23
+└──────────────────┬─────────────────────────────┘
24
+ │ per-driver transport
25
+┌──────────────────▼─────────────────────────────┐
26
+│ Agent CLIs: Codex, Claude, Cursor, Grok, │
27
+│ OpenCode │
28
+└────────────────────────────────────────────────┘
29
+```
30
+
31
+## The RPC boundary
32
+
33
+The client/server contract is an Effect RPC group, not a hand-rolled push protocol. [`rpc.ts`][rpc]
34
+declares `WS_METHODS` and assembles `WsRpcGroup`; each member is either unary or a server stream
35
+(`stream: true`). Streaming members such as `orchestration.subscribeShell`,
36
+`orchestration.subscribeThread`, `subscribeServerConfig`, and `terminal.attach` replace what used to
37
+be a broadcast push bus: a client subscribes to what it needs and the server pushes only on that
38
+subscription.
39
+
40
+[`ws.ts`][ws] serves the group. `websocketRpcRouteLayer` mounts `GET /ws`, authenticates the upgrade
41
+through `EnvironmentAuth.authenticateWebSocketUpgrade`, then hands the socket to
42
+`RpcServer.toHttpEffectWebsocket`. Authorization is per method: `RPC_REQUIRED_SCOPE` maps each method
43
+to a scope, and `authorizeEffect`/`authorizeStream` enforce it. Holding a valid socket is not
44
+authorization to call everything on it. See [environment-auth.md](./environment-auth.md).
45
+
46
+On the client, [`session.ts`][session] opens the socket and builds the typed client.
47
+`RpcSessionFactory` is the service; a session exposes `client`, `initialConfig`, `ready`, `probe`,
48
+and `closed`. It performs one attempt and does not retry. Retry, backoff, and offline policy belong
49
+to the connection supervisor.
50
+
51
+## Shared client runtime
52
+
53
+`packages/client-runtime` holds every non-visual client concern: connection lifecycle,
54
+authentication, RPC, cached environment data, and domain state as Atom factories. Web and mobile
55
+compose it the same way (`apps/web/src/connection/runtime.ts` and
56
+`apps/mobile/src/connection/runtime.ts` mirror each other, differing only in platform-specific
57
+background-activity layers) and differ beyond that only in the platform layer they supply and the
58
+UI they build on top. React components never construct transports, retry loops,
59
+or RPC clients. See [connection-runtime.md](./connection-runtime.md).
60
+
61
+## Orchestration is event-sourced
62
+
63
+The server does not mutate app state directly. Clients dispatch typed commands; the engine turns them
64
+into persisted events; projections derive the read model.
65
+
66
+[`OrchestrationEngine.ts`][engine] serializes this. `dispatch` offers a `CommandEnvelope` onto
67
+`commandQueue` and awaits its result; a single worker fiber takes envelopes one at a time, so command
68
+processing is totally ordered. For each envelope `processEnvelope`:
69
+
70
+1. checks the durable command receipt, making retries idempotent;
71
+2. runs `decideOrchestrationCommand` ([`decider.ts`][decider]) to produce events from command plus
72
+ current state, pure and side-effect free;
73
+3. inside one SQL transaction, appends events to the event store, applies them to the in-memory read
74
+ model via [`projector.ts`][projector], projects them into persisted tables, and writes the
75
+ accepted receipt;
76
+4. after commit, swaps in the new read model and publishes committed events to subscribers.
77
+
78
+Because persistence and projection share a transaction, the read model cannot durably disagree with
79
+the event log. On dispatch failure the engine rereads persisted events past the starting sequence and
80
+reconciles.
81
+
82
+Command and event names live in [`orchestration.ts`][contracts]. Some commands are client
83
+dispatchable (`thread.create`, `thread.turn.start`, `thread.approval.respond`); others are internal
84
+and produced only by server-side reactors (`thread.message.assistant.delta`,
85
+`thread.turn.diff.complete`).
86
+
87
+A turn is complete when its session leaves `running` status, projected by
88
+`settledTurnStateForSessionStatus` in [`projector.ts`][projector]. Checkpoint work settling later
89
+does not define turn end.
90
+
91
+## Drainable workers
92
+
93
+Follow-up work runs asynchronously in queue-backed workers built on [`DrainableWorker`][worker]:
94
+[`ProviderRuntimeIngestion`][ingest] normalizes provider runtime streams into orchestration commands,
95
+[`ProviderCommandReactor`][cmd] dispatches provider calls in response to intent events, and
96
+[`CheckpointReactor`][checkpoint] captures and reverts workspace checkpoints.
97
+
98
+`DrainableWorker` pairs a transactional queue with a transactional count of outstanding items.
99
+`enqueue` atomically offers and increments; processing always decrements. `drain` retries until the
100
+count reaches zero, so a test can await "queue empty and current item finished" instead of sleeping.
101
+Each of the three services exposes `drain` for exactly this.
102
+
103
+Runtime receipts are a test-only mechanism. `RuntimeReceiptBusLive` in
104
+[`RuntimeReceiptBus.ts`][receipts] publishes nothing; only the test layer is PubSub-backed. Do not
105
+build production behavior on receipts.
106
+
107
+## Provider drivers
108
+
109
+Five drivers ship built in, registered in [`builtInDrivers.ts`][drivers] as `BUILT_IN_DRIVERS`:
110
+Codex, Claude, Cursor, Grok, and OpenCode. A driver declares its kind and config schema and creates a
111
+scoped adapter; `ProviderInstanceRegistry` owns live instances and `ProviderAdapterRegistry` resolves
112
+an instance to its adapter, so `ProviderService` routes session and turn operations without knowing
113
+which agent is behind them. See [providers.md](./providers.md).
114
+
115
+## Checkpointing
116
+
117
+Each turn is bracketed by workspace checkpoints so diffs and reverts are exact. `CheckpointStore`
118
+captures state as hidden Git refs through the VCS driver's checkpoint operations;
119
+`CheckpointDiffQuery` answers turn and full-thread diff requests; `CheckpointReactor` coordinates
120
+baseline capture, completed-turn capture, diff projection, and reverting both the workspace and the
121
+provider conversation. The storage contract is `VcsCheckpointOps` in
122
+[`VcsDriver.ts`](../../apps/server/src/vcs/VcsDriver.ts), implemented for Git in the same directory.
123
+
124
+## Startup
125
+
126
+[`serverRuntimeStartup.ts`][startup] runs a fixed lifecycle: start keybindings, settings, and
127
+reactors; publish welcome; signal command readiness (logged as `Accepting commands`); wait for the
128
+HTTP listener via `markHttpListening`; publish ready; fork the heartbeat; then either print headless
129
+output or open the browser. Command readiness precedes the listener, so a socket that opens can
130
+already dispatch.
131
+
132
+## Related
133
+
134
+- [Workspace layout](./workspace-layout.md), [Glossary](./glossary.md)
135
+- [Remote environments](./remote.md), [Server updates](./server-updates.md)
136
+- [Resource telemetry](./resource-telemetry.md)
137
+- [Scripts](./scripts.md), [CI gates](./ci.md)
138
+
139
+[rpc]: ../../packages/contracts/src/rpc.ts
140
+[contracts]: ../../packages/contracts/src/orchestration.ts
141
+[ws]: ../../apps/server/src/ws.ts
142
+[session]: ../../packages/client-runtime/src/rpc/session.ts
143
+[startup]: ../../apps/server/src/serverRuntimeStartup.ts
144
+[engine]: ../../apps/server/src/orchestration/Layers/OrchestrationEngine.ts
145
+[decider]: ../../apps/server/src/orchestration/decider.ts
146
+[projector]: ../../apps/server/src/orchestration/projector.ts
147
+[worker]: ../../packages/shared/src/DrainableWorker.ts
148
+[ingest]: ../../apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts
149
+[cmd]: ../../apps/server/src/orchestration/Layers/ProviderCommandReactor.ts
150
+[checkpoint]: ../../apps/server/src/orchestration/Layers/CheckpointReactor.ts
151
+[receipts]: ../../apps/server/src/orchestration/Layers/RuntimeReceiptBus.ts
152
+[drivers]: ../../apps/server/src/provider/builtInDrivers.ts
docs/internals/providers.md
new
+92
@@ -0,0 +1,92 @@
1
+# Provider architecture
2
+
3
+> For maintainers. Using T3 Code? See [docs/user](../user/).
4
+
5
+A provider is the agent runtime that does the actual work. T3 Code supports several, and the
6
+orchestration layer does not know which one is behind a thread.
7
+
8
+## Built-in drivers
9
+
10
+[`builtInDrivers.ts`][drivers] exports `BUILT_IN_DRIVERS` with five entries:
11
+
12
+| Driver kind | Driver source |
13
+| ------------- | --------------------------------------- |
14
+| `codex` | [`Drivers/CodexDriver.ts`][codex] |
15
+| `claudeAgent` | [`Drivers/ClaudeDriver.ts`][claude] |
16
+| `cursor` | [`Drivers/CursorDriver.ts`][cursor] |
17
+| `grok` | [`Drivers/GrokDriver.ts`][grok] |
18
+| `opencode` | [`Drivers/OpenCodeDriver.ts`][opencode] |
19
+
20
+Each driver declares its `driverKind`, a `configSchema`, and a `create` function that builds an
21
+adapter in a child scope. Adapter implementations live beside them in
22
+`apps/server/src/provider/Layers/` (`CodexAdapter.ts`, `ClaudeAdapter.ts`, and so on) and conform to
23
+[`ProviderAdapter.ts`][adapter]. Read the driver plus its adapter to see how a specific agent's
24
+transport, config, and event shapes are mapped.
25
+
26
+## Registry and routing
27
+
28
+Two registries separate configuration from live processes:
29
+
30
+- [`ProviderInstanceRegistry`][instances] keys configured instances by `ProviderInstanceId`. Creating
31
+ one looks up the driver by `driverKind`, decodes `entry.config` with that driver's schema, opens a
32
+ child scope, and calls `driver.create`.
33
+- [`ProviderAdapterRegistry`][registry] resolves an instance ID to its live adapter via
34
+ `getByInstance`.
35
+
36
+[`ProviderService`][service] sits on top. It combines the adapter registry with the provider session
37
+directory to route session and turn operations for a thread, so callers name a thread, not an agent.
38
+
39
+Adding a driver means writing the driver plus adapter and adding it to `BUILT_IN_DRIVERS`. No
40
+orchestration, contract, or client change is required for the common case.
41
+
42
+## How provider work is requested
43
+
44
+Clients never call a provider directly. They dispatch orchestration commands over the RPC method
45
+`orchestration.dispatchCommand`, defined with the rest of the orchestration surface in
46
+[`orchestration.ts`][contracts]. The client-dispatchable provider-facing commands are
47
+`thread.turn.start`, `thread.turn.interrupt`, `thread.approval.respond`,
48
+`thread.user-input.respond`, `thread.checkpoint.revert`, and `thread.session.stop`, plus the mode
49
+setters `thread.runtime-mode.set` and `thread.interaction-mode.set`.
50
+
51
+The engine persists an event for the command, and a server-side reactor performs the provider call.
52
+Provider output comes back as internal commands such as `thread.message.assistant.delta` and
53
+`thread.session.set`, which clients observe through `orchestration.subscribeThread`. See
54
+[overview.md](./overview.md) for the command/event loop.
55
+
56
+## Server-side workers
57
+
58
+Provider work flows through three queue-backed workers. All three are built with
59
+`makeDrainableWorker` from [`DrainableWorker.ts`][worker] and expose `drain` for deterministic test
60
+synchronization.
61
+
62
+1. [`ProviderRuntimeIngestion`][ingest] consumes provider runtime streams and emits orchestration
63
+ commands.
64
+2. [`ProviderCommandReactor`][cmd] reacts to orchestration intent events and dispatches provider
65
+ calls.
66
+3. [`CheckpointReactor`][checkpoint] captures workspace checkpoints on turn start and completion, and
67
+ performs reverts.
68
+
69
+### Buffered assistant delivery
70
+
71
+A thread in `buffered` assistant delivery mode accumulates assistant text instead of streaming each
72
+delta. The buffer is not held until turn completion. In [`ProviderRuntimeIngestion`][ingest],
73
+`MAX_BUFFERED_ASSISTANT_CHARS` is 24,000: the append that would exceed it invalidates the buffer and
74
+spills the whole accumulated text as one delta. The buffer also flushes at interaction boundaries,
75
+when a request opens (approval) or user input is requested, via
76
+`flushBufferedAssistantMessagesForTurn`.
77
+
78
+[drivers]: ../../apps/server/src/provider/builtInDrivers.ts
79
+[codex]: ../../apps/server/src/provider/Drivers/CodexDriver.ts
80
+[claude]: ../../apps/server/src/provider/Drivers/ClaudeDriver.ts
81
+[cursor]: ../../apps/server/src/provider/Drivers/CursorDriver.ts
82
+[grok]: ../../apps/server/src/provider/Drivers/GrokDriver.ts
83
+[opencode]: ../../apps/server/src/provider/Drivers/OpenCodeDriver.ts
84
+[adapter]: ../../apps/server/src/provider/Services/ProviderAdapter.ts
85
+[instances]: ../../apps/server/src/provider/Services/ProviderInstanceRegistry.ts
86
+[registry]: ../../apps/server/src/provider/Services/ProviderAdapterRegistry.ts
87
+[service]: ../../apps/server/src/provider/Layers/ProviderService.ts
88
+[contracts]: ../../packages/contracts/src/orchestration.ts
89
+[worker]: ../../packages/shared/src/DrainableWorker.ts
90
+[ingest]: ../../apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts
91
+[cmd]: ../../apps/server/src/orchestration/Layers/ProviderCommandReactor.ts
92
+[checkpoint]: ../../apps/server/src/orchestration/Layers/CheckpointReactor.ts
docs/internals/remote.md
new
+235
@@ -0,0 +1,235 @@
1
+# Remote Architecture
2
+
3
+> For maintainers. Using T3 Code? See [docs/user](../user/).
4
+
5
+Remote environments are shipped, not planned. Direct, bearer-paired, relay-tunneled, Tailscale, and
6
+desktop-managed SSH access all exist today. This document describes the model they share and where
7
+each piece lives. For the user-facing setup guide see
8
+[remote access](../user/remote-access.md).
9
+
10
+## The model
11
+
12
+T3 has one runtime boundary: a client talks to a T3 server over HTTP and WebSocket, and the server
13
+owns orchestration, providers, terminals, git, and filesystem operations. Remoteness is expressed at
14
+the connection layer, never by splitting the runtime.
15
+
16
+```text
17
+┌──────────────────────────────────────────────┐
18
+│ Client (desktop / mobile / web) │
19
+│ known environments, connection supervisor │
20
+└───────────────┬──────────────────────────────┘
21
+ │ resolves one access endpoint
22
+┌───────────────▼──────────────────────────────┐
23
+│ Access method │
24
+│ direct ws/wss, relay tunnel, │
25
+│ Tailscale serve, desktop-managed ssh │
26
+└───────────────┬──────────────────────────────┘
27
+ │ connects to one T3 server
28
+┌───────────────▼──────────────────────────────┐
29
+│ Execution environment = one T3 server │
30
+│ identity, providers, projects/threads, │
31
+│ terminals, git, filesystem │
32
+└──────────────────────────────────────────────┘
33
+```
34
+
35
+### ExecutionEnvironment
36
+
37
+One running T3 server instance. It owns provider availability and auth, model availability, projects
38
+and threads, terminal processes, filesystem access, git operations, and server settings.
39
+
40
+It is identified by a stable `environmentId`, persisted by the server at `<stateDir>/environment-id`
41
+and generated on first start (`apps/server/src/environment/ServerEnvironment.ts`). Desktop, mobile,
42
+and web all reason about the same concept.
43
+
44
+### Known environments and connection targets
45
+
46
+A saved client-side entry for an environment the client knows how to reach. It is not
47
+server-authored; it is local to a device or client profile. In the hosted web app these entries are
48
+browser-local. A hosted pairing URL can create one, but it does not give the hosted app a server-side
49
+control plane or a copy of session state.
50
+
51
+[`connection/model.ts`][model] defines four target tags, which are the real access taxonomy:
52
+
53
+| Target | Used for |
54
+| ------------------------- | ------------------------------------------------------------------------ |
55
+| `PrimaryConnectionTarget` | The platform-managed local server (desktop backend, CLI-served web app). |
56
+| `BearerConnectionTarget` | Any manually paired endpoint reached over direct HTTP/WebSocket. |
57
+| `RelayConnectionTarget` | Managed T3 Connect relay tunnels. |
58
+| `SshConnectionTarget` | Desktop-managed SSH environments. |
59
+
60
+Bearer, relay, and SSH are persisted; primary is platform-managed. Note that Tailscale is not a
61
+separate target kind. A Tailscale URL is paired through the ordinary bearer path in
62
+[`onboarding.ts`][onboarding] (`preparePairingRegistration`), which accepts either a pairing URL or a
63
+host plus pairing code. Tailscale is an endpoint provider and transport, not a distinct runtime
64
+concept.
65
+
66
+### AdvertisedEndpoint
67
+
68
+A server- or desktop-authored candidate endpoint for an environment: a concrete HTTP and WebSocket
69
+base URL pair, a default/available/unavailable marker, reachability hints (loopback, LAN, private,
70
+public, tunnel), and compatibility hints such as whether the hosted HTTPS app can use it.
71
+
72
+Clients treat advertised endpoints as hints, not proof that a route works from the current device.
73
+The connection attempt decides.
74
+
75
+The UI shows one default endpoint in the network-access summary and keeps the rest behind an advanced
76
+list. `selectPairingEndpoint` in
77
+[`ConnectionsSettings.tsx`](../../apps/web/src/components/settings/ConnectionsSettings.tsx) excludes
78
+unavailable endpoints and then picks, in order:
79
+
80
+1. the saved `defaultEndpointKey` override;
81
+2. the first endpoint marked `isDefault`;
82
+3. the first endpoint whose reachability is not `loopback`;
83
+4. the first endpoint compatible with the hosted HTTPS app;
84
+5. otherwise nothing.
85
+
86
+There is no unconditional loopback fallback. A loopback endpoint only wins through an explicit saved
87
+override or `isDefault`. Persist the override by stable endpoint kind rather than raw URL where
88
+possible, since LAN addresses change with networks; Tailscale endpoints use provider-specific stable
89
+keys (`tailscale-ip:`, `tailscale-magicdns:`).
90
+
91
+### Endpoint providers
92
+
93
+Endpoint providers contribute advertised endpoints without becoming part of the core environment
94
+model: core owns environments, pairing, and connection lifecycle, and providers return normalized
95
+`AdvertisedEndpoint` records.
96
+
97
+Tailscale is the first provider, and T3 manages more than discovery. When `tailscaleServeEnabled` is
98
+set, the server acquires a Tailscale serve mapping for its actual listening port at startup with
99
+`ensureTailscaleServe` and releases it with `disableTailscaleServe` on scope close
100
+(`apps/server/src/server.ts`, using [`@t3tools/tailscale`](../../packages/tailscale/src/tailscale.ts)).
101
+Endpoint identifiers are synthesized in `apps/desktop/src/backend/tailscaleEndpointProvider.ts` with
102
+`private-network` reachability.
103
+
104
+### Hosted pairing request
105
+
106
+A hosted pairing request is a bootstrap URL for the static web app, not a transport:
107
+
108
+```text
109
+https://app.t3.codes/pair?host=https://backend.example.com:3773#token=PAIRCODE
110
+```
111
+
112
+The hosted app reads `host`, takes the token from the URL hash, exchanges it directly with that
113
+backend, strips the token from browser history, and saves the environment record locally. Helpers
114
+live in [`shared/remote.ts`](../../packages/shared/src/remote.ts) (`setPairingTokenOnUrl`,
115
+`getPairingTokenFromUrl`, `stripPairingTokenFromUrl`) and `apps/web/src/hostedPairing.ts`.
116
+
117
+Constraints:
118
+
119
+- the hosted app does not proxy HTTP or WebSocket traffic;
120
+- the backend must be directly reachable from the browser;
121
+- HTTPS pages can only reach HTTPS/WSS backends;
122
+- HTTP LAN endpoints keep using direct desktop or CLI pairing URLs;
123
+- the token belongs in the hash so it is never sent to the hosted app origin.
124
+
125
+### RepositoryIdentity and Project
126
+
127
+`RepositoryIdentity` is a best-effort logical repo grouping across environments, used for UI grouping
128
+and correlation only, never for routing. `Project` remains environment-local: a local clone and a
129
+remote clone are different projects that may share a `RepositoryIdentity`, and threads bind to one
130
+project in one environment.
131
+
132
+## Access methods
133
+
134
+Access answers one question: how does the client speak WebSocket to a T3 server? It does not answer
135
+how the server got started or who manages the process.
136
+
137
+### Direct WebSocket access
138
+
139
+`wss://t3.example.com` or `ws://10.0.0.15:3773`, paired as a bearer target. This is the base model.
140
+It works for desktop, mobile, and web with no client-side process management. Browser security rules
141
+are part of it: a hosted HTTPS client cannot connect to plain `ws://` or `http://` LAN backends.
142
+
143
+### Relay-tunneled access
144
+
145
+Managed T3 Connect relay tunnels use `RelayConnectionTarget` and are the answer when the host is
146
+behind NAT, inbound ports are unavailable, or mobile must reach a desktop-hosted environment. From
147
+the client's perspective this is still an ordinary WebSocket connection; the route is mediated. The
148
+relay Worker only brokers credentials and a managed endpoint; application traffic then flows over
149
+the provisioned Cloudflare tunnel hostname for the life of the connection, not through the relay
150
+Worker itself. See [t3-connect.md](./t3-connect.md).
151
+
152
+### Tailscale access
153
+
154
+A T3-managed `tailscale serve` mapping exposes the server on the tailnet over HTTPS, and the
155
+resulting private-network endpoints are advertised for pairing. Connection then follows the ordinary
156
+bearer path.
157
+
158
+### Desktop-managed SSH access
159
+
160
+SSH is an access and launch helper, not a separate environment type. `DesktopSshEnvironment`
161
+([apps/desktop/src/ssh/DesktopSshEnvironment.ts][sshenv]) exposes `discoverHosts`,
162
+`ensureEnvironment`, and `disconnectEnvironment`. It discovers targets from SSH config and known
163
+hosts, owns password/askpass prompts, and delegates lifecycle to `SshEnvironmentManager` in
164
+[packages/ssh/src/tunnel.ts][sshtunnel], which resolves the target, launches or reuses the remote T3
165
+server, opens a local tunnel, checks HTTP readiness, optionally issues a remote pairing token, and
166
+returns local HTTP/WS endpoints. Disconnect closes the tunnel and stops the remote server if the
167
+launcher started it; a server that was already running (marked `external`) is left running.
168
+
169
+The desktop main process owns this because it can spawn SSH, manage prompts, write launch scripts,
170
+and clean up forwards. The renderer connects through the forwarded URL like any other environment and
171
+needs no SSH-specific RPC path.
172
+
173
+Failure handling is explicit: SSH auth failure surfaces before an environment is saved, remote launch
174
+failure includes launcher output where available, forwarded-port failure leaves the environment
175
+disconnected rather than falling back to an unrelated endpoint, and reconnect restores the SSH bridge
176
+before reconnecting the WebSocket client.
177
+
178
+## Launch methods
179
+
180
+Launch answers a different question: how does a T3 server come to exist on the target machine? Keep
181
+it separate from access.
182
+
183
+- **Pre-existing server.** The operator already runs T3 and the client connects directly or through a
184
+ tunnel.
185
+- **Desktop-managed remote launch over SSH.** Desktop probes the machine, launches or reuses a remote
186
+ server, forwards a port, and the renderer connects normally. The saved environment records that it
187
+ came from SSH launch for reconnect and lifecycle UX only; that metadata never changes the protocol
188
+ or the identity model.
189
+- **Client-managed local publish.** A local server is published through the relay with
190
+ `t3 connect link`, exposing a desktop-hosted environment to mobile without router or firewall
191
+ changes.
192
+
193
+The same `ExecutionEnvironment` can be reached several of these ways. Only the launch and access
194
+paths differ.
195
+
196
+## Security model
197
+
198
+Some environments are reachable over untrusted networks, so remote-capable environments require
199
+explicit authentication, tunnel exposure never relies on obscurity, and saved endpoints carry enough
200
+auth metadata to reconnect safely.
201
+
202
+WebSocket authentication is a dedicated short-lived ticket, not a token in a query string. The client
203
+presents its long-lived bearer or DPoP credential in HTTP headers to
204
+`POST /api/auth/websocket-ticket` ([authorization/remote.ts][authremote]), and appends only the
205
+returned ticket as `wsTicket` on the socket URL. The server issues it through
206
+`EnvironmentAuth.issueWebSocketTicket`; tickets are tagged `kind: "websocket"` and default to a
207
+five-minute TTL (`DEFAULT_WEBSOCKET_TOKEN_TTL` in `apps/server/src/auth/SessionStore.ts`). The
208
+handshake verifies the ticket, and each RPC method still enforces its own scope. See
209
+[environment-auth.md](./environment-auth.md).
210
+
211
+Hosted pairing is a client-side convenience only. The hosted app must not receive pairing tokens
212
+through query parameters, must not store pairing state server-side, and must not imply that an HTTP
213
+backend is reachable from an HTTPS browser context.
214
+
215
+## Version coordination
216
+
217
+Remote environments stay online while clients move to newer releases. The environment descriptor
218
+carries the running server version and may advertise a safe replacement path, so the UI can show the
219
+right action without making the transport responsible for process management. The connection
220
+supervisor owns the resulting disconnect and reconnect like any other involuntary close. See
221
+[server-updates.md](./server-updates.md).
222
+
223
+## Future work
224
+
225
+These remain unbuilt and are listed to keep the model honest:
226
+
227
+- third-party tunnel products as additional endpoint providers;
228
+- a relay-hosted OAuth callback broker (see [t3-connect.md](./t3-connect.md));
229
+- richer multi-environment UI beyond the current connections list.
230
+
231
+[model]: ../../packages/client-runtime/src/connection/model.ts
232
+[onboarding]: ../../packages/client-runtime/src/connection/onboarding.ts
233
+[authremote]: ../../packages/client-runtime/src/authorization/remote.ts
234
+[sshenv]: ../../apps/desktop/src/ssh/DesktopSshEnvironment.ts
235
+[sshtunnel]: ../../packages/ssh/src/tunnel.ts
docs/internals/resource-telemetry.md
renamed
+2
@@ -1,5 +1,7 @@
1
# Resource telemetry architecture
2
3
+> For maintainers. Using T3 Code? See [docs/user](../user/).
4
+
5
Status: implemented
6
7
## Purpose
docs/internals/scripts.md
new
+119
@@ -0,0 +1,119 @@
1
+# Scripts
2
+
3
+> For maintainers. Using T3 Code? See [docs/user](../user/).
4
+
5
+## First checkout
6
+
7
+T3 Code uses [Vite+](https://viteplus.dev/guide/). Install the global `vp` command, install
8
+dependencies, then start the dev stack:
9
+
10
+```bash
11
+curl -fsSL https://vite.plus | bash # Windows: irm https://vite.plus/ps1 | iex
12
+vp i
13
+vp run dev
14
+```
15
+
16
+Node 24 is required. Bun is not: the server picks Bun adapters when it detects Bun and falls back to
17
+Node otherwise, and nothing in contributor setup needs it.
18
+
19
+`vp run dev` prints a one-time pairing URL. Open it so the first browser navigation is
20
+authenticated.
21
+
22
+## Dev
23
+
24
+- `vp run dev`: Starts contracts, server, and web in watch mode.
25
+- `vp run dev --share`: Also publishes the web port over HTTPS on this machine's tailnet. The
26
+ startup pairing URL is built against the shared origin, and the mapping is removed on exit.
27
+- `vp run dev --browser`: Auto-opens a browser. Off by default. The dev runner writes
28
+ `T3CODE_NO_BROWSER` itself from this flag, so setting `T3CODE_NO_BROWSER=0` in your environment has
29
+ no effect; use `--browser`.
30
+- `vp run dev:server`: Starts just the server. It runs on Node (`node --watch src/bin.ts`), so
31
+ without Bun present it selects `NodePtyAdapter` and `NodeHttpServer`.
32
+- `vp run dev:web`: Starts just the Vite dev server for the web app.
33
+- `vp run dev:desktop`: Starts the Electron shell against the dev server.
34
+- `vp run dev:marketing`: Starts the Astro marketing site.
35
+- Pass dev-runner flags directly after the root task name, for example:
36
+ `vp run dev --home-dir /tmp/t3code-dev`
37
+
38
+### Dev state directories
39
+
40
+- Dev commands run from a linked **git worktree** default to that worktree's gitignored `.t3`, even
41
+ when `T3CODE_HOME` is set, storing state in `<worktree>/.t3/userdata`. Pass `--home-dir <path>` to
42
+ choose another isolated directory explicitly. Submodules are not worktrees and keep the normal
43
+ precedence.
44
+- From the **main checkout**, dev commands implicitly use `~/.t3/dev`, keeping development state
45
+ separate from `~/.t3/userdata`. An explicit `--home-dir <path>` stores state under
46
+ `<path>/userdata`; the base directory remains available for caches, worktrees, and other shared
47
+ data.
48
+
49
+## Build, check, test
50
+
51
+- `vp run build`: Fans out over `apps/*`, `packages/*`, `oxlint-plugin-t3code`, and `scripts`.
52
+ Workspaces that define a build task run one: desktop, marketing, server (which depends on web), and
53
+ web. Shared packages are consumed and bundled transitively rather than built separately.
54
+- `vp run build:desktop`: Builds the desktop pipeline (desktop plus server).
55
+- `vp run start`: Runs the production server (serves the built web app as static files).
56
+- `vp check`: Vite+ format, lint, and type checks. This repo sets `typeCheck: false` in its lint
57
+ options, so workspace type checking runs separately.
58
+- `vp run typecheck`: Strict TypeScript checks for all packages.
59
+- `vp run test`: Runs workspace tests.
60
+- `vp run lint:mobile`: Mobile native static analysis (`scripts/mobile-native-static-check.ts`).
61
+- `node apps/server/scripts/t3-sqlite-state.ts <query|exec> --base-dir <path> ...`: Inspects or seeds
62
+ an isolated T3 SQLite database; writes create a private backup first.
63
+
64
+## Desktop artifacts
65
+
66
+- `vp run dist:desktop:artifact --platform <mac|linux|win> --target <target> --arch <arch>`: Builds a desktop artifact for a specific platform/target/arch.
67
+- `vp run dist:desktop:dmg`: Builds a shareable macOS `.dmg` into `./release`. Architecture defaults
68
+ to the host, so this produces an arm64 DMG on Apple Silicon. Use `dist:desktop:dmg:arm64` or
69
+ `dist:desktop:dmg:x64`, or pass `--arch <arm64|x64|universal>`, to force one.
70
+- `vp run dist:desktop:linux`: Builds a Linux AppImage into `./release`.
71
+- `vp run dist:desktop:win`: Builds a Windows NSIS installer into `./release`. `:arm64` and `:x64`
72
+ variants exist.
73
+
74
+### Desktop `.dmg` packaging notes
75
+
76
+- Default build is unsigned/not notarized for local sharing.
77
+- The DMG build uses `assets/prod/black-macos-1024.png` as the production app icon source.
78
+- Desktop production windows load the bundled UI from the `t3code://app/` root URL (not a
79
+ `127.0.0.1` document URL, and not an explicit `index.html` path).
80
+- Desktop packaging includes `apps/server/dist` (the `t3` backend) and starts it on loopback with an
81
+ auth token for WebSocket/API traffic.
82
+- Your tester can still open it on macOS by right-clicking the app and choosing **Open** on first
83
+ launch.
84
+- To keep staging files for debugging package contents, run: `vp run dist:desktop:dmg --keep-stage`
85
+- To allow code-signing/notarization when configured in CI/secrets, add: `--signed`.
86
+- Signed macOS builds also require `T3CODE_APPLE_TEAM_ID` and
87
+ `T3CODE_MACOS_PROVISIONING_PROFILE`. The passkey RP domain is derived from
88
+ `T3CODE_CLERK_PUBLISHABLE_KEY` unless `T3CODE_CLERK_PASSKEY_RP_DOMAINS` overrides it.
89
+- Windows `--signed` uses Azure Trusted Signing and expects:
90
+ `AZURE_TRUSTED_SIGNING_ENDPOINT`, `AZURE_TRUSTED_SIGNING_ACCOUNT_NAME`,
91
+ `AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME`, and `AZURE_TRUSTED_SIGNING_PUBLISHER_NAME`.
92
+- Azure authentication env vars are also required (for example service principal with secret):
93
+ `AZURE_TENANT_ID`, `AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET`.
94
+
95
+## Browser development
96
+
97
+`dev` and `dev:web` leave `VITE_HTTP_URL` and `VITE_WS_URL` unset so the browser resolves the backend
98
+from `window.location.origin`. Vite proxies `/api`, `/ws`, `/oauth`, and `/.well-known` to the
99
+server, allowing the same bundle to work from localhost or a tailnet hostname.
100
+
101
+## Running multiple dev instances
102
+
103
+Worktrees derive a preferred port offset from their path.
104
+
105
+- Default ports: server `13773`, web `5733`
106
+- Shifted ports: `base + offset`
107
+- Example: `T3CODE_DEV_INSTANCE=branch-a vp run dev:desktop`
108
+
109
+Offset resolution, in order:
110
+
111
+1. `T3CODE_PORT_OFFSET`, which must be a non-negative integer. Negative values are rejected.
112
+2. `T3CODE_DEV_INSTANCE`. An all-digit value is used directly as the offset; any other non-empty
113
+ value is hashed into one.
114
+3. The worktree path hash.
115
+
116
+Collision scanning depends on the mode. `dev:web` scans only the web port and shifts only the web
117
+offset. `dev:server` scans only the server port. `dev` and `dev:desktop` scan both and shift them
118
+together as one shared offset. Explicit server or dev-URL overrides remove the corresponding port
119
+from the availability check. Treat the `[dev-runner]` output as authoritative.
docs/internals/server-updates.md
renamed
+14
-5
@@ -1,5 +1,7 @@
1
# Server Update Architecture
2
3
+> For maintainers. Using T3 Code? See [docs/user](../user/).
4
+
5
T3 Code can update a connected server to the exact version of the client that detected version
6
drift. This path exists primarily for remote environments, where the user may not have a terminal
7
open on the server machine.
@@ -59,10 +61,11 @@ flowchart TD
61
B -->|boot-service or respawn| E{Progress capability}
62
E -->|present| F[server.updateServerWithProgress]
63
E -->|missing| G[server.updateServer fallback]
62
- F --> H[Download exact t3 version]
64
+ F --> H[Install exact t3 version in pinned runtime]
65
G --> H
64
- H --> I[Install and run version preflight]
65
- I -->|fails| J[Remove failed runtime and keep current server]
66
+ H --> I[Run version preflight]
67
+ I -->|bad code or version| J[Remove candidate runtime and keep current server]
68
+ I -->|cannot run preflight| J2[Keep candidate and current server]
69
I -->|passes| K{Handoff method}
70
K -->|boot-service| L[Rewrite and restart T3 systemd unit]
71
K -->|respawn| M[Start delayed replacement and exit current process]
@@ -82,8 +85,14 @@ successfully. Boot-service setup and self-update share the same process-wide ins
85
they cannot mutate a pinned runtime concurrently.
86
87
Before any restart, the current Node executable runs the replacement with `--version`. A failed
85
-install, failed preflight, or wrong reported version leaves the current server running. A failed
86
-preflight also removes the candidate runtime so retrying the same version performs a clean install.
88
+install, failed preflight, or wrong reported version leaves the current server running.
89
+
90
+Candidate cleanup is narrower than "any failed preflight". The candidate runtime is removed only when
91
+the preflight process actually completes and reports a bad exit code or the wrong version: that is
92
+the case where a completed npm install produced an unusable tree, so retrying the same version must
93
+perform a clean install rather than reuse it. If the preflight cannot run at all, for example a spawn
94
+error or the `PREFLIGHT_TIMEOUT` elapsing, the update fails before reaching cleanup and the candidate
95
+directory is left in place.
96
97
## Host Service Lifecycle
98
docs/internals/t3-code-connect-auth-flow.html
renamed
docs/internals/t3-connect.md
renamed
+52
-38
@@ -1,8 +1,16 @@
1
-# T3 Connect Clerk Setup
1
+# T3 Connect
2
3
-T3 Connect uses one Clerk application for web, desktop, and mobile authentication. The relay accepts
4
-Clerk JWTs only when they are generated from the `t3-relay` template with the shared
5
-`t3-code-relay` audience.
3
+> For maintainers. Using T3 Code? See [docs/user](../user/).
4
+
5
+T3 Connect uses one Clerk application for web, desktop, and mobile authentication. The relay verifies
6
+two kinds of bearer credential: template JWTs generated from the `t3-relay` template with the shared
7
+`t3-code-relay` audience, and Clerk OAuth tokens issued to the CLI. `verifyRelayClientBearerToken` in
8
+`infra/relay/src/http/Api.ts` tries the template/session path first and falls back to OAuth
9
+verification (`acceptsToken: "oauth_token"`), so the CLI's OAuth credential works without a JWT
10
+template.
11
+
12
+For the wider system diagram, see
13
+[t3-code-connect-auth-flow.html](./t3-code-connect-auth-flow.html).
14
15
## Application Keys
16
@@ -35,10 +43,11 @@ should set `T3CODE_CLERK_PUBLISHABLE_KEY`, `T3CODE_CLERK_JWT_TEMPLATE`,
43
production builds only need the Clerk publishable key, JWT template name, and relay URL in their EAS
44
environment.
45
38
-When any client-facing public value is absent, cloud UI is omitted. When the CLI public values are
39
-absent, the `t3 connect` CLI command group is omitted. The bundled server still accepts runtime
40
-overrides for self-hosted or operator-managed
41
-deployments.
46
+When any client-facing public value is absent, cloud UI is omitted. The `t3 connect` command group is
47
+always registered: when the CLI public values are absent, `makeCli` in `apps/server/src/bin.ts`
48
+registers a hidden fallback `connect` command that reports the missing configuration instead of
49
+silently vanishing from help. The bundled server still accepts runtime overrides for self-hosted or
50
+operator-managed deployments.
51
52
For a hosted relay deployment, copy `infra/relay/.env.example` to `infra/relay/.env`. The relay
53
deployment reads `RELAY_DOMAIN`, `RELAY_API_ZONE_NAME`, `RELAY_TUNNEL_ZONE_NAME`,
@@ -63,7 +72,12 @@ In **Clerk Dashboard > OAuth applications**:
72
73
1. Create an OAuth application for the T3 CLI.
74
2. Enable the **Public** option so authorization-code exchange uses PKCE.
66
-3. Add `http://127.0.0.1:34338/callback` as an allowed redirect URI.
75
+3. Add **both** allowed redirect URIs:
76
+ - `http://127.0.0.1:34338/callback` for the loopback listener;
77
+ - `https://app.t3.codes/connect/callback` for the hosted out-of-band flow. This is
78
+ `connectCallbackUrl(DEFAULT_HOSTED_APP_URL)` from `packages/shared/src/connectAuth.ts`, so a
79
+ custom `T3CODE_HOSTED_APP_URL` means `$T3CODE_HOSTED_APP_URL/connect/callback` instead.
80
+ Omitting it breaks headless and SSH authorization.
81
4. Enable the `openid`, `profile`, and `email` scopes.
82
5. Set `T3CODE_CLERK_CLI_OAUTH_CLIENT_ID` in the repository-root `.env` file and release build
83
environment to the generated public client ID.
@@ -72,17 +86,20 @@ The CLI derives Clerk's frontend API URL from the publishable key and calls Cler
86
`/oauth/authorize` and `/oauth/token` endpoints directly. The relay is not involved in the OAuth
87
handshake; it only validates the issued Clerk bearer token when the CLI manages an environment link.
88
75
-The CLI supports these headless operations:
89
+The connect command group is:
90
91
```sh
92
+t3 connect # default: onboarding
93
t3 connect login
79
-t3 connect link
80
-t3 connect status
94
+t3 connect link # --publish-only
95
+t3 connect status # --json
96
+t3 connect publish # --disable
97
t3 connect unlink
98
t3 connect logout
83
-t3 serve
99
```
100
101
+`t3 serve` is a separate top-level command, not a connect subcommand.
102
+
103
`t3 connect login` opens the Clerk authorization flow and stores the CLI credential without enabling
104
cloud exposure. `t3 connect link` installs the pinned managed `cloudflared` binary when needed,
105
authorizes when needed, and records durable intent to expose the environment. It works without a
@@ -95,16 +112,21 @@ logout` performs the same cleanup and removes the stored CLI authorization.
112
The background service has an independent lifecycle. Connect setup may offer to install it, but
113
logout leaves it running; manage it with `t3 service status`, `install`, `update`, and `uninstall`.
114
98
-The current OAuth callback listener binds to loopback port `34338`. When running the CLI over SSH,
99
-forward that port before running `t3 connect login` or `t3 connect link`:
115
+### Headless and SSH authorization
116
+
117
+The loopback OAuth callback listener binds to port `34338`. That path only works when a browser on
118
+the same machine can reach it, so `authorizeCli` in `apps/server/src/cli/connect.ts` automatically
119
+selects the out-of-band flow when `--headless` is passed or when it detects SSH through
120
+`SSH_CONNECTION` or `SSH_TTY`. The out-of-band flow prints the hosted `/connect` authorization URL
121
+and accepts a pasted authorization code, so no port is involved.
122
+
123
+Port forwarding is therefore optional, not required. Forward the port only if you specifically want
124
+the loopback flow over SSH:
125
126
```sh
127
ssh -L 34338:127.0.0.1:34338 <host>
128
```
129
105
-A relay-hosted callback broker can remove this port-forward requirement later without changing the
106
-stored PKCE token model.
107
-
130
## JWT Template
131
132
In **Clerk Dashboard > JWT templates**, create a template with:
@@ -207,34 +229,26 @@ codesign -d --entitlements :- "/Applications/T3 Code (Alpha).app"
229
The current mobile UI uses Clerk's native authentication view. If a future mobile browser OAuth
230
flow uses a custom redirect URI, add that exact URI to the same allowlist.
231
210
-## Enable Waitlist Access
211
-
212
-For a private beta where people should request access, use **Clerk Dashboard > Waitlist**:
213
-
214
-1. Toggle on **Enable waitlist** and save.
215
-2. Review requests on the same page and select **Invite** or **Deny**.
216
-
217
-Approved signed-in users manage T3 Connect under **Connections**. The web and desktop sidebars do
218
-not expose a dedicated account or waitlist control. Signed-out users reach Clerk's waitlist and
219
-sign-in flow contextually from the T3 Connect controls on the Connections page.
220
-
221
-On mobile, signed-out users open **Settings > T3 Account** to reach `/settings/waitlist` within the
222
-Settings form sheet. It submits enrollment through Clerk's `useWaitlist()` flow because the prebuilt
223
-`<Waitlist />` component is web-only in the Expo SDK. Approved users can use **Sign in** from that
224
-screen.
232
+## Sign-in Surfaces
233
226
-## Alternative: Known-User Allowlist
234
+Signed-in users manage T3 Connect under **Connections**. The settings sidebar also has dedicated
235
+controls, rendered by `SettingsSidebarNav.tsx`: `T3ConnectSidebarSignIn` in the footer shows a
236
+**Sign in to T3 Connect** button while signed out, and `T3ConnectSidebarAvatar` shows a Clerk
237
+`UserButton` account control while signed in. Both are gated on cloud public configuration.
238
+Desktop renders the same web bundle, so it has them too. The waitlist enrollment flow from the
239
+private beta was removed when Connect went GA; sign-up is open unless a Clerk restriction below is
240
+enabled.
241
228
-For a closed beta where all permitted users are known in advance, use an allowlist instead of a
229
-request-and-approval waitlist:
242
+## Restricting Sign-ups: Known-User Allowlist
243
231
-To restrict the beta to permitted email addresses or domains:
244
+For a closed deployment where all permitted users are known in advance, restrict sign-up to
245
+permitted email addresses or domains:
246
247
1. In **Clerk Dashboard > Restrictions > Allowlist**, add each permitted email address or email
248
domain.
249
2. Enable the allowlist and save.
250
3. Alternatively, enable **Restricted mode** when all new users must be explicitly invited or
237
- manually created without a waitlist request flow.
251
+ manually created.
252
253
Do not enable an empty allowlist: it blocks all new sign-ups.
254
docs/internals/workspace-layout.md
new
+63
@@ -0,0 +1,63 @@
1
+# Workspace layout
2
+
3
+> For maintainers. Using T3 Code? See [docs/user](../user/).
4
+
5
+A pnpm workspace driven by [vite-plus](https://vite.plus) (`vp`). See [scripts.md](./scripts.md) for
6
+the task commands.
7
+
8
+## apps
9
+
10
+- `apps/server` (`t3`): the execution runtime and the published CLI. Owns orchestration, provider
11
+ drivers, checkpointing, VCS, terminals, filesystem access, auth, and the HTTP + WebSocket surface.
12
+ Also serves the built web app.
13
+- `apps/web` (`@t3tools/web`): React + Vite UI. Consumes the shared client runtime and adds routing,
14
+ components, and web-specific platform layers.
15
+- `apps/desktop` (`@t3tools/desktop`): Electron shell. Supervises a desktop-scoped `t3` backend,
16
+ loads the web bundle over the `t3code://` protocol, and owns SSH-managed remote environments.
17
+- `apps/mobile` (`@t3tools/mobile`): Expo/React Native client. Same client runtime composition as
18
+ web, different platform layer and UI.
19
+- `apps/marketing` (`@t3tools/marketing`): Astro marketing site.
20
+
21
+## packages
22
+
23
+- `packages/contracts` (`@t3tools/contracts`): shared Effect Schema definitions. RPC group,
24
+ orchestration commands/events/read model, auth scopes, environment descriptors, settings.
25
+- `packages/shared` (`@t3tools/shared`): framework-agnostic utilities used by server and clients
26
+ (`DrainableWorker`, git and source-control helpers, relay auth and signing, DPoP, semver, logging,
27
+ observability, and more).
28
+- `packages/client-runtime` (`@t3tools/client-runtime`): connection lifecycle, authorization, RPC
29
+ session, environment registry, and Atom-based domain state shared by web and mobile. See its
30
+ [README](../../packages/client-runtime/README.md).
31
+- `packages/ssh` (`@t3tools/ssh`): SSH config parsing, auth prompts, command execution, and the
32
+ tunnel/environment manager behind desktop-managed SSH environments.
33
+- `packages/tailscale` (`@t3tools/tailscale`): Tailscale CLI wrapper, including the
34
+ `ensureTailscaleServe` / `disableTailscaleServe` serve lifecycle the server drives.
35
+- `packages/effect-acp` (`effect-acp`): Effect client and agent implementation of the Agent Client
36
+ Protocol, used by ACP-speaking provider drivers.
37
+- `packages/effect-codex-app-server` (`effect-codex-app-server`): Effect client for the
38
+ `codex app-server` JSON-RPC protocol.
39
+
40
+## infra
41
+
42
+- `infra/relay` (`t3code-relay`): the hosted T3 Connect relay, deployed with Alchemy. Handles
43
+ environment discovery, cloud-side records, and mobile notifications. It is not in the hot path;
44
+ after connect, client traffic goes directly to the environment. See
45
+ [t3-connect.md](./t3-connect.md).
46
+
47
+## Other top-level directories
48
+
49
+- `scripts/`: workspace tooling run through `vp run`. Dev runner, desktop artifact builds, release
50
+ helpers, mobile static checks and showcase capture, update-manifest merging.
51
+- `assets/`: brand and app icon sources per channel (`dev`, `nightly`, `prod`).
52
+- `patches/`: pnpm patches for pinned upstream dependencies.
53
+- `oxlint-plugin-t3code/`: repo-specific lint rules.
54
+- `experiments/`: throwaway prototypes. Not part of the shipped build.
55
+- `docs/`: this documentation tree.
56
+
57
+## Import conventions
58
+
59
+`@t3tools/shared` and `@t3tools/client-runtime` use explicit subpath exports with no barrel index and
60
+no root export. Import the narrow path (`@t3tools/shared/DrainableWorker`,
61
+`@t3tools/client-runtime/state/threads`) rather than the package root. Files that are not exported
62
+are implementation details. `@t3tools/contracts` does export a root alongside `./settings` and
63
+`./relay`.
docs/operations/ci.md
deleted
-6
@@ -1,6 +0,0 @@
1
-# CI quality gates
2
-
3
-- `.github/workflows/ci.yml` runs `vp check` (lint + typecheck), `vpr typecheck`, and `vp run test` on pull requests and pushes to `main`.
4
-- `.github/workflows/release.yml` builds macOS (`arm64` and `x64`), Linux (`x64`), and Windows (`x64`) desktop artifacts from a single `v*.*.*` tag and publishes one GitHub release.
5
-- The release workflow auto-enables signing only when platform credentials are present. macOS passkey builds additionally require `APPLE_TEAM_ID` and the `MACOS_PROVISIONING_PROFILE` secret; Windows uses Azure Trusted Signing. Without the core signing credentials, it still releases unsigned artifacts.
6
-- See [Release Checklist](./release.md) for the full release/signing setup checklist.
docs/operations/effect-fn-checklist.md
deleted
-198
@@ -1,198 +0,0 @@
1
-# Effect.fn Refactor Checklist
2
-
3
-Generated from a repo scan for non-test wrapper-style candidates matching either `=> Effect.gen(function* ...)` or `return Effect.gen(function* ...)`.
4
-
5
-Refactor Method:
6
-
7
-```ts
8
-// Old
9
-function old () {
10
- return Effect.gen(function* () {
11
- ...
12
- });
13
-}
14
-
15
-const old2 = () => Effect.gen(function* () {
16
- ...
17
-});
18
-```
19
-
20
-```ts
21
-// New
22
-const new = Effect.fn('functionName')(function* () {
23
- ...
24
-})
25
-```
26
-
27
-- Use `Effect.fn('name')(function* (input: Input): Effect.fn.Return<A, E, R> {})` to annotate the return type of the function if needed.
28
-
29
-- The 2nd argument works as a pipe, and it gets the effect and input as arguments:
30
-
31
-```ts
32
-Effect.fn("name")(
33
- function* (input: Input): Effect.fn.Return<A, E, R> {},
34
- (effect, input) => Effect.catch(effect, (reason) => Effect.logWarning("Err", { input, reason })),
35
-);
36
-```
37
-
38
-## Summary
39
-
40
-- Total non-test candidates: `322`
41
-
42
-## Suggested Order
43
-
44
-- [ ] `apps/server/src/provider/Layers/ProviderService.ts`
45
-- [x] `apps/server/src/provider/Layers/ClaudeAdapter.ts`
46
-- [x] `apps/server/src/provider/Layers/CodexAdapter.ts`
47
-- [x] `apps/server/src/git/Layers/GitCore.ts`
48
-- [x] `apps/server/src/git/Layers/GitManager.ts`
49
-- [x] `apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts`
50
-- [x] `apps/server/src/orchestration/Layers/ProjectionPipeline.ts`
51
-- [ ] `apps/server/src/orchestration/Layers/OrchestrationEngine.ts`
52
-- [ ] `apps/server/src/provider/Layers/EventNdjsonLogger.ts`
53
-- [ ] `Everything else`
54
-
55
-## Checklist
56
-
57
-### `apps/server/src/provider/Layers/ClaudeAdapter.ts` (`62`)
58
-
59
-- [x] [buildUserMessageEffect](../../apps/server/src/provider/Layers/ClaudeAdapter.ts#L554)
60
-- [x] [makeClaudeAdapter](../../apps/server/src/provider/Layers/ClaudeAdapter.ts#L913)
61
-- [x] [startSession](../../apps/server/src/provider/Layers/ClaudeAdapter.ts#L2414)
62
-- [x] [sendTurn](../../apps/server/src/provider/Layers/ClaudeAdapter.ts#L2887)
63
-- [x] [interruptTurn](../../apps/server/src/provider/Layers/ClaudeAdapter.ts#L2975)
64
-- [x] [readThread](../../apps/server/src/provider/Layers/ClaudeAdapter.ts#L2984)
65
-- [x] [rollbackThread](../../apps/server/src/provider/Layers/ClaudeAdapter.ts#L2990)
66
-- [x] [stopSession](../../apps/server/src/provider/Layers/ClaudeAdapter.ts#L3039)
67
-- [x] Internal helpers and callback wrappers in this file
68
-
69
-### `apps/server/src/git/Layers/GitCore.ts` (`58`)
70
-
71
-- [x] [makeGitCore](../../apps/server/src/git/Layers/GitCore.ts#L513)
72
-- [x] [handleTraceLine](../../apps/server/src/git/Layers/GitCore.ts#L324)
73
-- [x] [emitCompleteLines](../../apps/server/src/git/Layers/GitCore.ts#L455)
74
-- [x] [commit](../../apps/server/src/git/Layers/GitCore.ts#L1190)
75
-- [x] [pushCurrentBranch](../../apps/server/src/git/Layers/GitCore.ts#L1223)
76
-- [x] [pullCurrentBranch](../../apps/server/src/git/Layers/GitCore.ts#L1323)
77
-- [x] [checkoutBranch](../../apps/server/src/git/Layers/GitCore.ts#L1727)
78
-- [x] Service methods and callback wrappers in this file
79
-
80
-### `apps/server/src/git/Layers/GitManager.ts` (`28`)
81
-
82
-- [x] [configurePullRequestHeadUpstream](../../apps/server/src/git/Layers/GitManager.ts#L387)
83
-- [x] [materializePullRequestHeadBranch](../../apps/server/src/git/Layers/GitManager.ts#L428)
84
-- [x] [findOpenPr](../../apps/server/src/git/Layers/GitManager.ts#L576)
85
-- [x] [findLatestPr](../../apps/server/src/git/Layers/GitManager.ts#L602)
86
-- [x] [runCommitStep](../../apps/server/src/git/Layers/GitManager.ts#L728)
87
-- [x] [runPrStep](../../apps/server/src/git/Layers/GitManager.ts#L842)
88
-- [x] [runFeatureBranchStep](../../apps/server/src/git/Layers/GitManager.ts#L1106)
89
-- [x] Remaining helpers and nested callback wrappers in this file
90
-
91
-### `apps/server/src/orchestration/Layers/ProjectionPipeline.ts` (`25`)
92
-
93
-- [x] [runProjectorForEvent](../../apps/server/src/orchestration/Layers/ProjectionPipeline.ts#L1161)
94
-- [x] [applyProjectsProjection](../../apps/server/src/orchestration/Layers/ProjectionPipeline.ts#L357)
95
-- [x] [applyThreadsProjection](../../apps/server/src/orchestration/Layers/ProjectionPipeline.ts#L415)
96
-- [x] `Effect.forEach(..., threadId => Effect.gen(...))` callbacks around `L250`
97
-- [x] `Effect.forEach(..., entry => Effect.gen(...))` callbacks around `L264`
98
-- [x] `Effect.forEach(..., entry => Effect.gen(...))` callbacks around `L305`
99
-- [x] Remaining apply helpers in this file
100
-
101
-### `apps/server/src/provider/Layers/ProviderService.ts` (`24`)
102
-
103
-- [ ] [makeProviderService](../../apps/server/src/provider/Layers/ProviderService.ts#L134)
104
-- [ ] [recoverSessionForThread](../../apps/server/src/provider/Layers/ProviderService.ts#L196)
105
-- [ ] [resolveRoutableSession](../../apps/server/src/provider/Layers/ProviderService.ts#L255)
106
-- [ ] [startSession](../../apps/server/src/provider/Layers/ProviderService.ts#L284)
107
-- [ ] [sendTurn](../../apps/server/src/provider/Layers/ProviderService.ts#L347)
108
-- [ ] [interruptTurn](../../apps/server/src/provider/Layers/ProviderService.ts#L393)
109
-- [ ] [respondToRequest](../../apps/server/src/provider/Layers/ProviderService.ts#L411)
110
-- [ ] [respondToUserInput](../../apps/server/src/provider/Layers/ProviderService.ts#L430)
111
-- [ ] [stopSession](../../apps/server/src/provider/Layers/ProviderService.ts#L445)
112
-- [ ] [listSessions](../../apps/server/src/provider/Layers/ProviderService.ts#L466)
113
-- [ ] [rollbackConversation](../../apps/server/src/provider/Layers/ProviderService.ts#L516)
114
-- [ ] [runStopAll](../../apps/server/src/provider/Layers/ProviderService.ts#L538)
115
-
116
-### `apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts` (`14`)
117
-
118
-- [x] [finalizeAssistantMessage](../../apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts#L680)
119
-- [x] [upsertProposedPlan](../../apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts#L722)
120
-- [x] [finalizeBufferedProposedPlan](../../apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts#L761)
121
-- [x] [clearTurnStateForSession](../../apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts#L800)
122
-- [x] [processRuntimeEvent](../../apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts#L908)
123
-- [x] Nested callback wrappers in this file
124
-
125
-### `apps/server/src/provider/Layers/CodexAdapter.ts` (`12`)
126
-
127
-- [x] [makeCodexAdapter](../../apps/server/src/provider/Layers/CodexAdapter.ts#L1317)
128
-- [x] [sendTurn](../../apps/server/src/provider/Layers/CodexAdapter.ts#L1399)
129
-- [x] [writeNativeEvent](../../apps/server/src/provider/Layers/CodexAdapter.ts#L1546)
130
-- [x] [listener](../../apps/server/src/provider/Layers/CodexAdapter.ts#L1555)
131
-- [x] Remaining nested callback wrappers in this file
132
-
133
-### `apps/server/src/checkpointing/CheckpointStore.ts` (`10`)
134
-
135
-- [ ] [captureCheckpoint](../../apps/server/src/checkpointing/CheckpointStore.ts#L123)
136
-- [ ] [restoreCheckpoint](../../apps/server/src/checkpointing/CheckpointStore.ts#L137)
137
-- [ ] [diffCheckpoints](../../apps/server/src/checkpointing/CheckpointStore.ts#L144)
138
-- [ ] [deleteCheckpointRefs](../../apps/server/src/checkpointing/CheckpointStore.ts#L151)
139
-- [ ] Nested callback wrappers in this file
140
-
141
-### `apps/server/src/provider/Layers/EventNdjsonLogger.ts` (`9`)
142
-
143
-- [ ] [toLogMessage](../../apps/server/src/provider/Layers/EventNdjsonLogger.ts#L77)
144
-- [ ] [makeThreadWriter](../../apps/server/src/provider/Layers/EventNdjsonLogger.ts#L102)
145
-- [ ] [makeEventNdjsonLogger](../../apps/server/src/provider/Layers/EventNdjsonLogger.ts#L174)
146
-- [ ] [write](../../apps/server/src/provider/Layers/EventNdjsonLogger.ts#L231)
147
-- [ ] [close](../../apps/server/src/provider/Layers/EventNdjsonLogger.ts#L247)
148
-- [ ] Flush and writer-resolution callback wrappers in this file
149
-
150
-### `apps/server/scripts/cli.ts` (`8`)
151
-
152
-- [ ] Command handlers around [cli.ts](../../apps/server/scripts/cli.ts#L125)
153
-- [ ] Command handlers around [cli.ts](../../apps/server/scripts/cli.ts#L170)
154
-- [ ] Resource callbacks around [cli.ts](../../apps/server/scripts/cli.ts#L221)
155
-- [ ] Resource callbacks around [cli.ts](../../apps/server/scripts/cli.ts#L239)
156
-
157
-### `apps/server/src/orchestration/Layers/OrchestrationEngine.ts` (`7`)
158
-
159
-- [ ] [processEnvelope](../../apps/server/src/orchestration/Layers/OrchestrationEngine.ts#L64)
160
-- [ ] [dispatch](../../apps/server/src/orchestration/Layers/OrchestrationEngine.ts#L218)
161
-- [ ] Catch/stream callback wrappers around [OrchestrationEngine.ts](../../apps/server/src/orchestration/Layers/OrchestrationEngine.ts#L162)
162
-- [ ] Catch/stream callback wrappers around [OrchestrationEngine.ts](../../apps/server/src/orchestration/Layers/OrchestrationEngine.ts#L200)
163
-
164
-### `apps/server/src/orchestration/projector.ts` (`5`)
165
-
166
-- [ ] `switch` branch wrapper at [projector.ts](../../apps/server/src/orchestration/projector.ts#L242)
167
-- [ ] `switch` branch wrapper at [projector.ts](../../apps/server/src/orchestration/projector.ts#L336)
168
-- [ ] `switch` branch wrapper at [projector.ts](../../apps/server/src/orchestration/projector.ts#L397)
169
-- [ ] `switch` branch wrapper at [projector.ts](../../apps/server/src/orchestration/projector.ts#L446)
170
-- [ ] `switch` branch wrapper at [projector.ts](../../apps/server/src/orchestration/projector.ts#L478)
171
-
172
-### Smaller clusters
173
-
174
-- [ ] [packages/shared/src/DrainableWorker.ts](../../packages/shared/src/DrainableWorker.ts) (`4`)
175
-- [ ] [apps/server/src/wsServer/pushBus.ts](../../apps/server/src/wsServer/pushBus.ts) (`4`)
176
-- [ ] [apps/server/src/wsServer.ts](../../apps/server/src/wsServer.ts) (`4`)
177
-- [ ] [apps/server/src/provider/Layers/ProviderRegistry.ts](../../apps/server/src/provider/Layers/ProviderRegistry.ts) (`4`)
178
-- [ ] [apps/server/src/persistence/Layers/Sqlite.ts](../../apps/server/src/persistence/Layers/Sqlite.ts) (`4`)
179
-- [ ] [apps/server/src/orchestration/Layers/ProviderCommandReactor.ts](../../apps/server/src/orchestration/Layers/ProviderCommandReactor.ts) (`4`)
180
-- [ ] [apps/server/src/main.ts](../../apps/server/src/main.ts) (`4`)
181
-- [ ] [apps/server/src/keybindings.ts](../../apps/server/src/keybindings.ts) (`4`)
182
-- [ ] [apps/server/src/git/Layers/CodexTextGeneration.ts](../../apps/server/src/git/Layers/CodexTextGeneration.ts) (`4`)
183
-- [ ] [apps/server/src/serverLayers.ts](../../apps/server/src/serverLayers.ts) (`3`)
184
-- [ ] [apps/server/src/telemetry/Layers/AnalyticsService.ts](../../apps/server/src/telemetry/Layers/AnalyticsService.ts) (`2`)
185
-- [ ] [apps/server/src/telemetry/Identify.ts](../../apps/server/src/telemetry/Identify.ts) (`2`)
186
-- [ ] [apps/server/src/provider/Layers/ProviderAdapterRegistry.ts](../../apps/server/src/provider/Layers/ProviderAdapterRegistry.ts) (`2`)
187
-- [ ] [apps/server/src/provider/Layers/CodexProvider.ts](../../apps/server/src/provider/Layers/CodexProvider.ts) (`2`)
188
-- [ ] [apps/server/src/provider/Layers/ClaudeProvider.ts](../../apps/server/src/provider/Layers/ClaudeProvider.ts) (`2`)
189
-- [ ] [apps/server/src/persistence/NodeSqliteClient.ts](../../apps/server/src/persistence/NodeSqliteClient.ts) (`2`)
190
-- [ ] [apps/server/src/persistence/Migrations.ts](../../apps/server/src/persistence/Migrations.ts) (`2`)
191
-- [ ] [apps/server/src/open.ts](../../apps/server/src/open.ts) (`2`)
192
-- [ ] [apps/server/src/git/Layers/ClaudeTextGeneration.ts](../../apps/server/src/git/Layers/ClaudeTextGeneration.ts) (`2`)
193
-- [ ] [apps/server/src/checkpointing/CheckpointDiffQuery.ts](../../apps/server/src/checkpointing/CheckpointDiffQuery.ts) (`2`)
194
-- [ ] [apps/server/src/provider/makeManagedServerProvider.ts](../../apps/server/src/provider/makeManagedServerProvider.ts) (`1`)
195
-
196
-```
197
-
198
-```
docs/operations/mobile-app-store-screenshots.md
+48
-26
@@ -1,5 +1,7 @@
1
# Mobile app-store screenshot harness
2
3
+> For maintainers. Using T3 Code? See [docs/user](../user/).
4
+
5
The screenshot harness runs the real mobile application against three disposable local T3
6
environments. It creates an isolated base directory and server for each environment, real Git
7
projects with deterministic content, seeded orchestration projections, and persisted terminal
@@ -44,35 +46,44 @@ delay allows native terminal and Git review data to finish rendering.
46
A full capture regenerates the selected native project with Expo's clean development prebuild before
47
building it. Use --skip-build for repeated captures after the first build.
48
47
-The harness uses its own Metro port (8199 by default), so an ordinary mobile server or another
48
-worktree cannot accidentally provide the bundle being photographed.
49
+The harness uses fixed Metro port `8199`, which separates it from Expo's normal default port but is
50
+shared across every checkout. The readiness check only verifies that the port is open; it does not
51
+verify process ownership. Concurrent screenshot harnesses in different worktrees can therefore
52
+collide or attach to the wrong Metro process.
53
+
54
+Every configured device defaults to dark appearance, so plain `pnpm screenshots:mobile` produces
55
+30 dark PNGs. Pass `--appearance light`, `--appearance dark`, or `--appearance both` to override the
56
+configured appearance; `both` produces 60 PNGs.
57
58
The default matrix is:
59
52
-| Output folder | Capture target | Upload dimensions | Store slot |
53
-| ------------------------------------- | ------------------------- | ----------------- | ----------------------------------------- |
54
-| `apple/iphone-6.9/{light,dark}/` | iPhone 17 Pro Max | 1320×2868 | App Store Connect iPhone 6.9-inch |
55
-| `apple/iphone-6.5/{light,dark}/` | disposable iPhone 14 Plus | 1284×2778 | App Store Connect iPhone 6.5-inch |
56
-| `apple/ipad-13/{light,dark}/` | iPad Pro 13-inch (M5) | 2064×2752 | App Store Connect iPad 13-inch |
57
-| `google-play/phone/{light,dark}/` | Pixel AVD at 420 dpi | 1080×1920 | Google Play phone, portrait 9:16 |
58
-| `google-play/tablet-7/{light,dark}/` | Pixel AVD at 600dp width | 1080×1920 | Google Play 7-inch tablet, portrait 9:16 |
59
-| `google-play/tablet-10/{light,dark}/` | Pixel AVD at 800dp width | 1440×2560 | Google Play 10-inch tablet, portrait 9:16 |
60
-
61
-Each target captures thread, terminal, review, thread list, and environments, producing 30 PNG
62
-files for one appearance or 60 for both. Each appearance folder's five screenshots satisfy the configured Apple limit of 1–10, Google
60
+| Output folder | Capture target | Upload dimensions | Store slot |
61
+| ----------------------------- | ------------------------- | ----------------- | ----------------------------------------- |
62
+| `apple/iphone-6.9/dark/` | iPhone 17 Pro Max | 1320×2868 | App Store Connect iPhone 6.9-inch |
63
+| `apple/iphone-6.5/dark/` | disposable iPhone 14 Plus | 1284×2778 | App Store Connect iPhone 6.5-inch |
64
+| `apple/ipad-13/dark/` | iPad Pro 13-inch (M5) | 2064×2752 | App Store Connect iPad 13-inch |
65
+| `google-play/phone/dark/` | Pixel AVD at 420 dpi | 1080×1920 | Google Play phone, portrait 9:16 |
66
+| `google-play/tablet-7/dark/` | Pixel AVD at 600dp width | 1080×1920 | Google Play 7-inch tablet, portrait 9:16 |
67
+| `google-play/tablet-10/dark/` | Pixel AVD at 800dp width | 1440×2560 | Google Play 10-inch tablet, portrait 9:16 |
68
+
69
+Each target captures thread, terminal, review, thread list, and environments. Each appearance
70
+folder's five screenshots satisfy the configured Apple limit of 1–10, Google
71
phone requirement of 2–8, and Google tablet recommendation/slot minimum of 4 with a maximum of 8.
72
73
The generated tree is deliberately aligned with the store upload fields:
74
75
artifacts/app-store/screenshots/
76
├── apple/
69
- │ ├── iphone-6.9/{light,dark}/{thread,terminal,review,threads,environments}.png
70
- │ ├── iphone-6.5/{light,dark}/{thread,terminal,review,threads,environments}.png
71
- │ └── ipad-13/{light,dark}/{thread,terminal,review,threads,environments}.png
77
+ │ ├── iphone-6.9/dark/{thread,terminal,review,threads,environments}.png
78
+ │ ├── iphone-6.5/dark/{thread,terminal,review,threads,environments}.png
79
+ │ └── ipad-13/dark/{thread,terminal,review,threads,environments}.png
80
└── google-play/
73
- ├── phone/{light,dark}/{thread,terminal,review,threads,environments}.png
74
- ├── tablet-7/{light,dark}/{thread,terminal,review,threads,environments}.png
75
- └── tablet-10/{light,dark}/{thread,terminal,review,threads,environments}.png
81
+ ├── phone/dark/{thread,terminal,review,threads,environments}.png
82
+ ├── tablet-7/dark/{thread,terminal,review,threads,environments}.png
83
+ └── tablet-10/dark/{thread,terminal,review,threads,environments}.png
84
+
85
+A light-only run writes the same tree under `light/`; `--appearance both` writes both appearance
86
+folders.
87
88
Edit [mobile-showcase.config.ts](../../scripts/mobile-showcase.config.ts) to change simulator or AVD
89
names, light/dark appearance, scenes, output directory, capture delay, Android ABI, or viewport.
@@ -85,10 +96,11 @@ runs iOS and Android concurrently: iPhone and iPad capture on a
96
12-vCPU Blacksmith macOS runner, while Android phone, 7-inch tablet, and 10-inch tablet capture on a
97
16-vCPU Blacksmith Linux runner with a KVM-accelerated x86_64 emulator.
98
88
-Every job uploads its PNGs even when a later capture fails, which makes partial runs useful for
89
-diagnosis. Download `app-store-connect-screenshots` and `google-play-screenshots` from the workflow
90
-run's Artifacts section. Each job runs validation again immediately before upload. Artifacts are
91
-retained for 14 days.
99
+Every job uploads its PNGs even when capture fails, which makes partial runs useful for diagnosis.
100
+The separate validation step is success-gated: it runs before upload only when capture succeeds. If
101
+capture fails, the `always()` upload still publishes partial PNGs without re-validating them.
102
+Download `app-store-connect-screenshots` and `google-play-screenshots` from the workflow run's
103
+Artifacts section. Artifacts are retained for 14 days.
104
105
The workflow uses the same checked-in device and scene matrix as local capture. Android remains
106
ARM64 by default for local Apple Silicon development; CI sets `T3_SHOWCASE_ANDROID_ABI=x86_64` so the
@@ -111,11 +123,19 @@ Reuse the native build and retain the disposable environment:
123
124
pnpm screenshots:mobile --device ipad-13 --skip-build --keep-running
125
114
-Run Metro separately:
126
+By default, let the screenshot runner start Metro on port `8199`. To keep Metro in a separate
127
+terminal, start it with the same showcase environment and explicit harness port:
128
+
129
+ cd apps/mobile
130
+ APP_VARIANT=development EXPO_PUBLIC_SHOWCASE=1 pnpm exec expo start --dev-client --port 8199
131
+
132
+Then run the capture from the repository root:
133
116
- pnpm --filter @t3tools/mobile showcase
134
pnpm screenshots:mobile --skip-build --skip-metro --device iphone-6.9
135
136
+`pnpm --filter @t3tools/mobile showcase` starts Expo on its normal port, so it is not compatible with
137
+the harness's `--skip-metro` mode.
138
+
139
List the matrix and flags:
140
141
pnpm screenshots:mobile --list
@@ -151,7 +171,9 @@ remote-first while the harness retains reliable loopback connections to its ephe
171
## Local prerequisites
172
173
- iOS: Xcode command-line tools, the configured simulator runtimes, and installed CocoaPods.
154
-- Android: ANDROID_HOME (or the default macOS SDK path), adb, emulator, and the configured AVD.
174
+- Android: SDK resolution checks `ANDROID_HOME`, then `ANDROID_SDK_ROOT`, then defaults to
175
+ `$HOME/Library/Android/sdk` on macOS or `$HOME/Android/Sdk` on other platforms. The resolved SDK
176
+ must provide `adb` and `emulator`, and the configured AVD must exist.
177
178
The harness is the source of truth for upload dimensions; do not resize its output. If store rules
179
change, update the target's `storeAsset` specification. Capture fails when a PNG is the wrong size,
docs/operations/observability.md
+41
-20
@@ -1,39 +1,53 @@
1
# Observability
2
3
+> For maintainers. Using T3 Code? See [docs/user](../user/).
4
+
5
T3 Code has one server-side observability model:
6
7
- pretty logs go to stdout for humans
8
- completed spans go to a local NDJSON trace file
9
- traces and metrics can also be exported over OTLP to a real backend like Grafana LGTM
10
9
-The local trace file is the persisted source of truth. There is no separate persisted server log file anymore.
11
+The local trace file is the persisted source of truth for normal local launches. Those launches do not
12
+write a separate server log file, but SSH-managed launches also persist the remote process's
13
+stdout/stderr at `~/.t3/ssh-launch/<state>/server.log`.
14
15
## Where To Find Things
16
17
### Logs
18
15
-Logs are human-facing only:
19
+Logs are human-facing:
20
21
- destination: stdout
22
- format: `Logger.consolePretty()`
19
-- persistence: none
23
+- normal local persistence: none
24
+- SSH-managed launch persistence: `~/.t3/ssh-launch/<state>/server.log`
25
26
If you want a log message to show up in the trace file, emit it inside an active span with `Effect.log...`. `Logger.tracerLogger` will attach it as a span event.
27
28
### Traces
29
25
-Completed spans are written as NDJSON records to `serverTracePath` (by default, `~/.t3/userdata/logs/server.trace.ndjson`).
30
+Completed spans are written as NDJSON records to `serverTracePath`. The default depends on how the
31
+server starts: production and explicitly configured homes use
32
+`<home>/userdata/logs/server.trace.ndjson` (so `~/.t3/userdata/...` by default, or
33
+`/custom/path/userdata/...` with `--home-dir /custom/path`), a linked worktree dev run uses
34
+`<worktree>/.t3/userdata/logs/server.trace.ndjson`, and an implicit dev run outside a linked
35
+worktree uses `~/.t3/dev/logs/server.trace.ndjson`.
36
27
-Important fields in each record:
37
+Important fields common to both record types:
38
39
+- `type`: `effect-span` or `otlp-span`
40
- `name`: span name
41
- `traceId`, `spanId`, `parentSpanId`: correlation
42
- `durationMs`: elapsed time
43
- `attributes`: structured context
44
- `events`: embedded logs and custom events
34
-- `exit`: `Success`, `Failure`, or `Interrupted`
45
36
-The schema lives in `apps/server/src/observability/TraceRecord.ts`.
46
+`effect-span` records also contain `exit` with `Success`, `Failure`, or `Interrupted`. `otlp-span`
47
+records instead carry OTLP resource, scope, and optional status fields.
48
+
49
+The `TraceRecord`, `EffectTraceRecord`, and `OtlpTraceRecord` schemas live in
50
+`packages/shared/src/observability.ts`.
51
52
### Metrics
53
@@ -165,30 +179,35 @@ The backend reads observability config at process start. If you change OTLP env
179
180
The trace file is the fastest way to inspect raw span data.
181
168
-Resolve the production or explicitly configured trace file once. Runtime state lives under the
169
-base directory's `userdata` folder:
182
+Resolve the path for the launch mode once. Production and explicitly configured homes store runtime
183
+state under the base directory's `userdata` folder:
184
185
```bash
186
TRACE_FILE="${T3CODE_HOME:-$HOME/.t3}/userdata/logs/server.trace.ndjson"
187
```
188
175
-Tail it:
189
+A dev server started from a linked worktree defaults to that worktree's local home:
190
191
```bash
178
-tail -f "$TRACE_FILE"
192
+TRACE_FILE="$WORKTREE/.t3/userdata/logs/server.trace.ndjson"
193
```
194
181
-For an implicit monorepo dev server, use:
195
+Only an implicit dev run outside a linked worktree uses the shared dev directory:
196
197
```bash
198
TRACE_FILE="$HOME/.t3/dev/logs/server.trace.ndjson"
199
+```
200
+
201
+Tail the selected file:
202
+
203
+```bash
204
tail -f "$TRACE_FILE"
205
```
206
207
Show failed spans:
208
209
```bash
191
-jq -c 'select(.exit._tag != "Success") | {
210
+jq -c 'select(.type == "effect-span" and .exit._tag != "Success") | {
211
name,
212
durationMs,
213
exit,
@@ -281,10 +300,12 @@ Recommended flow in Grafana:
300
Good first searches:
301
302
- service name such as `t3-local`, `t3-dev`, or `t3-desktop`
284
-- span names like `sql.execute`, `git.runCommand`, `provider.sendTurn`
303
+- span names like `sendTurn` or a Git operation such as `GitVcsDriver.statusDetails.status`
304
+- Git spans whose `git.operation` attribute identifies the operation
305
- orchestration spans with attributes like `orchestration.command_type`
306
287
-Once you know traces are arriving, narrower TraceQL queries like `name = "sql.execute"` become useful.
307
+Once you know traces are arriving, narrower TraceQL queries for names such as `sendTurn` or Git
308
+operation names become useful.
309
310
### Use Metrics To See Systemic Problems
311
@@ -297,7 +318,6 @@ Good metric families to watch:
318
- `t3_orchestration_command_ack_duration`
319
- `t3_provider_turn_duration`
320
- `t3_git_command_duration`
300
-- `t3_db_query_duration`
321
322
Counters tell you volume and failure rate:
323
@@ -305,7 +325,6 @@ Counters tell you volume and failure rate:
325
- `t3_orchestration_commands_total`
326
- `t3_provider_turns_total`
327
- `t3_git_commands_total`
308
-- `t3_db_queries_total`
328
329
Use metrics when the question is:
330
@@ -339,7 +358,7 @@ If you need those later, add client-side instrumentation or a dedicated server f
358
### "Why did this request fail?"
359
360
1. Start with the local NDJSON file.
342
-2. Find spans where `exit._tag != "Success"`.
361
+2. Find `effect-span` records where `exit._tag != "Success"`.
362
3. Group by `traceId`.
363
4. Inspect sibling spans and span events.
364
5. If needed, move to Tempo for the full trace tree.
@@ -522,6 +541,8 @@ Current high-value span and metric boundaries include:
541
542
### Current Constraints
543
525
-- logs outside spans are not persisted
544
+- logs outside spans are not persisted in the trace file; SSH-managed launch stdout/stderr is still
545
+ captured in its launcher log
546
- metrics are not snapshotted locally
527
-- the old `serverLogPath` still exists in config for compatibility, but the trace file is the persisted artifact that matters
547
+- the old `serverLogPath` still exists in config for compatibility, but the trace file is the primary
548
+ structured persisted artifact
docs/operations/relay-observability.md
+22
-11
@@ -1,9 +1,14 @@
1
# Relay observability
2
3
-The relay Alchemy stack owns a focused Axiom trace setup:
3
+> For maintainers. Using T3 Code? See [docs/user](../user/).
4
5
-- `t3-code-relay-traces-prod`, an OpenTelemetry trace dataset for Worker requests
6
-- `t3-code-relay-otel-ingest-prod`, a dataset-scoped ingest token bound to the Worker
5
+The relay Alchemy stack owns a shared Axiom trace setup:
6
+
7
+- `t3-code-relay-traces-prod`, the OpenTelemetry trace dataset shared by the Worker, mobile app, and
8
+ first-party relay clients
9
+- `t3-code-relay-otel-ingest-prod`, the dataset-scoped Worker ingest token
10
+- `t3-code-mobile-otel-ingest-prod`, the dataset-scoped mobile ingest token
11
+- `t3-code-relay-client-otel-ingest-prod`, the dataset-scoped first-party relay-client ingest token
12
- `t3-code-relay-recent-spans-prod`, a view of recent request and endpoint spans
13
14
Alchemy stages append their sanitized stage name to isolate resources, for example
@@ -15,8 +20,9 @@ Deploy from `infra/relay` with the normal Alchemy workflow:
20
vp run deploy
21
```
22
18
-Alchemy resolves Axiom deployment credentials through its provider. At runtime, the Worker
19
-receives only the scoped ingest token; it does not receive the diagnostics query token.
23
+Alchemy resolves account-level Axiom deployment credentials through its provider. At runtime, the
24
+Worker receives only its scoped ingest token. Mobile and relay clients use their own separately
25
+provisioned scoped ingest tokens.
26
27
The Worker emits Effect's built-in HTTP server spans plus endpoint and database child spans.
28
Effect's OpenTelemetry exporter stores semantic HTTP attributes below the `attributes.` prefix.
@@ -25,18 +31,23 @@ For example:
31
```apl
32
['t3-code-relay-traces-prod']
33
| where name startswith 'http.server'
34
+| extend endpoint = column_ifexists('attributes.http.route', ''),
35
+ customAttributes = column_ifexists('attributes.custom', dynamic({}))
36
| project _time, name, trace_id, duration,
37
['attributes.http.request.method'],
38
['attributes.url.path'],
31
- ['attributes.http.response.status_code']
39
+ ['attributes.http.response.status_code'],
40
+ endpoint,
41
+ relayOperation = customAttributes['relay']['operation']
42
| order by _time desc
43
| limit 200
44
```
45
36
-Endpoint failure annotations and other relay-specific attributes are also emitted in the
37
-`attributes.custom` map when present on a span, for example
38
-`['attributes.custom']['relay.endpoint']`.
46
+The provisioned view also reads the endpoint from `attributes.http.route`. Relay-specific span
47
+annotations are stored under `attributes.custom`; `relay.operation` is one of the emitted custom
48
+attributes.
49
50
Agents should prefer the provisioned view or APL queries for completed incidents instead of
41
-tailing the Cloudflare Worker. Use the read-only query token when scripted access is needed;
42
-keep the ingest token reserved for the Worker.
51
+tailing the Cloudflare Worker. The stack does not provision a separate query token. Responders who
52
+need scripted query access use the authorized account-level `AXIOM_TOKEN` together with
53
+`AXIOM_ORG_ID`; scoped ingest tokens remain write-only credentials for their producers.
docs/operations/release.md
+39
-20
@@ -1,5 +1,7 @@
1
# Release Checklist
2
3
+> For maintainers. Using T3 Code? See [docs/user](../user/).
4
+
5
This document covers the unified release workflow for stable and nightly desktop releases.
6
7
## What the workflow does
@@ -30,6 +32,17 @@ This document covers the unified release workflow for stable and nightly desktop
32
- nightly releases are aliased to the `nightly` hosted app channel
33
- Signing is optional and auto-detected per platform from secrets.
34
35
+## Required release credentials
36
+
37
+The release workflow requires these GitHub Actions secrets in addition to the platform and deployment
38
+credentials documented below:
39
+
40
+- `RELEASE_APP_ID`
41
+- `RELEASE_APP_PRIVATE_KEY`
42
+
43
+The GitHub Release job uses them to mint the token that publishes release assets. Stable releases use
44
+them again in the finalize job, which can commit and push aligned package versions to `main`.
45
+
46
## T3 Connect relay deployment
47
48
The relay is a shared control plane versioned separately from client releases. Stable and nightly
@@ -148,7 +161,8 @@ One-time Vercel dashboard setup:
161
- manual `workflow_dispatch` with `channel=nightly`
162
- Runs the same desktop quality gates and artifact matrix as the tagged release flow.
163
- Publishes a GitHub prerelease only:
151
- - tag format: `nightly-vX.Y.Z-nightly.YYYYMMDD.<run_number>`
164
+ - current tag format: `vX.Y.Z-nightly.YYYYMMDD.<run_number>`
165
+ - `nightly-v...` is accepted only as a legacy previous-nightly tag
166
- release name includes the short commit SHA
167
- `make_latest` is always `false`
168
- Uses the next stable patch version as the nightly base. For example, `0.0.17` produces nightlies on `0.0.18-nightly.*`.
@@ -178,7 +192,9 @@ guidance when those environments are available.
192
193
## Desktop auto-update notes
194
181
-- Runtime updater: `electron-updater` in `apps/desktop/src/main.ts`.
195
+- Updater runtime: `apps/desktop/src/updates/DesktopUpdates.ts`.
196
+- `electron-updater` adapter: `apps/desktop/src/electron/ElectronUpdater.ts`.
197
+- `apps/desktop/src/main.ts` only wires the updater layers into the desktop runtime.
198
- Update UX:
199
- Background checks run on startup delay + interval.
200
- No automatic download or install.
@@ -187,9 +203,6 @@ guidance when those environments are available.
203
- Repository slug source:
204
- `T3CODE_DESKTOP_UPDATE_REPOSITORY` (format `owner/repo`), if set.
205
- otherwise `GITHUB_REPOSITORY` from GitHub Actions.
190
-- Temporary private-repo auth workaround:
191
- - set `T3CODE_DESKTOP_UPDATE_GITHUB_TOKEN` (or `GH_TOKEN`) in the desktop app runtime environment.
192
- - the app forwards it as an `Authorization: Bearer <token>` request header for updater HTTP calls.
206
- Required release assets for updater:
207
- platform installers (`.exe`, `.dmg`, `.AppImage`, plus macOS `.zip` for Squirrel.Mac update payloads)
208
- channel metadata: `latest*.yml` for stable releases, `nightly*.yml` for nightly releases
@@ -200,8 +213,9 @@ guidance when those environments are available.
213
214
## 0) npm OIDC trusted publishing setup (CLI)
215
203
-The workflow publishes the CLI with `npm publish` from `apps/server` after bumping
204
-the package version to the release tag version.
216
+The workflow invokes `node apps/server/scripts/cli.ts publish` after aligning package versions. That
217
+script temporarily prepares the `t3` package, then runs `vp pm publish --filter t3 ...` from the
218
+repository root so workspace publish configuration is applied correctly.
219
220
Checklist:
221
@@ -213,22 +227,27 @@ Checklist:
227
- Environment (if used): match your npm trusted publishing config
228
3. Ensure npm account and org policies allow trusted publishing for the package.
229
4. Create release tag `vX.Y.Z` and push; workflow will:
216
- - set `apps/server/package.json` version to `X.Y.Z`
230
+ - align the release package versions to `X.Y.Z`
231
- build web + server
218
- - run `npm publish --access public --tag latest`
219
-5. Nightly runs from the same workflow file publish with `npm publish --access public --tag nightly`.
232
+ - invoke the CLI publish script with npm dist-tag `latest`
233
+5. Nightly runs invoke the same publish script with npm dist-tag `nightly`.
234
+
235
+## 1) Release validation and unsigned builds
236
221
-## 1) Dry-run release without signing
237
+There is no dry-run tag path. Pushing any accepted non-nightly tag, including
238
+`v0.0.0-test.1`, classifies the run as the stable channel. It publishes `t3` with npm dist-tag
239
+`latest`, creates a real GitHub Release, aliases the hosted app to `latest.app.t3.codes` and
240
+`app.t3.codes`, and can commit a version bump to `main` in the finalize job. Do not push a test tag
241
+to validate the workflow.
242
223
-Use this first to validate the release pipeline.
243
+The workflow has no non-publishing `workflow_dispatch` mode. Use normal CI or local quality gates to
244
+validate checks and builds without shipping. To exercise the complete release graph at lower stable
245
+risk, manually dispatch `channel=nightly`; this still publishes a real nightly npm package, GitHub
246
+prerelease, desktop updater release, and hosted nightly alias, but it does not update stable aliases or
247
+commit a version bump to `main`. Only run it when a real nightly release is acceptable.
248
225
-1. Confirm no signing secrets are required for this test.
226
-2. Create a test tag:
227
- - `git tag v0.0.0-test.1`
228
- - `git push origin v0.0.0-test.1`
229
-3. Wait for `.github/workflows/release.yml` to finish.
230
-4. Verify the GitHub Release contains all platform artifacts.
231
-5. Download each artifact and sanity-check installation on each OS.
249
+Manual `channel=stable` with a version input is also a real stable-channel release. Omitting signing
250
+secrets only makes platform artifacts unsigned; it does not prevent publication.
251
252
## 2) Apple signing + notarization setup (macOS)
253
@@ -267,7 +286,7 @@ Checklist:
286
- `APPLE_API_KEY`: contents of the downloaded `.p8`
287
- `APPLE_API_KEY_ID`: Key ID
288
- `APPLE_API_ISSUER`: Issuer ID
270
-10. Complete the Clerk Native API and AASA setup in [T3 Connect Clerk Setup](../cloud/t3-connect-clerk.md#desktop-passkeys).
289
+10. Complete the Clerk Native API and AASA setup in [T3 Connect Clerk Setup](../internals/t3-connect.md#desktop-passkeys).
290
11. Re-run a tag release and confirm macOS artifacts are signed/notarized and contain the expected
291
`com.apple.developer.associated-domains` entitlement.
292
docs/project/todo.md
deleted
-13
@@ -1,13 +0,0 @@
1
-# TODO
2
-
3
-## Small things
4
-
5
-- [ ] Submitting new messages should scroll to bottom
6
-- [ ] Only show last 10 threads for a given project
7
-- [ ] Thread archiving
8
-- [ ] New projects should go on top
9
-- [ ] Projects should be sorted by latest thread update
10
-
11
-## Bigger things
12
-
13
-- [ ] Queueing messages
docs/reference/scripts.md
deleted
-56
@@ -1,56 +0,0 @@
1
-# Scripts
2
-
3
-- `vp run dev` — Starts contracts, server, and web in watch mode.
4
-- `vp run dev --share` — Also publishes the web port over HTTPS on this machine's tailnet. The startup pairing URL is built against the shared origin, and the mapping is removed on exit.
5
-- `vp run dev:server` — Starts just the WebSocket server. The server process runs on Bun (`@effect/platform-bun` + `BunPtyAdapter`), but task running uses `vp run`.
6
-- `vp run dev:web` — Starts just the Vite dev server for the web app.
7
-- Dev commands run from a linked **git worktree** default to that worktree's gitignored `.t3`, even when `T3CODE_HOME` is set, storing state in `<worktree>/.t3/userdata`. Pass `--home-dir <path>` to choose another isolated directory explicitly. Submodules are not worktrees and keep the normal precedence.
8
-- From the **main checkout**, dev commands implicitly use `~/.t3/dev`, keeping development state separate from `~/.t3/userdata`. An explicit `--home-dir <path>` stores state under `<path>/userdata`; the base directory remains available for caches, worktrees, and other shared data.
9
-- Web dev commands do not auto-open a browser. Open the one-time pairing URL printed by the server so the first browser navigation is authenticated. Set `T3CODE_NO_BROWSER=0` only when interactive auto-open is intentional.
10
-- Pass dev-runner flags directly after the root task name, for example:
11
- `vp run dev --home-dir /tmp/t3code-dev`
12
-- `vp run start` — Runs the production server (serves built web app as static files).
13
-- `vp run build` — Builds contracts, web app, and server.
14
-- `vp run typecheck` — Strict TypeScript checks for all packages.
15
-- `vp run test` — Runs workspace tests.
16
-- `node apps/server/scripts/t3-sqlite-state.ts <query|exec> --base-dir <path> ...` — Inspects or seeds an isolated T3 SQLite database; writes create a private backup first.
17
-- `vp run dist:desktop:artifact -- --platform <mac|linux|win> --target <target> --arch <arch>` — Builds a desktop artifact for a specific platform/target/arch.
18
-- `vp run dist:desktop:dmg` — Builds a shareable macOS `.dmg` into `./release`.
19
-- `vp run dist:desktop:dmg:x64` — Builds an Intel macOS `.dmg`.
20
-- `vp run dist:desktop:linux` — Builds a Linux AppImage into `./release`.
21
-- `vp run dist:desktop:win` — Builds a Windows NSIS installer into `./release`.
22
-
23
-## Desktop `.dmg` packaging notes
24
-
25
-- Default build is unsigned/not notarized for local sharing.
26
-- The DMG build uses `assets/prod/black-macos-1024.png` as the production app icon source.
27
-- Desktop production windows load the bundled UI from `t3code://app/index.html` (not a `127.0.0.1` document URL).
28
-
29
-- Desktop packaging includes `apps/server/dist` (the `t3` backend) and starts it on loopback with an auth token for WebSocket/API traffic.
30
-- Your tester can still open it on macOS by right-clicking the app and choosing **Open** on first launch.
31
-- To keep staging files for debugging package contents, run: `vp run dist:desktop:dmg -- --keep-stage`
32
-- To allow code-signing/notarization when configured in CI/secrets, add: `--signed`.
33
-- Signed macOS builds also require `T3CODE_APPLE_TEAM_ID` and
34
- `T3CODE_MACOS_PROVISIONING_PROFILE`. The passkey RP domain is derived from
35
- `T3CODE_CLERK_PUBLISHABLE_KEY` unless `T3CODE_CLERK_PASSKEY_RP_DOMAINS` overrides it.
36
-- Windows `--signed` uses Azure Trusted Signing and expects:
37
- `AZURE_TRUSTED_SIGNING_ENDPOINT`, `AZURE_TRUSTED_SIGNING_ACCOUNT_NAME`,
38
- `AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE_NAME`, and `AZURE_TRUSTED_SIGNING_PUBLISHER_NAME`.
39
-- Azure authentication env vars are also required (for example service principal with secret):
40
- `AZURE_TENANT_ID`, `AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET`.
41
-
42
-## Browser development
43
-
44
-`dev` and `dev:web` leave `VITE_HTTP_URL` and `VITE_WS_URL` unset so the browser resolves the backend from `window.location.origin`. Vite proxies `/api`, `/ws`, `/oauth`, and `/.well-known` to the server, allowing the same bundle to work from localhost or a tailnet hostname.
45
-
46
-Worktrees derive a preferred port offset from their path. The runner shifts both ports together when either is occupied or the web port is blocked by browsers, so treat the `[dev-runner]` output as authoritative.
47
-
48
-## Running multiple dev instances
49
-
50
-Set `T3CODE_DEV_INSTANCE` to any value to deterministically shift all dev ports together.
51
-
52
-- Default ports: server `13773`, web `5733`
53
-- Shifted ports: `base + offset` (offset is hashed from `T3CODE_DEV_INSTANCE`)
54
-- Example: `T3CODE_DEV_INSTANCE=branch-a vp run dev:desktop`
55
-
56
-If you want full control instead of hashing, set `T3CODE_PORT_OFFSET` to a numeric offset.
docs/reference/workspace-layout.md
deleted
-7
@@ -1,7 +0,0 @@
1
-# Workspace layout
2
-
3
-- `/apps/server`: Node.js WebSocket server. Wraps Codex app-server, serves the built web app, and opens the browser on start.
4
-- `/apps/web`: React + Vite UI. Session control, conversation, and provider event rendering. Connects to the server via WebSocket.
5
-- `/apps/desktop`: Electron shell. Spawns a desktop-scoped `t3` backend process and loads the shared web app.
6
-- `/packages/contracts`: Shared effect/Schema schemas and TypeScript contracts for provider events, WebSocket protocol, and model/session types.
7
-- `/packages/shared`: Shared runtime utilities consumed by both server and web. Uses explicit subpath exports (e.g. `@t3tools/shared/git`, `@t3tools/shared/DrainableWorker`) — no barrel index.
docs/user/install.md
new
+84
@@ -0,0 +1,84 @@
1
+# Install T3 Code
2
+
3
+T3 Code is a web and desktop GUI for running coding agents on your machine.
4
+
5
+## Requirements
6
+
7
+Node.js `^22.16 || ^23.11 || >=24.10` on the machine that runs the T3 Code server.
8
+
9
+At least one provider CLI, installed and authenticated. See [Providers](#providers) below.
10
+
11
+## Run Without Installing
12
+
13
+```bash
14
+npx t3@latest
15
+```
16
+
17
+This starts the T3 Code server on your machine and opens the local web app. Use
18
+`npx t3@latest --help` for the full CLI reference.
19
+
20
+## Desktop App
21
+
22
+Download the latest release from
23
+[GitHub Releases](https://github.com/pingdotgg/t3code/releases), or install from a package
24
+registry.
25
+
26
+Windows:
27
+
28
+```bash
29
+winget install T3Tools.T3Code
30
+```
31
+
32
+macOS:
33
+
34
+```bash
35
+brew install --cask t3-code
36
+```
37
+
38
+Arch Linux:
39
+
40
+```bash
41
+yay -S t3code-bin
42
+```
43
+
44
+## Providers
45
+
46
+T3 Code drives provider CLIs; it does not ship them. Install the CLI for each provider you want
47
+to use, then authenticate it.
48
+
49
+| Provider | CLI | Default binary | Log in with |
50
+| ---------- | ----------------------------------------------------- | -------------- | --------------------- |
51
+| Codex | [Codex CLI](https://developers.openai.com/codex/cli) | `codex` | `codex login` |
52
+| Claude | [Claude Code](https://claude.com/product/claude-code) | `claude` | `claude auth login` |
53
+| Cursor | [Cursor CLI](https://cursor.com/cli) | `cursor-agent` | `agent login` |
54
+| Grok Build | [Grok Build CLI](https://x.ai/cli) | `grok` | `grok login` |
55
+| OpenCode | [OpenCode](https://opencode.ai) | `opencode` | `opencode auth login` |
56
+
57
+Cursor is the one to watch: install Cursor CLI, which provides the `cursor-agent` binary that
58
+T3 Code looks for, but authenticate with `agent login`, not `cursor-agent login`.
59
+
60
+Run the login command on the machine running the T3 Code server, not on the device you browse
61
+from.
62
+
63
+### Binary Discovery
64
+
65
+Each provider CLI must be on the server's `PATH`, or have an explicit binary path set in
66
+**Settings** → the provider instance → **Binary path**. Use the explicit path when a version
67
+manager or a non-standard install location keeps the CLI off the `PATH` of the shell that
68
+started T3 Code.
69
+
70
+### When Auth Is Needed
71
+
72
+Provider auth is required before you start a session with that provider, not before you start
73
+T3 Code. You can install T3 Code, open it, and add providers afterwards. A provider that is not
74
+authenticated shows its status in **Settings** and fails at session start with the login command
75
+to run.
76
+
77
+For multi-account setups, see [Codex](./providers-codex.md) and [Claude](./providers-claude.md).
78
+
79
+## Next Steps
80
+
81
+- [Permission modes](./permission-modes.md): how much T3 Code asks before acting
82
+- [Remote access](./remote-access.md): connect from a phone, tablet, or another desktop
83
+- [Keeping T3 Code in sync](./updating.md): client and server version skew
84
+- [Running in the background](./background-service.md): Linux background service
docs/user/keybindings.md
+37
-84
@@ -1,10 +1,14 @@
1
# Keybindings
2
3
-T3 Code reads keybindings from:
3
+Edit keybindings from **Settings** → **Keybindings**. That page lists every command, its current
4
+shortcut, whether it is a default or your own, and warns about conflicts.
5
5
-- `~/.t3/keybindings.json`
6
+The same configuration lives in `~/.t3/userdata/keybindings.json` on the machine running the
7
+server, if you prefer editing it directly. T3 Code writes the built-in defaults into that file on
8
+first run, and adds any new defaults on later startups unless a rule of yours already claims the
9
+command or the shortcut.
10
7
-The file must be a JSON array of rules:
11
+The file is a JSON array of rules.
12
13
```json
14
[
@@ -13,110 +17,59 @@ The file must be a JSON array of rules:
17
]
18
```
19
16
-See the full schema for more details: [`packages/contracts/src/keybindings.ts`](../../packages/contracts/src/keybindings.ts)
20
+Invalid rules are ignored. An invalid file is ignored entirely, and the server logs a warning.
21
18
-## Defaults
22
+## Rule Shape
23
20
-```json
21
-[
22
- { "key": "mod+j", "command": "terminal.toggle" },
23
- { "key": "mod+d", "command": "terminal.split", "when": "terminalFocus" },
24
- { "key": "mod+n", "command": "terminal.new", "when": "terminalFocus" },
25
- { "key": "mod+w", "command": "terminal.close", "when": "terminalFocus" },
26
- { "key": "mod+shift+j", "command": "preview.toggle" },
27
- { "key": "mod+r", "command": "preview.refresh", "when": "previewFocus" },
28
- { "key": "mod+l", "command": "preview.focusUrl", "when": "previewFocus" },
29
- { "key": "mod+=", "command": "preview.zoomIn", "when": "previewFocus" },
30
- { "key": "mod+-", "command": "preview.zoomOut", "when": "previewFocus" },
31
- { "key": "mod+0", "command": "preview.resetZoom", "when": "previewFocus" },
32
- { "key": "mod+k", "command": "commandPalette.toggle", "when": "!terminalFocus" },
33
- { "key": "mod+n", "command": "chat.new", "when": "!terminalFocus" },
34
- { "key": "mod+shift+o", "command": "chat.new", "when": "!terminalFocus" },
35
- { "key": "mod+shift+n", "command": "chat.newLocal", "when": "!terminalFocus" },
36
- { "key": "mod+o", "command": "editor.openFavorite" }
37
-]
38
-```
39
-
40
-For most up to date defaults, see [`DEFAULT_KEYBINDINGS` in `apps/server/src/keybindings.ts`](../../apps/server/src/keybindings.ts)
24
+- `key` (required): shortcut string, like `mod+j`, `ctrl+k`, `cmd+shift+d`
25
+- `command` (required): the command ID to run
26
+- `when` (optional): boolean expression controlling when the shortcut is active
27
42
-## Configuration
28
+## Key Syntax
29
44
-### Rule Shape
30
+Modifiers: `mod` (`cmd` on macOS, `ctrl` elsewhere), `cmd` / `meta`, `ctrl` / `control`, `shift`,
31
+`alt` / `option`.
32
46
-Each entry supports:
33
+Examples: `mod+j`, `mod+shift+d`, `ctrl+l`, `cmd+k`.
34
48
-- `key` (required): shortcut string, like `mod+j`, `ctrl+k`, `cmd+shift+d`
49
-- `command` (required): action ID
50
-- `when` (optional): boolean expression controlling when the shortcut is active
35
+## Commands
36
52
-Invalid rules are ignored. Invalid config files are ignored. Warnings are logged by the server.
53
-
54
-### Available Commands
55
-
56
-- `terminal.toggle`: open/close terminal drawer
57
-- `terminal.split`: split terminal (in focused terminal context by default)
58
-- `terminal.new`: create new terminal (in focused terminal context by default)
59
-- `terminal.close`: close/kill the focused terminal (in focused terminal context by default)
60
-- `preview.toggle`: open/close the in-app browser preview panel (desktop app only)
61
-- `preview.refresh`: reload the active preview tab (in focused preview context by default)
62
-- `preview.focusUrl`: focus the URL input of the preview panel (in focused preview context by default)
63
-- `preview.zoomIn`: zoom the preview viewport in one step (in focused preview context by default)
64
-- `preview.zoomOut`: zoom the preview viewport out one step (in focused preview context by default)
65
-- `preview.resetZoom`: reset the preview zoom to 100% (in focused preview context by default)
66
-- `commandPalette.toggle`: open or close the global command palette
67
-- `chat.new`: create a new chat thread preserving the active thread's branch/worktree state
68
-- `chat.newLocal`: create a new chat thread for the active project in a new environment (local/worktree determined by app settings (default `local`))
69
-- `editor.openFavorite`: open current project/worktree in the last-used editor
70
-- `script.{id}.run`: run a project script by id (for example `script.test.run`)
37
+Commands are IDs like `terminal.toggle`, `commandPalette.toggle`, `preview.refresh`, and
38
+`chat.new`. Project scripts are addressable as `script.{id}.run`, for example `script.test.run`.
39
40
The command palette searches active thread titles, projects, branches, user messages, and final
41
agent responses across connected environments. Message matches show one labeled excerpt while
42
keeping the thread's project, branch, and machine context visible. Message search begins after two
43
characters and uses SQLite's ASCII case-insensitive matching.
44
77
-### Key Syntax
78
-
79
-Supported modifiers:
80
-
81
-- `mod` (`cmd` on macOS, `ctrl` on non-macOS)
82
-- `cmd` / `meta`
83
-- `ctrl` / `control`
84
-- `shift`
85
-- `alt` / `option`
86
-
87
-Examples:
88
-
89
-- `mod+j`
90
-- `mod+shift+d`
91
-- `ctrl+l`
92
-- `cmd+k`
45
+The full command list and the current defaults are shown in **Settings** → **Keybindings**, which
46
+always matches the build you are running. Use that rather than a copied list.
47
94
-### `when` Conditions
48
+Note that `chat.new` and `chat.newLocal` both create a thread through the same path. A new thread
49
+inherits the project you were in, along with model and mode selections. Branch, worktree, and
50
+environment mode always come from your configured defaults, not from the thread you were looking
51
+at. To keep a worktree, use the explicit "new thread in this worktree" action in the branch
52
+toolbar. The only difference between the two commands: with the current sidebar and more than one
53
+project, `chat.new` opens a project chooser first.
54
96
-Currently available context keys:
55
+## `when` Conditions
56
98
-- `terminalFocus`
99
-- `terminalOpen`
100
-- `previewFocus`
101
-- `previewOpen`
57
+A `when` expression is evaluated against context keys describing the current UI state. The keys
58
+the app supplies today are `terminalFocus`, `terminalOpen`, `previewFocus`, `previewOpen`, and
59
+`modelPickerOpen`. The set is open and grows over time, so treat that as the current list rather
60
+than a fixed one. Any key the running app does not supply evaluates to `false`.
61
103
-Supported operators:
104
-
105
-- `!` (not)
106
-- `&&` (and)
107
-- `||` (or)
108
-- parentheses: `(` `)`
62
+Operators: `!` (not), `&&` (and), `||` (or), and parentheses.
63
64
Examples:
65
66
- `"when": "terminalFocus"`
67
- `"when": "terminalOpen && !terminalFocus"`
114
-- `"when": "terminalFocus || terminalOpen"`
115
-
116
-Unknown condition keys evaluate to `false`.
68
+- `"when": "!terminalFocus"`
69
118
-### Precedence
70
+## Precedence
71
72
- Rules are evaluated in array order.
73
- For a key event, the last rule where both `key` matches and `when` evaluates to `true` wins.
122
-- That means precedence is across commands, not only within the same command.
74
+- Precedence is across commands, not only within the same command. A later rule for a different
75
+ command can take a key away from an earlier one.
docs/user/permission-modes.md
new
+48
@@ -0,0 +1,48 @@
1
+# Permission Modes
2
+
3
+A permission mode controls how much the agent does on its own and when it stops to ask you.
4
+
5
+The mode is set per thread, from the mode control in the message composer. Changing it in one
6
+thread does not change any other thread. A thread created from inside another thread keeps that
7
+thread's mode; otherwise new threads start in **Full access** unless you pick something else
8
+before sending.
9
+
10
+## The Modes
11
+
12
+**Supervised**: ask before commands and file changes. The agent pauses and shows you what it
13
+wants to run or edit, and waits for approval. Work outside the workspace is restricted.
14
+
15
+**Auto-accept edits**: auto-approve edits, ask before other actions. File changes go through
16
+without prompting; commands and anything else still stop for approval.
17
+
18
+**Auto**: routine actions proceed without you; risky ones still ask. How this is enforced depends
19
+on the provider: Codex delegates routine approvals to an AI reviewer, Claude uses its own auto
20
+permission mode, and providers without an equivalent (such as OpenCode) fall back to asking, like
21
+Supervised.
22
+
23
+**Full access**: allow commands and edits without prompts. The default. The agent runs
24
+unattended until it finishes or asks a question of its own.
25
+
26
+Approvals appear inline in the conversation. Approve or reject one and the agent continues from
27
+there.
28
+
29
+## Choosing a Mode
30
+
31
+Use **Full access** for work in a worktree or a sandbox you can throw away.
32
+
33
+Use **Supervised** on a repository where an unwanted command is expensive, or the first time you
34
+run an unfamiliar task.
35
+
36
+**Auto-accept edits** suits refactors where the edits are the point and you only care about the
37
+shell commands.
38
+
39
+## Provider Behavior
40
+
41
+Each provider maps these modes onto its own approval and sandbox settings. Codex, for example,
42
+translates the mode into its approval policy and sandbox level, so **Supervised** runs the CLI
43
+with prompting enabled and a restricted workspace while **Full access** disables both. The
44
+labels above describe what you get; the exact per-provider translation is internal and may
45
+change.
46
+
47
+Mobile offers the same four modes. It labels the first one **Approve actions** rather than
48
+**Supervised**.
docs/user/providers-claude.md
renamed
+30
-44
@@ -1,6 +1,7 @@
1
# Claude
2
3
-This guide is for people who want to use more than one Claude setup in T3 Code.
3
+This guide is for people who want to use more than one Claude setup in T3 Code. For Codex, see
4
+[Codex](./providers-codex.md). For first-time setup, see [Install T3 Code](./install.md).
5
6
Common reasons:
7
@@ -24,20 +25,24 @@ In T3 Code Settings, your Claude provider can stay like this:
25
```text
26
Display name: Claude
27
Binary path: claude
27
-Claude HOME path: empty
28
+CLAUDE_CONFIG_DIR path: empty
29
```
30
30
-An empty `Claude HOME path` means T3 Code uses your normal home directory.
31
+An empty `CLAUDE_CONFIG_DIR path` means T3 Code uses Claude Code's normal config directory.
32
+
33
+When you set this field, T3 Code points Claude Code at that directory with the
34
+`CLAUDE_CONFIG_DIR` environment variable. It does not change `HOME`, so your system keychain and
35
+the rest of your environment stay as they are.
36
37
## I Want Work And Personal Claude Accounts
38
34
-Use a different Claude home for each account.
39
+Use a different Claude config directory for each account.
40
41
Example:
42
43
```text
39
-default home work account
40
-~/.claude_personal_home personal account
44
+default config dir work account
45
+~/.claude_personal_home personal account
46
```
47
48
### Set Up The First Account
@@ -53,24 +58,27 @@ In T3 Code Settings:
58
```text
59
Display name: Claude Work
60
Binary path: claude
56
-Claude HOME path: empty
61
+CLAUDE_CONFIG_DIR path: empty
62
```
63
64
### Set Up The Second Account
65
61
-Log in with a separate home:
66
+Log in with a separate config directory:
67
68
```bash
69
mkdir -p ~/.claude_personal_home
65
-HOME=~/.claude_personal_home claude auth login
70
+CLAUDE_CONFIG_DIR=~/.claude_personal_home claude auth login
71
```
72
73
+Use `CLAUDE_CONFIG_DIR`, not `HOME`. Setting `HOME` writes the login to
74
+`~/.claude_personal_home/.claude`, which is not where T3 Code looks.
75
+
76
Then add another Claude provider in T3 Code:
77
78
```text
79
Display name: Claude Personal
80
Binary path: claude
73
-Claude HOME path: ~/.claude_personal_home
81
+CLAUDE_CONFIG_DIR path: ~/.claude_personal_home
82
```
83
84
Use the email shown in Settings to confirm each provider is using the intended account. Emails are
@@ -80,12 +88,12 @@ blurred by default; click the blurred email to reveal it.
88
89
Usually, no.
90
83
-T3 Code only offers Claude providers that use the same Claude home for an existing thread. A
84
-different Claude home is treated as a different Claude environment.
91
+T3 Code only offers Claude providers that use the same config directory for an existing thread. A
92
+different config directory is treated as a different Claude environment.
93
94
This is different from the recommended Codex setup. Claude Code keeps account and local state across
87
-multiple files under its home directory, so T3 Code keeps separate Claude homes isolated instead of
88
-trying to share part of the state.
95
+multiple files under its config directory, so T3 Code keeps separate config directories isolated
96
+instead of trying to share part of the state.
97
98
## I Want To Use OpenRouter
99
@@ -102,7 +110,7 @@ Add or edit a Claude provider in T3 Code Settings:
110
```text
111
Display name: Claude OpenRouter
112
Binary path: claude
105
-Claude HOME path: ~/.claude_openrouter_home
113
+CLAUDE_CONFIG_DIR path: ~/.claude_openrouter_home
114
```
115
116
In that provider's Environment variables section, add:
@@ -173,40 +181,18 @@ Claude Code Router is useful when you want a local routing layer with more contr
181
OpenRouter setup.
182
183
T3 Code does not need a special Claude Code Router provider. Treat the router as a Claude
176
-environment.
177
-
178
-Use this when you want Claude Code Router to decide which upstream model or provider handles Claude
179
-requests.
180
-
181
-High-level flow:
182
-
183
-1. Start Claude Code Router.
184
-2. Add or configure a Claude provider in T3 Code.
185
-3. Put the router's required variables on that provider instance.
186
-
187
-Configure a Claude provider:
184
+environment: give a Claude provider its own `CLAUDE_CONFIG_DIR path`, and put whatever variables
185
+the router tells you to export into that provider's Environment variables section. Mark tokens
186
+and API keys as sensitive.
187
188
```text
189
Display name: Claude Router
190
Binary path: claude
192
-Claude HOME path: ~/.claude_router_home
193
-```
194
-
195
-Then copy the variables that `ccr activate` would export into the provider's Environment variables
196
-section. Mark tokens and API keys as sensitive.
197
-
198
-If you want the router-backed setup to stay separate from your normal Claude account, create and log
199
-in with a dedicated home first:
200
-
201
-```bash
202
-mkdir -p ~/.claude_router_home
203
-ccr start
204
-ccr activate
205
-HOME=~/.claude_router_home claude auth login
191
+CLAUDE_CONFIG_DIR path: ~/.claude_router_home
192
```
193
208
-Claude Code Router's setup can change over time. Use its upstream README for the current install and
209
-configuration steps: <https://github.com/musistudio/claude-code-router>.
194
+Follow the upstream project's README for the router's own install, startup, and configuration
195
+steps: <https://github.com/musistudio/claude-code-router>.
196
197
## I Want Different Claude Settings, Not A Different Account
198
@@ -218,7 +204,7 @@ Examples:
204
- "Claude Router"
205
- "Claude Experimental"
206
221
-If the preset needs different Claude files, give it a different `Claude HOME path`. If it needs
207
+If the preset needs different Claude files, give it a different `CLAUDE_CONFIG_DIR path`. If it needs
208
different API keys, base URLs, or router settings, use Environment variables.
209
210
Do not put environment variable assignments in `Launch arguments`.
docs/user/providers-codex.md
renamed
+2
-1
@@ -1,6 +1,7 @@
1
# Codex
2
3
-This guide is for people who want to use more than one Codex account in T3 Code.
3
+This guide is for people who want to use more than one Codex account in T3 Code. For Claude, see
4
+[Claude](./providers-claude.md). For first-time setup, see [Install T3 Code](./install.md).
5
6
Common reasons:
7
docs/user/remote-access.md
+15
-22
@@ -14,14 +14,15 @@ That gives you:
14
15
## Enabling Network Access
16
17
-There are two ways to expose your server for remote connections: from the desktop app or from the CLI.
17
+There are three ways to reach your server from another device: expose the desktop app's backend,
18
+run a headless server from the CLI, or have the desktop app launch T3 Code over SSH.
19
20
### Option 1: Desktop App
21
22
If you are already running the desktop app and want to make it reachable from other devices:
23
24
1. Open **Settings** → **Connections**.
24
-2. Under **Manage Local Backend**, toggle **Network access** on. This will restart the app and run the backend on all network interfaces.
25
+2. Under **This environment**, toggle **Network access** on. This will restart the app and run the backend on all network interfaces.
26
3. The settings panel will show the default reachable endpoint, with a `+N` control when more endpoints are available. Expand it to inspect alternatives such as loopback, LAN, private-network, or HTTPS endpoints.
27
4. Use **Create Link** to generate a pairing link you can share with another device.
28
@@ -48,10 +49,10 @@ Depending on your Tailscale setup, this may include:
49
- an HTTPS MagicDNS endpoint when Tailscale Serve is configured for this backend
50
51
The Tailscale HTTPS endpoint uses the clean MagicDNS URL, such as
51
-`https://machine.tailnet.ts.net/`, and is disabled until the app verifies that the URL reaches this
52
-backend. Use **Setup** on the Tailscale HTTPS row to opt in. The desktop app restarts the backend
53
-with the same server-side behavior as `t3 serve --tailscale-serve`, then the server asks Tailscale
54
-Serve to proxy HTTPS traffic to the local backend.
52
+`https://machine.tailnet.ts.net/`, and is off until you opt in. Turn on **Enable Tailscale HTTPS**
53
+on the **Tailscale HTTPS** row in **Settings** → **Connections**. The desktop app restarts the
54
+backend with the same server-side behavior as `t3 serve --tailscale-serve`, then the server asks
55
+Tailscale Serve to proxy HTTPS traffic to the local backend. Turn the same switch off to stop it.
56
57
The Tailscale support is an endpoint provider add-on. The core remote model still works without Tailscale: LAN HTTP endpoints, custom HTTPS endpoints, future tunnels, and SSH-launched environments all use the same saved environment and pairing flow.
58
@@ -96,10 +97,8 @@ By default this configures Tailscale Serve on HTTPS port 443 and advertises
97
npx t3 serve --tailscale-serve --tailscale-serve-port 8443
98
```
99
99
-> Note
100
-> The GUIs do not currently support adding projects on remote environments.
101
-> For now, use `t3 project ...` on the server machine instead.
102
-> Full GUI support for remote project management is coming soon.
100
+Once paired, add projects normally: open the Command Palette and choose **Add Project**, then pick
101
+the environment the project lives on. Every saved environment is offered, not only the local one.
102
103
### Option 3: Desktop-Managed SSH Launch
104
@@ -125,16 +124,10 @@ The remote host must have a compatible Node.js runtime. T3 Code uses the server
124
^22.16 || ^23.11 || >=24.10
125
```
126
128
-During SSH launch, T3 Code first checks whether `node` is already available on `PATH`. If it is missing, the launcher tries common non-interactive shell locations and version-manager shims/activation hooks:
129
-
130
-- `~/.local/bin`, `~/bin`, `/opt/homebrew/bin`, `/usr/local/bin`, `/usr/bin`, `/bin`
131
-- Volta via `~/.volta/bin`
132
-- asdf via `~/.asdf/shims`, `~/.asdf/bin`, or `~/.asdf/asdf.sh`
133
-- mise via `~/.local/share/mise/shims`, `~/.mise/shims`, or `mise activate sh`
134
-- fnm via `fnm env --use-on-cd --shell sh` or `fnm env --shell sh`
135
-- nodenv via `~/.nodenv/bin`, `~/.nodenv/shims`, or `nodenv init -`
136
-- nvm via `$NVM_DIR/nvm.sh`, then `nvm use default`, `nvm use node`, or `nvm use --lts`
137
-- installed nvm versions under `$NVM_DIR/versions/node/*/bin`
127
+During SSH launch, T3 Code first checks whether `node` is on `PATH`. If it is missing, the launcher
128
+looks in the usual install directories and tries to activate a version manager if it finds one
129
+(Volta, asdf, mise, fnm, nodenv, nvm). That covers most setups, but a version manager that only
130
+initializes from an interactive shell profile will not be picked up.
131
132
If launch fails with `node: command not found`, a port-scan failure, or a message that the remote Node version does not satisfy the required range, SSH into the host and check the same non-interactive shell path T3 Code uses:
133
@@ -148,7 +141,7 @@ If that does not print a compatible Node version, configure your version manager
141
nvm alias default 24
142
```
143
151
-With mise/asdf/fnm/nodenv, make sure the tool's shim directory is installed and points at a Node version satisfying the range above.
144
+With mise, asdf, fnm, or nodenv, make sure the tool's shim directory is installed and resolves to a Node version satisfying the range above without an interactive shell.
145
146
If reconnecting after an app update fails, retry the SSH launch once. The launcher now compares its generated runner script, stops stale launcher-managed remote servers, clears the SSH launch PID/port state, and starts a fresh remote server. You should not normally need to delete `~/.t3/ssh-launch` or kill `t3` processes manually.
147
@@ -160,7 +153,7 @@ be able to update and reconnect the server for you, or it may ask you to update
153
run a copied command on the server machine.
154
155
Finish active work before updating because the server restarts briefly. For step-by-step guidance,
163
-see [Keeping T3 Code in Sync](./server-updates.md).
156
+see [Keeping T3 Code in Sync](./updating.md).
157
158
On a Linux host, you can keep the server running after logout and manage it independently of the
159
connection method. See [Running T3 Code in the Background](./background-service.md).
docs/user/source-control.md
renamed
+25
-15
@@ -1,6 +1,6 @@
1
# Source Control Integrations
2
3
-T3 Code connects directly to your Git hosting provider so you can create pull requests, review code, and manage repositories without leaving your editor. Work stays in flow—no more jumping between browser tabs and terminal windows.
3
+T3 Code connects to your Git hosting provider so you can create pull requests, review code, and manage repositories without leaving the app.
4
5
## Supported Providers
6
@@ -24,16 +24,16 @@ T3 Code works with the platforms your team already uses:
24
**Publish local projects to the cloud**
25
26
- Have a local Git repository without a remote?
27
-- Use the **Publish Repository** action to create a new hosted repository (GitHub, GitLab, Bitbucket, or Azure DevOps), add it as your origin remote, and push—all in one flow
28
-- Perfect for turning a weekend prototype into a real project
27
+- Use the **Publish Repository** action to create a new hosted repository (GitHub, GitLab, Bitbucket, or Azure DevOps), add it as your origin remote, and push, in one flow
28
+- If the local repository has no commits yet, publishing creates the remote and wires it up but does not push. Make a commit, then push normally.
29
30
### Manage Code Reviews Without Context Switching
31
32
**Create pull requests while you work**
33
34
-- Push a branch and create a pull request from the Git panel
34
+- Push a branch and create a pull request from the Git actions controls in the toolbar
35
- T3 Code can suggest titles and descriptions based on your commits
36
-- Supports GitHub Pull Requests, GitLab Merge Requests, and Bitbucket Pull Requests
36
+- Supports GitHub Pull Requests, GitLab Merge Requests, Bitbucket Pull Requests, and Azure DevOps Pull Requests
37
38
**Stay on top of open reviews**
39
@@ -65,7 +65,7 @@ Run a quick **Rescan** after setting up a new machine or changing credentials.
65
```
66
3. Open **Settings → Source Control** in T3 Code and verify GitHub shows as authenticated
67
68
-That's it—you can now clone, publish, and create pull requests.
68
+You can now clone, publish, and create pull requests.
69
70
### For GitLab
71
@@ -81,15 +81,25 @@ That's it—you can now clone, publish, and create pull requests.
81
82
### For Bitbucket
83
84
-Bitbucket uses API tokens instead of a CLI tool:
84
+Bitbucket uses tokens instead of a CLI tool. Two options, both set as environment variables on the
85
+machine running T3 Code.
86
86
-1. Create an API token in your Atlassian account with read/write access to pull requests and repositories
87
-2. Add these environment variables to the environment running T3 Code:
88
- ```bash
89
- export T3CODE_BITBUCKET_EMAIL="you@example.com"
90
- export T3CODE_BITBUCKET_API_TOKEN="your-token"
91
- ```
92
-3. Restart T3 Code and verify the connection in **Source Control settings**
87
+Recommended, a Bitbucket access token:
88
+
89
+```bash
90
+export T3CODE_BITBUCKET_ACCESS_TOKEN="your-access-token"
91
+```
92
+
93
+Or an Atlassian account email plus API token, with read/write access to pull requests and
94
+repositories:
95
+
96
+```bash
97
+export T3CODE_BITBUCKET_EMAIL="you@example.com"
98
+export T3CODE_BITBUCKET_API_TOKEN="your-token"
99
+```
100
+
101
+If both are set, the access token wins. Restart T3 Code and verify the connection in **Source
102
+Control settings**.
103
104
### For Azure DevOps
105
@@ -124,4 +134,4 @@ Bitbucket uses API tokens instead of a CLI tool:
134
135
- [GitHub CLI](https://cli.github.com/)
136
- [GitLab CLI](https://gitlab.com/gitlab-org/cli)
127
-- [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/)
137
+- [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/)
docs/user/updating.md
renamed
+10
-2
@@ -36,12 +36,20 @@ After selecting **Update server**, the warning becomes a three-step progress rai
36
Connections, so navigating between them does not lose the update. A failed step remains visible
37
with its error and an option to retry.
38
39
-If the server uses the T3 Code background service, you can also update it directly on the host:
39
+**Copy update command** gives you `npx t3@<client-version>`, which relaunches the server directly
40
+at the matching version. Add whatever startup options you normally use.
41
+
42
+If the server instead runs as the T3 Code background service, update the service on the host and
43
+pin the same version:
44
45
```sh
42
-npx t3@latest service update
46
+npx t3@<client-version> service update
47
```
48
49
+`service update` installs the version of the CLI that invoked it, so `npx t3@latest service update`
50
+only resolves the skew when your client happens to be on the latest release. The exact version from
51
+the warning always works.
52
+
53
See [Running T3 Code in the Background](./background-service.md) for install, status, and removal
54
commands.
55
infra/relay/README.md
+7
-7
@@ -1,7 +1,7 @@
1
# T3 Connect Relay
2
3
-> [!WARNING]
4
-> T3 Connect is currently in private beta. Join the waitlist in the app under Settings > T3 Connect.
3
+> [!NOTE]
4
+> Sign in to T3 Connect from the app under Settings > Connections.
5
6
The relay is the hosted control plane for T3 Connect. It helps clients discover and connect to
7
remote environments, manages the cloud-side records needed for those connections, and delivers
@@ -9,7 +9,7 @@ optional mobile notifications and Live Activities.
9
10
The relay is intentionally not in the hot path for normal T3 Code traffic. After a client connects,
11
regular API and WebSocket traffic goes directly between that client and the selected environment.
12
-See the [T3 Connect architecture overview](../../docs/cloud/t3-code-connect-auth-flow.html) for the larger system
12
+See the [T3 Connect architecture overview](../../docs/internals/t3-code-connect-auth-flow.html) for the larger system
13
design.
14
15
## Responsibilities
@@ -25,7 +25,7 @@ The relay currently owns:
25
- Persisting relay state and exposing relay-specific traces for diagnostics.
26
27
The environment server and relay have separate credentials and trust boundaries. Read
28
-[Environment Authentication Profile](../../docs/environment-auth.md) before changing token,
28
+[Environment Authentication Profile](../../docs/internals/environment-auth.md) before changing token,
29
credential, or authorization behavior.
30
31
## Code Map
@@ -159,8 +159,8 @@ and hosted web builds.
159
160
See:
161
162
-- [T3 Connect Clerk Setup](../../docs/cloud/t3-connect-clerk.md) for Clerk keys, JWT templates, and waitlist
162
+- [T3 Connect Clerk Setup](../../docs/internals/t3-connect.md) for Clerk keys, JWT templates, and sign-up restrictions
163
setup.
164
-- [Relay Observability](../../docs/relay-observability.md) for deployment tracing and diagnostics.
165
-- [T3 Connect Architecture Overview](../../docs/cloud/t3-code-connect-auth-flow.html) for the full link,
164
+- [Relay Observability](../../docs/operations/relay-observability.md) for deployment tracing and diagnostics.
165
+- [T3 Connect Architecture Overview](../../docs/internals/t3-code-connect-auth-flow.html) for the full link,
166
connect, endpoint, and notification flows.