mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-30 16:39:33 +01:00
fix(web): decide the history notice per replay move and drop unused anchor fields (#814)
- 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.
This commit is contained in:
1 parent
1f9b17e29a
commit
a692f9f193
5 files changed
+38
-22
No files matched your search
+10
-6
@@ -9872,13 +9872,17 @@ class CodemanApp {
|
||||
const baseY = this.terminal.buffer.active.baseY;
|
||||
const clamp = (row) => Math.max(0, Math.min(baseY, row));
|
||||
let row = this._restoreViewportAnchor(viewportAnchor);
|
||||
for (const move of this._earlyReplayTravel.moves) row = clamp(row + move);
|
||||
this.terminal.scrollToLine(row);
|
||||
// Replay travel bypassed the live scroll handler's notice update.
|
||||
if (this._earlyReplayTravel.moves.length > 0) {
|
||||
if (row === 0) this._setHistoryNoticeRevealed?.(sessionId);
|
||||
else if (this.isTerminalAtBottom()) this._setHistoryNoticeRevealed?.(null);
|
||||
// Replay travel bypassed the live scroll handler's notice update, so
|
||||
// decide it per move as that handler would: an upward move that reaches
|
||||
// row 0 reveals the notice, a downward move back at live output retires it.
|
||||
let reveal = null;
|
||||
for (const move of this._earlyReplayTravel.moves) {
|
||||
row = clamp(row + move);
|
||||
if (move < 0 && row === 0) reveal = true;
|
||||
else if (move > 0 && row >= baseY - 2) reveal = false;
|
||||
}
|
||||
this.terminal.scrollToLine(row);
|
||||
if (reveal !== null) this._setHistoryNoticeRevealed?.(reveal ? sessionId : null);
|
||||
} else {
|
||||
const delta = parsedBufferLength - rowsBefore;
|
||||
if (delta > 0) this.terminal.scrollToLine(delta);
|
||||
|
||||
@@ -4019,14 +4019,7 @@ Object.assign(CodemanApp.prototype, {
|
||||
{ length: Math.min(this.terminal.rows || 3, 64, buffer.length - viewportY) },
|
||||
(_, i) => buffer.getLine(viewportY + i)?.translateToString(true) || ''
|
||||
);
|
||||
const offset = Math.max(0, context.findIndex((text) => text.trim()));
|
||||
return {
|
||||
viewportY,
|
||||
rowsFromBottom: baseY - viewportY,
|
||||
offset,
|
||||
signature: Array.from({ length: 3 }, (_, i) => context[offset + i] || ''),
|
||||
context,
|
||||
};
|
||||
return { viewportY, rowsFromBottom: baseY - viewportY, context };
|
||||
},
|
||||
|
||||
/** Match the visible context; a lone repeated row is not a reliable anchor. */
|
||||
|
||||
Reference in new issue
Block a user