Skip to content

Commit df5f4c6

Browse files
Merge remote-tracking branch 'origin/main' into HEAD
2 parents 03832ac + 236be55 commit df5f4c6

343 files changed

Lines changed: 15226 additions & 3231 deletions

File tree

Some content is hidden

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

‎.github/scripts/ci-changes.cjs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const EXTRA_OWNERS = [
3636
// scripts/build-desktop-artifact.ts reads the GNOME extension manifest.
3737
[/^apps\/desktop\/gnome-extension\//, ["@t3tools/scripts"]],
3838
[/^native\/browser-secret\//, ["@t3tools/desktop"]],
39+
[/^native\/kde-snap-shot\//, ["@t3tools/desktop"]],
3940
[/^native\/libghostty-vt\//, ["@t3tools/web"]],
4041
];
4142
const RUST = /^native\/(resource-monitor|kde-snap-shot|hyprland-snap-shot)\//;
@@ -112,10 +113,10 @@ function ownersOf(file, packages) {
112113
// A manifest can change dependencies or versions other packages read.
113114
if (path.posix.basename(file) === "package.json") return null;
114115
if (RUNS_EVERYTHING.some((pattern) => pattern.test(file))) return null;
116+
const extra = EXTRA_OWNERS.flatMap(([pattern, names]) => (pattern.test(file) ? names : []));
115117
// scripts/build-desktop-artifact.test.ts reads the crates' sources.
116-
if (RUST.test(file)) return ["@t3tools/scripts"];
118+
if (RUST.test(file)) return ["@t3tools/scripts", ...extra];
117119

118-
const extra = EXTRA_OWNERS.flatMap(([pattern, names]) => (pattern.test(file) ? names : []));
119120
const owner = packages
120121
.filter((pkg) => file.startsWith(`${pkg.dir}/`))
121122
.sort((a, b) => b.dir.length - a.dir.length)[0];

‎.github/workflows/cursor-hygiene-webhook.yml‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ name: Forward to Cursor hygiene
33
on:
44
push:
55
branches: [main]
6-
pull_request:
6+
# Use trusted workflow code and repository secrets for fork PRs.
7+
# Keep this job payload-only: never check out or run PR code.
8+
pull_request_target:
79
types: [opened, reopened, ready_for_review]
810
issues:
911
types: [opened, closed, reopened]
@@ -34,7 +36,7 @@ jobs:
3436
--output /dev/null --write-out '%{http_code}' \
3537
-H "Authorization: $AUTH" \
3638
-H "Content-Type: application/json" \
37-
-H "X-GitHub-Event: ${{ github.event_name }}" \
39+
-H "X-GitHub-Event: ${{ github.event_name == 'pull_request_target' && 'pull_request' || github.event_name }}" \
3840
-H "X-GitHub-Delivery: ${{ github.run_id }}-${{ github.run_attempt }}" \
3941
--data-binary @"${{ github.event_path }}") || curl_status=$?
4042
if [ "$curl_status" -eq 0 ]; then

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

Lines changed: 0 additions & 30 deletions
This file was deleted.

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

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// @effect-diagnostics nodeBuiltinImport:off globalFetchInEffect:off - Hosted handoff test uses a real localhost listener without an OpenAI account.
22
import * as NodeHttp from "node:http";
3-
import * as NodePath from "@effect/platform-node/NodePath";
3+
import * as NodePath from "node:path";
4+
import * as PlatformNodePath from "@effect/platform-node/NodePath";
45
import { codexAuthHandoffUrl, readCodexAuthDelivery } from "@t3tools/shared/codexAuthHandoff";
56
import { EnvironmentId, ProviderInstanceId } from "@t3tools/contracts";
67
import * as HostProcess from "@t3tools/shared/HostProcess";
@@ -59,11 +60,15 @@ const layerDesktopClerk = (
5960
copyText: () => Effect.void,
6061
},
6162
listeners = new Map<string, (...args: unknown[]) => void>(),
63+
isPackaged = false,
6264
) => {
6365
const environment = DesktopEnvironment.DesktopEnvironment.of({
6466
stateDir: "/tmp/t3-state",
6567
isDevelopment,
6668
appDataDirectory: "/tmp/app-data",
69+
isPackaged,
70+
dirname: platform === "win32" ? String.raw`C:\T3 Code\dist-electron` : "/tmp/dist-electron",
71+
path: platform === "win32" ? NodePath.win32 : NodePath.posix,
6772
platform,
6873
} as unknown as DesktopEnvironment.DesktopEnvironment["Service"]);
6974

@@ -95,7 +100,7 @@ const layerDesktopClerk = (
95100
return DesktopClerk.layer.pipe(
96101
Layer.provide(
97102
Layer.mergeAll(
98-
NodePath.layerPosix,
103+
PlatformNodePath.layerPosix,
99104
Layer.succeed(DesktopEnvironment.DesktopEnvironment, environment),
100105
Layer.succeed(ElectronApp.ElectronApp, electronApp),
101106
Layer.succeed(ElectronShell.ElectronShell, shell),
@@ -112,6 +117,67 @@ describe("DesktopClerk", () => {
112117
storageMock.mockReset();
113118
});
114119

120+
it.effect.each([
121+
{ platform: "win32", isPackaged: false, isDevelopment: false, registers: true },
122+
{ platform: "win32", isPackaged: false, isDevelopment: true, registers: false },
123+
{ platform: "win32", isPackaged: true, isDevelopment: false, registers: false },
124+
{ platform: "darwin", isPackaged: false, isDevelopment: false, registers: false },
125+
{ platform: "linux", isPackaged: false, isDevelopment: false, registers: false },
126+
] as const)(
127+
"registers an entry point only for unpackaged non-development Windows ($platform, packaged=$isPackaged, development=$isDevelopment)",
128+
({ platform, isPackaged, isDevelopment, registers }) => {
129+
const events: string[] = [];
130+
storageMock.mockReturnValue(storageAdapter);
131+
createClerkBridgeMock.mockImplementation(() => {
132+
events.push("bridge");
133+
return { cleanup: vi.fn() };
134+
});
135+
const setAsDefaultProtocolClient = vi.fn(() =>
136+
Effect.sync(() => {
137+
events.push("register");
138+
return true;
139+
}),
140+
);
141+
const electronApp = {
142+
on: () => Effect.void,
143+
setAsDefaultProtocolClient,
144+
} as unknown as ElectronApp.ElectronApp["Service"];
145+
146+
return Effect.gen(function* () {
147+
const clerk = yield* DesktopClerk.DesktopClerk;
148+
yield* clerk.configure;
149+
150+
assert.deepEqual(
151+
setAsDefaultProtocolClient.mock.calls,
152+
registers
153+
? [["t3code", process.execPath, [String.raw`C:\T3 Code\dist-electron\main.cjs`]]]
154+
: [],
155+
);
156+
assert.deepEqual(events, registers ? ["bridge", "register"] : ["bridge"]);
157+
}).pipe(
158+
Effect.scoped,
159+
Effect.provide(
160+
layerDesktopClerk(
161+
isDevelopment,
162+
[],
163+
platform,
164+
undefined,
165+
undefined,
166+
undefined,
167+
isPackaged,
168+
),
169+
),
170+
Effect.provideService(ElectronApp.ElectronApp, electronApp),
171+
Effect.provideService(
172+
ElectronWindow.ElectronWindow,
173+
{} as ElectronWindow.ElectronWindow["Service"],
174+
),
175+
Effect.provideService(DesktopWebLinks.DesktopWebLinks, ignoreWebLinks),
176+
Effect.provideService(HostProcess.Arguments, ["electron"]),
177+
);
178+
},
179+
);
180+
115181
it.effect("acquires and releases the SDK bridge with the layer", () => {
116182
const cleanup = vi.fn();
117183
const events: string[] = [];

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,20 @@ export const make = Effect.gen(function* () {
151151
const context = yield* Effect.context<ElectronWindow.ElectronWindow>();
152152
const runPromise = Effect.runPromiseWith(context);
153153

154+
// Clerk's bare scheme registration omits the app entry on unpackaged Windows.
155+
// Development callbacks also need dev server environment this command cannot restore.
156+
if (
157+
!environment.isPackaged &&
158+
!environment.isDevelopment &&
159+
environment.platform === "win32"
160+
) {
161+
yield* electronApp.setAsDefaultProtocolClient(
162+
ElectronProtocol.getDesktopScheme(environment.isDevelopment),
163+
process.execPath,
164+
[environment.path.join(environment.dirname, "main.cjs")],
165+
);
166+
}
167+
154168
const startProviderAuthHandoff = (value: string | undefined) => {
155169
if (!value) return false;
156170
const request = readCodexAuthHandoff(value, environment.isDevelopment);

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

Lines changed: 0 additions & 37 deletions
This file was deleted.

‎apps/desktop/src/backend/DesktopBackendPool.test.ts‎

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { assert, describe, it } from "@effect/vitest";
2-
import * as Duration from "effect/Duration";
32
import * as Effect from "effect/Effect";
43
import * as FileSystem from "effect/FileSystem";
54
import * as Layer from "effect/Layer";
@@ -19,29 +18,7 @@ import * as DesktopWindow from "../window/DesktopWindow.ts";
1918
import * as DesktopWslEnvironment from "../wsl/DesktopWslEnvironment.ts";
2019
import * as DesktopBackendConfiguration from "./DesktopBackendConfiguration.ts";
2120
import * as DesktopBackendPool from "./DesktopBackendPool.ts";
22-
import type { DesktopBackendSnapshot, DesktopBackendStartConfig } from "./DesktopBackendManager.ts";
23-
24-
function makeStubInstance(
25-
id: DesktopBackendPool.BackendInstanceId,
26-
label: string,
27-
): DesktopBackendPool.DesktopBackendInstance {
28-
const snapshot: DesktopBackendSnapshot = {
29-
desiredRunning: false,
30-
ready: false,
31-
activePid: Option.none(),
32-
restartAttempt: 0,
33-
restartScheduled: false,
34-
};
35-
return {
36-
id,
37-
label: Effect.succeed(label),
38-
start: Effect.void,
39-
stop: () => Effect.void,
40-
currentConfig: Effect.succeed(Option.none<DesktopBackendStartConfig>()),
41-
snapshot: Effect.succeed(snapshot),
42-
waitForReady: (_timeout: Duration.Duration) => Effect.succeed(false),
43-
};
44-
}
21+
import type { DesktopBackendStartConfig } from "./DesktopBackendManager.ts";
4522

4623
function layerPool(labelRef: Ref.Ref<string>): Layer.Layer<DesktopBackendPool.DesktopBackendPool> {
4724
return DesktopBackendPool.layer.pipe(
@@ -111,36 +88,6 @@ function layerPool(labelRef: Ref.Ref<string>): Layer.Layer<DesktopBackendPool.De
11188
}
11289

11390
describe("DesktopBackendPool", () => {
114-
it.effect("layerTest exposes registered instances by id", () =>
115-
Effect.gen(function* () {
116-
const pool = yield* DesktopBackendPool.DesktopBackendPool;
117-
const fetchedPrimary = yield* pool.get(DesktopBackendPool.PRIMARY_INSTANCE_ID);
118-
const fetchedWsl = yield* pool.get(DesktopBackendPool.BackendInstanceId("wsl:ubuntu"));
119-
const fetchedMissing = yield* pool.get(DesktopBackendPool.BackendInstanceId("missing"));
120-
const all = yield* pool.list;
121-
const resolvedPrimary = yield* pool.primary;
122-
123-
assert.equal(yield* Option.getOrThrow(fetchedPrimary).label, "Windows");
124-
assert.equal(yield* Option.getOrThrow(fetchedWsl).label, "WSL (Ubuntu)");
125-
assert.isTrue(Option.isNone(fetchedMissing));
126-
assert.lengthOf(all, 2);
127-
assert.equal(resolvedPrimary.id, DesktopBackendPool.PRIMARY_INSTANCE_ID);
128-
}).pipe(
129-
Effect.provide(
130-
DesktopBackendPool.layerTest([
131-
makeStubInstance(DesktopBackendPool.PRIMARY_INSTANCE_ID, "Windows"),
132-
makeStubInstance(DesktopBackendPool.BackendInstanceId("wsl:ubuntu"), "WSL (Ubuntu)"),
133-
]),
134-
),
135-
),
136-
);
137-
138-
it.effect("layerTest dies when no instances are supplied", () =>
139-
Effect.exit(
140-
DesktopBackendPool.DesktopBackendPool.pipe(Effect.provide(DesktopBackendPool.layerTest([]))),
141-
).pipe(Effect.map((exit) => assert.equal(exit._tag, "Failure"))),
142-
);
143-
14491
it.effect("resolves the primary label lazily after pool layer construction", () =>
14592
Effect.scoped(
14693
Effect.gen(function* () {

‎apps/desktop/src/ipc/methods/wsl.test.ts‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,43 @@ describe("WSL IPC", () => {
120120
),
121121
);
122122

123+
it.effect("does not enumerate distros until the WSL backend is enabled", () => {
124+
const distros = [
125+
{ name: "Ubuntu", isDefault: true, version: 2 as const },
126+
{ name: "Debian", isDefault: false, version: 2 as const },
127+
];
128+
const layer = Layer.mergeAll(
129+
DesktopAppSettings.layerTest({
130+
...DesktopAppSettings.DEFAULT_DESKTOP_SETTINGS,
131+
wslDistro: "Debian",
132+
}),
133+
DesktopWslEnvironment.layerTest({ isAvailable: true, distros }),
134+
layerWslBackend(),
135+
layerLifecycle([]),
136+
layerUnusedLifecycleRuntime,
137+
);
138+
139+
return Effect.gen(function* () {
140+
const wsl = yield* DesktopWslEnvironment.DesktopWslEnvironment;
141+
const state = yield* getWslState.handler(undefined).pipe(
142+
Effect.provideService(DesktopWslEnvironment.DesktopWslEnvironment, {
143+
...wsl,
144+
listDistros: Effect.die("must not enumerate distros"),
145+
}),
146+
Effect.flatMap(decodeWslState),
147+
);
148+
assert.equal(state.enabled, false);
149+
assert.equal(state.available, true);
150+
assert.equal(state.distro, "Debian");
151+
assert.deepEqual(state.distros, []);
152+
153+
const enabledState = yield* invokeSetWslBackendEnabled(true);
154+
assert.equal(enabledState.enabled, true);
155+
assert.equal(enabledState.distro, "Debian");
156+
assert.deepEqual(enabledState.distros, distros);
157+
}).pipe(Effect.provide(layer));
158+
});
159+
123160
it.effect("stages dual-backend preferences before enabling without relaunching", () => {
124161
const relaunchReasons: Array<string> = [];
125162
const layer = Layer.mergeAll(

‎apps/desktop/src/ipc/methods/wsl.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ const readWslState: Effect.Effect<
2222
const wslBackend = yield* DesktopWslBackend.DesktopWslBackend;
2323
const settings = yield* appSettings.get;
2424
const available = settings.localEnvironmentEnabled && (yield* wslEnvironment.isAvailable);
25-
// Only enumerate distros when WSL is actually available — listDistros on a
26-
// non-WSL host would spawn wsl.exe and hit the timeout for nothing.
27-
const distros = available ? yield* wslEnvironment.listDistros : [];
25+
// Windows ships a wsl.exe stub that can prompt to install WSL when invoked.
26+
// Keep disabled state reads from launching it to enumerate distros.
27+
const distros = available && settings.wslBackendEnabled ? yield* wslEnvironment.listDistros : [];
2828
const preflightError = yield* wslBackend.lastPreflightError;
2929
return {
3030
enabled: settings.wslBackendEnabled,

0 commit comments

Comments
 (0)