fix: use switch-client when already inside a tmux session #2
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
backmeupplz/superharness!2
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/nested-tmux-session"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #1
Problem
Running
superharnessfrom within an existing tmux session (common in Linux setups that use tmux as the default terminal multiplexer, e.g. Omarchy) always fails:tmux attach-sessionrefuses to run when$TMUXis already set because it detects nesting and exits non-zero, which triggersbail!("tmux attach failed").Fix
Detect
$TMUXbefore attaching. When it is set, useswitch-client -t superharnessinstead ofattach-session -t superharness.switch-clientmoves the current tmux client to the superharness session without creating a nested session — exactly the right behaviour. Becauseswitch-clientreturns immediately (unlikeattach-session, which blocks until the user detaches), the post-attach session-cleanup block is skipped in this path so the session is not killed right after switching to it.Behaviour
tmux attach failedTest
Made with Cursor
Thanks for the PR! This fix has already shipped in main — we landed the same
switch-clientapproach in commit10f7ede(feat/tmux-attach). Closing as already resolved, but appreciate you taking the time to track this down and submit a fix!Pull request closed