@linxiraos/pi-tui 1.4.3 → 1.4.6
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 +29 -23
- package/THIRD-PARTY-NOTICES.txt +14 -0
- package/dist/types/app-keybindings.d.ts +5 -0
- package/dist/types/chrome/context-map.d.ts +15 -0
- package/dist/types/chrome/context-presentation.d.ts +48 -0
- package/dist/types/chrome/context-view-model.d.ts +77 -0
- package/dist/types/components/image.d.ts +20 -0
- package/dist/types/components/loader.d.ts +1 -1
- package/dist/types/native/blobs.d.ts +9 -0
- package/dist/types/overlays/advisor-config.d.ts +6 -0
- package/dist/types/overlays/agent-hub-projection.d.ts +3 -1
- package/dist/types/overlays/ask-dialog.d.ts +12 -3
- package/dist/types/overlays/btw-history-panel.d.ts +16 -2
- package/dist/types/overlays/btw-history.d.ts +7 -0
- package/dist/types/overlays/btw-panel.d.ts +2 -0
- package/dist/types/overlays/context-viewer-format.d.ts +42 -0
- package/dist/types/overlays/context-viewer-overview.d.ts +70 -0
- package/dist/types/overlays/context-viewer.d.ts +25 -0
- package/dist/types/overlays/hook-input.d.ts +1 -0
- package/dist/types/overlays/mcp-add-wizard.d.ts +2 -0
- package/dist/types/overlays/pause-screen.d.ts +13 -3
- package/dist/types/overlays/running-subagent-badge.d.ts +7 -1
- package/dist/types/prompt/macos-spelling.d.ts +2 -2
- package/dist/types/render/hyperlink.d.ts +15 -2
- package/dist/types/render/output-pane.d.ts +1 -1
- package/dist/types/render/render-utils.d.ts +7 -1
- package/dist/types/status-line/component.d.ts +2 -2
- package/dist/types/status-line/context-usage.d.ts +15 -30
- package/dist/types/terminal-capabilities.d.ts +7 -0
- package/dist/types/theme/symbols.d.ts +1 -1
- package/dist/types/tools/ask.d.ts +4 -0
- package/dist/types/tools/edit.d.ts +3 -1
- package/dist/types/tools/fetch.d.ts +1 -0
- package/dist/types/tools/github.d.ts +3 -0
- package/dist/types/tools/grouped-file-output.d.ts +2 -0
- package/dist/types/tools/mcp.d.ts +3 -3
- package/dist/types/tools/read.d.ts +3 -0
- package/dist/types/tools/wait.d.ts +16 -2
- package/dist/types/tui.d.ts +2 -0
- package/dist/types/vim.d.ts +39 -0
- package/package.json +9 -9
- package/src/app-keybindings.d.ts +5 -0
- package/src/app-keybindings.ts +5 -0
- package/src/chat/bash-execution.ts +7 -1
- package/src/chat/read-tool-group.ts +1 -2
- package/src/chat/skill-message.ts +2 -6
- package/src/chrome/context-map.ts +62 -0
- package/src/chrome/context-presentation.ts +26 -0
- package/src/chrome/context-view-model.ts +73 -0
- package/src/chrome/transcript-container.ts +89 -59
- package/src/components/editor.ts +455 -13
- package/src/components/image.d.ts +20 -0
- package/src/components/image.ts +83 -18
- package/src/components/loader.d.ts +1 -1
- package/src/components/loader.ts +1 -1
- package/src/components/markdown.ts +109 -7
- package/src/hotkeys-markdown.ts +1 -0
- package/src/native/blobs.d.ts +9 -0
- package/src/native/blobs.ts +3 -2
- package/src/overlays/advisor-config.ts +9 -2
- package/src/overlays/agent-hub-projection.d.ts +3 -1
- package/src/overlays/agent-hub-projection.ts +6 -5
- package/src/overlays/agent-hub.ts +51 -42
- package/src/overlays/ask-dialog.ts +125 -35
- package/src/overlays/btw-history-panel.ts +124 -12
- package/src/overlays/btw-history.ts +11 -0
- package/src/overlays/btw-panel.ts +8 -4
- package/src/overlays/context-viewer-format.ts +145 -0
- package/src/overlays/context-viewer-overview.ts +381 -0
- package/src/overlays/context-viewer.ts +728 -0
- package/src/overlays/hook-input.ts +2 -0
- package/src/overlays/mcp-add-wizard.ts +5 -0
- package/src/overlays/pause-screen.ts +166 -33
- package/src/overlays/running-subagent-badge.ts +12 -1
- package/src/overlays/settings-defs.ts +1 -0
- package/src/overlays/usage-dashboard.ts +15 -2
- package/src/prompt/macos-spelling.ts +24 -15
- package/src/render/hyperlink.d.ts +15 -2
- package/src/render/hyperlink.ts +41 -18
- package/src/render/output-pane.d.ts +1 -1
- package/src/render/output-pane.ts +60 -17
- package/src/render/render-utils.d.ts +7 -1
- package/src/render/render-utils.ts +11 -2
- package/src/setup/scenes/sign-in.ts +6 -0
- package/src/status-line/component.ts +6 -4
- package/src/status-line/context-usage.ts +56 -582
- package/src/terminal-capabilities.d.ts +7 -0
- package/src/terminal-capabilities.ts +10 -0
- package/src/theme/symbols.d.ts +1 -1
- package/src/theme/symbols.ts +16 -0
- package/src/tools/ask.d.ts +4 -0
- package/src/tools/ask.ts +4 -0
- package/src/tools/ast-grep.ts +3 -2
- package/src/tools/bash.ts +5 -23
- package/src/tools/edit.d.ts +3 -1
- package/src/tools/edit.ts +8 -4
- package/src/tools/fetch.d.ts +1 -0
- package/src/tools/fetch.ts +1 -0
- package/src/tools/find.ts +3 -10
- package/src/tools/github.d.ts +3 -0
- package/src/tools/github.ts +23 -3
- package/src/tools/glob.ts +4 -3
- package/src/tools/grep.ts +3 -4
- package/src/tools/grouped-file-output.d.ts +2 -0
- package/src/tools/grouped-file-output.ts +8 -2
- package/src/tools/mcp.d.ts +3 -3
- package/src/tools/mcp.ts +27 -9
- package/src/tools/native-view.ts +2 -2
- package/src/tools/read.d.ts +3 -0
- package/src/tools/read.ts +3 -1
- package/src/tools/vibe.ts +14 -3
- package/src/tools/wait.d.ts +16 -2
- package/src/tools/wait.ts +16 -2
- package/src/tui.d.ts +2 -0
- package/src/tui.ts +59 -19
- package/src/vim.d.ts +39 -0
- package/src/vim.ts +313 -22
|
@@ -31,6 +31,21 @@ export interface ImageOptions {
|
|
|
31
31
|
* synchronously instead of committing its reserved blank rows.
|
|
32
32
|
*/
|
|
33
33
|
export declare function renderForScrollback<T>(render: () => T): T;
|
|
34
|
+
/**
|
|
35
|
+
* Run `render` to measure rows outside display order — a newest-first height
|
|
36
|
+
* walk, say. {@link ImageBudget} derives demotion from the order images are
|
|
37
|
+
* observed in, so a budgeted {@link Image} inside this scope claims no display
|
|
38
|
+
* slot: it replays the decision its slot in the surface's last full pass
|
|
39
|
+
* implies. `images` reports whether any budgeted image was observed; the caller
|
|
40
|
+
* MUST render every such block it lays out again, outside this scope and in
|
|
41
|
+
* display order, or its images keep no slot in the pass.
|
|
42
|
+
*/
|
|
43
|
+
export declare function measureRender<T>(render: () => T): {
|
|
44
|
+
value: T;
|
|
45
|
+
images: boolean;
|
|
46
|
+
demoted: boolean;
|
|
47
|
+
unresolved: boolean;
|
|
48
|
+
};
|
|
34
49
|
/** Widest an {@link Image} rendered at `width` columns draws; callers sizing a raster for it (`SvgFigure`) match it. */
|
|
35
50
|
export declare function imageMaxColumns(width: number): number;
|
|
36
51
|
/** Default count of inline images kept as live graphics before older ones fall back to text. */
|
|
@@ -118,6 +133,11 @@ export declare class ImageBudget {
|
|
|
118
133
|
* During a `stable` pass ({@link beginPass}) the call order and visible subset
|
|
119
134
|
* are not authoritative, so the decision is the surface's committed
|
|
120
135
|
* on-terminal split, keyed by id — order- and partiality-independent.
|
|
136
|
+
*
|
|
137
|
+
* Inside {@link measureRender} the call claims no slot: it answers what the
|
|
138
|
+
* image's slot in the last full pass implies under the planned threshold,
|
|
139
|
+
* which is what the display-order render that follows will decide once the
|
|
140
|
+
* split has converged.
|
|
121
141
|
*/
|
|
122
142
|
observe(imageId: number): boolean;
|
|
123
143
|
/**
|
package/src/components/image.ts
CHANGED
|
@@ -67,6 +67,47 @@ export function renderForScrollback<T>(render: () => T): T {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
/** Renders in progress that measure rows outside display order; see {@link measureRender}. */
|
|
71
|
+
let measureRenderDepth = 0;
|
|
72
|
+
/** Budgeted image observations made under {@link measureRender}; only differences are meaningful. */
|
|
73
|
+
let measuredImageObservations = 0;
|
|
74
|
+
/** Those observations that the planned split demotes to the text fallback. */
|
|
75
|
+
let measuredDemotedObservations = 0;
|
|
76
|
+
/** Those observations with no slot yet from a full pass, so their fate is unknown. */
|
|
77
|
+
let measuredUnresolvedObservations = 0;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Run `render` to measure rows outside display order — a newest-first height
|
|
81
|
+
* walk, say. {@link ImageBudget} derives demotion from the order images are
|
|
82
|
+
* observed in, so a budgeted {@link Image} inside this scope claims no display
|
|
83
|
+
* slot: it replays the decision its slot in the surface's last full pass
|
|
84
|
+
* implies. `images` reports whether any budgeted image was observed; the caller
|
|
85
|
+
* MUST render every such block it lays out again, outside this scope and in
|
|
86
|
+
* display order, or its images keep no slot in the pass.
|
|
87
|
+
*/
|
|
88
|
+
export function measureRender<T>(render: () => T): {
|
|
89
|
+
value: T;
|
|
90
|
+
images: boolean;
|
|
91
|
+
demoted: boolean;
|
|
92
|
+
unresolved: boolean;
|
|
93
|
+
} {
|
|
94
|
+
const before = measuredImageObservations;
|
|
95
|
+
const beforeDemoted = measuredDemotedObservations;
|
|
96
|
+
const beforeUnresolved = measuredUnresolvedObservations;
|
|
97
|
+
measureRenderDepth++;
|
|
98
|
+
try {
|
|
99
|
+
const value = render();
|
|
100
|
+
return {
|
|
101
|
+
value,
|
|
102
|
+
images: measuredImageObservations !== before,
|
|
103
|
+
demoted: measuredDemotedObservations !== beforeDemoted,
|
|
104
|
+
unresolved: measuredUnresolvedObservations !== beforeUnresolved,
|
|
105
|
+
};
|
|
106
|
+
} finally {
|
|
107
|
+
measureRenderDepth--;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
70
111
|
const EMPTY_IDS: readonly number[] = [];
|
|
71
112
|
const EMPTY_TRANSMITS: readonly string[] = [];
|
|
72
113
|
const SAVE_CURSOR = "\x1b7";
|
|
@@ -104,16 +145,16 @@ interface SurfaceSplit {
|
|
|
104
145
|
/** Images the last full pass on this surface observed. */
|
|
105
146
|
lastTotal: number;
|
|
106
147
|
/**
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
148
|
+
* Display slot of every image the last full pass on this surface observed,
|
|
149
|
+
* keyed by id. A pass that cannot derive display order from its own walk — a
|
|
150
|
+
* partial `stable` pass, or a {@link measureRender} scope — replays its
|
|
151
|
+
* decisions from these slots instead.
|
|
111
152
|
*/
|
|
112
|
-
readonly
|
|
153
|
+
readonly slots: Map<number, number>;
|
|
113
154
|
}
|
|
114
155
|
|
|
115
156
|
function newSurfaceSplit(): SurfaceSplit {
|
|
116
|
-
return { onTerminal: 0, planned: 0, lastTotal: 0,
|
|
157
|
+
return { onTerminal: 0, planned: 0, lastTotal: 0, slots: new Map() };
|
|
117
158
|
}
|
|
118
159
|
|
|
119
160
|
/** Return a split to "nothing has been painted on this surface yet", in place. */
|
|
@@ -121,7 +162,7 @@ function resetSurfaceSplit(split: SurfaceSplit): void {
|
|
|
121
162
|
split.onTerminal = 0;
|
|
122
163
|
split.planned = 0;
|
|
123
164
|
split.lastTotal = 0;
|
|
124
|
-
if (split.
|
|
165
|
+
if (split.slots.size > 0) split.slots.clear();
|
|
125
166
|
}
|
|
126
167
|
|
|
127
168
|
let nextImageBudgetSeed = Math.floor(Math.random() * 0xffffff);
|
|
@@ -336,14 +377,34 @@ export class ImageBudget {
|
|
|
336
377
|
* During a `stable` pass ({@link beginPass}) the call order and visible subset
|
|
337
378
|
* are not authoritative, so the decision is the surface's committed
|
|
338
379
|
* on-terminal split, keyed by id — order- and partiality-independent.
|
|
380
|
+
*
|
|
381
|
+
* Inside {@link measureRender} the call claims no slot: it answers what the
|
|
382
|
+
* image's slot in the last full pass implies under the planned threshold,
|
|
383
|
+
* which is what the display-order render that follows will decide once the
|
|
384
|
+
* split has converged.
|
|
339
385
|
*/
|
|
340
386
|
observe(imageId: number): boolean {
|
|
387
|
+
if (measureRenderDepth > 0) {
|
|
388
|
+
measuredImageObservations++;
|
|
389
|
+
if (this.#split.slots.get(imageId) === undefined) measuredUnresolvedObservations++;
|
|
390
|
+
}
|
|
341
391
|
const existing = this.#passSuppression.get(imageId);
|
|
342
|
-
if (existing !== undefined)
|
|
392
|
+
if (existing !== undefined) {
|
|
393
|
+
if (measureRenderDepth > 0 && existing) measuredDemotedObservations++;
|
|
394
|
+
return existing;
|
|
395
|
+
}
|
|
343
396
|
if (this.#stablePass) {
|
|
344
|
-
const suppressed = this.#cap > 0 && this.#split.
|
|
397
|
+
const suppressed = this.#cap > 0 && this.#lastSlotBelow(imageId, this.#split.onTerminal);
|
|
345
398
|
this.#passSuppression.set(imageId, suppressed);
|
|
346
|
-
if (suppressed)
|
|
399
|
+
if (suppressed) {
|
|
400
|
+
this.#forgetKeyForId(imageId);
|
|
401
|
+
if (measureRenderDepth > 0) measuredDemotedObservations++;
|
|
402
|
+
}
|
|
403
|
+
return suppressed;
|
|
404
|
+
}
|
|
405
|
+
if (measureRenderDepth > 0) {
|
|
406
|
+
const suppressed = this.#cap > 0 && this.#lastSlotBelow(imageId, this.#split.planned);
|
|
407
|
+
if (suppressed) measuredDemotedObservations++;
|
|
347
408
|
return suppressed;
|
|
348
409
|
}
|
|
349
410
|
const index = this.#passIds.length;
|
|
@@ -355,6 +416,12 @@ export class ImageBudget {
|
|
|
355
416
|
return suppressed;
|
|
356
417
|
}
|
|
357
418
|
|
|
419
|
+
/** Whether `imageId` held a display slot below `threshold` in the last full pass on this surface. */
|
|
420
|
+
#lastSlotBelow(imageId: number, threshold: number): boolean {
|
|
421
|
+
const slot = this.#split.slots.get(imageId);
|
|
422
|
+
return slot !== undefined && slot < threshold;
|
|
423
|
+
}
|
|
424
|
+
|
|
358
425
|
/**
|
|
359
426
|
* End a render pass. Returns true when the pass discovered a stricter budget
|
|
360
427
|
* and must be repeated before its terminal frame is emitted.
|
|
@@ -373,14 +440,12 @@ export class ImageBudget {
|
|
|
373
440
|
this.#applyingReset = false;
|
|
374
441
|
}
|
|
375
442
|
const retry = this.#reconcile(total);
|
|
376
|
-
// Snapshot
|
|
377
|
-
//
|
|
378
|
-
//
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
const suppressedCount = Math.min(total, split.onTerminal);
|
|
383
|
-
for (let i = 0; i < suppressedCount; i++) suppressedIds.add(this.#passIds[i]);
|
|
443
|
+
// Snapshot display order by id. Partial passes (see #stablePass) and
|
|
444
|
+
// measuring renders replay their decisions from it instead of
|
|
445
|
+
// re-deriving them from a reversed or tail-only walk.
|
|
446
|
+
const slots = split.slots;
|
|
447
|
+
if (slots.size > 0) slots.clear();
|
|
448
|
+
for (let i = 0; i < total; i++) slots.set(this.#passIds[i], i);
|
|
384
449
|
return retry;
|
|
385
450
|
}
|
|
386
451
|
|
|
@@ -75,6 +75,6 @@ export declare class Loader extends Text {
|
|
|
75
75
|
* session title). Re-evaluated every paint; dropped when the row leaves
|
|
76
76
|
* less than a two-cell gap. */
|
|
77
77
|
setTrailer(trailer: (() => string | undefined) | undefined): void;
|
|
78
|
-
setMessage(message: string): void;
|
|
78
|
+
setMessage(message: string | (() => string)): void;
|
|
79
79
|
}
|
|
80
80
|
export {};
|
package/src/components/loader.ts
CHANGED
|
@@ -1764,8 +1764,13 @@ type ListToken = Token & {
|
|
|
1764
1764
|
start?: number;
|
|
1765
1765
|
loose: boolean;
|
|
1766
1766
|
};
|
|
1767
|
-
type TableCellToken = { tokens?: Token[] };
|
|
1768
|
-
type TableToken = Token & {
|
|
1767
|
+
type TableCellToken = { tokens?: Token[]; align?: Tokens.TableCell["align"] };
|
|
1768
|
+
type TableToken = Token & {
|
|
1769
|
+
header: TableCellToken[];
|
|
1770
|
+
rows: TableCellToken[][];
|
|
1771
|
+
raw?: string;
|
|
1772
|
+
align?: Array<Tokens.TableCell["align"]>;
|
|
1773
|
+
};
|
|
1769
1774
|
|
|
1770
1775
|
/** `item` as marked lexes it inside a loose list: tight `text` blocks become paragraphs. */
|
|
1771
1776
|
function loosenListItem(item: Tokens.ListItem): Tokens.ListItem {
|
|
@@ -1819,6 +1824,63 @@ function formatHyperlink(text: string, target: string): string {
|
|
|
1819
1824
|
return `\x1b]8;;${safeTarget}\x07${text}\x1b]8;;\x07`;
|
|
1820
1825
|
}
|
|
1821
1826
|
|
|
1827
|
+
const CODE_ESCAPE_RE = /\x1b(?:\[[0-?]*[ -/]*[@-~]|\][^\x07\x1b]*(?:\x07|\x1b\\))/y;
|
|
1828
|
+
const CODE_URL_RE = /(?<![A-Za-z0-9+.-])https?:\/\/[^\s\x00-\x1f\x7f<>"'`]+/g;
|
|
1829
|
+
const CODE_URL_TRAILING_RE = /[.,;:!?]+$/;
|
|
1830
|
+
const CODE_URL_OPENERS: Partial<Record<string, string>> = { ")": "(", "]": "[", "}": "{" };
|
|
1831
|
+
|
|
1832
|
+
/** Whether `url` ends in a closing bracket that has no matching opener inside it. */
|
|
1833
|
+
function endsWithUnbalancedCloser(url: string): boolean {
|
|
1834
|
+
const closer = url.at(-1) ?? "";
|
|
1835
|
+
const opener = CODE_URL_OPENERS[closer];
|
|
1836
|
+
return opener !== undefined && url.split(closer).length > url.split(opener).length;
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
/**
|
|
1840
|
+
* Wrap each http(s) URL in a highlighted code row with an OSC 8 hyperlink.
|
|
1841
|
+
* The row is hard-wrapped later; wrapTextWithAnsi reopens the link on every
|
|
1842
|
+
* fragment, so terminals open the whole URL instead of only the first visual
|
|
1843
|
+
* line. URLs are located in the visible text so syntax-highlight escapes
|
|
1844
|
+
* inside them stay in place and the visible width is unchanged.
|
|
1845
|
+
*/
|
|
1846
|
+
function linkifyCodeUrls(line: string): string {
|
|
1847
|
+
if (!TERMINAL.hyperlinks || !line.includes("://") || line.includes("\x1b]8;")) {
|
|
1848
|
+
return line;
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1851
|
+
let visible = "";
|
|
1852
|
+
const offsets: number[] = [];
|
|
1853
|
+
for (let i = 0; i < line.length;) {
|
|
1854
|
+
if (line.charCodeAt(i) === 0x1b) {
|
|
1855
|
+
CODE_ESCAPE_RE.lastIndex = i;
|
|
1856
|
+
const match = CODE_ESCAPE_RE.exec(line);
|
|
1857
|
+
if (match) {
|
|
1858
|
+
i += match[0].length;
|
|
1859
|
+
continue;
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
offsets.push(i);
|
|
1863
|
+
visible += line[i];
|
|
1864
|
+
i++;
|
|
1865
|
+
}
|
|
1866
|
+
|
|
1867
|
+
let result = "";
|
|
1868
|
+
let copied = 0;
|
|
1869
|
+
for (const match of visible.matchAll(CODE_URL_RE)) {
|
|
1870
|
+
let url = match[0].replace(CODE_URL_TRAILING_RE, "");
|
|
1871
|
+
// A closer only belongs to the URL when it balances an opener inside it.
|
|
1872
|
+
while (endsWithUnbalancedCloser(url)) {
|
|
1873
|
+
url = url.slice(0, -1).replace(CODE_URL_TRAILING_RE, "");
|
|
1874
|
+
}
|
|
1875
|
+
if (!/:\/\/./.test(url)) continue;
|
|
1876
|
+
const start = offsets[match.index] ?? 0;
|
|
1877
|
+
const end = (offsets[match.index + url.length - 1] ?? start) + 1;
|
|
1878
|
+
result += line.slice(copied, start) + formatHyperlink(line.slice(start, end), url);
|
|
1879
|
+
copied = end;
|
|
1880
|
+
}
|
|
1881
|
+
return copied === 0 ? line : result + line.slice(copied);
|
|
1882
|
+
}
|
|
1883
|
+
|
|
1822
1884
|
function isAsciiTextSizingPayload(text: string): boolean {
|
|
1823
1885
|
for (let i = 0; i < text.length; i++) {
|
|
1824
1886
|
const code = text.charCodeAt(i);
|
|
@@ -3483,7 +3545,8 @@ export class Markdown implements Component {
|
|
|
3483
3545
|
const tokenText = "text" in token && typeof token.text === "string" ? token.text : "";
|
|
3484
3546
|
const lang = "lang" in token && typeof token.lang === "string" ? token.lang : undefined;
|
|
3485
3547
|
const addBodyLine = (line: string): void => {
|
|
3486
|
-
|
|
3548
|
+
const linked = linkifyCodeUrls(line);
|
|
3549
|
+
bodyLines.push(renderedLine(literalCode ? linked : codeIndent + linked, literalCode));
|
|
3487
3550
|
};
|
|
3488
3551
|
|
|
3489
3552
|
const streaming = this.transientRenderCache && !this.#renderingStablePrefix;
|
|
@@ -4283,7 +4346,13 @@ export class Markdown implements Component {
|
|
|
4283
4346
|
|
|
4284
4347
|
// Process item tokens; nested-list lines arrive structurally tagged and
|
|
4285
4348
|
// already carry their own full indent.
|
|
4286
|
-
const itemLines = this.#renderListItem(
|
|
4349
|
+
const itemLines = this.#renderListItem(
|
|
4350
|
+
item.tokens || [],
|
|
4351
|
+
depth,
|
|
4352
|
+
width,
|
|
4353
|
+
Math.max(1, width - visibleWidth(continuationIndent)),
|
|
4354
|
+
styleContext,
|
|
4355
|
+
);
|
|
4287
4356
|
|
|
4288
4357
|
if (itemLines.length > 0) {
|
|
4289
4358
|
const firstLine = itemLines[0]!;
|
|
@@ -4335,11 +4404,13 @@ export class Markdown implements Component {
|
|
|
4335
4404
|
tokens: Token[],
|
|
4336
4405
|
parentDepth: number,
|
|
4337
4406
|
width: number,
|
|
4407
|
+
contentWidth: number,
|
|
4338
4408
|
styleContext?: InlineStyleContext,
|
|
4339
4409
|
): RenderedListItemLine[] {
|
|
4340
4410
|
const lines: RenderedListItemLine[] = [];
|
|
4341
4411
|
|
|
4342
|
-
for (
|
|
4412
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
4413
|
+
const token = tokens[i]!;
|
|
4343
4414
|
if (token.type === "list") {
|
|
4344
4415
|
// Nested list - render with one additional indent level
|
|
4345
4416
|
// These lines carry their own indent, so tag them for pass-through
|
|
@@ -4379,6 +4450,10 @@ export class Markdown implements Component {
|
|
|
4379
4450
|
lines.push({ ...bodyLine, nested: false });
|
|
4380
4451
|
}
|
|
4381
4452
|
lines.push({ text: this.#theme.codeBlockBorder("```"), nested: false });
|
|
4453
|
+
} else if (token.type === "table") {
|
|
4454
|
+
for (const row of this.#renderTable(token as TableToken, contentWidth, tokens[i + 1]?.type, styleContext)) {
|
|
4455
|
+
lines.push({ text: row, nested: false });
|
|
4456
|
+
}
|
|
4382
4457
|
} else if (isMathToken(token)) {
|
|
4383
4458
|
// Display math block inside a list item: stack fractions / matrix rows.
|
|
4384
4459
|
const apply = styleContext?.applyText ?? ((t: string) => this.#applyDefaultStyle(t));
|
|
@@ -4445,6 +4520,26 @@ export class Markdown implements Component {
|
|
|
4445
4520
|
});
|
|
4446
4521
|
}
|
|
4447
4522
|
|
|
4523
|
+
/**
|
|
4524
|
+
* Pad a table cell to the width of its column, following the column's GFM
|
|
4525
|
+
* alignment: a right-aligned cell ends at the column's right edge, a
|
|
4526
|
+
* centered one is surrounded by padding, and anything else stays flush left.
|
|
4527
|
+
*/
|
|
4528
|
+
#alignCellText(text: string, width: number, align: Tokens.TableCell["align"]): string {
|
|
4529
|
+
const gap = Math.max(0, width - visibleWidth(text));
|
|
4530
|
+
if (gap === 0) return text;
|
|
4531
|
+
switch (align) {
|
|
4532
|
+
case "right":
|
|
4533
|
+
return padding(gap) + text;
|
|
4534
|
+
case "center": {
|
|
4535
|
+
const left = Math.floor(gap / 2);
|
|
4536
|
+
return padding(left) + text + padding(gap - left);
|
|
4537
|
+
}
|
|
4538
|
+
default:
|
|
4539
|
+
return text + padding(gap);
|
|
4540
|
+
}
|
|
4541
|
+
}
|
|
4542
|
+
|
|
4448
4543
|
/**
|
|
4449
4544
|
* Render a table with width-aware cell wrapping.
|
|
4450
4545
|
* Cells that don't fit are wrapped to multiple lines.
|
|
@@ -4586,6 +4681,12 @@ export class Markdown implements Component {
|
|
|
4586
4681
|
const h = t.horizontal;
|
|
4587
4682
|
const v = t.vertical;
|
|
4588
4683
|
|
|
4684
|
+
// GFM alignment belongs to the column: the marker in the delimiter row
|
|
4685
|
+
// applies to the header and to every body cell below it.
|
|
4686
|
+
const columnAligns: Array<Tokens.TableCell["align"]> = token.header.map(
|
|
4687
|
+
(cell, i) => cell.align ?? token.align?.[i] ?? null,
|
|
4688
|
+
);
|
|
4689
|
+
|
|
4589
4690
|
// Render top border
|
|
4590
4691
|
const topBorderCells = columnWidths.map(w => h.repeat(w));
|
|
4591
4692
|
lines.push(`${t.topLeft}${h}${topBorderCells.join(`${h}${t.teeDown}${h}`)}${h}${t.topRight}`);
|
|
@@ -4600,7 +4701,7 @@ export class Markdown implements Component {
|
|
|
4600
4701
|
for (let lineIdx = 0; lineIdx < headerLineCount; lineIdx++) {
|
|
4601
4702
|
const rowParts = headerCellLines.map((cellLines, colIdx) => {
|
|
4602
4703
|
const text = cellLines[lineIdx] || "";
|
|
4603
|
-
const padded = text
|
|
4704
|
+
const padded = this.#alignCellText(text, columnWidths[colIdx], columnAligns[colIdx] ?? null);
|
|
4604
4705
|
return this.#theme.bold(padded);
|
|
4605
4706
|
});
|
|
4606
4707
|
lines.push(`${v} ${rowParts.join(` ${v} `)} ${v}`);
|
|
@@ -4644,7 +4745,8 @@ export class Markdown implements Component {
|
|
|
4644
4745
|
for (let lineIdx = 0; lineIdx < rowLineCount; lineIdx++) {
|
|
4645
4746
|
const rowParts = rowCellLines.map((cellLines, colIdx) => {
|
|
4646
4747
|
const text = cellLines[lineIdx] || "";
|
|
4647
|
-
|
|
4748
|
+
const align = row[colIdx]?.align ?? columnAligns[colIdx] ?? null;
|
|
4749
|
+
return this.#alignCellText(text, columnWidths[colIdx], align);
|
|
4648
4750
|
});
|
|
4649
4751
|
lines.push(`${v} ${rowParts.join(` ${v} `)} ${v}`);
|
|
4650
4752
|
}
|
package/src/hotkeys-markdown.ts
CHANGED
|
@@ -139,6 +139,7 @@ function hotkeyGroups(bindings: HotkeysMarkdownBindings): HotkeyGroup[] {
|
|
|
139
139
|
{ keys: [act("app.approval.approve")], action: "Approve a pending tool call" },
|
|
140
140
|
{ keys: [act("app.thinking.toggle")], action: "Toggle thinking block visibility" },
|
|
141
141
|
{ keys: [act("app.editor.external")], action: "Edit message in external editor" },
|
|
142
|
+
{ keys: [act("app.local.open")], action: "Open a local:// file in external editor" },
|
|
142
143
|
{ keys: [act("app.retry")], action: "Retry last failed assistant turn" },
|
|
143
144
|
{ keys: [act("app.clipboard.pasteImage")], action: "Paste image or text from clipboard" },
|
|
144
145
|
{
|
package/src/native/blobs.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content-addressed binary blobs (images) for `image` nodes.
|
|
3
|
+
*
|
|
4
|
+
* `describe()` registers the bytes and puts the returned id in `image.p.blob`;
|
|
5
|
+
* the native backend delivers each referenced blob once per terminal
|
|
6
|
+
* connection (asking the terminal first which it holds, or through its blob
|
|
7
|
+
* cache), else uploads it with verb `b` before the frame that first
|
|
8
|
+
* references it.
|
|
9
|
+
*/
|
|
1
10
|
import type { TspProps } from "@linxiraos/pi-wire";
|
|
2
11
|
import type { NativeChild, NativeNode } from "./node";
|
|
3
12
|
export interface NativeBlob {
|
package/src/native/blobs.ts
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* cache), else uploads it with verb `b` before the frame that first
|
|
8
8
|
* references it.
|
|
9
9
|
*/
|
|
10
|
-
import * as url from "node:url";
|
|
11
10
|
import type { TspProps } from "@linxiraos/pi-wire";
|
|
11
|
+
import { tryFileUri } from "../render/hyperlink";
|
|
12
12
|
import { resolveImageOptions } from "../render/render-utils";
|
|
13
13
|
import { getImageDimensions } from "../terminal-capabilities";
|
|
14
14
|
import { node } from "./describe";
|
|
@@ -100,7 +100,8 @@ export function base64ImageNode(
|
|
|
100
100
|
* context menu. Empty without a file.
|
|
101
101
|
*/
|
|
102
102
|
export function openableImageProps(filePath: string | undefined): Pick<TspProps<"image">, "href" | "actions"> {
|
|
103
|
-
|
|
103
|
+
const href = filePath ? tryFileUri(filePath) : undefined;
|
|
104
|
+
return href ? { href, actions: { menu: ["open"] } } : {};
|
|
104
105
|
}
|
|
105
106
|
|
|
106
107
|
/**
|
|
@@ -64,10 +64,11 @@ import { getThinkingLevelMetadata, parseThinkingLevel } from "../thinking";
|
|
|
64
64
|
|
|
65
65
|
export const ADVISOR_REVIEW_MODES = ["turn", "agent-end"] as const;
|
|
66
66
|
export const ADVISOR_SYNC_BACKLOG_MODES = ["off", "1", "3", "5", "strict"] as const;
|
|
67
|
+
export const ADVISOR_SESSION_SCOPES = ["main", "subagent", "all"] as const;
|
|
67
68
|
|
|
68
69
|
export type AdvisorReviewMode = (typeof ADVISOR_REVIEW_MODES)[number];
|
|
69
70
|
export type AdvisorSyncBacklog = (typeof ADVISOR_SYNC_BACKLOG_MODES)[number];
|
|
70
|
-
|
|
71
|
+
export type AdvisorSessionScope = (typeof ADVISOR_SESSION_SCOPES)[number];
|
|
71
72
|
/** One advisor declared in `WATCHDOG.yml`; its instructions specialize the shared baseline. */
|
|
72
73
|
export interface AdvisorConfig {
|
|
73
74
|
name: string;
|
|
@@ -83,6 +84,10 @@ export interface AdvisorConfig {
|
|
|
83
84
|
reviewMode?: AdvisorReviewMode;
|
|
84
85
|
reviewInterval?: number;
|
|
85
86
|
syncBacklog?: AdvisorSyncBacklog;
|
|
87
|
+
/** Which session kinds this advisor attaches to (`main`, `subagent`, or `all`; defaults to `all`). */
|
|
88
|
+
scope?: AdvisorSessionScope;
|
|
89
|
+
/** Whether primary assistant thinking blocks are included in updates sent to this advisor (defaults to `true`). */
|
|
90
|
+
includeReasoning?: boolean;
|
|
86
91
|
}
|
|
87
92
|
|
|
88
93
|
/** Which level a `WATCHDOG.yml` lives at: the project root or the user agent dir. */
|
|
@@ -1202,7 +1207,9 @@ export class AdvisorConfigOverlayComponent implements Component {
|
|
|
1202
1207
|
advisor.syncBacklog === undefined &&
|
|
1203
1208
|
!advisor.instructions?.trim() &&
|
|
1204
1209
|
advisor.enabled !== false &&
|
|
1205
|
-
advisor.maxNotesPerUpdate === undefined
|
|
1210
|
+
advisor.maxNotesPerUpdate === undefined &&
|
|
1211
|
+
advisor.scope === undefined &&
|
|
1212
|
+
advisor.includeReasoning === undefined
|
|
1206
1213
|
);
|
|
1207
1214
|
}
|
|
1208
1215
|
|
|
@@ -44,5 +44,7 @@ export declare function aggregateMetrics<TRecord extends AgentRecordLike>(args:
|
|
|
44
44
|
hasFallbackLiveSessions: boolean;
|
|
45
45
|
};
|
|
46
46
|
/** Parent-before-child projection preserving initial subtree rank and prepending new siblings. */
|
|
47
|
-
export declare function projectAgentTree<TRecord extends AgentRecordLike>(refs: readonly TRecord[],
|
|
47
|
+
export declare function projectAgentTree<TRecord extends AgentRecordLike>(refs: readonly TRecord[],
|
|
48
|
+
/** Rows spawned while the hub is open; such a child never lifts its parent's group. */
|
|
49
|
+
spawnedWhileOpen?: (ref: TRecord) => boolean): AgentTreeProjection<TRecord>;
|
|
48
50
|
export {};
|
|
@@ -342,7 +342,8 @@ export function aggregateMetrics<TRecord extends AgentRecordLike>(args: {
|
|
|
342
342
|
/** Parent-before-child projection preserving initial subtree rank and prepending new siblings. */
|
|
343
343
|
export function projectAgentTree<TRecord extends AgentRecordLike>(
|
|
344
344
|
refs: readonly TRecord[],
|
|
345
|
-
|
|
345
|
+
/** Rows spawned while the hub is open; such a child never lifts its parent's group. */
|
|
346
|
+
spawnedWhileOpen?: (ref: TRecord) => boolean,
|
|
346
347
|
): AgentTreeProjection<TRecord> {
|
|
347
348
|
const ids = new Set<string>();
|
|
348
349
|
const operationalIndex = new Map<string, number>();
|
|
@@ -374,13 +375,13 @@ export function projectAgentTree<TRecord extends AgentRecordLike>(
|
|
|
374
375
|
const current = stack.pop();
|
|
375
376
|
if (!current) continue;
|
|
376
377
|
if (current.expanded) {
|
|
377
|
-
|
|
378
|
-
|
|
378
|
+
const own = operationalIndex.get(current.ref.id) ?? Number.MAX_SAFE_INTEGER;
|
|
379
|
+
let order = own;
|
|
379
380
|
for (const child of children.get(current.ref.id) ?? []) {
|
|
380
|
-
const childRank = rosterRank?.get(child);
|
|
381
381
|
// A child spawned later cannot move an existing parent's group.
|
|
382
|
-
if (
|
|
382
|
+
if (spawnedWhileOpen?.(child) && (operationalIndex.get(child.id) ?? Number.MAX_SAFE_INTEGER) < own) {
|
|
383
383
|
continue;
|
|
384
|
+
}
|
|
384
385
|
order = Math.min(order, subtreeOrder.get(child.id) ?? Number.MAX_SAFE_INTEGER);
|
|
385
386
|
}
|
|
386
387
|
subtreeOrder.set(current.ref.id, order);
|
|
@@ -200,9 +200,18 @@ const DATA_CHANGE_RENDER_COALESCE_MS = 100;
|
|
|
200
200
|
/** Double-tap window for the table's left-left "close hub" gesture. */
|
|
201
201
|
const LEFT_TAP_WINDOW_MS = 500;
|
|
202
202
|
|
|
203
|
-
|
|
203
|
+
/** A row's rank, frozen when the hub first saw its generation: the batch it came in, and its status and recency then. */
|
|
204
|
+
interface FrozenRank extends Pick<AgentRecordLike, "id" | "status" | "lastActivity"> {
|
|
205
|
+
/** 0 for the agents the hub opened with or the saved-agent scan found; each later batch of new generations is one lower. */
|
|
206
|
+
batch: number;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function compareFrozenRanks(a: FrozenRank, b: FrozenRank): number {
|
|
204
210
|
return (
|
|
205
|
-
|
|
211
|
+
a.batch - b.batch ||
|
|
212
|
+
STATUS_ORDER[a.status] - STATUS_ORDER[b.status] ||
|
|
213
|
+
b.lastActivity - a.lastActivity ||
|
|
214
|
+
a.id.localeCompare(b.id)
|
|
206
215
|
);
|
|
207
216
|
}
|
|
208
217
|
|
|
@@ -364,10 +373,17 @@ export class AgentHubOverlayComponent<TRecord extends AgentRecordLike = AgentRec
|
|
|
364
373
|
#rows: TRecord[] = [];
|
|
365
374
|
#statusCounts: Record<AgentStatus, number> = { running: 0, idle: 0, parked: 0, aborted: 0 };
|
|
366
375
|
#selectedRow = 0;
|
|
367
|
-
/**
|
|
368
|
-
*
|
|
369
|
-
|
|
370
|
-
|
|
376
|
+
/**
|
|
377
|
+
* Each row keeps the rank it got when the hub first saw its generation, so
|
|
378
|
+
* heartbeats and status changes do not move rows. An agent the saved-agent
|
|
379
|
+
* scan finds takes its place in the status/recency order; every other new
|
|
380
|
+
* generation goes on top.
|
|
381
|
+
*/
|
|
382
|
+
#frozenRank = new Map<TRecord, FrozenRank>();
|
|
383
|
+
/** Every id ranked so far: a new object under a known id is a new generation, not a saved agent. */
|
|
384
|
+
#seenIds = new Set<string>();
|
|
385
|
+
#opened = false;
|
|
386
|
+
#spawnBatches = 0;
|
|
371
387
|
#hoveredRow: number | null = null;
|
|
372
388
|
/** Per-render screen-line to agent-row map, shared by click and hover routing. */
|
|
373
389
|
#hitRows: Array<number | undefined> = [];
|
|
@@ -519,13 +535,11 @@ export class AgentHubOverlayComponent<TRecord extends AgentRecordLike = AgentRec
|
|
|
519
535
|
logger.warn("Failed to register persisted subagents", { error });
|
|
520
536
|
})
|
|
521
537
|
.finally(() => {
|
|
522
|
-
|
|
523
|
-
//
|
|
538
|
+
if (this.#disposed) return;
|
|
539
|
+
// Rank what the scan found before its end turns later arrivals into spawns.
|
|
540
|
+
this.#refreshRows();
|
|
524
541
|
this.#loadingPersistedSubagents = false;
|
|
525
|
-
|
|
526
|
-
this.#refreshRows();
|
|
527
|
-
this.#requestRender();
|
|
528
|
-
}
|
|
542
|
+
this.#requestRender();
|
|
529
543
|
});
|
|
530
544
|
this.#refreshRows();
|
|
531
545
|
}
|
|
@@ -1532,41 +1546,36 @@ export class AgentHubOverlayComponent<TRecord extends AgentRecordLike = AgentRec
|
|
|
1532
1546
|
this.#requestRender();
|
|
1533
1547
|
}
|
|
1534
1548
|
|
|
1549
|
+
/** A parked or killed agent with no live session and an unknown id, seen while the saved-agent scan runs, is one the scan found. */
|
|
1550
|
+
#foundOnDisk(ref: TRecord): boolean {
|
|
1551
|
+
return (
|
|
1552
|
+
this.#loadingPersistedSubagents &&
|
|
1553
|
+
ref.session === null &&
|
|
1554
|
+
(ref.status === "parked" || ref.status === "aborted") &&
|
|
1555
|
+
!this.#seenIds.has(ref.id)
|
|
1556
|
+
);
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1535
1559
|
#refreshRows(): void {
|
|
1536
1560
|
const selectedId = this.#rows[this.#selectedRow]?.id;
|
|
1537
1561
|
const refs = this.#registry.list().filter(ref => ref.id !== MAIN_AGENT_ID);
|
|
1538
1562
|
this.#observedById = new Map();
|
|
1539
1563
|
for (const session of this.#observers.getSessions()) this.#observedById.set(session.id, session);
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
const
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
} else {
|
|
1553
|
-
for (const rankedRef of rowOrder.keys()) {
|
|
1554
|
-
if (!refs.includes(rankedRef)) rowOrder.delete(rankedRef);
|
|
1555
|
-
}
|
|
1556
|
-
// Each batch of newly appearing generations uses the initial sort,
|
|
1557
|
-
// then takes ranks above every agent already on screen.
|
|
1558
|
-
let newcomers: TRecord[] | undefined;
|
|
1559
|
-
for (const ref of refs) {
|
|
1560
|
-
if (!rowOrder.has(ref)) (newcomers ??= []).push(ref);
|
|
1561
|
-
}
|
|
1562
|
-
if (newcomers) {
|
|
1563
|
-
newcomers.sort(compareRosterAgents);
|
|
1564
|
-
for (let i = newcomers.length - 1; i >= 0; i--) {
|
|
1565
|
-
rowOrder.set(newcomers[i]!, --this.#nextNewRowOrder);
|
|
1566
|
-
}
|
|
1567
|
-
}
|
|
1568
|
-
ordered = refs.sort((a, b) => rowOrder.get(a)! - rowOrder.get(b)!);
|
|
1564
|
+
const live = new Set(refs);
|
|
1565
|
+
for (const ref of this.#frozenRank.keys()) if (!live.has(ref)) this.#frozenRank.delete(ref);
|
|
1566
|
+
let spawnBatch: number | undefined;
|
|
1567
|
+
for (const ref of refs) {
|
|
1568
|
+
if (this.#frozenRank.has(ref)) continue;
|
|
1569
|
+
this.#frozenRank.set(ref, {
|
|
1570
|
+
batch: this.#opened && !this.#foundOnDisk(ref) ? (spawnBatch ??= --this.#spawnBatches) : 0,
|
|
1571
|
+
id: ref.id,
|
|
1572
|
+
status: ref.status,
|
|
1573
|
+
lastActivity: ref.lastActivity,
|
|
1574
|
+
});
|
|
1575
|
+
this.#seenIds.add(ref.id);
|
|
1569
1576
|
}
|
|
1577
|
+
this.#opened = true;
|
|
1578
|
+
const ordered = refs.sort((a, b) => compareFrozenRanks(this.#frozenRank.get(a)!, this.#frozenRank.get(b)!));
|
|
1570
1579
|
const query = this.#agentFilter.getValue().trim();
|
|
1571
1580
|
const rosterRows =
|
|
1572
1581
|
query.length > 0
|
|
@@ -1574,7 +1583,7 @@ export class AgentHubOverlayComponent<TRecord extends AgentRecordLike = AgentRec
|
|
|
1574
1583
|
: ordered;
|
|
1575
1584
|
|
|
1576
1585
|
if (this.#viewMode === "tree") {
|
|
1577
|
-
const tree = projectAgentTree(rosterRows,
|
|
1586
|
+
const tree = projectAgentTree(rosterRows, ref => this.#frozenRank.get(ref)!.batch < 0);
|
|
1578
1587
|
this.#rows = tree.rows;
|
|
1579
1588
|
this.#treeDepthById = tree.depthById;
|
|
1580
1589
|
this.#treeParentById = tree.parentById;
|