Skip to content

Commit e07a291

Browse files
committed
Merge github/main into issue-watch/26446
2 parents cf84f60 + a7f6c68 commit e07a291

1,286 files changed

Lines changed: 63427 additions & 13188 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/ci.yml‎

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,41 @@ jobs:
192192
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
193193
run: node apps/desktop/scripts/verify-preload-bundle.mjs
194194

195+
# Browser tests run source modules; this boots the production chunk graph. The
196+
# desktop build above already produced apps/web/dist, and the client waits about
197+
# 15s for a session that never comes, so this runs here instead of in Test Web,
198+
# which gates the whole run. Chromium comes from the cache Test Web shares.
199+
- name: Resolve Playwright version
200+
id: playwright_version
201+
if: ${{ !cancelled() && steps.build.outcome == 'success' && needs.changes.outputs.test_web != 'false' }}
202+
run: echo "version=$(node -p "require('./apps/web/node_modules/playwright/package.json').version")" >> "$GITHUB_OUTPUT"
203+
204+
- name: Cache Chromium
205+
id: chromium_cache
206+
if: ${{ !cancelled() && steps.build.outcome == 'success' && needs.changes.outputs.test_web != 'false' }}
207+
uses: actions/cache@v6
208+
with:
209+
path: ~/.cache/ms-playwright
210+
key: playwright-chromium-shell-${{ runner.os }}-${{ runner.arch }}-${{ steps.playwright_version.outputs.version }}
211+
212+
- name: Install Chromium for the built web client boot check
213+
if: ${{ !cancelled() && steps.build.outcome == 'success' && needs.changes.outputs.test_web != 'false' && steps.chromium_cache.outputs.cache-hit != 'true' }}
214+
run: node apps/web/node_modules/playwright/cli.js install --only-shell chromium
215+
216+
- name: Install missing Chromium system dependencies
217+
if: ${{ !cancelled() && steps.build.outcome == 'success' && needs.changes.outputs.test_web != 'false' }}
218+
run: |
219+
browser=$(find "$HOME/.cache/ms-playwright" -name chrome-headless-shell -type f -print -quit)
220+
test -n "$browser"
221+
if ldd "$browser" | grep '=> not found'; then
222+
node apps/web/node_modules/playwright/cli.js install-deps chromium
223+
fi
224+
225+
- name: Boot the built web client
226+
if: ${{ !cancelled() && steps.build.outcome == 'success' && needs.changes.outputs.test_web != 'false' }}
227+
timeout-minutes: 3
228+
run: node apps/web/scripts/verify-built-boot.ts
229+
195230
- name: Typecheck
196231
if: ${{ !cancelled() && steps.typecheck.outcome == 'success' }}
197232
timeout-minutes: 5
@@ -340,12 +375,6 @@ jobs:
340375
- name: Test
341376
run: vp run --filter @t3tools/web test
342377

343-
# Browser tests run source modules; this boots the production chunk graph.
344-
- name: Boot the built web client
345-
run: |
346-
vp run --filter @t3tools/web build
347-
node apps/web/scripts/verify-built-boot.ts
348-
349378
# apps/server sets `fileParallelism: false`, so its test files run strictly
350379
# one at a time. Sharding spreads them over separate runners instead of
351380
# separate workers, so no two server test files ever share a machine and the

‎.macroscope/ignore.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,3 +279,7 @@ native/libghostty-vt/include/**
279279
# it needs. Regenerated by apps/mobile/scripts/generate-highlights.mts; review
280280
# that script and cpp/t3_highlights.c instead.
281281
apps/mobile/modules/t3-highlights/Vendor/**
282+
283+
# Nitro bindings for T3Highlights. Regenerated by `vp run generate:nitro` in
284+
# apps/mobile from modules/t3-highlights/src/T3Highlights.nitro.ts.
285+
apps/mobile/modules/t3-highlights/nitrogen/generated/**

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as Cause from "effect/Cause";
2-
import * as Duration from "effect/Duration";
2+
import * as Config from "effect/Config";
33
import * as Effect from "effect/Effect";
44
import * as Option from "effect/Option";
55
import * as Ref from "effect/Ref";
@@ -18,6 +18,7 @@ import * as DesktopClerk from "./DesktopClerk.ts";
1818
import * as DesktopApplicationMenu from "../window/DesktopApplicationMenu.ts";
1919
import * as DesktopWindow from "../window/DesktopWindow.ts";
2020
import * as PreviewPasskeys from "../preview/Passkeys.ts";
21+
import * as DesktopBackendManager from "../backend/DesktopBackendManager.ts";
2122
import * as DesktopBackendPool from "../backend/DesktopBackendPool.ts";
2223
import * as DesktopEnvironment from "./DesktopEnvironment.ts";
2324
import * as DesktopLegacyLocalStorage from "./DesktopLegacyLocalStorage.ts";
@@ -42,6 +43,11 @@ const DEFAULT_DESKTOP_BACKEND_PORT = 3773;
4243
const MAX_TCP_PORT = 65_535;
4344
const DESKTOP_BACKEND_PORT_PROBE_HOSTS = ["127.0.0.1", "0.0.0.0", "::"] as const;
4445

46+
const LinuxDesktopSessionConfig = Config.all({
47+
current: Config.String("XDG_CURRENT_DESKTOP").pipe(Config.option),
48+
session: Config.String("XDG_SESSION_DESKTOP").pipe(Config.option),
49+
});
50+
4551
const makeDesktopRunId = SecureRandom.SecureRandom.pipe(
4652
Effect.flatMap((random) => random.uuidV4()),
4753
Effect.map((value) => value.replaceAll("-", "").slice(0, 12)),
@@ -154,7 +160,7 @@ const stopAllPoolInstances = Effect.fn("desktop.app.stopAllPoolInstances")(
154160
const instances = yield* pool.list;
155161
yield* Effect.forEach(
156162
instances,
157-
(instance) => instance.stop({ timeout: Duration.seconds(5) }),
163+
(instance) => instance.stop({ timeout: DesktopBackendManager.BACKEND_QUIT_STOP_TIMEOUT }),
158164
{ concurrency: "unbounded" },
159165
);
160166
},
@@ -307,12 +313,13 @@ const startup = Effect.gen(function* () {
307313
yield* desktopSettings.load;
308314

309315
if (linuxElectronOptions !== null) {
316+
const xdgDesktop = yield* LinuxDesktopSessionConfig;
310317
yield* logStartupInfo("linux password store configured", {
311318
passwordStore: hasCommandLinePasswordStore
312319
? "command-line"
313320
: (linuxElectronOptions.passwordStore ?? "electron-default"),
314-
xdgCurrentDesktop: process.env.XDG_CURRENT_DESKTOP ?? null,
315-
xdgSessionDesktop: process.env.XDG_SESSION_DESKTOP ?? null,
321+
xdgCurrentDesktop: Option.getOrNull(xdgDesktop.current),
322+
xdgSessionDesktop: Option.getOrNull(xdgDesktop.session),
316323
});
317324
}
318325

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

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as NodeServices from "@effect/platform-node/NodeServices";
2-
import { afterEach, beforeEach, expect, it } from "@effect/vitest";
2+
import { expect, it } from "@effect/vitest";
33
import * as HostProcess from "@t3tools/shared/HostProcess";
44
import * as Effect from "effect/Effect";
55
import * as FileSystem from "effect/FileSystem";
@@ -29,7 +29,13 @@ const environmentFor = (
2929
} as unknown as DesktopEnvironment.DesktopEnvironment["Service"]);
3030

3131
const commandIn = (
32-
input: { home: string; baseDir?: string; platform?: NodeJS.Platform; isPackaged?: boolean },
32+
input: {
33+
home: string;
34+
baseDir?: string;
35+
platform?: NodeJS.Platform;
36+
isPackaged?: boolean;
37+
env?: NodeJS.ProcessEnv;
38+
},
3339
spawner?: ChildProcessSpawner.ChildProcessSpawner["Service"],
3440
) =>
3541
Effect.gen(function* () {
@@ -42,6 +48,7 @@ const commandIn = (
4248
DesktopEnvironment.DesktopEnvironment,
4349
environmentFor(path, { ...input, baseDir }),
4450
),
51+
Effect.provideService(HostProcess.Environment, input.env ?? { PATH: "" }),
4552
);
4653
return yield* spawner
4754
? make.pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner))
@@ -84,14 +91,6 @@ const fakePowerShell = (initial: string) => {
8491
return { registry, spawner };
8592
};
8693

87-
const machinePath = process.env.PATH;
88-
beforeEach(() => {
89-
process.env.PATH = "";
90-
});
91-
afterEach(() => {
92-
process.env.PATH = machinePath;
93-
});
94-
9594
it.layer(NodeServices.layer)("DesktopCliCommand", (it) => {
9695
it.effect("links the launcher onto PATH and removes only that link", () =>
9796
Effect.gen(function* () {
@@ -124,7 +123,8 @@ it.layer(NodeServices.layer)("DesktopCliCommand", (it) => {
124123
const fs = yield* FileSystem.FileSystem;
125124
const path = yield* Path.Path;
126125
const home = yield* fs.makeTempDirectoryScoped();
127-
const command = yield* commandIn({ home });
126+
const env: NodeJS.ProcessEnv = { PATH: "" };
127+
const command = yield* commandIn({ home, env });
128128
const theirs = path.join(home, ".local", "bin", "t3");
129129
yield* fs.makeDirectory(path.dirname(theirs), { recursive: true });
130130
yield* fs.writeFileString(theirs, "npm's t3\n");
@@ -139,7 +139,7 @@ it.layer(NodeServices.layer)("DesktopCliCommand", (it) => {
139139

140140
const launcher = path.join(home, ".t3", "bin", "t3");
141141
yield* fs.writeFileString(launcher, "npm's t3\n");
142-
process.env.PATH = path.dirname(launcher);
142+
env.PATH = path.dirname(launcher);
143143
expect(yield* command.state).toMatchObject({ onPath: false, shadowedBy: launcher });
144144
expect((yield* Effect.flip(command.install)).message).toContain("Could not set up");
145145
yield* command.uninstall;
@@ -173,9 +173,9 @@ it.layer(NodeServices.layer)("DesktopCliCommand", (it) => {
173173
const shadow = path.join(home, "shadow");
174174
yield* fs.makeDirectory(shadow);
175175
yield* fs.writeFileString(path.join(shadow, "t3"), "#!/bin/sh\n", { mode: 0o755 });
176-
process.env.PATH = [shadow, path.join(home, ".local", "bin")].join(":");
176+
const env = { PATH: [shadow, path.join(home, ".local", "bin")].join(":") };
177177

178-
const command = yield* commandIn({ home });
178+
const command = yield* commandIn({ home, env });
179179
const theirs = path.join(shadow, "t3");
180180
expect((yield* command.state).shadowedBy).toBe(theirs);
181181
const error = yield* Effect.flip(command.install);
@@ -209,9 +209,9 @@ it.layer(NodeServices.layer)("DesktopCliCommand", (it) => {
209209
yield* fs.chmod(path.join(plain, "t3"), process.getuid?.() === 0 ? 0o600 : 0o601);
210210
yield* fs.makeDirectory(shadow);
211211
yield* fs.writeFileString(path.join(shadow, "t3"), "#!/bin/sh\n", { mode: 0o755 });
212-
process.env.PATH = [folder, plain, shadow, path.join(home, ".local", "bin")].join(":");
212+
const env = { PATH: [folder, plain, shadow, path.join(home, ".local", "bin")].join(":") };
213213

214-
const command = yield* commandIn({ home });
214+
const command = yield* commandIn({ home, env });
215215
expect((yield* command.state).shadowedBy).toBe(path.join(shadow, "t3"));
216216

217217
const error = yield* Effect.flip(command.install);
@@ -231,9 +231,9 @@ it.layer(NodeServices.layer)("DesktopCliCommand", (it) => {
231231
const path = yield* Path.Path;
232232
const home = yield* fs.makeTempDirectoryScoped();
233233
const launcher = path.join(home, ".t3", "bin", "t3");
234-
process.env.PATH = [path.dirname(launcher), path.join(home, ".local", "bin")].join(":");
234+
const env = { PATH: [path.dirname(launcher), path.join(home, ".local", "bin")].join(":") };
235235

236-
const command = yield* commandIn({ home });
236+
const command = yield* commandIn({ home, env });
237237
const installed = yield* command.install;
238238

239239
expect(yield* fs.exists(launcher)).toBe(true);

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import * as NodeFSP from "node:fs/promises";
33

44
import type { DesktopCliCommandState } from "@t3tools/contracts";
5+
import * as HostProcess from "@t3tools/shared/HostProcess";
56
import * as Context from "effect/Context";
67
import * as Effect from "effect/Effect";
78
import * as FileSystem from "effect/FileSystem";
@@ -61,11 +62,13 @@ export class DesktopCliCommand extends Context.Service<
6162
}
6263
>()("@t3tools/desktop/app/DesktopCliCommand") {}
6364

64-
/** @public */
6565
export const make = Effect.gen(function* () {
6666
const environment = yield* DesktopEnvironment.DesktopEnvironment;
6767
const fs = yield* FileSystem.FileSystem;
6868
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
69+
// Read the live env: shell discovery patches PATH after startup, and Windows variable
70+
// names are case-insensitive only on process.env, not on Config's copy of it.
71+
const env = yield* HostProcess.Environment;
6972
const path = environment.path;
7073
const windows = environment.platform === "win32";
7174
const launcher = DesktopCliShim.launcherPath(environment);
@@ -105,15 +108,15 @@ export const make = Effect.gen(function* () {
105108
Effect.orElseSucceed(() => false),
106109
);
107110

108-
const powershell = (env: Record<string, string>) =>
111+
const powershell = (overrides: Record<string, string>) =>
109112
Effect.scoped(
110113
Effect.gen(function* () {
111-
const root = process.env.SystemRoot ?? process.env.WINDIR;
114+
const root = env.SystemRoot ?? env.WINDIR;
112115
const handle = yield* spawner.spawn(
113116
ChildProcess.make(
114117
root ? `${root}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe` : "powershell.exe",
115118
["-NoLogo", "-NoProfile", "-NonInteractive", "-Command", WINDOWS_USER_PATH_SCRIPT],
116-
{ stdin: "ignore", stderr: "ignore", env, extendEnv: true },
119+
{ stdin: "ignore", stderr: "ignore", env: overrides, extendEnv: true },
117120
),
118121
);
119122
const [stdout, exitCode] = yield* Effect.all(
@@ -137,14 +140,17 @@ export const make = Effect.gen(function* () {
137140
const isExecutableFile = Effect.fn("DesktopCliCommand.isExecutableFile")(
138141
function* (target: string) {
139142
if ((yield* fs.stat(target)).type !== "File") return false;
140-
yield* Effect.tryPromise(() => NodeFSP.access(target, NodeFSP.constants.X_OK));
143+
yield* Effect.tryPromise({
144+
try: () => NodeFSP.access(target, NodeFSP.constants.X_OK),
145+
catch: () => fail(`${target} is not executable.`),
146+
});
141147
return true;
142148
},
143149
Effect.orElseSucceed(() => false),
144150
);
145151

146152
const firstOnPath = Effect.gen(function* () {
147-
for (const directory of pathEntries(process.env.PATH, ":")) {
153+
for (const directory of pathEntries(env.PATH, ":")) {
148154
const candidate = path.join(directory, "t3");
149155
if (yield* isExecutableFile(candidate)) return Option.some(candidate);
150156
}
@@ -239,7 +245,7 @@ export const make = Effect.gen(function* () {
239245
`Another t3 at ${shadowedBy.value} runs first in a new terminal. Remove it, or run the launcher directly at ${launcher}.`,
240246
);
241247
}
242-
const onPath = pathEntries(process.env.PATH, ":");
248+
const onPath = pathEntries(env.PATH, ":");
243249
const candidates = unixCandidates(environment.homeDirectory, environment.platform);
244250
for (const directory of [
245251
...candidates.filter((candidate) => onPath.includes(candidate)),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const trimNonEmptyOption = (value: string): Option.Option<string> => {
88
return trimmed.length > 0 ? Option.some(trimmed) : Option.none();
99
};
1010

11-
const trimmedString = (name: string) =>
11+
export const trimmedString = (name: string) =>
1212
Config.String(name).pipe(Config.option, Config.map(Option.flatMap(trimNonEmptyOption)));
1313

1414
const optionalBoolean = (name: string) =>

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ vi.mock("node:child_process", () => ({
5757
execFileSync: execFileSyncMock,
5858
}));
5959

60+
import * as DesktopConfig from "./DesktopConfig.ts";
6061
import * as DesktopPreReadyPlatform from "./DesktopPreReadyPlatform.ts";
6162

6263
describe("DesktopPreReadyPlatform", () => {
@@ -124,8 +125,6 @@ describe("DesktopPreReadyPlatform", () => {
124125
{ previousEntry: 'Exec="/Applications/deleted-previous.AppImage" %U', label: "stale" },
125126
])("prepares a $label Linux desktop entry before startup yields", ({ previousEntry }) => {
126127
vi.stubEnv("VITE_DEV_SERVER_URL", "");
127-
vi.stubEnv("XDG_DATA_HOME", "/xdg");
128-
vi.stubEnv("APPIMAGE", "/Applications/current.AppImage");
129128
getSwitchValueMock.mockReturnValue("");
130129
let desktopName = "t3code.desktop";
131130
let desktopEntry = previousEntry;
@@ -150,6 +149,12 @@ describe("DesktopPreReadyPlatform", () => {
150149
yield* Layer.build(
151150
DesktopPreReadyPlatform.layer.pipe(
152151
Layer.provide(Layer.succeed(HostProcess.Platform, "linux")),
152+
Layer.provide(
153+
DesktopConfig.layerTest({
154+
XDG_DATA_HOME: "/xdg",
155+
APPIMAGE: "/Applications/current.AppImage",
156+
}),
157+
),
153158
),
154159
);
155160
const identity = yield* Effect.promise(() => portalIdentity);
@@ -168,16 +173,20 @@ describe("DesktopPreReadyPlatform", () => {
168173

169174
it.effect("points the early portal entry at a configured distribution launcher", () => {
170175
vi.stubEnv("VITE_DEV_SERVER_URL", "");
171-
vi.stubEnv("XDG_DATA_HOME", "/xdg");
172-
vi.stubEnv("APPIMAGE", "/Applications/current.AppImage");
173-
vi.stubEnv("T3CODE_DESKTOP_LAUNCHER_PATH", " /opt/T3 Code/t3code ");
174176
getSwitchValueMock.mockReturnValue("");
175177

176178
return Effect.scoped(
177179
Effect.gen(function* () {
178180
yield* Layer.build(
179181
DesktopPreReadyPlatform.layer.pipe(
180182
Layer.provide(Layer.succeed(HostProcess.Platform, "linux")),
183+
Layer.provide(
184+
DesktopConfig.layerTest({
185+
XDG_DATA_HOME: "/xdg",
186+
APPIMAGE: "/Applications/current.AppImage",
187+
T3CODE_DESKTOP_LAUNCHER_PATH: " /opt/T3 Code/t3code ",
188+
}),
189+
),
181190
),
182191
);
183192
const entry = writeFileSyncMock.mock.calls.find(

0 commit comments

Comments
 (0)