From 836e852af178a6f6b49fffea8ce4e6440f2c60cb Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Fri, 30 Jan 2026 18:19:16 +0100 Subject: [PATCH] Fixes #1099 --- packages/tui/CHANGELOG.md | 4 ++++ packages/tui/src/tui.ts | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/packages/tui/CHANGELOG.md b/packages/tui/CHANGELOG.md index e76c06de..57e3ac7c 100644 --- a/packages/tui/CHANGELOG.md +++ b/packages/tui/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Fixed + +- Fixed terminal cursor remaining hidden after exiting TUI via `stop()` when a render was pending ([#1099](https://github.com/badlogic/pi-mono/pull/1099) by [@haoqixu](https://github.com/haoqixu)) + ## [0.50.5] - 2026-01-30 ### Fixed diff --git a/packages/tui/src/tui.ts b/packages/tui/src/tui.ts index 3a44efbd..92ecd46a 100644 --- a/packages/tui/src/tui.ts +++ b/packages/tui/src/tui.ts @@ -212,6 +212,7 @@ export class TUI extends Container { private maxLinesRendered = 0; // Track terminal's working area (max lines ever rendered) private previousViewportTop = 0; // Track previous viewport top for resize-aware cursor moves private fullRedrawCount = 0; + private stopped = false; // Overlay stack for modal components rendered on top of base content private overlayStack: { @@ -352,6 +353,7 @@ export class TUI extends Container { } start(): void { + this.stopped = false; this.terminal.start( (data) => this.handleInput(data), () => this.requestRender(), @@ -373,6 +375,7 @@ export class TUI extends Container { } stop(): void { + this.stopped = true; // Move cursor to the end of the content to prevent overwriting/artifacts on exit if (this.previousLines.length > 0) { const targetRow = this.previousLines.length; // Line after the last content @@ -797,6 +800,7 @@ export class TUI extends Container { } private doRender(): void { + if (this.stopped) return; const width = this.terminal.columns; const height = this.terminal.rows; let viewportTop = Math.max(0, this.maxLinesRendered - height);