The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tui): stop terminal.resize on canonical sessions ("no longer attached" on every resize)
teknium1e1db185d3a9c
diff --git a/tests/e2e/core/tui_pty/test_modals_resize.py b/tests/e2e/core/tui_pty/test_modals_resize.pyindex eb9276402de..bb5efead46b 100644--- a/tests/e2e/core/tui_pty/test_modals_resize.py+++ b/tests/e2e/core/tui_pty/test_modals_resize.py@@ -41,7 +41,7 @@ TOKEN = r"\b(?:c1|a1|t1)w\d{3}\b"CELLS = ["clarify_card_survives_resize", "clarify_answer_reaches_tool", "clarify_tool_call_rendered_once","clarify_answer_not_a_user_turn",- "approval_card_survives_resize", "approval_deny_honoured",+ "approval_card_survives_resize", "approval_deny_honoured", "prompts_resize_without_detach_error","tool_output_reaches_model_in_order", "tool_output_rendered_once","transcript_ledger", "exits_clean",]@@ -69,6 +69,11 @@ def _typed(content) -> object:return content.split("\n\n[System note: ", 1)[0] if isinstance(content, str) else content+# describeRpcError's copy for a 4001 "session not found": a resize while a prompt is open is not+# a detach, so the transcript must never claim the chat lost its backend.+DETACHED_RE = re.compile(r"no\s+longer\s+attached\s+to\s+the\s+backend")++def _visible_once(tui: TmuxTui, needles: list[str]) -> str:text = "\n".join(tui.rows())bad = {n: text.count(n) for n in needles if text.count(n) != 1}@@ -135,6 +140,11 @@ def _scenario(root, victim) -> object:if not victim.exists():problem += " / the dangerous command ran before anyone answered"cells.add("approval_card_survives_resize", problem, tui.dump())+ # Scrollback + screen: covers the clarify card's resizes as well as this one's.+ n = len(DETACHED_RE.findall(tui.text()))+ cells.add("prompts_resize_without_detach_error",+ f"'no longer attached' error printed {n}x across the prompts' resizes" if n else "",+ tui.dump())tui.key("4")tui.wait_replies(2)denied = _tool_results(llm)[-1]diff --git a/ui-tui/src/app/useMainApp.ts b/ui-tui/src/app/useMainApp.tsindex 7f316dad398..bf2e3321db5 100644--- a/ui-tui/src/app/useMainApp.ts+++ b/ui-tui/src/app/useMainApp.ts@@ -734,7 +734,12 @@ export function useMainApp(gw: GatewayClient) {scrollRef.current.scrollToBottom()}- void rpc<TerminalResizeResponse>('terminal.resize', { cols: stdout.columns ?? 80, session_id: ui.sid })+ // A canonical session has no server-side width (create/resume drop `cols`) and is not+ // in the legacy registry `terminal.resize` looks up: it answers 4001 "session not+ // found", which reads as "no longer attached" on every resize.+ if (!gw.isCanonical) {+ void rpc<TerminalResizeResponse>('terminal.resize', { cols: stdout.columns ?? 80, session_id: ui.sid })+ }}, 100)}@@ -744,7 +749,7 @@ export function useMainApp(gw: GatewayClient) {clearTimeout(timer)stdout.off('resize', onResize)}- }, [rpc, stdout, ui.sid])+ }, [gw, rpc, stdout, ui.sid])const answerClarify = useCallback((answer: string) => {