From 690e2ea5d5b5caeaaeb06dd212c50911399ad35e Mon Sep 17 00:00:00 2001 From: liplus-lin-lay Date: Mon, 13 Apr 2026 20:21:30 +0900 Subject: [PATCH] fix(tabs): suppress resize_pty on tab switch to prevent CLI screen clear MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit タブ切り替え時に fit() → onResize → resize_pty が発火し、CLI の Ink UI が 画面クリア+再描画を行うことでターミナル内容が消える問題を修正。 suppressResize フラグでタブ活性化中の resize_pty 送信を抑制。 fit() 完了後 100ms で解除し、通常のウィンドウリサイズは引き続き動作。 Refs #69 Co-Authored-By: Claude Opus 4.6 (1M context) --- src/tabs.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/tabs.ts b/src/tabs.ts index e6c920a..cde03a5 100644 --- a/src/tabs.ts +++ b/src/tabs.ts @@ -40,6 +40,7 @@ interface TabState { unlistenData: UnlistenFn | null; unlistenExit: UnlistenFn | null; resizeObserver: ResizeObserver | null; + suppressResize: boolean; } // --------------------------------------------------------------------------- @@ -351,6 +352,7 @@ export class TabManager { unlistenData: null, unlistenExit: null, resizeObserver, + suppressResize: false, }; // Register input/resize handlers ONCE per terminal (not per start) @@ -360,7 +362,7 @@ export class TabManager { } }); terminal.onResize(({ cols, rows }) => { - if (tabState.ptyId) { + if (tabState.ptyId && !tabState.suppressResize) { invoke("resize_pty", { id: tabState.ptyId, cols, rows }); } }); @@ -387,14 +389,19 @@ export class TabManager { // Activate new const state = this.tabs.get(tabId); if (state) { + // Suppress resize_pty during tab activation to prevent CLI screen clear + state.suppressResize = true; state.containerEl.style.display = "flex"; state.tabEl.classList.add("tab-active"); this.activeTabId = tabId; this.updateToolbar(state); // Re-fit terminal after it becomes visible - // Use requestAnimationFrame to ensure layout is complete before fitting requestAnimationFrame(() => { state.fitAddon.fit(); + // Re-enable resize after fit settles + setTimeout(() => { + state.suppressResize = false; + }, 100); }); } }