Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
152 commits
Select commit Hold shift + click to select a range
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
7966f20
fix(antigravity): pre-approve T3 MCP tools in Auto and Auto-accept ed…
charlesbine Nov 22, 2026
ad1b1f9
fix(server): Antigravity keeps Auto in the mode picker after a restar…
juliusmarminge Nov 22, 2026
11224f6
fix(client-runtime): a new thread's first message and a queued send-n…
Tgoh Nov 22, 2026
02ea261
fix(server): long webhook prompts in the delivery log no longer end i…
tiliakoos Nov 22, 2026
426b5a6
fix(server): a released ACP session no longer leaves its run stuck ru…
juliusmarminge Nov 22, 2026
cd3a57a
feat(web): sidebar thread rows show the environment instead of the br…
juliusmarminge Nov 22, 2026
6f49071
fix: a failed checkpoint capture keeps Edit from here for conversatio…
juliusmarminge Nov 22, 2026
15a3daa
docs(claude): mobile shows the compact chip too (#40755)
juliusmarminge Nov 22, 2026
e3f9db2
fix(server): TanStack Source pull requests open from every client, an…
juliusmarminge Nov 22, 2026
976aca3
fix: include delegated threads in CLI listing (#40738)
dajiaohuang Nov 22, 2026
bcace07
fix(pi): turn token usage counts cached tokens as input and stays per…
juliusmarminge Nov 22, 2026
4c3d83f
fix(mobile): usage account detail keeps even pace current while open …
juliusmarminge Nov 22, 2026
7f125d8
fix(server): Resume sends pending context to providers without native…
juliusmarminge Nov 22, 2026
90a8ac0
fix(server): a failed or cancelled clone no longer blocks re-cloning …
amanthanvi Nov 22, 2026
70b5e48
fix: retain pull request metadata in thread show (#40744)
dajiaohuang Nov 22, 2026
c3a330d
fix(web): show Queue for running sessions that cannot steer (#40767)
iiijiashu Nov 22, 2026
c198f73
fix(web): a click outside the project action editor no longer discard…
AymanKhan9 Nov 22, 2026
379a98a
fix(server): t3 pair skips Windows VirtualBox and VMware host-only ad…
juliusmarminge Nov 22, 2026
418e1ac
fix(server): Word text boxes keep their paragraph breaks for agents (…
KyrosHendrix Nov 22, 2026
356dff3
fix(web): RTF previews respect hidden character formatting (#40783)
geezoria Nov 22, 2026
5fc2eb2
fix(mobile): the iOS composer keeps its keyboard and caret after dict…
arun279 Nov 22, 2026
997103b
fix(shared): find file links whose labels contain brackets (#40781)
Abhiram-745 Nov 22, 2026
1acfd37
fix(web): restore effort picker keyboard typeahead (#40798)
juliusmarminge Nov 22, 2026
0ae3154
fix(server): migration 75 no longer fails on an unreadable subagent p…
juliusmarminge Nov 22, 2026
671e05b
fix(issues): an Activity cross-reference opens the issue or pull requ…
juliusmarminge Nov 22, 2026
8435a8c
fix(server): tell a stopped parent which delegated tasks its Stop int…
juliusmarminge Nov 22, 2026
f931f03
fix(server): worktree thread lookups match any spelling of the path (…
juliusmarminge Nov 22, 2026
c585a58
fix(mobile): prevent clipped percentages in usage limit cards (#40778)
peterxiemin Nov 22, 2026
9892474
test(web): browser tests no longer fail when a stale optimizer cache …
Brechard Nov 22, 2026
62a7108
fix(github): superseded runs' cancelled checks no longer block PR wat…
juliusmarminge Nov 22, 2026
a8363da
fix(web): keybindings using '+' show a plus keycap instead of empty p…
AymanKhan9 Nov 22, 2026
d27d29f
fix(web): lineage show-more no longer clips the last row or drops foc…
justsrc Nov 22, 2026
4868aeb
fix(mobile): pulling to Load earlier activity no longer snaps the fee…
juliusmarminge Nov 22, 2026
aa0a851
perf(dev): incremental, cached server typecheck like web and desktop …
Pyseph Nov 22, 2026
a35b3ca
fix(contracts): delegate_task options example says ids differ by prov…
juliusmarminge Nov 22, 2026
d834a4e
fix(web): preserve reply-only edits when a queued message leaves the …
iiijiashu Nov 22, 2026
3c68308
fix(server): t3 start ignores a stale runtime record whose PID was re…
juliusmarminge Nov 22, 2026
9f19a6d
fix(server): runtime prune removes the runtime a committed update rep…
juliusmarminge Nov 22, 2026
f2d0217
fix(server): preserve cancellations during checkpoint capture (#31349)
voltcrash Nov 22, 2026
91d2d90
fix(web): a failed main chunk load reloads once instead of showing th…
juliusmarminge Nov 22, 2026
ecdd8e2
fix(server): slash commands reach the provider verbatim when context …
juliusmarminge Nov 22, 2026
c80f41f
fix(opencode): a command that never calls the model no longer leaves …
juliusmarminge Nov 22, 2026
3d7bb17
fix(mobile): model search finds legacy models (#27587)
juliusmarminge Nov 22, 2026
5799b8a
fix(acp): follow a mode the agent leaves on its own so picking it aga…
juliusmarminge Nov 22, 2026
bcb9217
fix(web): settling a thread no longer jolts the sidebar list (#26661)
flamboh Nov 22, 2026
4136ab6
fix(server): Word files whose main part is not word/document.xml reac…
Marve10s Nov 22, 2026
03920ad
fix(server): wake the agent when Claude exits while it awaits backgro…
juliusmarminge Nov 22, 2026
3571f28
fix(web): Usage Limits no longer shows a stale scrollbar (#40816)
inanimran Nov 22, 2026
77d299c
fix(web): closing the last open pull request clears it from the list …
MyDigitalLife Nov 22, 2026
31790d8
fix(mobile): account badge on the provider icon is readable without a…
juliusmarminge Nov 22, 2026
66ca7cd
fix(server): Claude turns no longer stall on empty or partial stream …
lln556 Nov 22, 2026
ac62463
fix(server): filesystem browse lists symlinks pointing to directories…
lln556 Nov 22, 2026
d5497d6
fix(client-runtime): a resumed thread renders its catch-up once inste…
ahalekelly Nov 22, 2026
501e39d
fix(web): clicking the Tab hint inserts short prompt suggestions agai…
floklein Nov 22, 2026
1e78f37
fix(web): keep script-only drafts reachable in the sidebar (#25272)
juliusmarminge Nov 22, 2026
b23f1e8
fix(server): retire unresponsive shared Codex app-servers (#25123)
juliusmarminge Nov 22, 2026
a985332
fix(shared): Windows command discovery no longer blocks the event loo…
maria-rcks Nov 22, 2026
b479ce2
fix(client-runtime): stop sessions on incompatible server configurati…
juliusmarminge Nov 22, 2026
620cf47
fix(web): browser page translation no longer crashes the app when a t…
juliusmarminge Nov 22, 2026
30372d0
perf(mobile): keep image bytes outside draft JSON (#9727)
t3dotgg Nov 22, 2026
ad2bdc7
fix(server): watch_pull_request says when checks already passed (#40866)
juliusmarminge Nov 22, 2026
a445025
fix(codex): Open diff shows every file of a multi-file patch (#40874)
Abhiram-745 Nov 22, 2026
2f19cec
fix(server): ACP startup gives up when the agent never answers the ha…
juliusmarminge Nov 22, 2026
1d02824
fix(server): a branch prefixed with another remote's name publishes u…
Abhiram-745 Nov 22, 2026
f10e1eb
fix(server): list open delegated tasks when task_status or task_cance…
Project516 Nov 22, 2026
2251de4
fix(gitlab): find merge requests opened from a fork (#40894)
Abhiram-745 Nov 22, 2026
2c4310e
fix(web): pasting a chat message with text and a picture keeps both (…
juliusmarminge Nov 22, 2026
6a5db65
chore(coil): merge upstream/main 2c4310eb06 (151 commits)
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
  •  
  •  
  •  
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
3 changes: 1 addition & 2 deletions apps/desktop/src/backend/DesktopBackendConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ const WSL_FORWARDED_ENV_NAMES = [
"OPENAI_API_KEY",
"ANTHROPIC_API_KEY",
"T3CODE_TELEMETRY_ENABLED",
"T3CODE_GITHUB_APP_CLIENT_ID",
"T3CODE_TANSTACK_SOURCE",
"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