fix(web): retire Reload history on the drop-recovery shrink fallback (#814)

- _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.
This commit is contained in:
Hadrien Kerlero committed 2026-11-22 02:44:24 +01:00
1 parent bc00ad4335
commit b3698756a2
6 files changed
+51 -19

No files matched your search

+10
View File
@@ -3505,7 +3505,13 @@ class CodemanApp {
);
let headersReceivedAt = capture.headersAt;
let data = capture.json?.data ?? {};
// The full capture would shrink the buffer: tmux holds less than the browser,
// the signal `_maybeRefetchFullHistory` retires Reload history on. Record it
// and apply it past the ownership guard below, so the next tap does not run
// another forced full capture only to be refused.
let refusedFullCapture = false;
if (useFullHistory && data.terminalBuffer && this._replayWouldShrinkBuffer(data.terminalBuffer)) {
refusedFullCapture = true;
capture = await this._fetchTerminalCapture(`/api/sessions/${sessionId}/terminal?tail=${TERMINAL_TAIL_SIZE}`);
headersReceivedAt = capture.headersAt;
data = capture.json?.data ?? {};
@@ -3519,6 +3525,10 @@ class CodemanApp {
// pane), and an error envelope is not a capture at all.
if (this.activeSessionId !== sessionId || this._terminalRefreshOwner !== refreshOwner) return false;
if (capture.json?.success !== false) this._notePaneHistory?.(sessionId, data);
if (refusedFullCapture) {
(this._historyReloadDismissed ||= new Set()).add(sessionId);
this._syncHistoryReloadAction?.();
}
if (data.terminalBuffer) {
// This refresh is SERVER-triggered, so a user quietly reading scrollback
// did not ask for it and must not be dragged to the bottom by it (#259).