Skip to content

fix(tmux): replace pane-exited with after-kill-pane; enforce width on pane close#40

Open
kanlac wants to merge 2 commits into
Ataraxy-Labs:mainfrom
kanlac:fix/enforce-sidebar-width-on-pane-kill
Open

fix(tmux): replace pane-exited with after-kill-pane; enforce width on pane close#40
kanlac wants to merge 2 commits into
Ataraxy-Labs:mainfrom
kanlac:fix/enforce-sidebar-width-on-pane-kill

Conversation

@kanlac
Copy link
Copy Markdown

@kanlac kanlac commented May 6, 2026

Problem

Two features that were supposed to work after a pane is closed have never actually fired on tmux 3.4+:

  1. Orphaned sidebar cleanup — when all content panes in a window are closed, the sidebar pane is supposed to be killed automatically.
  2. Sidebar width enforcement — when a pane is closed, tmux redistributes window space and can resize the sidebar away from its configured width. The server was supposed to snap it back.

Both are broken because they relied on the pane-exited hook, which is silently ignored by tmux 3.4+. set-hook -g pane-exited ... returns exit code 0 but the hook never appears in show-hooks and never fires.

Fix

packages/mux/providers/tmux/src/provider.ts
Replace pane-exited with after-kill-pane, which fires reliably after every kill-pane command on modern tmux. Also update cleanupHooks() to unset the correct hook name on shutdown.

packages/mux/tmux-sdk/src/index.ts
Add after-kill-pane to HOOK_NAMES so the type is correct.

packages/runtime/src/server/index.ts
Add scheduleClientResizeSync() to the /pane-exited handler so sidebar width is enforced after a pane close, not just on terminal resize.

Verified on

  • tmux 3.6a / macOS — after-kill-pane appears in show-hooks and fires correctly
  • Closing all content panes in a window kills the orphaned sidebar automatically
  • Sidebar width is restored after closing a pane (no longer drifts)
  • pane-exited no longer appears in show-hooks (was silently registered before this fix)

Test plan

  • Open a window with sidebar + 2 content panes; close one pane; verify sidebar width stays at configured value
  • Close all content panes; verify sidebar pane is killed automatically (window closes)
  • Confirm after-kill-pane appears in tmux show-hooks -g after starting the server
  • Confirm pane-exited no longer appears

kanlac added 2 commits May 7, 2026 02:24
When a pane is killed, tmux redistributes window space and can shrink
or grow the sidebar pane. The pane-exited handler already ran to clean
up orphaned sidebars, but did not re-enforce the stored sidebar width.

Call scheduleClientResizeSync() after the orphan cleanup so the sidebar
is snapped back to its configured width, same as on a terminal resize.
pane-exited is silently ignored by tmux 3.4+ — set-hook accepts it
without error but show-hooks never lists it and it never fires. As a
result, orphaned sidebar cleanup and post-kill width enforcement have
never worked on modern tmux.

Replace with after-kill-pane, which fires reliably after kill-pane.
Also add after-kill-pane to HOOK_NAMES in tmux-sdk so the type is
correct and cleanupHooks can unset it on shutdown.
Copy link
Copy Markdown

@inspect-review inspect-review Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inspect review

Triage: 5 entities analyzed | 0 critical, 0 high, 4 medium, 1 low
Verdict: standard_review

Findings (1)

  1. [low] Stale tmux global hook cleanup: cleanupHooks() no longer unsets the previously-used "pane-exited" hook. If an older version installed the "pane-exited" global hook, upgrading to this version will leave it installed, potentially causing duplicate POSTs to /pane-exited (old pane-exited hook + new after-kill-pane hook). Evidence: provider.ts changed from tmux.unsetGlobalHook("pane-exited") to tmux.unsetGlobalHook("after-kill-pane"), with no remaining unset for "pane-exited".

Reviewed by inspect | Entity-level triage found 0 high-risk changes

@Palanikannan1437 Palanikannan1437 self-requested a review May 18, 2026 20:06
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.

1 participant