Skip to content

Commit cd65e56

Browse files
fix(terminal): preserve fish environment choices and clarify tradeoffs
1 parent 1c37ea9 commit cd65e56

3 files changed

Lines changed: 24 additions & 16 deletions

File tree

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,17 +2147,22 @@ it.layer(
21472147

21482148
it.effect("turns off fish terminal queries unless the user chose query-term", () =>
21492149
Effect.gen(function* () {
2150-
for (const [parentFeatures, expected] of [
2151-
[undefined, "no-query-term"],
2152-
["qmark-noglob", "qmark-noglob,no-query-term"],
2153-
["query-term", "query-term"],
2154-
["no-query-term", "no-query-term"],
2150+
for (const [parentFeatures, runtimeFeatures, expected] of [
2151+
[undefined, undefined, "no-query-term"],
2152+
["qmark-noglob", undefined, "qmark-noglob,no-query-term"],
2153+
["qmark-noglob,query-term", undefined, "qmark-noglob,query-term"],
2154+
["qmark-noglob,no-query-term", undefined, "qmark-noglob,no-query-term"],
2155+
["query-term", "qmark-noglob", "qmark-noglob,no-query-term"],
21552156
] as const) {
21562157
const { manager, ptyAdapter } = yield* createManager(5, {
21572158
shellResolver: () => "/bin/sh",
21582159
env: { fish_features: parentFeatures },
21592160
});
2160-
yield* manager.open(openInput());
2161+
yield* manager.open(
2162+
openInput({
2163+
env: runtimeFeatures === undefined ? {} : { fish_features: runtimeFeatures },
2164+
}),
2165+
);
21612166
expect(ptyAdapter.spawnInputs[0]?.env.fish_features).toBe(expected);
21622167
}
21632168
}),

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,10 +1283,10 @@ function createTerminalSpawnEnv(
12831283
if (!spawnEnv.COLORTERM && runtimeEnv?.COLORTERM === undefined) {
12841284
spawnEnv.COLORTERM = "truecolor";
12851285
}
1286-
// fish 4.1+ blocks startup on a DA1 query that no renderer may be attached to answer yet.
1287-
// Turning off its terminal queries skips that wait; an explicit `query-term` choice wins.
1288-
const fishFeatures = spawnEnv.fish_features ?? "";
1289-
if (!/\bquery-term\b/.test(fishFeatures)) {
1286+
// fish 4.1+ can wait 10s at startup for a DA1 reply before a renderer can answer.
1287+
// Skip the query unless the user or provider already chose `query-term` or `no-query-term`.
1288+
const fishFeatures = spawnEnv.fish_features;
1289+
if (!fishFeatures?.includes("query-term")) {
12901290
spawnEnv.fish_features = fishFeatures ? `${fishFeatures},no-query-term` : "no-query-term";
12911291
}
12921292
return stripAppImageRuntimeEnv(spawnEnv);

‎docs/user/terminal.md‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@ Jump to latest in the context menu returns to the current output.
1919

2020
## fish
2121

22-
T3 Code starts terminals with fish's `no-query-term` feature, so fish 4.1 and
23-
later start without waiting for terminal replies. This turns off fish features
24-
that need those replies. To keep them, add `query-term` to `fish_features` in
25-
the environment that starts T3 Code; fish can then pause at startup. T3 Code's
26-
`fish_features` value replaces your universal one, so export any other flags you
27-
use there too.
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)