Open History to see the last commit
1# Development
2
3## First checkout
4
5Install [Vite+](https://viteplus.dev/guide/) (`vp` provides the pinned Node version from `package.json`):
6
7```sh
8curl -fsSL https://vite.plus | bash
9# Windows PowerShell: irm https://vite.plus/ps1 | iex
10```
11
12On Windows, clone with long paths enabled so `.repos/` checks out cleanly:
13
14```powershell
15git clone -c core.longpaths=true https://github.com/pingdotgg/t3code.git
16```
17
18From the repository root:
19
20```sh
21vp i
22vp run dev
23```
24
25Open the pairing URL printed by the dev runner (the bare origin does not authenticate a new browser). Prefer a container? See [Dev container](./01_devcontainer.md).
26
27## Forge mirror (optional)
28
29GitHub is the source of truth; [source.tanstack.com/@pingdotgg/t3code](https://source.tanstack.com/@pingdotgg/t3code) is a two-way mirror for parallel agent work:
30
31```sh
32git remote set-url origin https://source.tanstack.com/@pingdotgg/t3code.git
33git remote add github https://github.com/pingdotgg/t3code.git
34src auth login --web && src auth setup-git
35```
36
37With `origin` on the mirror, use `src` instead of `gh`. PRs into `main` still merge on GitHub, and numbers can differ between forges—use the GitHub number in text that reaches GitHub.
38
39## Running dev servers
40
41- `vp run dev` (server + web), `vp run dev:desktop` (Electron), `vp run dev:server`, `vp run dev:web`. See [apps/mobile/README.md](../../apps/mobile/README.md) for mobile.
42- Pass flags directly after the task name (e.g. `vp run dev --home-dir /tmp/t3code-dev`, `--browser`).
43- **State and ports:** Linked worktrees default to `<worktree>/.t3/userdata` (outranking `T3CODE_HOME`) and seed on first start from a read-only snapshot of `~/.t3/userdata/statev2.sqlite` when it is at most 500 MiB (`--no-seed` or `T3CODE_DEV_SEED=0` skips; `vp run migrate-dev-db` refreshes manually). Plain clones and the main checkout default to `~/.t3/dev`. Never point a dev server at `~/.t3/userdata`. Read actual ports from `[dev-runner]` output (`T3CODE_PORT_OFFSET` / `T3CODE_DEV_INSTANCE` override).
44- **Resource monitor:** First start builds `native/resource-monitor` via Cargo when missing; without Rust, dev starts without process telemetry.
45- **Sharing:** `vp run dev --share` exposes the web port over Tailscale and prints a pairing URL. Add `--built` to serve `apps/web/dist` via `vp build --watch` (no HMR, faster over slow links). Never set `VITE_HTTP_URL` or `VITE_WS_URL` in dev—Vite proxies `/api` and `/ws` single-origin.
46- **Startup profiling:** `vp run profile:startup` captures the first 20 s of Node processes under `.t3/startup-profiles/<timestamp>`.
47
48### Replay provider
49
50`vp run dev` registers `Replay (dev)` ([dev-replay-agent.ts](../../apps/server/scripts/dev-replay-agent.ts)), a local ACP agent that streams recorded transcripts without calling a paid model. Add scenarios under `SCENARIOS` pointing at a generic ACP fixture (`registry_transcript.ndjson`) or a file in `apps/server/scripts/dev-replay`.
51
52### Reusable dev credential
53
54Only use this on a hostname where you trust every service (browsers share cookies across ports on the same hostname). Generate one secret once and put it in the main checkout's gitignored `.env` (which `t3.json` links into worktrees):
55
56```sh
57openssl rand -hex 32
58# Add to .env: T3CODE_DEV_AUTH_TOKEN=<value>
59```
60
61Restart `vp run dev --share` and open its printed pairing URL once per browser profile. Never commit or publish the token or startup URLs. Desktop and non-dev servers ignore it; see [environment auth](../internals/04_environment-auth.md#reusable-dev-credential).
62
63## Checks
64
65- `vp run check:changed` — CI's fast checks for your branch (format, lint, knip, affected typechecks, nearby tests, and React Compiler coverage).
66- Focused iteration: `vp test run <files>`, `vp lint <files>`, `vp run --filter <pkg> typecheck`, `vp run knip:check`, `vp run lint:mobile`.
67- `apps/web` uses real Chromium (`*.browser.test.{ts,tsx}`) for DOM/React tests (no jsdom) and Node for `*.test.ts`.
68- Typechecking uses `effect-tsgo tsrs --noEmit` (`@effect/tsgo`), not `typescript` (except `apps/marketing` for Astro). On Windows, open the workspace through WSL for VS Code's `.vscode/tsdk/tsgo`.
69
70## Desktop artifacts
71
72Unsigned local builds write to `release/`:
73
74```sh
75vp run dist:desktop:dmg
76vp run dist:desktop:linux
77vp run dist:desktop:win
78# Linux ARM64: vp run dist:desktop:artifact --platform linux --target AppImage --arch arm64
79```
80
81Run `vp run dist:desktop:artifact --help` for `--arch`, `--signed`, and `--keep-stage`.
82
83### Linux AppImage prerequisites
84
85Build on Linux (the browser-secret helper links against `libsecret`). Install Rust stable (`rustup`), C/C++ build tools, `libsecret` dev headers, `pkg-config`, ImageMagick, and Electron runtime libs (`gtk3`, `nss`, `alsa`, `gbm`):
86
87```sh
88# Ubuntu 24.04 / Debian 13 (on 22.04/Debian 12 use libgtk-3-0 and libasound2)
89sudo apt-get install build-essential libsecret-1-dev pkg-config imagemagick libgtk-3-0t64 libnss3 libasound2t64 libgbm1
90
91# Fedora
92sudo dnf install gcc gcc-c++ make libsecret-devel pkgconf-pkg-config ImageMagick gtk3 nss alsa-lib mesa-libgbm
93
94# Arch
95sudo pacman -S base-devel libsecret pkgconf imagemagick gtk3 nss alsa-lib mesa
96```
97
98### macOS DMG prerequisites
99
100Install Xcode Command Line Tools (`xcode-select --install`) and Rust. For cross-arch/universal builds:
101
102```sh
103rustup target add aarch64-apple-darwin x86_64-apple-darwin
104```
105
106### Windows installer prerequisites
107
108Install Rust, Python 3, and Visual Studio Build Tools (**Desktop development with C++**, Windows SDK, MSVC build tools, Spectre-mitigated libraries), then add the Rust target:
109
110```powershell
111rustup target add x86_64-pc-windows-msvc # or aarch64-pc-windows-msvc
112```
113
114WSL support also requires passing the Linux CLI archive via `--wsl-runtime`; see [release runbook](./03_release.md#windows-payload-topology-and-update-validation). For signing and macOS passkeys, see [release](./03_release.md) and [Connect setup](./02_connect-setup.md#desktop-passkeys).