Skip to content
TypeScript

fix(terminal): fish no longer stalls 10s on startup (#19685)

Theo Browne45ad47df2254
diff --git a/apps/server/src/terminal/Manager.test.ts b/apps/server/src/terminal/Manager.test.ts
index 92385a723e8..c864ba28e5c 100644
--- a/apps/server/src/terminal/Manager.test.ts
+++ b/apps/server/src/terminal/Manager.test.ts
@@ -2248,6 +2248,79 @@ it.layer(
}),
);
+ it.effect("turns off fish terminal queries unless the user chose query-term", () =>
+ Effect.gen(function* () {
+ for (const [platform, env, runtimeEnv, expected] of [
+ ["linux", {}, {}, { fish_features: "no-query-term" }],
+ [
+ "linux",
+ { fish_features: "qmark-noglob" },
+ {},
+ { fish_features: "qmark-noglob,no-query-term" },
+ ],
+ [
+ "linux",
+ { fish_features: "qmark-noglob,query-term" },
+ {},
+ { fish_features: "qmark-noglob,query-term" },
+ ],
+ [
+ "linux",
+ { fish_features: "qmark-noglob,no-query-term" },
+ {},
+ { fish_features: "qmark-noglob,no-query-term" },
+ ],
+ [
+ "linux",
+ { fish_features: "query-term" },
+ { fish_features: "qmark-noglob" },
+ { fish_features: "qmark-noglob,no-query-term" },
+ ],
+ [
+ "win32",
+ { FISH_FEATURES: "qmark-noglob" },
+ {},
+ { FISH_FEATURES: "qmark-noglob,no-query-term" },
+ ],
+ [
+ "win32",
+ { Fish_Features: "qmark-noglob,query-term" },
+ {},
+ { Fish_Features: "qmark-noglob,query-term" },
+ ],
+ [
+ "win32",
+ { FISH_FEATURES: "qmark-noglob,no-query-term" },
+ {},
+ { FISH_FEATURES: "qmark-noglob,no-query-term" },
+ ],
+ [
+ "win32",
+ { Fish_Features: "query-term" },
+ { fish_features: "qmark-noglob" },
+ { Fish_Features: "qmark-noglob,no-query-term" },
+ ],
+ [
+ "win32",
+ { FISH_FEATURES: "no-query-term" },
+ { fish_features: "qmark-noglob,query-term" },
+ { FISH_FEATURES: "qmark-noglob,query-term" },
+ ],
+ ] as const) {
+ const { manager, ptyAdapter } = yield* createManager(5, {
+ env,
+ }).pipe(Effect.provide(layerWithHostPlatform(platform)));
+ yield* manager.open(openInput({ env: runtimeEnv }));
+ const fishFeatures = Object.fromEntries(
+ Object.entries(ptyAdapter.spawnInputs[0]!.env).filter(
+ ([key]) => key.toLowerCase() === "fish_features",
+ ),
+ );
+ expect.soft(fishFeatures, JSON.stringify({ platform, env, runtimeEnv })).toEqual(expected);
+ }
+ }),
+ );
+
it.effect("filters app runtime env variables from terminal sessions", () =>
Effect.gen(function* () {
const { manager, ptyAdapter } = yield* createManager(5, {
diff --git a/apps/server/src/terminal/Manager.ts b/apps/server/src/terminal/Manager.ts
index 0a06efc5bf0..08651591f1a 100644
--- a/apps/server/src/terminal/Manager.ts
+++ b/apps/server/src/terminal/Manager.ts
@@ -1296,6 +1296,17 @@ function createTerminalSpawnEnv(
if (!spawnEnv.COLORTERM && runtimeEnv?.COLORTERM === undefined) {
spawnEnv.COLORTERM = "truecolor";
}
+ // fish 4.1+ can wait 10s at startup for a DA1 reply before a renderer can answer.
+ // Skip the query unless the user or provider already chose `query-term` or `no-query-term`.
+ const fishFeaturesKey =
+ platform === "win32"
+ ? (Object.keys(spawnEnv).find((candidate) => candidate.toLowerCase() === "fish_features") ??
+ "fish_features")
+ : "fish_features";
+ const fishFeatures = spawnEnv[fishFeaturesKey];
+ if (!fishFeatures?.includes("query-term")) {
+ spawnEnv[fishFeaturesKey] = fishFeatures ? `${fishFeatures},no-query-term` : "no-query-term";
+ }
return stripAppImageRuntimeEnv(spawnEnv);
}
diff --git a/docs/user/terminal.md b/docs/user/terminal.md
index 73413803bef..347b051f0bc 100644
--- a/docs/user/terminal.md
+++ b/docs/user/terminal.md
@@ -16,3 +16,15 @@ To copy all retained output, choose Select all in the terminal's context menu,
then copy. Cmd+A on macOS and Ctrl+Shift+A elsewhere select the same output.
Ctrl+A still moves to the beginning of shell input on Windows and Linux.
Jump to latest in the context menu returns to the current output.
+
+## fish
+
+T3 Code starts fish with `no-query-term`, avoiding startup waits for terminal
+replies. This disables optional fish features that depend on those replies.
+T3 Code's exported `fish_features` also hides any universal flags you set with
+`set -U fish_features`.
+
+To preserve those flags or enable queries with `query-term`, include them in
+`fish_features` in the environment that launches T3 Code. A shell export applies
+when you launch T3 Code from that shell; it does not configure a desktop app
+launched from the Dock or Finder. Enabling queries can restore the startup wait.