Skip to content

Commit 45ad47d

Browse files
t3dotggclaudejuliusmarminge
authored
fix(terminal): fish no longer stalls 10s on startup (#19685)
Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Julius Marminge <[email protected]>
1 parent 2bae2b1 commit 45ad47d

3 files changed

Lines changed: 96 additions & 0 deletions

File tree

‎apps/server/src/terminal/Manager.test.ts‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2248,6 +2248,79 @@ it.layer(
22482248
}),
22492249
);
22502250

2251+
it.effect("turns off fish terminal queries unless the user chose query-term", () =>
2252+
Effect.gen(function* () {
2253+
for (const [platform, env, runtimeEnv, expected] of [
2254+
["linux", {}, {}, { fish_features: "no-query-term" }],
2255+
[
2256+
"linux",
2257+
{ fish_features: "qmark-noglob" },
2258+
{},
2259+
{ fish_features: "qmark-noglob,no-query-term" },
2260+
],
2261+
[
2262+
"linux",
2263+
{ fish_features: "qmark-noglob,query-term" },
2264+
{},
2265+
{ fish_features: "qmark-noglob,query-term" },
2266+
],
2267+
[
2268+
"linux",
2269+
{ fish_features: "qmark-noglob,no-query-term" },
2270+
{},
2271+
{ fish_features: "qmark-noglob,no-query-term" },
2272+
],
2273+
[
2274+
"linux",
2275+
{ fish_features: "query-term" },
2276+
{ fish_features: "qmark-noglob" },
2277+
{ fish_features: "qmark-noglob,no-query-term" },
2278+
],
2279+
[
2280+
"win32",
2281+
{ FISH_FEATURES: "qmark-noglob" },
2282+
{},
2283+
{ FISH_FEATURES: "qmark-noglob,no-query-term" },
2284+
],
2285+
[
2286+
"win32",
2287+
{ Fish_Features: "qmark-noglob,query-term" },
2288+
{},
2289+
{ Fish_Features: "qmark-noglob,query-term" },
2290+
],
2291+
[
2292+
"win32",
2293+
{ FISH_FEATURES: "qmark-noglob,no-query-term" },
2294+
{},
2295+
{ FISH_FEATURES: "qmark-noglob,no-query-term" },
2296+
],
2297+
[
2298+
"win32",
2299+
{ Fish_Features: "query-term" },
2300+
{ fish_features: "qmark-noglob" },
2301+
{ Fish_Features: "qmark-noglob,no-query-term" },
2302+
],
2303+
[
2304+
"win32",
2305+
{ FISH_FEATURES: "no-query-term" },
2306+
{ fish_features: "qmark-noglob,query-term" },
2307+
{ FISH_FEATURES: "qmark-noglob,query-term" },
2308+
],
2309+
] as const) {
2310+
const { manager, ptyAdapter } = yield* createManager(5, {
2311+
env,
2312+
}).pipe(Effect.provide(layerWithHostPlatform(platform)));
2313+
yield* manager.open(openInput({ env: runtimeEnv }));
2314+
const fishFeatures = Object.fromEntries(
2315+
Object.entries(ptyAdapter.spawnInputs[0]!.env).filter(
2316+
([key]) => key.toLowerCase() === "fish_features",
2317+
),
2318+
);
2319+
expect.soft(fishFeatures, JSON.stringify({ platform, env, runtimeEnv })).toEqual(expected);
2320+
}
2321+
}),
2322+
);
2323+
22512324
it.effect("filters app runtime env variables from terminal sessions", () =>
22522325
Effect.gen(function* () {
22532326
const { manager, ptyAdapter } = yield* createManager(5, {

‎apps/server/src/terminal/Manager.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,6 +1296,17 @@ function createTerminalSpawnEnv(
12961296
if (!spawnEnv.COLORTERM && runtimeEnv?.COLORTERM === undefined) {
12971297
spawnEnv.COLORTERM = "truecolor";
12981298
}
1299+
// fish 4.1+ can wait 10s at startup for a DA1 reply before a renderer can answer.
1300+
// Skip the query unless the user or provider already chose `query-term` or `no-query-term`.
1301+
const fishFeaturesKey =
1302+
platform === "win32"
1303+
? (Object.keys(spawnEnv).find((candidate) => candidate.toLowerCase() === "fish_features") ??
1304+
"fish_features")
1305+
: "fish_features";
1306+
const fishFeatures = spawnEnv[fishFeaturesKey];
1307+
if (!fishFeatures?.includes("query-term")) {
1308+
spawnEnv[fishFeaturesKey] = fishFeatures ? `${fishFeatures},no-query-term` : "no-query-term";
1309+
}
12991310
return stripAppImageRuntimeEnv(spawnEnv);
13001311
}
13011312

‎docs/user/terminal.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,15 @@ To copy all retained output, choose Select all in the terminal's context menu,
1616
then copy. Cmd+A on macOS and Ctrl+Shift+A elsewhere select the same output.
1717
Ctrl+A still moves to the beginning of shell input on Windows and Linux.
1818
Jump to latest in the context menu returns to the current output.
19+
20+
## fish
21+
22+
T3 Code starts fish with `no-query-term`, avoiding startup waits for terminal
23+
replies. This disables optional fish features that depend on those replies.
24+
T3 Code's exported `fish_features` also hides any universal flags you set with
25+
`set -U fish_features`.
26+
27+
To preserve those flags or enable queries with `query-term`, include them in
28+
`fish_features` in the environment that launches T3 Code. A shell export applies
29+
when you launch T3 Code from that shell; it does not configure a desktop app
30+
launched from the Dock or Finder. Enabling queries can restore the startup wait.

0 commit comments

Comments
 (0)