Skip to content

Commit 7723365

Browse files
Merge remote-tracking branch 'origin/main' into pr/launch-branch
2 parents 18d260a + b3fdf2b commit 7723365

443 files changed

Lines changed: 19944 additions & 2750 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: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,16 @@ jobs:
140140
- name: Start installing browser secret helper build libraries
141141
if: needs.changes.outputs.build != 'false'
142142
run: |
143-
sudo sed -i 's|http://|https://|g' /etc/apt/blacksmith-ubuntu-mirrors.txt /etc/apt/sources.list.d/ubuntu.sources
143+
# Fetch only the indexes these main and universe packages need. The full set is ~42 MB,
144+
# which a slow mirror can stretch past the wait below.
145+
sudo sed -i -e 's|http://|https://|g' -e 's/^Components: .*/Components: main universe/' \
146+
/etc/apt/blacksmith-ubuntu-mirrors.txt /etc/apt/sources.list.d/ubuntu.sources
144147
(
145148
set +e
146-
sudo apt-get update && sudo apt-get install -y libsecret-1-dev pkg-config xvfb
149+
sudo apt-get update -o Acquire::Languages=none \
150+
-o Acquire::IndexTargets::deb::DEP-11::DefaultEnabled=false \
151+
-o Acquire::IndexTargets::deb::CNF::DefaultEnabled=false &&
152+
sudo apt-get install -y libsecret-1-dev pkg-config xvfb
147153
echo "$?" > "$RUNNER_TEMP/apt-status"
148154
) > "$RUNNER_TEMP/apt.log" 2>&1 < /dev/null &
149155
@@ -287,10 +293,16 @@ jobs:
287293
# the background while Vite+ installs; the step before the tests waits for it.
288294
- name: Start installing browser secret helper build libraries
289295
run: |
290-
sudo sed -i 's|http://|https://|g' /etc/apt/blacksmith-ubuntu-mirrors.txt /etc/apt/sources.list.d/ubuntu.sources
296+
# Fetch only the indexes these main and universe packages need. The full set is ~42 MB,
297+
# which a slow mirror can stretch past the wait below.
298+
sudo sed -i -e 's|http://|https://|g' -e 's/^Components: .*/Components: main universe/' \
299+
/etc/apt/blacksmith-ubuntu-mirrors.txt /etc/apt/sources.list.d/ubuntu.sources
291300
(
292301
set +e
293-
sudo apt-get update && sudo apt-get install -y libsecret-1-dev pkg-config
302+
sudo apt-get update -o Acquire::Languages=none \
303+
-o Acquire::IndexTargets::deb::DEP-11::DefaultEnabled=false \
304+
-o Acquire::IndexTargets::deb::CNF::DefaultEnabled=false &&
305+
sudo apt-get install -y libsecret-1-dev pkg-config
294306
echo "$?" > "$RUNNER_TEMP/apt-status"
295307
) > "$RUNNER_TEMP/apt.log" 2>&1 < /dev/null &
296308

‎.github/workflows/mobile-showcase-screenshots.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ jobs:
8888
axe --version
8989
9090
- name: Install foldable simulator controls
91-
run: npm install --global [email protected].25
91+
run: npm install --global [email protected].36
9292

9393
- name: Capture iOS showcase
9494
run: pnpm screenshots:mobile --platform ios --appearance "${{ inputs.appearance }}" --theme "${{ inputs.theme }}"

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ apps/mobile/.android-cache/
3838
artifacts/app-store/screenshots/
3939
artifacts/mobile-e2e/
4040
artifacts/mobile-behavior/
41+
scripts/.e2e/
4142
.github/pr-assets/
4243
native/**/target/
4344
node_modules/

‎AGENTS.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ An empty database is a bad test. Seed your worktree's `.t3` with a copy of real
108108
- [Testing](docs/internals/testing.md) carries these same test rules, plus review guidance, for review bots. Change both together.
109109
- **Do not run repo-wide checks.** No `vp check`, no `vp run -r test`, no `vp run -r typecheck` unless I ask. CI owns the full suite.
110110
- Backend behavior changes ship with focused tests for that behavior.
111-
- Proof for a bug fix depends on the bug. Logic, data, state, and protocol bugs get a failing test first (the fewest that fail on `main` for that reason, in an existing case of the module's test file where one fits), then the fix. Purely visual bugs (spacing, colour, alignment, a layout shift) get before/after captures as their proof and no test: do not add UI tests for nitpicks, and do not ask for one in review when a capture already shows it. A server-only fix with no visible surface ships the test plus a short runtime transcript.
111+
- Proof for a bug fix depends on the bug. Logic, data, state, and protocol bugs get a failing test first (the fewest that fail on `main` for that reason, in an existing case of the module's test file where one fits), then the fix. Purely visual bugs (spacing, colour, alignment, a layout shift) get before/after captures as their proof and no test: do not add UI tests for nitpicks, and do not ask for one in review when a capture already shows it. A server-only fix with no visible surface ships the test plus a short runtime transcript. For a bug a user can reproduce in the web client, `vp run scenarios:prove` shows it failing on base and passing on the fix in the real app; see [Scenarios](docs/operations/scenarios.md).
112112
- The server is event-sourced, and side effects run after the command commits. In tests, drain the effect worker (`OrchestrationEffectWorkerV2.drain`) or await the specific persisted event or `Deferred` that marks the milestone. Never wait on sleeps or polling. A test that needs a timeout to pass is wrong. Concretely:
113113
- `it.effect` runs on a `TestClock`; `Effect.sleep` only advances through `TestClock.adjust`. `it.live` is wall-clock and only for subprocess or network fixtures.
114114
- No `yieldNow` or `sleep` polling loops. Await the `Deferred`, take from the `Queue`, or drain the worker.

‎apps/desktop/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"electron-updater": "^6.8.9",
2828
"electron-webauthn": "catalog:",
2929
"ffi-rs": "1.3.2",
30-
"playwright-core": "1.60.0",
30+
"playwright-core": "1.64.1",
3131
"react-grab": "^0.1.32",
3232
"tldts": "catalog:"
3333
},

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ export const make = Effect.gen(function* () {
116116
yield* electronApp.quit;
117117
return yield* Effect.interrupt;
118118
}
119+
// Chromium opens these caches at the first event-loop turn, before ready.
120+
yield* DesktopUserData.clearStaleGpuCaches({
121+
userDataPath,
122+
electronVersion: process.versions.electron,
123+
});
119124

120125
const pendingSecondInstances: Array<readonly string[]> = [];
121126
let handleSecondInstance = (argv: readonly string[]) => {

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ export const make = FileSystem.makeNoop({
4949
syncFs("makeDirectory", path, () => {
5050
NodeFS.mkdirSync(path, { recursive: options?.recursive ?? false });
5151
}),
52+
remove: (path, options) =>
53+
syncFs("remove", path, () =>
54+
NodeFS.rmSync(path, {
55+
recursive: options?.recursive ?? false,
56+
force: options?.force ?? false,
57+
}),
58+
),
5259
writeFileString: (path, data, options) =>
5360
syncFs("writeFileString", path, () =>
5461
NodeFS.writeFileSync(path, data, { flag: options?.flag ?? "w" }),

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

Lines changed: 99 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import { assert, it } from "@effect/vitest";
33
import * as Effect from "effect/Effect";
44
import * as FileSystem from "effect/FileSystem";
55
import * as Path from "effect/Path";
6+
import * as PlatformError from "effect/PlatformError";
67

7-
import { resolveUserDataPath } from "./DesktopUserData.ts";
8+
import { clearStaleGpuCaches, resolveUserDataPath } from "./DesktopUserData.ts";
89

910
it.effect.each(["t3code", "T3 Code (Alpha)"])(
1011
"preserves Windows credential keys from %s without copying browser databases",
@@ -40,3 +41,100 @@ it.effect.each(["t3code", "T3 Code (Alpha)"])(
4041
);
4142
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
4243
);
44+
45+
const gpuCacheDirectories = [
46+
"GPUCache",
47+
"GrShaderCache",
48+
"ShaderCache",
49+
"DawnGraphiteCache",
50+
"DawnWebGPUCache",
51+
"GPUPersistentCache",
52+
];
53+
54+
it.effect.each([
55+
{ profile: "written by Electron 44.10.0", marker: "44.10.0" },
56+
{ profile: "with no recorded Electron version", marker: undefined },
57+
])("clears GPU caches $profile once when Electron 44.10.1 starts", ({ marker }) =>
58+
Effect.gen(function* () {
59+
const fs = yield* FileSystem.FileSystem;
60+
const path = yield* Path.Path;
61+
const userDataPath = yield* fs.makeTempDirectoryScoped({ prefix: "t3-v2-gpu-cache-" });
62+
for (const name of gpuCacheDirectories) {
63+
yield* fs.makeDirectory(path.join(userDataPath, name), { recursive: true });
64+
yield* fs.writeFileString(path.join(userDataPath, name, "data_0"), "44.10.0 shaders");
65+
}
66+
yield* fs.makeDirectory(path.join(userDataPath, "Local Storage"), { recursive: true });
67+
yield* fs.writeFileString(path.join(userDataPath, "Local Storage", "LOCK"), "profile");
68+
yield* fs.writeFileString(path.join(userDataPath, "Local State"), "profile");
69+
if (marker !== undefined) {
70+
yield* fs.writeFileString(path.join(userDataPath, "gpu-cache-electron-version"), marker);
71+
}
72+
73+
yield* clearStaleGpuCaches({ userDataPath, electronVersion: "44.10.1" });
74+
75+
const survivingCaches: Array<string> = [];
76+
for (const name of gpuCacheDirectories) {
77+
if (yield* fs.exists(path.join(userDataPath, name))) survivingCaches.push(name);
78+
}
79+
assert.deepStrictEqual(survivingCaches, []);
80+
assert.equal(
81+
yield* fs.readFileString(path.join(userDataPath, "Local Storage", "LOCK")),
82+
"profile",
83+
);
84+
assert.equal(yield* fs.readFileString(path.join(userDataPath, "Local State")), "profile");
85+
86+
yield* fs.makeDirectory(path.join(userDataPath, "GPUCache"));
87+
yield* fs.writeFileString(path.join(userDataPath, "GPUCache", "data_0"), "44.10.1 shaders");
88+
yield* clearStaleGpuCaches({ userDataPath, electronVersion: "44.10.1" });
89+
assert.equal(
90+
yield* fs.readFileString(path.join(userDataPath, "GPUCache", "data_0")),
91+
"44.10.1 shaders",
92+
);
93+
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
94+
);
95+
96+
it.effect("keeps GPU caches built on the first launch of a fresh install", () =>
97+
Effect.gen(function* () {
98+
const fs = yield* FileSystem.FileSystem;
99+
const path = yield* Path.Path;
100+
const appData = yield* fs.makeTempDirectoryScoped({ prefix: "t3-v2-fresh-" });
101+
const userDataPath = path.join(appData, "t3code-v2");
102+
103+
yield* clearStaleGpuCaches({ userDataPath, electronVersion: "44.10.1" });
104+
yield* fs.makeDirectory(path.join(userDataPath, "GPUCache"));
105+
yield* fs.writeFileString(path.join(userDataPath, "GPUCache", "data_0"), "44.10.1 shaders");
106+
yield* clearStaleGpuCaches({ userDataPath, electronVersion: "44.10.1" });
107+
108+
assert.equal(
109+
yield* fs.readFileString(path.join(userDataPath, "GPUCache", "data_0")),
110+
"44.10.1 shaders",
111+
);
112+
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
113+
);
114+
115+
it.effect("retries on the next launch when a GPU cache cannot be removed", () =>
116+
Effect.gen(function* () {
117+
const writes: Array<string> = [];
118+
const fileSystem = FileSystem.makeNoop({
119+
remove: (path) =>
120+
Effect.fail(
121+
PlatformError.systemError({
122+
_tag: "PermissionDenied",
123+
module: "FileSystem",
124+
method: "remove",
125+
pathOrDescriptor: path,
126+
}),
127+
),
128+
writeFileString: (path) =>
129+
Effect.sync(() => {
130+
writes.push(path);
131+
}),
132+
});
133+
134+
yield* clearStaleGpuCaches({ userDataPath: "/profile", electronVersion: "44.10.1" }).pipe(
135+
Effect.provideService(FileSystem.FileSystem, fileSystem),
136+
);
137+
138+
assert.deepStrictEqual(writes, []);
139+
}).pipe(Effect.provide(NodeServices.layer)),
140+
);

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,43 @@ export const resolveUserDataPath = Effect.fn("desktop.userData.resolveUserDataPa
9595
return destinationPath;
9696
},
9797
);
98+
99+
const GPU_CACHE_DIRECTORIES = [
100+
"GPUCache",
101+
"GrShaderCache",
102+
"ShaderCache",
103+
"DawnGraphiteCache",
104+
"DawnWebGPUCache",
105+
"GPUPersistentCache",
106+
];
107+
108+
// Keyed on Electron, not Chromium: Electron patches ship Chromium backports under the same Chrome version.
109+
export const clearStaleGpuCaches = Effect.fn("desktop.userData.clearStaleGpuCaches")(
110+
function* (input: { readonly userDataPath: string; readonly electronVersion: string }) {
111+
const fs = yield* FileSystem.FileSystem;
112+
const path = yield* Path.Path;
113+
const markerPath = path.join(input.userDataPath, "gpu-cache-electron-version");
114+
const cachedVersion = yield* fs.readFileString(markerPath).pipe(
115+
Effect.catchIf(
116+
(error) => error.reason._tag === "NotFound",
117+
() => Effect.undefined,
118+
),
119+
);
120+
if (cachedVersion?.trim() === input.electronVersion) return;
121+
for (const name of GPU_CACHE_DIRECTORIES) {
122+
yield* fs.remove(path.join(input.userDataPath, name), { recursive: true, force: true });
123+
}
124+
yield* fs.makeDirectory(input.userDataPath, { recursive: true });
125+
yield* fs.writeFileString(markerPath, input.electronVersion);
126+
},
127+
(effect, input) =>
128+
effect.pipe(
129+
Effect.catch((error) =>
130+
Effect.logWarning("could not clear stale GPU caches", {
131+
userDataPath: input.userDataPath,
132+
electronVersion: input.electronVersion,
133+
error: error.message,
134+
}),
135+
),
136+
),
137+
);
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import * as Effect from "effect/Effect";
2+
import * as Layer from "effect/Layer";
3+
import * as Schema from "effect/Schema";
4+
import { assert, it } from "@effect/vitest";
5+
import { vi } from "vite-plus/test";
6+
7+
vi.mock("electron", () => ({}));
8+
9+
import * as ElectronWindow from "../electron/ElectronWindow.ts";
10+
import * as DesktopIpc from "./DesktopIpc.ts";
11+
12+
it.effect("answers only the main window's top frame", () =>
13+
Effect.gen(function* () {
14+
const mainFrame = {};
15+
const invoke = new Map<string, DesktopIpc.DesktopIpcHandleListener>();
16+
const sync = new Map<string, DesktopIpc.DesktopIpcSyncListener>();
17+
const ipc = yield* DesktopIpc.DesktopIpc.pipe(
18+
Effect.provide(
19+
DesktopIpc.layer({
20+
removeHandler: (channel) => void invoke.delete(channel),
21+
handle: (channel, listener) => void invoke.set(channel, listener),
22+
removeAllListeners: (channel) => void sync.delete(channel),
23+
on: (channel, listener) => void sync.set(channel, listener),
24+
}).pipe(
25+
Layer.provide(
26+
Layer.mock(ElectronWindow.ElectronWindow, {
27+
main: Effect.succeedSome({
28+
webContents: { id: 1, mainFrame },
29+
} as unknown as Electron.BrowserWindow),
30+
}),
31+
),
32+
),
33+
),
34+
);
35+
yield* ipc.handle(
36+
DesktopIpc.makeIpcMethod({
37+
channel: "token",
38+
payload: Schema.Void,
39+
result: Schema.String,
40+
handler: () => Effect.succeed("secret"),
41+
}),
42+
);
43+
yield* ipc.handleSync({ channel: "token-sync", handler: () => Effect.succeed("secret") });
44+
45+
const senders = {
46+
app: { sender: { id: 1 }, senderFrame: mainFrame },
47+
appSubframe: { sender: { id: 1 }, senderFrame: {} },
48+
previewGuest: { sender: { id: 2 }, senderFrame: {} },
49+
};
50+
const results: Record<string, unknown> = {};
51+
for (const [name, sender] of Object.entries(senders)) {
52+
const event = { ...sender, returnValue: "unset" as unknown };
53+
sync.get("token-sync")!(event);
54+
results[name] = [
55+
yield* Effect.promise(() =>
56+
Promise.resolve(invoke.get("token")!(sender, undefined)).catch(() => "rejected"),
57+
),
58+
event.returnValue,
59+
];
60+
}
61+
assert.deepEqual(results, {
62+
app: ["secret", "secret"],
63+
appSubframe: ["rejected", undefined],
64+
previewGuest: ["rejected", undefined],
65+
});
66+
}).pipe(Effect.scoped),
67+
);

0 commit comments

Comments
 (0)