Title: 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 · Issue #601 · developing-today/code · GitHub
Open Graph Title: 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 · Issue #601 · developing-today/code
X Title: 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 · Issue #601 · developing-today/code
Description: Contribute to developing-today/code development by creating an account on GitHub.
Open Graph Description: Contribute to developing-today/code development by creating an account on GitHub.
X Description: Contribute to developing-today/code development by creating an account on GitHub.
Opengraph URL: https://github.com/developing-today/code
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"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","articleBody":"## Finding\n\nPR #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.\n\n## Evidence (`pkgs/id/src/world_ssh.rs` on the PR head)\n\n- `:48-50` defines both sequences:\n - `ALT_SCREEN_ENTER = \"\\x1b[?1049h\"`\n - `ALT_SCREEN_LEAVE = \"\\x1b[?1049l\"`\n- `: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 };`\n- The only place that stored string is ever written to the channel is `leave_alt_screen()` at `:464-475`, after `run_session` ends:\n\n ```rust\n let Some(sequence) = self.alt_screen.take() else { return; };\n let text = match self.last_error.take() {\n Some(error) => format!(\"{sequence}\\r\\n{error}\\r\\n\"),\n None => sequence,\n };\n let _ = self.handle.data(self.channel, text).await;\n ```\n\n So at exit the terminal receives `\\x1b[?1049h` (enter) — the opposite of leaving — immediately before the channel closes.\n- `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.\n- 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.\n\n## Why it matters\n\n- Raw sessions keep repainting into scrollback for the whole session — exactly the #545 complaint.\n- 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.\n\n## Acceptance criteria\n\n- A raw (non-command-mode) session writes `\\x1b[?1049h` to the channel before the first session frame.\n- 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.\n- `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.\n- Command mode still never emits either sequence.\n\n## Verification note (added after filing, same run)\n\nThe 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`):\n\n- 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.\n- 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).\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-22T16:20:25Z","url":"https://github.com/developing-today/code/issues/601"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/issues/:id(.:format) |
| route-controller | issues |
| route-action | show |
| fetch-nonce | v2:d914e0d0-5dfc-5e9d-8605-899587d363f9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E8CE:1CD523:7F3704:A5908D:6B062D04 |
| html-safe-nonce | 94da4d00681b9def2d49ffc1ffb9689d566e0c4b9eea49d06e89976d9c06f977 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOENFOjFDRDUyMzo3RjM3MDQ6QTU5MDhEOjZCMDYyRDA0IiwidmlzaXRvcl9pZCI6IjEwNzcxMzM0Nzk4NjQ4Mzk0MjgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b8c77309d7222d80c1850dfbe86035c58c25f45b416d8aadb4188605caf8b6c3 |
| hovercard-subject-tag | repository:627308783 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/developing-today/code/issues/601 |
| twitter:image | https://opengraph.githubassets.com/c1a2d415bd2c796fea2e23b2fed64a1efc7802730482e5b3777242c3e81bd5e2/developing-today/code |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c1a2d415bd2c796fea2e23b2fed64a1efc7802730482e5b3777242c3e81bd5e2/developing-today/code |
| og:image:alt | Contribute to developing-today/code development by creating an account on GitHub. |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7f961de5dd5c5d4aca24d33f8b3ffb3fb8b2ef53d0a4f32f01f0a790e512f6d3 |
| turbo-cache-control | no-cache |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 494ea0bb1e0feef734a83e2628697647755e8864 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width