Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
1e60d60
Fix #29433: Restore Codex MCP apps after thread unload (#29498)
amr807 Nov 15, 2026
0bd581b
fix(server): regenerate an empty persisted secret instead of failing …
juliusmarminge Nov 15, 2026
f283973
fix(server): Gemini Spark can register its six MCP OAuth redirect URI…
juliusmarminge Nov 15, 2026
5f6b5a8
fix(cli): the already-running error names the t3 pair command that co…
juliusmarminge Nov 15, 2026
2a66bf2
fix(server): read_pull_request_guide reads no-checkout hosts through …
juliusmarminge Nov 15, 2026
467ec62
fix(server): Codex calls delegate_task directly instead of from Code …
juliusmarminge Nov 15, 2026
c6a120a
fix(forgejo): review guides work for checkouts whose SSH remote is no…
juliusmarminge Nov 15, 2026
9791bce
fix(effect-acp): reject elicitation modes the client did not advertis…
juliusmarminge Nov 15, 2026
6c0032d
fix(server): MCP refuses disallowed browser origins with 403 before a…
juliusmarminge Nov 15, 2026
2e9418a
fix(mcp): explain cross-thread permission rejections (#36934)
07rjain Nov 15, 2026
1672b51
fix(web): Add Environment drops the old tab's error when switching mo…
kvapca Nov 15, 2026
3e29748
fix(server): malformed MCP client registration returns an RFC 7591 er…
juliusmarminge Nov 15, 2026
e57041a
fix(server): pairing codes typed in hyphen- or space-separated groups…
juliusmarminge Nov 15, 2026
137a869
fix(shared): use HTTP for schemeless loopback previews (#29710)
JoaoMarcos44 Nov 15, 2026
166cb00
fix(opencode): Full access subagents start without approval prompts (…
juliusmarminge Nov 15, 2026
9dbb802
fix(desktop): saving keeps a connection catalog this build cannot rea…
juliusmarminge Nov 15, 2026
dcd39b4
fix(pi): model list loads when the server's folder has a project MCP …
chaitanyaprem Nov 15, 2026
5a31f17
fix(server): Git LFS images in pull request descriptions load the obj…
juliusmarminge Nov 15, 2026
98f885a
fix(server): desktop preview uploads accept files over 50 MB (#30299)
juliusmarminge Nov 15, 2026
d430dff
fix(usage): keep default-home history after the default account moves…
juliusmarminge Nov 15, 2026
1dfc746
fix(provider-acp): approving a Devin plan never picks its bypass-perm…
juliusmarminge Nov 15, 2026
1b9121b
fix(server): guests of a forked thread can expand the commands it inh…
saphid Nov 15, 2026
355adf2
docs(user): Tailscale HTTPS lists what the tailnet needs (#23759)
WesleySmits Nov 15, 2026
e6344be
fix(client-runtime): MCP app results with images reach the app instea…
juliusmarminge Nov 15, 2026
a9386ac
fix(gitlab): a pasted repository URL is looked up by its project path…
Dkm0315 Nov 15, 2026
e9d8ac5
fix(server): skip user hooks in Codex text generation (#35203)
thelogicmatrix Nov 15, 2026
808dae1
fix(server): worktrees of git-annex repositories can be removed (#34065)
cardoso-neto Nov 15, 2026
46fff79
fix(server): Codex model changes no longer restart a shared session f…
juliusmarminge Nov 15, 2026
4c9a873
fix(cursor): an aborted Cursor SDK stall no longer stops the server (…
Gourav224 Nov 15, 2026
9b38039
fix(forgejo): prefer the deepest-mounted login when a root login also…
juliusmarminge Nov 15, 2026
2123168
fix(opencode): Go-key-only instances keep OpenCode Go usage on OpenCo…
juliusmarminge Nov 15, 2026
25a1afe
fix(client-runtime): opening an old search result keeps messages in o…
juliusmarminge Nov 15, 2026
6a510c4
fix(server): MCP OAuth rejects a resource with an empty fragment (#35…
juliusmarminge Nov 15, 2026
5de10b9
fix(provider-core): branch-name generation no longer starts the user'…
juliusmarminge Nov 15, 2026
32a6a7f
fix(web): desktop window recovers when its backend restarts during a …
juliusmarminge Nov 15, 2026
8bc7a08
fix(server): an explicit Tailscale IPv6 bind is advertised as a tailn…
juliusmarminge Nov 15, 2026
9bea6f7
fix(server): agent slice memory limits follow live memory changes (#3…
OmarAlex24 Nov 15, 2026
d6795ea
fix(grok): background text generation no longer inherits Grok always-…
saphid Nov 15, 2026
17db708
fix(server): preview port discovery stops polling while no client is …
juliusmarminge Nov 15, 2026
da95a04
fix(web): right-panel shortcuts work on a new, unsent thread (#35189)
juliusmarminge Nov 15, 2026
e3c7c08
fix(desktop): a backend busy right after startup no longer ends in a …
juliusmarminge Nov 15, 2026
3cd8b05
fix(onepassword): a failed batch read no longer outlasts the 45-secon…
juliusmarminge Nov 15, 2026
d5726cb
fix(server): agents get no device tools or instructions while the Dev…
juliusmarminge Nov 15, 2026
fa5fde4
fix(server): clients paired over Tailscale Serve keep their own addre…
juliusmarminge Nov 15, 2026
3947e22
fix(server): HTML previews load relative video and audio files (#36199)
juliusmarminge Nov 15, 2026
dc7ea2c
fix(server): a linked launch above the link's access names the link, …
juliusmarminge Nov 15, 2026
bf8fd41
fix(server): Claude append launch text may start with two hyphens (#3…
juliusmarminge Nov 15, 2026
64a481c
fix(cursor): text generation retries without the sandbox when send re…
juliusmarminge Nov 15, 2026
5ee4fd4
fix(server): resolve Claude WinGet launchers on Windows (#32138)
Sidreyas Nov 15, 2026
365a62a
fix(server): Claude knows decline feedback is the user's message (#27…
juliusmarminge Nov 15, 2026
ea4e7c1
fix(acp): permission answers send the agent's option id unchanged (#3…
juliusmarminge Nov 15, 2026
3466f9e
fix(server): forwarded calls to a linked environment no longer wait o…
juliusmarminge Nov 15, 2026
2c2a286
fix(server): Claude sessions no longer log a canUseTool shadowing war…
mahirozdin Nov 15, 2026
85a81b7
fix(server): Claude text generation honors --settings launch args (#3…
juliusmarminge Nov 15, 2026
12042ff
docs: align delegation guide with current MCP contract (#31045)
jacobcorbett Nov 15, 2026
23ba9b3
fix(server): fx threads load the user's profile MCP servers (#29538)
juliusmarminge Nov 15, 2026
93cd25a
fix(acp-registry): executables named like ..agent count as inside the…
juliusmarminge Nov 15, 2026
0f0c1ca
fix(server): usage mapped onto a Pi, Cursor or Antigravity model pric…
MarcoDotIO Nov 15, 2026
3209fa9
fix(server): resuming a queue no longer bypasses failed worktree setu…
StiensWout Nov 15, 2026
ffd11ff
fix(server): agents can no longer delete the built-in No project thro…
juliusmarminge Nov 15, 2026
f12e820
fix(web): load a too-large PR file's diff on demand (#37007)
Yash-Singh1 Nov 15, 2026
eefba1a
fix(cli): t3 up and t3 status hints keep --base-dir (#31878)
spoukyii Nov 15, 2026
d2a894a
fix(server): forks of forks keep their deleted source's files (#32255)
shivamhwp Nov 15, 2026
cc4160c
fix(web): stashed prompt previews no longer end in a broken character…
felixlaga Nov 15, 2026
e0ca4fc
fix(web, mobile): a failed terminal resize is sent again (#32047)
juliusmarminge Nov 15, 2026
3b5bfce
fix(gitcafe): recognize ssh:// remotes that name no user (#32363)
jancuk Nov 15, 2026
7b9af5f
fix(server): EPUB text extraction skips the chapter head (#32370)
jancuk Nov 15, 2026
a9e900f
fix(mobile): queued messages show mentions and files by name, not as …
MarcoDotIO Nov 15, 2026
189290c
fix(web): [NIT] SF Pro label no longer renders in a serif in the font…
plusk-dev Nov 15, 2026
559cd7d
fix(web): quieter Ready and Merge buttons on PR rows (#25346)
flamboh Nov 15, 2026
348009d
fix(prs): include Storybook files in the test filter and counts (#29083)
aminevg Nov 15, 2026
0fbe8a2
fix(web): settings section headers no longer overlap their actions on…
M0xoo Nov 15, 2026
58f609f
fix(web): theme import no longer says a file just under 1 MB is "1024…
spoukyii Nov 15, 2026
25c44fc
fix(web): use available space for project breadcrumbs (#30503)
bentbrain Nov 15, 2026
e6666dc
docs: include required Bitbucket workspace read scope (#30593)
chungweileong94 Nov 15, 2026
f7a1bac
fix(web): subagent status dots no longer jump between corners (#30753)
markjoshwel Nov 15, 2026
b8bffc8
fix(web): resource monitor no longer claims to sample every 0 ms (#29…
M0xoo Nov 15, 2026
843893e
fix(web): the minimap keeps the current turn lit while reading a long…
Yuruzuu Nov 15, 2026
16a7005
fix(desktop): voice input recovers after Linux audio restarts (#32376)
voltcrash Nov 15, 2026
d5a50a1
perf(pr): actions, title edits and labels show the moment you click, …
Bil0000 Nov 15, 2026
f0495f7
fix(provider-core): background work notices no longer say every task …
felixlaga Nov 15, 2026
34204a3
fix(server): restarts no longer drop prompts the provider never accep…
Jolymmiles Nov 15, 2026
e2afd25
perf(web): typing no longer re-renders the composer's footer controls…
OmarAlex24 Nov 15, 2026
11c425b
fix(server): task_status no longer reports a restart-continued task a…
Jolymmiles Nov 15, 2026
86cdf80
fix(web): sidebar edge uses the same resize cursor as side panels (#3…
tenyoru Nov 15, 2026
ab319a5
fix(web): attach command palette threads outside the sidebar (#37054)
Yash-Singh1 Nov 15, 2026
d8b80a1
fix(server): status reports no branch while a clone has not checked o…
juliusmarminge Nov 15, 2026
97edb7a
perf(scripts): check:changed on Windows no longer spends minutes walk…
Pyseph Nov 15, 2026
4117bd4
perf(web): answering a question no longer re-renders the whole chat v…
OmarAlex24 Nov 15, 2026
a5d21a3
perf(server): command palette status rows skip the Changes totals the…
Yuruzuu Nov 15, 2026
aace48b
fix(web): PR file order follows alias imports of dotted modules (#32364)
jancuk Nov 15, 2026
015eba4
fix(acp): a failed MCP-over-ACP disconnect can be retried (#33069)
notzenco Nov 15, 2026
1b04bab
fix(web): settle check lines up with row timestamps (#33053)
sergiiopm Nov 15, 2026
9ec7143
fix(provider-core): handoff work reserve fits small context windows (…
MiaAI-Lab Nov 15, 2026
fbfebc8
fix(mobile): video previews survive re-signed URLs and a late-attache…
bartlomiejbloniarz Nov 15, 2026
7ced2ca
fix(mobile): honor Android clock format in message timestamps (#33078)
razzeee Nov 15, 2026
528c77f
fix(shared): .localdomain hosts no longer leak to the favicon service…
mrlufepines Nov 15, 2026
7f575e6
fix(web): collapsing Electron main no longer hides the backend server…
thepradipvc Nov 15, 2026
b1050d3
test: remove duplicate client call-site coverage (#36776)
t3-code-bot[bot] Nov 15, 2026
2d80ca0
fix(github): pull request activity reports a rate-limited review-thre…
only21mil Nov 15, 2026
f52fba4
fix(web): stacked composer banners no longer show dark seam bands (#3…
Pulsar-Programmer Nov 15, 2026
8e06750
fix(web): draft images keep their order after a reload (#32709)
only21mil Nov 15, 2026
71adeef
fix(web): open PDF links in the file viewer (#37064)
Yash-Singh1 Nov 15, 2026
ab2420f
fix(server): a selected-file commit keeps other files' merge conflict…
only21mil Nov 15, 2026
9a79883
fix(web): a file opened from a diff in a project folder inside a repo…
Entrpi Nov 15, 2026
294a841
test(web): ACP project picker test waits for the popup to take focus …
seancarnahan Nov 15, 2026
147de34
fix(web): stop held dictation when shortcut modifiers are released (#…
mrlufepines Nov 15, 2026
2386789
perf(web): resting on a PR row also reads its activity, so the timeli…
Bil0000 Nov 15, 2026
62d33c1
fix(server): agents can see whether a thread is pinned (#32727)
shadizx Nov 15, 2026
52c6208
fix(server): a pushed commit no longer reports failure when the final…
only21mil Nov 15, 2026
da9c848
test(web): the streaming render scenario gives the timeline stable pr…
Entrpi Nov 15, 2026
3a1dfb7
fix(web): HTML file previews use the current canvas color (#37072)
Yash-Singh1 Nov 15, 2026
ca31ab6
fix(web): an image-only send that fails behind a new draft now says s…
only21mil Nov 15, 2026
40f63b4
fix(assets): align app icons and retain a folder placeholder while lo…
Yash-Singh1 Nov 15, 2026
ab45ce7
fix(github): pull request activity says when its comments were cut (#…
only21mil Nov 15, 2026
742a912
test(github): activity mock sets the new truncated flag (#37078)
juliusmarminge Nov 15, 2026
9f815c9
fix(server): a branch's own pull request shows past a hundred same-na…
only21mil Nov 15, 2026
033ae7c
fix(server): an effect this build can't read no longer blocks its thr…
only21mil Nov 15, 2026
781ab05
fix(acp-registry): a failed agent install no longer floods provider s…
only21mil Nov 15, 2026
3fe1dd9
fix(web): terminal reports focus changes to programs that request the…
StiensWout Nov 15, 2026
37b71a4
fix(web): remove redundant subagent action from background row (#37079)
Yash-Singh1 Nov 15, 2026
4fa5f0e
fix(web): a side chat's subagent opens its parent as a side chat tab,…
Yuruzuu Nov 15, 2026
79e47e9
fix(shared): inline code paths like `docker/Dockerfile` become file c…
felixlaga Nov 15, 2026
63b5645
fix(web): Esc in Clerk's account modal no longer closes Settings (#32…
thepradipvc Nov 15, 2026
d738edf
fix(mobile): show thread sync status in the header, not above the com…
juliusmarminge Nov 15, 2026
154c0fd
fix(mobile): undo toast lines up with the folded Duo's tab bar (#37081)
juliusmarminge Nov 15, 2026
ca0ca71
fix(desktop): Stable switch no longer tells policy-blocked nightly ap…
only21mil Nov 15, 2026
2f30d98
fix(web): live dictation transcript keeps the newest words in view (#…
SharoonRafeek Nov 15, 2026
0720280
fix(server): preserve shell paths containing spaces and dashes (#37069)
StiensWout Nov 15, 2026
efddcfe
perf(server): batch terminal output that arrives within 2 ms (#37060)
juliusmarminge Nov 15, 2026
5d58954
perf(desktop): WSL preflight starts the staged runtime once instead o…
juliusmarminge Nov 15, 2026
93f8563
fix(mobile): worktree setup shows in the chat from the first moment (…
juliusmarminge Nov 15, 2026
f36c835
fix(server): an MCP pin lands at the top of the Pinned section (#33978)
xwchen Nov 15, 2026
9de4a2f
fix(mobile): keep Diagnostics and Client Storage content above floati…
j-gaertig Nov 15, 2026
5e0127c
fix(acp-registry): observe delayed model discovery and avoid stale ca…
hxbib Nov 15, 2026
986975e
test(web): Settings Esc test waits for the modal's initial focus (#37…
juliusmarminge Nov 15, 2026
52451a7
fix(claude): keep monitor threads waiting between updates (#37085)
Yash-Singh1 Nov 15, 2026
278e47d
fix(mobile): the iPhone Duo's sidebar list ends above its tab bar in …
juliusmarminge Nov 15, 2026
2dc5ebd
fix(web): switching providers no longer drops the thread's stored eff…
only21mil Nov 15, 2026
aaf5b9c
fix(mobile): PR activity filter remembers bot and resolved visibility…
juliusmarminge Nov 15, 2026
2cb2fa1
fix(web): terminal links open bare compiler filenames (#37071)
StiensWout Nov 15, 2026
b35c970
fix(acp): optional text questions can be left blank (#36997)
shivamhwp Nov 15, 2026
4ab3b98
fix(shared): MCP apps that fall back to a blob: frame no longer rende…
u9g Nov 15, 2026
2045004
fix(shared): keep coalescing workers alive when processors throw (#32…
luke2x Nov 15, 2026
9618837
fix(server): an empty Antigravity MCP config still allows text genera…
saphid Nov 15, 2026
570640b
perf(server): active thread reads filter on the archived_at column (#…
mahirozdin Nov 15, 2026
6444087
perf(resource-monitor): look up external process identities by PID (#…
hieu-lee Nov 15, 2026
3ee4aa6
fix(server): accept ASCII whitespace in base64 image payloads (#31798)
darshmahadevia Nov 15, 2026
8c80003
perf(server): Codex skills for four workspaces load in a median 138 m…
Yuruzuu Nov 15, 2026
f2c9449
fix(web): recover expired composer uploads before sending (#32910)
Adamulek123 Nov 15, 2026
32c069e
fix(server): content search recovers after a slow first index (#33138)
ItsThierry Nov 15, 2026
e101cae
fix(terminal): show shell startup failures across attachments (#37088)
StiensWout Nov 15, 2026
4f82964
perf(server): long threads open about 2.5x faster (#34014)
valuin Nov 15, 2026
50a2f5b
perf(server): long threads open about 2.5x faster (#34014)
valuin Nov 15, 2026
6fbafaa
Merge remote-tracking branch 'upstream/main' into sync/upstream-2026-…
shuv1337 Nov 15, 2026
cfffaeb
test(cli): port the pair-hint fixture to fork homes
shuv1337 Nov 15, 2026
c9af87a
test(cli): restore strict no-lan hint assertion
shuv1337 Nov 15, 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: 0 additions & 2 deletions apps/desktop/src/app/DesktopApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,9 @@ const bootstrap = Effect.fn("desktop.bootstrap")(function* (backendStarted: bool
}

const primaryBackend = yield* (yield* DesktopBackendPool.DesktopBackendPool).primary;
// WSL-only fallback can change the primary endpoint before readiness.
const config = yield* primaryBackend.currentConfig;
if (
!environment.isDevelopment &&
!settings.wslOnly &&
Option.isSome(config) &&
Option.isNone(config.value.preflightFailure)
) {
Expand Down
62 changes: 62 additions & 0 deletions apps/desktop/src/app/DesktopConnectionCatalogStore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,66 @@ describe("DesktopConnectionCatalogStore", () => {
assert.deepStrictEqual(yield* store.get, Option.some('{"schemaVersion":1,"targets":[]}'));
}).pipe(Effect.provide(NodeServices.layer)),
);

const emptyCatalog =
'{"schemaVersion":1,"targets":[],"profiles":[],"credentials":[],"remoteDpopTokens":[],"disabledEnvironmentIds":[]}';
const savedFilesHolding = Effect.fn(function* (stateDir: string, contents: string) {
const fileSystem = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const kept: string[] = [];
for (const name of yield* fileSystem.readDirectory(stateDir)) {
const file = path.join(stateDir, name);
if ((yield* fileSystem.stat(file)).type !== "File") continue;
if ((yield* fileSystem.readFileString(file)) === contents) kept.push(name);
}
return kept;
});

it.effect("keeps a catalog this build cannot decode when the next save replaces it", () =>
withStore(
Effect.gen(function* () {
const path = yield* Path.Path;
const environment = yield* DesktopEnvironment.DesktopEnvironment;
const fileSystem = yield* FileSystem.FileSystem;
const store = yield* DesktopConnectionCatalogStore.DesktopConnectionCatalogStore;
const catalogPath = path.join(environment.stateDir, "connection-catalog.json");
assert.isTrue(
yield* store.set(
'{"schemaVersion":1,"targets":[{"_tag":"FutureConnectionTarget","environmentId":"remote"}],"profiles":[],"credentials":[],"remoteDpopTokens":[],"disabledEnvironmentIds":[]}',
),
);
const original = yield* fileSystem.readFileString(catalogPath);

yield* store.get;
assert.isTrue(yield* store.set(emptyCatalog));

assert.isNotEmpty(yield* savedFilesHolding(environment.stateDir, original));
}),
),
);

it.effect("keeps a catalog that no longer decrypts when the next save replaces it", () =>
Effect.gen(function* () {
const path = yield* Path.Path;
const fileSystem = yield* FileSystem.FileSystem;
const baseDir = yield* fileSystem.makeTempDirectoryScoped({
prefix: "t3-desktop-connection-catalog-test-",
});
const failDecrypt = yield* Ref.make(false);
const store = yield* DesktopConnectionCatalogStore.DesktopConnectionCatalogStore.pipe(
Effect.provide(layerFor(baseDir, true, failDecrypt)),
);
const stateDir = path.join(baseDir, "userdata");
assert.isTrue(yield* store.set('{"schemaVersion":1,"targets":[]}'));
const original = yield* fileSystem.readFileString(
path.join(stateDir, "connection-catalog.json"),
);

yield* Ref.set(failDecrypt, true);
yield* store.get.pipe(Effect.flip);
assert.isTrue(yield* store.set(emptyCatalog));

assert.isNotEmpty(yield* savedFilesHolding(stateDir, original));
}).pipe(Effect.provide(NodeServices.layer), Effect.scoped),
);
});
73 changes: 58 additions & 15 deletions apps/desktop/src/app/DesktopConnectionCatalogStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { fromLenientJson } from "@t3tools/shared/schemaJson";
import * as Context from "effect/Context";
import * as SecureRandom from "effect/crypto/SecureRandom";
import * as Effect from "effect/Effect";
import * as Clock from "effect/Clock";
import * as Base64 from "effect/encoding/Base64";
import * as FileSystem from "effect/FileSystem";
import * as Layer from "effect/Layer";
Expand Down Expand Up @@ -45,13 +46,17 @@ const RuntimeConnectionCatalogDocumentJson = Schema.fromJsonString(
const encodeRuntimeConnectionCatalogDocumentJson = Schema.encodeEffect(
RuntimeConnectionCatalogDocumentJson,
);
const decodeRuntimeConnectionCatalogDocumentJson = Schema.decodeEffect(
RuntimeConnectionCatalogDocumentJson,
);

const DesktopConnectionCatalogStoreWriteOperation = Schema.Literals([
"create-temporary-file-name",
"encode-document",
"create-directory",
"write-temporary-file",
"replace-catalog-file",
"keep-unreadable-catalog",
]);

const DesktopConnectionCatalogStoreMigrationOperation = Schema.Literals([
Expand Down Expand Up @@ -395,6 +400,57 @@ export const make = Effect.gen(function* () {
),
);

const decryptDocument = (document: EncryptedConnectionCatalogDocument) =>
decodeSecretBytes(catalogPath, document.encryptedCatalog).pipe(
Effect.flatMap((encryptedCatalog) =>
safeStorage.decryptString(encryptedCatalog).pipe(
Effect.mapError(
(cause) =>
new DesktopConnectionCatalogStoreProtectionError({
operation: "decrypt-catalog",
catalogPath,
cause,
}),
),
),
),
);

// A catalog this build cannot decrypt or decode may still hold another build's saved
// environments and credentials, so a save copies it aside instead of destroying it.
const keepUnreadableCatalog = Effect.gen(function* () {
const readable = yield* readDocument(fileSystem, catalogPath).pipe(
Effect.flatMap(
Option.match({
onNone: () => Effect.succeed(true),
onSome: (document) =>
decryptDocument(document).pipe(
Effect.flatMap(decodeRuntimeConnectionCatalogDocumentJson),
Effect.as(true),
),
}),
),
Effect.orElseSucceed(() => false),
);
if (readable) {
return;
}
const keptPath = `${catalogPath}.unreadable-${yield* Clock.currentTimeMillis}`;
yield* fileSystem.copyFile(catalogPath, keptPath).pipe(
Effect.mapError(
(cause) =>
new DesktopConnectionCatalogStoreWriteError({
operation: "keep-unreadable-catalog",
path: keptPath,
cause,
}),
),
);
yield* Effect.logWarning("Kept an unreadable connection catalog before replacing it.", {
keptPath,
});
});

const writeCatalog = Effect.fn("desktop.connectionCatalogStore.writeCatalog")(function* (
catalog: string,
) {
Expand Down Expand Up @@ -470,26 +526,13 @@ export const make = Effect.gen(function* () {
if (!(yield* encryptionAvailable)) {
return Option.none<string>();
}
const decrypted = yield* decodeSecretBytes(catalogPath, document.value.encryptedCatalog).pipe(
Effect.flatMap((encryptedCatalog) =>
safeStorage.decryptString(encryptedCatalog).pipe(
Effect.mapError(
(cause) =>
new DesktopConnectionCatalogStoreProtectionError({
operation: "decrypt-catalog",
catalogPath,
cause,
}),
),
),
),
);
return Option.some(decrypted);
return Option.some(yield* decryptDocument(document.value));
}).pipe(Effect.withSpan("desktop.connectionCatalogStore.get")),
set: Effect.fn("desktop.connectionCatalogStore.set")(function* (catalog) {
if (!(yield* encryptionAvailable)) {
return false;
}
yield* keepUnreadableCatalog;
yield* writeCatalog(catalog);
return true;
}),
Expand Down
22 changes: 11 additions & 11 deletions apps/desktop/src/backend/DesktopBackendConfiguration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ describe("DesktopBackendConfiguration", () => {
runtimeId: string;
sha256: string;
}> = [];
const observedProbeRoots: string[] = [];
let probeCount = 0;
let legacyCleanupCount = 0;
const linuxAppRoot = "/home/test/.t3/wsl-runtime/1.2.3-x64";
const resolvedPath = "/home/test/.local/bin:/usr/bin:/bin";
Expand All @@ -419,8 +419,8 @@ describe("DesktopBackendConfiguration", () => {
});
return { ok: true, linuxAppRoot };
},
probeRuntime: (_distro, root) => {
observedProbeRoots.push(root);
probeRuntime: () => {
probeCount += 1;
return { ok: true, resolvedPath };
},
ensureNodePty: () => {
Expand All @@ -441,7 +441,7 @@ describe("DesktopBackendConfiguration", () => {
sha256: archiveHash,
},
]);
assert.deepEqual(observedProbeRoots, [linuxAppRoot]);
assert.equal(probeCount, 1);
assert.equal(
config.entryPath,
path.join(baseDir, "server.asar/apps/server/dist/bin.mjs"),
Expand Down Expand Up @@ -536,10 +536,10 @@ describe("DesktopBackendConfiguration", () => {
);
});

it.effect("resolveWsl retires a staged runtime whose executable does not start", () => {
it.effect("resolveWsl retires a staged runtime whose launch probe fails", () => {
const archiveHash = "c".repeat(64);
const stagedAppRoot = `/home/test/.t3/wsl-runtime/sha256-${archiveHash}`;
const observedProbeRoots: string[] = [];
let probeCount = 0;
const observedNodePtyRoots: string[] = [];
const invalidatedRuntimeIds: string[] = [];
return withPackagedWslHarness(
Expand All @@ -551,9 +551,9 @@ describe("DesktopBackendConfiguration", () => {
Effect.sync(() => {
invalidatedRuntimeIds.push(runtimeId);
}),
probeRuntime: (_distro, root) => {
observedProbeRoots.push(root);
return { ok: false, reason: `${root}/t3 --version failed (exit 127)` };
probeRuntime: () => {
probeCount += 1;
return { ok: false, reason: "WSL login-shell PATH could not be resolved" };
},
ensureNodePty: (_distro, root) => {
observedNodePtyRoots.push(root);
Expand All @@ -566,7 +566,7 @@ describe("DesktopBackendConfiguration", () => {
const configuration = yield* DesktopBackendConfiguration.DesktopBackendConfiguration;
const config = yield* configuration.resolveWsl({ port: 5000, distro: "Ubuntu" });

assert.deepEqual(observedProbeRoots, [stagedAppRoot]);
assert.equal(probeCount, 1);
assert.deepEqual(observedNodePtyRoots, [mountedAppRoot]);
assert.include(config.args, "/usr/bin/node");
assert.include(config.args, `${mountedAppRoot}/apps/server/dist/bin.mjs`);
Expand All @@ -591,7 +591,7 @@ describe("DesktopBackendConfiguration", () => {
Effect.sync(() => {
invalidatedRuntimeIds.push(runtimeId);
}),
probeRuntime: () => ({ ok: false, reason: "t3 --version failed (exit 1)" }),
probeRuntime: () => ({ ok: false, reason: "WSL login-shell PATH could not be resolved" }),
ensureNodePty: () => ({
ok: false,
reason: "WSL backend preflight timed out while probing for Node.js.",
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/backend/DesktopBackendConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ const runWslPreflight = Effect.fn("desktop.backendConfiguration.wslPreflight")(f
const runtime = yield* wslEnv.prepareRuntime(runningDistro, input.runtimeArchive);
if (runtime.ok) {
// Staged runtimes bundle Node and node-pty; provider PATH discovery must not require them.
const stagedProbe = yield* wslEnv.probeRuntime(runningDistro, runtime.linuxAppRoot);
const stagedProbe = yield* wslEnv.probeRuntime(runningDistro);
if (stagedProbe.ok) {
yield* wslServerTree.cleanupLegacy;
return {
Expand All @@ -448,7 +448,7 @@ const runWslPreflight = Effect.fn("desktop.backendConfiguration.wslPreflight")(f
} as const;
}
yield* Effect.logWarning(
"The staged WSL runtime did not start; retrying from the mounted server tree.",
"The staged WSL runtime probe failed; retrying from the mounted server tree.",
{ reason: stagedProbe.reason },
);
stagedFailure = { runtimeId: input.runtimeArchive.runtimeId, reason: stagedProbe.reason };
Expand Down
38 changes: 38 additions & 0 deletions apps/desktop/src/backend/DesktopBackendManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
DATABASE_MIGRATIONS_STARTED_MESSAGE,
} from "@t3tools/shared/databaseMigrationLog";
import { assert, describe, it } from "@effect/vitest";
import * as Clock from "effect/Clock";
import * as Deferred from "effect/Deferred";
import * as Duration from "effect/Duration";
import * as Effect from "effect/Effect";
Expand Down Expand Up @@ -239,6 +240,43 @@ describe("DesktopBackendManager", () => {
}),
);

it.effect("notices a WSL backend soon after it listens despite slow refused connects", () =>
Effect.gen(function* () {
const ready = yield* Deferred.make<void>();
const exit = yield* Deferred.make<ChildProcessSpawner.ExitCode>();
const instance = yield* makeTestInstance({
config: { ...baseConfig, httpBaseUrl: new URL("http://172.20.84.98:3773") },
onReady: Deferred.succeed(ready, undefined).pipe(Effect.asVoid),
spawnerLayer: Layer.succeed(
ChildProcessSpawner.ChildProcessSpawner,
ChildProcessSpawner.make(() =>
Effect.acquireRelease(
Effect.succeed(makeProcess({ exitCode: Deferred.await(exit) })),
() => Deferred.succeed(exit, ChildProcessSpawner.ExitCode(0)),
),
),
),
// Before the server listens at 300 ms, each refused connect takes a second to fail.
httpClientLayer: layerHttpClient((request) =>
Clock.currentTimeMillis.pipe(
Effect.flatMap((now) =>
now < 300
? Effect.sleep(Duration.seconds(1)).pipe(
Effect.as(responseForRequest(request, 503)),
)
: Effect.succeed(responseForRequest(request, 200)),
),
),
),
});
yield* instance.start;
yield* TestClock.adjust(Duration.millis(600));

assert.isTrue(yield* Deferred.isDone(ready));
yield* instance.stop();
}),
);

it.effect("spawns the backend with fd3 bootstrap and fd4 telemetry", () =>
Effect.gen(function* () {
let spawnedCommand: ChildProcess.Command | undefined;
Expand Down
18 changes: 18 additions & 0 deletions apps/desktop/src/backend/DesktopBackendManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,26 @@ const closeRun = (
);
};

const LOOPBACK_HOSTNAMES = new Set(["127.0.0.1", "localhost", "[::1]"]);
// Windows takes about a second to fail a refused connection to a non-loopback address such as a
// WSL distro IP, so one sequential poller notices readiness up to a second late.
const STAGGERED_READINESS_POLLERS = 4;
const READINESS_POLLER_STAGGER = Duration.millis(250);

const waitForHttpReady = (
options: BackendProcessContext & { readonly timeout: Duration.Duration },
): Effect.Effect<void, BackendReadinessTimeoutError, HttpClient.HttpClient> => {
const poll = pollHttpReady(options);
if (LOOPBACK_HOSTNAMES.has(options.httpBaseUrl.hostname)) return poll;
return Effect.raceAll(
Array.from({ length: STAGGERED_READINESS_POLLERS }, (_, index) =>
Effect.sleep(Duration.times(READINESS_POLLER_STAGGER, index)).pipe(Effect.andThen(poll)),
),
);
};

const pollHttpReady = (
options: BackendProcessContext & { readonly timeout: Duration.Duration },
): Effect.Effect<void, BackendReadinessTimeoutError, HttpClient.HttpClient> => {
const readinessUrl = new URL(BACKEND_READINESS_PATH, options.httpBaseUrl);
return waitForHttpReadyShared({
Expand Down
Loading
Loading