@linxiraos/pi-tui 1.4.4 → 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 -27
- 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
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Text } from "../components/text";
|
|
2
2
|
import { ansi } from "../native/describe";
|
|
3
|
+
import { Memo } from "../native/memo";
|
|
3
4
|
import type { DescribeContext, NativeNode } from "../native/node";
|
|
4
5
|
import { ImageProtocol, TERMINAL } from "../terminal-capabilities";
|
|
5
|
-
import type
|
|
6
|
+
import { getThemeEpoch, type Theme } from "../theme/theme";
|
|
6
7
|
import type { Component } from "../tui";
|
|
7
|
-
import { getPaddingX } from "../utils";
|
|
8
|
+
import { getPaddingX, getWidthConfigEpoch } from "../utils";
|
|
8
9
|
import { truncateToVisualLines } from "../chrome/visual-truncate";
|
|
9
10
|
import { getSixelLineMask } from "./sixel";
|
|
10
11
|
import { formatExpandHint, replaceTabs } from "./render-utils";
|
|
@@ -158,8 +159,17 @@ export class OutputPane implements Component {
|
|
|
158
159
|
#lines: string[] = [];
|
|
159
160
|
#pendingCarriageReturn = false;
|
|
160
161
|
#text: Text;
|
|
161
|
-
|
|
162
|
+
/** The content last handed to the inner `Text`, compared by identity. */
|
|
163
|
+
#renderContent: string | undefined;
|
|
162
164
|
#native: NativeNode | undefined;
|
|
165
|
+
/**
|
|
166
|
+
* The styled-and-joined content of the last render, kept with the inputs
|
|
167
|
+
* that produced it. A pane re-renders every frame while it sits in the live
|
|
168
|
+
* transcript tail, but its content only changes when its rows, presentation,
|
|
169
|
+
* width, theme, or image protocol change — so the styling, joining and
|
|
170
|
+
* hashing would otherwise be repeated work on every frame.
|
|
171
|
+
*/
|
|
172
|
+
#memo = new Memo<string>();
|
|
163
173
|
|
|
164
174
|
constructor(theme: Theme, options: OutputPaneOptions, text = "") {
|
|
165
175
|
this.#theme = theme;
|
|
@@ -276,34 +286,67 @@ export class OutputPane implements Component {
|
|
|
276
286
|
return this.#native;
|
|
277
287
|
}
|
|
278
288
|
|
|
289
|
+
/**
|
|
290
|
+
* The content the last render produced, rebuilt only when one of the
|
|
291
|
+
* inputs it depends on changes.
|
|
292
|
+
*
|
|
293
|
+
* The pane's own state — the stored rows and the options — changes only
|
|
294
|
+
* through methods that call {@link OutputPane.invalidate}, which drops
|
|
295
|
+
* this memo. The dependencies below are the inputs that can change
|
|
296
|
+
* *without* the pane hearing about it, and every one of them shapes the
|
|
297
|
+
* content:
|
|
298
|
+
*
|
|
299
|
+
* - `contentWidth` — the wrapping width that feeds the visual cap as well
|
|
300
|
+
* as the inner `Text` render: `width` minus both horizontal paddings.
|
|
301
|
+
* - `widthConfigEpoch` — the width-affecting runtime configuration (the
|
|
302
|
+
* Hangul compatibility-Jamo width), which `visibleWidth` — and so the
|
|
303
|
+
* visual cap — depends on.
|
|
304
|
+
* - `themeEpoch` — the active theme's colors, which `styleLine` bakes into
|
|
305
|
+
* the styled rows and which the inner `Text` re-resolves on every render.
|
|
306
|
+
* - `imageProtocol` — read by the formatter to decide whether rows carry
|
|
307
|
+
* sixel payload that must not be styled or split.
|
|
308
|
+
*
|
|
309
|
+
* A `styleLine` whose *captured* state changes without the pane hearing
|
|
310
|
+
* about it would break this. Callers must call
|
|
311
|
+
* {@link OutputPane.invalidate} when that happens.
|
|
312
|
+
*/
|
|
313
|
+
#renderDeps(): readonly unknown[] {
|
|
314
|
+
return [getWidthConfigEpoch(), getThemeEpoch(), TERMINAL.imageProtocol];
|
|
315
|
+
}
|
|
316
|
+
|
|
279
317
|
render(width: number): readonly string[] {
|
|
280
318
|
const paddingX = getPaddingX(this.#options.paddingX ?? 0);
|
|
281
319
|
const contentWidth = Math.max(1, width - paddingX * 2);
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
320
|
+
const content = this.#memo.get([...this.#renderDeps(), contentWidth], () => {
|
|
321
|
+
const formatted = formatOutputPaneLines(
|
|
322
|
+
{
|
|
323
|
+
...this.#options,
|
|
324
|
+
lines: this.#lines,
|
|
325
|
+
width: contentWidth,
|
|
326
|
+
},
|
|
327
|
+
this.#theme,
|
|
328
|
+
);
|
|
329
|
+
return `${this.#options.leadingBlank && formatted.lines.length > 0 ? "\n" : ""}${formatted.lines.join("\n")}`;
|
|
330
|
+
});
|
|
331
|
+
// The memo hands back the same string while its inputs hold, so the
|
|
332
|
+
// identity check is a pointer compare — no re-hash of the content.
|
|
333
|
+
if (content !== this.#renderContent) {
|
|
334
|
+
this.#renderContent = content;
|
|
294
335
|
this.#text.setText(content);
|
|
295
336
|
}
|
|
296
337
|
return this.#text.render(width);
|
|
297
338
|
}
|
|
298
339
|
|
|
299
340
|
invalidate(): void {
|
|
300
|
-
this.#
|
|
341
|
+
this.#renderContent = undefined;
|
|
301
342
|
this.#native = undefined;
|
|
343
|
+
this.#memo.clear();
|
|
302
344
|
this.#text.invalidate();
|
|
303
345
|
}
|
|
304
346
|
|
|
305
347
|
releaseRenderCaches(): void {
|
|
306
|
-
this.#
|
|
348
|
+
this.#renderContent = undefined;
|
|
349
|
+
this.#memo.clear();
|
|
307
350
|
this.#text.setText("");
|
|
308
351
|
this.#text.releaseRenderCaches();
|
|
309
352
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* tool renderers to ensure a unified TUI experience.
|
|
6
6
|
*/
|
|
7
7
|
import { ThinkingLevel } from "@linxiraos/pi-agent-core";
|
|
8
|
-
import
|
|
8
|
+
import { Ellipsis } from "@linxiraos/pi-natives";
|
|
9
9
|
import type { Theme } from "../theme/theme";
|
|
10
10
|
import type { Component } from "../tui";
|
|
11
11
|
export { Ellipsis } from "@linxiraos/pi-natives";
|
|
@@ -284,6 +284,12 @@ export declare function capParseErrors(errors: string[] | undefined, limit?: num
|
|
|
284
284
|
export declare function createCachedComponent(getExpanded: () => boolean, compute: (width: number, expanded: boolean) => string[], options?: {
|
|
285
285
|
paddingX?: number;
|
|
286
286
|
}): Component;
|
|
287
|
+
/**
|
|
288
|
+
* Fit a status header plus body rows to `width` for search-style results. The
|
|
289
|
+
* header soft-wraps so its trailing summary meta (counts, `truncated`) stays
|
|
290
|
+
* visible behind a long pattern; body rows keep single-row truncation.
|
|
291
|
+
*/
|
|
292
|
+
export declare function fitHeaderedRows(header: string, rows: readonly string[], width: number): string[];
|
|
287
293
|
/**
|
|
288
294
|
* Single-slot memo for an expensive rendered string (syntax highlighting, diff
|
|
289
295
|
* coloring) keyed by the exact inputs that shape the bytes: theme instance,
|
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
import * as os from "node:os";
|
|
9
9
|
import * as path from "node:path";
|
|
10
10
|
import { ThinkingLevel } from "@linxiraos/pi-agent-core";
|
|
11
|
-
import
|
|
11
|
+
import { Ellipsis } from "@linxiraos/pi-natives";
|
|
12
12
|
import { expandWindowsLongPath, getWindowsShortPath } from "@linxiraos/pi-natives/path";
|
|
13
13
|
import { pluralize, sanitizeText } from "@linxiraos/pi-utils";
|
|
14
14
|
import { formatKeyHint, type KeyId } from "../app-keybindings";
|
|
15
15
|
import { getKeybindings } from "../keybindings";
|
|
16
16
|
import type { Theme } from "../theme/theme";
|
|
17
17
|
import type { Component } from "../tui";
|
|
18
|
-
import { replaceTabs, sliceByColumn, truncateToWidth, visibleWidth } from "../utils";
|
|
18
|
+
import { replaceTabs, sliceByColumn, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "../utils";
|
|
19
19
|
import { Hasher } from "./utils";
|
|
20
20
|
|
|
21
21
|
export { Ellipsis } from "@linxiraos/pi-natives";
|
|
@@ -1148,6 +1148,15 @@ export function createCachedComponent(
|
|
|
1148
1148
|
};
|
|
1149
1149
|
}
|
|
1150
1150
|
|
|
1151
|
+
/**
|
|
1152
|
+
* Fit a status header plus body rows to `width` for search-style results. The
|
|
1153
|
+
* header soft-wraps so its trailing summary meta (counts, `truncated`) stays
|
|
1154
|
+
* visible behind a long pattern; body rows keep single-row truncation.
|
|
1155
|
+
*/
|
|
1156
|
+
export function fitHeaderedRows(header: string, rows: readonly string[], width: number): string[] {
|
|
1157
|
+
return [...wrapTextWithAnsi(header, width), ...rows.map(row => truncateToWidth(row, width, Ellipsis.Omit))];
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1151
1160
|
/**
|
|
1152
1161
|
* Single-slot memo for an expensive rendered string (syntax highlighting, diff
|
|
1153
1162
|
* coloring) keyed by the exact inputs that shape the bytes: theme instance,
|
|
@@ -67,6 +67,12 @@ class CopyablePromptInput implements Component, Focusable {
|
|
|
67
67
|
this.#input.handleInput(data);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
/** Enhanced-paste delivery targets the focused component's `pasteText`; without it the
|
|
71
|
+
* payload fell back to the detached main editor and never reached this field. */
|
|
72
|
+
pasteText(text: string): void {
|
|
73
|
+
this.#input.pasteText(text);
|
|
74
|
+
}
|
|
75
|
+
|
|
70
76
|
invalidate(): void {
|
|
71
77
|
this.#input.invalidate();
|
|
72
78
|
}
|
|
@@ -998,24 +998,26 @@ export class StatusLineComponent<TSession extends StatusLineSession = StatusLine
|
|
|
998
998
|
this.#invalidateStatusLineRenderCache();
|
|
999
999
|
}
|
|
1000
1000
|
|
|
1001
|
-
setRunningSubagents(agentIds: readonly string[]):
|
|
1001
|
+
setRunningSubagents(agentIds: readonly string[]): boolean {
|
|
1002
1002
|
if (
|
|
1003
1003
|
agentIds.length === this.#runningSubagentIds.size &&
|
|
1004
1004
|
agentIds.every(agentId => this.#runningSubagentIds.has(agentId))
|
|
1005
1005
|
) {
|
|
1006
|
-
return;
|
|
1006
|
+
return false;
|
|
1007
1007
|
}
|
|
1008
1008
|
this.#subagentCount = agentIds.length;
|
|
1009
1009
|
this.#runningSubagentIds = new Set(agentIds);
|
|
1010
1010
|
this.#invalidateStatusLineRenderCache();
|
|
1011
|
+
return true;
|
|
1011
1012
|
}
|
|
1012
1013
|
|
|
1013
1014
|
/** Host-computed spend of the main session's whole subagent tree (Agent Hub projection). */
|
|
1014
|
-
setSubagentTreeCost(cost: number):
|
|
1015
|
+
setSubagentTreeCost(cost: number): boolean {
|
|
1015
1016
|
const next = Number.isFinite(cost) && cost > 0 ? cost : 0;
|
|
1016
|
-
if (next === this.#subagentTreeCost) return;
|
|
1017
|
+
if (next === this.#subagentTreeCost) return false;
|
|
1017
1018
|
this.#subagentTreeCost = next;
|
|
1018
1019
|
this.#invalidateStatusLineRenderCache();
|
|
1020
|
+
return true;
|
|
1019
1021
|
}
|
|
1020
1022
|
|
|
1021
1023
|
/**
|