Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/mux/providers/tmux/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,10 @@ export class TmuxProvider implements MuxProviderV1, WindowCapable, SidebarCapabl
tmux.setGlobalHook("after-new-window", ensureCmd);
// client-resized: terminal window changed size — enforce stored width back
tmux.setGlobalHook("client-resized", clientResizedCmd);
// pane-exited: a pane closed — kill orphaned sidebar panes (only pane left in window)
// after-kill-pane: a pane was killed — clean up orphaned sidebars and
// re-enforce width (pane-exited is not recognised by tmux 3.4+)
const paneExitedCmd = hookPost("/pane-exited");
tmux.setGlobalHook("pane-exited", paneExitedCmd);
tmux.setGlobalHook("after-kill-pane", paneExitedCmd);
}

cleanupHooks(): void {
Expand All @@ -118,7 +119,7 @@ export class TmuxProvider implements MuxProviderV1, WindowCapable, SidebarCapabl
tmux.unsetGlobalHook("after-select-window");
tmux.unsetGlobalHook("after-new-window");
tmux.unsetGlobalHook("client-resized");
tmux.unsetGlobalHook("pane-exited");
tmux.unsetGlobalHook("after-kill-pane");
}

getAllPaneCounts(): Map<string, number> {
Expand Down
1 change: 1 addition & 0 deletions packages/mux/tmux-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export const HOOK_NAMES = [
"window-layout-changed",
"after-select-window",
"after-new-window",
"after-kill-pane",
"after-resize-pane",
"pane-died",
"pane-exited",
Expand Down
4 changes: 3 additions & 1 deletion packages/runtime/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2285,13 +2285,15 @@ export function startServer(mux: MuxProvider, extraProviders?: MuxProvider[], wa
return new Response("ok", { status: 200 });
}

// pane-exited hook: a pane closed — kill orphaned sidebar panes
// pane-exited hook: a pane closed — kill orphaned sidebar panes and
// re-enforce sidebar width (tmux redistributes space when panes close)
if (req.method === "POST" && url.pathname === "/pane-exited") {
if (isSidebarVisible()) {
invalidateSidebarPaneCache();
for (const { provider } of listSidebarPanesByProvider()) {
provider.killOrphanedSidebarPanes();
}
scheduleClientResizeSync();
}
return new Response("ok", { status: 200 });
}
Expand Down