@devries-cameron20 / t3code-1 / commits / 2edddbc847
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

test(desktop): prune low-value tests in desktop (second pass) (#22589)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 20, 2026 at 18:30 UTC 2edddbc84752ddeaa8cfdbd4511d1751a0790f2b
58 files changed +21 -2010
apps/desktop/gnome-extension/captureFeedback.test.js
-11
@@ -151,17 +151,6 @@ it("waits for T3 to remap and cancels that wait when disabled", async () => {
151 expect(shell.mapped.size).toBe(0);
152 });
153
154 -it("does not animate under reduced motion but still activates T3", async () => {
155 - shell.animations = false;
156 - shell.windows = [target()];
157 - const { feedback, started } = begin();
158 - expect(started).toBe(false);
159 - expect(shell.actors).toHaveLength(0);
160 - await feedback.activate(":1.23", "T3");
161 - expect(shell.activate).toHaveBeenCalledOnce();
162 - feedback.dispose();
163 -});
164 -
154 it("rejects another sender and locked-session activation", async () => {
155 shell.windows = [target()];
156 const { feedback } = begin();
apps/desktop/gnome-extension/captureService.test.js
-5
@@ -28,11 +28,6 @@ it("rejects other clients before looking at the active window", async () => {
28 expect(await service.capture(":1.23")).toBe("pixels");
29 });
30
31 -it.each(CLIENT_NAMES)("accepts the current owner of %s", async (client) => {
32 - const { service } = fixture({ getNameOwner: async (name) => (name === client ? ":1.23" : null) });
33 - expect(await service.capture(":1.23")).toBe("pixels");
34 -});
35 -
31 it("rechecks the name owner on each capture", async () => {
32 let owner = ":1.23";
33 const { service } = fixture({ getNameOwner: async () => owner });
apps/desktop/scripts/electron-launcher.mjs
+3 -3
@@ -94,7 +94,7 @@ function runChecked(command, args) {
94 throw new Error(`Failed to run ${command} ${args.join(" ")}: ${details}`.trim());
95 }
96
97 -export function resolveMacCodeSignArguments(appBundlePath) {
97 +function resolveMacCodeSignArguments(appBundlePath) {
98 return ["--force", "--deep", "--sign", "-", "--timestamp=none", appBundlePath];
99 }
100
@@ -201,7 +201,7 @@ function registerMacLauncherBundle(appBundlePath) {
201 }
202
203 // Bundle-internal paths are macOS paths whatever host builds them.
204 -export function resolveMacLauncherIconPaths(runtimeDir, development = isDevelopment) {
204 +function resolveMacLauncherIconPaths(runtimeDir, development = isDevelopment) {
205 return {
206 sourceIconPath: development ? developmentMacIconPngPath : productionMacIconPngPath,
207 generatedIconPath: NodePath.posix.join(
@@ -260,7 +260,7 @@ function ensureMacIconIcns(runtimeDir) {
260 }
261 }
262
263 -export function resolveMacBundleInfoPlistStrings(executableName) {
263 +function resolveMacBundleInfoPlistStrings(executableName) {
264 return {
265 CFBundleDisplayName: APP_DISPLAY_NAME,
266 CFBundleName: APP_DISPLAY_NAME,
apps/desktop/scripts/electron-launcher.test.mjs
-37
@@ -11,9 +11,6 @@ import {
11 makeDevelopmentEnvironmentScript,
12 makeDevelopmentLauncherScript,
13 resolveElectronBinaryPath,
14 - resolveMacBundleInfoPlistStrings,
15 - resolveMacCodeSignArguments,
16 - resolveMacLauncherIconPaths,
14 resolveMacLauncherPaths,
15 writeDevelopmentLauncherScript,
16 } from "./electron-launcher.mjs";
@@ -106,30 +103,6 @@ describe("electron development launcher", () => {
103 assert.notInclude(script, "node_modules/electron");
104 });
105
109 - it("declares why the macOS app needs protected access", () => {
110 - const values = resolveMacBundleInfoPlistStrings("T3 Code (Dev) Launcher");
111 -
112 - assert.equal(
113 - values.NSScreenCaptureUsageDescription,
114 - "T3 Code captures the active window when you use the snapshot shortcut.",
115 - );
116 - assert.equal(
117 - values.NSDocumentsFolderUsageDescription,
118 - "T3 Code reads project files you open in the desktop app.",
119 - );
120 - });
121 -
122 - it("ad-hoc signs the complete development app bundle", () => {
123 - assert.deepEqual(resolveMacCodeSignArguments("/runtime/T3 Code (Dev).app"), [
124 - "--force",
125 - "--deep",
126 - "--sign",
127 - "-",
128 - "--timestamp=none",
129 - "/runtime/T3 Code (Dev).app",
130 - ]);
131 - });
132 -
106 it("restores execute permissions on an unchanged launcher", () => {
107 const directory = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-launcher-"));
108 const launcherPath = NodePath.join(directory, "launcher");
@@ -143,16 +116,6 @@ describe("electron development launcher", () => {
116 NodeFS.rmSync(directory, { recursive: true, force: true });
117 }
118 });
146 -
147 - it("derives launcher icons from canonical development and production assets", () => {
148 - const development = resolveMacLauncherIconPaths("/runtime", true);
149 - const production = resolveMacLauncherIconPaths("/runtime", false);
150 -
151 - assert.match(development.sourceIconPath, /assets[\\/]dev[\\/]blueprint-macos-1024\.png$/);
152 - assert.equal(development.generatedIconPath, "/runtime/icon-dev.icns");
153 - assert.match(production.sourceIconPath, /assets[\\/]prod[\\/]black-macos-1024\.png$/);
154 - assert.equal(production.generatedIconPath, "/runtime/icon-prod.icns");
155 - });
119 });
120
121 async function startupCleanupPattern(desktopDir) {
apps/desktop/scripts/verify-preload-bundle.test.mjs
-13
@@ -60,12 +60,6 @@ describe("desktop preload bundle verifier", () => {
60 );
61 });
62
63 - it("ignores import-like text in strings", () => {
64 - assert.doesNotThrow(() =>
65 - verifyPreloadBundle(`${validPreload}\nconst message = 'import /* comment */("module")';`),
66 - );
67 - });
68 -
63 it("rejects unsupported require calls with comments before the opening parenthesis", () => {
64 assert.throws(
65 () => verifyPreloadBundle(`${validPreload}\nrequire /* @__PURE__ */ ("node:fs");`),
@@ -73,13 +67,6 @@ describe("desktop preload bundle verifier", () => {
67 );
68 });
69
76 - it("rejects unsupported optional require calls", () => {
77 - assert.throws(
78 - () => verifyPreloadBundle(`${validPreload}\nrequire?.("node:fs");`),
79 - /unsupported sandbox imports: node:fs/,
80 - );
81 - });
82 -
70 it("accepts Electron sandbox module aliases", () => {
71 assert.doesNotThrow(() =>
72 verifyPreloadBundle(`
apps/desktop/src/app/DesktopAppActivationBroker.test.ts
-25
@@ -49,31 +49,6 @@ describe("DesktopAppActivationBroker", () => {
49 broker.close();
50 });
51
52 - it("queues requests after unsubscribe until a new renderer registers", async () => {
53 - const previousSend = vi.fn();
54 - const nextSend = vi.fn();
55 - const broker = new DesktopAppActivationBroker({ requestTimeoutMs: 1_000, activate: vi.fn() });
56 - broker.registerRenderer(previousSend);
57 - broker.clearRenderer();
58 -
59 - const response = broker.request(request);
60 - expect(previousSend).not.toHaveBeenCalled();
61 - expect(nextSend).not.toHaveBeenCalled();
62 -
63 - broker.registerRenderer(nextSend);
64 - expect(nextSend).toHaveBeenCalledWith(request);
65 - broker.complete({
66 - version: 1,
67 - requestId: request.requestId,
68 - ok: true,
69 - projectId: ProjectId.make("project-1"),
70 - threadId: ThreadId.make("thread-1"),
71 - });
72 -
73 - await expect(response).resolves.toMatchObject({ ok: true });
74 - broker.close();
75 - });
76 -
52 it("never sends a canceled request that was queued behind another request", async () => {
53 const send = vi.fn();
54 const broker = new DesktopAppActivationBroker({ requestTimeoutMs: 1_000, activate: vi.fn() });
apps/desktop/src/app/DesktopConnectionCatalogStore.test.ts
-39
@@ -8,7 +8,6 @@ import * as FileSystem from "effect/FileSystem";
8 import * as Path from "effect/Path";
9 import * as Layer from "effect/Layer";
10 import * as Option from "effect/Option";
11 -import * as PlatformError from "effect/PlatformError";
11 import * as Ref from "effect/Ref";
12 import * as Schema from "effect/Schema";
13
@@ -267,44 +266,6 @@ describe("DesktopConnectionCatalogStore", () => {
266 ),
267 );
268
270 - it.effect("surfaces catalog filesystem failures instead of treating them as missing", () =>
271 - Effect.gen(function* () {
272 - const path = yield* Path.Path;
273 - const baseFileSystem = yield* FileSystem.FileSystem;
274 - const baseDir = yield* baseFileSystem.makeTempDirectoryScoped({
275 - prefix: "t3-desktop-connection-catalog-test-",
276 - });
277 - const permissionError = PlatformError.systemError({
278 - _tag: "PermissionDenied",
279 - module: "FileSystem",
280 - method: "readFileString",
281 - pathOrDescriptor: path.join(baseDir, "userdata", "connection-catalog.json"),
282 - });
283 - const layerFileSystem = Layer.succeed(
284 - FileSystem.FileSystem,
285 - FileSystem.makeNoop({
286 - readFileString: () => Effect.fail(permissionError),
287 - }),
288 - );
289 - const store = yield* DesktopConnectionCatalogStore.DesktopConnectionCatalogStore.pipe(
290 - Effect.provide(layerFor(baseDir, true, null, layerFileSystem)),
291 - );
292 -
293 - const error = yield* store.get.pipe(Effect.flip);
294 - assert.instanceOf(
295 - error,
296 - DesktopConnectionCatalogStore.DesktopConnectionCatalogStoreReadError,
297 - );
298 - assert.equal(error.catalogPath, path.join(baseDir, "userdata", "connection-catalog.json"));
299 - assert.strictEqual(error.cause, permissionError);
300 - assert.equal(
301 - error.message,
302 - `Failed to read the desktop connection catalog at ${path.join(baseDir, "userdata", "connection-catalog.json")}.`,
303 - );
304 - assert.notEqual(error.message, permissionError.message);
305 - }).pipe(Effect.provide(NodeServices.layer), Effect.scoped),
306 - );
307 -
269 it.effect("surfaces a catalog that can no longer be decrypted without deleting it", () =>
270 Effect.gen(function* () {
271 const path = yield* Path.Path;
apps/desktop/src/app/DesktopEarlyElectronStartup.test.ts
+9 -14
@@ -57,8 +57,6 @@ describe("DesktopEarlyElectronStartup", () => {
57 const releaseCommits: Record<string, string> = {
58 "0.48.0": "5ee35f914f921e5696030698e74fb5566a804768",
59 "0.48.1": "29e2e59fdbab8ed2cc23a20e3c6043d5decb5cdc",
60 - "0.49.0": "9958d297641b5c84dcff93f9039d80a5ad37ab00",
61 - "0.50.0": "c4a4c341568944bd4fb9cd503558b2de602c0213",
60 "0.50.1": "4e242d086e20b32951fdc0ebcbfb4d41b5be8dcc",
61 };
62 const hyprctlVersion =
@@ -80,18 +78,15 @@ describe("DesktopEarlyElectronStartup", () => {
78 readHyprctlVersionJson: hyprctlVersion("0.48.1"),
79 };
80
83 - it.each(["0.48.0", "0.48.1", "0.49.0", "0.50.0", "0.50.1"])(
84 - "disables the color manager on Hyprland %s",
85 - (version) => {
86 - assert.equal(
87 - resolveLinuxDisableFeaturesSwitch({
88 - ...brokenHyprland,
89 - readHyprctlVersionJson: hyprctlVersion(version),
90 - }),
91 - "WaylandWpColorManagerV1",
92 - );
93 - },
94 - );
81 + it.each(["0.48.0", "0.50.1"])("disables the color manager on Hyprland %s", (version) => {
82 + assert.equal(
83 + resolveLinuxDisableFeaturesSwitch({
84 + ...brokenHyprland,
85 + readHyprctlVersionJson: hyprctlVersion(version),
86 + }),
87 + "WaylandWpColorManagerV1",
88 + );
89 + });
90
91 it.each([
92 { label: "case-insensitive desktop tokens", env: { XDG_CURRENT_DESKTOP: "foo:HYPRLAND" } },
apps/desktop/src/app/DesktopObservability.test.ts
-24
@@ -280,30 +280,6 @@ describe("DesktopObservability", () => {
280 ),
281 );
282
283 - it.effect("stays off the network when no endpoint is configured", () => {
284 - const requests: Array<ExportedRequest> = [];
285 - return Effect.gen(function* () {
286 - const fileSystem = yield* FileSystem.FileSystem;
287 - const baseDir = yield* fileSystem.makeTempDirectoryScoped({
288 - prefix: "t3-desktop-observability-test-",
289 - });
290 -
291 - yield* Effect.scoped(
292 - Effect.logInfo("desktop log stays local").pipe(
293 - Effect.withSpan("desktop-offline-test"),
294 - Effect.provide(
295 - DesktopObservability.layer.pipe(Layer.provideMerge(layerEnvironmentFor(baseDir))),
296 - ),
297 - ),
298 - );
299 -
300 - assert.lengthOf(requests, 0);
301 - }).pipe(
302 - Effect.scoped,
303 - Effect.provide(Layer.mergeAll(NodeServices.layer, layerCollector(requests), layerEmptyEnv)),
304 - );
305 - });
306 -
283 it.effect("stops every export when the OpenTelemetry SDK is disabled", () => {
284 const requests: Array<ExportedRequest> = [];
285 return Effect.gen(function* () {
apps/desktop/src/app/DesktopPreReadyFileSystem.test.ts
-16
@@ -4,7 +4,6 @@ import * as HostProcess from "@t3tools/shared/HostProcess";
4 import * as Effect from "effect/Effect";
5 import * as Exit from "effect/Exit";
6 import * as FileSystem from "effect/FileSystem";
7 -import * as Path from "effect/Path";
7
8 import * as DesktopPreReadyFileSystem from "./DesktopPreReadyFileSystem.ts";
9 import * as DesktopUserData from "./DesktopUserData.ts";
@@ -17,21 +16,6 @@ const resolveWindowsUserData = (appDataDirectory: string) =>
16 }).pipe(Effect.provide(DesktopPreReadyFileSystem.layer));
17
18 it.layer(NodeServices.layer)("DesktopPreReadyFileSystem", (it) => {
20 - it.effect("migrates the legacy Windows profile state", () =>
21 - Effect.gen(function* () {
22 - const fileSystem = yield* FileSystem.FileSystem;
23 - const path = yield* Path.Path;
24 - const root = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-pre-ready-fs-" });
25 - yield* fileSystem.makeDirectory(path.join(root, "T3 Code (Alpha)"));
26 - yield* fileSystem.writeFileString(path.join(root, "T3 Code (Alpha)", "Local State"), "keys");
27 -
28 - const userData = yield* resolveWindowsUserData(root);
29 -
30 - assert.equal(userData, path.join(root, "t3code-v2"));
31 - assert.equal(yield* fileSystem.readFileString(path.join(userData, "Local State")), "keys");
32 - }),
33 - );
34 -
19 it.effect.skipIf(HostProcess.Platform.defaultValue() === "win32" || process.getuid?.() === 0)(
20 "fails instead of treating an unreadable profile as missing",
21 () =>
apps/desktop/src/app/DesktopPreReadyPlatform.test.ts
-51
@@ -119,57 +119,6 @@ describe("DesktopPreReadyPlatform", () => {
119 );
120 });
121
122 - it.effect.each([
123 - {
124 - label: "merges the color-manager fallback into disabled features on Hyprland 0.48.1",
125 - switches: { "ozone-platform": "wayland", "disable-features": "Vulkan" },
126 - hyprlandVersion: "0.48.1",
127 - hyprlandCommit: "29e2e59fdbab8ed2cc23a20e3c6043d5decb5cdc",
128 - expected: [["disable-features", "Vulkan,WaylandWpColorManagerV1"]],
129 - },
130 - {
131 - label: "preserves color management on Hyprland 0.51.0",
132 - switches: { "ozone-platform": "wayland", "disable-features": "Vulkan" },
133 - hyprlandVersion: "0.51.0",
134 - hyprlandCommit: "0123456789abcdef0123456789abcdef01234567",
135 - expected: [],
136 - },
137 - {
138 - label: "preserves color management when Electron resolved X11",
139 - switches: { "ozone-platform": "x11", "disable-features": "Vulkan" },
140 - hyprlandVersion: "0.48.1",
141 - hyprlandCommit: "29e2e59fdbab8ed2cc23a20e3c6043d5decb5cdc",
142 - expected: [],
143 - },
144 - ])("$label", ({ switches, hyprlandVersion, hyprlandCommit, expected }) => {
145 - vi.stubEnv("XDG_CURRENT_DESKTOP", "Hyprland");
146 - vi.stubEnv("XDG_SESSION_TYPE", "wayland");
147 - const commandLine = new Map<string, string>(Object.entries(switches));
148 - hasSwitchMock.mockImplementation((switchName: string) => commandLine.has(switchName));
149 - getSwitchValueMock.mockImplementation(
150 - (switchName: string) => commandLine.get(switchName) ?? "",
151 - );
152 - execFileSyncMock.mockReturnValue(
153 - JSON.stringify({
154 - commit: hyprlandCommit,
155 - version: hyprlandVersion,
156 - dirty: false,
157 - tag: `v${hyprlandVersion}`,
158 - }),
159 - );
160 -
161 - return DesktopPreReadyPlatform.make.pipe(
162 - Effect.provideService(HostProcess.Platform, "linux"),
163 - Effect.map(() => {
164 - const featureSwitches = appendSwitchMock.mock.calls.filter(([name]) =>
165 - ["disable-features", "enable-features", "ozone-platform"].includes(name),
166 - );
167 - assert.deepEqual(featureSwitches, expected);
168 - }),
169 - Effect.ensuring(Effect.sync(() => vi.unstubAllEnvs())),
170 - );
171 - });
172 -
122 it.effect.each([
123 { previousEntry: undefined, label: "missing" },
124 { previousEntry: 'Exec="/Applications/deleted-previous.AppImage" %U', label: "stale" },
apps/desktop/src/app/DesktopWebLinks.test.ts
-8
@@ -36,14 +36,6 @@ const makeWindow = () => {
36 };
37
38 describe("DesktopWebLinks", () => {
39 - it("treats only http and https as web links", () => {
40 - assert.isTrue(DesktopWebLinks.isWebLink("https://example.com/"));
41 - assert.isTrue(DesktopWebLinks.isWebLink("http://localhost:3000/a?b=1"));
42 - assert.isFalse(DesktopWebLinks.isWebLink("t3code://app/welcome"));
43 - assert.isFalse(DesktopWebLinks.isWebLink("mailto:hello@example.com"));
44 - assert.isFalse(DesktopWebLinks.isWebLink("not a url"));
45 - });
46 -
39 it.effect("holds links until the renderer listens, then delivers them in order", () => {
40 const { sent, revealed, layer } = makeWindow();
41 return Effect.gen(function* () {
apps/desktop/src/backend/DesktopBackendConfiguration.test.ts
-36
@@ -873,42 +873,6 @@ describe("DesktopBackendConfiguration", () => {
873 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
874 );
875
876 - it.effect("resolveWsl keeps a transient distro-list failure retryable", () =>
877 - Effect.gen(function* () {
878 - const fileSystem = yield* FileSystem.FileSystem;
879 - const baseDir = yield* fileSystem.makeTempDirectoryScoped({
880 - prefix: "t3-desktop-backend-config-test-",
881 - });
882 -
883 - yield* Effect.gen(function* () {
884 - const configuration = yield* DesktopBackendConfiguration.DesktopBackendConfiguration;
885 - const config = yield* configuration.resolveWsl({ port: 5050, distro: "Ubuntu" });
886 - const failure = Option.getOrThrow(config.preflightFailure);
887 -
888 - assert.isFalse(failure.fatal);
889 - assert.equal(failure.retryLimit, 12);
890 - assert.include(failure.reason, "timed out");
891 - }).pipe(
892 - Effect.provide(
893 - layerBackendConfiguration().pipe(
894 - Layer.provideMerge(layerServerExposure),
895 - Layer.provideMerge(DesktopAppSettings.layerTest()),
896 - Layer.provideMerge(DesktopWslServerTree.layerTest()),
897 - Layer.provideMerge(
898 - DesktopWslEnvironment.layerTest({
899 - isAvailable: true,
900 - distroListError: new DesktopWslEnvironment.DesktopWslDistroListError({
901 - reason: "wsl.exe --list --verbose timed out",
902 - }),
903 - }),
904 - ),
905 - Layer.provideMerge(layerEnvironment(baseDir, { platform: "win32" })),
906 - ),
907 - ),
908 - );
909 - }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
910 - );
911 -
876 it.effect("resolveWsl marks a missing packaged server entry as fatal", () =>
877 Effect.gen(function* () {
878 const fileSystem = yield* FileSystem.FileSystem;
apps/desktop/src/backend/DesktopBackendManager.test.ts
-54
@@ -295,60 +295,6 @@ describe("DesktopBackendManager", () => {
295 }),
296 );
297
298 - it.effect("reports output handler failures separately from stream read failures", () =>
299 - Effect.gen(function* () {
300 - const chunk = new TextEncoder().encode("backend output");
301 - const nextChunk = new TextEncoder().encode("still draining");
302 - const outputCause = new Error("output-handler-secret-sentinel");
303 - const reported = yield* Deferred.make<DesktopBackendManager.BackendProcessOutputError>();
304 - const drained = yield* Deferred.make<void>();
305 - let outputCount = 0;
306 - const layerSpawner = Layer.succeed(
307 - ChildProcessSpawner.ChildProcessSpawner,
308 - ChildProcessSpawner.make(() =>
309 - Effect.succeed(
310 - makeProcess({
311 - stdout: Stream.make(chunk, nextChunk),
312 - exitCode: Deferred.await(drained).pipe(Effect.as(ChildProcessSpawner.ExitCode(0))),
313 - }),
314 - ),
315 - ),
316 - );
317 -
318 - const exit = yield* DesktopBackendManager.runBackendProcess({
319 - ...baseConfig,
320 - desktopTelemetryStream: Stream.empty,
321 - onOutput: () => {
322 - outputCount += 1;
323 - return outputCount === 1
324 - ? Effect.fail(outputCause)
325 - : Deferred.succeed(drained, void 0).pipe(Effect.asVoid);
326 - },
327 - onOutputFailure: (error) => Deferred.succeed(reported, error).pipe(Effect.asVoid),
328 - }).pipe(Effect.scoped, Effect.provide(Layer.merge(layerSpawner, layerHealthyHttpClient)));
329 - const error = yield* Deferred.await(reported);
330 -
331 - assert.equal(exit.code.pipe(Option.getOrUndefined), 0);
332 - if (error._tag !== "BackendProcessOutputHandlingError") {
333 - return assert.fail(`Expected output handling error, received ${error._tag}`);
334 - }
335 - assert.equal(error.executablePath, "/electron");
336 - assert.equal(error.entryPath, "/server/bin.mjs");
337 - assert.equal(error.cwd, "/server");
338 - assert.equal(error.httpBaseUrl.href, "http://127.0.0.1:3773/");
339 - assert.equal(error.pid, 123);
340 - assert.equal(error.streamName, "stdout");
341 - assert.equal(error.chunkByteLength, chunk.byteLength);
342 - assert.strictEqual(error.cause, outputCause);
343 - assert.equal(
344 - error.message,
345 - `Failed to handle ${chunk.byteLength} bytes from stdout of desktop backend process 123.`,
346 - );
347 - assert.notInclude(error.message, "output-handler-secret-sentinel");
348 - assert.equal(outputCount, 2);
349 - }),
350 - );
351 -
298 it.effect("reports child exit before waiting for trailing output to drain", () =>
299 Effect.scoped(
300 Effect.gen(function* () {
apps/desktop/src/backend/DesktopServerExposure.test.ts
-14
@@ -191,20 +191,6 @@ describe("DesktopServerExposure", () => {
191 ),
192 );
193
194 - it.effect("returns a typed error when network access is explicitly unavailable", () =>
195 - withHarness(
196 - emptyNetworkInterfaces,
197 - Effect.gen(function* () {
198 - const serverExposure = yield* DesktopServerExposure.DesktopServerExposure;
199 - yield* serverExposure.configureFromSettings({ port: 4173 });
200 -
201 - const error = yield* serverExposure.setMode("network-accessible").pipe(Effect.flip);
202 - assert.ok(error._tag === "DesktopServerExposureNoNetworkAddressError");
203 - assert.equal(error.port, 4173);
204 - }),
205 - ),
206 - );
207 -
194 it.effect("persists network-accessible mode and updates backend binding state", () =>
195 withHarness(
196 lanNetworkInterfaces,
apps/desktop/src/backend/tailscaleEndpointProvider.test.ts
+1 -52
@@ -4,10 +4,7 @@ import * as Layer from "effect/Layer";
4 import { HttpClient } from "effect/http";
5 import { ChildProcessSpawner } from "effect/process";
6
7 -import {
8 - parseTailscaleMagicDnsName,
9 - resolveTailscaleAdvertisedEndpoints,
10 -} from "./tailscaleEndpointProvider.ts";
7 +import { resolveTailscaleAdvertisedEndpoints } from "./tailscaleEndpointProvider.ts";
8
9 const layerUnusedTailscaleExternalServices = Layer.mergeAll(
10 Layer.succeed(
@@ -82,52 +79,4 @@ describe("tailscale endpoint provider", () => {
79 );
80 }).pipe(Effect.provide(layerUnusedTailscaleExternalServices)),
81 );
85 -
86 - it.effect("parses MagicDNS names from tailscale status", () =>
87 - Effect.gen(function* () {
88 - const dnsName = yield* parseTailscaleMagicDnsName(
89 - `{"Self":{"DNSName":"desktop.tail.ts.net."}}`,
90 - );
91 - assert.equal(dnsName, "desktop.tail.ts.net");
92 - assert.equal(yield* parseTailscaleMagicDnsName("{}"), null);
93 - const malformed = yield* Effect.result(parseTailscaleMagicDnsName("not-json"));
94 - assert.isTrue(malformed._tag === "Failure");
95 - }),
96 - );
97 -
98 - it.effect(
99 - "marks the Tailscale HTTPS endpoint available after Serve is enabled and reachable",
100 - () =>
101 - Effect.gen(function* () {
102 - const endpoints = yield* resolveTailscaleAdvertisedEndpoints({
103 - port: 3773,
104 - networkInterfaces: {},
105 - statusJson: `{"Self":{"DNSName":"desktop.tail.ts.net."}}`,
106 - serveEnabled: true,
107 - probe: () => Effect.succeed(true),
108 - });
109 - assert.deepEqual(endpoints, [
110 - {
111 - id: "tailscale-magicdns:https://desktop.tail.ts.net/",
112 - label: "Tailscale HTTPS",
113 - provider: {
114 - id: "tailscale",
115 - label: "Tailscale",
116 - kind: "private-network",
117 - isAddon: true,
118 - },
119 - httpBaseUrl: "https://desktop.tail.ts.net/",
120 - wsBaseUrl: "wss://desktop.tail.ts.net/",
121 - reachability: "private-network",
122 - compatibility: {
123 - hostedHttpsApp: "compatible",
124 - desktopApp: "compatible",
125 - },
126 - source: "desktop-addon",
127 - status: "available",
128 - description: "HTTPS endpoint served by Tailscale Serve.",
129 - },
130 - ]);
131 - }).pipe(Effect.provide(layerUnusedTailscaleExternalServices)),
132 - );
82 });
apps/desktop/src/backend/tailscaleEndpointProvider.ts
-2
@@ -15,8 +15,6 @@ import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
15
16 import type { NetworkInterfaces } from "./DesktopNetworkInterfaces.ts";
17
18 -export { parseTailscaleMagicDnsName } from "@t3tools/tailscale";
19 -
18 const TAILSCALE_ENDPOINT_PROVIDER: AdvertisedEndpointProvider = {
19 id: "tailscale",
20 label: "Tailscale",
apps/desktop/src/electron/ElectronProtocol.test.ts
-42
@@ -153,46 +153,4 @@ describe("ElectronProtocol", () => {
153 assert.equal(netFetchMock.mock.calls.length, 0);
154 }).pipe(Effect.provide(layerProtocol)),
155 );
156 -
157 - it("keeps executable sources host-restricted while allowing runtime network resources", () => {
158 - const policy = ElectronProtocol.makeDesktopContentSecurityPolicy({
159 - scheme: "t3code",
160 - targetOrigin: new URL("http://127.0.0.1:3773/"),
161 - clerkFrontendApiHostname: "clerk.t3.codes",
162 - });
163 - const directives = Object.fromEntries(
164 - policy.split("; ").map((directive) => {
165 - const [name, ...sources] = directive.split(" ");
166 - return [name, sources];
167 - }),
168 - );
169 -
170 - assert.deepEqual(directives["script-src"], [
171 - "'self'",
172 - "'unsafe-inline'",
173 - "'wasm-unsafe-eval'",
174 - "https://clerk.t3.codes",
175 - "https://challenges.cloudflare.com",
176 - ]);
177 - assert.deepEqual(directives["connect-src"], [
178 - "'self'",
179 - "blob:",
180 - "http:",
181 - "https:",
182 - "ws:",
183 - "wss:",
184 - ]);
185 - assert.deepEqual(directives["img-src"], [
186 - "'self'",
187 - "t3code:",
188 - "blob:",
189 - "data:",
190 - "http:",
191 - "https:",
192 - ]);
193 - assert.deepEqual(directives["media-src"], ["'self'", "t3code:", "blob:", "http:", "https:"]);
194 - assert.deepEqual(directives["frame-src"], ["'self'", "blob:", "http:", "https:"]);
195 - assert.deepEqual(directives["object-src"], ["'self'", "blob:", "http:", "https:"]);
196 - assert.deepEqual(directives["font-src"], ["'self'", "t3code:", "data:"]);
197 - });
156 });
apps/desktop/src/electron/ElectronProtocol.ts
+1 -1
@@ -66,7 +66,7 @@ export class ElectronProtocol extends Context.Service<
66 }
67 >()("@t3tools/desktop/electron/ElectronProtocol") {}
68
69 -export function makeDesktopContentSecurityPolicy(input: DesktopProtocolRegistrationInput): string {
69 +function makeDesktopContentSecurityPolicy(input: DesktopProtocolRegistrationInput): string {
70 const clerkOrigin = input.clerkFrontendApiHostname
71 ? `https://${input.clerkFrontendApiHostname}`
72 : undefined;
apps/desktop/src/electron/ElectronWindow.test.ts
-25
@@ -62,13 +62,6 @@ const layerTestFor = (platform: NodeJS.Platform) =>
62
63 const layerTest = layerTestFor("linux");
64
65 -function makeBrowserWindow(input: { readonly id: number; readonly destroyed: boolean }) {
66 - return {
67 - id: input.id,
68 - isDestroyed: vi.fn(() => input.destroyed),
69 - } as unknown as Electron.BrowserWindow;
70 -}
71 -
65 function makeWindowsRevealWindow() {
66 return {
67 id: 41,
@@ -109,24 +102,6 @@ describe("ElectronWindow", () => {
102 windowsForegroundCloseMock.mockReset();
103 });
104
112 - it.effect("skips windows destroyed before appearance sync runs", () =>
113 - Effect.gen(function* () {
114 - const liveWindow = makeBrowserWindow({ id: 1, destroyed: false });
115 - const destroyedWindow = makeBrowserWindow({ id: 2, destroyed: true });
116 - getAllWindowsMock.mockReturnValue([destroyedWindow, liveWindow]);
117 -
118 - const syncedWindows: Electron.BrowserWindow[] = [];
119 - const electronWindow = yield* ElectronWindow.ElectronWindow;
120 - yield* electronWindow.syncAllAppearance((window) =>
121 - Effect.sync(() => {
122 - syncedWindows.push(window);
123 - }),
124 - );
125 -
126 - assert.deepEqual(syncedWindows, [liveWindow]);
127 - }).pipe(Effect.provide(layerTest)),
128 - );
129 -
105 it.effect("cancels native focus when destroyed during the foreground query", () =>
106 Effect.gen(function* () {
107 const window = makeWindowsRevealWindow();
apps/desktop/src/electron/WindowsForeground.test.ts
-18
@@ -54,24 +54,6 @@ describe("Windows foreground activation", () => {
54 assert.deepEqual(api.setForegroundWindow.mock.calls, [[41n]]);
55 });
56
57 - it("does not attach a thread to itself", () => {
58 - const api = makeApi({ currentThreadId: 20, foregroundThreadId: 20 });
59 -
60 - assert.isTrue(activateWindowsForegroundWithApi(nativeHandle(41n), api));
61 -
62 - assert.lengthOf(api.attachThreadInput.mock.calls, 0);
63 - assert.deepEqual(api.setForegroundWindow.mock.calls, [[41n]]);
64 - });
65 -
66 - it("still asks Windows directly when the input queues cannot be attached", () => {
67 - const api = makeApi({ attached: false });
68 -
69 - assert.isTrue(activateWindowsForegroundWithApi(nativeHandle(41n), api));
70 -
71 - assert.deepEqual(api.attachThreadInput.mock.calls, [[10, 20, true]]);
72 - assert.deepEqual(api.setForegroundWindow.mock.calls, [[41n]]);
73 - });
74 -
57 it("rejects malformed native handles", () => {
58 const api = makeApi({});
59
apps/desktop/src/ipc/DesktopIpc.test.ts deleted
-49
@@ -1,49 +0,0 @@
1 -import { assert, describe, it } from "@effect/vitest";
2 -import * as Effect from "effect/Effect";
3 -import { vi } from "vite-plus/test";
4 -
5 -import * as DesktopIpc from "./DesktopIpc.ts";
6 -
7 -function makeIpcMain(
8 - overrides: Partial<DesktopIpc.DesktopIpcMain> = {},
9 -): DesktopIpc.DesktopIpcMain {
10 - return {
11 - removeHandler: vi.fn(),
12 - handle: vi.fn(),
13 - removeAllListeners: vi.fn(),
14 - on: vi.fn(),
15 - ...overrides,
16 - };
17 -}
18 -
19 -describe("DesktopIpc", () => {
20 - it.effect("forwards the invoke sender to the method", () =>
21 - Effect.gen(function* () {
22 - let listener: DesktopIpc.DesktopIpcHandleListener | undefined;
23 - const ipc = DesktopIpc.make(
24 - makeIpcMain({
25 - handle: (_channel, registered) => {
26 - listener = registered;
27 - },
28 - }),
29 - );
30 - const sender = { sender: { id: 7 } };
31 - let received: DesktopIpc.DesktopIpcInvokeEvent | undefined;
32 -
33 - yield* Effect.scoped(
34 - Effect.gen(function* () {
35 - yield* ipc.handle({
36 - channel: "desktop.test.sender",
37 - handler: (_raw, event) =>
38 - Effect.sync(() => {
39 - received = event;
40 - }),
41 - });
42 - yield* Effect.promise(async () => listener!(sender, undefined));
43 - }),
44 - );
45 -
46 - assert.strictEqual(received, sender);
47 - }),
48 - );
49 -});
apps/desktop/src/ipc/methods/preview.test.ts
-45
@@ -10,7 +10,6 @@ import * as Schema from "effect/Schema";
10 import { beforeEach, describe, expect, it, vi } from "vite-plus/test";
11
12 import * as PreviewManager from "../../preview/Manager.ts";
13 -import * as BrowserImport from "../../preview/BrowserImport/BrowserImport.ts";
13 import * as PreviewIpc from "./preview.ts";
14 import * as DesktopIpc from "../DesktopIpc.ts";
15 import * as DesktopClientSettings from "../../settings/DesktopClientSettings.ts";
@@ -121,18 +120,6 @@ describe("preview IPC methods", () => {
120 expect(first.scope).not.toBe(second.scope);
121 });
122
124 - it("preserves lone surrogates without collapsing them to replacement characters", () => {
125 - const highSurrogate = PreviewIpc.resolvePartitionScope("environment", "profile-\ud800");
126 - const lowSurrogate = PreviewIpc.resolvePartitionScope("environment", "profile-\udc00");
127 - const replacement = PreviewIpc.resolvePartitionScope("environment", "profile-�");
128 -
129 - expect(highSurrogate.scope).toBe('["environment","profile-\\ud800"]');
130 - expect(lowSurrogate.scope).toBe('["environment","profile-\\udc00"]');
131 - expect(highSurrogate.scope).not.toBe(lowSurrogate.scope);
132 - expect(highSurrogate.scope).not.toBe(replacement.scope);
133 - expect(lowSurrogate.scope).not.toBe(replacement.scope);
134 - });
135 -
123 it("keeps the legacy default partition scope and incognito persistence", () => {
124 expect(PreviewIpc.resolvePartitionScope("environment::legacy", undefined)).toEqual({
125 scope: "environment::legacy",
@@ -149,36 +136,4 @@ describe("preview IPC methods", () => {
136 namespace: "profile",
137 });
138 });
152 -
153 - effectIt.effect("targets imports at the same partition tuple as the renderer", () => {
154 - const received: Array<Parameters<BrowserImport.BrowserImport["Service"]["importCookies"]>[0]> =
155 - [];
156 - const browserImport = BrowserImport.BrowserImport.of({
157 - listSources: Effect.succeed([]),
158 - importCookies: (input) =>
159 - Effect.sync(() => {
160 - received.push(input);
161 - return { imported: 0, skipped: 0, skippedDomains: [] };
162 - }),
163 - });
164 - const request = (environmentId: string, targetProfileId: string) =>
165 - PreviewIpc.importBrowserCookies.handler({
166 - environmentId,
167 - sourceId: "helium",
168 - sourceProfileDirectory: "Default",
169 - targetProfileId,
170 - });
171 -
172 - return Effect.gen(function* () {
173 - yield* request("a", "b");
174 - yield* request("a::b", DEFAULT_BROWSER_PROFILE_ID);
175 -
176 - expect(received[0]).toMatchObject(PreviewIpc.resolvePartitionScope("a", "b"));
177 - expect(received[1]).toMatchObject(
178 - PreviewIpc.resolvePartitionScope("a::b", DEFAULT_BROWSER_PROFILE_ID),
179 - );
180 - expect(received[0]?.namespace).toBe("profile");
181 - expect(received[1]?.namespace).toBeUndefined();
182 - }).pipe(Effect.provideService(BrowserImport.BrowserImport, browserImport));
183 - });
139 });
apps/desktop/src/ipc/methods/snapShot.test.ts
-30
@@ -67,36 +67,6 @@ describe("window capture IPC", () => {
67 );
68 });
69
70 - it.effect("uses only the file returned by the native custom config picker", () => {
71 - let path: string | undefined;
72 - return Effect.gen(function* () {
73 - yield* previewSnapShotConfig.handler(
74 - { operation: "install", chooseFile: true },
75 - { sender: { id: 7 } },
76 - );
77 - assert.equal(path, "/chosen/config.kdl");
78 - }).pipe(
79 - Effect.provide(
80 - Layer.mergeAll(
81 - Layer.succeed(ElectronWindow.ElectronWindow, {
82 - main: Effect.succeedSome({ webContents: { id: 7 } }),
83 - } as ElectronWindow.ElectronWindow["Service"]),
84 - Layer.succeed(DesktopSnapShot.DesktopSnapShot, {
85 - state: Effect.succeed({ linuxBackend: "niri" }),
86 - previewConfig: (_: unknown, selected: string) =>
87 - Effect.sync(() => {
88 - path = selected;
89 - return configPreview;
90 - }),
91 - } as unknown as DesktopSnapShot.DesktopSnapShot["Service"]),
92 - Layer.succeed(ElectronDialog.ElectronDialog, {
93 - pickFiles: () => Effect.succeed(["/chosen/config.kdl"]),
94 - } as unknown as ElectronDialog.ElectronDialog["Service"]),
95 - ),
96 - ),
97 - );
98 - });
99 -
70 it.effect("allows capture setup only from the trusted main renderer", () => {
71 const actions: string[] = [];
72 return Effect.gen(function* () {
apps/desktop/src/ipc/methods/sshEnvironment.test.ts
-31
@@ -34,37 +34,6 @@ function layerHttpClient(
34 }
35
36 describe("SSH environment IPC", () => {
37 - it.effect("fetches and decodes the remote environment descriptor", () => {
38 - const requestUrls: string[] = [];
39 - const layer = layerHttpClient((request) =>
40 - Effect.sync(() => {
41 - requestUrls.push(request.url);
42 - return jsonResponse(request, {
43 - environmentId: "remote-env",
44 - label: "Remote Devbox",
45 - platform: { os: "linux", arch: "x64" },
46 - serverVersion: "1.2.3",
47 - capabilities: { repositoryIdentity: true },
48 - });
49 - }),
50 - );
51 -
52 - return Effect.gen(function* () {
53 - const descriptor = yield* fetchSshEnvironmentDescriptor.handler({
54 - httpBaseUrl: "http://127.0.0.1:41773/",
55 - });
56 -
57 - assert.deepEqual(descriptor, {
58 - environmentId: "remote-env",
59 - label: "Remote Devbox",
60 - platform: { os: "linux", arch: "x64" },
61 - serverVersion: "1.2.3",
62 - capabilities: { repositoryIdentity: true },
63 - });
64 - assert.deepEqual(requestUrls, ["http://127.0.0.1:41773/.well-known/t3/environment"]);
65 - }).pipe(Effect.provide(layer));
66 - });
67 -
37 it.effect("rejects non-loopback HTTP endpoints before issuing a request", () => {
38 let requestCount = 0;
39 const layer = layerHttpClient((request) =>
apps/desktop/src/permissions/MacPermissionHelper.test.ts
-27
@@ -1,8 +1,6 @@
1 import { afterEach, beforeEach, expect, it, vi } from "vite-plus/test";
2 -import * as Electron from "electron";
2 import { MacPermissionHelper } from "./MacPermissionHelper.ts";
3 import type { SettingsWindow } from "./MacSettingsWindow.ts";
5 -import { MAC_PERMISSION_HELPER_CHANNEL } from "../ipc/channels.ts";
4
5 const mocks = vi.hoisted(() => ({
6 granted: false,
@@ -110,31 +108,6 @@ afterEach(() => {
108 const iconPaths = ["/bundle/prod-resources/icon.png"];
109 const open = () =>
110 helper.show("accessibility", "/bundle/mac-permission-preload.cjs", null, iconPaths);
113 -function send(action: string, trusted = true) {
114 - const window = windows.at(-1)!;
115 - Electron.ipcMain.emit(
116 - MAC_PERMISSION_HELPER_CHANNEL,
117 - {
118 - sender: trusted ? window.webContents : {},
119 - senderFrame: window.webContents.mainFrame,
120 - },
121 - action,
122 - );
123 -}
124 -it("drags the running app bundle only for the helper's own renderer", async () => {
125 - await open();
126 - send("drag", false);
127 - expect(mocks.startDrag).not.toHaveBeenCalled();
128 - send("drag");
129 - expect(mocks.createFromPath).toHaveBeenCalledWith("/bundle/prod-resources/icon.png");
130 - expect(mocks.startDrag).toHaveBeenCalledWith({
131 - file: "/Applications/T3 Code (Nightly).app",
132 - icon: mocks.createFromPath.mock.results[0]!.value.resize(),
133 - });
134 - send("finder");
135 - expect(mocks.showItemInFolder).toHaveBeenCalledWith("/Applications/T3 Code (Nightly).app");
136 -});
137 -
111 it("does not reopen a superseded helper when its initial probe completes", async () => {
112 const pending = Promise.withResolvers<boolean>();
113 const first = helper.show(
apps/desktop/src/preview/BrowserImport/ChromiumCookies.test.ts
-39
@@ -47,13 +47,6 @@ describe("cookieScope", () => {
47 });
48 });
49
50 - it("preserves a domain cookie's leading dot", () => {
51 - expect(cookieScope(".example.test", "/app", true)).toEqual({
52 - url: "https://example.test/app",
53 - domain: ".example.test",
54 - });
55 - });
56 -
50 it("brackets bare IPv6 hosts without duplicating existing brackets", () => {
51 expect(cookieScope("::1", "/", false)).toEqual({
52 url: "http://[::1]/",
@@ -334,38 +327,6 @@ describe("readChromiumCookieDatabase", () => {
327 }).pipe(Effect.provide(NodeServices.layer), Effect.scoped),
328 );
329
337 - it.effect("preserves arbitrary long encrypted values from pre-24 schemas", () =>
338 - Effect.gen(function* () {
339 - const fileSystem = yield* FileSystem.FileSystem;
340 - const directory = yield* fileSystem.makeTempDirectoryScoped({
341 - prefix: "t3code-chromium-cookies-",
342 - });
343 - const filename = `${directory}/Cookies`;
344 - const key = Buffer.from("0123456789abcdef");
345 - const value = "x".repeat(32) + " legacy value";
346 -
347 - yield* Effect.gen(function* () {
348 - const sql = yield* SqlClient.SqlClient;
349 - yield* sql`create table meta (key text primary key, value text not null)`;
350 - yield* sql`insert into meta values ('version', 23)`;
351 - yield* sql`
352 - create table cookies (
353 - host_key text not null, name text not null, value text not null,
354 - encrypted_value blob not null, path text not null, expires_utc integer not null,
355 - is_secure integer not null, is_httponly integer not null, samesite integer not null,
356 - top_frame_site_key text not null default ''
357 - )
358 - `;
359 - yield* sql`insert into cookies (host_key, name, value, encrypted_value, path, expires_utc, is_secure, is_httponly, samesite) values
360 - ('legacy.example', 'legacy', '', ${encryptV10(value, key)}, '/', 0, 0, 0, 0)`;
361 - }).pipe(Effect.provide(NodeSqliteClient.layer({ filename })));
362 -
363 - const result = yield* readChromiumCookieDatabase(filename, { cbcV10: key }, "darwin");
364 - expect(result.cookies[0]?.value).toBe(value);
365 - expect(result.undecryptable).toBe(0);
366 - }).pipe(Effect.provide(NodeServices.layer), Effect.scoped),
367 - );
368 -
330 it.effect("treats unversioned encrypted values as legacy plaintext on macOS and Linux", () =>
331 Effect.gen(function* () {
332 const fileSystem = yield* FileSystem.FileSystem;
apps/desktop/src/preview/BrowserImport/ChromiumKeys.test.ts
-35
@@ -146,28 +146,6 @@ describe("Linux Chromium secrets", () => {
146 ),
147 );
148
149 - it.effect("looks up the browser's libsecret application attribute", () => {
150 - let captured: CapturedCommand | undefined;
151 - return Effect.gen(function* () {
152 - const keys = yield* resolveChromiumKeys({
153 - platform: "linux",
154 - keychainService: "ignored macOS service",
155 - keychainAccount: "ignored macOS account",
156 - linuxSecretApplication: "msedge",
157 - });
158 -
159 - expect(captured?.command).toBe("/bundled/browser-secret/t3-browser-secret");
160 - expect(captured?.args).toEqual(["msedge"]);
161 - expect(captured?.options.stdin).toBe("ignore");
162 - expect(keys.cbcV10).toHaveLength(16);
163 - expect(keys.cbcV11).toHaveLength(16);
164 - }).pipe(
165 - Effect.provide(
166 - layerHelper({ stdout: "linux-secret", capture: (value) => (captured = value) }),
167 - ),
168 - );
169 - });
170 -
149 it.effect("preserves trailing whitespace in the stored secret", () =>
150 Effect.gen(function* () {
151 const secret = yield* readLinuxSecret("chrome");
@@ -220,19 +198,6 @@ describe("Linux Chromium secrets", () => {
198 );
199 },
200 );
223 -
224 - it.effect("keeps the v10 fallback when no matching v11 secret exists", () =>
225 - Effect.gen(function* () {
226 - const keys = yield* resolveChromiumKeys({
227 - platform: "linux",
228 - keychainService: undefined,
229 - keychainAccount: undefined,
230 - linuxSecretApplication: "vivaldi",
231 - });
232 - expect(keys.cbcV10).toHaveLength(16);
233 - expect(keys.cbcV11).toBeUndefined();
234 - }).pipe(Effect.provide(layerHelper({ exitCode: 2 }))),
235 - );
201 });
202
203 describe("Windows Chromium secrets", () => {
apps/desktop/src/preview/BrowserImport/SafariCookies.test.ts
-84
@@ -11,7 +11,6 @@ import {
11 parseBinaryCookies,
12 readSafariCookies,
13 safariAccessDenied,
14 - safariAccessGranted,
14 SafariCookieReadError,
15 } from "./SafariCookies.ts";
16
@@ -180,18 +179,6 @@ describe("parseBinaryCookies", () => {
179 );
180 });
181
183 - it("rejects a record whose declared size runs past its page", () => {
184 - const valid = encodeBinaryCookies([
185 - { domain: "a.test", name: "n", path: "/", value: "v", expiry: 1_000, flags: 0 },
186 - ]);
187 - const pageStart = 8 + 4;
188 - const recordStart = pageStart + valid.readUInt32LE(pageStart + 8);
189 - const corrupt = Buffer.from(valid);
190 - corrupt.writeUInt32LE(0xffff, recordStart);
191 -
192 - expect(() => parseBinaryCookies(corrupt)).toThrow(SafariCookieReadError);
193 - });
194 -
182 it("rejects record offsets that point into the page header or an earlier record", () => {
183 const valid = encodeBinaryCookies([
184 { domain: "a.test", name: "n", path: "/", value: "v", expiry: 1_000, flags: 0 },
@@ -211,22 +198,6 @@ describe("parseBinaryCookies", () => {
198 expect(parseBinaryCookies(valid)).toHaveLength(2);
199 });
200
214 - it("rejects string offsets that point into the record header", () => {
215 - const valid = encodeBinaryCookies([
216 - { domain: "a.test", name: "n", path: "/", value: "v", expiry: 1_000, flags: 0 },
217 - ]);
218 - const pageStart = 8 + 4;
219 - const recordStart = pageStart + valid.readUInt32LE(pageStart + 8);
220 -
221 - for (const offsetField of [16, 20, 24, 28]) {
222 - const corrupt = Buffer.from(valid);
223 - corrupt.writeUInt32LE(55, recordStart + offsetField);
224 - expect(() => parseBinaryCookies(corrupt), `offset field ${offsetField}`).toThrow(
225 - SafariCookieReadError,
226 - );
227 - }
228 - });
229 -
201 it("accepts the checksum and property-list trailer Safari writes", () => {
202 const file = encodeBinaryCookies([
203 { domain: "a.test", name: "c", path: "/", value: "v", flags: 0, expiry: 0 },
@@ -239,24 +210,6 @@ describe("parseBinaryCookies", () => {
210 expect(parseBinaryCookies(Buffer.concat([file, checksum]))).toHaveLength(1);
211 expect(parseBinaryCookies(Buffer.concat([file, checksum, plistLength, plist]))).toHaveLength(1);
212 });
242 -
243 - it("rejects a jar whose page table stops short of its contents", () => {
244 - const first = encodeBinaryCookies([
245 - { domain: "a.test", name: "c", path: "/", value: "v", flags: 0, expiry: 0 },
246 - ]);
247 - const extraPage = encodeBinaryCookies([
248 - { domain: "b.test", name: "d", path: "/", value: "w", flags: 0, expiry: 0 },
249 - ]).subarray(12);
250 -
251 - expect(() => parseBinaryCookies(Buffer.concat([first, extraPage]))).toThrow(
252 - SafariCookieReadError,
253 - );
254 - const badLength = Buffer.alloc(4);
255 - badLength.writeUInt32BE(99, 0);
256 - expect(() =>
257 - parseBinaryCookies(Buffer.concat([first, Buffer.alloc(8), badLength, Buffer.from("x")])),
258 - ).toThrow(SafariCookieReadError);
259 - });
213 });
214
215 describe("readSafariCookies", () => {
@@ -284,26 +237,6 @@ describe("readSafariCookies", () => {
237 });
238
239 describe("safariAccessDenied", () => {
287 - const eperm = PlatformError.systemError({
288 - _tag: "Unknown",
289 - module: "FileSystem",
290 - method: "open",
291 - pathOrDescriptor: "/protected/Cookies.binarycookies",
292 - cause: Object.assign(new Error("operation not permitted"), { code: "EPERM" }),
293 - });
294 - const denied = (error: PlatformError.PlatformError) =>
295 - FileSystem.layerNoop({ open: () => Effect.fail(error) });
296 -
297 - it.effect("reports TCC's EPERM as a missing Full Disk Access grant", () =>
298 - Effect.gen(function* () {
299 - assert.isTrue(
300 - yield* safariAccessDenied("/protected/Cookies.binarycookies").pipe(
301 - Effect.provide(denied(eperm)),
302 - ),
303 - );
304 - }),
305 - );
306 -
240 it.effect("does not read a readable jar, or any other failure, as denied", () =>
241 Effect.gen(function* () {
242 const fileSystem = yield* FileSystem.FileSystem;
@@ -324,20 +257,3 @@ describe("isPermissionDenied", () => {
257 expect(isPermissionDenied(platformError("PermissionDenied", "EACCES"))).toBe(false);
258 });
259 });
327 -
328 -describe("safariAccessGranted", () => {
329 - it.effect("only reports a successful read-only open as granted", () =>
330 - Effect.gen(function* () {
331 - const fileSystem = yield* FileSystem.FileSystem;
332 - const directory = yield* fileSystem.makeTempDirectoryScoped({
333 - prefix: "t3-safari-permission-",
334 - });
335 - const jar = `${directory}/Cookies.binarycookies`;
336 - assert.isFalse(yield* safariAccessGranted(jar));
337 - yield* fileSystem.writeFileString(jar, "no cookie parsing needed");
338 - assert.isTrue(yield* safariAccessGranted(jar));
339 - yield* fileSystem.remove(jar);
340 - assert.isFalse(yield* safariAccessGranted(jar));
341 - }).pipe(Effect.provide(NodeServices.layer), Effect.scoped),
342 - );
343 -});
apps/desktop/src/preview/BrowserSession.test.ts
-46
@@ -250,50 +250,4 @@ describe("BrowserSession", () => {
250 assert.strictEqual(created.clearStorageData.mock.calls.length, 1);
251 }).pipe(Effect.provide(layer)),
252 );
253 -
254 - it.effect("correlates clear failures while still attempting every session", () =>
255 - Effect.gen(function* () {
256 - const browserSessions = yield* BrowserSession.BrowserSession;
257 - yield* browserSessions.getSession("scope-a");
258 - yield* browserSessions.getSession("scope-b");
259 - const firstPartition = yield* browserSessions.getPartition("scope-a");
260 - const secondPartition = yield* browserSessions.getPartition("scope-b");
261 - const firstSession = sessions.get(firstPartition);
262 - const secondSession = sessions.get(secondPartition);
263 - assert.isDefined(firstSession);
264 - assert.isDefined(secondSession);
265 -
266 - const storageCause = new Error("storage clear failed");
267 - secondSession.clearStorageData.mockImplementationOnce(() => Promise.reject(storageCause));
268 - const storageError = yield* browserSessions.clearCookies().pipe(Effect.flip);
269 -
270 - assert.instanceOf(storageError, BrowserSession.BrowserSessionStorageClearError);
271 - assert.equal(storageError.partition, secondPartition);
272 - assert.strictEqual(storageError.cause, storageCause);
273 - assert.equal(
274 - storageError.message,
275 - `Failed to clear desktop preview browser storage for partition ${secondPartition}.`,
276 - );
277 - assert.notInclude(storageError.message, storageCause.message);
278 - for (const browserSession of sessions.values()) {
279 - assert.strictEqual(browserSession.clearStorageData.mock.calls.length, 1);
280 - }
281 -
282 - const cacheCause = new Error("cache clear failed");
283 - firstSession.clearCache.mockImplementationOnce(() => Promise.reject(cacheCause));
284 - const cacheError = yield* browserSessions.clearCache().pipe(Effect.flip);
285 -
286 - assert.instanceOf(cacheError, BrowserSession.BrowserSessionCacheClearError);
287 - assert.equal(cacheError.partition, firstPartition);
288 - assert.strictEqual(cacheError.cause, cacheCause);
289 - assert.equal(
290 - cacheError.message,
291 - `Failed to clear the desktop preview browser cache for partition ${firstPartition}.`,
292 - );
293 - assert.notInclude(cacheError.message, cacheCause.message);
294 - for (const browserSession of sessions.values()) {
295 - assert.strictEqual(browserSession.clearCache.mock.calls.length, 1);
296 - }
297 - }).pipe(Effect.provide(layer)),
298 - );
253 });
apps/desktop/src/preview/FaviconCapture.test.ts
-30
@@ -386,21 +386,6 @@ describe("captureFavicon", () => {
386 expect(executeJavaScriptInIsolatedWorld).not.toHaveBeenCalled();
387 });
388
389 - it("rejects JPEGs with multiple frame headers before rasterization", async () => {
390 - const buffer = Buffer.concat([sourceJpeg(4096, 4096), sourceJpeg(1, 1).subarray(2)]);
391 - const { webContents, executeJavaScriptInIsolatedWorld } = makeWebContents();
392 -
393 - expect(
394 - await captureFavicon({
395 - webContents,
396 - pageUrl: "https://example.com/page",
397 - candidates: [`data:image/jpeg;base64,${buffer.toString("base64")}`],
398 - signal: new AbortController().signal,
399 - }),
400 - ).toEqual({ kind: "none" });
401 - expect(executeJavaScriptInIsolatedWorld).not.toHaveBeenCalled();
402 - });
403 -
389 it.each([
390 ["GIF", "image/gif", sourceGif(4096, 4096)],
391 ["GIF frame", "image/gif", sourceGif(1, 1, 4096, 4096)],
@@ -454,21 +439,6 @@ describe("captureFavicon", () => {
439 expect(executeJavaScriptInIsolatedWorld).not.toHaveBeenCalled();
440 });
441
457 - it("ignores output that is not a bounded PNG data URL", async () => {
458 - const { webContents } = makeWebContents({
459 - rasterize: async () => "data:image/svg+xml;base64,c3Zn",
460 - });
461 -
462 - expect(
463 - await captureFavicon({
464 - webContents,
465 - pageUrl: "https://example.com/page",
466 - candidates: [SOURCE_PNG_URL],
467 - signal: new AbortController().signal,
468 - }),
469 - ).toEqual({ kind: "none" });
470 - });
471 -
442 it("coalesces queued rasterizations so only the latest pending capture launches", async () => {
443 let resolveFirst!: (value: unknown) => void;
444 let executions = 0;
apps/desktop/src/preview/GuestInput.test.ts
+1
@@ -64,6 +64,7 @@ describe("CDP key events as Electron input", () => {
64 ]);
65 });
66
67 + // regression: #18556 agent typing in a preview tab landed in the app instead of the guest
68 it("names arrows and function keys as Electron accelerators", () => {
69 expect(toKeyboardInputEvents({ type: "keyUp", key: "ArrowLeft", modifiers: 3 })).toEqual([
70 { type: "keyUp", keyCode: "Left", modifiers: ["alt", "control"] },
apps/desktop/src/preview/Manager.test.ts
+1 -56
@@ -922,39 +922,6 @@ describe("PreviewManager", () => {
922 ),
923 );
924
925 - effectIt.effect("allows an identical retry after an undecodable capture", () =>
926 - withManager((manager) =>
927 - Effect.gen(function* () {
928 - const changes = makeChangeSignal();
929 - let rasterizations = 0;
930 - const preview = makeFaviconWebContents({
931 - changes,
932 - rasterize: async () => (++rasterizations === 1 ? null : TEST_FAVICON),
933 - });
934 - fromId.mockReturnValue(preview.webContents);
935 - const states: PreviewManager.PreviewTabState[] = [];
936 - yield* manager.subscribeStateChanges((_tabId, state) =>
937 - Effect.sync(() => {
938 - states.push(state);
939 - changes.notify();
940 - }),
941 - );
942 - yield* manager.createTab("tab_favicon_retry");
943 - yield* manager.registerWebview("tab_favicon_retry", 42);
944 - const faviconUpdated = preview.listeners.get("page-favicon-updated")!;
945 -
946 - faviconUpdated({} as never, ["http://localhost:3200/favicon.png"] as never);
947 - yield* changes.until(() => rasterizations === 1);
948 - yield* flushMicrotasks();
949 - faviconUpdated({} as never, ["http://localhost:3200/favicon.png"] as never);
950 - yield* changes.until(() => states.at(-1)?.favicon !== undefined);
951 -
952 - expect(rasterizations).toBe(2);
953 - expect(states.at(-1)?.favicon?.dataUrl).toBe(TEST_FAVICON);
954 - }),
955 - ),
956 - );
957 -
925 effectIt.effect("does not publish a capture invalidated by navigation", () =>
926 withManager((manager) =>
927 Effect.gen(function* () {
@@ -1253,29 +1220,6 @@ describe("PreviewManager", () => {
1220 };
1221 };
1222
1256 - effectIt.effect("still registers a guest that refuses the mute reassert", () =>
1257 - withManager((manager) =>
1258 - Effect.gen(function* () {
1259 - const first = makeAudioWebContents(42);
1260 - fromId.mockReturnValue(first.wc);
1261 - yield* manager.createTab("tab_audio_attach_fail");
1262 - yield* manager.registerWebview("tab_audio_attach_fail", 42);
1263 - yield* Effect.yieldNow;
1264 - yield* manager.setAudioMuted("tab_audio_attach_fail", true);
1265 -
1266 - const replacement = makeAudioWebContents(43);
1267 - replacement.setAudioMuted.mockImplementationOnce(() => undefined);
1268 - replacement.setAudioMuted.mockImplementationOnce(() => {
1269 - throw new Error("guest went away");
1270 - });
1271 - fromId.mockReturnValue(replacement.wc);
1272 -
1273 - const exit = yield* manager.registerWebview("tab_audio_attach_fail", 43).pipe(Effect.exit);
1274 - expect(Exit.isSuccess(exit)).toBe(true);
1275 - }),
1276 - ),
1277 - );
1278 -
1223 effectIt.effect("reconciles audibility that changed while the guest attached", () =>
1224 withManager((manager) =>
1225 Effect.gen(function* () {
@@ -2552,6 +2496,7 @@ describe("PreviewManager", () => {
2496 }),
2497 );
2498
2499 + // regression: #18441 zero-area strokes on the viewport edge must still get a screenshot crop
2500 effectIt.effect.each([
2501 {
2502 name: "zero-width SVG line on the left edge",
apps/desktop/src/preview/PasskeyBridge.test.ts
-12
@@ -149,18 +149,6 @@ describe("installPasskeyBridge", () => {
149 assert.instanceOf(fetched, TypeError);
150 });
151
152 - it("refuses when the main process has no handler for the page", async () => {
153 - const { credentials } = install(() => {
154 - throw new Error("Error invoking remote method 'preview:passkey-get': No handler registered");
155 - });
156 -
157 - const error = await credentials
158 - .get({ publicKey: { challenge: new Uint8Array([1]) } })
159 - .catch((caught: unknown) => caught);
160 - assert.instanceOf(error, DOMException);
161 - assert.strictEqual((error as DOMException).name, "NotAllowedError");
162 - });
163 -
152 it("rejects as soon as the page aborts, without waiting on the system sheet", async () => {
153 const { credentials } = install(() => new Promise(() => {}));
154 const controller = new AbortController();
apps/desktop/src/preview/PickedElementPayload.test.ts
-4
@@ -31,10 +31,6 @@ function validPayload(overrides?: Record<string, unknown>): Record<string, unkno
31 }
32
33 describe("isPickedElementPayload", () => {
34 - it("accepts a complete, well-typed payload", () => {
35 - expect(isPickedElementPayload(validPayload())).toBe(true);
36 - });
37 -
34 it("rejects non-finite numeric line/column numbers", () => {
35 expect(
36 isPickedElementPayload(
apps/desktop/src/preview/WebviewPreferences.test.ts
-8
@@ -32,12 +32,4 @@ describe("PREVIEW_WEBVIEW_PREFERENCES", () => {
32 it("keeps the renderer sandbox enabled (so the page cannot reach Node APIs)", () => {
33 expect(parsed["sandbox"]).toBe("true");
34 });
35 -
36 - it("disables nodeIntegration (defense in depth — page never gets Node)", () => {
37 - expect(parsed["nodeIntegration"]).toBe("false");
38 - });
39 -
40 - it("contains no whitespace (Electron's parser does not trim)", () => {
41 - expect(PREVIEW_WEBVIEW_PREFERENCES).not.toMatch(/\s/);
42 - });
35 });
apps/desktop/src/settings/DesktopAppSettings.test.ts
-63
@@ -3,7 +3,6 @@ import { assert, describe, it } from "@effect/vitest";
3 import * as Effect from "effect/Effect";
4 import * as FileSystem from "effect/FileSystem";
5 import * as Layer from "effect/Layer";
6 -import * as Option from "effect/Option";
6 import * as Schema from "effect/Schema";
7
8 import * as DesktopConfig from "../app/DesktopConfig.ts";
@@ -110,53 +109,6 @@ describe("DesktopSettings", () => {
109 ),
110 );
111
113 - it.effect("loads persisted settings and applies semantic updates", () =>
114 - withSettings(
115 - Effect.gen(function* () {
116 - const settings = yield* DesktopAppSettings.DesktopAppSettings;
117 - yield* writeSettingsPatch({
118 - linuxPasswordStore: "gnome-libsecret",
119 - serverExposureMode: "network-accessible",
120 - tailscaleServeEnabled: true,
121 - tailscaleServePort: 8443,
122 - updateChannel: "latest",
123 - updateChannelConfiguredByUser: true,
124 - });
125 -
126 - assert.deepEqual(yield* settings.load, {
127 - linuxPasswordStore: "gnome-libsecret",
128 - localEnvironmentEnabled: true,
129 - mainWindowBounds: null,
130 - mainWindowMaximized: false,
131 - serverExposureMode: "network-accessible",
132 - tailscaleServeEnabled: true,
133 - tailscaleServePort: 8443,
134 - updateChannel: "latest",
135 - updateChannelConfiguredByUser: true,
136 - wslBackendEnabled: false,
137 - wslOnly: false,
138 - wslDistro: null,
139 - } satisfies DesktopAppSettings.DesktopSettings);
140 -
141 - const exposure = yield* settings.setServerExposureMode("local-only");
142 - assert.isTrue(exposure.changed);
143 - assert.equal(exposure.settings.serverExposureMode, "local-only");
144 -
145 - const tailscale = yield* settings.setTailscaleServe({
146 - enabled: true,
147 - port: Option.some(9443),
148 - });
149 - assert.isTrue(tailscale.changed);
150 - assert.equal(tailscale.settings.tailscaleServePort, 9443);
151 -
152 - const updateChannel = yield* settings.setUpdateChannel("nightly");
153 - assert.isTrue(updateChannel.changed);
154 - assert.equal(updateChannel.settings.updateChannel, "nightly");
155 - assert.equal(updateChannel.settings.updateChannelConfiguredByUser, true);
156 - }),
157 - ),
158 - );
159 -
112 it.effect("falls back to defaults when the settings file is malformed", () =>
113 withSettings(
114 Effect.gen(function* () {
@@ -406,19 +358,4 @@ describe("DesktopSettings", () => {
358 }),
359 ),
360 );
409 -
410 - it.effect("drops invalid persisted wsl distro values on load", () =>
411 - withSettings(
412 - Effect.gen(function* () {
413 - const settings = yield* DesktopAppSettings.DesktopAppSettings;
414 - yield* writeSettingsPatch({
415 - wslBackendEnabled: true,
416 - wslDistro: "bad/name",
417 - });
418 - const loaded = yield* settings.load;
419 - assert.equal(loaded.wslBackendEnabled, true);
420 - assert.equal(loaded.wslDistro, null);
421 - }),
422 - ),
423 - );
361 });
apps/desktop/src/settings/DesktopClientSettings.test.ts
-10
@@ -110,15 +110,6 @@ const withClientSettings = <A, E, R>(
110 }).pipe(Effect.provide(NodeServices.layer), Effect.scoped);
111
112 describe("DesktopClientSettings", () => {
113 - it.effect("returns none when no client settings file exists", () =>
114 - withClientSettings(
115 - Effect.gen(function* () {
116 - const settings = yield* DesktopClientSettings.DesktopClientSettings;
117 - assert.isTrue(Option.isNone(yield* settings.get));
118 - }),
119 - ),
120 - );
121 -
113 it.effect("saves through a symlinked client settings file without replacing the link", () =>
114 withClientSettings(
115 Effect.gen(function* () {
@@ -249,7 +240,6 @@ describe("DesktopClientSettings", () => {
240
241 it.effect.each([
242 { label: "malformed JSON", contents: "{not-json" },
252 - { label: "invalid direct settings", contents: '{"fontSizeCode":"large"}' },
243 { label: "invalid legacy settings", contents: '{"settings":{"fontSizeCode":"large"}}' },
244 ])("reports $label without treating the settings file as absent", (document) =>
245 withClientSettings(
apps/desktop/src/settings/DesktopSavedEnvironments.test.ts
-86
@@ -4,10 +4,8 @@ import { EnvironmentId, type PersistedSavedEnvironmentRecord } from "@t3tools/co
4 import * as Effect from "effect/Effect";
5 import * as Base64 from "effect/encoding/Base64";
6 import * as FileSystem from "effect/FileSystem";
7 -import * as Path from "effect/Path";
7 import * as Layer from "effect/Layer";
8 import * as Option from "effect/Option";
10 -import * as PlatformError from "effect/PlatformError";
9 import * as Schema from "effect/Schema";
10
11 import * as DesktopConfig from "../app/DesktopConfig.ts";
@@ -205,30 +203,6 @@ describe("DesktopSavedEnvironments", () => {
203 ),
204 );
205
208 - it.effect("reports invalid saved secret encoding without exposing the secret", () =>
209 - withSavedEnvironments(
210 - Effect.gen(function* () {
211 - const environment = yield* DesktopEnvironment.DesktopEnvironment;
212 - const savedEnvironments = yield* DesktopSavedEnvironments.DesktopSavedEnvironments;
213 - yield* seedSavedEnvironmentRegistry("%%%");
214 -
215 - const error = yield* savedEnvironments
216 - .getSecret(savedRegistryRecord.environmentId)
217 - .pipe(Effect.flip);
218 - assert.instanceOf(error, DesktopSavedEnvironments.DesktopSavedEnvironmentSecretDecodeError);
219 - assert.equal(error.environmentId, savedRegistryRecord.environmentId);
220 - assert.equal(error.registryPath, environment.savedEnvironmentRegistryPath);
221 - assert.equal(error.field, "encryptedBearerToken");
222 - assert.exists(error.cause);
223 - assert.equal(
224 - error.message,
225 - `Failed to decode encryptedBearerToken for environment ${savedRegistryRecord.environmentId} at ${environment.savedEnvironmentRegistryPath}.`,
226 - );
227 - assert.notInclude(error.message, "%%%");
228 - }),
229 - ),
230 - );
231 -
206 it.effect("returns no secret while encryption is unavailable", () =>
207 withSavedEnvironments(
208 Effect.gen(function* () {
@@ -243,64 +217,4 @@ describe("DesktopSavedEnvironments", () => {
217 { availableSecretStorage: false },
218 ),
219 );
246 -
247 - it.effect("surfaces malformed saved environment documents", () =>
248 - withSavedEnvironments(
249 - Effect.gen(function* () {
250 - const environment = yield* DesktopEnvironment.DesktopEnvironment;
251 - const fileSystem = yield* FileSystem.FileSystem;
252 - const savedEnvironments = yield* DesktopSavedEnvironments.DesktopSavedEnvironments;
253 - yield* fileSystem.makeDirectory(environment.stateDir, { recursive: true });
254 - yield* fileSystem.writeFileString(environment.savedEnvironmentRegistryPath, "{not-json");
255 -
256 - const registryError = yield* savedEnvironments.getRegistry.pipe(Effect.flip);
257 - assert.instanceOf(
258 - registryError,
259 - DesktopSavedEnvironments.DesktopSavedEnvironmentsDocumentDecodeError,
260 - );
261 - assert.equal(registryError.registryPath, environment.savedEnvironmentRegistryPath);
262 - assert.exists(registryError.cause);
263 - const secretError = yield* savedEnvironments
264 - .getSecret(savedRegistryRecord.environmentId)
265 - .pipe(Effect.flip);
266 - assert.instanceOf(
267 - secretError,
268 - DesktopSavedEnvironments.DesktopSavedEnvironmentsDocumentDecodeError,
269 - );
270 - }),
271 - ),
272 - );
273 -
274 - it.effect("reports saved environment filesystem reads separately from document decoding", () =>
275 - Effect.gen(function* () {
276 - const path = yield* Path.Path;
277 - const baseFileSystem = yield* FileSystem.FileSystem;
278 - const baseDir = yield* baseFileSystem.makeTempDirectoryScoped({
279 - prefix: "t3-desktop-saved-environments-test-",
280 - });
281 - const registryPath = path.join(baseDir, "userdata", "saved-environments.json");
282 - const permissionError = PlatformError.systemError({
283 - _tag: "PermissionDenied",
284 - module: "FileSystem",
285 - method: "readFileString",
286 - pathOrDescriptor: registryPath,
287 - });
288 - const layerFileSystem = Layer.succeed(
289 - FileSystem.FileSystem,
290 - FileSystem.makeNoop({
291 - readFileString: () => Effect.fail(permissionError),
292 - }),
293 - );
294 - const savedEnvironments = yield* DesktopSavedEnvironments.DesktopSavedEnvironments.pipe(
295 - Effect.provide(layer(baseDir, undefined, layerFileSystem)),
296 - );
297 -
298 - const error = yield* savedEnvironments.getRegistry.pipe(Effect.flip);
299 - assert.instanceOf(error, DesktopSavedEnvironments.DesktopSavedEnvironmentsReadError);
300 - assert.equal(error.registryPath, registryPath);
301 - assert.strictEqual(error.cause, permissionError);
302 - assert.equal(error.message, `Failed to read desktop saved environments at ${registryPath}.`);
303 - assert.notEqual(error.message, permissionError.message);
304 - }).pipe(Effect.provide(NodeServices.layer), Effect.scoped),
305 - );
220 });
apps/desktop/src/shell/DesktopShellEnvironment.test.ts
-46
@@ -141,29 +141,6 @@ describe("DesktopShellEnvironment", () => {
141 }),
142 );
143
144 - it.effect("tries the account shell before the platform fallback when SHELL has no PATH", () =>
145 - Effect.gen(function* () {
146 - const env: NodeJS.ProcessEnv = { SHELL: "/bin/missing", PATH: "/usr/bin" };
147 - const commands: string[] = [];
148 -
149 - yield* runShellEnvironment({
150 - env,
151 - platform: "linux",
152 - userShell: "/usr/local/bin/fish",
153 - handler: (command) => {
154 - if (command._tag !== "StandardCommand") return "";
155 - commands.push(command.command);
156 - return command.command === "/usr/local/bin/fish"
157 - ? envOutput({ PATH: "/home/test/.local/bin:/usr/bin" })
158 - : "";
159 - },
160 - });
161 -
162 - assert.deepEqual(commands, ["/bin/missing", "/usr/local/bin/fish"]);
163 - assert.equal(env.PATH, "/home/test/.local/bin:/usr/bin");
164 - }),
165 - );
166 -
144 it.effect("hydrates PATH and missing SSH_AUTH_SOCK from the login shell on macOS", () =>
145 Effect.gen(function* () {
146 const env: NodeJS.ProcessEnv = {
@@ -193,29 +170,6 @@ describe("DesktopShellEnvironment", () => {
170 }),
171 );
172
196 - it.effect("preserves inherited POSIX values when present", () =>
197 - Effect.gen(function* () {
198 - const env: NodeJS.ProcessEnv = {
199 - SHELL: "/bin/zsh",
200 - PATH: "/usr/bin",
201 - SSH_AUTH_SOCK: "/tmp/inherited.sock",
202 - };
203 -
204 - yield* runShellEnvironment({
205 - env,
206 - platform: "darwin",
207 - handler: () =>
208 - envOutput({
209 - PATH: "/opt/homebrew/bin:/usr/bin",
210 - SSH_AUTH_SOCK: "/tmp/login-shell.sock",
211 - }),
212 - });
213 -
214 - assert.equal(env.PATH, "/opt/homebrew/bin:/usr/bin");
215 - assert.equal(env.SSH_AUTH_SOCK, "/tmp/inherited.sock");
216 - }),
217 - );
218 -
173 it.effect("does not mix login-shell locale categories into an inherited locale", () =>
174 Effect.gen(function* () {
175 const env: NodeJS.ProcessEnv = {
apps/desktop/src/snapShot/CaptureShortcutConfig.test.ts
-32
@@ -48,12 +48,6 @@ it("reads without writing, then applies only the approved diff with a backup", a
48 expect(tools.validateNiri).toHaveBeenCalledOnce();
49 await expect(setup.apply(preview.id, "niri")).rejects.toThrow("expired");
50 });
51 -it("refuses apply without a preview or for the wrong desktop", async () => {
52 - await expect(setup.apply("invented", "niri")).rejects.toThrow("expired");
53 - const preview = await setup.preview(target(), install);
54 - await expect(setup.apply(preview.id, "hyprland")).rejects.toThrow("expired");
55 - expect(await NodeFSP.readFile(path, "utf8")).toBe(preview.before);
56 -});
51 it("rechecks Hyprland conflicts before writing", async () => {
52 const hypr = {
53 ...target(),
@@ -78,11 +72,6 @@ it("notices an optional include created while the diff is open", async () => {
72 await expect(setup.apply(preview.id, "niri")).rejects.toThrow("changed since");
73 expect(await NodeFSP.readFile(path, "utf8")).toBe(preview.before);
74 });
81 -it("invalidates an earlier proposal when another config is opened", async () => {
82 - const first = await setup.preview(target(), install);
83 - await setup.preview(target(), { ...install, shortcut: "Ctrl+Alt+Y" });
84 - await expect(setup.apply(first.id, "niri")).rejects.toThrow("expired");
85 -});
75 it("does not overwrite edits made after preview", async () => {
76 const preview = await setup.preview(target(), install);
77 await NodeFSP.appendFile(path, "// edited elsewhere\n");
@@ -241,27 +230,6 @@ it("detects conflicts in included Niri configs without changing either file", as
230 await expect(setup.preview(target(), install)).rejects.toThrow("already used");
231 expect((await NodeFSP.readdir(directory)).sort()).toEqual(["config.kdl", "keys.kdl"]);
232 });
244 -it("detects included config changes before applying", async () => {
245 - await NodeFSP.appendFile(path, 'include "keys.kdl"\n');
246 - const included = NodePath.join(directory, "keys.kdl");
247 - await NodeFSP.writeFile(included, "binds { Ctrl+Alt+Q { quit; } }");
248 - const preview = await setup.preview(target(), install);
249 - await NodeFSP.writeFile(included, "binds { Ctrl+Shift+2 { quit; } }");
250 - await expect(setup.apply(preview.id, "niri")).rejects.toThrow("changed since");
251 -});
252 -it("reports reload failure separately from a successfully saved config", async () => {
253 - const hypr = {
254 - ...target(),
255 - desktop: "hyprland" as const,
256 - path: NodePath.join(directory, "hyprland.conf"),
257 - };
258 - await NodeFSP.writeFile(hypr.path, "# preferences\n");
259 - const preview = await setup.preview(hypr, install);
260 - tools.reloadHyprland.mockRejectedValue(new Error("Compositor stopped"));
261 - const result = await setup.apply(preview.id, "hyprland");
262 - expect(result.warning).toContain("Config saved");
263 - expect(await NodeFSP.readFile(hypr.path, "utf8")).toBe(preview.after);
264 -});
233 it("does not edit Omarchy's shipped defaults", async () => {
234 const defaults = NodePath.join(directory, "omarchy", "default", "hypr");
235 await NodeFSP.mkdir(defaults, { recursive: true });
apps/desktop/src/snapShot/DesktopSnapShot.test.ts
-291
@@ -754,52 +754,6 @@ function concurrentCaptureFixture(platform: NodeJS.Platform, animations: boolean
754 };
755 }
756
757 -it.effect("reads and acknowledges queued captures through Effect services", () => {
758 - const captureId = "12345678-1234-1234-1234-123456789abc";
759 - const captureDirectory = "/state/snap-shots";
760 - const metadataPath = captureDirectory + "/" + captureId + ".json";
761 - const imagePath = captureDirectory + "/" + captureId + ".png";
762 - const removed: Array<string> = [];
763 - const metadata = JSON.stringify({
764 - id: captureId,
765 - name: "window.png",
766 - mimeType: "image/png",
767 - sizeBytes: 3,
768 - source: {
769 - kind: "snap-shot",
770 - capturedAt: "2026-08-24T11:00:00.000Z",
771 - appName: "Editor",
772 - windowTitle: "main.ts",
773 - },
774 - });
775 - const layer = layerTest("linux", {
776 - readDirectory: () => Effect.succeed([captureId + ".json", "invalid.json"]),
777 - readFileString: (filePath) => Effect.succeed(filePath === metadataPath ? metadata : "invalid"),
778 - readFile: () => Effect.succeed(new Uint8Array([1, 2, 3])),
779 - remove: (filePath) =>
780 - Effect.sync(() => {
781 - removed.push(filePath);
782 - }),
783 - });
784 -
785 - return Effect.scoped(
786 - Effect.gen(function* () {
787 - const service = yield* DesktopSnapShot.make;
788 - const pending = yield* service.listPending;
789 - assert.deepEqual(
790 - pending.map((capture) => capture.id),
791 - [captureId],
792 - );
793 -
794 - const capture = yield* service.read(captureId);
795 - assert.strictEqual(capture.dataUrl, "data:image/png;base64,AQID");
796 -
797 - yield* service.acknowledge(captureId);
798 - assert.deepEqual(removed.sort(), [imagePath, metadataPath].sort());
799 - }),
800 - ).pipe(Effect.provide(layer));
801 -});
802 -
757 it.effect.each(["darwin", "win32"] as const)(
758 "drops shortcut bursts during flight and accepts a fresh capture after landing on %s",
759 (platform) => {
@@ -1030,41 +984,6 @@ it.effect.each(["succeeds", "fails"] as const)(
984 },
985 );
986
1033 -it.effect("keeps newer native feedback when older accessibility persistence fails", () => {
1034 - const fixture = concurrentCaptureFixture("linux", true);
1035 - fixture.state.failFirstPersistence = true;
1036 - return Effect.scoped(
1037 - Effect.gen(function* () {
1038 - const service = yield* DesktopSnapShot.make;
1039 - yield* service.configure(fixture.settings);
1040 - fixture.first.pixels.resolve();
1041 - const first = yield* Effect.promise(fixture.trigger).pipe(
1042 - Effect.forkChild({ startImmediately: true }),
1043 - );
1044 - yield* Effect.promise(() => fixture.first.handoff.promise);
1045 - yield* TestClock.adjust("200 millis");
1046 - fixture.second.pixels.resolve();
1047 - const second = yield* Effect.promise(fixture.trigger).pipe(
1048 - Effect.forkChild({ startImmediately: true }),
1049 - );
1050 - yield* Effect.promise(() => fixture.second.handoff.promise);
1051 - fixture.first.context.resolve({ accessibleText: "Discord accessibility" });
1052 - yield* Fiber.join(first);
1053 -
1054 - assert.lengthOf(fixture.readyIds, 0);
1055 - assert.lengthOf(fixture.second.feedback.close.mock.calls, 0);
1056 - assert.lengthOf(fixture.second.feedback.complete.mock.calls, 0);
1057 - fixture.second.context.resolve({ accessibleText: "Explorer accessibility" });
1058 - yield* Fiber.join(second);
1059 - assert.lengthOf(fixture.readyIds, 1);
1060 - const newer = yield* service.read(fixture.readyIds[0]!);
1061 - assert.equal(newer.source.windowTitle, fixture.second.title);
1062 - yield* service.acknowledge(fixture.readyIds[0]!);
1063 - assert.lengthOf(fixture.second.feedback.complete.mock.calls, 1);
1064 - }).pipe(Effect.ensuring(Effect.sync(fixture.releaseAll))),
1065 - ).pipe(Effect.provide(fixture.layer), Effect.ensuring(Effect.sync(fixture.reset)));
1066 -});
1067 -
987 it.effect("matches Windows accessibility windows on a scaled display", () => {
988 const png = Buffer.from([1, 2, 3]);
989 const active = {
@@ -1227,75 +1146,6 @@ it.effect.each(["gnome", "niri", "kde", "hyprland"] as const)(
1146 },
1147 );
1148
1230 -it.effect("persists a window capture from a portal activation without a setup test", () => {
1231 - vi.stubEnv("XDG_SESSION_TYPE", "wayland");
1232 - linuxCaptureMock.mockClear().mockResolvedValueOnce({
1233 - png: Buffer.from([1, 2, 3]),
1234 - window: {
1235 - title: "Shortcut capture",
1236 - appName: "Text Editor",
1237 - appIdentifier: "org.kde.kwrite",
1238 - processId: 123,
1239 - bounds: { x: 0, y: 0, width: 700, height: 520 },
1240 - },
1241 - });
1242 - let metadata = "";
1243 - const writes: Uint8Array[] = [];
1244 - return Effect.scoped(
1245 - Effect.gen(function* () {
1246 - const service = yield* DesktopSnapShot.make;
1247 - yield* service.configure({
1248 - ...DEFAULT_CLIENT_SETTINGS,
1249 - snapShotEnabled: true,
1250 - snapShotIncludeAccessibility: false,
1251 - snapShotShortcut: {
1252 - key: "2",
1253 - ctrlKey: true,
1254 - shiftKey: true,
1255 - altKey: false,
1256 - metaKey: false,
1257 - modKey: false,
1258 - },
1259 - });
1260 - yield* Effect.promise(portalShortcutInstances[0]!.onCapture);
1261 - assert.lengthOf(linuxCaptureMock.mock.calls, 1);
1262 - assert.deepEqual(writes, [Buffer.from([1, 2, 3])]);
1263 - const saved = yield* decodePendingMetadata(metadata);
1264 - assert.equal(saved.source.windowTitle, "Shortcut capture");
1265 - assert.equal(saved.source.appIdentifier, "org.kde.kwrite");
1266 - const state = yield* service.state;
1267 - assert.isTrue(state.shortcutVerified);
1268 - assert.isNull(state.message);
1269 - const portal = portalShortcutInstances[0]!;
1270 - portal.state = {
1271 - shortcutRegistered: false,
1272 - shortcutPending: false,
1273 - shortcutMessage: "Permission revoked",
1274 - };
1275 - portal.onStateChanged();
1276 - const revoked = yield* service.state;
1277 - assert.isFalse(revoked.shortcutVerified);
1278 - assert.isFalse(revoked.shortcutRegistered);
1279 - }),
1280 - ).pipe(
1281 - Effect.provide(
1282 - layerTest("linux", {
1283 - makeDirectory: () => Effect.void,
1284 - rename: () => Effect.void,
1285 - writeFile: (_, bytes) =>
1286 - Effect.sync(() => {
1287 - writes.push(bytes);
1288 - }),
1289 - writeFileString: (_, text) =>
1290 - Effect.sync(() => {
1291 - metadata = text;
1292 - }),
1293 - }),
1294 - ),
1295 - Effect.ensuring(Effect.sync(() => vi.unstubAllEnvs())),
1296 - );
1297 -});
1298 -
1149 it("covers straddling captures and intervening monitors without spanning unrelated displays", () => {
1150 const displays = [
1151 { bounds: { x: -1_920, y: 0, width: 1_920, height: 1_080 } },
@@ -1605,8 +1455,6 @@ it.each(["darwin", "win32"] as const)(
1455
1456 it.each([
1457 ["darwin", "", "value", 650],
1608 - ["win32", "", "value", 650],
1609 - ["linux", "x11", "value", 650],
1458 ["linux", "wayland", "value", 650],
1459 ["darwin", "", "name", 100],
1460 ] as const)(
@@ -1914,64 +1762,6 @@ it("keeps a truncated element tree when the flat text read fails", async () => {
1762 );
1763 });
1764
1917 -it.effect("keeps snapshots disabled when client settings cannot be read at startup", () => {
1918 - const readError = new DesktopClientSettings.DesktopClientSettingsReadError({
1919 - operation: "read-file",
1920 - path: "/state/client-settings.json",
1921 - cause: new Error("unavailable"),
1922 - });
1923 -
1924 - return Effect.scoped(
1925 - Effect.gen(function* () {
1926 - const service = yield* DesktopSnapShot.make;
1927 - yield* service.initialize;
1928 - assert.isFalse((yield* service.state).shortcutRegistered);
1929 - }),
1930 - ).pipe(Effect.provide(layerTest("win32", {}, Option.none(), Effect.fail(readError))));
1931 -});
1932 -
1933 -it.effect("requests macOS permissions only for an explicit enable action", () => {
1934 - accessibilityTrustedMock.mockReset().mockReturnValue(false);
1935 - mediaAccessStatusMock.mockReset().mockReturnValue("not-determined");
1936 - getSourcesMock.mockReset().mockResolvedValue([]);
1937 - openExternalMock.mockClear();
1938 -
1939 - return Effect.scoped(
1940 - Effect.gen(function* () {
1941 - const service = yield* DesktopSnapShot.make;
1942 - yield* service.requestPermissions(true);
1943 -
1944 - assert.deepEqual(accessibilityTrustedMock.mock.calls, [[true]]);
1945 - assert.lengthOf(getSourcesMock.mock.calls, 1);
1946 - assert.lengthOf(openExternalMock.mock.calls, 1);
1947 - }),
1948 - ).pipe(Effect.provide(layerTest("darwin")));
1949 -});
1950 -
1951 -it.effect("reports macOS permission status and requests each permission on its own", () => {
1952 - accessibilityTrustedMock.mockReset().mockReturnValue(false);
1953 - mediaAccessStatusMock.mockReset().mockReturnValue("granted");
1954 - getSourcesMock.mockReset().mockResolvedValue([]);
1955 - openExternalMock.mockClear();
1956 -
1957 - return Effect.scoped(
1958 - Effect.gen(function* () {
1959 - const service = yield* DesktopSnapShot.make;
1960 - const state = yield* service.state;
1961 - assert.deepEqual(state.macPermissions, { screenRecording: true, accessibility: false });
1962 -
1963 - yield* service.setup("allow-accessibility");
1964 - assert.deepEqual(accessibilityTrustedMock.mock.calls.at(-1), [true]);
1965 - assert.lengthOf(getSourcesMock.mock.calls, 0);
1966 -
1967 - mediaAccessStatusMock.mockReturnValue("not-determined");
1968 - yield* service.setup("allow-screen-recording");
1969 - assert.lengthOf(getSourcesMock.mock.calls, 1);
1970 - assert.lengthOf(openExternalMock.mock.calls, 1);
1971 - }),
1972 - ).pipe(Effect.provide(layerTest("darwin")));
1973 -});
1974 -
1765 it.effect("flags revoked macOS permissions on read and re-registers once they return", () => {
1766 accessibilityTrustedMock.mockReset().mockReturnValue(true);
1767 mediaAccessStatusMock.mockReset().mockReturnValue("granted");
@@ -2012,30 +1802,6 @@ it.effect("flags revoked macOS permissions on read and re-registers once they re
1802 ).pipe(Effect.provide(layerTest("darwin")));
1803 });
1804
2015 -it.effect("starts the Shift listener outside the Electron main process", () => {
2016 - shortcutForkArgs.length = 0;
2017 - shortcutForkOptions.length = 0;
2018 - shortcutProcesses.length = 0;
2019 - const settings = { ...DEFAULT_CLIENT_SETTINGS, snapShotEnabled: true };
2020 -
2021 - return Effect.scoped(
2022 - Effect.gen(function* () {
2023 - const service = yield* DesktopSnapShot.make;
2024 - yield* service.configure(settings);
2025 - const state = yield* service.state;
2026 -
2027 - assert.isTrue(state.shortcutRegistered);
2028 - assert.lengthOf(shortcutProcesses, 1);
2029 - assert.deepEqual(shortcutForkArgs[0], ["shift"]);
2030 - assert.strictEqual(shortcutForkOptions[0]?.env?.ELECTRON_RUN_AS_NODE, "1");
2031 -
2032 - shortcutProcesses[0]?.emit("exit", 1);
2033 - yield* Effect.promise(() => new Promise<void>((resolve) => queueMicrotask(resolve)));
2034 - assert.isFalse((yield* service.state).shortcutRegistered);
2035 - }),
2036 - ).pipe(Effect.provide(layerTest("win32")));
2037 -});
2038 -
1805 it.effect("an unrelated client-setting change keeps the registered shortcut", () => {
1806 registerShortcutMock.mockReset().mockReturnValue(true);
1807 unregisterShortcutMock.mockReset();
@@ -2169,63 +1935,6 @@ it.effect(
1935 },
1936 );
1937
2172 -it.effect("exposes pending portal permission and then the real assigned shortcut", () => {
2173 - vi.stubEnv("XDG_SESSION_TYPE", "wayland");
2174 - registerShortcutMock.mockReset().mockReturnValue(true);
2175 - nextPortalState.value = {
2176 - shortcutRegistered: false,
2177 - shortcutPending: true,
2178 - shortcutMessage: "Waiting for permission",
2179 - };
2180 - const shortcut = {
2181 - key: "2",
2182 - metaKey: false,
2183 - ctrlKey: true,
2184 - shiftKey: true,
2185 - altKey: false,
2186 - modKey: false,
2187 - } as const;
2188 - const settings = {
2189 - ...DEFAULT_CLIENT_SETTINGS,
2190 - snapShotEnabled: true,
2191 - snapShotShortcut: shortcut,
2192 - };
2193 -
2194 - return Effect.scoped(
2195 - Effect.gen(function* () {
2196 - const service = yield* DesktopSnapShot.make;
2197 - yield* service.configure(settings);
2198 -
2199 - const state = yield* service.state;
2200 - assert.lengthOf(registerShortcutMock.mock.calls, 0);
2201 - assert.isFalse(state.shortcutRegistered);
2202 - assert.isTrue(state.shortcutPending);
2203 - assert.deepEqual(state.shortcut, shortcut);
2204 - assert.equal(state.shortcutMessage, "Waiting for permission");
2205 -
2206 - portalShortcutInstances[0]!.state = {
2207 - shortcutRegistered: true,
2208 - shortcutPending: false,
2209 - shortcutLabel: "Ctrl+Shift+7",
2210 - shortcutMessage: null,
2211 - };
2212 - assert.equal((yield* service.state).shortcutLabel, "Ctrl+Shift+7");
2213 - assert.isTrue((yield* service.state).shortcutRegistered);
2214 - portalShortcutInstances[0]!.state = {
2215 - shortcutRegistered: false,
2216 - shortcutPending: false,
2217 - shortcutMessage: "Permission denied",
2218 - };
2219 - const failed = yield* service.state;
2220 - assert.isFalse(failed.shortcutRegistered);
2221 - assert.equal(failed.shortcutMessage, "Permission denied");
2222 - }),
2223 - ).pipe(
2224 - Effect.provide(layerTest("linux")),
2225 - Effect.ensuring(Effect.sync(() => vi.unstubAllEnvs())),
2226 - );
2227 -});
2228 -
1938 it.effect("verifies only native shortcut delivery and captures normally", () => {
1939 vi.stubEnv("XDG_SESSION_TYPE", "wayland");
1940 vi.stubEnv("XDG_CURRENT_DESKTOP", "test-desktop");
apps/desktop/src/snapShot/GnomeCaptureSetup.test.ts
-4
@@ -113,13 +113,9 @@ it("refuses to replace symlinks or downgrade a newer extension", async () => {
113 });
114
115 it.each([
116 - [{}, "not-installed"],
117 - [{ state: 2, version: 3 }, "disabled"],
116 [{ state: 1, version: 3 }, "enabled"],
119 - [{ state: 1, version: 1 }, "update-required"],
117 [{ state: 1, version: 2, shell: "51.0" }, "update-required"],
118 [{ state: 2, version: 3, enabled: false }, "extensions-disabled"],
122 - [{ state: 3, version: 3, error: "Load failed" }, "error"],
119 [{ shell: "52.0" }, "unsupported"],
120 ] as const)("reports GNOME setup state %j", async (options, status) => {
121 const { setup, call } = fixture(options);
apps/desktop/src/snapShot/PortalCaptureShortcut.test.ts
-11
@@ -158,17 +158,6 @@ it("accepts Hyprland's action-only binding without claiming the keys are reserve
158 expect(client.state.shortcutActionRegistered).toBe(false);
159 });
160
161 -it("does not accept an empty trigger as approval on other desktops", async () => {
162 - const bus = new FakeBus();
163 - bus.actualLabel = "";
164 - const { client, capture } = start(bus);
165 - await client.ready;
166 - expect(client.state.shortcutRegistered).toBe(false);
167 - expect(client.state.shortcutActionRegistered).not.toBe(true);
168 - bus.activate();
169 - expect(capture).not.toHaveBeenCalled();
170 -});
171 -
161 it.each([
162 ["2", "CTRL+SHIFT+2"],
163 ["f12", "CTRL+SHIFT+F12"],
apps/desktop/src/snapShot/SnapShotAccessibilityProcess.test.ts
-15
@@ -1,6 +1,5 @@
1 import { assert, beforeEach, it } from "@effect/vitest";
2 import * as NodeEvents from "node:events";
3 -import * as NodeProcess from "node:process";
3 import { vi } from "vite-plus/test";
4
5 const forkMock = vi.hoisted(() =>
@@ -62,20 +61,6 @@ it("returns immediately when accessibility crashes before the screenshot is read
61 assert.isUndefined(await read.result);
62 });
63
65 -it("returns accessibility extracted by the helper", async () => {
66 - const process = startSnapShotAccessibilityProcess("accessibility.cjs");
67 - const read = process.read(request);
68 - const context = { accessibleText: "Meeting controls" };
69 - worker.emit("message", "ready");
70 - worker.emit("message", "started");
71 - worker.emit("message", { type: "result", context });
72 -
73 - await read.started;
74 - assert.deepEqual(await read.result, context);
75 - assert.strictEqual(forkMock.mock.calls[0]?.[2]?.env?.ELECTRON_RUN_AS_NODE, "1");
76 - assert.strictEqual(forkMock.mock.calls[0]?.[2]?.execPath, NodeProcess.execPath);
77 -});
78 -
64 it("replaces a warm helper that exits before capture", async () => {
65 const exitedWorker = makeWorker();
66 const captureWorker = makeWorker();
apps/desktop/src/snapShot/WindowsCaptureFeedback.test.ts
-16
@@ -33,19 +33,3 @@ it("disables Chromium window animation only while showing the capture overlay",
33 expect(flagsDuringShow).toEqual([["unrelated-switch", animationSwitch]]);
34 expect([...switches]).toEqual(["unrelated-switch"]);
35 });
36 -
37 -it.each([false, true])(
38 - "restores the original switch state when showing throws (preexisting: %s)",
39 - (preexisting) => {
40 - if (preexisting) switches.add(animationSwitch);
41 - const original = [...switches];
42 - const failure = new Error("Overlay was destroyed");
43 - const window = overlay(() => {
44 - expect(switches.has(animationSwitch)).toBe(true);
45 - throw failure;
46 - });
47 -
48 - expect(() => showWindowsCaptureOverlay(window)).toThrow(failure);
49 - expect([...switches]).toEqual(original);
50 - },
51 -);
apps/desktop/src/snapShot/captureConfigEdit.test.ts
-17
@@ -39,14 +39,6 @@ describe("Niri capture config edits", () => {
39 `\uFEFFbinds {\r\n ${binding}\r\n}\r\n`,
40 );
41 });
42 - it("preserves Unicode spacing around nodes and line continuations", () => {
43 - const spaces =
44 - "\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000";
45 - const before = `binds${spaces}\\${spaces}\n{\n}\n`;
46 - expect(editCaptureConfig(before, "niri", app, "install").after).toBe(
47 - before.replace("}\n", ` ${binding}\n}\n`),
48 - );
49 - });
42 it("does not duplicate an existing binding, including a custom chord", () => {
43 const before = `binds {\n ${binding.replace("Ctrl+Shift+2", "Alt+Ctrl+Y")}\n}\n`;
44 const result = editCaptureConfig(before, "niri", app, "install");
@@ -68,11 +60,6 @@ describe("Niri capture config edits", () => {
60 expect(niriConfigConflict(before, app, "Ctrl+Shift+2")).toBe(true);
61 expect(() => editCaptureConfig(before, "niri", app, "install")).toThrow("already used");
62 });
71 - it("does not count a slash-dash-disabled key as occupied", () => {
72 - expect(niriConfigConflict("binds { /- Ctrl+Shift+2 { quit; }; }", app, "Ctrl+Shift+2")).toBe(
73 - false,
74 - );
75 - });
63 it.each(["binds {", "binds {}\nbinds {}", "/* unfinished", 'spawn "unfinished'])(
64 "fails safely for malformed structure: %s",
65 (source) => {
@@ -115,10 +102,6 @@ describe("Hyprland capture config edits", () => {
102 editCaptureConfig("bind = SHIFT CTRL, 2, exec, kitty\n", "hyprland", app, "install"),
103 ).toThrow("already used");
104 });
118 - it("leaves commented bindings alone", () => {
119 - const before = "# bind = CTRL SHIFT, 2, global, com.t3tools.T3Code:capture-window\n";
120 - expect(editCaptureConfig(before, "hyprland", app, "remove").after).toBe(before);
121 - });
105 it.each([
106 "return {}",
107 '--[[\nhl.bind("CTRL + SHIFT + 2", hl.dsp.global("com.t3tools.T3Code:capture-window"))\n]]',
apps/desktop/src/snapShot/snapShot.test.ts
-11
@@ -315,17 +315,6 @@ describe("findAccessibleWindow", () => {
315 expect(findAccessibleWindow(windows, captured)).toBe(windows[1]);
316 });
317
318 - it("uses the matched source title when macOS omits the active title", () => {
319 - const windows = [{ name: "Editor", bounds: captured.bounds }];
320 - expect(
321 - findAccessibleWindow(windows, {
322 - ...captured,
323 - title: "",
324 - sourceTitle: "Editor",
325 - }),
326 - ).toBe(windows[0]);
327 - });
328 -
318 it("uses the captured source title when the active title changed", () => {
319 const windows = [{ name: "Editor — saved", bounds: captured.bounds }];
320
apps/desktop/src/ssh/DesktopSshEnvironment.test.ts deleted
-101
@@ -1,101 +0,0 @@
1 -import * as NodeHttpClient from "@effect/platform-node/NodeHttpClient";
2 -import * as NodeServices from "@effect/platform-node/NodeServices";
3 -import { assert, describe, it } from "@effect/vitest";
4 -import * as NetService from "@t3tools/shared/Net";
5 -import * as Effect from "effect/Effect";
6 -import * as FileSystem from "effect/FileSystem";
7 -import * as Layer from "effect/Layer";
8 -import * as Path from "effect/Path";
9 -
10 -import * as DesktopSshEnvironment from "./DesktopSshEnvironment.ts";
11 -import * as DesktopSshPasswordPrompts from "./DesktopSshPasswordPrompts.ts";
12 -
13 -function makeTempHomeDir() {
14 - return Effect.gen(function* () {
15 - const fs = yield* FileSystem.FileSystem;
16 - return yield* fs.makeTempDirectoryScoped({ prefix: "t3-ssh-env-test-" });
17 - });
18 -}
19 -
20 -describe("sshEnvironment", () => {
21 - it.effect("wires desktop host discovery through the ssh package runtime", () =>
22 - Effect.gen(function* () {
23 - const fs = yield* FileSystem.FileSystem;
24 - const path = yield* Path.Path;
25 - const homeDir = yield* makeTempHomeDir();
26 - const sshDir = path.join(homeDir, ".ssh");
27 - yield* fs.makeDirectory(path.join(sshDir, "config.d"), { recursive: true });
28 - yield* fs.writeFileString(
29 - path.join(sshDir, "config"),
30 - ["Include config.d/*.conf", "Host devbox", " HostName devbox.example.com", ""].join("\n"),
31 - );
32 - yield* fs.writeFileString(
33 - path.join(sshDir, "config.d", "team.conf"),
34 - [
35 - "Host staging",
36 - " HostName staging.example.com",
37 - "Host *",
38 - " ServerAliveInterval 30",
39 - "",
40 - ].join("\n"),
41 - );
42 - yield* fs.writeFileString(
43 - path.join(sshDir, "known_hosts"),
44 - [
45 - "known.example.com ssh-ed25519 AAAA",
46 - "|1|hashed|entry ssh-ed25519 AAAA",
47 - "[bastion.example.com]:2222 ssh-ed25519 AAAA",
48 - "",
49 - ].join("\n"),
50 - );
51 -
52 - const sshEnvironment = yield* DesktopSshEnvironment.DesktopSshEnvironment;
53 - const hosts = yield* sshEnvironment.discoverHosts({ homeDir });
54 - assert.deepEqual(hosts, [
55 - {
56 - alias: "bastion.example.com",
57 - hostname: "bastion.example.com",
58 - username: null,
59 - port: null,
60 - source: "known-hosts",
61 - },
62 - {
63 - alias: "devbox",
64 - hostname: "devbox.example.com",
65 - username: null,
66 - port: null,
67 - source: "ssh-config",
68 - },
69 - {
70 - alias: "known.example.com",
71 - hostname: "known.example.com",
72 - username: null,
73 - port: null,
74 - source: "known-hosts",
75 - },
76 - {
77 - alias: "staging",
78 - hostname: "staging.example.com",
79 - username: null,
80 - port: null,
81 - source: "ssh-config",
82 - },
83 - ]);
84 - }).pipe(
85 - Effect.provide(
86 - DesktopSshEnvironment.layer().pipe(
87 - Layer.provideMerge(
88 - Layer.succeed(DesktopSshPasswordPrompts.DesktopSshPasswordPrompts, {
89 - request: () => Effect.die("unexpected password prompt request"),
90 - resolve: () => Effect.die("unexpected password prompt resolution"),
91 - }),
92 - ),
93 - Layer.provideMerge(NodeServices.layer),
94 - Layer.provideMerge(NodeHttpClient.layerUndici),
95 - Layer.provideMerge(NetService.layer),
96 - ),
97 - ),
98 - Effect.scoped,
99 - ),
100 - );
101 -});
apps/desktop/src/ssh/DesktopSshPasswordPrompts.test.ts
-31
@@ -143,37 +143,6 @@ describe("DesktopSshPasswordPrompts", () => {
143 }).pipe(Effect.provide(layer(testWindow.window)), Effect.scoped);
144 });
145
146 - it.effect("cleans up a prompt that fails during renderer delivery", () => {
147 - const cause = new Error("renderer unavailable");
148 - const testWindow = makeTestWindow({ sendError: cause });
149 -
150 - return Effect.gen(function* () {
151 - const prompts = yield* DesktopSshPasswordPrompts.DesktopSshPasswordPrompts;
152 - const error = yield* prompts
153 - .request({
154 - destination: "devbox",
155 - username: "julius",
156 - prompt: "Enter the SSH password.",
157 - attempt: 1,
158 - })
159 - .pipe(Effect.flip);
160 -
161 - assert.instanceOf(error, DesktopSshPasswordPrompts.DesktopSshPromptPresentationError);
162 - assert.equal(error.operation, "send-prompt-request");
163 - assert.equal(error.destination, "devbox");
164 - const requestId = error.requestId;
165 - if (requestId === null) {
166 - assert.fail("renderer delivery failures must retain their request id");
167 - }
168 - assert.equal(testWindow.closedListenerCount(), 0);
169 -
170 - const resolveError = yield* prompts
171 - .resolve({ requestId, password: "secret" })
172 - .pipe(Effect.flip);
173 - assert.instanceOf(resolveError, DesktopSshPasswordPrompts.DesktopSshPromptExpiredError);
174 - }).pipe(Effect.provide(layer(testWindow.window)), Effect.scoped);
175 - });
176 -
146 it.effect("keeps a submitted password when a later presentation step fails", () => {
147 const testWindow = makeTestWindow({
148 isMinimizedError: new Error("failed to read minimized state"),
apps/desktop/src/telemetry/DesktopTelemetryPublisher.test.ts
-79
@@ -1,17 +1,13 @@
1 -import { DesktopHostTelemetryMessage } from "@t3tools/contracts";
1 import * as NodeServices from "@effect/platform-node/NodeServices";
2 import { assert, describe, it } from "@effect/vitest";
3 import * as Deferred from "effect/Deferred";
4 import * as Duration from "effect/Duration";
5 import * as Effect from "effect/Effect";
6 import * as Exit from "effect/Exit";
8 -import * as Fiber from "effect/Fiber";
7 import * as FileSystem from "effect/FileSystem";
8 import * as Layer from "effect/Layer";
11 -import * as Option from "effect/Option";
9 import * as Schema from "effect/Schema";
10 import * as Scope from "effect/Scope";
14 -import * as Stream from "effect/Stream";
11 import * as TestClock from "effect/testing/TestClock";
12
13 import type * as Electron from "electron";
@@ -95,81 +91,6 @@ describe("DesktopTelemetryPublisher", () => {
91 assert.isDefined(closeFiber.pollUnsafe());
92 }),
93 );
98 -
99 - it.effect("routes requestDesktopUpdate control messages and replays update reports", () =>
100 - Effect.gen(function* () {
101 - const layerPower = Layer.succeed(
102 - ElectronPowerMonitor.ElectronPowerMonitor,
103 - ElectronPowerMonitor.ElectronPowerMonitor.of({
104 - isOnBatteryPower: Effect.succeed(false),
105 - getSystemIdleTime: Effect.succeed(0),
106 - getSystemIdleState: () => Effect.succeed("active"),
107 - getCurrentThermalState: Effect.succeed("nominal"),
108 - onSimpleEvent: () => Effect.void,
109 - onThermalStateChange: () => Effect.void,
110 - onSpeedLimitChange: () => Effect.void,
111 - }),
112 - );
113 - const layer = DesktopTelemetryPublisher.layer.pipe(
114 - Layer.provide(Layer.mergeAll(layerElectronApp([]), layerPower, layerHistory)),
115 - );
116 -
117 - yield* Effect.gen(function* () {
118 - const publisher = yield* DesktopTelemetryPublisher.DesktopTelemetryPublisher;
119 -
120 - const requestFiber = yield* Stream.runHead(publisher.updateRequests).pipe(Effect.forkChild);
121 - yield* Effect.yieldNow;
122 - yield* publisher.handleControlForSource("test", {
123 - version: 1,
124 - type: "requestDesktopUpdate",
125 - requestId: "req-9",
126 - });
127 - const received = yield* Fiber.join(requestFiber);
128 - assert.equal(Option.getOrThrow(received).requestId, "req-9");
129 -
130 - const report = {
131 - version: 1,
132 - type: "desktopUpdateStatus",
133 - outcome: "up-to-date",
134 - state: {
135 - enabled: true,
136 - status: "up-to-date",
137 - channel: "latest",
138 - currentVersion: "1.2.3",
139 - hostArch: "arm64",
140 - appArch: "arm64",
141 - runningUnderArm64Translation: false,
142 - availableVersion: null,
143 - downloadedVersion: null,
144 - releaseNotes: [],
145 - downloadPercent: null,
146 - checkedAt: null,
147 - message: null,
148 - errorContext: null,
149 - canRetry: false,
150 - omittedReleaseCount: 0,
151 - },
152 - } as const;
153 - yield* publisher.publishUpdateReport(report);
154 -
155 - const decoder = new TextDecoder();
156 - const decodeMessage = Schema.decodeUnknownEffect(
157 - Schema.fromJsonString(DesktopHostTelemetryMessage),
158 - );
159 - const replayed = yield* publisher.encoded.pipe(
160 - Stream.mapEffect((bytes) => decodeMessage(decoder.decode(bytes).trim())),
161 - Stream.filter((message) => message.type === "desktopUpdateStatus"),
162 - Stream.runHead,
163 - );
164 - const replayedReport = Option.getOrThrow(replayed);
165 - if (replayedReport.type !== "desktopUpdateStatus") {
166 - return assert.fail("Expected a desktop update status report.");
167 - }
168 - assert.equal(replayedReport.outcome, "up-to-date");
169 - assert.equal(replayedReport.state.currentVersion, "1.2.3");
170 - }).pipe(Effect.provide(layer));
171 - }),
172 - );
94 });
95
96 describe("DesktopRendererHistory", () => {
apps/desktop/src/updates/DesktopUpdates.test.ts
+1 -86
@@ -209,28 +209,6 @@ describe("DesktopUpdates", () => {
209 }),
210 );
211
212 - it.effect("keeps raw updater event failures out of update state", () => {
213 - const harness = makeHarness();
214 - const cause = new Error(
215 - "request failed for https://user:secret@example.com/update?token=secret",
216 - );
217 -
218 - return Effect.scoped(
219 - Effect.gen(function* () {
220 - const updates = yield* DesktopUpdates.DesktopUpdates;
221 - yield* updates.configure;
222 -
223 - harness.emit("error", cause);
224 - yield* flushCallbacks;
225 -
226 - const state = yield* updates.getState;
227 - assert.equal(state.status, "error");
228 - assert.equal(state.message, "Desktop updater background operation reported an error.");
229 - assert.notInclude(state.message ?? "", "secret");
230 - }),
231 - ).pipe(Effect.provide(Layer.merge(TestClock.layer(), harness.layer)));
232 - });
233 -
212 it.effect("preserves a queued installer after a background updater error", () => {
213 const harness = makeHarness();
214
@@ -479,6 +457,7 @@ describe("DesktopUpdates", () => {
457 ).pipe(Effect.provide(Layer.merge(TestClock.layer(), harness.layer)));
458 });
459
460 + // regression: #19291 an install that did apply was still flagged as not applied
461 it.effect("does not flag an install that applied", () => {
462 const harness = makeHarness({
463 installRecord: JSON.stringify({ fromVersion: "1.2.2", targetVersion: "1.2.3" }),
@@ -734,40 +713,6 @@ describe("DesktopUpdates", () => {
713 ).pipe(Effect.provide(Layer.merge(TestClock.layer(), harness.layer)));
714 });
715
737 - it.effect("fails channel changes with a typed error while a check is in progress", () =>
738 - Effect.gen(function* () {
739 - const checkStarted = yield* Deferred.make<void>();
740 - const releaseCheck = yield* Deferred.make<void>();
741 - const harness = makeHarness({
742 - checkForUpdates: Deferred.succeed(checkStarted, undefined).pipe(
743 - Effect.andThen(Deferred.await(releaseCheck)),
744 - ),
745 - });
746 -
747 - yield* Effect.scoped(
748 - Effect.gen(function* () {
749 - const updates = yield* DesktopUpdates.DesktopUpdates;
750 - yield* updates.configure;
751 -
752 - const checkFiber = yield* updates.check("manual").pipe(Effect.forkScoped);
753 - yield* Deferred.await(checkStarted);
754 -
755 - const exit = yield* Effect.exit(updates.setChannel("nightly"));
756 - assert.equal(exit._tag, "Failure");
757 - if (exit._tag === "Failure") {
758 - const error = Cause.squash(exit.cause);
759 - assert.instanceOf(error, DesktopUpdates.DesktopUpdateActionInProgressError);
760 - assert.equal(error.action, "check");
761 - assert.equal(error.requestedChannel, "nightly");
762 - }
763 -
764 - yield* Deferred.succeed(releaseCheck, undefined);
765 - yield* Fiber.join(checkFiber);
766 - }),
767 - ).pipe(Effect.provide(Layer.merge(TestClock.layer(), harness.layer)));
768 - }),
769 - );
770 -
716 it.effect("rejects checks while an update channel change is being persisted", () =>
717 Effect.gen(function* () {
718 const channelChangeStarted = yield* Deferred.make<void>();
@@ -799,36 +744,6 @@ describe("DesktopUpdates", () => {
744 ).pipe(Effect.provide(Layer.merge(TestClock.layer(), harness.layer)));
745 }),
746 );
802 -
803 - it.effect("preserves settings failure context when an update channel cannot be persisted", () => {
804 - const diskFailure = new Error("disk exploded");
805 - const settingsFailure = new DesktopAppSettings.DesktopSettingsWriteError({
806 - operation: "replace-settings-file",
807 - path: "/tmp/settings.json",
808 - cause: diskFailure,
809 - });
810 - const harness = makeHarness({ setUpdateChannelError: settingsFailure });
811 -
812 - return Effect.scoped(
813 - Effect.gen(function* () {
814 - const updates = yield* DesktopUpdates.DesktopUpdates;
815 - yield* updates.configure;
816 -
817 - const error = yield* updates.setChannel("nightly").pipe(Effect.flip);
818 -
819 - assert.instanceOf(error, DesktopUpdates.DesktopUpdateChannelPersistenceError);
820 - assert.equal(error.channel, "nightly");
821 - assert.strictEqual(error.cause, settingsFailure);
822 - assert.strictEqual(error.cause.cause, diskFailure);
823 - assert.equal(error.message, "Failed to persist the nightly desktop update channel.");
824 - assert.notInclude(error.message, diskFailure.message);
825 -
826 - const checkResult = yield* updates.check("manual");
827 - assert.isTrue(checkResult.checked);
828 - assert.equal(harness.checkCount(), 1);
829 - }),
830 - ).pipe(Effect.provide(Layer.merge(TestClock.layer(), harness.layer)));
831 - });
747 });
748
749 describe("describeUpdateErrorCause", () => {
apps/desktop/src/updates/releaseNotes.test.ts
+1
@@ -103,6 +103,7 @@ describe("normalizeDesktopUpdateReleaseNotes", () => {
103 expect(result.omittedReleaseCount).toBe(0);
104 });
105
106 + // regression: #11753 prerelease entries leaked into a channel's update changelog
107 it("keeps only stable releases on the latest channel", () => {
108 const result = normalizeDesktopUpdateReleaseNotes(
109 [
apps/desktop/src/updates/remoteUpdateFlow.test.ts
-36
@@ -2,7 +2,6 @@ import { assert, describe, it } from "@effect/vitest";
2 import type { DesktopUpdateState } from "@t3tools/contracts";
3
4 import {
5 - MAX_REMOTE_UPDATE_CHECKS,
5 MAX_REMOTE_UPDATE_DOWNLOADS,
6 nextRemoteDesktopUpdateStep,
7 type RemoteDesktopUpdateAttempts,
@@ -116,23 +115,6 @@ describe("nextRemoteDesktopUpdateStep", () => {
115 });
116 });
117
119 - it("rides along while a check or download is already in flight", () => {
120 - assert.deepEqual(
121 - nextRemoteDesktopUpdateStep(makeState({ status: "checking" }), NO_ATTEMPTS, null),
122 - {
123 - action: "wait",
124 - },
125 - );
126 - assert.deepEqual(
127 - nextRemoteDesktopUpdateStep(
128 - makeState({ status: "downloading", availableVersion: "1.2.4", downloadPercent: 40 }),
129 - NO_ATTEMPTS,
130 - null,
131 - ),
132 - { action: "wait" },
133 - );
134 - });
135 -
118 it("downloads an available update until the attempt cap, then fails", () => {
119 const available = makeState({ status: "available", availableVersion: "1.2.4" });
120 assert.deepEqual(nextRemoteDesktopUpdateStep(available, NO_ATTEMPTS, null), {
@@ -199,22 +181,4 @@ describe("nextRemoteDesktopUpdateStep", () => {
181 reason: "The desktop app update failed.",
182 });
183 });
202 -
203 - it("checks from idle until the attempt cap, then fails", () => {
204 - assert.deepEqual(nextRemoteDesktopUpdateStep(makeState(), NO_ATTEMPTS, null), {
205 - action: "check",
206 - });
207 - assert.deepEqual(
208 - nextRemoteDesktopUpdateStep(
209 - makeState(),
210 - { checks: MAX_REMOTE_UPDATE_CHECKS, downloads: 0 },
211 - null,
212 - ),
213 - {
214 - action: "done",
215 - outcome: "failed",
216 - reason: "The desktop app did not report an update result.",
217 - },
218 - );
219 - });
184 });
apps/desktop/src/updates/remoteUpdateFlow.ts
+1 -1
@@ -22,7 +22,7 @@ export interface RemoteDesktopUpdateAttempts {
22 readonly downloads: number;
23 }
24
25 -export const MAX_REMOTE_UPDATE_CHECKS = 2;
25 +const MAX_REMOTE_UPDATE_CHECKS = 2;
26 export const MAX_REMOTE_UPDATE_DOWNLOADS = 3;
27
28 function isInstallableDesktopUpdateState(state: DesktopUpdateState): boolean {
apps/desktop/src/window/DesktopWindow.test.ts
+1 -73
@@ -45,7 +45,7 @@ import * as ElectronMenu from "../electron/ElectronMenu.ts";
45 import * as ElectronShell from "../electron/ElectronShell.ts";
46 import * as ElectronTheme from "../electron/ElectronTheme.ts";
47 import * as ElectronWindow from "../electron/ElectronWindow.ts";
48 -import { MENU_ACTION_CHANNEL, SNAP_SHOT_EVENT_CHANNEL } from "../ipc/channels.ts";
48 +import { SNAP_SHOT_EVENT_CHANNEL } from "../ipc/channels.ts";
49 import * as DesktopServerExposure from "../backend/DesktopServerExposure.ts";
50 import * as DesktopWindow from "./DesktopWindow.ts";
51 import * as PreviewManager from "../preview/Manager.ts";
@@ -472,27 +472,6 @@ describe("DesktopWindow", () => {
472 );
473 });
474
475 - it("recognizes only same-origin renderer navigations", () => {
476 - assert.isTrue(
477 - DesktopWindow.isSameOriginRendererNavigation({
478 - applicationUrl: "t3code://app/",
479 - navigationUrl: "t3code://app/settings/connections",
480 - }),
481 - );
482 - assert.isFalse(
483 - DesktopWindow.isSameOriginRendererNavigation({
484 - applicationUrl: "t3code://app/",
485 - navigationUrl: "https://accounts.microsoft.com/oauth",
486 - }),
487 - );
488 - assert.isFalse(
489 - DesktopWindow.isSameOriginRendererNavigation({
490 - applicationUrl: "t3code://app/",
491 - navigationUrl: "not a url",
492 - }),
493 - );
494 - });
495 -
475 it.effect(
476 "opens and reopens the window without backend readiness when local execution is disabled",
477 () =>
@@ -1043,29 +1022,6 @@ describe("DesktopWindow", () => {
1022 }),
1023 );
1024
1046 - it.effect("dispatches menu actions after backend readiness when no main window exists", () =>
1047 - Effect.gen(function* () {
1048 - const splash = makeFakeBrowserWindow();
1049 - const main = makeFakeBrowserWindow();
1050 - const scenario = yield* makeSplashScenario([splash.window, null, main.window]);
1051 -
1052 - yield* Effect.gen(function* () {
1053 - const desktopWindow = yield* DesktopWindow.DesktopWindow;
1054 -
1055 - yield* desktopWindow.showConnectingSplash;
1056 - const readyExit = yield* Effect.exit(
1057 - desktopWindow.handleBackendReady(new URL("http://127.0.0.1:3773")),
1058 - );
1059 - assert.equal(readyExit._tag, "Failure");
1060 -
1061 - yield* desktopWindow.dispatchMenuAction("open-settings");
1062 -
1063 - assert.equal(yield* Ref.get(scenario.createCalls), 3);
1064 - assert.deepEqual(main.send.mock.calls, [[MENU_ACTION_CHANNEL, "open-settings"]]);
1065 - }).pipe(Effect.provide(scenario.layer));
1066 - }),
1067 - );
1068 -
1025 it.effect("delivers capture completion and late errors without taking focus back", () =>
1026 Effect.gen(function* () {
1027 const operations: Array<string> = [];
@@ -1106,34 +1062,6 @@ describe("DesktopWindow", () => {
1062 }),
1063 );
1064
1109 - it.effect("delivers the renderer event even when the reveal fails", () =>
1110 - Effect.gen(function* () {
1111 - const fakeWindow = makeFakeBrowserWindow();
1112 - const createCount = yield* Ref.make(0);
1113 - const mainWindow = yield* Ref.make<Option.Option<Electron.BrowserWindow>>(Option.none());
1114 - const layer = layerTest({
1115 - window: fakeWindow.window,
1116 - createCount,
1117 - mainWindow,
1118 - onReveal: () => {
1119 - throw new Error("another process kept the foreground");
1120 - },
1121 - });
1122 -
1123 - yield* Effect.gen(function* () {
1124 - const desktopWindow = yield* DesktopWindow.DesktopWindow;
1125 - yield* desktopWindow.handleBackendReady(new URL("http://127.0.0.1:3773"));
1126 - yield* Effect.exit(
1127 - desktopWindow.dispatchSnapShotEvent({ type: "started", id: captureOne }),
1128 - );
1129 -
1130 - assert.deepEqual(fakeWindow.send.mock.calls, [
1131 - [SNAP_SHOT_EVENT_CHANNEL, { type: "started", id: captureOne }],
1132 - ]);
1133 - }).pipe(Effect.provide(layer));
1134 - }),
1135 - );
1136 -
1065 it.effect("does not reopen a closed main window for a completed capture", () =>
1066 Effect.gen(function* () {
1067 const fakeWindow = makeFakeBrowserWindow();
apps/desktop/src/window/DesktopWindow.ts
+1 -1
@@ -185,7 +185,7 @@ function buildConnectingSplashDataUrl(shouldUseDarkColors: boolean): string {
185 return `data:text/html;charset=utf-8,${encodeURIComponent(html)}`;
186 }
187
188 -export function isSameOriginRendererNavigation(input: {
188 +function isSameOriginRendererNavigation(input: {
189 readonly applicationUrl: string;
190 readonly navigationUrl: string;
191 }): boolean {
apps/desktop/src/wsl/wslPathParsing.test.ts
-14
@@ -47,16 +47,6 @@ describe("parseWslDistroList", () => {
47 ]);
48 });
49
50 - it("handles output without BOM", () => {
51 - const text = [
52 - " NAME STATE VERSION",
53 - "* Ubuntu Running 2",
54 - ].join("\r\n");
55 - const output = Buffer.from(text, "utf16le");
56 - const distros = parseWslDistroList(output);
57 - expect(distros).toEqual([{ name: "Ubuntu", isDefault: true, version: 2 }]);
58 - });
59 -
50 it("handles UTF-8 output", () => {
51 const text = [
52 " NAME STATE VERSION",
@@ -73,10 +63,6 @@ describe("extractDistroFromUncPath", () => {
63 "Ubuntu-22.04",
64 );
65 });
76 -
77 - it("extracts the distro from the legacy \\\\wsl$ UNC paths", () => {
78 - expect(extractDistroFromUncPath("\\\\wsl$\\Debian\\home\\josh")).toBe("Debian");
79 - });
66 });
67
68 describe("wslUncPathToLinuxPath", () => {