fix(tui): take the window size back when the attached terminal is used

`codeman tui` sets `window-size latest` for an attach, but a browser tab
that opens or resizes the same session mid-attach makes Codeman run
`resize-window`, which puts the window back on `manual` at the browser's
size. The terminal then showed a phone-sized pane, and typing or pasting
changed nothing until a detach and a fresh attach.

The attach now sets a per-session `client-active[91]` hook on every
session it dresses. It runs `set-window-option window-size latest` only
for the TUI's own client (`#{client_tty}`), so typing, pasting or
resizing the terminal hands the window back to it, the way plain tmux
follows whoever used it last. `restore()` removes the hooks before the
window sizes are put back, and only while they still name this tty.

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:28:06 +01:00
1 parent 5548c17c4a
commit ba61cfe4e6
8 files changed
+480 -1

No files matched your search

+10
View File
@@ -216,6 +216,16 @@ exactly as it was on detach, along with each window's size. Every session the st
can switch to is dressed and sized the same way, so switching is instant and lands
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.
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
pane stays as a corpse: the TUI refuses to attach to a dead pane and offers `r` to