From 41ad684ff8f2a95d8ad873efeaa58b38ea4cdd03 Mon Sep 17 00:00:00 2001 From: Steve Dowling Date: Mon, 23 Nov 2026 13:17:51 +0800 Subject: [PATCH 1/2] Start the shell only after the terminal has loaded (fixes #3162) The initial resync (which starts the shell) fired from the first ResizeObserver callback, racing initTerminal(). While loaded is false, handleTermData drops everything xterm.js emits, so terminal query replies were lost if a freshly started shell queried before load finished. fish 4.x sends a Primary Device Attribute query (CSI 0c) at startup and waits 10s for the reply, then prints a warning. Defer the initial resync until loaded is true so replies always reach the new shell. Co-Authored-By: Claude Opus 5.5 --- frontend/app/view/term/termwrap.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/app/view/term/termwrap.ts b/frontend/app/view/term/termwrap.ts index 956d5fc9e2..3e902a5383 100644 --- a/frontend/app/view/term/termwrap.ts +++ b/frontend/app/view/term/termwrap.ts @@ -427,6 +427,7 @@ export class TermWrap { await this.loadInitialTerminalData(); } finally { this.loaded = true; + this.handleResize(); } this.runProcessIdleTimeout(); } @@ -571,7 +572,10 @@ export class TermWrap { RpcApi.ControllerInputCommand(TabRpcClient, { blockid: this.blockId, termsize: termSize }); } dlog("resize", `${this.terminal.rows}x${this.terminal.cols}`, `${oldRows}x${oldCols}`, this.hasResized); - if (!this.hasResized) { + // the initial resync can start the shell, so wait until the terminal has loaded. + // until then handleTermData drops xterm.js replies (e.g. DA1 for fish), and a + // query sent by a freshly started shell would never get its answer. + if (!this.hasResized && this.loaded) { this.hasResized = true; this.resyncController("initial resize"); } From 0e2a5206415490a0a13997a9b8419105ed156cfc Mon Sep 17 00:00:00 2001 From: Steve Dowling Date: Mon, 23 Nov 2026 13:53:44 +0800 Subject: [PATCH 2/2] Track conn status while waiting for the initial resync TermResyncHandler returned early until hasResized was set without recording connStatus. Now that the initial resync waits for the terminal to load, a disconnect/reconnect during that window would be compared against a stale status and the reconnect resync skipped. Co-Authored-By: Claude Opus 5.5 --- frontend/app/view/term/term.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frontend/app/view/term/term.tsx b/frontend/app/view/term/term.tsx index 67eb5737c6..41a445f82d 100644 --- a/frontend/app/view/term/term.tsx +++ b/frontend/app/view/term/term.tsx @@ -51,6 +51,9 @@ const TermResyncHandler = React.memo(({ blockId, model }: TerminalViewProps) => React.useEffect(() => { if (!model.termRef.current?.hasResized) { + // the initial resync (after load) uses the current status, so track it here or a + // disconnect/reconnect during load would look unchanged and skip the resync + setLastConnStatus(connStatus); return; } const isConnected = connStatus?.status == "connected";