Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions bin/backends/herdr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2587,14 +2587,22 @@ fm_backend_herdr_send_key() { # <target> <key>
# the composer-state guard/fallback reads around submit and injection). Workaround:
# always request a generous fetch far above any realistic viewport height, then
# trim to the caller's requested bound ourselves with `tail`.
#
# Fetches --format ansi and strips locally instead of asking for text: on herdr
# 0.8.0 a text-format `pane read --source recent` against an idle alt-screen
# agent triggers the wheel-event history harvest (src/server/alt_screen_read.rs)
# — the pane VISIBLY scrolls up for seconds and snaps back on every poll
# (herdrdev/herdr#2669, closed as dup of #2387). The ansi path skips the
# harvest entirely and returns herdr's retained rows instantly, which matches
# the pre-0.8.0 text behavior this capture was written against.
fm_backend_herdr_capture() { # <target> <lines>
fm_backend_herdr_target_ready "$1" || return 1
local lines=${2:-200} fetch out
case "$lines" in ''|*[!0-9]*) lines=200 ;; esac
fetch=$lines
case "$fetch" in ''|*[!0-9]*) fetch=200 ;; *) [ "$fetch" -ge 200 ] || fetch=200 ;; esac
out=$(fm_backend_herdr_cli "$FM_BACKEND_HERDR_SESSION" pane read "$FM_BACKEND_HERDR_PANE" --source recent --lines "$fetch" 2>/dev/null) || return 1
printf '%s' "$out" | tail -n "$lines"
out=$(fm_backend_herdr_cli "$FM_BACKEND_HERDR_SESSION" pane read "$FM_BACKEND_HERDR_PANE" --source recent --lines "$fetch" --format ansi 2>/dev/null) || return 1
printf '%s' "$out" | tail -n "$lines" | fm_composer_strip_ansi
Comment on lines +2604 to +2605

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Record live verification for ANSI capture

Captain, for Herdr 0.8.0 idle alternate-screen panes, the fix depends on vendor-specific behavior that the updated fake test cannot exercise: it only confirms that --format ansi appears in argv and returns an already-plain fixture. The maintained verification matrix still records the old text command at docs/verification/runtime-backends.md:231-238, so there is no live evidence that this path both avoids the history harvest and produces escape-free plain captures after local stripping. Update the real-Herdr guard/evidence with the new command and observed output so future Herdr upgrades cannot silently restore scrolling or leak control sequences.

Useful? React with 👍 / 👎.

}

fm_backend_herdr_capture_ansi() { # <target> <lines>
Expand Down
9 changes: 6 additions & 3 deletions tests/fm-backend-herdr.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2856,9 +2856,12 @@ test_capture_calls_pane_read() {
out=$( PATH="$fb:$PATH" FM_HERDR_LOG="$log" FM_HERDR_RESPONSES="$resp" \
bash -c '. "$0/bin/backends/herdr.sh"; fm_backend_herdr_capture default:w1:p2 250' "$ROOT" )
[ "$out" = $'line one\nline two\nline three' ] || fail "capture did not pass through pane read output, got '$out'"
assert_contains "$(cat "$log")" "HERDR_SESSION=default"$'\x1f''pane'$'\x1f''read'$'\x1f''w1:p2'$'\x1f''--source'$'\x1f''recent'$'\x1f''--lines'$'\x1f''250' \
"capture did not call pane read with the right pane id and line bound"
pass "fm_backend_herdr_capture: calls 'pane read <pane> --source recent --lines N' with the session set"
# --format ansi is load-bearing, not cosmetic: on herdr 0.8.0 a text-format
# recent read of an idle alt-screen agent triggers the wheel-event history
# harvest and the pane visibly scrolls for seconds (herdrdev/herdr#2669).
assert_contains "$(cat "$log")" "HERDR_SESSION=default"$'\x1f''pane'$'\x1f''read'$'\x1f''w1:p2'$'\x1f''--source'$'\x1f''recent'$'\x1f''--lines'$'\x1f''250'$'\x1f''--format'$'\x1f''ansi' \
"capture did not call pane read with the right pane id, line bound, and the harvest-skipping ansi format"
pass "fm_backend_herdr_capture: calls 'pane read <pane> --source recent --lines N --format ansi' with the session set"
}

test_capture_works_around_small_lines_bug() {
Expand Down
Loading