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"; 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"); }