8000 Reset terminal state can't leave the alternate screen in panes that don't report shell state · Issue #357 · amirlehmam/wmux · GitHub
[go: up one dir, main page]

Skip to content

Reset terminal state can't leave the alternate screen in panes that don't report shell state #357

Closed

Description

@jpstratman

What happens

Since #347 (2.40.0), Reset terminal state (Ctrl+Shift+R) leaves the alternate screen only when the pane's shell has reported it is back at its prompt (shellOwnsScreen in src/renderer/utils/terminal-reset.ts, used by the wmux:reset-terminal handler in useTerminal.ts). No report at all counts as "keep the alternate screen".

Only wmux's PowerShell integration sends that report in a local pane. These never do:

  • cmd: its integration emits OSC 9 and OSC 133 A/B only
  • Git Bash: wmux doesn't load wmux-bash-integration.sh into a local pane
  • WSL: wmux exports WMUX_INTEGRATION=1 into the distro but installs no rc hook (see the note in src/shared/paths.ts)
  • PowerShell without the integration script
  • SSH sessions and nested shells, where the outer PowerShell last reported running for the ssh/wsl/pwsh command and nothing reports the inner prompt

In all of these, the reset can no longer do what #175 added it for. A fullscreen program that dies without sending ESC[?1049l leaves the pane stuck on the alternate screen, and Ctrl+Shift+R now resets the other modes but leaves it there. Scrollback stays unreachable, there's no way to force the exit, and nothing says why.

A smaller case: in PowerShell, running is reported only from the integration's PSReadLine Enter handler. Without PSReadLine, or if a module rebinds Enter after the integration loads, the state reads idle while vim or Claude Code runs, so the #347 problem itself comes back there.

Steps to reproduce

Found by reading the code at v2.40.0. I haven't reproduced it in the app. Expected reproduction:

  1. Open a Git Bash or cmd pane.
  2. Simulate a program that dies on the alternate screen. In Git Bash: printf '\e[?1049h\e[H'; echo STUCK
  3. The prompt comes back on the alternate screen, with no scrollback.
  4. Press Ctrl+Shift+R.
  5. Expected: the pane returns to the normal screen with its scrollback, as in 2.39.0. Likely actual: it stays on the alternate screen.

Possible fixes

  • Use an in-band signal. An OSC 133;A (prompt start) that arrives while the active buffer is the alternate one means a shell is prompting there, so whatever entered it is gone. xterm already parses these marks for the prompt log. wmux's PowerShell, cmd and bash integrations emit them, and so do third-party integrations, including on remote hosts. This doesn't depend on running being reported, so it also covers PowerShell without PSReadLine.
  • Add a way to force it for panes with no integration at all, for example a second Ctrl+Shift+R within a few seconds, or a palette entry "Reset terminal state (leave alternate screen)". Show a short notice when the reset kept the alternate screen, so the user knows the second press exists.

wmux version

2.40.0

Anything else

Related: #347 (the fix that introduced this), #175 (what the reset is for), #345.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0