Skip to content

Commit 87f8a18

Browse files
fix(tui): avoid startup cursor position query
Remove the redundant ratatui clear that waits for a cursor response. Align login lifecycle and generated demo documentation with current behavior. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
1 parent 3707026 commit 87f8a18

4 files changed

Lines changed: 18 additions & 12 deletions

File tree

scripts/render-demo-gif.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44
# Two stages:
55
# 1. generate_tui_demo paints the signed lock TUI (splash → typing → working)
66
# at 120×40 through cortex-tui.
7-
# 2. scripts/ansi-frames-to-gif.py rasterises those frames and calls ffmpeg.
7+
# 2. scripts/ansi-frames-to-gif.py rasterises those frames, composites a
8+
# macOS-styled desktop and moving pointer, and calls ffmpeg.
89
#
9-
# Requires: cargo, ffmpeg, python3 with Pillow.
10-
# Output size is 1232×912 with the default 16px font and 16px padding.
10+
# Requires: cargo, ffmpeg, python3 with Pillow, and a supported sans font
11+
# (Liberation Sans, DejaVu Sans, Noto Sans, or macOS Helvetica/Arial).
12+
# Raw raster: 1232×912 at the default 16px font and padding.
13+
# Composed GIF: 1416×1140. Validate with python3 scripts/check-macos-demo.py.
1114

1215
set -euo pipefail
1316

src/cortex-tui/src/runner/login_screen.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Login Screen
22
//!
3-
//! Inline TUI (no alternate screen) so the host shell prompt stays in
4-
//! scrollback above the picker.
3+
//! Uses the alternate screen by default. `run_with_options` follows the
4+
//! caller's terminal preferences; inline mode preserves scrollback.
55
66
use std::path::{Path, PathBuf};
77
use std::time::{Duration, Instant};

src/cortex-tui/src/runner/terminal.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,8 @@ impl CortexTerminal {
279279
// Own cleanup before the first fallible setup operation.
280280
init_terminal(&options)?;
281281
let backend = CrosstermBackend::new(stdout());
282-
let mut terminal = Terminal::new(backend)?;
283-
// Ratatui's initial diff assumes blank cells, even on the primary screen.
284-
// Clear the visible viewport, not scrollback, before the first frame.
285-
if options.clear_on_start {
286-
terminal.clear()?;
287-
}
282+
// init_screen already clears when requested; Terminal::clear would query the cursor.
283+
let terminal = Terminal::new(backend)?;
288284

289285
Ok(Self {
290286
terminal,

src/cortex-tui/src/runner/terminal_tests.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,20 @@ fn startup_clears_visible_screen_in_both_modes() {
88
assert!(startup.find("\x1b[?1049h").unwrap() < startup.find("\x1b[2J").unwrap());
99
assert!(startup.contains("\x1b[0m\x1b[2J\x1b[1;1H"));
1010
assert!(!startup.contains("\x1b[3J"), "never erase scrollback");
11+
assert!(
12+
!startup.contains("\x1b[6n"),
13+
"startup must not query the cursor"
14+
);
1115

1216
let mut output = Vec::new();
1317
init_screen(&mut output, &TerminalOptions::inline()).unwrap();
1418
let startup = String::from_utf8(output).unwrap();
1519
assert!(startup.contains("\x1b[0m\x1b[2J\x1b[1;1H"));
1620
assert!(!startup.contains("\x1b[3J"));
21+
assert!(
22+
!startup.contains("\x1b[6n"),
23+
"startup must not query the cursor"
24+
);
1725
}
1826

1927
#[test]
@@ -53,7 +61,6 @@ fn inline_preflight_options_preserve_scrollback_without_switching_screens() {
5361
)
5462
.unwrap();
5563
let output = String::from_utf8(output).unwrap();
56-
// CortexTerminal also clears the visible viewport after construction.
5764
// 2J is allowed; switching screens and purging history are not.
5865
for forbidden in ["\x1b[?1049h", "\x1b[?1049l", "\x1b[3J"] {
5966
assert!(!output.contains(forbidden), "unexpected {forbidden:?}");

0 commit comments

Comments
 (0)