You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
id(ssh): PR #594 never enters the alternate screen during a session — its leave path sends the ENTER sequence and ALT_SCREEN_LEAVE is never used #601
PR #594 (OPEN, head 090c356b52a9e1c852692785cee2d0af3e03eef1) claims to enter the alternate screen on raw SSH shell start and leave it on every exit path (#545), but the enter sequence is never written to the channel while a session runs, and the leave path sends the enter sequence again. #545 is not actually fixed by the PR as written.
Evidence (pkgs/id/src/world_ssh.rs on the PR head)
:48-50 defines both sequences:
ALT_SCREEN_ENTER = "\x1b[?1049h"
ALT_SCREEN_LEAVE = "\x1b[?1049l"
:318-320 stores the enter string in the session state: let alt_screen = if !login.command_mode { Some(ALT_SCREEN_ENTER.to_owned()) } else { None };
The only place that stored string is ever written to the channel is leave_alt_screen() at :464-475, after run_session ends:
So at exit the terminal receives \x1b[?1049h (enter) — the opposite of leaving — immediately before the channel closes.
ALT_SCREEN_LEAVE has no other reference in the file (grep over the full file at the head SHA, cross-checked via gh pr diff, gh api contents at the head SHA, and a local checkout). Nothing else in the crate emits 1049 either, so no other code path enters the buffer on the session's behalf.
The PR's own test (a_raw_shell_enters_and_leaves_the_alternate_screen, :1590) only waits for the enter bytes to arrive before dropping the channel; it never asserts that the leave sequence (1049l) is ever sent, so it cannot catch this.
On exit the terminal is told to enter the alternate screen right before disconnect; the "re-send the last error after leaving, so a refused join stays readable in scrollback" mechanism is prefixed with the enter sequence instead of the leave sequence, so the error lands on the alternate screen and disappears — the opposite of the PR's stated goal.
Acceptance criteria
A raw (non-command-mode) session writes \x1b[?1049h to the channel before the first session frame.
Every exit path (normal quit, refused join, errored session) writes \x1b[?1049l, and the stored last error, when present, is written after the leave sequence.
ALT_SCREEN_LEAVE is actually used (no dead constant), and a test asserts both the enter-at-start and leave-at-exit byte sequences on a live session, not just the enter bytes.
Command mode still never emits either sequence.
Verification note (added after filing, same run)
The PR head was built and its own test run in a scratch worktree (cargo test --features ssh,sandbox --lib world_ssh::tests::a_raw_shell_enters_and_leaves_the_alternate_screen):
rustc itself warns: constant `ALT_SCREEN_LEAVE` is never used (world_ssh.rs:50) and constant `INPUT_DROP_NOTICE_BYTES` is never used (world_ssh.rs:52) — compiler confirmation that both constants are dead.
The test passes in 1.08s — which is consistent with the bug, not against it: the test password's join is refused (compare a_wrong_password_is_refused_inside_the_shell), run_session ends, and after REFUSED_SHELL_DELAY (exactly 1s) leave_alt_screen() fires and sends the stored enter sequence plus the error, then closes the channel. The test loop sees the enter bytes — arriving at teardown, from the leave path — and passes. It never observes a leave sequence, and a live, accepted session receives no enter sequence from this code at all (grep over the whole repo at the head SHA finds no other 1049 emitter outside lockfiles/corpus data).
Activity