fix(web): make the early history repair a manual Reload history action (#814)

- Scrolling pulls tmux history only at the top of the buffer again (#205);
  the automatic pull on any upward scroll is removed.
- Reload history lives in the existing #historyTruncationBar on desktop and
  touch, shown for a marked non-shell session scrolled away from live output.
  It never duplicates Load full history; one × dismisses what the bar carried.
- New per-device setting historyReloadAction (Terminal & Input > Scrolling &
  rendering), default on, kept out of SettingsUpdateSchema.
- Eligibility sync is transition-only and onScroll is coalesced per frame.
- Remove the floating #historyReloadBtn and its z-index 20 layer.
- Deferred dropped-output recovery resumes at its saved attempt.
- zh-CN entries for the new strings; docs and changeset updated.
This commit is contained in:
Hadrien Kerlero committed 2026-11-22 02:44:23 +01:00
1 parent b890ef3302
commit fd6b392b4d
13 files changed
+517 -271

No files matched your search

+1 -1
View File
@@ -56,7 +56,7 @@ Frontend JS modules have `@fileoverview` with `@dependency`/`@loadorder` tags. L
**Command palette + shortcut registry**: `Ctrl/Cmd/Alt+K` opens the session palette; shortcuts live in a rebindable registry (`DEFAULT_SHORTCUTS`/`getShortcutRegistry()`/`matchesShortcutEvent()` in app.js, overrides in `settings.shortcutOverrides`). ⚠️ Palette-chord keys must ALSO be swallowed in `attachCustomKeyEventHandler` (terminal-ui.js) or xterm writes the control byte into the PTY. ⚠️ The global Escape handler (app.js) calls EVERY close method on every Escape, in the capture phase, so a close method that does more than hide (the palette and Session Manager restore focus) must return early when its overlay is not open. ⚠️ `saveAppSettings()` rebuilds settings from the DOM, so keys edited elsewhere (`shortcutOverrides`, `showTokenCount`, `showCost`) need explicit `_prev` carry-over. ⚠️ **Smart copy (`Ctrl+C`)**: with no selection it must `return true` without `preventDefault()` or the interrupt is lost; keep `copyTerminalSelection` out of `SHORTCUT_ACTIONS`. The gate tests the CLEANED selection (`CodemanCopySelection.clean`: trailing padding, plus a LEADING margin only up to the width the CLI declares in `capabilities.transcriptGutter`, never one derived from the pane); the strip is not idempotent, so clean once and pass the RAW selection on, and leave Alt+drag column selections untouched. → [architecture-invariants#command-palette-and-shortcut-registry](../../docs/architecture-invariants.md#command-palette-and-shortcut-registry)
**Per-device vs synced settings**: the `displayKeys` set in settings-ui.js is a **client-side merge policy**, not a wire filter. A display key seeds from the server only when localStorage has no value for it, which is what prevents one device overwriting another; `showPlanUsageLimits` is additionally `delete`d from the incoming payload outright. Separately, `SettingsUpdateSchema` is `.strict()` and simply **does not declare** `skin`, `showFileViewerButton`, `showCronButton`, `webglRendererEnabled`, `localEchoEnabled`, `keyboardHoldsRows`, `cjkInputEnabled`, `cjkInputHoldUntilEnter`, or `extendedKeyboardBar`, so sending one of those is a validation error. The rest (`showResponseViewer`, `showPlanUsageLimits`, `language`, and most `show*` keys) ARE in the schema and do persist server-side; they are per-device by client policy only. ⚠️ Adding a new per-device setting means deciding **both** questions: membership in `displayKeys`, and presence in the schema.
**Per-device vs synced settings**: the `displayKeys` set in settings-ui.js is a **client-side merge policy**, not a wire filter. A display key seeds from the server only when localStorage has no value for it, which is what prevents one device overwriting another; `showPlanUsageLimits` is additionally `delete`d from the incoming payload outright. Separately, `SettingsUpdateSchema` is `.strict()` and simply **does not declare** `skin`, `showFileViewerButton`, `showCronButton`, `webglRendererEnabled`, `localEchoEnabled`, `keyboardHoldsRows`, `cjkInputEnabled`, `cjkInputHoldUntilEnter`, `extendedKeyboardBar`, or `historyReloadAction`, so sending one of those is a validation error. The rest (`showResponseViewer`, `showPlanUsageLimits`, `language`, and most `show*` keys) ARE in the schema and do persist server-side; they are per-device by client policy only. ⚠️ Adding a new per-device setting means deciding **both** questions: membership in `displayKeys`, and presence in the schema.
**Settings surface** (`#appSettingsModal` + `#sessionOptionsModal` + `#createCaseModal`): one `set-*` language shared through a single `:is(...)` id scope in styles.css. App Settings' rail is a table of contents over ONE scrolling document (`switchSettingsTab` scrolls); Session Options and Add Case really switch (`switchOptionsTab` / `switchCaseModalTab`), and their larger per-modal size blocks are the design, not drift. ⚠️ **The load/save contract is `getElementById` by id**: renaming or dropping a control id silently stops it loading or saving. ⚠️ The Session Options "Session" entry still keys off `context` (label-only rename). ⚠️ Add Case keeps its legacy `.form-row` markup via an adapter; every `<details>` there needs `.set-adv-chev` plus both marker suppressions. ⚠️ Model cards and the effort segment are views over hidden `<select>`s, which stay the source of truth. ⚠️ `.modal-tabs*` classes are retired; `admin-ui.js` needs `.set-rail-items` + `.set-doc` to survive any restructure. Guard: `test/app-settings-structure.test.ts`. → [architecture-invariants#settings-surface-app-settings-session-options-add-case](../../docs/architecture-invariants.md#settings-surface-app-settings-session-options-add-case)
+77 -26
View File
@@ -801,10 +801,11 @@ class CodemanApp {
// the small `full=1` capture instead of the 1 MiB byte tail: see
// _notePaneHistory and selectSession.
this._paneHistoryLines = new Map(); // Map<sessionId, number>
// Per-session cooldown for upward-scroll history repair / top-of-buffer pulls.
// Per-session cooldown for top-of-buffer pulls; manual actions bypass it.
this._fullHistoryRepullAt = new Map(); // Map<sessionId, timestamp>
this._fullHistoryRepullInFlight = false;
this._liveOutputSinceFullPull = new Set(); // Set<sessionId>
this._historyReloadDismissed = new Set(); // Until the next successful full mux replay
this._liveOutputGen = new Map(); // Map<sessionId, number>
this._earlyReplayTravel = null; // { sessionId, moves: number[] } during a content-anchored replay
// Sessions whose last re-pull came back THINNER than the live buffer (a
@@ -2606,10 +2607,10 @@ class CodemanApp {
// it releases instead of spending every retry against the same open load.
if (this._isLoadingBuffer) {
if (sessionId === this.activeSessionId) {
if (this._pendingDroppedOutputRecovery !== sessionId && Number.isFinite(queuedBytes)) {
if (this._pendingDroppedOutputRecovery?.sessionId !== sessionId && Number.isFinite(queuedBytes)) {
_crashDiag.log(`TERMINAL DROP: ${(queuedBytes / 1024).toFixed(0)}KB queued (recovery deferred)`);
}
this._pendingDroppedOutputRecovery = sessionId;
this._pendingDroppedOutputRecovery = { sessionId, attempt };
}
return;
}
@@ -2621,7 +2622,7 @@ class CodemanApp {
// A load may have opened after this timer was armed. Defer without
// advancing the attempt; _finishBufferLoad resumes only the active tab.
if (this._isLoadingBuffer) {
if (sessionId === this.activeSessionId) this._pendingDroppedOutputRecovery = sessionId;
if (sessionId === this.activeSessionId) this._pendingDroppedOutputRecovery = { sessionId, attempt };
return;
}
let repainted = false;
@@ -9614,8 +9615,8 @@ class CodemanApp {
}
/**
* Re-pull tmux history at the top, or on any upward scroll in a non-shell
* session marked by live output since its last mux-full-history replay.
* Re-pull tmux history automatically at the top, or explicitly from the
* history banner's Load full history / Reload history actions.
*
* xterm's buffer is only ever a WINDOW onto tmux's real history, and two things
* shrink it. tmux repaints the pane rectangle instead of emitting linefeeds
@@ -9626,9 +9627,10 @@ class CodemanApp {
* everything (history-limit 100k by default), so the fix is to go ask for it with
* the same `?full=1` capture a page reload uses (issue #205).
*
* Gesture-triggered and cooldown/latch guarded: a synchronous capture can cost
* about 0.3 s at 100k lines and blocks the server event loop. Content anchors
* hold the reader's place even when new history fills a gap below them.
* Automatic pulls are top-only and cooldown/latch guarded: a synchronous
* capture can cost about 0.3 s at 100k lines and blocks the server event loop.
* The manual Reload history action uses a content anchor to hold the reader's
* place even when new history fills a gap below them.
*
* NEVER a downgrade: for a repaint-mode CLI pane tmux keeps no history of its
* own, so the capture can be THINNER than what xterm already holds and the
@@ -9795,6 +9797,8 @@ class CodemanApp {
if (!completed || this.activeSessionId !== sessionId || selectGen !== this._selectGeneration) return;
if (payload.source === 'mux-full-history' && (this._liveOutputGen?.get(sessionId) || 0) === liveOutputGen) {
this._liveOutputSinceFullPull?.delete(sessionId);
this._historyReloadDismissed?.delete(sessionId);
this._syncHistoryReloadAction?.();
}
// Keep shell tab restores bounded too. A user-triggered full-history pull
// may be tens of MB; caching it would replay that whole payload again on
@@ -9837,7 +9841,7 @@ class CodemanApp {
if (!replayed) this._finishBufferLoad(loadOwner, { flushQueued: true, since: 0 });
if (anchor === 'content') this._earlyReplayTravel = null;
this._fullHistoryRepullInFlight = false;
this._syncHistoryReloadButton?.();
this._syncHistoryReloadAction?.();
}
}
@@ -9913,6 +9917,29 @@ class CodemanApp {
this._renderHistoryTruncationBanner();
}
/** Whether the active session can offer a manual, content-anchored repair. */
_historyReloadActionEligible() {
const sessionId = this.activeSessionId;
const session = this.sessions.get(sessionId);
// Cheap state checks first: the terminal is read only for a marked session.
return !!(this.loadAppSettingsFromStorage?.()?.historyReloadAction !== false &&
session && session.mode !== 'shell' && this._liveOutputSinceFullPull?.has(sessionId) &&
!this._fullHistoryRepullInFlight && !this.detachedSessions?.has(sessionId) &&
!this._historyReloadDismissed?.has(sessionId) && !this._tilesOwnTerminal?.() &&
!this.isTerminalAtBottom());
}
/** Only eligibility/session/loading transitions may rebuild the banner. */
_syncHistoryReloadAction() {
const sessionId = this.activeSessionId;
const eligible = this._historyReloadActionEligible();
const loading = !!sessionId && this._historyReloadActionLoadingFor === sessionId;
const last = this._historyReloadActionState;
if (last && last.sessionId === sessionId && last.eligible === eligible && last.loading === loading) return;
this._historyReloadActionState = { sessionId, eligible, loading };
this._renderHistoryTruncationBanner();
}
/**
* Paint the partial-history banner for the active session.
*
@@ -9920,12 +9947,12 @@ class CodemanApp {
* is gone forever" are not the same message and the old single boolean could
* not tell them apart:
* - recoverable → offer to load the rest
* - exhausted → say so plainly, offer nothing
* - exhausted → say so plainly
* - at the limit → the full capture ITSELF hit the byte ceiling
*
* Shown only while revealed (`_setHistoryNoticeRevealed`: the user scrolled
* to the top of this tab's buffer) and never again for a session whose notice
* the user dismissed on this page.
* Notices wait for a scroll to the top and respect their page-long dismissal.
* Independently, eligible marked sessions offer Reload history while reading;
* the same bar carries it without duplicating a Load full history control.
*/
_renderHistoryTruncationBanner() {
const bar = document.getElementById('historyTruncationBar');
@@ -9933,11 +9960,12 @@ class CodemanApp {
const sessionId = this.activeSessionId;
const state = sessionId ? this._historyTruncation?.get(sessionId) : null;
const notice = computeHistoryTruncationNotice(state || {});
if (
!notice.visible ||
this._historyNoticeRevealedFor !== sessionId ||
this._historyNoticeDismissed?.has(sessionId)
) {
const showNotice = notice.visible && this._historyNoticeRevealedFor === sessionId &&
!this._historyNoticeDismissed?.has(sessionId);
const eligible = this._historyReloadActionEligible?.() ?? false;
const loading = !!sessionId && this._historyReloadActionLoadingFor === sessionId;
this._historyReloadActionState = { sessionId, eligible, loading };
if (!showNotice && !eligible && !loading) {
bar.hidden = true;
return;
}
@@ -9945,10 +9973,10 @@ class CodemanApp {
bar.textContent = '';
const label = document.createElement('span');
label.className = 'history-trunc-text';
label.textContent = notice.message;
label.textContent = showNotice ? notice.message : 'Recent output may be missing from this view.';
bar.appendChild(label);
if (notice.canLoadMore) {
if (showNotice && notice.canLoadMore) {
const btn = document.createElement('button');
btn.type = 'button';
btn.className = 'history-trunc-load';
@@ -9962,6 +9990,23 @@ class CodemanApp {
});
};
bar.appendChild(btn);
} else if (eligible || loading) {
const btn = document.createElement('button');
btn.type = 'button';
btn.className = 'history-trunc-load';
btn.disabled = loading;
btn.textContent = loading ? 'Loading…' : 'Reload history';
btn.onclick = () => {
btn.disabled = true;
btn.textContent = 'Loading…';
this._historyReloadActionLoadingFor = sessionId;
this._syncHistoryReloadAction();
return this._maybeRefetchFullHistory({ force: true, anchor: 'content' }).finally(() => {
if (this._historyReloadActionLoadingFor === sessionId) this._historyReloadActionLoadingFor = null;
this._syncHistoryReloadAction();
});
};
bar.appendChild(btn);
}
const dismiss = document.createElement('button');
@@ -9970,10 +10015,12 @@ class CodemanApp {
dismiss.setAttribute('aria-label', 'Dismiss history notice');
dismiss.textContent = '×';
dismiss.onclick = () => {
// Sticky for this session until the page reloads: a dismissed notice used
// to come straight back on the next tab switch.
(this._historyNoticeDismissed ||= new Set()).add(sessionId);
bar.hidden = true;
// One × dismisses everything this bar carried. A notice dismissal sticks
// for the lifetime of this page; a reload dismissal lasts until a
// successful full mux replay clears the session's mark.
if (showNotice) (this._historyNoticeDismissed ||= new Set()).add(sessionId);
if (eligible || loading) (this._historyReloadDismissed ||= new Set()).add(sessionId);
this._renderHistoryTruncationBanner();
};
bar.appendChild(dismiss);
@@ -10093,7 +10140,7 @@ class CodemanApp {
this.activeSessionId = sessionId;
this._activateFileBrowserSession?.(sessionId);
if (typeof CjkInput !== 'undefined') CjkInput.restoreDraft?.(sessionId);
this._syncHistoryReloadButton?.();
this._syncHistoryReloadAction?.();
// A keyboard row hold belongs to the session it was taken for: release it here
// if this one resizes instead (the geometry work below then fits it).
this._reconcileKeyboardHold?.({ resize: false });
@@ -10481,6 +10528,8 @@ class CodemanApp {
}
if (fullHistoryReplay && data.source === 'mux-full-history' && completed && (this._liveOutputGen?.get(sessionId) || 0) === liveOutputGen) {
this._liveOutputSinceFullPull?.delete(sessionId);
this._historyReloadDismissed?.delete(sessionId);
this._syncHistoryReloadAction?.();
}
// Ensure terminal is scrolled to bottom after buffer load
this.terminal.scrollToBottom();
@@ -10890,6 +10939,8 @@ class CodemanApp {
this.terminalBuffers.delete(sessionId);
this.terminalBufferCache.delete(sessionId);
this._liveOutputSinceFullPull?.delete(sessionId);
this._historyReloadDismissed?.delete(sessionId);
this._syncHistoryReloadAction?.();
this._liveOutputGen?.delete(sessionId);
this._clearHistoryTruncation(sessionId);
this._xtermSnapshots?.delete(sessionId);
+6
View File
@@ -751,6 +751,12 @@
'Extended Keyboard Bar': '扩展键盘栏',
'Gesture Control (beta)': '手势控制(测试版)',
'Wheel Scrolls Local History': '滚轮滚动本地历史',
'History Reload Button': '历史重新加载按钮',
'When scrolled up after new output, offer a Reload history action that re-reads the full tmux history (a full capture on the server).':
'有新输出后向上滚动时,提供“重新加载历史”操作,重新读取完整的 tmux 历史(在服务器上完整捕获)。',
'Recent output may be missing from this view.': '此视图可能缺少最近的输出。',
'Reload history': '重新加载历史',
'Load full history': '加载完整历史',
'Auto Copy Selection': '自动复制选中内容',
'Selection & clipboard': '选中与剪贴板',
'Auto Copy: selection copied': '自动复制:已复制选中内容',
+7 -1
View File
@@ -478,7 +478,6 @@
scrolled away with the output it described and could not be acted
on. Populated by app.js _renderHistoryTruncationBanner(). -->
<div class="history-trunc-bar" id="historyTruncationBar" role="status" aria-live="polite" hidden></div>
<button id="historyReloadBtn" type="button" class="history-reload-btn" aria-label="Reload history" hidden>↻ Reload history</button>
<div class="terminal-container" id="terminalContainer"></div>
<textarea id="cjkInput" rows="1" placeholder="CJK input (Enter = send, Esc = clear)"
maxlength="65536" aria-label="CJK IME input field"
@@ -2162,6 +2161,13 @@
</div>
<label class="switch switch-sm"><input type="checkbox" id="appSettingsTerminalWheelLocal"><span class="slider"></span></label>
</div>
<div class="set-row" data-search="history reload button repair scrollback">
<div class="set-row-text">
<span class="set-row-label">History Reload Button <span class="set-scope">device</span></span>
<span class="set-row-desc">When scrolled up after new output, offer a Reload history action that re-reads the full tmux history (a full capture on the server).</span>
</div>
<label class="switch switch-sm"><input type="checkbox" id="appSettingsHistoryReloadAction"><span class="slider"></span></label>
</div>
<div class="set-row" id="appSettingsWebglRendererItem" data-search="webgl renderer gpu terminal">
<div class="set-row-text">
<span class="set-row-label">WebGL Renderer <span class="set-tag">desktop</span> <span class="set-scope">device</span></span>
+7
View File
@@ -648,6 +648,8 @@ Object.assign(CodemanApp.prototype, {
);
document.getElementById('appSettingsTerminalWheelLocal').checked =
settings.terminalWheelLocalScrollback ?? defaults.terminalWheelLocalScrollback ?? false;
document.getElementById('appSettingsHistoryReloadAction').checked =
settings.historyReloadAction ?? defaults.historyReloadAction ?? true;
document.getElementById('appSettingsCjkInput').checked = settings.cjkInputEnabled ?? defaults.cjkInputEnabled ?? false;
document.getElementById('appSettingsCjkHoldUntilEnter').checked =
settings.cjkInputHoldUntilEnter ?? defaults.cjkInputHoldUntilEnter ?? false;
@@ -3196,6 +3198,7 @@ Object.assign(CodemanApp.prototype, {
document.getElementById('appSettingsTerminalFontWeightBold')
),
terminalWheelLocalScrollback: document.getElementById('appSettingsTerminalWheelLocal').checked,
historyReloadAction: document.getElementById('appSettingsHistoryReloadAction').checked,
cjkInputEnabled: document.getElementById('appSettingsCjkInput').checked,
cjkInputHoldUntilEnter: document.getElementById('appSettingsCjkHoldUntilEnter').checked,
webglRendererEnabled: document.getElementById('appSettingsWebglRenderer').checked,
@@ -3285,6 +3288,7 @@ Object.assign(CodemanApp.prototype, {
this._updateLocalEchoState();
// Turning Keep Size Under Keyboard off while it holds releases it now.
this._reconcileKeyboardHold?.();
this._syncHistoryReloadAction?.();
this.applyTerminalFontFamily?.(settings.terminalFontFamily);
this.applyTerminalFontWeights?.(settings);
@@ -3459,6 +3463,7 @@ Object.assign(CodemanApp.prototype, {
showTileGridButton: _stg,
webglRendererEnabled: _wgl,
terminalWheelLocalScrollback: _twls,
historyReloadAction: _hra,
// Copy-on-select. Per-device (clipboard access differs by device and by
// origin: the plain-HTTP LAN install has no navigator.clipboard at all)
// and absent from SettingsUpdateSchema (.strict()), so sending it would
@@ -4484,6 +4489,7 @@ Object.assign(CodemanApp.prototype, {
cjkInputEnabled: false,
cjkInputHoldUntilEnter: false,
terminalWheelLocalScrollback: false, // mobile scrolls via touch, not wheel
historyReloadAction: true,
webglRendererEnabled: false, // mobile always uses the DOM renderer
skin: 'daylight-blue',
};
@@ -5216,6 +5222,7 @@ Object.assign(CodemanApp.prototype, {
'terminalFontFamily', 'terminalFontWeight', 'terminalFontWeightBold',
'language',
'terminalWheelLocalScrollback',
'historyReloadAction',
'autoCopySelection', 'copyStripMargin',
'showSessionButton', 'showAwayDigestButton', 'showCronButton', 'showGitStatus', 'gitStatusTree', 'gitStatusMaxRepos', 'gitStatusTimeoutSeconds', 'showEditHistory',
'showTabDetachButton',
-20
View File
@@ -4401,26 +4401,6 @@ html[data-tab-logos='off'] .home-sessions-harness {
position: relative;
}
/* Touch-only control; _syncHistoryReloadButton owns its hidden state. */
.history-reload-btn {
position: absolute;
top: 0.5rem;
right: 0.5rem;
z-index: 20;
min-width: 44px;
min-height: 44px;
padding: 0.5rem 0.75rem;
border: 1px solid var(--border);
border-radius: 6px;
background: var(--bg-card);
color: var(--text);
touch-action: manipulation;
}
.history-reload-btn:disabled {
opacity: 0.65;
}
/* Partial-history banner (#258).
OVERLAY, not a flex child, on purpose: FitAddon derives rows/cols from the
terminal parent's computed height, so a banner that occupied real layout
+20 -44
View File
@@ -1060,8 +1060,8 @@ Object.assign(CodemanApp.prototype, {
this._predictiveEcho =
typeof PredictiveEchoOverlay !== 'undefined' ? new PredictiveEchoOverlay(this.terminal) : null;
this._predictiveEcho?.setPredictWhen((terminal) => window.CodemanTerminalInput.isCodexComposerRow(terminal));
this.terminal.onScroll(() => this._scheduleHistoryReloadActionSync());
if (MobileDetection.isTouchDevice()) {
this.terminal.onScroll(() => this._syncHistoryReloadButton());
this.terminal.onCursorMove(() => this._syncMobileHelperTextareaToCursor());
this.terminal.onRender(() => this._syncMobileHelperTextareaToCursor());
// Keep the live content above the keyboard while the rows are held.
@@ -4060,29 +4060,13 @@ Object.assign(CodemanApp.prototype, {
return target;
},
/** Sole owner of the touch-only history reload control's visibility. */
_syncHistoryReloadButton() {
// Touch capability does not change at runtime and desktop never shows the
// control, so non-touch pages skip the DOM work entirely.
const touch = typeof MobileDetection !== 'undefined' && MobileDetection.isTouchDevice();
if (!touch) return;
const button = document.getElementById('historyReloadBtn');
if (!button) return;
const sessionId = this.activeSessionId;
const session = this.sessions.get(sessionId);
const visible = !!(touch && session && session.mode !== 'shell' &&
!this.isTerminalAtBottom() && this._liveOutputSinceFullPull?.has(sessionId) &&
!this._tilesOwnTerminal?.() && !this._fullHistoryRepullInFlight);
if (button.hidden === visible) button.hidden = !visible;
if (this._fullHistoryRepullInFlight) return;
button.disabled = false;
button.textContent = '↻ Reload history';
button.onclick = () => {
button.disabled = true;
button.textContent = 'Loading…';
return Promise.resolve(this._maybeRefetchFullHistory({ force: true, anchor: 'content' }))
.finally(() => this._syncHistoryReloadButton());
};
/** xterm may emit once per scrolled line; sample eligibility once per frame. */
_scheduleHistoryReloadActionSync() {
if (this._historyReloadActionFrame != null) return;
this._historyReloadActionFrame = requestAnimationFrame(() => {
this._historyReloadActionFrame = null;
this._syncHistoryReloadAction();
});
},
/**
@@ -4129,11 +4113,10 @@ Object.assign(CodemanApp.prototype, {
},
/**
* After scrollLines(), repair on ANY upward gesture in a non-shell session
* marked by live output since its last mux-full-history replay (#814), using
* a content anchor to hold the reader's place. Unmarked sessions still pull
* at the top (#205); shells pull only a bounded window there. The pull owns
* cooldown/latch and downgrade guards.
* After scrollLines(), pull only at the top of the local buffer (#205).
* Shells pull a bounded window; full captures while reading require the
* explicit Reload history action (#814). The pull owns cooldown/latch and
* downgrade guards. Content-anchored replays keep session-scoped travel.
*
* It is also what brings up the partial-history notice, and what retires it
* once a downward scroll is back at live output (_setHistoryNoticeRevealed).
@@ -4151,20 +4134,14 @@ Object.assign(CodemanApp.prototype, {
}
if (lines === 0) return;
const buffer = this.terminal?.buffer?.active;
const reachedTop = buffer?.viewportY === 0;
if (buffer?.viewportY !== 0) return;
const sessionId = this.activeSessionId;
const repair = sessionId && this._liveOutputSinceFullPull?.has(sessionId) &&
this.sessions.get(sessionId)?.mode !== 'shell';
if (!repair && buffer?.viewportY !== 0) return;
// An earlier frame already started a pull and owns the notice reveal.
if (this._fullHistoryRepullInFlight || this._isLoadingBuffer) return;
Promise.resolve(repair
? this._maybeRefetchFullHistory?.({ anchor: 'content' })
: this._maybeRefetchFullHistory?.())
Promise.resolve(this._maybeRefetchFullHistory?.())
.catch(() => {})
.then(() => {
if (sessionId && this.activeSessionId === sessionId &&
(reachedTop || this.terminal?.buffer?.active?.viewportY === 0)) {
if (sessionId && this.activeSessionId === sessionId) {
this._setHistoryNoticeRevealed?.(sessionId);
}
});
@@ -4796,9 +4773,8 @@ Object.assign(CodemanApp.prototype, {
marked.add(flushSessionId);
const generations = (this._liveOutputGen ||= new Map());
generations.set(flushSessionId, (generations.get(flushSessionId) || 0) + 1);
// Visibility only changes here when the mark appears; scrolling is
// covered by the touch-only onScroll hook.
if (newlyMarked) this._syncHistoryReloadButton?.();
// Mark transitions sync immediately; onScroll is coalesced on all devices.
if (newlyMarked) this._syncHistoryReloadAction?.();
}
} catch (err) {
this._terminalWriteInFlight = false;
@@ -5140,10 +5116,10 @@ Object.assign(CodemanApp.prototype, {
this.batchTerminalWrite(entry.data);
}
}
const recoverySession = this._pendingDroppedOutputRecovery;
const recovery = this._pendingDroppedOutputRecovery;
this._pendingDroppedOutputRecovery = null;
if (recoverySession && recoverySession === this.activeSessionId) {
this._scheduleDroppedOutputRecovery?.(recoverySession);
if (recovery && recovery.sessionId === this.activeSessionId) {
this._scheduleDroppedOutputRecovery?.(recovery.sessionId, recovery.attempt);
}
return true;
},