The one-row nudge before a forced resize at an unchanged size runs only
for a tmux-backed session. On a direct PTY the process is the agent
itself, which got two height changes where master sent none. The
unrelated table reformatting in docs/tui.md is dropped.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The live-pane close case moves into test/kill-pid-guard.test.ts, whose
harness answers ps from a fixed table. In tmux-manager.test.ts the mock
keeps the real execFile, so the walk read this machine's process table.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Review follow-up on the follow-typing attach.
- Redraw (and every forced resize at an unchanged size) handed the window
back to the terminal: an unchanged pty sends tmux no SIGWINCH, so the
terminal stayed the latest client and the after-resize-window hook undid
the resize-window. Session.resize() now nudges the pty one row first
(FORCED_RESIZE_NUDGE_MS), then applies the size, so tmux counts the tab
as the client used last; the second move bumps the guarded geometry
revision too. Under manual with no attach the agent sees no change.
- With the nudge, client-active[91] alone covers every case, so the
after-resize-window hook is gone. It kept latest through every browser
resize and cost the agent three height changes per resize; now the first
resize after the terminal was used costs two and later ones one. The
cost is stated next to the hook.
- The leak sweep matched owners by tty, and Linux hands the next terminal
the pty that just closed, so the common leak was never swept. The arm
now records the TUI's pid (@codeman-tui-follow-pid), and the sweep keeps
only sessions this process armed (a Set filled before the first write)
or whose pid is another live process. One list-sessions call reads every
owner. It also runs before each attach dresses its sessions, so
`codeman tui <n>` gets it and a leaked hook cannot undo presizeWindow().
- `set-hook -u` on our index left an empty session-level array, which
hides the user's global hook on that event. Disarm unsets the whole
event when ours is its only entry, and arm refuses while the user has a
global client-active hook.
- Arm and disarm are one tmux call to read and one to write (`;` lists).
- Docs: the "forced resize when a browser opens a session" wording was
wrong (selectSession sends no force; only Redraw, a closing pop-out and
the split pane do), fixed in tui-client.ts, docs/tui.md and the
invariants, whose paragraph now stands on its own.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-up (owner's merge-time items, applied here).
- killSession() used `pane.pid ?? session.pid`, which kept tmux's 0 for
an empty active pane (`split-window ''`: `1|0|` up to tmux 3.6, `0|0|`
on 3.7) beside a running agent, so the close signalled nothing where
master signals the agent's tree. `||` restores that; isSignalablePid()
still refuses 0 or 1.
- kill-pid-guard.test.ts answered the old pid-only read, which the
three-field parser read as no pid, so no case gave killSession() tmux's
own 0. Its mock now answers the kill read, with cases for `1|0|`,
`0|0|` and `0||` against a recorded agent pid and a recorded 0.
- Tests pin the whole kill read format, and the reconcile rule that a
pane without a pid never overwrites a live pane's pid. Dropping
`#{pane_dead_time}`, using `??` or `pane.pid` alone, or a plain
`active.set(...)` each fail now.
- parsePaneKillRead() cases for `1|0|`, `0|0|` and `1|-1|`.
- Comments and docs: the blank pid with a late dead flag is tmux 3.8;
on 3.4 only the seconds to collect the status were measured. A pid
below 2 is no pid. The recorded pid is unreaped in the closing window
only when it is the pane's start pid (`respawn-pane` breaks that).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolves the killSession() conflict with babb55e4 (never signal pid 0
or 1). The dead-pane read decides first; a pid that is not signalable
(isSignalablePid) then also means nothing is signalled and only
`tmux kill-session` runs. killPaneProcessTree() sends every signal
through signalProcess().
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A restore no longer pages through a whole large folder for an expanded
folder that is gone: directories are listed before files across pages, so
a loaded file ends the search, and the expansion is forgotten. An expanded
folder that waits for its turn in the restore says it is loading, and a
search-result folder opened while the tree was loading runs the restore
afterwards. The error line keeps its parts in separate elements so the
zh-CN entries apply, one local match reads in the singular, and the search
box labels the phone keyboard's Enter key.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The manual multi-user start line is printed only where no service runs:
next to a working service it would start a second server on the same data
dir and tmux socket. The Environment= reader removes quotes wherever they
sit in a word, as systemd does, so a hand-written CODEMAN_MULTIUSER="1" or
CODEMAN_PASSWORD="my pass" survives a re-run.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
tmux answers 0 for the pid of a pane without a process (`split-window ''`).
The pane list read at server start recorded that 0 on the session, and the
next close of the tab walked the children of pid 0, which is the whole
machine: every process of the account was signalled, all sessions, tmux
itself and the systemd user manager included.
killSession() now decides once whether there is a process to signal
(isSignalablePid(), an integer above 1) and otherwise leaves the close to
`tmux kill-session`. The descendant walk of the kill path returns nothing
for such a root, and signalProcess(), the only place in tmux-manager.ts
that sends a signal, refuses it for the process group form as well.
proc-walk-bounds used pid 1 as the root of its fixture tree, which the kill
path now refuses on purpose, so the fixture is rooted at a real pid.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The live-pane close test mocked process.kill to always succeed, so the
pane never exited and the kill path's wait polled isProcessRunning().
On Linux that reads /proc/<pid>/stat, which this file mocks to return
undefined, and the test threw "Cannot read properties of undefined
(reading 'lastIndexOf')". macOS skips that read, so it passed locally.
The mock now models a pane that exits on its first real signal, after
which kill(pid, 0) throws ESRCH. Reproduced the CI error locally by
forcing the Linux branch; it passes with this change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-up on the tmux 3.8 dead-pane fix.
- parsePaneRows() skipped a row with a blank pid and pane_dead 0. tmux
blanks the pid when the pty closes, and pane_dead turns 1 only once
the exit status is collected (seconds for some exits on tmux 3.4), so
a restart in that window dropped the session. Only a row with neither
a pid nor a dead flag is skipped now.
- Before tmux 3.7 pane_dead means only that the pty is closed. The kill
read now also reads #{pane_dead_time}, and counts a pane as dead only
with a blank pid or a set exit time, so a program that closed its tty
and ignores SIGHUP is still killed on tmux 3.3a to 3.6.
- Tests pin the last two pane format fields and add a live-pane
counterpart to the dead-pane kill test.
- Changeset notes that finished sessions piled up on 3.8 are relaunched
once at the first start after the update.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After App Settings or Session Options was opened with a mouse click and
closed, nothing typed reached the terminal until it was clicked again.
FocusTrap saved document.activeElement when the dialog opened, and by then
the press had already moved focus: onto the pressed control in Chromium and
Firefox, onto <body> in WebKit on macOS, where a button takes no focus from
the mouse.
FocusTrap.focusToReturn() is what a dialog saves now. A pointerdown listener
records the typing field that had focus when a mouse press began (pointerdown
comes before mousedown, whose default action moves focus), and that field is
the answer when focus sits on the pressed control or on <body> as the dialog
opens. Any key forgets the press, so a control reached with the keyboard gets
focus back as before. Only a typing field is remembered, for one press (a
press on a menu item inherits it from the press that opened the menu) and
only for a mouse, so touch is unchanged. Asking spends the press, so nothing
pressed inside the opening dialog can hand the keyboard to a field behind it.
The command palette and the Session Manager save the same answer.
Measured in Chromium against a running server: App Settings and Session
Options opened by mouse ended on the clicked gear before and in the terminal
after, also with the press clearing focus as WebKit on macOS does, with the
tile grid and the split open (the keyboard returns to the pane it was in),
and through a tile's menu. Not run in WebKit on macOS itself.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
armFollowTyping() set the owner option, then a hook. On tmux before 3.3
there is no client-active hook, so the first set-hook failed and the arm
answered false with the owner still set; restore() disarms only what
armed, so it stayed on the session. A failed arm now drops the owner and
any of our hooks it already set.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
A terminal that dies while attached (closed window, dropped SSH) never
reaches restore(), so its client-active[91] hooks stayed on the sessions.
TUI startup now removes ours whose tty has no live tmux client, next to
the leaked-banner sweep. The TUI's own tty is never swept: the sweep is
fire-and-forget, and an early Enter can arm that hook before the attach
client exists.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`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>
The kill rule was pinned only through parsePaneKillRead(). Drive
killSession() with tmux commands enabled and exec answering like tmux
3.8 (a dead pane, pid blank), and assert nothing signals the recorded
pid while kill-session still runs. Against bee4948e it fails: pid 4242
is signalled 201 times. Group the three no-pid tests in their own
describe instead of the launch-cwd one.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
killSession() read `#{pane_pid}` and fell back to the recorded pid when
tmux printed none, which tmux 3.8 does for every dead pane. That pid
belongs to the program that exited; the OS may have reused it, and the
kill path walked its process tree and SIGKILLed it. It now reads
`#{pane_dead}` with the pid (parsePaneKillRead) and, for a dead pane,
only runs kill-session. Survivors of an exited program were already out
of reach (reparented, and the group kill only ran for a live leader),
so nothing a live pane gets is lost. Strategies 1 and 2 move into
killPaneProcessTree() unchanged.
Docs: the architecture-invariants paragraph says a kept dead pane is
respawned by the restore at the next server start (measured on tmux
3.8; tmux 3.7 and older always did this), and describes the kill rule.
CLAUDE.md's paneExit rule gains the no-pid warning. The
PaneExitObservation comment no longer claims tmux before 3.4 lacks
`#{pane_dead_time}`, which was never measured.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ledger layout hid every .tab-status to swap the dot for its coloured
bar. The bar is green for idle and working alike, and the spinner is the
dot's own .tab-status.busy::after ring, so a working session showed no
mark at all. A busy cell now keeps the dot and its ring, idle cells stay
bar-only, and an exited agent's cell still hides it like the classic strip.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- flushPendingWrites falls back to the absolute viewport index when the write disposed the marker, which ESC[3J or RIS also do (the narrow and middle strips keep 3J), instead of sending the reader to row 0.
- The live-output mark block moves below the write's try/catch, so the catch only covers the write.
- Test: one flush of ESC[H ESC[2J ESC[3J plus a reprint keeps the reader on line 100, with and without markers.
- The reload-only bar's × is now labelled "Dismiss Reload history", which Playwright's default substring name match also selected; the five Reload history locators in history-gap-repair.browser.test.ts pass exact: true.
- _historyReloadActionEligible() leaves out Docker and adopted sessions, whose nested tmux client keeps the local pane in the alternate screen so ?full=1 returns one screen the downgrade guard refuses; remote sessions stay eligible.
- The bar's × is labelled "Dismiss Reload history" when the bar carries no truncation notice, with a zh-CN entry.
- selectSession now samples _liveOutputGen before its fresh fetch, as the refresh and manual-pull paths do, so output that arrives during the download keeps the session marked for Reload history.
- Test: live output during the fresh fetch keeps the mark after a mux-full-history replay.
- _renderHistoryTruncationBanner sets aria-live to polite for the truncation notice and off for a reload-only bar, which re-renders on nearly every scroll-up in a busy tab; its button stays reachable with Tab.
- docs: comma in the Reload eligibility list, and the live-region rule in the invariants paragraph.
- _historyReloadActionEligible() and _maybeRefetchFullHistory stand aside while _terminalRefreshOwner holds the active session, so Reload, Load full history and the top-of-buffer pull no longer start a second capture whose download-time queue the refresh's own load would replace.
- _onSessionNeedsRefresh re-syncs the action when it takes the owner and again in its finally once it releases it.
- Tests: a refresh-in-flight visibility row, and a tap during a held refresh that fetches nothing and gets the action back afterwards.
- A content-anchored Load full history pull sets _historyReloadActionLoadingFor and clears it on settle, as Reload history does.
- The button renders from that loading state, so the re-render the in-flight pull triggers keeps it disabled on Loading….
- The top-anchor case keeps no loading state, so the bar still hides on a scroll back to live output.
- Content-anchored replay travel reveals the notice on an upward move that reaches row 0 and retires it on a downward move back at live output, as a live scroll does.
- _captureViewportAnchor returns only viewportY, rowsFromBottom and context; tests read anchor.context.
- _onSessionNeedsRefresh clears the Reload mark only after a completed mux replay.
- A later drop during an open load keeps the deferred recovery's higher attempt.
- Replay travel that reaches row 0 reveals the partial-history notice; at live output it retires it.
- The onScroll coalescing test drives the scheduler instead of evaluating a source line.
- _restoreViewportAnchor searches expected - 4000 + rows .. expected + rows
(same 4,001 candidates / 4,064 reads): filled rows only move the reader
up, so gaps up to 4000 - rows land exactly, also at the scrollback cap.
- _resetAllAppState and _cleanupPreviousSession clear
_pendingDroppedOutputRecovery next to the recovery timer, so a reconnect
load does not resume a stale recovery and run a second full capture.
- Tests: capped 2,500- and 3,900-row gaps; both real cleanup methods drop
the pending recovery. Docs: the window and the beyond-window fallback.
- The notice's Load full history button pulls with anchor 'content' when
Reload history is eligible (read at click time, since the bar only
re-renders on eligibility transitions) and keeps 'top' otherwise.
- Tests: the single load control asserts the content anchor; an
ineligible session keeps the top anchor.
- _onSessionNeedsRefresh adds the session to _historyReloadDismissed when
the full capture would shrink the buffer and it falls back to ?tail=,
past the ownership guard, so a no-history pane is not re-captured by
the next tap.
- Changeset: scope the note to agent sessions (seen with OMP).
- CLAUDE.md: one warning sentence on the Reload history rules.
- terminal-resilience test reads each whole method instead of a
4,000-character window.
- _onSessionNeedsRefresh samples the live-output generation before its
fetch and, after replaying a mux-full-history capture, clears
_liveOutputSinceFullPull and _historyReloadDismissed while it still owns
the active session and the generation is unchanged; the ?tail= fallback
never clears them.
- test/terminal-viewport-marker.test.ts: gated test driving the real
flushPendingWrites over @xterm/headless at a full scrollback; the reading
row holds with the marker and drifts without it.
- Docs: the anchor sentence matches minimumScore, and the refresh rule is
in the Repair while reading paragraph.
- A content-anchored reload answered by anything but mux-full-history (an
empty response, or the byte-history fallback for a blank or failed pane
capture) adds the session to _historyReloadDismissed until the next mux
replay; only a mux replay clears the mark, so each tap repeated a forced,
unbounded capture. An error envelope leaves it available.
- Only the request still current (active session and select generation)
may dismiss: a slow answer from before an A -> B -> A switch must not
retire the action a newer capture already cleared.
- _historyReloadActionEligible() also requires no terminal load state:
selectSession sets it before switching activeSessionId, so the sync
right after the switch no longer offers Reload for the loading tab.
- _clearTerminalLoadState() re-syncs the action, so a marked tab offers
Reload once its load ends.
- Changeset: note the reading-position fix for live flushes at the
scrollback cap.
- _historyReloadActionEligible() no longer reads _paneHistoryLines: it is
recorded at the last load, so a session first opened empty kept 0 after
the burst that opens the gap, and the action never appeared (found by the
live #814 recipe).
- A pane with no tmux history is still retired by the downgrade refusal,
which dismisses the action until the next mux-full-history replay.
- Reload history requires pane history and no buffer load in flight; a
downgrade-refused pull hides it until the next mux-full-history replay,
and a stale tap re-checks eligibility before fetching.
- x during Loading... hides the bar at once; the pull continues.
- The content anchor scores up to 64 visible rows, so repeated TUI borders
cannot outvote the row being read; ambiguous matches keep the viewport.
- Live flushes track the reading row with an xterm marker across
scrollback trimming at the cap.
- Docs: Settings-Reference row, Dashboard notice text, ~1 s capture cost,
byte-history replays rely on the top-of-buffer pull.