Refresh managed tmux commands after reconnect

Merged
TE
19d ago
+65-0

Fixes #12936.

When cmux reconnects to an existing remote tmux session, it rebinds the current relay environment but leaves the session's cmux-managed default-command unchanged. User-created panes can therefore keep launching through a deleted relay rcfile and lose the normal login-shell PATH.

The reconnect command now reads the existing default command and refreshes it only when it contains cmux's managed helper or integration markers. User-authored tmux defaults remain untouched. Added a regression test proving a stale managed command is replaced before attach, while the existing test continues to cover preservation of unrecognized options.

Testing

  • python3 scripts/verify-local.py --affected mf/main
  • Swift parse of the changed source and tests
  • git diff --check
  • SwiftPM test attempt was blocked by unrelated compiler type-check timeouts in existing CmuxFoundation tests

Changelog

Remote tmux user-created panes regain the current cmux shell integration after reconnect instead of retaining a stale relay rcfile.

Demo Video

Not included. The reconnect command and guarded option update are covered by deterministic command-builder tests.

Checklist

  • Refreshes only cmux-managed defaults
  • Preserves user-authored tmux options
  • Adds reconnect regression coverage

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Fixes #12936 so reconnecting to an existing remote tmux session refreshes a stale cmux-managed default-command, keeping user-created panes on the current shell integration instead of a deleted relay rcfile.

  • Reconnect reads the session's default-command and resets it only when it contains cmux's managed helper or shell integration markers; a failed refresh aborts before attach with remote diagnostics suppressed.
  • User-authored tmux defaults remain untouched.
  • Adds regression coverage for the replace-before-attach and abort-on-failure paths; an existing test covers preservation of unrecognized options.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed attachment to existing tmux sessions by refreshing outdated cmux-managed shell commands before connecting. Existing custom commands remain unchanged. If the refresh fails, attachment stops and returns the tmux failure status rather than continuing with an outdated command.