@oh-my-pi/pi-tui 18.12.6 → 18.13.0
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 +35 -34
- package/dist/types/app-keybindings.d.ts +5 -0
- package/dist/types/components/image.d.ts +18 -0
- package/dist/types/components/loader.d.ts +1 -1
- package/dist/types/native/blobs.d.ts +9 -0
- package/dist/types/overlays/agent-hub-projection.d.ts +3 -1
- 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/mcp-add-wizard.d.ts +2 -0
- 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/terminal-capabilities.d.ts +7 -0
- package/dist/types/tools/edit.d.ts +3 -1
- package/dist/types/tools/grouped-file-output.d.ts +2 -0
- package/dist/types/tools/mcp.d.ts +3 -3
- package/dist/types/tools/wait.d.ts +10 -2
- package/dist/types/vim.d.ts +39 -0
- package/package.json +9 -9
- 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/transcript-container.ts +61 -32
- package/src/components/editor.ts +432 -13
- package/src/components/image.ts +52 -16
- package/src/components/loader.ts +1 -1
- package/src/components/markdown.ts +95 -5
- package/src/hotkeys-markdown.ts +1 -0
- package/src/native/blobs.ts +3 -2
- package/src/overlays/agent-hub-projection.ts +6 -5
- package/src/overlays/agent-hub.ts +51 -42
- 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/mcp-add-wizard.ts +5 -0
- package/src/overlays/usage-dashboard.ts +15 -2
- package/src/prompt/macos-spelling.ts +24 -15
- package/src/render/hyperlink.ts +41 -18
- package/src/render/output-pane.ts +60 -17
- package/src/render/render-utils.ts +11 -2
- package/src/setup/scenes/sign-in.ts +6 -0
- package/src/terminal-capabilities.ts +10 -0
- package/src/tools/ast-grep.ts +3 -2
- package/src/tools/edit.ts +8 -4
- package/src/tools/find.ts +3 -10
- package/src/tools/glob.ts +4 -3
- package/src/tools/grep.ts +3 -4
- package/src/tools/grouped-file-output.ts +8 -2
- package/src/tools/mcp.ts +27 -9
- package/src/tools/native-view.ts +2 -2
- package/src/tools/vibe.ts +14 -3
- package/src/tools/wait.ts +10 -2
- package/src/tui.ts +36 -16
- package/src/vim.ts +313 -22
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Component, Container, type HistoryBatch } from "../tui";
|
|
2
2
|
import * as logger from "@oh-my-pi/pi-utils/logger";
|
|
3
3
|
import { popLoopPhase, pushLoopPhase } from "@oh-my-pi/pi-utils";
|
|
4
|
-
import { renderForScrollback } from "../components/image";
|
|
4
|
+
import { measureRender, renderForScrollback } from "../components/image";
|
|
5
5
|
import { col } from "../native/describe";
|
|
6
6
|
import type { NativeNode } from "../native/node";
|
|
7
7
|
import { isNativeSettled, settleNative } from "../native/settle";
|
|
@@ -159,6 +159,13 @@ const RETIREMENT_BUDGET_MS = 8;
|
|
|
159
159
|
const EMPTY_ROWS: readonly string[] = [];
|
|
160
160
|
const EMPTY_STABLE_ROWS: readonly TranscriptStableRow[] = [];
|
|
161
161
|
|
|
162
|
+
/** A block's full-allocation render taken by {@link TranscriptContainer}'s walk-order measurement. */
|
|
163
|
+
interface MeasuredBlock {
|
|
164
|
+
rows: readonly string[];
|
|
165
|
+
/** Whether the render observed a budgeted image; see {@link measureRender}. */
|
|
166
|
+
images: boolean;
|
|
167
|
+
}
|
|
168
|
+
|
|
162
169
|
function isFinalized(component: Component): boolean {
|
|
163
170
|
const block = component as Component & FinalizableBlock;
|
|
164
171
|
return (block.isTranscriptBlockFinalized?.() ?? true) && block.isTranscriptBlockPending?.() !== true;
|
|
@@ -282,7 +289,7 @@ export class TranscriptContainer extends Container {
|
|
|
282
289
|
* composition, with no block mutation possible in between; replaying the
|
|
283
290
|
* first measurement spares every block its second render per frame.
|
|
284
291
|
*/
|
|
285
|
-
#frameRows = new Map<TranscriptEntry,
|
|
292
|
+
#frameRows = new Map<TranscriptEntry, MeasuredBlock>();
|
|
286
293
|
#frameRowsWidth = 0;
|
|
287
294
|
#releaseFailures = new WeakSet<Component>();
|
|
288
295
|
/** The `children` array `#entries` last mirrored; see {@link #syncEntries}. */
|
|
@@ -510,41 +517,47 @@ export class TranscriptContainer extends Container {
|
|
|
510
517
|
this.#settleFinalized();
|
|
511
518
|
let total = 0;
|
|
512
519
|
for (const { entry, index } of this.#liveEntries()) {
|
|
513
|
-
const block = this.#
|
|
520
|
+
const block = this.#liveBlock(entry, index, width).rows;
|
|
514
521
|
if (block.length > 0) total += block.length + (total > 0 ? 1 : 0);
|
|
515
522
|
if (total > limit) break;
|
|
516
523
|
}
|
|
517
524
|
return total;
|
|
518
525
|
}
|
|
519
526
|
|
|
520
|
-
/** One live block's un-emitted rows at `width`,
|
|
521
|
-
#
|
|
522
|
-
const
|
|
527
|
+
/** One live block's un-emitted rows at `width`, measured against its full-height allocation. */
|
|
528
|
+
#liveBlock(entry: TranscriptEntry, index: number, width: number): MeasuredBlock {
|
|
529
|
+
const measured = this.#measure(entry, width);
|
|
523
530
|
const emitted = this.#projectedEmittedRowCount(entry, index, width);
|
|
524
|
-
return emitted === 0 ?
|
|
531
|
+
return emitted === 0 ? measured : { rows: measured.rows.slice(emitted), images: measured.images };
|
|
525
532
|
}
|
|
526
533
|
|
|
527
534
|
/**
|
|
528
535
|
* One block's blank-trimmed render at its full-height allocation. Inside an
|
|
529
536
|
* open frame the first measurement of each block is replayed to later ones,
|
|
530
537
|
* leaving whatever allocation the viewport has since rendered it at.
|
|
538
|
+
*
|
|
539
|
+
* Measurements run in walk order, not display order, so they render under
|
|
540
|
+
* {@link measureRender}: a block whose images they observed must render
|
|
541
|
+
* again in display order before its rows are laid out.
|
|
531
542
|
*/
|
|
532
|
-
#
|
|
533
|
-
if (this.#openFrame === undefined)
|
|
534
|
-
this.#setAllocation(entry.component, Number.MAX_SAFE_INTEGER, this.#lastFrame);
|
|
535
|
-
return this.#renderEntry(entry, width);
|
|
536
|
-
}
|
|
543
|
+
#measure(entry: TranscriptEntry, width: number): MeasuredBlock {
|
|
544
|
+
if (this.#openFrame === undefined) return this.#measureEntry(entry, width);
|
|
537
545
|
if (this.#frameRowsWidth !== width) {
|
|
538
546
|
this.#frameRows.clear();
|
|
539
547
|
this.#frameRowsWidth = width;
|
|
540
548
|
}
|
|
541
|
-
let
|
|
542
|
-
if (
|
|
543
|
-
this.#
|
|
544
|
-
|
|
545
|
-
this.#frameRows.set(entry, rows);
|
|
549
|
+
let measured = this.#frameRows.get(entry);
|
|
550
|
+
if (measured === undefined) {
|
|
551
|
+
measured = this.#measureEntry(entry, width);
|
|
552
|
+
this.#frameRows.set(entry, measured);
|
|
546
553
|
}
|
|
547
|
-
return
|
|
554
|
+
return measured;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
#measureEntry(entry: TranscriptEntry, width: number): MeasuredBlock {
|
|
558
|
+
this.#setAllocation(entry.component, Number.MAX_SAFE_INTEGER, this.#lastFrame);
|
|
559
|
+
const { value: rows, images } = measureRender(() => this.#renderEntry(entry, width));
|
|
560
|
+
return { rows, images };
|
|
548
561
|
}
|
|
549
562
|
|
|
550
563
|
#closeFrame(): void {
|
|
@@ -606,6 +619,7 @@ export class TranscriptContainer extends Container {
|
|
|
606
619
|
// show — the whole ledger on a resumed session's first paint (#12933).
|
|
607
620
|
const shown: Array<{ entry: TranscriptEntry; index: number }> = [];
|
|
608
621
|
const blocks: (readonly string[])[] = [];
|
|
622
|
+
const measuredImages: boolean[] = [];
|
|
609
623
|
let unrendered = 0;
|
|
610
624
|
for (let cursor = live.length - 1; cursor >= 0; cursor--) {
|
|
611
625
|
if (shown.length > capacity) {
|
|
@@ -613,15 +627,15 @@ export class TranscriptContainer extends Container {
|
|
|
613
627
|
break;
|
|
614
628
|
}
|
|
615
629
|
const candidate = live[cursor]!;
|
|
616
|
-
const block = this.#
|
|
617
|
-
if (block.length === 0) continue;
|
|
630
|
+
const block = this.#liveBlock(candidate.entry, candidate.index, width);
|
|
631
|
+
if (block.rows.length === 0) continue;
|
|
618
632
|
shown.push(candidate);
|
|
619
|
-
blocks.push(block);
|
|
633
|
+
blocks.push(block.rows);
|
|
634
|
+
measuredImages.push(block.images);
|
|
620
635
|
}
|
|
621
636
|
shown.reverse();
|
|
622
637
|
blocks.reverse();
|
|
623
|
-
|
|
624
|
-
for (const block of blocks) total += block.length + (total > 0 ? 1 : 0);
|
|
638
|
+
measuredImages.reverse();
|
|
625
639
|
if (shown.length === 0) {
|
|
626
640
|
this.#lastViewportSpans = [];
|
|
627
641
|
return EMPTY_ROWS;
|
|
@@ -631,6 +645,19 @@ export class TranscriptContainer extends Container {
|
|
|
631
645
|
// emergency layout consults them only where it must.
|
|
632
646
|
return this.#renderEmergency(shown, live.slice(0, unrendered), width, capacity, frame);
|
|
633
647
|
}
|
|
648
|
+
// The walk ran newest-first, so the images it measured claimed no
|
|
649
|
+
// display slot (see #measure). Render those blocks again oldest-first:
|
|
650
|
+
// the image budget keeps the newest images live by observation order.
|
|
651
|
+
for (let blockIndex = 0; blockIndex < shown.length; blockIndex++) {
|
|
652
|
+
if (!measuredImages[blockIndex]) continue;
|
|
653
|
+
const { entry, index } = shown[blockIndex]!;
|
|
654
|
+
this.#setAllocation(entry.component, Number.MAX_SAFE_INTEGER, frame);
|
|
655
|
+
blocks[blockIndex] = this.#renderEntry(entry, width).slice(
|
|
656
|
+
this.#projectedEmittedRowCount(entry, index, width),
|
|
657
|
+
);
|
|
658
|
+
}
|
|
659
|
+
let total = 0;
|
|
660
|
+
for (const block of blocks) total += block.length + (total > 0 ? 1 : 0);
|
|
634
661
|
if (total <= capacity) {
|
|
635
662
|
const output: string[] = [];
|
|
636
663
|
const owners: (Component | undefined)[] = [];
|
|
@@ -778,7 +805,7 @@ export class TranscriptContainer extends Container {
|
|
|
778
805
|
// Only a render publishes a block's stable rows, so the head renders
|
|
779
806
|
// before its progressive-append eligibility is read.
|
|
780
807
|
const head = this.#entries[this.#frontier];
|
|
781
|
-
if (head !== undefined) this.#
|
|
808
|
+
if (head !== undefined) this.#measure(head, width);
|
|
782
809
|
const appendHead =
|
|
783
810
|
policy === "pressure" &&
|
|
784
811
|
head?.mode === "appendOnly" &&
|
|
@@ -802,7 +829,7 @@ export class TranscriptContainer extends Container {
|
|
|
802
829
|
let fits = true;
|
|
803
830
|
for (let cursor = live.length - 1; cursor >= 0; cursor--) {
|
|
804
831
|
const candidate = live[cursor]!;
|
|
805
|
-
const height = this.#
|
|
832
|
+
const height = this.#liveBlock(candidate.entry, candidate.index, width).rows.length;
|
|
806
833
|
if (height > 0) liveRows += height + (liveRows > 0 ? 1 : 0);
|
|
807
834
|
if (fits) {
|
|
808
835
|
const next = height > 0 ? tailRows + height + (tailRows > 0 ? 1 : 0) : tailRows;
|
|
@@ -918,11 +945,13 @@ export class TranscriptContainer extends Container {
|
|
|
918
945
|
width: number,
|
|
919
946
|
visible: number,
|
|
920
947
|
): { rows: readonly string[]; split: RowSplit } | "whole" | undefined {
|
|
921
|
-
const measured = this.#
|
|
948
|
+
const measured = this.#measure(entry, width).rows;
|
|
922
949
|
const start = this.#emittedRowCount(entry, width);
|
|
923
950
|
const cut = measured.length - visible;
|
|
924
951
|
if (cut <= start) return undefined;
|
|
925
|
-
|
|
952
|
+
// The boundary block stays live, so the viewport renders it in display
|
|
953
|
+
// order; this render precedes the retired blocks and must claim no slot.
|
|
954
|
+
const scrollback = measureRender(() => renderForScrollback(() => this.#renderEntry(entry, width))).value;
|
|
926
955
|
if (scrollback.length !== measured.length) return undefined;
|
|
927
956
|
const total = cutBelowWholeImage(scrollback, cut);
|
|
928
957
|
if (total >= scrollback.length) return "whole";
|
|
@@ -1131,7 +1160,7 @@ export class TranscriptContainer extends Container {
|
|
|
1131
1160
|
* content stays live: it can repeat committed text but never drop any.
|
|
1132
1161
|
*/
|
|
1133
1162
|
#splitRowCount(entry: TranscriptEntry, split: RowSplit, width: number): number {
|
|
1134
|
-
const rendered = this.#
|
|
1163
|
+
const rendered = this.#measure(entry, width).rows;
|
|
1135
1164
|
if (split.located?.rendered === rendered) return split.located.count;
|
|
1136
1165
|
let count = 0;
|
|
1137
1166
|
if (
|
|
@@ -1333,10 +1362,10 @@ export class TranscriptContainer extends Container {
|
|
|
1333
1362
|
const entry = this.#entries[this.#frontier]!;
|
|
1334
1363
|
if (entry.state !== "settled") return;
|
|
1335
1364
|
if (entry.split !== undefined) {
|
|
1336
|
-
if (this.#splitRowCount(entry, entry.split, width) < this.#
|
|
1365
|
+
if (this.#splitRowCount(entry, entry.split, width) < this.#measure(entry, width).rows.length) return;
|
|
1337
1366
|
} else {
|
|
1338
1367
|
if (entry.mode !== "appendOnly") return;
|
|
1339
|
-
const rendered = this.#
|
|
1368
|
+
const rendered = this.#measure(entry, width).rows;
|
|
1340
1369
|
if (entry.emitted !== entry.stableRows.length) return;
|
|
1341
1370
|
if (this.#renderStablePrefix(entry, entry.emitted, width).length !== rendered.length) return;
|
|
1342
1371
|
}
|
|
@@ -1401,7 +1430,7 @@ export class TranscriptContainer extends Container {
|
|
|
1401
1430
|
let hiddenBelow = 0;
|
|
1402
1431
|
for (const candidate of behind) {
|
|
1403
1432
|
if (candidate.entry.state !== "active") continue;
|
|
1404
|
-
if (this.#
|
|
1433
|
+
if (this.#liveBlock(candidate.entry, candidate.index, width).rows.length > 0) hiddenBelow++;
|
|
1405
1434
|
}
|
|
1406
1435
|
let behindEmergency: { candidate: { entry: TranscriptEntry; index: number }; row: string } | null | undefined;
|
|
1407
1436
|
const findBehindEmergency = () => {
|
|
@@ -1412,7 +1441,7 @@ export class TranscriptContainer extends Container {
|
|
|
1412
1441
|
if (candidate.entry.state !== "settled") continue;
|
|
1413
1442
|
const block = candidate.entry.component as Component & FinalizableBlock;
|
|
1414
1443
|
if (block.renderTranscriptBlockEmergencyRow === undefined) continue;
|
|
1415
|
-
if (this.#
|
|
1444
|
+
if (this.#liveBlock(candidate.entry, candidate.index, width).rows.length === 0) continue;
|
|
1416
1445
|
const row = block.renderTranscriptBlockEmergencyRow(width);
|
|
1417
1446
|
if (row === undefined) continue;
|
|
1418
1447
|
behindEmergency = { candidate, row };
|