fix(tui): keep the window following the client used last, forced resizes included

A browser that opens a session sends a forced resize at its current size.
Its pty does not change, so tmux keeps the TUI's client as the latest one
and `client-active` never fires again, while Codeman's `resize-window`
still pins the window to `manual` at the browser's size. Typing in the
terminal then did nothing, which is the bug this branch fixes.

An `after-resize-window[91]` hook now puts `latest` back after Codeman's
resize, so tmux keeps deciding by the client used last; `client-active[91]`
stays for Codeman's own attach (`setManualWindowSize()`), which sets
`manual` without a resize.

The owner's tty moves into the session option `@codeman-tui-follow`, and
both hook commands are constants that read it, so no tty is interpolated
into a hook and hooks whose owner is gone do nothing. restore() and the
startup sweep drop the owner first, then our hooks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kamil KaliszandClaude Opus 5.5 committed 2026-11-24 18:39:54 +01:00
1 parent d387cf8cdb
commit dbf545ce8f
7 files changed
+344 -301

No files matched your search

+9 -8
View File
@@ -217,14 +217,15 @@ can switch to is dressed and sized the same way, so switching is instant and lan
in a pane that already fills your terminal.
The window follows whoever used it last, as plain tmux does. If a browser tab (a
phone, say) opens or resizes the session while you are attached, Codeman sizes the
window to that tab, and your terminal shows a smaller pane. Type, paste or resize
your terminal and the window fills it again. The TUI does this with a
`client-active[91]` hook on each session it dressed, which only acts for this
terminal's tmux client, and it removes the hooks on detach. Typing in the browser
tab is left to Codeman's own sizing rules. tmux older than 3.3 has no
`client-active` hook, so there the pane stays at the browser's size until you
detach and attach again.
phone, say) opens or resizes the session while you are attached, the window takes
that tab's size, and your terminal shows a smaller pane. Type, paste or resize your
terminal and the window fills it again; type in the tab and the tab gets it back.
The TUI does this with two hooks on each session it dressed (`client-active[91]`
and `after-resize-window[91]`) and a session option naming your terminal
(`@codeman-tui-follow`), and removes all three on detach. A TUI that was killed
while attached (a closed window, a dropped SSH) leaves them behind, and the next
`codeman tui` removes them. tmux older than 3.3 has no `client-active` hook, so
there the pane stays at the browser's size until you detach and attach again.
Detaching leaves the agent running; typing `exit` or pressing `Ctrl+D` would end it,
which is the difference the bar exists to make obvious. If an agent does exit, its