From b6c98d8a41a73bdc329aece11211a64741469d2a Mon Sep 17 00:00:00 2001 From: Erik M Jacobs Date: Tue, 20 Jan 2026 09:54:52 -0500 Subject: [PATCH] feat: Add F6 shortcut to force terminal redraw Adds F6 keyboard shortcut to force a complete terminal redraw. This fixes garbled display issues that can occur in xterm.js. The implementation uses a resize trick (shrink then restore) to force xterm.js to completely re-render the terminal content. Co-Authored-By: Claude Opus 4.5 --- src/public/app.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/public/app.js b/src/public/app.js index b35e564..364dc8e 100644 --- a/src/public/app.js +++ b/src/public/app.js @@ -360,6 +360,39 @@ class ClaudeCodeWebInterface { this.send({ type: 'resize', cols, rows }); } }); + + // Handle F6 to force terminal redraw (fixes garbled display) + // F6 is not used by xterm or browsers, so it works reliably + document.addEventListener('keydown', (event) => { + if (event.code === 'F6' || event.key === 'F6') { + event.preventDefault(); + event.stopPropagation(); + event.stopImmediatePropagation(); + console.log('F6 pressed, forcing terminal redraw...'); + if (this.terminal && this.fitAddon) { + try { + // Force full re-render by resize trick: + // 1. Get current dimensions + const cols = this.terminal.cols; + const rows = this.terminal.rows; + // 2. Resize to slightly different size + this.terminal.resize(cols - 1, rows); + // 3. Restore original size (forces complete re-render) + requestAnimationFrame(() => { + this.terminal.resize(cols, rows); + this.terminal.refresh(0, rows - 1); + this.terminal.scrollToBottom(); + console.log('Terminal redraw completed (F6)'); + }); + } catch (e) { + console.error('Terminal redraw failed:', e); + } + } else { + console.warn('Terminal or fitAddon not available'); + } + return false; + } + }, true); } showSessionSelectionModal() {