8000 fix(session): keep the requested shell spec through a remount by LevSky22 · Pull Request #197 · amirlehmam/wmux · GitHub
[go: up one dir, main page]

Skip to content

fix(session): keep the requested shell spec through a remount - #197

Merged
amirlehmam merged 1 commit into
amirlehmam:masterfrom
LevSky22:fix/preserve-shell-spec
Aug 24, 2026
Merged

amirlehmam merged 1 commit into
amirlehmam:masterfrom
LevSky22:fix/preserve-shell-spec

Conversation

@LevSky22
Copy link
Copy Markdown
Contributor

Summary

  • preserve SurfaceRef.shell as the requested respawn/session-restore specification
  • store the actual spawned executable separately as resolvedShell
  • use the resolved value only for the terminal label
  • keep persisted sessions without the new optional field compatible

This prevents a shell such as ssh user@host from becoming a destination-less ssh.exe after a remount or restore.

Validation

  • 14 focused unit tests passed
  • npm run typecheck

Closes #194

setResolvedShellForSurface wrote the resolved executable back into
SurfaceRef.shell so the tab could be labelled (e5ec559). But that field is
also the surface's respawn spec, and it is persisted: `ssh user@host` became
a bare `…\ssh.exe`, was saved that way, and a restored ssh workspace started
an ssh with no destination, printed usage and exited.

The two consumers wanted different things — PaneWrapper wants the spec, the
tab caption wants a name — so give the caption its own field. `shell` is now
immutable: whatever the surface was asked to start with.

resolvedShell is deliberately not persisted; the PTY reports it again on
every spawn, so saving it could only make it stale.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@LevSky22
LevSky22 force-pushed the fix/preserve-shell-spec branch from cd616c3 to 835b189 Compare August 24, 2026 08:14
@amirlehmam
amirlehmam merged commit 1fbff76 into amirlehmam:master Aug 24, 2026
@amirlehmam
Copy link
Copy Markdown
Owner

Merged. Thank you.

This is the kind of bug I like seeing fixed properly: the symptom was "restored ssh workspace prints usage and exits", and the tempting fix is a guard at the respawn site. Splitting the field instead — shell stays the requested spec, resolvedShell carries the executable for the caption — fixes it at the cause, and it fixes it for every spec that carries arguments, not just ssh.

Narrowing updateSurface to Partial<Omit<SurfaceRef, 'id' | 'type' | 'shell'>> in #198 is the part that makes it stay fixed. The regression was reintroducible by anyone reaching for the obvious field name; now it is a type error.

I checked the persistence side too — SessionData.workspaces[].splitTree is typed any, so resolvedShell rides along without a schema change, and older session.json files without the field restore fine. That matches the invariant from #145 (persistence types must be a superset of what every writer emits).

Shipping in v1.12.0.

amirlehmam added a commit that referenced this pull request Sep 29, 2026
…only once the shell is ready (#252, #251)

`where` against wmux's OWN PATH. Git for Windows only puts `<Git>\cmd`
there, so the lookup either missed (silent fallback to pwsh, a
console.warn nobody sees) or hit System32\bash.exe, the WSL launcher.
Measured here with PATH rebuilt from the registry (what an Explorer-launched
wmux inherits): `where bash.exe` -> System32\bash.exe + the WindowsApps
alias, no Git bash. A bare bash/git-bash alias now resolves to Git's
bin\bash.exe (via the git.exe on PATH or the default install roots) unless
PATH holds a real, non-WSL bash; it gets `--login -i` like every other Git
Bash entry point. Verified end to end under node-pty with that PATH: the
pane opens MINGW64 in the requested cwd. A spec that still cannot resolve
now says so in the pane (shellFallbackFrom). Restore needs no change:
SurfaceRef.shell is only set for an explicit choice (resolvedShell carries
the display value since #197), so a restored surface without one already
spawns the CURRENT default.

renderer on a blind 600 ms timer after pty.create, and agent-manager kept
its own prompt sniff. PtyManager now owns delivery for every caller
(startup-commands.ts): an OSC 133 A/B mark, then a prompt-shaped line, then
1.5 s of quiet output, with a 5 s ceiling on a separate timer. PowerShell
with the integration is unchanged (WMUX_STARTUP_COMMANDS, no keystrokes);
spawning pwsh 7 exactly as PtyManager does with a stand-in `claude` showed
argv `["--resume","<id>"]` intact on every run, env-baked or typed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preserve the requested shell specification across terminal remounts

2 participants

0