The JS pager paints over the user's normal screen: enter does tty.raw + hide-cursor + ESC[2J clear, exit clears again — the shell's screen content is destroyed and the pager frame pollutes scrollback. vim/less switch to the alternate screen buffer (ESC[?1049h on enter, ESC[?1049l on exit) so the prior screen is restored intact on quit. Do the same in Bro pager, views/bro/pager.js.
views/bro/pager.js run(): line 956 977 writes tty.raw(this.fd), then ttyWrite(fd, HIDE_CUR + MOUSE_ON + PASTE_ON); the finally at MOUSE_OFF + PASTE_OFF + ESC[0m + SHOW_CUR + CLEAR + tty.cook. No ?1049 anywhere in be/.
CLEAR = ESC[2J + ESC[H (line 61) — on a normal screen the old frames get pushed into scrollback.Bracket the whole raw-mode session in the alternate screen buffer, restoring the user's screen on every exit path.
ESC[?1049h FIRST, before HIDE_CUR/MOUSE_ON/PASTE_ON.ESC[?1049l LAST, after mouse/paste off + SGR reset + SHOW_CUR; drop the final CLEAR — restore makes it moot.?1049h...?1049l bracket around a pager session (see test/bro/pager/pty.js driver).view/bro.js) and non-tty/piped output untouched.?1049 bytes (the bracket lives inside the tty-only run() path).?1049 (save cursor + alt screen + clear, restore on l) over the legacy ?47+?1048 pair — it is the terminfo smcup/rmcup pair on every terminal jab targets.
?1049h, ends ?1049l, no ?1049 when stdout is a pipe.Editor handover (_suspend/_resume, pager.js ~1041, BE-047) cooks/re-raws WITHOUT leaving the alt screen — a spawned vim doing its own ?1049h/l may drop back to the NORMAL screen under the pager on exit. Out of this ticket's scope, left untouched (test/bro/vim green); candidate follow-up ticket.
Landed in worktree work/BRO-027, NOT merged: ?972f8b60 (pager.js + test bump), ?4235044a (test subtree: test/bro/altscreen/ run.sh+alt.js, ctest name be-js-bro-altscreen). ALT_ON/OFF at pager.js:73, bracket at :1324/:1345. Suite 267/267 (-LE big); orchestrator re-verified the test solo.