Skip to content

Commit fdb8979

Browse files
authored
Merge branch 'main' into fix/remote-terminal-output-latency
2 parents 5fa7e81 + 0dec07d commit fdb8979

526 files changed

Lines changed: 33320 additions & 6088 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/release-desktop.yml‎

Lines changed: 528 additions & 0 deletions
Large diffs are not rendered by default.

‎.github/workflows/release.yml‎

Lines changed: 358 additions & 455 deletions
Large diffs are not rendered by default.

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ node_modules
55
*.log
66
*.tsbuildinfo
77
apps/*/dist
8+
apps/*/dist-exe
89
infra/*/dist
910
.astro
1011
packages/*/dist

‎.macroscope/check-run-agents/effect-service-conventions.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Effect Service Conventions
33
model: gpt-5-6-sol
44
effort: medium
5-
input: full_diff
5+
input: incremental
66
tools:
77
- browse_code
88
- modify_pr

‎.macroscope/check-run-agents/ui-consistency.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
title: UI Consistency
3-
model: gpt-5-6-terra
3+
model: gpt-5-6-sol
44
effort: medium
5-
input: full_diff
5+
input: incremental
66
tools:
77
- browse_code
88
- modify_pr

‎.pnpm-store/v11/index.db‎

-8 KB
Binary file not shown.

‎AGENTS.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ The most common defect in this repo is a change that works on the path you teste
7979
- `vp i` installs. Worktrees get this from the t3.json setup script; if module resolution looks broken, it probably did not run.
8080
- `vp run dev` starts server and web. In a worktree, state defaults to that worktree's gitignored `.t3`, which deliberately outranks an ambient `T3CODE_HOME` so you cannot land on shared state by accident. An explicit `--home-dir` still wins.
8181
- Ports derive from the worktree path and are stable across restarts, but read the real ones from the `[dev-runner]` line since occupied ports shift.
82-
- Sharing over the tailnet is three steps: run `vp run dev --share` in the background, wait for the `pairingUrl:` line in its output, paste that full URL (token included) in your reply. Do not wire up `tailscale serve` by hand for this, and do not open the URL yourself.
83-
- The web app requires pairing. Hand over the pairing URL, not the bare origin. A URL without its token is useless to whoever you gave it to. If the token got consumed, mint a fresh one with `node apps/server/src/bin.ts pair` — note it carries standard scopes, while the startup URL carries admin scopes (needed for Settings → Connections management).
82+
- Sharing over the tailnet is three steps: run `vp run dev --share` in the background, wait for the `pairingUrl:` line in its output, then give that full URL to an unpaired browser. Do not wire up `tailscale serve` by hand, open the URL yourself, or consume the user's pairing link. A browser with the reusable dev cookie can use the bare origin. If a normal one-time token was consumed, mint a fresh one with `node apps/server/src/bin.ts pair`. It carries standard scopes, while the startup URL carries admin scopes needed for Connections settings.
83+
- To reuse web dev auth across worktrees, configure one fixed `T3CODE_DEV_AUTH_TOKEN` in the main checkout's gitignored `.env`. The `t3.json` setup links that file into worktrees. Never commit or publish the token or a startup URL. See [Reusable dev credential](docs/operations/development.md#reusable-dev-credential).
8484
- Stop what you started, by the PID you tracked. See rule 1.
8585

8686
## Test data

‎apps/desktop/src/app/DesktopApp.ts‎

Lines changed: 55 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as Cause from "effect/Cause";
2+
import * as Duration from "effect/Duration";
23
import * as Effect from "effect/Effect";
34
import * as Option from "effect/Option";
45
import * as Ref from "effect/Ref";
@@ -142,19 +143,58 @@ const handleFatalStartupError = Effect.fn("desktop.startup.handleFatalStartupErr
142143
const fatalStartupCause = <E>(stage: string, cause: Cause.Cause<E>) =>
143144
handleFatalStartupError(stage, Cause.pretty(cause)).pipe(Effect.andThen(Effect.failCause(cause)));
144145

146+
export const stopAllPoolInstances = Effect.fn("desktop.app.stopAllPoolInstances")(
147+
function* (): Effect.fn.Return<void, never, DesktopBackendPool.DesktopBackendPool> {
148+
// Stop every backend in the pool with a timeout to guarantee the quit
149+
// path makes progress even if a backend hangs during teardown.
150+
const pool = yield* DesktopBackendPool.DesktopBackendPool;
151+
const instances = yield* pool.list;
152+
yield* Effect.forEach(
153+
instances,
154+
(instance) => instance.stop({ timeout: Duration.seconds(5) }),
155+
{ concurrency: "unbounded" },
156+
);
157+
},
158+
);
159+
145160
const bootstrap = Effect.gen(function* () {
146-
const pool = yield* DesktopBackendPool.DesktopBackendPool;
147-
const primaryBackend = yield* pool.primary;
148161
const state = yield* DesktopState.DesktopState;
149162
const environment = yield* DesktopEnvironment.DesktopEnvironment;
150163
const desktopSettings = yield* DesktopAppSettings.DesktopAppSettings;
151-
const serverExposure = yield* DesktopServerExposure.DesktopServerExposure;
152-
const wslBackend = yield* DesktopWslBackend.DesktopWslBackend;
153164
const desktopWindow = yield* DesktopWindow.DesktopWindow;
154165
const snapShot = yield* DesktopSnapShot.DesktopSnapShot;
155166
const appActivation = yield* DesktopAppActivation.DesktopAppActivation;
156167
yield* logBootstrapInfo("bootstrap start");
157168

169+
const settings = yield* desktopSettings.get;
170+
// The renderer is served from the bundled client (or Vite in development)
171+
// rather than through the local backend, so the window can open without one.
172+
const electronProtocol = yield* ElectronProtocol.ElectronProtocol;
173+
yield* electronProtocol.registerDesktopProtocol({
174+
scheme: ElectronProtocol.getDesktopScheme(environment.isDevelopment),
175+
...(environment.isDevelopment
176+
? { targetOrigin: Option.getOrThrow(environment.devServerUrl) }
177+
: { assetDirectory: environment.clientAssetsDir }),
178+
clerkFrontendApiHostname: DesktopClerk.desktopClerkFrontendApiHostname,
179+
});
180+
yield* installDesktopIpcHandlers();
181+
yield* logBootstrapInfo("bootstrap ipc handlers registered");
182+
183+
yield* snapShot.initialize;
184+
185+
if (!settings.localEnvironmentEnabled) {
186+
yield* logBootstrapInfo("bootstrap skipping local environment (disabled in settings)");
187+
if (!(yield* Ref.get(state.quitting))) {
188+
yield* desktopWindow.createMainIfBackendReady;
189+
}
190+
return;
191+
}
192+
193+
const pool = yield* DesktopBackendPool.DesktopBackendPool;
194+
const primaryBackend = yield* pool.primary;
195+
const serverExposure = yield* DesktopServerExposure.DesktopServerExposure;
196+
const wslBackend = yield* DesktopWslBackend.DesktopWslBackend;
197+
158198
if (environment.isDevelopment && Option.isNone(environment.configuredBackendPort)) {
159199
return yield* new DesktopDevelopmentBackendPortRequiredError();
160200
}
@@ -171,24 +211,13 @@ const bootstrap = Effect.gen(function* () {
171211
},
172212
);
173213

174-
const settings = yield* desktopSettings.get;
175214
if (settings.serverExposureMode !== environment.defaultDesktopSettings.serverExposureMode) {
176215
yield* logBootstrapInfo("bootstrap restoring persisted server exposure mode", {
177216
mode: settings.serverExposureMode,
178217
});
179218
}
180219
const serverExposureState = yield* serverExposure.configureFromSettings({ port: backendPort });
181220
const backendConfig = yield* serverExposure.backendConfig;
182-
const electronProtocol = yield* ElectronProtocol.ElectronProtocol;
183-
const rendererTarget = environment.isDevelopment
184-
? Option.getOrThrow(environment.devServerUrl)
185-
: backendConfig.httpBaseUrl;
186-
yield* electronProtocol.registerDesktopProtocol({
187-
scheme: ElectronProtocol.getDesktopScheme(environment.isDevelopment),
188-
targetOrigin: rendererTarget,
189-
backendOrigin: backendConfig.httpBaseUrl,
190-
clerkFrontendApiHostname: DesktopClerk.desktopClerkFrontendApiHostname,
191-
});
192221
yield* logBootstrapInfo("bootstrap resolved backend endpoint", {
193222
baseUrl: backendConfig.httpBaseUrl.href,
194223
});
@@ -204,16 +233,13 @@ const bootstrap = Effect.gen(function* () {
204233
"bootstrap fell back to local-only because no advertised network host was available",
205234
);
206235
}
207-
yield* snapShot.initialize;
208-
209-
yield* installDesktopIpcHandlers();
210-
yield* logBootstrapInfo("bootstrap ipc handlers registered");
211236

212237
if (!(yield* Ref.get(state.quitting))) {
213-
// In wsl-only mode the renderer is served by the WSL backend, which can be
214-
// slow to cold-boot — show a "Connecting to WSL" splash immediately so the
215-
// app feels responsive instead of presenting no window until WSL is ready.
216-
// (Dual mode opens fast off the Windows primary, so no splash there.)
238+
// The main window waits for the primary backend. In wsl-only mode that is
239+
// the WSL backend, which can be slow to cold-boot — show a "Connecting to
240+
// WSL" splash immediately so the app feels responsive instead of presenting
241+
// no window until WSL is ready. (Dual mode opens fast off the Windows
242+
// primary, so no splash there.)
217243
if (settings.wslOnly === true && settings.wslBackendEnabled === true) {
218244
yield* desktopWindow.showConnectingSplash;
219245
}
@@ -313,18 +339,12 @@ const scopedProgram = Effect.scoped(
313339
const shutdown = yield* DesktopShutdown.DesktopShutdown;
314340

315341
yield* Effect.addFinalizer(() =>
316-
Effect.gen(function* () {
317-
const pool = yield* DesktopBackendPool.DesktopBackendPool;
318-
// Stop every backend in the pool, not just the primary. The
319-
// electronApp.quit() path can race ahead of the layer-scope
320-
// cascade, so leaving the WSL instance for its parent scope
321-
// finalizer means it gets hard-killed by the OS instead of
322-
// receiving SIGTERM + grace. Stops run concurrently.
323-
const instances = yield* pool.list;
324-
yield* Effect.forEach(instances, (instance) => instance.stop(), {
325-
concurrency: "unbounded",
326-
});
327-
}).pipe(Effect.ensuring(shutdown.markComplete)),
342+
// Stop every backend in the pool, not just the primary. The
343+
// electronApp.quit() path can race ahead of the layer-scope
344+
// cascade, so leaving the WSL instance for its parent scope
345+
// finalizer means it gets hard-killed by the OS instead of
346+
// receiving SIGTERM + grace.
347+
stopAllPoolInstances().pipe(Effect.ensuring(shutdown.markComplete)),
328348
);
329349

330350
yield* startup;

‎apps/desktop/src/app/DesktopConnectionCatalogStore.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ const migrateSavedEnvironmentRecords = Effect.fn(
372372
profiles,
373373
credentials,
374374
remoteDpopTokens: [],
375+
disabledEnvironmentIds: [],
375376
};
376377
});
377378

‎apps/desktop/src/app/DesktopEnvironment.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ describe("DesktopEnvironment", () => {
120120
environment.backendEntryPath,
121121
"/install/resources/server.asar/apps/server/dist/bin.mjs",
122122
);
123+
assert.equal(
124+
environment.clientAssetsDir,
125+
"/install/resources/server.asar/apps/server/dist/client",
126+
);
123127
}),
124128
);
125129

0 commit comments

Comments
 (0)