From 1eebc384f60b73f8c0dbcd2dbcb1ce578702be46 Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 15 Nov 2026 17:46:47 +0100 Subject: 0.6.2: resizing no longer duplicates the prompt The terminal reflows the input block and moves the caret with it, so drawing on resize produced a second copy. Recompute the caret's row and let the next redraw work from the reflowed block. Documented the dependency on reflowing terminals. --- CHANGELOG.md | 9 +++++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- docs/KNOWN-ISSUES.md | 15 ++++++++++++--- scripts/ux-check.sh | 24 ++++++++++++++++++++++++ src/line.rs | 14 ++++++++------ 6 files changed, 55 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d33608d..99b92db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,15 @@ break the interface, **PATCH** for bug fixes. file, and the tool schemas the model sees. Anything a script or a resumed session could depend on counts as API. +## 0.6.2 + +### Fixed +- Resizing the terminal duplicated the prompt: the terminal had already reflowed + the block, and the editor then drew a second copy below it. The editor now + emits nothing on resize and only recomputes where the caret sits, so the next + redraw lands on the reflowed block. +- `scripts/ux-check.sh` now also covers narrowing a pane while typing. + ## 0.6.1 ### Fixed diff --git a/Cargo.lock b/Cargo.lock index 8b92fd5..0ce01e2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,7 +10,7 @@ checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" [[package]] name = "agent686" -version = "0.6.1" +version = "0.6.2" dependencies = [ "crossterm", "libc", diff --git a/Cargo.toml b/Cargo.toml index 147541b..38fc125 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "agent686" -version = "0.6.1" +version = "0.6.2" edition = "2021" description = "A small coding agent for a 32-bit Debian box" publish = false diff --git a/docs/KNOWN-ISSUES.md b/docs/KNOWN-ISSUES.md index 79ce26c..6bc72c6 100644 --- a/docs/KNOWN-ISSUES.md +++ b/docs/KNOWN-ISSUES.md @@ -44,11 +44,20 @@ bump, not a sandbox; `bash` has no sandbox by design. `--list`, `--doctor` and `--show` print for humans. A `--json` shape would let scripts consume them. +## Resize relies on the terminal reflowing + +Already-printed output belongs to the terminal: this harness never re-renders +it. Terminals that reflow their scrollback (tmux, VTE, kitty, foot, wezterm) do +the right thing on resize, and the input block follows because the caret moves +with the text. xterm does not reflow; there a resize can leave the prompt +misplaced until you press Enter or Ctrl-C. Making it independent of the terminal +would mean owning the screen (alt-screen TUI) or clearing and re-rendering the +transcript, which loses scrollback. + ## Editor gaps -Wide characters, combining marks and tabs are now measured correctly, and a -resize starts a fresh prompt line instead of erasing output. There is still no -Ctrl-L redraw and no Ctrl-Z suspend. +Wide characters, combining marks and tabs are measured correctly. There is still +no Ctrl-L redraw and no Ctrl-Z suspend. ## No session garbage collection diff --git a/scripts/ux-check.sh b/scripts/ux-check.sh index 019f63d..204fc98 100755 --- a/scripts/ux-check.sh +++ b/scripts/ux-check.sh @@ -78,6 +78,30 @@ if echo "$screen" | grep -q 'line two.*Hello from the mock'; then fail_msg "the answer was written on the same line as the prompt" fi +# Resizing while typing must not duplicate the prompt or erase what is above it. +printf 'ZEBRA alpha beta gamma delta epsilon zeta eta theta iota kappa lambda mu' \ + | tmux load-buffer -b uxresize - +tmux paste-buffer -p -b uxresize -t "$session" +sleep 0.5 +tmux resize-window -t "$session" -x 40 -y 24 +sleep 0.6 +screen=$(tmux capture-pane -p -t "$session") +[ "$(echo "$screen" | grep -c ZEBRA)" -eq 1 ] \ + || fail_msg "resizing to 40 columns duplicated the prompt" +echo "$screen" | grep -q "Hello from the mock provider" \ + || fail_msg "resizing erased the output above the prompt" + +# Typing after the resize must redraw in the right place. +tmux send-keys -t "$session" End +sleep 0.3 +tmux send-keys -t "$session" -l "!" +sleep 0.4 +screen=$(tmux capture-pane -p -t "$session") +[ "$(echo "$screen" | grep -c ZEBRA)" -eq 1 ] \ + || fail_msg "redrawing after a resize duplicated the prompt" +echo "$screen" | grep -q "Hello from the mock provider" \ + || fail_msg "redrawing after a resize erased output above" + if [ "$fail" -ne 0 ]; then echo "--- final screen ---" >&2 echo "$screen" >&2 diff --git a/src/line.rs b/src/line.rs index 613dffe..2b6c894 100644 --- a/src/line.rs +++ b/src/line.rs @@ -58,12 +58,14 @@ impl Editor { draw(prompt, &buffer, cursor, &mut state)?; } Event::Resize(_, _) => { - // The terminal reflowed the block we were tracking, so the - // old row count is meaningless. Start a fresh prompt line - // rather than risk erasing output above it. - println!(); - state = DrawState::default(); - draw(prompt, &buffer, cursor, &mut state)?; + // The terminal has already reflowed the block and moved the + // caret with it, so drawing again here would duplicate the + // prompt. Recompute only where the caret now sits relative + // to the block; the next redraw moves up from there. + let width = terminal_width(); + let (cursor_row, _) = layout(prompt, &buffer, cursor, width); + state.cursor_row = cursor_row; + state.rows = layout(prompt, &buffer, buffer.len(), width).0 + 1; } Event::Key(key) if key.kind == KeyEventKind::Press => { match handle_key(key, &mut buffer, &mut cursor, self) { -- cgit v1.2.3