mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-09 08:59:40 +02:00
fix(terminal): bail the backpressure refresh on a mid-fetch tab switch
The refresh can now issue two fetches (full history, then the tail as a downgrade fallback), which widens an existing window where the user switches tabs mid-flight and this session's history gets painted into the terminal they are now looking at. Guard it the way _maybeRefetchFullHistory already does. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2213,6 +2213,10 @@ class CodemanApp {
|
|||||||
res = await fetch(`/api/sessions/${sessionId}/terminal?tail=${TERMINAL_TAIL_SIZE}`);
|
res = await fetch(`/api/sessions/${sessionId}/terminal?tail=${TERMINAL_TAIL_SIZE}`);
|
||||||
data = (await res.json())?.data ?? {};
|
data = (await res.json())?.data ?? {};
|
||||||
}
|
}
|
||||||
|
// Bail on a tab switch mid-fetch: writing here would paint this session's
|
||||||
|
// history into the terminal the user is now looking at. The window is two
|
||||||
|
// fetches wide in the fallback case, so this guard is not optional.
|
||||||
|
if (this.activeSessionId !== sessionId) return;
|
||||||
if (data.terminalBuffer) {
|
if (data.terminalBuffer) {
|
||||||
// This refresh is SERVER-triggered, so a user quietly reading scrollback
|
// 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).
|
// did not ask for it and must not be dragged to the bottom by it (#259).
|
||||||
@@ -2225,7 +2229,7 @@ class CodemanApp {
|
|||||||
await this.chunkedTerminalWrite(data.terminalBuffer);
|
await this.chunkedTerminalWrite(data.terminalBuffer);
|
||||||
// A tail fetch can be partial, and the banner would otherwise keep
|
// A tail fetch can be partial, and the banner would otherwise keep
|
||||||
// describing the pre-refresh buffer (#258).
|
// describing the pre-refresh buffer (#258).
|
||||||
if (this.activeSessionId === sessionId) this._setHistoryTruncation(sessionId, data);
|
this._setHistoryTruncation(sessionId, data);
|
||||||
const target = computeRewriteScrollLine({
|
const target = computeRewriteScrollLine({
|
||||||
linesFromBottom,
|
linesFromBottom,
|
||||||
baseY: this.terminal.buffer?.active?.baseY ?? 0,
|
baseY: this.terminal.buffer?.active?.baseY ?? 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user