Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
797038e
fix(mobile): Vietnamese letters stay bold in bold text on Android (#4…
juliusmarminge Nov 21, 2026
7ef0558
fix(desktop): preview tabs drop a destroyed webview's WebContents (#4…
juliusmarminge Nov 21, 2026
baf7e5b
fix(acp): persist context usage reported after a turn ends (#40220)
juliusmarminge Nov 21, 2026
67933a2
perf(server): complete Changes preview reuses its tracked-only pass (…
juliusmarminge Nov 21, 2026
511447a
feat(server): add a TanStack Source forge and issue tracker behind T3…
juliusmarminge Nov 21, 2026
2c01259
perf(server): remote status polls read HEAD, upstream and remotes onc…
juliusmarminge Nov 21, 2026
d51d8c4
fix(client-runtime): opening the Diff panel reads each file patch onc…
juliusmarminge Nov 21, 2026
28bcb73
fix(web): floating device preview keeps its stream across thread swit…
juliusmarminge Nov 21, 2026
5aae557
fix(web): show the update capsule label in narrower sidebars
Nov 20, 2026
dea657a
fix(web): show the update capsule at default sidebar width with a sho…
Nov 20, 2026
4be39cf
fix(web): keep the update icon in place while the capsule shrinks
Nov 20, 2026
1425613
fix(web): keep restart seconds visible in narrow sidebars
shivamhwp Nov 21, 2026
b19ca97
fix(web): inline file and thread chips can be removed during dictatio…
juliusmarminge Nov 21, 2026
bb0d718
fix(web): typing and pasting no longer write into the read-only compo…
juliusmarminge Nov 21, 2026
0fd4822
fix(server): per-file diff reads reuse the preview's merge base (#40216)
juliusmarminge Nov 21, 2026
714997c
fix(acp-registry): reinstall the current version when a cached build …
juliusmarminge Nov 21, 2026
0b02be3
fix(server): Claude's answer before a late-read steer stays visible (…
juliusmarminge Nov 21, 2026
d5f8a75
fix(web): RTF previews hide tracked deletions (#40264)
geezoria Nov 21, 2026
0dc32b5
perf(server): an untracked file's Diff panel patch no longer copies t…
juliusmarminge Nov 21, 2026
c1464d6
perf(server): status of a repository without a remote skips remote lo…
juliusmarminge Nov 21, 2026
3d8a023
fix(forgejo): issue links on a self-hosted Forgejo hostname resolve (…
turnercore Nov 21, 2026
47525fa
fix(web): switching threads no longer restarts the Changes and git st…
juliusmarminge Nov 21, 2026
0854259
fix(web): clipped Files tree names show the full name on hover (#40308)
juliusmarminge Nov 21, 2026
6644126
fix(cli): update Windows launchers outside PATH (#40309)
gero3 Nov 21, 2026
69228fe
fix(server): typed-message commits stage the worktree once (#40282)
shivamhwp Nov 21, 2026
7ef7ba0
perf(server): a tracked file's Diff panel patch skips the untracked-f…
juliusmarminge Nov 21, 2026
0775dc4
fix(mobile): mark the linked line in the native source viewer (#40295)
juliusmarminge Nov 21, 2026
c385377
fix(server): slash commands sent during a turn wait instead of steeri…
shivamhwp Nov 21, 2026
989d7ec
perf(server): push and commit-and-push read the full git status once …
juliusmarminge Nov 21, 2026
0c921e1
fix(server): ACP session/load replay no longer pins background work (…
juliusmarminge Nov 21, 2026
232f52c
fix(mobile): confirming a push to the default branch no longer opens …
arifali123 Nov 21, 2026
9c25b71
fix(opencode): Usage → Limits shows why OpenCode could not read usage…
juliusmarminge Nov 21, 2026
d3bb8f8
perf(server): deleting a thread's worktree refreshes git status once,…
juliusmarminge Nov 21, 2026
ece4964
fix(antigravity): accept null skill manifest lists (#40287)
Lucenx9 Nov 21, 2026
e0f3ab9
fix(mobile): text selection menu items follow the UI language (#40297)
panol Nov 21, 2026
997575b
perf(server): pull no longer scans the working tree twice (#40338)
juliusmarminge Nov 21, 2026
755de00
fix(server): Antigravity Orchestrator usage prices at the base Gemini…
juliusmarminge Nov 21, 2026
dd941b9
fix(server): treat a branch rename as done when Git moved the ref but…
juliusmarminge Nov 21, 2026
27125d7
fix(cli): thread --wait --json keeps a result a woken run submits (#4…
Marve10s Nov 21, 2026
b427708
fix(issues): agents can file issues in any bound Linear team (#40299)
shivamhwp Nov 21, 2026
08804b2
fix(server): a queued message that names no model runs on the thread'…
juliusmarminge Nov 21, 2026
d57b83d
perf(server): branch list reloads run 6 git processes instead of 9 (#…
juliusmarminge Nov 21, 2026
e337cee
perf(client-runtime): Git menu status refresh keeps the branch list w…
juliusmarminge Nov 21, 2026
7d3677f
fix(web): picker branch switches no longer re-read the full local sta…
juliusmarminge Nov 21, 2026
8cf94f2
fix(web): a modified click on a remote server opens it after forwardi…
Marve10s Nov 21, 2026
370b1fd
fix(server): a no-op fetch on Windows no longer re-resolves the base …
juliusmarminge Nov 21, 2026
efea1aa
fix(web): CSV preview rows keep their height during horizontal scroll…
Abaans Nov 21, 2026
1458a42
fix(server): transcript cleanup failures tell the user why (#40424)
juliusmarminge Nov 21, 2026
3bf21c0
fix(acp): Devin's terminal commands run under Git Bash on Windows, no…
juliusmarminge Nov 21, 2026
d4d5465
fix(server): a delegated task still reaches its parent when its first…
sungyongcho Nov 21, 2026
3b15a01
fix(server): worktree threads start when a checkout hook already link…
juliusmarminge Nov 21, 2026
630f2e1
fix(desktop): a forward moves off a port this machine serves on IPv6 …
Marve10s Nov 21, 2026
8ee2a8a
fix(web): RTF previews no longer join text across section and column …
Michel-Liao Nov 21, 2026
e203593
fix(azure-devops): project-less pull request URLs can be pasted to ch…
Michel-Liao Nov 21, 2026
28b413f
fix(server): queued messages no longer wait out every timed-out check…
ExSidius Nov 21, 2026
ac00327
fix(shell): non-ASCII Windows PATH entries survive the PowerShell env…
lowlyleon Nov 21, 2026
1cedd4b
fix(web): scheduled task times follow the Time format setting (#37314)
Gooder24 Nov 21, 2026
e2fdfd2
perf(client-runtime): opening the branch picker keeps the branch list…
juliusmarminge Nov 21, 2026
194025e
perf(server): turn end reads upstream divergence once, not twice (#40…
juliusmarminge Nov 21, 2026
1ffa099
fix(shared): file links whose title holds the other quote keep their …
Michel-Liao Nov 21, 2026
a3001b3
fix(web): RTF previews break the line at TextEdit soft line breaks (#…
Michel-Liao Nov 21, 2026
9fdcd08
fix(mobile): scheduled task Time dialog closes after OK on Android (#…
juliusmarminge Nov 21, 2026
fcf5097
fix(server): RTF attachments no longer garble text set in a font's ow…
Michel-Liao Nov 21, 2026
f0ceeef
fix(antigravity): match skill manifest filters literally (#40488)
Lucenx9 Nov 21, 2026
e452042
fix(contracts): older clients drop unknown values in RPC responses (#…
phorrr Nov 21, 2026
10a5b5d
fix(server): Word table cells wrapped in a content control reach the …
Michel-Liao Nov 21, 2026
db9efc5
fix(server): a stop-on-settle action no longer holds back automatic s…
Marve10s Nov 21, 2026
bac8647
fix(web): links inside a PDF are clickable in the in-app PDF viewer (…
juliusmarminge Nov 21, 2026
ba4f99a
fix(web,mobile): Limits shows why a provider's limits are unavailable…
seankd3 Nov 21, 2026
c3fb01d
fix(server): preview snapshots no longer report an empty interactiveE…
juliusmarminge Nov 21, 2026
23e6e91
fix(web): ODT previews no longer print an index's title twice or its …
Michel-Liao Nov 21, 2026
c6ca01b
fix(web): preserve newer navigation when reopening closed views (#40516)
StiensWout Nov 21, 2026
cea19e4
fix(server): ODT attachments no longer repeat index titles or templat…
Michel-Liao Nov 21, 2026
67f3a66
fix(server): skip symlinks during storage cleanup (#40528)
StiensWout Nov 21, 2026
5935157
fix(web): keep secret check replies tied to their own attempt (#40541)
StiensWout Nov 21, 2026
227ac64
fix(web): downscaled image attachments keep Display P3 colors (#40501)
juliusmarminge Nov 21, 2026
1a9a858
fix(keybindings): preserve sibling shortcuts when editing an inherite…
StiensWout Nov 21, 2026
464e8f7
fix: keep paged linked thread history when reopening the same snapsho…
StiensWout Nov 21, 2026
da57ea2
fix(mobile): push clean default branches without a new commit (#40538)
StiensWout Nov 21, 2026
ffb42a0
fix(web): preserve browser history across open tabs (#40543)
StiensWout Nov 21, 2026
fd4284d
fix(vcs): refresh branch pickers after external worktree changes (#40…
StiensWout Nov 21, 2026
b70b9e3
test(scripts): launcher test compares the resolved temp path (#40475)
IzonIcy Nov 21, 2026
4157f38
fix(web): send queued dictation to original thread after switching th…
gordon-vidal Nov 21, 2026
404dd5b
fix(server): Conventional Commits style uses a Conventional Commit PR…
juliusmarminge Nov 21, 2026
dac6422
fix(server): PowerPoint speaker notes leave out the notes page's slid…
Marve10s Nov 21, 2026
fd6c367
fix: write "Pull requests" in sentence case on Android and in the key…
flamboh Nov 21, 2026
828fe37
perf(issues): skip redundant thread payload reads (#40569)
Adamulek123 Nov 21, 2026
cbd1f04
fix(mobile): Steer interrupts ACP agents without native steering inst…
juliusmarminge Nov 21, 2026
87ba898
fix(server): a thread named before its first message keeps its name (…
pauldupuyjr Nov 21, 2026
7b21adb
fix(server): a merge no longer settles an unlinked thread on another …
juliusmarminge Nov 21, 2026
d3242f8
fix(mobile): reuse gallery resources for workspace image taps (#40576)
StiensWout Nov 21, 2026
6247463
perf(server): turn-end git status reads the branch remote and remote …
juliusmarminge Nov 21, 2026
904e267
fix(web): Keep background announcements quiet for held or stopped run…
mwolson Nov 21, 2026
a480167
perf(issues): reuse repository bindings when classifying markdown lin…
Adamulek123 Nov 21, 2026
b5709bb
perf(issues): read only the selected project tracker binding (#40587)
Adamulek123 Nov 21, 2026
76bb5ec
perf(issues): read only link metadata when linking GitHub issues (#40…
Adamulek123 Nov 21, 2026
10586f9
feat: read feature flags from one T3CODE_FEATURE_FLAGS service (#40594)
juliusmarminge Nov 21, 2026
63fa4c8
fix(mcp): a child's async question no longer keeps its parent polling…
navidnadali Nov 21, 2026
2ea1c51
fix(acp): a late session update no longer marks a stopped thread acti…
juliusmarminge Nov 22, 2026
76b4218
fix(web): Ctrl+click in the composer no longer outlines the whole lin…
juliusmarminge Nov 22, 2026
b5a0352
fix(server): log when a settle script is skipped because its worktree…
juliusmarminge Nov 22, 2026
a9447ce
fix(web): Cite button appears as fast after a double-click as after a…
MatthewFeroz Nov 22, 2026
67bf1e6
fix(desktop): AppImage t3 serve stops cleanly under systemd (#40624)
RibatTRW Nov 22, 2026
047fb5b
fix(relay): iOS notifications no longer cut an emoji in half at the t…
saphid Nov 22, 2026
5028eb1
perf(shared): Windows command lookups reuse PATH listings across requ…
juliusmarminge Nov 22, 2026
83edd5e
fix(mcp): t3_thread_wait no longer has parents poll a task's first ru…
navidnadali Nov 22, 2026
15d945f
fix(server): reveal no longer opens Explorer's default folder for a m…
juliusmarminge Nov 22, 2026
90f0bac
fix(server): a steer that missed its turn keeps its place in the queu…
navidnadali Nov 22, 2026
3f08098
fix(web): wrapped prompt suggestion no longer overlaps the composer t…
juliusmarminge Nov 22, 2026
571b869
fix(server): refuse ref switches while a thread works in the shared c…
gbrasil720 Nov 22, 2026
c7a9fba
fix(server): label speaker notes in OpenDocument attachments (#38542)
geezoria Nov 22, 2026
f9b19a7
fix(server): folder discovery skips the walk when t3.json ignores the…
juliusmarminge Nov 22, 2026
28a4200
fix(server): checkpoint repository scopes walk the project folder onc…
Sidreyas Nov 22, 2026
c5fa33b
fix(server,cursor): preserve inline handoff when a failed Cursor turn…
MIT-Consulting Nov 22, 2026
0fb6ac6
perf(web): Markdown renders with Words as static islands under one sh…
juliusmarminge Nov 22, 2026
c1fbdf6
fix(web): pasting text copied from Word inserts the text instead of a…
juliusmarminge Nov 22, 2026
3b3f880
fix(web): wait for image uploads before sending (#40672)
Yash-Singh1 Nov 22, 2026
122d3bf
fix(server): provider refresh finds CLIs installed after launch on ma…
juliusmarminge Nov 22, 2026
b9d0f70
fix(mobile): replace undefined text-foreground-subtle token with text…
MIT-Consulting Nov 22, 2026
df67c4f
fix(antigravity): a long shell command keeps its start, not its last …
juliusmarminge Nov 22, 2026
4e28da0
fix(server): setup script output no longer ends in half an emoji (#40…
tiliakoos Nov 22, 2026
5045891
fix(server): text generation no longer falls back to a model that can…
tiliakoos Nov 22, 2026
4ac5e6e
fix(client-runtime): typing a bare Windows drive lists its folders (#…
brunobola Nov 22, 2026
c9e9e7d
fix(web): a click outside the scheduled task editor no longer discard…
Jardo-51 Nov 22, 2026
4745657
chore(fork): merge upstream v0.1.12-nightly.20261122.5085
tebiggs Nov 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/fork/upstream-tag
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.1.12-nightly.20261121.5038
v0.1.12-nightly.20261122.5085
26 changes: 16 additions & 10 deletions .pnpmfile.cjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
const fs = require("node:fs");
const path = require("node:path");

// Our forks ship as tarballs in apps/mobile/deps. A pnpm patch on one is a second source of
// truth that the next tarball silently drops, so changes go to the fork (apps/mobile/deps/README.md).
// Our forks ship as tarballs in apps/mobile/deps and apps/web/deps. A pnpm patch on one is a
// second source of truth that the next tarball silently drops, so changes go to the fork (see
// the README beside each tarball).
const FORK_APPS = ["apps/mobile", "apps/web"];

function forkTarballPatches(patchedDependencies) {
const manifestPath = path.join(__dirname, "apps/mobile/package.json");
// Release staging installs a partial workspace without the mobile app.
if (!patchedDependencies || !fs.existsSync(manifestPath)) return [];
const { dependencies = {} } = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
const forks = Object.keys(dependencies).filter((name) =>
String(dependencies[name]).startsWith("file:deps/"),
);
if (!patchedDependencies) return [];
const forks = FORK_APPS.flatMap((app) => {
const manifestPath = path.join(__dirname, app, "package.json");
// Release staging installs a partial workspace without every app.
if (!fs.existsSync(manifestPath)) return [];
const { dependencies = {} } = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
return Object.keys(dependencies).filter((name) =>
String(dependencies[name]).startsWith("file:deps/"),
);
});
return Object.keys(patchedDependencies).filter((key) =>
forks.some((name) => key === name || key.startsWith(`${name}@`)),
);
Expand All @@ -23,7 +29,7 @@ module.exports = {
if (forkPatches.length > 0) {
throw new Error(
`pnpm-workspace.yaml patches ${forkPatches.join(", ")}, which ships as a fork tarball in ` +
"apps/mobile/deps. Change the fork and replace the tarball instead (apps/mobile/deps/README.md).",
"an app's deps directory. Change the fork and replace the tarball instead (deps/README.md).",
);
}
// Windows installs need Linux x64 glibc binaries because WSL shares node_modules.
Expand Down
27 changes: 27 additions & 0 deletions apps/desktop/src/app/DesktopApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as Effect from "effect/Effect";
import * as Option from "effect/Option";
import * as Ref from "effect/Ref";
import * as Schema from "effect/Schema";
import * as Stream from "effect/Stream";

import * as NetService from "@t3tools/shared/Net";
import * as SecureRandom from "effect/crypto/SecureRandom";
Expand Down Expand Up @@ -173,6 +174,31 @@ const stopAllPoolInstances = Effect.fn("desktop.app.stopAllPoolInstances")(
);

// Spawns the local backend as soon as the protocol, IPC, and legacy storage that every window needs exist.
/**
* The server reads T3CODE_FEATURE_FLAGS once at start, from the value cached at the last
* discovery. When the login shell now sets different flags, restart it so they apply.
*/
const restartOnFeatureFlagChange = Effect.fn("desktop.restartOnFeatureFlagChange")(function* (
backend: DesktopBackendManager.DesktopBackendInstance,
) {
const state = yield* DesktopState.DesktopState;
const shellEnvironment = yield* DesktopShellEnvironment.DesktopShellEnvironment;
let startedWith = (yield* HostProcess.Environment).T3CODE_FEATURE_FLAGS;
yield* shellEnvironment.updates.pipe(
Stream.filter((snapshot) => snapshot.discovered),
Stream.runForEach(
Effect.fnUntraced(function* (snapshot) {
const flags = snapshot.environment.T3CODE_FEATURE_FLAGS ?? undefined;
if (flags === startedWith || (yield* Ref.get(state.quitting))) return;
startedWith = flags;
yield* logBootstrapInfo("restarting backend for changed T3CODE_FEATURE_FLAGS");
yield* backend.stop();
yield* backend.start;
}),
),
);
});

const startLocalBackend = Effect.gen(function* () {
const state = yield* DesktopState.DesktopState;
const environment = yield* DesktopEnvironment.DesktopEnvironment;
Expand Down Expand Up @@ -268,6 +294,7 @@ const startLocalBackend = Effect.gen(function* () {
}
yield* primaryBackend.start;
yield* logBootstrapInfo("bootstrap backend start requested");
yield* Effect.forkScoped(restartOnFeatureFlagChange(primaryBackend));
// The renderer asks for this token first; minting it at readiness saves a round trip.
yield* Effect.forkScoped(
(yield* DesktopLocalEnvironmentAuth.DesktopLocalEnvironmentAuth).getBearerToken.pipe(
Expand Down
27 changes: 18 additions & 9 deletions apps/desktop/src/app/DesktopCliShim.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const fakeAppImage = (canMount = true, app = REPORTER) => {
// Stays up after a signal until the test lets it finish, like a server shutting down.
const SLOW_SERVER = [
"#!/bin/sh",
"trap 'echo stopping >&3; read go; echo stopped >&3; exit 0' TERM HUP",
"trap 'echo stopping >&3; read go; echo \"stopped $go\" >&3; exit 7' TERM HUP",
"echo ready",
"while :; do sleep 0.05; done",
"",
Expand Down Expand Up @@ -101,9 +101,16 @@ const lines = (stream: NodeJS.ReadableStream) => {
};

describe("renderCliShim", () => {
it.skipIf(!hasSetsid).each(["SIGTERM", "SIGHUP"] as const)(
"keeps the AppImage mounted until the server exits after %s to the process group",
async (signal) => {
// Ctrl-C, an SSH hangup, or a supervisor signals the process group. systemd's default KillMode
// also signals the mounter, and KillMode=mixed signals only the launcher.
it.skipIf(!hasSetsid).each([
["SIGTERM", "the process group"],
["SIGHUP", "the process group"],
["SIGTERM", "every process"],
["SIGTERM", "the launcher"],
] as const)(
"keeps the AppImage mounted until the server exits after %s to %s",
async (signal, target) => {
const { root, shim } = fakeAppImage(true, SLOW_SERVER);
const child = NodeChildProcess.spawn(shim, [], {
detached: true,
Expand All @@ -114,12 +121,12 @@ describe("renderCliShim", () => {
try {
const stdout = lines(child.stdout!);
const events = lines(child.stdio[3] as NodeJS.ReadableStream);
const exited = new Promise((resolve) => child.on("close", resolve));
const exited = new Promise<number | null>((resolve) => child.on("close", resolve));
await stdout.until((line) => line === "ready");
mounter = Number(NodeFS.readFileSync(NodePath.join(root, "mounter.pid"), "utf8"));

// Ctrl-C in a terminal, a closed SSH session, or a service manager signals the whole group.
process.kill(-child.pid!, signal);
process.kill(target === "the launcher" ? child.pid! : -child.pid!, signal);
if (target === "every process") process.kill(mounter, signal);
// The shell runs pending traps in ascending signal number, and WINCH outnumbers TERM and
// HUP, so a mounter that also got the group signal unmounts before it answers this probe.
process.kill(mounter, "SIGWINCH");
Expand All @@ -128,8 +135,8 @@ describe("renderCliShim", () => {

await events.until((line) => line === "stopping");
child.stdin!.end("go\n");
await exited;
expect(events.seen.slice(-2)).toEqual(["stopped", "unmounted"]);
expect(await exited).toBe(7);
expect(events.seen.slice(-2)).toEqual(["stopped go", "unmounted"]);
} finally {
for (const pid of [-child.pid!, mounter]) {
if (pid === undefined) continue;
Expand All @@ -156,6 +163,8 @@ describe("renderCliShim", () => {
const result = run(shim, ["--version"]);
expect(result.status).toBe(3);
expect(result.stdout).toContain(`appimage=${appImage}`);
const closedStdin = NodeChildProcess.spawnSync("sh", ["-c", '"$0" --version <&-', shim]);
expect(closedStdin.status).toBe(3);
});

it("keeps the install's T3 home under sudo, unless one is set", () => {
Expand Down
27 changes: 24 additions & 3 deletions apps/desktop/src/app/DesktopCliShim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,15 @@ export const renderCliShim = (input: {
// Extract-and-run would make the runtime start the app instead of mounting it.
"unset APPIMAGE_EXTRACT_AND_RUN",
// Its own session keeps a group signal (Ctrl-C, SSH hangup) from unmounting it under the
// running server; the traps unmount it after. Without setsid the extract fallback runs.
// running server, and ignoring TERM survives a stop sent to every process (systemd's default).
// Without setsid the extract fallback runs.
"work=$(mktemp -d) || exit 1",
"trap '' TERM",
'setsid "$app" --appimage-mount >"$work/mount" 2>/dev/null &',
"mounter=$!",
`trap 'kill "$mounter" 2>/dev/null; rm -rf "$work"' EXIT`,
// It unmounts itself on TERM, which it now ignores, so the trap unmounts it. Lazily, like the
// runtime: the server's own children may still be exiting.
`trap '[ -z "$mount" ] || fusermount3 -uz "$mount" 2>/dev/null || fusermount -uz "$mount" 2>/dev/null; kill -HUP "$mounter" 2>/dev/null; rm -rf "$work"' EXIT`,
"trap 'exit 130' INT TERM HUP",
"mount=",
'while kill -0 "$mounter" 2>/dev/null; do',
Expand All @@ -111,7 +115,24 @@ export const renderCliShim = (input: {
"fi",
// The runtime sets this when it launches the app; the CLI skips its path-keyed compile cache on it.
'export APPIMAGE="$app"',
run("$mount"),
// The shell must outlive the CLI to unmount, so it forwards TERM and HUP; the terminal sends
// Ctrl-C to the CLI directly. A background child would read /dev/null, so pass stdin on fd 9.
// With stdin closed, `exec 9<&0` would end the shell; `command` makes it a normal error.
"{ command exec 9<&0; } 2>/dev/null || exec 9</dev/null",
`${run("$mount")} <&9 9<&- &`,
"cli=$!",
"exec 9<&-",
`trap 'kill -TERM "$cli" 2>/dev/null' TERM`,
`trap 'kill -HUP "$cli" 2>/dev/null' HUP`,
"trap '' INT",
"status=0",
'wait "$cli" || status=$?',
// A trapped signal interrupts wait; wait again for the CLI's own exit status.
'while kill -0 "$cli" 2>/dev/null; do',
" status=0",
' wait "$cli" || status=$?',
"done",
'exit "$status"',
"",
].join("\n");
};
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/backend/DesktopBackendConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const WSL_FORWARDED_ENV_NAMES = [
"OPENAI_API_KEY",
"ANTHROPIC_API_KEY",
"T3CODE_TELEMETRY_ENABLED",
"T3CODE_GITHUB_APP_CLIENT_ID",
"T3CODE_FEATURE_FLAGS",
// Otherwise the WSL server keeps exporting to endpoints from the bootstrap.
"T3CODE_OTEL_SDK_DISABLED",
"OTEL_SDK_DISABLED",
Expand Down
56 changes: 26 additions & 30 deletions apps/desktop/src/ipc/methods/window.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import type { ManagedPolicyLimits } from "@t3tools/contracts";
import { EDITORS, REMOTE_CAPABLE_EDITOR_IDS } from "@t3tools/contracts";
import { resolveEditorCommand } from "@t3tools/shared/editor";
import * as HostProcess from "@t3tools/shared/HostProcess";
import { makePathDirectoryListings, PathDirectoryListings } from "@t3tools/shared/shell";
import { ManagedPolicyFileError } from "@t3tools/shared/managedPolicyFile";
import * as FileSystem from "effect/FileSystem";
import * as Path from "effect/Path";
import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
import * as Option from "effect/Option";
import * as Stream from "effect/Stream";
import * as TestClock from "effect/testing/TestClock";
import { vi } from "vite-plus/test";
import type * as Electron from "electron";

Expand Down Expand Up @@ -550,6 +552,7 @@ it.effect.skipIf(HostProcess.Platform.defaultValue() === "win32")(
);

describe("probeRemoteEditors PATH scan", () => {
const FIXTURE_MTIME = 1_767_225_600;
const platform = HostProcess.Platform.defaultValue();
const launcherName = (command: string) => (platform === "win32" ? `${command}.cmd` : command);

Expand All @@ -570,6 +573,9 @@ describe("probeRemoteEditors PATH scan", () => {
yield* fs.writeFileString(file, "#!/bin/sh\n");
if (platform !== "win32") yield* fs.chmod(file, 0o755);
}
// A listing of a directory changed moments ago is not kept, so age them past that window.
for (const dir of dirs) yield* fs.utimes(dir, FIXTURE_MTIME, FIXTURE_MTIME);
yield* TestClock.setTime((FIXTURE_MTIME + 60) * 1000);
return {
root,
env: {
Expand All @@ -581,19 +587,15 @@ describe("probeRemoteEditors PATH scan", () => {
};
});

const countingFileSystem = (counter: { stat: number; reads: Map<string, number> }) =>
const countingFileSystem = (reads: Map<string, number>) =>
Layer.effect(
FileSystem.FileSystem,
Effect.gen(function* () {
const fs = yield* FileSystem.FileSystem;
return FileSystem.FileSystem.of({
...fs,
stat: (target) => {
counter.stat += 1;
return fs.stat(target);
},
readDirectory: (target, options) => {
counter.reads.set(target, (counter.reads.get(target) ?? 0) + 1);
reads.set(target, (reads.get(target) ?? 0) + 1);
return fs.readDirectory(target, options);
},
});
Expand All @@ -612,44 +614,38 @@ describe("probeRemoteEditors PATH scan", () => {
return available;
});

it.effect("reads each PATH directory once instead of stat-ing every candidate per editor", () =>
it.effect("finds the editors a serial scan finds, listing each PATH directory at most once", () =>
Effect.gen(function* () {
const { env: baseEnv } = yield* makeFakePath();
const delimiter = platform === "win32" ? ";" : ":";
const uncachedCounter = { stat: 0, reads: new Map<string, number>() };
const cachedCounter = { stat: 0, reads: new Map<string, number>() };
const uncachedEnv = { ...baseEnv, PATH: `${baseEnv.PATH}${delimiter}${baseEnv.HOME}x1` };
const cachedEnv = { ...baseEnv, PATH: `${baseEnv.PATH}${delimiter}${baseEnv.HOME}x2` };
const uncached = yield* serialReference(uncachedEnv).pipe(
Effect.provide(countingFileSystem(uncachedCounter)),
const reads = new Map<string, number>();
// Distinct PATH values keep one scan from answering the other out of the resolution cache.
const serialEnv = { ...baseEnv, PATH: `${baseEnv.PATH}${delimiter}${baseEnv.HOME}x1` };
const probeEnv = { ...baseEnv, PATH: `${baseEnv.PATH}${delimiter}${baseEnv.HOME}x2` };
const serial = yield* serialReference(serialEnv).pipe(
Effect.provideServiceEffect(PathDirectoryListings, makePathDirectoryListings),
);
const cached = yield* probeRemoteEditors
const probed = yield* probeRemoteEditors
.handler(undefined)
.pipe(
Effect.provideService(HostProcess.Environment, cachedEnv),
Effect.provideService(HostProcess.Environment, probeEnv),
Effect.provideService(HostProcess.Platform, platform),
Effect.provide(countingFileSystem(cachedCounter)),
Effect.provide(countingFileSystem(reads)),
Effect.provideServiceEffect(PathDirectoryListings, makePathDirectoryListings),
);
// The host can add editors from app folders the fixture can't redirect (e.g. /Applications).
const fixtureEditors = ["cursor", "vscode", "zed", "webstorm"];
assert.deepStrictEqual(
uncached.filter((id) => fixtureEditors.includes(id)),
serial.filter((id) => fixtureEditors.includes(id)),
fixtureEditors,
);
assert.deepStrictEqual(cached, uncached);
assert.isAbove(uncachedCounter.stat, 0);
// On every platform the probe lists each PATH directory at most once. Only PATH entries count:
// resolveEditorCommand also reads app folders such as /Applications on macOS.
const pathReads = cachedEnv.PATH.split(delimiter)
assert.deepStrictEqual(probed, serial);
// Only PATH entries count: resolveEditorCommand also reads app folders such as /Applications
// on macOS. PATH directories are listed on Windows only, once even for concurrent probes.
const pathReads = probeEnv.PATH.split(delimiter)
.filter((entry) => entry.length > 0)
.map((entry) => cachedCounter.reads.get(entry) ?? 0);
assert.isAbove(Math.max(...pathReads), 0);
assert.isAtMost(Math.max(...pathReads), 1);
// Without the listings, Windows stats every PATH entry x PATHEXT candidate for each editor;
// elsewhere there is no PATHEXT, so the stat count is about the same either way.
if (platform === "win32") {
assert.isBelow(cachedCounter.stat, uncachedCounter.stat / 2);
}
.map((entry) => reads.get(entry) ?? 0);
assert.strictEqual(Math.max(...pathReads), platform === "win32" ? 1 : 0);
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
);
});
4 changes: 1 addition & 3 deletions apps/desktop/src/ipc/methods/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
} from "@t3tools/contracts";
import { PROJECT_FAVICON_EXTENSIONS } from "@t3tools/shared/projectFavicon";
import { resolveEditorCommand } from "@t3tools/shared/editor";
import { withPathDirectoryListings } from "@t3tools/shared/shell";
import * as HostProcess from "@t3tools/shared/HostProcess";
import { isRelayTracingEnabled } from "@t3tools/shared/otelEnvironment";
import * as FileSystem from "effect/FileSystem";
Expand Down Expand Up @@ -446,7 +445,6 @@ export const probeRemoteEditors = DesktopIpc.makeIpcMethod({
result: Schema.Array(EditorId),
handler: Effect.fn("desktop.ipc.window.probeRemoteEditors")(function* () {
const env = yield* HostProcess.Environment;
// Shared listings stop each editor re-stating every PATH entry x PATHEXT candidate on Windows.
const resolved = yield* Effect.forEach(
REMOTE_CAPABLE_EDITOR_IDS,
(editorId) => {
Expand All @@ -456,7 +454,7 @@ export const probeRemoteEditors = DesktopIpc.makeIpcMethod({
: Effect.succeed(false);
},
{ concurrency: REMOTE_EDITOR_PROBE_CONCURRENCY },
).pipe(withPathDirectoryListings);
);
return REMOTE_CAPABLE_EDITOR_IDS.filter((_, index) => resolved[index]);
}),
});
Expand Down
Loading
Loading