From 5e473b9ff6125d610784958798b27bae44aa963b Mon Sep 17 00:00:00 2001 From: I Luk Kim Date: Fri, 12 Jun 2026 18:06:05 -0700 Subject: [PATCH] fix: stop 8s terminal blank-flash on non-Claude surfaces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The periodic Claude-mode re-check (setInterval 8s) called setClaudeMode(false) on plain/codex surfaces, which ran claudeRenderer.clear() unconditionally. clear() empties the shared output element (this.el), blanking live terminal/codex content until the next repaint — perceived as text fading out then back every 8s. - app.js: remove the 8s claude re-check interval - terminal-view.js: only clear the renderer on an actual mode transition (changed), so redundant setClaudeMode/setCodexMode(false) no longer wipes the shared output - index.html: bump terminal-view.js v12, app.js v21 Verified deterministically in Playwright: pre-fix the output wiped 48->0 ~350ms after each 8s /api/claude-surfaces fetch; post-fix 18s window shows 0 fetches and content intact. Co-Authored-By: Claude Opus 4.8 --- public/index.html | 4 ++-- public/js/app.js | 7 ------- public/js/terminal-view.js | 9 +++++++-- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/public/index.html b/public/index.html index bb5b5c4..94de6c5 100644 --- a/public/index.html +++ b/public/index.html @@ -119,7 +119,7 @@ - + @@ -129,7 +129,7 @@ - + diff --git a/public/js/app.js b/public/js/app.js index 3e01f13..3f3327e 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -541,13 +541,6 @@ } } - // Periodically re-check Claude mode in case initial detection failed transiently. - setInterval(() => { - if (currentSurface && !document.body.classList.contains('claude-mode')) { - updateClaudeMode(currentSurface); - } - }, 8000); - // Browser back/forward navigation window.addEventListener('hashchange', () => { const saved = getHashSurface(); diff --git a/public/js/terminal-view.js b/public/js/terminal-view.js index 12c2c74..d6c3330 100644 --- a/public/js/terminal-view.js +++ b/public/js/terminal-view.js @@ -138,7 +138,8 @@ class TerminalView { if (!this.codexRenderer) this.codexRenderer = new CodexRenderer(this.el); if (changed && this.lines.length > 0) this.scheduleRender(); } else { - if (this.codexRenderer) this.codexRenderer.clear(); + // Same as setClaudeMode: only clear on a real transition out of codex mode. + if (changed && this.codexRenderer) this.codexRenderer.clear(); } } @@ -159,7 +160,11 @@ class TerminalView { // Re-render existing content in claude mode (fixes race with async mode detection) if (changed && this.lines.length > 0) this.scheduleRender(); } else { - if (this.claudeRenderer) this.claudeRenderer.clear(); + // Only clear on an actual transition OUT of claude mode. A redundant + // setClaudeMode(false) on an already-plain surface must NOT wipe the + // output — claudeRenderer.clear() empties the shared `this.el`, which + // would blank the live terminal/codex content until the next repaint. + if (changed && this.claudeRenderer) this.claudeRenderer.clear(); } }