Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

development.md

151 lines5.5 KB

1# Development
2​
3## First checkout
4​
5Install `vp` using the [root README](../../README.md#install-vp). The checkout requires Node 24;
6Bun is optional. From the repository root:
7​
8```sh
9vp i
10vp run dev
11```
12​
13Open the one-time pairing URL printed by the dev runner. The bare origin does not authenticate
14a new browser.
15​
16## Choosing a dev process
17​
18Use `vp run dev` for server and web, or `vp run dev:desktop` for the Electron client.
19`dev:server` and `dev:web` start those processes separately.
20See the [mobile README](../../apps/mobile/README.md) for native builds and Metro.
21​
22Flags go directly after the task name, for example `vp run dev --home-dir /tmp/t3code-dev`.
23Add `--browser` to open a browser automatically.
24​
25### State and ports
26​
27Linked worktrees default to their own `.t3/userdata`, even when `T3CODE_HOME` is set.
28The main checkout defaults to `~/.t3/dev/userdata`. An explicit `--home-dir` wins in both cases.
29Never run a development server against the live `~/.t3/userdata`.
30See [test data](../../AGENTS.md#test-data) for copying a consistent database snapshot.
31​
32Read ports from the `[dev-runner]` output. Worktrees derive stable preferences from their paths,
33but occupied ports can shift them. `T3CODE_PORT_OFFSET` or `T3CODE_DEV_INSTANCE` can select a
34different preference when needed.
35​
36### Sharing and remote debugging
37​
38`vp run dev --share` publishes the web port over the machine's tailnet and prints a pairing URL
39for that origin. Give the tester the complete URL, including its token. The dev runner removes
40its mapping on exit.
41​
42Leave `VITE_HTTP_URL` and `VITE_WS_URL` unset. Vite proxies the backend through the browser's
43origin so the same build works over localhost and remote connections.
44​
45Shared runs enable bundled dev to avoid a network round trip for each import level.
46`T3CODE_BUNDLED_DEV=0` opts out when debugging bundler differences. Two reload traps matter
47when changing this setup:
48​
49- The web entry must dynamically import the app so React refresh initializes before application
50 chunks. Static imports can work on first load and fail after a route split.
51- Bundled dev rebuilds Tailwind through watched files. Its ordinary Vite hot-update hook expects
52 a server/module graph that Rolldown does not provide.
53​
54The workarounds live in the [web entry](../../apps/web/src/bootstrap.ts) and
55[Tailwind plugin](../../apps/web/vite/tailwind.ts).
56​
57## Checks
58​
59Run checks for the files and packages you changed:
60​
61```sh
62vp test run <files>
63vp lint <files>
64vp run --filter <package> typecheck
65```
66​
67Use `vp run lint:mobile` for native mobile changes. CI owns the full suite; see
68[ci.yml](../../.github/workflows/ci.yml) for its current jobs.
69The [manual Windows lane](../../.github/workflows/windows-tests.yml) is available for focused
70Windows investigation while that suite is not a required gate.
71​
72### Unused code
73​
74`vp run knip:check` checks unused files and dependencies across the repo, then
75unused exports and types in `packages/tailscale`. CI enforces both checks.
76Use `vp run knip --workspace apps/web` to audit one workspace, including exports,
77or `vp run knip:production --workspace apps/web` to find code kept alive only by tests.
78The full export audit still has findings and is not a repo-wide CI gate. Extend the
79export check's workspace selectors as more workspaces become clean. Review callers before
80deleting code; production mode can also report development scripts and test fixtures.
81Runtime-discovered entrypoints and dependency exceptions belong in [knip.jsonc](../../knip.jsonc).
82​
83## Desktop artifacts
84​
85Local artifact builds are unsigned by default and write to `release/`:
86​
87```sh
88vp run dist:desktop:dmg
89vp run dist:desktop:linux
90vp run dist:desktop:win
91```
92​
93DMGs default to the host architecture. Use `--arch` to choose another target and `--keep-stage`
94to retain packaging files for inspection. Run `vp run dist:desktop:artifact --help` for other
95options.
96​
97### Linux AppImage prerequisites
98​
99Build on Linux because the browser-secret helper links against the host's libsecret. Install
100Rust, C/C++ build tools, libsecret development headers, pkg-config, and ImageMagick.
101​
102Ubuntu and Debian:
103​
104```sh
105sudo apt-get update
106sudo apt-get install cargo rustc build-essential libsecret-1-dev pkg-config imagemagick
107```
108​
109Fedora:
110​
111```sh
112sudo dnf install rust cargo gcc gcc-c++ make libsecret-devel pkgconf-pkg-config ImageMagick
113```
114​
115Arch Linux:
116​
117```sh
118sudo pacman -S rust base-devel libsecret pkgconf imagemagick
119```
120​
121The C toolchain, pkg-config, and libsecret headers are also needed for Linux desktop development.
122​
123### macOS DMG prerequisites
124​
125Install the Xcode Command Line Tools with `xcode-select --install` and install Rust.
126For a cross-architecture or universal build, add the requested Rust targets:
127​
128```sh
129rustup target add aarch64-apple-darwin x86_64-apple-darwin
130```
131​
132### Windows installer prerequisites
133​
134Install Rust, Python 3, and Visual Studio Build Tools with **Desktop development with C++**.
135Include the Windows SDK and the MSVC build tools and Spectre-mitigated libraries for the target
136architecture. Add its Rust target:
137​
138```powershell
139rustup target add x86_64-pc-windows-msvc
140# For an ARM64 installer:
141rustup target add aarch64-pc-windows-msvc
142```
143​
144NSIS is downloaded by electron-builder. WSL support additionally needs a Linux node-pty prebuild;
145see the [release runbook](./release.md#windows-payload-topology-and-update-validation).
146​
147### Signing and passkeys
148​
149Add `--signed` after configuring the platform credentials in the
150[release runbook](./release.md). macOS passkeys need a signed, provisioned app; follow the
151[Connect setup](./connect-setup.md#desktop-passkeys) for local signing and renderer HMR.