@aragon-agent/cli 0.6.33 → 0.6.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2305 -2242
- package/README.md +3007 -2970
- package/dist/commands/perf.d.ts +10 -0
- package/dist/commands/perf.js +1 -1
- package/dist/ui/App.js +27 -3
- package/dist/ui/ScrollbackShell.d.ts +20 -10
- package/dist/ui/ScrollbackShell.js +4 -3
- package/dist/ui/scrollback/LiveTail.d.ts +42 -8
- package/dist/ui/scrollback/LiveTail.js +13 -2
- package/dist/ui/scrollback/limits.d.ts +16 -0
- package/dist/ui/scrollback/limits.js +16 -0
- package/dist/ui/scrollback/overflow-print.d.ts +108 -0
- package/dist/ui/scrollback/overflow-print.js +120 -0
- package/dist/ui/scrollback/renderer.d.ts +11 -1
- package/dist/ui/scrollback/renderer.js +53 -25
- package/dist/ui/scrollback/tail-anchor.d.ts +68 -0
- package/dist/ui/scrollback/tail-anchor.js +77 -0
- package/dist/ui/scrollback/tail-window.d.ts +9 -8
- package/dist/ui/scrollback/tail-window.js +9 -8
- package/dist/ui/scrollback/use-scrollback-view.d.ts +38 -10
- package/dist/ui/scrollback/use-scrollback-view.js +366 -86
- package/package.json +2 -2
|
@@ -17,6 +17,7 @@ import { Box, render } from 'ink';
|
|
|
17
17
|
import { EntryView } from '../Transcript.js';
|
|
18
18
|
import { getLogger } from '../../logging/logger.js';
|
|
19
19
|
import { SCROLLBACK_LIMITS } from './limits.js';
|
|
20
|
+
import { elisionRow } from './overflow-print.js';
|
|
20
21
|
/**
|
|
21
22
|
* Catches a throwing entry INSIDE the offscreen tree.
|
|
22
23
|
*
|
|
@@ -76,30 +77,52 @@ function trimTrailingBlank(rows) {
|
|
|
76
77
|
}
|
|
77
78
|
export function createEntryRenderer(initial) {
|
|
78
79
|
let options = initial;
|
|
79
|
-
|
|
80
|
+
/**
|
|
81
|
+
* Resident offscreen instances, keyed by width.
|
|
82
|
+
*
|
|
83
|
+
* TWO SLOTS, NOT ONE. Ink reads `columns` once, at creation, so a width change needs a new
|
|
84
|
+
* instance - but a width change happens WITHIN one promotion pass as soon as the plan
|
|
85
|
+
* measures at the box width (`previewCols`) and prints at `contentCols`, and a single slot
|
|
86
|
+
* would then dispose and rebuild a complete Ink root on every such frame. Two slots cover
|
|
87
|
+
* both widths of the current geometry; a third width (an actual resize) evicts the oldest.
|
|
88
|
+
*/
|
|
89
|
+
const slots = new Map();
|
|
90
|
+
const MAX_SLOTS = 2;
|
|
80
91
|
let elidedRows = 0;
|
|
81
92
|
let failures = 0;
|
|
82
93
|
let guardKey = 0;
|
|
83
|
-
const
|
|
84
|
-
|
|
94
|
+
const disposeSlot = (cols) => {
|
|
95
|
+
const target = slots.get(cols);
|
|
96
|
+
if (!target)
|
|
85
97
|
return;
|
|
86
|
-
|
|
87
|
-
offscreen = null;
|
|
98
|
+
slots.delete(cols);
|
|
88
99
|
try {
|
|
89
|
-
|
|
90
|
-
|
|
100
|
+
target.instance.unmount();
|
|
101
|
+
target.instance.cleanup();
|
|
91
102
|
}
|
|
92
103
|
catch {
|
|
93
104
|
// Tearing down a fake stream must never throw into an exit path.
|
|
94
105
|
}
|
|
95
106
|
};
|
|
107
|
+
const dispose = () => {
|
|
108
|
+
for (const cols of [...slots.keys()])
|
|
109
|
+
disposeSlot(cols);
|
|
110
|
+
};
|
|
96
111
|
/** Ink reads `columns` once, at creation, so a width change rebuilds the instance. */
|
|
97
112
|
const ensure = (cols) => {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
113
|
+
const resident = slots.get(cols);
|
|
114
|
+
if (resident) {
|
|
115
|
+
// Refresh the recency order so the OTHER width is the eviction candidate.
|
|
116
|
+
slots.delete(cols);
|
|
117
|
+
slots.set(cols, resident);
|
|
118
|
+
return resident;
|
|
119
|
+
}
|
|
120
|
+
const evictable = [...slots.keys()][0];
|
|
121
|
+
if (evictable !== undefined && slots.size >= MAX_SLOTS)
|
|
122
|
+
disposeSlot(evictable);
|
|
123
|
+
const created = createOffscreen(cols);
|
|
124
|
+
slots.set(cols, created);
|
|
125
|
+
return created;
|
|
103
126
|
};
|
|
104
127
|
const capRows = (rows) => {
|
|
105
128
|
const cap = SCROLLBACK_LIMITS.maxRowsPerEntry;
|
|
@@ -107,9 +130,9 @@ export function createEntryRenderer(initial) {
|
|
|
107
130
|
return rows;
|
|
108
131
|
const hidden = rows.length - (cap - 1);
|
|
109
132
|
elidedRows += hidden;
|
|
110
|
-
return [...rows.slice(0, cap - 1),
|
|
133
|
+
return [...rows.slice(0, cap - 1), elisionRow(hidden)];
|
|
111
134
|
};
|
|
112
|
-
const
|
|
135
|
+
const renderFrame = (node, cols) => {
|
|
113
136
|
const target = ensure(Math.max(1, Math.floor(cols)));
|
|
114
137
|
target.last.value = null;
|
|
115
138
|
target.failure.error = NO_FAILURE;
|
|
@@ -122,27 +145,32 @@ export function createEntryRenderer(initial) {
|
|
|
122
145
|
throw failure;
|
|
123
146
|
if (frame === null)
|
|
124
147
|
throw new Error('offscreen Ink instance produced no frame');
|
|
125
|
-
return
|
|
148
|
+
return trimTrailingBlank(frame.split('\n'));
|
|
126
149
|
};
|
|
127
150
|
const failureRow = (label) => {
|
|
128
151
|
failures += 1;
|
|
129
152
|
return [`[aragon] ${label} could not be rendered`];
|
|
130
153
|
};
|
|
154
|
+
const entryFrame = (entry, prev, cols, expanded) => renderFrame(_jsx(EntryView, { entry: entry, prev: prev, expanded: expanded, thinkingVisible: options.thinkingVisible, reducedMotion: options.reducedMotion, density: options.density, theme: options.theme, caps: options.caps }), cols);
|
|
155
|
+
const renderEntryRows = (entry, prev, cols, expanded = false) => {
|
|
156
|
+
try {
|
|
157
|
+
return entryFrame(entry, prev, cols, expanded);
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
getLogger().warn('cli', 'entry_render_failed', {
|
|
161
|
+
id: entry.id, kind: entry.kind, error: String(error),
|
|
162
|
+
});
|
|
163
|
+
return failureRow(`entry ${entry.id} (${entry.kind})`);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
131
166
|
return {
|
|
132
167
|
renderEntry(entry, prev, cols, expanded = false) {
|
|
133
|
-
|
|
134
|
-
return renderNode(_jsx(EntryView, { entry: entry, prev: prev, expanded: expanded, thinkingVisible: options.thinkingVisible, reducedMotion: options.reducedMotion, density: options.density, theme: options.theme, caps: options.caps }), cols);
|
|
135
|
-
}
|
|
136
|
-
catch (error) {
|
|
137
|
-
getLogger().warn('cli', 'entry_render_failed', {
|
|
138
|
-
id: entry.id, kind: entry.kind, error: String(error),
|
|
139
|
-
});
|
|
140
|
-
return failureRow(`entry ${entry.id} (${entry.kind})`);
|
|
141
|
-
}
|
|
168
|
+
return capRows(renderEntryRows(entry, prev, cols, expanded));
|
|
142
169
|
},
|
|
170
|
+
renderEntryRows,
|
|
143
171
|
renderNode(node, cols) {
|
|
144
172
|
try {
|
|
145
|
-
return
|
|
173
|
+
return capRows(renderFrame(node, cols));
|
|
146
174
|
}
|
|
147
175
|
catch (error) {
|
|
148
176
|
getLogger().warn('cli', 'node_render_failed', { error: String(error) });
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the live tail sits inside the band's preview box
|
|
3
|
+
* (tui-first-reply-bottom-aligned, plan A-prime).
|
|
4
|
+
*
|
|
5
|
+
* THE DEFECT THIS ANSWERS. The box is always the whole pool (`band.previewRows`, 24 rows
|
|
6
|
+
* on a 30-row terminal) while a first turn is four rows tall. A constant
|
|
7
|
+
* `justifyContent="flex-end"` therefore pushed those four rows against the composer and
|
|
8
|
+
* left every unused row ABOVE the conversation - the "the first reply starts at the
|
|
9
|
+
* bottom of the screen" report. The answer is conditional anchoring: top while the
|
|
10
|
+
* content fits, so the conversation is written downwards from under the header.
|
|
11
|
+
*
|
|
12
|
+
* WHY THE FALLBACK IS `bottom` AND NOT THE OTHER WAY ROUND. `flex-start` inside an
|
|
13
|
+
* `overflow="hidden"` box clips the NEWEST rows (Ink's clip rectangle is the box's
|
|
14
|
+
* `[top, top + height]`), and a streaming entry is never printable
|
|
15
|
+
* (`settled-boundary.ts` holds it unstable, and "printed is forever"). Overflowing to
|
|
16
|
+
* `flex-start` would hide the text the user is waiting for; overflowing to `flex-end`
|
|
17
|
+
* hides the oldest rows, which the tail window prints on its way out.
|
|
18
|
+
*
|
|
19
|
+
* THE THRESHOLD CARRIES A MARGIN. `rowOf` is an ESTIMATE, and the one available
|
|
20
|
+
* (`layout/virtual-window.ts::estimateEntryRows`) under-counts a `#` heading and a code
|
|
21
|
+
* block. The margin in `SCROLLBACK_LIMITS.tailAnchorSlackRows` absorbs that error on the
|
|
22
|
+
* `bottom` side, the only direction that cannot clip something new.
|
|
23
|
+
*
|
|
24
|
+
* PURE: no Ink, no I/O, no clock, and deliberately no import of `virtual-window.ts` (its
|
|
25
|
+
* import graph reaches a `.tsx` gutter). The row height is injected, so this stays three
|
|
26
|
+
* parameters and a unit test can drive it with any table it likes.
|
|
27
|
+
*/
|
|
28
|
+
import type { Entry } from '../../agent/reducer.js';
|
|
29
|
+
/** `top` = content grows down from the header; `bottom` = newest row hugs the composer. */
|
|
30
|
+
export type TailAnchor = 'top' | 'bottom';
|
|
31
|
+
/**
|
|
32
|
+
* Which alignment the live tail should use for the entries it is about to render.
|
|
33
|
+
*
|
|
34
|
+
* @param entries The entries THIS FRAME renders (already windowed by `selectTailEntries`;
|
|
35
|
+
* summing the whole conversation would make every session past the entry cap overflow and
|
|
36
|
+
* anchor to the bottom forever).
|
|
37
|
+
* @param budgetRows Height of the box that will clip them, in rows.
|
|
38
|
+
* @param rowOf Estimated height of one entry, including its separation row.
|
|
39
|
+
* @returns `top` when the estimates plus `tailAnchorSlackRows` fit in `budgetRows`,
|
|
40
|
+
* `bottom` otherwise (and for the first entry that does not fit, so the loop stops early).
|
|
41
|
+
*/
|
|
42
|
+
export declare function tailAnchor(entries: readonly Entry[], budgetRows: number, rowOf: (entry: Entry) => number): TailAnchor;
|
|
43
|
+
/**
|
|
44
|
+
* The anchor this frame really uses: MEASURED when the measurement exists, estimated
|
|
45
|
+
* otherwise.
|
|
46
|
+
*
|
|
47
|
+
* WHY A MEASURED ANSWER WINS (tui-final-reply-truncated-unscrollable). The estimate is an
|
|
48
|
+
* upper bound that charges a separation row this renderer may not draw, so it can claim the
|
|
49
|
+
* content overflows while it actually fits (the block sits at the bottom of a half-empty
|
|
50
|
+
* box - the very complaint `tui-first-reply-bottom-aligned` answered) and it under-counts a
|
|
51
|
+
* heading or a wrapped code block, so it can claim the content fits while the box is really
|
|
52
|
+
* clipping. The second error is the expensive one now: "top give-way" only prints while the
|
|
53
|
+
* box is bottom-anchored (that is the branch that clips the TOP), so a wrongly top-anchored
|
|
54
|
+
* box would clip the newest rows and print the oldest ones - the wrong half, twice.
|
|
55
|
+
*
|
|
56
|
+
* A measured total is available only when every window entry is stable AND already measured
|
|
57
|
+
* at the current geometry (`use-scrollback-view.ts` keeps that cache), which is exactly the
|
|
58
|
+
* frame on which a print decision is being made. Every other frame - streaming, resize,
|
|
59
|
+
* first sight of a new entry - falls back to the estimate, unchanged.
|
|
60
|
+
*
|
|
61
|
+
* @param measuredRows Measured height of the same entries, or `undefined` when unknown.
|
|
62
|
+
*/
|
|
63
|
+
export declare function resolveTailAnchor(input: {
|
|
64
|
+
entries: readonly Entry[];
|
|
65
|
+
budgetRows: number;
|
|
66
|
+
rowOf: (entry: Entry) => number;
|
|
67
|
+
measuredRows: number | undefined;
|
|
68
|
+
}): TailAnchor;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the live tail sits inside the band's preview box
|
|
3
|
+
* (tui-first-reply-bottom-aligned, plan A-prime).
|
|
4
|
+
*
|
|
5
|
+
* THE DEFECT THIS ANSWERS. The box is always the whole pool (`band.previewRows`, 24 rows
|
|
6
|
+
* on a 30-row terminal) while a first turn is four rows tall. A constant
|
|
7
|
+
* `justifyContent="flex-end"` therefore pushed those four rows against the composer and
|
|
8
|
+
* left every unused row ABOVE the conversation - the "the first reply starts at the
|
|
9
|
+
* bottom of the screen" report. The answer is conditional anchoring: top while the
|
|
10
|
+
* content fits, so the conversation is written downwards from under the header.
|
|
11
|
+
*
|
|
12
|
+
* WHY THE FALLBACK IS `bottom` AND NOT THE OTHER WAY ROUND. `flex-start` inside an
|
|
13
|
+
* `overflow="hidden"` box clips the NEWEST rows (Ink's clip rectangle is the box's
|
|
14
|
+
* `[top, top + height]`), and a streaming entry is never printable
|
|
15
|
+
* (`settled-boundary.ts` holds it unstable, and "printed is forever"). Overflowing to
|
|
16
|
+
* `flex-start` would hide the text the user is waiting for; overflowing to `flex-end`
|
|
17
|
+
* hides the oldest rows, which the tail window prints on its way out.
|
|
18
|
+
*
|
|
19
|
+
* THE THRESHOLD CARRIES A MARGIN. `rowOf` is an ESTIMATE, and the one available
|
|
20
|
+
* (`layout/virtual-window.ts::estimateEntryRows`) under-counts a `#` heading and a code
|
|
21
|
+
* block. The margin in `SCROLLBACK_LIMITS.tailAnchorSlackRows` absorbs that error on the
|
|
22
|
+
* `bottom` side, the only direction that cannot clip something new.
|
|
23
|
+
*
|
|
24
|
+
* PURE: no Ink, no I/O, no clock, and deliberately no import of `virtual-window.ts` (its
|
|
25
|
+
* import graph reaches a `.tsx` gutter). The row height is injected, so this stays three
|
|
26
|
+
* parameters and a unit test can drive it with any table it likes.
|
|
27
|
+
*/
|
|
28
|
+
import { SCROLLBACK_LIMITS } from './limits.js';
|
|
29
|
+
/**
|
|
30
|
+
* Which alignment the live tail should use for the entries it is about to render.
|
|
31
|
+
*
|
|
32
|
+
* @param entries The entries THIS FRAME renders (already windowed by `selectTailEntries`;
|
|
33
|
+
* summing the whole conversation would make every session past the entry cap overflow and
|
|
34
|
+
* anchor to the bottom forever).
|
|
35
|
+
* @param budgetRows Height of the box that will clip them, in rows.
|
|
36
|
+
* @param rowOf Estimated height of one entry, including its separation row.
|
|
37
|
+
* @returns `top` when the estimates plus `tailAnchorSlackRows` fit in `budgetRows`,
|
|
38
|
+
* `bottom` otherwise (and for the first entry that does not fit, so the loop stops early).
|
|
39
|
+
*/
|
|
40
|
+
export function tailAnchor(entries, budgetRows, rowOf) {
|
|
41
|
+
const budget = Number.isFinite(budgetRows) ? Math.max(0, Math.floor(budgetRows)) : 0;
|
|
42
|
+
let rows = 0;
|
|
43
|
+
for (const entry of entries) {
|
|
44
|
+
rows += Math.max(0, rowOf(entry));
|
|
45
|
+
if (rows + SCROLLBACK_LIMITS.tailAnchorSlackRows > budget)
|
|
46
|
+
return 'bottom';
|
|
47
|
+
}
|
|
48
|
+
return 'top';
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The anchor this frame really uses: MEASURED when the measurement exists, estimated
|
|
52
|
+
* otherwise.
|
|
53
|
+
*
|
|
54
|
+
* WHY A MEASURED ANSWER WINS (tui-final-reply-truncated-unscrollable). The estimate is an
|
|
55
|
+
* upper bound that charges a separation row this renderer may not draw, so it can claim the
|
|
56
|
+
* content overflows while it actually fits (the block sits at the bottom of a half-empty
|
|
57
|
+
* box - the very complaint `tui-first-reply-bottom-aligned` answered) and it under-counts a
|
|
58
|
+
* heading or a wrapped code block, so it can claim the content fits while the box is really
|
|
59
|
+
* clipping. The second error is the expensive one now: "top give-way" only prints while the
|
|
60
|
+
* box is bottom-anchored (that is the branch that clips the TOP), so a wrongly top-anchored
|
|
61
|
+
* box would clip the newest rows and print the oldest ones - the wrong half, twice.
|
|
62
|
+
*
|
|
63
|
+
* A measured total is available only when every window entry is stable AND already measured
|
|
64
|
+
* at the current geometry (`use-scrollback-view.ts` keeps that cache), which is exactly the
|
|
65
|
+
* frame on which a print decision is being made. Every other frame - streaming, resize,
|
|
66
|
+
* first sight of a new entry - falls back to the estimate, unchanged.
|
|
67
|
+
*
|
|
68
|
+
* @param measuredRows Measured height of the same entries, or `undefined` when unknown.
|
|
69
|
+
*/
|
|
70
|
+
export function resolveTailAnchor(input) {
|
|
71
|
+
const { entries, budgetRows, rowOf, measuredRows } = input;
|
|
72
|
+
if (measuredRows === undefined || !Number.isFinite(measuredRows)) {
|
|
73
|
+
return tailAnchor(entries, budgetRows, rowOf);
|
|
74
|
+
}
|
|
75
|
+
const budget = Number.isFinite(budgetRows) ? Math.max(0, Math.floor(budgetRows)) : 0;
|
|
76
|
+
return measuredRows > budget ? 'bottom' : 'top';
|
|
77
|
+
}
|
|
@@ -10,20 +10,21 @@
|
|
|
10
10
|
* only the unfinished cards on it. So the region now shows the last `K` PRINTABLE
|
|
11
11
|
* entries - settled or not - and an entry is printed when it LEAVES that window.
|
|
12
12
|
*
|
|
13
|
-
* The window is defined by ENTRY COUNT, never by measured height
|
|
14
|
-
* than the region
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
13
|
+
* The window is defined by ENTRY COUNT, never by measured height; what a single entry
|
|
14
|
+
* taller than the region used to do is the whole subject of
|
|
15
|
+
* `overflow-print.ts` (tui-final-reply-truncated-unscrollable). The box still clips it
|
|
16
|
+
* from the top with `justifyContent="flex-end"`, but the rows it hides are now PRINTED
|
|
17
|
+
* into the terminal's scrollback, where the wheel already reaches, instead of waiting for
|
|
18
|
+
* `K` further entries (README, known limitation 2 - rewritten by that fix).
|
|
18
19
|
*
|
|
19
20
|
* PURE: no Ink, no I/O, no clock. `promote()` (the writer's only feeder) takes
|
|
20
|
-
* `printBoundary`'s result and keeps its own `
|
|
21
|
+
* `printBoundary`'s result and keeps its own `printed` authority, so "printed is
|
|
21
22
|
* forward-only" (RV-7) is unchanged.
|
|
22
23
|
*
|
|
23
24
|
* PRINTABILITY != VISIBILITY. `isExcluded` entries (a non-terminal `service` card) never
|
|
24
25
|
* print and never take a slot in the window; an entry that is in the window may still be
|
|
25
|
-
* scrolled out of sight by a taller neighbour
|
|
26
|
-
*
|
|
26
|
+
* scrolled out of sight by a taller neighbour. That second gap is what the row-level plan
|
|
27
|
+
* closes, and `/perf`'s `window=<start>/<n> head=<rows>` is how it stays observable.
|
|
27
28
|
*/
|
|
28
29
|
import type { Entry } from '../../agent/reducer.js';
|
|
29
30
|
export interface TailWindow {
|
|
@@ -10,20 +10,21 @@
|
|
|
10
10
|
* only the unfinished cards on it. So the region now shows the last `K` PRINTABLE
|
|
11
11
|
* entries - settled or not - and an entry is printed when it LEAVES that window.
|
|
12
12
|
*
|
|
13
|
-
* The window is defined by ENTRY COUNT, never by measured height
|
|
14
|
-
* than the region
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
13
|
+
* The window is defined by ENTRY COUNT, never by measured height; what a single entry
|
|
14
|
+
* taller than the region used to do is the whole subject of
|
|
15
|
+
* `overflow-print.ts` (tui-final-reply-truncated-unscrollable). The box still clips it
|
|
16
|
+
* from the top with `justifyContent="flex-end"`, but the rows it hides are now PRINTED
|
|
17
|
+
* into the terminal's scrollback, where the wheel already reaches, instead of waiting for
|
|
18
|
+
* `K` further entries (README, known limitation 2 - rewritten by that fix).
|
|
18
19
|
*
|
|
19
20
|
* PURE: no Ink, no I/O, no clock. `promote()` (the writer's only feeder) takes
|
|
20
|
-
* `printBoundary`'s result and keeps its own `
|
|
21
|
+
* `printBoundary`'s result and keeps its own `printed` authority, so "printed is
|
|
21
22
|
* forward-only" (RV-7) is unchanged.
|
|
22
23
|
*
|
|
23
24
|
* PRINTABILITY != VISIBILITY. `isExcluded` entries (a non-terminal `service` card) never
|
|
24
25
|
* print and never take a slot in the window; an entry that is in the window may still be
|
|
25
|
-
* scrolled out of sight by a taller neighbour
|
|
26
|
-
*
|
|
26
|
+
* scrolled out of sight by a taller neighbour. That second gap is what the row-level plan
|
|
27
|
+
* closes, and `/perf`'s `window=<start>/<n> head=<rows>` is how it stays observable.
|
|
27
28
|
*/
|
|
28
29
|
import { isExcluded, settledCount } from './settled-boundary.js';
|
|
29
30
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `useScrollbackView` — the promotion pipeline of native-scroll mode
|
|
3
|
-
* (tui-native-terminal-scroll §4.4 / §6.2, tui-full-height-live-region D3/D4/D7/D8
|
|
3
|
+
* (tui-native-terminal-scroll §4.4 / §6.2, tui-full-height-live-region D3/D4/D7/D8,
|
|
4
|
+
* tui-final-reply-truncated-unscrollable A-prime).
|
|
4
5
|
*
|
|
5
6
|
* `App` calls it ALWAYS (hooks cannot be conditional); `enabled: false` makes every
|
|
6
7
|
* effect a no-op and keeps `scrollMode: 'app'` byte-identical to the pre-feature
|
|
@@ -12,8 +13,15 @@
|
|
|
12
13
|
* writer. Entries still on screen are never printed - at `H = rows - 1` a printed
|
|
13
14
|
* row is pushed back off the top by the next frame, and a second copy in the
|
|
14
15
|
* scrollback would be a duplicate the user meets by scrolling up (I-F8).
|
|
15
|
-
* 2.
|
|
16
|
-
*
|
|
16
|
+
* 2. Gives way at the TOP (tui-final-reply-truncated-unscrollable). The window is still
|
|
17
|
+
* counted in ENTRIES, so a settled answer taller than the box used to sit inside the
|
|
18
|
+
* window forever, clipped by `justifyContent="flex-end"`, in a mode whose wheel only
|
|
19
|
+
* scrolls the terminal's scrollback: the clipped rows existed nowhere the user could
|
|
20
|
+
* reach. The rows the box hides are now measured (`overflow-print.ts`) and printed, so
|
|
21
|
+
* `scrollback + screen` covers every row exactly once. Screen unchanged, reachability
|
|
22
|
+
* fixed.
|
|
23
|
+
* 3. Computes the live-region budget, the window and the tail rows for the shell.
|
|
24
|
+
* 4. Flushes the window before either reset path (`/clear`, `--resume`) and on exit,
|
|
17
25
|
* so "on screen but not printed yet" can never become "lost" (D8 / I-F12).
|
|
18
26
|
*
|
|
19
27
|
* THE HEADER AND THE OPENER ARE NOT PRINTED HERE ANY MORE (D3/D4). They are slots of
|
|
@@ -27,13 +35,20 @@
|
|
|
27
35
|
* issued from inside the main tree's commit (a layout effect) is deferred until that
|
|
28
36
|
* commit finishes, so its frame would not exist when the effect reads it. A microtask
|
|
29
37
|
* runs after the commit has unwound, where the offscreen render is synchronous again.
|
|
30
|
-
* Everything the pass needs is read from refs for that reason.
|
|
31
38
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
39
|
+
* THE PASS READS THE COMMITTED FRAME, NOT THE LATEST RENDER. `latest` is refreshed during
|
|
40
|
+
* render, so it can be a frame ahead of the screen; `committed` is written by a layout
|
|
41
|
+
* effect and therefore describes exactly the frame the user is looking at. With
|
|
42
|
+
* entry-granular bookkeeping the difference was harmless (printing was idempotent per
|
|
43
|
+
* entry); with ROW-granular bookkeeping it would slice this frame's picture with another
|
|
44
|
+
* frame's row numbers, and the result is a duplicate or a hole.
|
|
45
|
+
*
|
|
46
|
+
* `printed` is the ONLY authority on "already printed" (RV-7): a `Map` from entry id to
|
|
47
|
+
* the leading rows already handed to the writer, and the width they were measured at. The
|
|
48
|
+
* cursor is just a hint for where to resume scanning: entries leave the list by retain-ring
|
|
49
|
+
* trimming AND by reducer deletion (empty settled assistants, abandoned tool cards), so an
|
|
50
|
+
* id-keyed cursor can dangle, and then the only correct answer is to rescan and let
|
|
51
|
+
* `printed` skip.
|
|
37
52
|
*/
|
|
38
53
|
import type { Entry } from '../../agent/reducer.js';
|
|
39
54
|
import type { TermCapabilities } from '../capabilities.js';
|
|
@@ -50,7 +65,7 @@ export interface ScrollbackBridge {
|
|
|
50
65
|
requestFlush: () => void;
|
|
51
66
|
/**
|
|
52
67
|
* Installed by the hook on mount (reads the latest entries through a ref).
|
|
53
|
-
* `restore()` calls it on every exit path; it is idempotent through `
|
|
68
|
+
* `restore()` calls it on every exit path; it is idempotent through `printed`
|
|
54
69
|
* and it releases the offscreen renderer when done.
|
|
55
70
|
*/
|
|
56
71
|
settleAllNow: () => void;
|
|
@@ -89,6 +104,11 @@ export interface UseScrollbackViewArgs {
|
|
|
89
104
|
panelEnabled: boolean;
|
|
90
105
|
/** `buildTeamPanelLayout().rowCount`; 0 when nothing is dispatched. */
|
|
91
106
|
teamRowsNatural: number;
|
|
107
|
+
/**
|
|
108
|
+
* `state.expandedToolIds` - REQUIRED, because the height of a window entry depends on it
|
|
109
|
+
* and a forgotten value would measure an expansion the region is not drawing.
|
|
110
|
+
*/
|
|
111
|
+
expandedToolIds: Record<string, true>;
|
|
92
112
|
}
|
|
93
113
|
export interface ScrollbackView {
|
|
94
114
|
budget: ScrollbackBudget | null;
|
|
@@ -101,6 +121,14 @@ export interface ScrollbackView {
|
|
|
101
121
|
*/
|
|
102
122
|
tailEntries: readonly Entry[];
|
|
103
123
|
windowStart: number;
|
|
124
|
+
/**
|
|
125
|
+
* Measured height of `tailEntries`, once every one of them is stable AND measured at the
|
|
126
|
+
* current geometry; `undefined` otherwise. `LiveTail` prefers it over the estimate - see
|
|
127
|
+
* `tail-anchor.ts::resolveTailAnchor` for why the measured answer has to win.
|
|
128
|
+
*/
|
|
129
|
+
measuredTailRows: number | undefined;
|
|
130
|
+
/** Rows the top give-way has printed this session; `/perf`'s `head=`. */
|
|
131
|
+
headRows: number;
|
|
104
132
|
/** Print a fresh EXPANDED copy of an entry; false when it cannot be found / rendered. */
|
|
105
133
|
reprintExpanded(entryId: string): boolean;
|
|
106
134
|
/** Promote everything still unprinted (shutdown) - `flushUnprinted(latest entries)`. */
|