@linxiraos/pi-tui 1.4.11 → 1.4.13
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 +30 -233
- package/README.md +4 -1
- package/THIRD-PARTY-NOTICES.txt +4 -5
- package/dist/types/apps/shell-visualizer.d.ts +24 -0
- package/dist/types/autocomplete.d.ts +20 -0
- package/dist/types/chat/cache-invalidation-marker.d.ts +15 -7
- package/dist/types/chat/chat-transcript-builder.d.ts +5 -3
- package/dist/types/chat/display-preferences.d.ts +2 -0
- package/dist/types/chat/extension-types.d.ts +72 -1
- package/dist/types/chat/image-loading.d.ts +2 -2
- package/dist/types/chat/messages.d.ts +2 -3
- package/dist/types/chat/read-tool-group.d.ts +15 -2
- package/dist/types/chat/skill-message.d.ts +1 -0
- package/dist/types/chat/spotlight.d.ts +203 -0
- package/dist/types/chat/tool-execution.d.ts +26 -5
- package/dist/types/chat/transcript-actions.d.ts +11 -0
- package/dist/types/chat/transcript-browser.d.ts +9 -0
- package/dist/types/chat/transcript-presentation.d.ts +164 -0
- package/dist/types/chat/ttsr-notification.d.ts +2 -0
- package/dist/types/chrome/message-frame.d.ts +2 -0
- package/dist/types/chrome/transcript-container.d.ts +27 -6
- package/dist/types/components/loader.d.ts +0 -2
- package/dist/types/components/markdown.d.ts +11 -1
- package/dist/types/components/settings-list.d.ts +12 -2
- package/dist/types/frame-rate.d.ts +18 -0
- package/dist/types/hotkeys-markdown.d.ts +2 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/keybinding-matchers.d.ts +4 -1
- package/dist/types/kitty-graphics.d.ts +1 -1
- package/dist/types/motion-effects.d.ts +10 -0
- package/dist/types/native/encode.d.ts +2 -0
- package/dist/types/native/measure.d.ts +10 -0
- package/dist/types/native/overlay.d.ts +1 -1
- package/dist/types/native/quiet.d.ts +5 -0
- package/dist/types/native/reconcile.d.ts +6 -1
- package/dist/types/native/spans.d.ts +6 -0
- package/dist/types/native/state.d.ts +4 -0
- package/dist/types/overlays/agent-hub.d.ts +6 -0
- package/dist/types/overlays/link-browser.d.ts +55 -0
- package/dist/types/overlays/running-subagent-badge.d.ts +1 -4
- package/dist/types/overlays/spotlight-sheet.d.ts +36 -0
- package/dist/types/prompt/composer-attachments.d.ts +5 -2
- package/dist/types/prompt/composer-cache.d.ts +7 -2
- package/dist/types/prompt/composer.d.ts +6 -11
- package/dist/types/prompt/custom-editor.d.ts +8 -2
- package/dist/types/prompt/gradient-highlight.d.ts +2 -2
- package/dist/types/prompt/magic-keywords.d.ts +2 -0
- package/dist/types/prompt/model-mention-autocomplete.d.ts +9 -7
- package/dist/types/prompt/model-mention-syntax.d.ts +6 -0
- package/dist/types/prompt/prompt-action-autocomplete.d.ts +2 -1
- package/dist/types/prompt/welcome.d.ts +19 -0
- package/dist/types/render/extension-links.d.ts +0 -6
- package/dist/types/render/index.d.ts +1 -0
- package/dist/types/render/link-hints.d.ts +78 -0
- package/dist/types/render/render-utils.d.ts +0 -2
- package/dist/types/setup/scenes/types.d.ts +8 -0
- package/dist/types/setup/scenes/updates.d.ts +6 -0
- package/dist/types/setup/wizard.d.ts +7 -2
- package/dist/types/spinner-clock.d.ts +34 -0
- package/dist/types/status-line/component.d.ts +8 -4
- package/dist/types/status-line/host.d.ts +62 -0
- package/dist/types/status-line/index.d.ts +1 -0
- package/dist/types/status-line/prompt-cache.d.ts +14 -0
- package/dist/types/status-line/schema.d.ts +1 -1
- package/dist/types/status-line/startup.d.ts +6 -0
- package/dist/types/status-line/types.d.ts +8 -21
- package/dist/types/theme/schema.d.ts +28 -1
- package/dist/types/theme/symbols.d.ts +1 -1
- package/dist/types/theme/theme-class.d.ts +12 -2
- package/dist/types/theme/theme.d.ts +1 -1
- package/dist/types/theme/tui-adapters.d.ts +7 -0
- package/dist/types/thinking.d.ts +12 -0
- package/dist/types/tools/ask.d.ts +1 -1
- package/dist/types/tools/bash.d.ts +21 -0
- package/dist/types/tools/find.d.ts +9 -1
- package/dist/types/tools/grep.d.ts +2 -1
- package/dist/types/tools/grouped-file-output.d.ts +17 -0
- package/dist/types/tools/job-widget.d.ts +2 -2
- package/dist/types/tools/lsp.d.ts +4 -2
- package/dist/types/tools/native-view.d.ts +4 -0
- package/dist/types/tools/renderer.d.ts +9 -1
- package/dist/types/tools/shell-trace.d.ts +10 -0
- package/dist/types/tools/shell-viz-render.d.ts +6 -0
- package/dist/types/tools/shell-viz.d.ts +16 -0
- package/dist/types/tools/wait.d.ts +2 -2
- package/dist/types/tools/web-search-types.d.ts +1 -0
- package/dist/types/tools/write.d.ts +2 -0
- package/dist/types/tui.d.ts +15 -1
- package/package.json +15 -11
- package/src/apps/shell-visualizer.d.ts +24 -0
- package/src/apps/shell-visualizer.ts +167 -0
- package/src/autocomplete.d.ts +20 -0
- package/src/autocomplete.ts +14 -0
- package/src/chat/assistant-message.ts +11 -6
- package/src/chat/cache-invalidation-marker.d.ts +15 -7
- package/src/chat/cache-invalidation-marker.ts +18 -9
- package/src/chat/chat-transcript-builder.d.ts +5 -3
- package/src/chat/chat-transcript-builder.ts +16 -12
- package/src/chat/display-preferences.d.ts +2 -0
- package/src/chat/display-preferences.ts +3 -0
- package/src/chat/extension-types.d.ts +72 -1
- package/src/chat/extension-types.ts +74 -1
- package/src/chat/image-loading.d.ts +2 -2
- package/src/chat/image-loading.ts +2 -2
- package/src/chat/messages.d.ts +2 -3
- package/src/chat/messages.ts +3 -8
- package/src/chat/read-tool-group.d.ts +15 -2
- package/src/chat/read-tool-group.ts +201 -41
- package/src/chat/skill-message.d.ts +1 -0
- package/src/chat/skill-message.ts +4 -0
- package/src/chat/spotlight.d.ts +203 -0
- package/src/chat/spotlight.ts +460 -0
- package/src/chat/tool-execution.d.ts +26 -5
- package/src/chat/tool-execution.ts +360 -38
- package/src/chat/transcript-actions.d.ts +11 -0
- package/src/chat/transcript-actions.ts +13 -1
- package/src/chat/transcript-browser.d.ts +9 -0
- package/src/chat/transcript-browser.ts +18 -0
- package/src/chat/transcript-presentation.d.ts +164 -0
- package/src/chat/transcript-presentation.ts +642 -0
- package/src/chat/ttsr-notification.d.ts +25 -0
- package/src/chat/ttsr-notification.ts +5 -0
- package/src/chrome/message-frame.d.ts +2 -0
- package/src/chrome/message-frame.ts +7 -0
- package/src/chrome/message-notice.d.ts +58 -0
- package/src/chrome/transcript-container.d.ts +27 -6
- package/src/chrome/transcript-container.ts +317 -66
- package/src/components/editor.ts +25 -1
- package/src/components/loader.d.ts +0 -2
- package/src/components/loader.ts +30 -18
- package/src/components/markdown.d.ts +11 -1
- package/src/components/markdown.ts +41 -16
- package/src/components/settings-list.d.ts +12 -2
- package/src/components/settings-list.ts +29 -13
- package/src/frame-rate.d.ts +18 -0
- package/src/frame-rate.ts +36 -0
- package/src/hotkeys-markdown.ts +9 -2
- package/src/index.d.ts +3 -0
- package/src/index.ts +3 -0
- package/src/keybinding-matchers.d.ts +4 -1
- package/src/keybinding-matchers.ts +13 -12
- package/src/kitty-graphics.d.ts +1 -1
- package/src/kitty-graphics.ts +3 -2
- package/src/motion-effects.d.ts +10 -0
- package/src/motion-effects.ts +27 -0
- package/src/native/backend.ts +66 -7
- package/src/native/encode.d.ts +2 -0
- package/src/native/encode.ts +2 -0
- package/src/native/measure.d.ts +10 -0
- package/src/native/measure.ts +185 -0
- package/src/native/overlay.d.ts +1 -1
- package/src/native/overlay.ts +1 -1
- package/src/native/quiet.d.ts +5 -0
- package/src/native/quiet.ts +105 -0
- package/src/native/reconcile.d.ts +6 -1
- package/src/native/reconcile.ts +16 -10
- package/src/native/spans.d.ts +6 -0
- package/src/native/spans.ts +40 -0
- package/src/native/state.d.ts +4 -0
- package/src/native/state.ts +18 -0
- package/src/overlays/agent-hub.ts +15 -2
- package/src/overlays/ask-dialog.ts +1 -0
- package/src/overlays/btw-history-panel.ts +73 -6
- package/src/overlays/link-browser.ts +295 -0
- package/src/overlays/running-subagent-badge.ts +2 -9
- package/src/overlays/settings-defs.ts +1 -1
- package/src/overlays/settings-selector.ts +17 -3
- package/src/overlays/spotlight-sheet.ts +478 -0
- package/src/overlays/usage-dashboard.ts +6 -5
- package/src/prompt/composer-attachments.d.ts +5 -2
- package/src/prompt/composer-attachments.ts +6 -6
- package/src/prompt/composer-cache.ts +17 -16
- package/src/prompt/composer.ts +30 -123
- package/src/prompt/custom-editor.ts +17 -13
- package/src/prompt/gradient-highlight.d.ts +2 -2
- package/src/prompt/gradient-highlight.ts +5 -4
- package/src/prompt/magic-keywords.d.ts +2 -0
- package/src/prompt/magic-keywords.ts +4 -1
- package/src/prompt/model-mention-autocomplete.ts +73 -20
- package/src/prompt/model-mention-syntax.d.ts +6 -0
- package/src/prompt/model-mention-syntax.ts +9 -0
- package/src/prompt/prompt-action-autocomplete.ts +49 -33
- package/src/prompt/tips.txt +1 -0
- package/src/prompt/welcome.ts +104 -2
- package/src/render/extension-links.d.ts +0 -6
- package/src/render/extension-links.ts +0 -20
- package/src/render/index.d.ts +1 -0
- package/src/render/index.ts +1 -0
- package/src/render/link-hints.d.ts +78 -0
- package/src/render/link-hints.ts +299 -0
- package/src/render/render-utils.d.ts +0 -2
- package/src/render/render-utils.ts +0 -5
- package/src/setup/scenes/glyph.ts +1 -1
- package/src/setup/scenes/types.ts +8 -0
- package/src/setup/scenes/updates.ts +116 -0
- package/src/setup/wizard.ts +19 -8
- package/src/spinner-clock.d.ts +34 -0
- package/src/spinner-clock.ts +79 -0
- package/src/status-line/component.ts +145 -53
- package/src/status-line/host.ts +51 -0
- package/src/status-line/index.ts +1 -0
- package/src/status-line/presets.ts +3 -1
- package/src/status-line/prompt-cache.ts +154 -0
- package/src/status-line/schema.ts +1 -1
- package/src/status-line/segments.ts +33 -22
- package/src/status-line/startup.ts +22 -4
- package/src/status-line/types.ts +8 -22
- package/src/stdin-buffer.ts +89 -46
- package/src/terminal-capabilities.ts +3 -3
- package/src/terminal.ts +1 -8
- package/src/theme/loader.ts +3 -2
- package/src/theme/schema.d.ts +28 -1
- package/src/theme/schema.ts +30 -1
- package/src/theme/symbols.d.ts +1 -1
- package/src/theme/symbols.ts +15 -3
- package/src/theme/theme-class.d.ts +12 -2
- package/src/theme/theme-class.ts +23 -0
- package/src/theme/theme-schema.json +1 -1
- package/src/theme/theme.d.ts +1 -1
- package/src/theme/theme.ts +3 -7
- package/src/theme/tui-adapters.d.ts +7 -0
- package/src/theme/tui-adapters.ts +33 -1
- package/src/thinking.d.ts +12 -0
- package/src/thinking.ts +31 -0
- package/src/tools/ask.d.ts +1 -1
- package/src/tools/ask.ts +99 -38
- package/src/tools/ast-edit.ts +51 -32
- package/src/tools/ast-grep.ts +31 -19
- package/src/tools/bash.d.ts +21 -0
- package/src/tools/bash.ts +166 -24
- package/src/tools/find.d.ts +9 -1
- package/src/tools/find.ts +23 -2
- package/src/tools/grep.d.ts +2 -1
- package/src/tools/grep.ts +52 -36
- package/src/tools/grouped-file-output.d.ts +17 -0
- package/src/tools/grouped-file-output.ts +20 -2
- package/src/tools/job-widget.d.ts +2 -2
- package/src/tools/job-widget.ts +2 -2
- package/src/tools/lsp.d.ts +4 -2
- package/src/tools/lsp.ts +537 -642
- package/src/tools/native-view.d.ts +4 -0
- package/src/tools/native-view.ts +8 -2
- package/src/tools/renderer.d.ts +9 -1
- package/src/tools/renderer.ts +9 -1
- package/src/tools/shell-trace.d.ts +10 -0
- package/src/tools/shell-trace.ts +80 -0
- package/src/tools/shell-viz-render.d.ts +6 -0
- package/src/tools/shell-viz-render.ts +156 -0
- package/src/tools/shell-viz.d.ts +16 -0
- package/src/tools/shell-viz.ts +181 -0
- package/src/tools/streaming-output.ts +18 -8
- package/src/tools/wait.d.ts +2 -2
- package/src/tools/wait.ts +39 -34
- package/src/tools/web-search-types.d.ts +1 -0
- package/src/tools/web-search-types.ts +1 -0
- package/src/tools/write.d.ts +2 -0
- package/src/tools/write.ts +2 -0
- package/src/tui.d.ts +15 -1
- package/src/tui.ts +63 -6
- package/src/windows-input-mode.ts +7 -1
- package/dist/types/chat/collab-prompt-message.d.ts +0 -14
- package/dist/types/chrome/collab-qrcode.d.ts +0 -35
- package/src/chat/collab-prompt-message.d.ts +0 -14
- package/src/chat/collab-prompt-message.ts +0 -46
- package/src/chrome/collab-qrcode.ts +0 -99
package/src/native/state.d.ts
CHANGED
|
@@ -6,5 +6,9 @@ export declare function setNativeRendering(on: boolean): void;
|
|
|
6
6
|
export declare function nativeButtons(): boolean;
|
|
7
7
|
/** Called by the native backend when it adopts a `hello` reply and when it stops. */
|
|
8
8
|
export declare function setNativeButtons(on: boolean): void;
|
|
9
|
+
/** Whether a live surface's terminal paces streamed `md` (see {@link setNativePacing}). */
|
|
10
|
+
export declare function nativePacing(): boolean;
|
|
11
|
+
/** Called by the native backend when it adopts a `hello` reply and when it stops. */
|
|
12
|
+
export declare function setNativePacing(on: boolean): void;
|
|
9
13
|
/** Call `listener` whenever native rendering starts or stops; returns the unsubscribe. */
|
|
10
14
|
export declare function onNativeRenderingChange(listener: (on: boolean) => void): () => void;
|
package/src/native/state.ts
CHANGED
|
@@ -41,6 +41,24 @@ export function setNativeButtons(on: boolean): void {
|
|
|
41
41
|
buttons = on;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Whether the live terminal types streaming `md` out itself (its `hello`
|
|
46
|
+
* lists `pace`): omp then sends assistant text as it arrives instead of
|
|
47
|
+
* pacing it. Set only by the native backend from the `hello` it adopts;
|
|
48
|
+
* false while no surface is live.
|
|
49
|
+
*/
|
|
50
|
+
let pacing = false;
|
|
51
|
+
|
|
52
|
+
/** Whether a live surface's terminal paces streamed `md` (see {@link setNativePacing}). */
|
|
53
|
+
export function nativePacing(): boolean {
|
|
54
|
+
return active && pacing;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Called by the native backend when it adopts a `hello` reply and when it stops. */
|
|
58
|
+
export function setNativePacing(on: boolean): void {
|
|
59
|
+
pacing = on;
|
|
60
|
+
}
|
|
61
|
+
|
|
44
62
|
/** Call `listener` whenever native rendering starts or stops; returns the unsubscribe. */
|
|
45
63
|
export function onNativeRenderingChange(listener: (on: boolean) => void): () => void {
|
|
46
64
|
listeners.add(listener);
|
|
@@ -298,6 +298,12 @@ export interface AgentHubDeps<TRecord extends AgentRecordLike = AgentRecordLike>
|
|
|
298
298
|
requestRender: () => void;
|
|
299
299
|
/** Registry supplying the roster. */
|
|
300
300
|
registry: AgentHubRegistry<TRecord>;
|
|
301
|
+
/**
|
|
302
|
+
* Whether a registry ref belongs to the open session's tree. The host registry
|
|
303
|
+
* outlives `/new` and session switches, so earlier sessions' agents stay
|
|
304
|
+
* registered; absent, every ref is listed.
|
|
305
|
+
*/
|
|
306
|
+
inSession?: (ref: AgentRecordLike) => boolean;
|
|
301
307
|
/** Resolve lifecycle actions lazily when a local action needs them. */
|
|
302
308
|
lifecycle: () => AgentLifecycleLike<TRecord>;
|
|
303
309
|
/** Host message bus supplying unread counts. */
|
|
@@ -338,6 +344,7 @@ export class AgentHubOverlayComponent<TRecord extends AgentRecordLike = AgentRec
|
|
|
338
344
|
implements SelectListMouseTarget
|
|
339
345
|
{
|
|
340
346
|
#registry: AgentHubRegistry<TRecord>;
|
|
347
|
+
#inSession: ((ref: AgentRecordLike) => boolean) | undefined;
|
|
341
348
|
#observers: SessionObserverRegistry;
|
|
342
349
|
#getRoleInfo: ((role: string) => AgentRoleDisplay) | undefined;
|
|
343
350
|
#transcript: AgentTranscriptSource;
|
|
@@ -488,6 +495,7 @@ export class AgentHubOverlayComponent<TRecord extends AgentRecordLike = AgentRec
|
|
|
488
495
|
this.#activity = deps.activity;
|
|
489
496
|
this.#manageActivityLive = deps.manageActivityLive ?? true;
|
|
490
497
|
this.#registry = deps.registry;
|
|
498
|
+
this.#inSession = deps.inSession;
|
|
491
499
|
this.#observers = deps.observers;
|
|
492
500
|
this.#getRoleInfo = deps.getRoleInfo;
|
|
493
501
|
this.#transcript = deps.transcript;
|
|
@@ -928,7 +936,7 @@ export class AgentHubOverlayComponent<TRecord extends AgentRecordLike = AgentRec
|
|
|
928
936
|
columns: AGENT_COLUMNS,
|
|
929
937
|
items: this.#rows.map(ref => this.#pickerAgentItem(ref)),
|
|
930
938
|
selected: selected?.id ?? null,
|
|
931
|
-
total: this.#
|
|
939
|
+
total: this.#sessionRefs().length,
|
|
932
940
|
state: this.#rows.length === 0 && this.#loadingPersistedSubagents ? "loading" : "ready",
|
|
933
941
|
empty: "No agents in this session. Finished, parked and killed subagents stay with the session that created them.",
|
|
934
942
|
actions,
|
|
@@ -1556,9 +1564,14 @@ export class AgentHubOverlayComponent<TRecord extends AgentRecordLike = AgentRec
|
|
|
1556
1564
|
);
|
|
1557
1565
|
}
|
|
1558
1566
|
|
|
1567
|
+
/** Registry refs shown in this session's roster, excluding the main agent. */
|
|
1568
|
+
#sessionRefs(): TRecord[] {
|
|
1569
|
+
return this.#registry.list().filter(ref => ref.id !== MAIN_AGENT_ID && (this.#inSession?.(ref) ?? true));
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1559
1572
|
#refreshRows(): void {
|
|
1560
1573
|
const selectedId = this.#rows[this.#selectedRow]?.id;
|
|
1561
|
-
const refs = this.#
|
|
1574
|
+
const refs = this.#sessionRefs();
|
|
1562
1575
|
this.#observedById = new Map();
|
|
1563
1576
|
for (const session of this.#observers.getSessions()) this.#observedById.set(session.id, session);
|
|
1564
1577
|
const live = new Set(refs);
|
|
@@ -1575,6 +1575,7 @@ export class AskDialogComponent implements Component {
|
|
|
1575
1575
|
state.note = note.text;
|
|
1576
1576
|
state.noteImages = note.images;
|
|
1577
1577
|
state.noteRowKey = rowItem.key;
|
|
1578
|
+
this.#justAnswered = undefined;
|
|
1578
1579
|
} finally {
|
|
1579
1580
|
this.#promptActive = false;
|
|
1580
1581
|
this.#runDeferredTimeout();
|
|
@@ -25,6 +25,7 @@ import { BtwInjectAnswer, type BtwInjectState, describeBtwInjectAnswer } from ".
|
|
|
25
25
|
import { compactImageMarkers, formatVisionMarker } from "../prompt/composer-attachments";
|
|
26
26
|
import { extractImagePastePathsFromText } from "../prompt/custom-editor";
|
|
27
27
|
import { BracketedPasteHandler } from "../bracketed-paste";
|
|
28
|
+
import { routeSgrMouseInput, type SgrMouseEvent } from "../mouse";
|
|
28
29
|
import { getMarkdownTheme, type ThemeColor, theme } from "../theme/theme";
|
|
29
30
|
import {
|
|
30
31
|
matchesSelectCancel,
|
|
@@ -55,6 +56,11 @@ function getDisplayTurns(record: BtwHistoryRecord): readonly BtwHistoryTurn[] {
|
|
|
55
56
|
return record.title === undefined ? turns : [{ ...turns[0]!, question: record.title }, ...turns.slice(1)];
|
|
56
57
|
}
|
|
57
58
|
|
|
59
|
+
/** Whether two timestamps fall on the same calendar day in the local time zone. */
|
|
60
|
+
function isSameLocalDay(a: number | Date, b: number | Date): boolean {
|
|
61
|
+
return new Date(a).toDateString() === new Date(b).toDateString();
|
|
62
|
+
}
|
|
63
|
+
|
|
58
64
|
interface BtwHistoryPanelOptions {
|
|
59
65
|
records: readonly BtwHistoryRecord[];
|
|
60
66
|
onClose: () => void;
|
|
@@ -192,6 +198,9 @@ export class BtwHistoryPanel implements Component, Focusable {
|
|
|
192
198
|
#native: BtwHistoryNativeMemo | undefined;
|
|
193
199
|
/** The last answer-pane scroll key, forwarded natively (see {@link NativeNode.scroll}). */
|
|
194
200
|
#scroll: NativeScroll | undefined;
|
|
201
|
+
/** Frame rows above the body and whether the last frame split into two panes; the wheel hit-tests against them. */
|
|
202
|
+
#bodyTop = 0;
|
|
203
|
+
#wide = false;
|
|
195
204
|
readonly #detail = new ScrollView([], {
|
|
196
205
|
height: 1,
|
|
197
206
|
scrollbar: "auto",
|
|
@@ -238,6 +247,15 @@ export class BtwHistoryPanel implements Component, Focusable {
|
|
|
238
247
|
minute: "2-digit",
|
|
239
248
|
hourCycle: "h23",
|
|
240
249
|
});
|
|
250
|
+
readonly #dayFormat = new Intl.DateTimeFormat("en", { month: "short", day: "numeric" });
|
|
251
|
+
readonly #yearDayFormat = new Intl.DateTimeFormat("en", { month: "short", day: "numeric", year: "numeric" });
|
|
252
|
+
|
|
253
|
+
/** A history row's stamp: the time for a question asked today, its date (and year, if not this one) before. */
|
|
254
|
+
#listStamp(timestamp: number, now: Date): string {
|
|
255
|
+
const date = new Date(timestamp);
|
|
256
|
+
if (isSameLocalDay(date, now)) return this.#timeFormat.format(date);
|
|
257
|
+
return (date.getFullYear() === now.getFullYear() ? this.#dayFormat : this.#yearDayFormat).format(date);
|
|
258
|
+
}
|
|
241
259
|
|
|
242
260
|
constructor(options: BtwHistoryPanelOptions) {
|
|
243
261
|
this.#options = options;
|
|
@@ -506,6 +524,10 @@ export class BtwHistoryPanel implements Component, Focusable {
|
|
|
506
524
|
}
|
|
507
525
|
|
|
508
526
|
handleInput(data: string): void {
|
|
527
|
+
// SGR reports arrive as input while this page holds focus; without this
|
|
528
|
+
// branch the wheel moved nothing here, although the other scrolling
|
|
529
|
+
// sheets follow it (and the composer would have typed the bytes).
|
|
530
|
+
if (routeSgrMouseInput(data, event => this.#routeWheel(event))) return;
|
|
509
531
|
if (this.#composer) {
|
|
510
532
|
const paste = this.#pasteHandler.process(data);
|
|
511
533
|
if (paste.handled) {
|
|
@@ -598,6 +620,32 @@ export class BtwHistoryPanel implements Component, Focusable {
|
|
|
598
620
|
return true;
|
|
599
621
|
}
|
|
600
622
|
|
|
623
|
+
/**
|
|
624
|
+
* A wheel notch over the body follows the pointer: over the history list it
|
|
625
|
+
* moves the selection, over the reader it scrolls the answer three rows.
|
|
626
|
+
* A narrow frame shows one pane, so the wheel follows that one. The pane
|
|
627
|
+
* split decides by column because both panes share the body rows.
|
|
628
|
+
*/
|
|
629
|
+
#routeWheel(event: SgrMouseEvent): boolean {
|
|
630
|
+
if (event.wheel === null) return false;
|
|
631
|
+
const line = event.row - this.#bodyTop;
|
|
632
|
+
// A notch on the frame chrome or the rows below the body (navigation,
|
|
633
|
+
// actions, composer) belongs to no pane, in either layout.
|
|
634
|
+
if (line < 0 || line >= this.#bodyHeightLast) return false;
|
|
635
|
+
const overList = this.#wide ? this.#split.locate(line, event.col)?.pane === "left" : this.#focus === "list";
|
|
636
|
+
if (overList) {
|
|
637
|
+
// A follow-up composer holds the record it was opened for; moving the
|
|
638
|
+
// selection would show one topic while Enter submits to another.
|
|
639
|
+
if (this.#composer) return true;
|
|
640
|
+
this.#select(this.#selectedIndex() + event.wheel);
|
|
641
|
+
} else {
|
|
642
|
+
this.#detail.scroll(event.wheel * 3);
|
|
643
|
+
this.#followLatest = false;
|
|
644
|
+
}
|
|
645
|
+
this.#options.requestRender();
|
|
646
|
+
return true;
|
|
647
|
+
}
|
|
648
|
+
|
|
601
649
|
/** A large glass sheet (the list beside the reader), palette-sized while there is nothing to list. */
|
|
602
650
|
get nativeOverlay(): NonNullable<Component["nativeOverlay"]> {
|
|
603
651
|
return this.#records.length > 0 ? SHEET : EMPTY_SHEET;
|
|
@@ -716,9 +764,10 @@ export class BtwHistoryPanel implements Component, Focusable {
|
|
|
716
764
|
* reader has the keys the selection rests (`zeta.btw.list.idle`).
|
|
717
765
|
*/
|
|
718
766
|
#describeList(): NativeNode {
|
|
767
|
+
const now = new Date();
|
|
719
768
|
const items = this.#records.map(record => {
|
|
720
769
|
const followUps = record.followUps?.length ?? 0;
|
|
721
|
-
const detail: TspSpan[] = [span(this.#
|
|
770
|
+
const detail: TspSpan[] = [span(this.#listStamp(record.createdAt, now), "mono")];
|
|
722
771
|
if (followUps > 0) detail.push(span(` · ${followUps} follow-up${followUps === 1 ? "" : "s"}`));
|
|
723
772
|
const status = describeStatus(getBtwLatestTurn(record).status);
|
|
724
773
|
// The question is markdown: its `code` reads as mono, without the backticks.
|
|
@@ -740,7 +789,7 @@ export class BtwHistoryPanel implements Component, Focusable {
|
|
|
740
789
|
#describeThread(record: BtwHistoryRecord): NativeNode {
|
|
741
790
|
const turns = getDisplayTurns(record);
|
|
742
791
|
const children: NativeChild[] = turns.map((turn, index) =>
|
|
743
|
-
this.#describeTurn(turn, index, `turn-${index}`, this.#injectBlock(record, turn, index)),
|
|
792
|
+
this.#describeTurn(turn, index, `turn-${index}`, this.#injectBlock(record, turn, index), record.createdAt),
|
|
744
793
|
);
|
|
745
794
|
if (this.#composer) children.push(this.#describeComposer(this.#composer));
|
|
746
795
|
return node("col", { role: "zeta.btw.thread" }, children, "thread");
|
|
@@ -763,11 +812,25 @@ export class BtwHistoryPanel implements Component, Focusable {
|
|
|
763
812
|
return state && { parts, state };
|
|
764
813
|
}
|
|
765
814
|
|
|
766
|
-
#describeTurn(
|
|
815
|
+
#describeTurn(
|
|
816
|
+
turn: BtwHistoryTurn,
|
|
817
|
+
index: number,
|
|
818
|
+
key: string,
|
|
819
|
+
block: InjectBlock | undefined,
|
|
820
|
+
topicCreatedAt: number,
|
|
821
|
+
): NativeNode {
|
|
822
|
+
// A follow-up asked on the topic's day needs only its time; a later one needs its date too.
|
|
767
823
|
const meta: TspSpan[] =
|
|
768
824
|
index === 0
|
|
769
825
|
? [span(this.#dateFormat.format(turn.createdAt))]
|
|
770
|
-
: [
|
|
826
|
+
: [
|
|
827
|
+
span("Follow-up · "),
|
|
828
|
+
span(
|
|
829
|
+
(isSameLocalDay(turn.createdAt, topicCreatedAt) ? this.#timeFormat : this.#dateFormat).format(
|
|
830
|
+
turn.createdAt,
|
|
831
|
+
),
|
|
832
|
+
),
|
|
833
|
+
];
|
|
771
834
|
const status = describeStatus(turn.status);
|
|
772
835
|
if (status) meta.push(span(" · "), ...status);
|
|
773
836
|
// The question stays markdown so its inline code and links render.
|
|
@@ -875,6 +938,7 @@ export class BtwHistoryPanel implements Component, Focusable {
|
|
|
875
938
|
this.#listScroll = Math.min(selection.scrollOffset, Math.max(0, this.#records.length - this.#listHeight));
|
|
876
939
|
const contentWidth = contentRowWidth(width, this.#records.length * rowSpan, height);
|
|
877
940
|
const lines: string[] = [];
|
|
941
|
+
const now = new Date();
|
|
878
942
|
for (
|
|
879
943
|
let index = this.#listScroll;
|
|
880
944
|
index < Math.min(this.#records.length, this.#listScroll + this.#listHeight);
|
|
@@ -884,7 +948,7 @@ export class BtwHistoryPanel implements Component, Focusable {
|
|
|
884
948
|
const selected = index === selectedIndex;
|
|
885
949
|
const status = STATUS[getBtwLatestTurn(record).status];
|
|
886
950
|
const cursor = selected ? theme.fg(this.#focus === "list" ? "accent" : "muted", theme.nav.cursor) : " ";
|
|
887
|
-
const time = theme.fg("dim", this.#
|
|
951
|
+
const time = theme.fg("dim", this.#listStamp(record.createdAt, now));
|
|
888
952
|
const badge = theme.fg(status.color, status.label);
|
|
889
953
|
const prefix = `${cursor} ${time} ${badge} `;
|
|
890
954
|
const question = sanitizeDisplayLine(getBtwTopicLabel(record));
|
|
@@ -1104,6 +1168,10 @@ export class BtwHistoryPanel implements Component, Focusable {
|
|
|
1104
1168
|
this.#detail.scrollToBottom();
|
|
1105
1169
|
detail = this.#detail.render(detailWidth);
|
|
1106
1170
|
}
|
|
1171
|
+
// Wheel hit-testing reads the geometry of the frame it already shows.
|
|
1172
|
+
this.#bodyTop = framed ? 2 : height >= 3 ? 1 : 0;
|
|
1173
|
+
this.#wide = wide;
|
|
1174
|
+
this.#bodyHeightLast = bodyHeight;
|
|
1107
1175
|
const lines: string[] = [];
|
|
1108
1176
|
if (framed) {
|
|
1109
1177
|
lines.push(topBorder(width, "BTW history"));
|
|
@@ -1112,7 +1180,6 @@ export class BtwHistoryPanel implements Component, Focusable {
|
|
|
1112
1180
|
lines.push(truncateToWidth(this.#focusLabel(this.#focus), width));
|
|
1113
1181
|
}
|
|
1114
1182
|
if (framed) {
|
|
1115
|
-
this.#bodyHeightLast = bodyHeight;
|
|
1116
1183
|
this.#detailCache = detail ?? [];
|
|
1117
1184
|
this.#listCache = wide || this.#focus === "list" ? this.#renderList(listWidth, bodyHeight) : [];
|
|
1118
1185
|
this.#split.setHeight(bodyHeight);
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fullscreen extension link browser: the transcript replayed on the alternate screen, so links
|
|
3
|
+
* that have scrolled into terminal scrollback (which omp cannot draw over) can be picked too.
|
|
4
|
+
*
|
|
5
|
+
* Each extension link label ({@link extensionLinkLabels}) on the rows in view gets a hint tag that
|
|
6
|
+
* it keeps while it stays in view (see {@link LinkHints.update}); typing a whole tag, or a left click on
|
|
7
|
+
* a label, picks its link. Arrows, Page Up/Down, Home/End and the wheel scroll; Esc closes; other
|
|
8
|
+
* keys do nothing. The browser stays open after a pick, so an extension redrawing the reply
|
|
9
|
+
* ({@link LinkBrowserComponent.rerenderMessage}) is seen in place.
|
|
10
|
+
*
|
|
11
|
+
* The transcript is a snapshot taken when the browser opens: a reply still streaming shows as far
|
|
12
|
+
* as it had come. Like `/copy`, it replays the recent part of a long branch first, and the rest
|
|
13
|
+
* once the view scrolls to its top.
|
|
14
|
+
*/
|
|
15
|
+
import type { AgentTool } from "@linxiraos/pi-agent-core";
|
|
16
|
+
import { AssistantMessageComponent } from "../chat/assistant-message";
|
|
17
|
+
import { ChatTranscriptBuilder } from "../chat/chat-transcript-builder";
|
|
18
|
+
import type { AssistantTextRenderer, MessageRenderer } from "../chat/extension-types";
|
|
19
|
+
import { TranscriptBrowser, type TranscriptBrowserFrame } from "../chat/transcript-browser";
|
|
20
|
+
import { recentTranscriptEntries, type TranscriptEntryLike as TranscriptEntry } from "../chat/transcript-entry";
|
|
21
|
+
import { composeOutlineColumn } from "../chat/transcript-outline";
|
|
22
|
+
import { matchesSelectCancel } from "../keybinding-matchers";
|
|
23
|
+
import { matchesKey, parseKey } from "../keys";
|
|
24
|
+
import { routeSgrMouseInput } from "../mouse";
|
|
25
|
+
import { extensionLinkLabels } from "../render/extension-links";
|
|
26
|
+
import { LinkHints } from "../render/link-hints";
|
|
27
|
+
import { theme } from "../theme/theme";
|
|
28
|
+
import { sliceByColumn } from "../utils";
|
|
29
|
+
import type { Component, TUI } from "../tui";
|
|
30
|
+
|
|
31
|
+
export interface LinkBrowserDeps {
|
|
32
|
+
ui: TUI;
|
|
33
|
+
getTool?: (name: string) => AgentTool | undefined;
|
|
34
|
+
/** Whether the active registry entry came from a built-in factory. */
|
|
35
|
+
isBuiltInTool?: (name: string) => boolean;
|
|
36
|
+
getMessageRenderer?: (customType: string) => MessageRenderer | undefined;
|
|
37
|
+
cwd: string;
|
|
38
|
+
hideThinkingBlock?: () => boolean;
|
|
39
|
+
proseOnlyThinking?: () => boolean;
|
|
40
|
+
expandThinkingBlocks?: () => boolean;
|
|
41
|
+
linkTargets?: ReadonlyMap<string, string>;
|
|
42
|
+
/** The extension assistant text renderers the transcript draws with, which may write the links. */
|
|
43
|
+
textRenderers: readonly AssistantTextRenderer[];
|
|
44
|
+
requestRender: () => void;
|
|
45
|
+
/** A link was picked: raise `link_activate` for `url`. */
|
|
46
|
+
onActivate: (url: string) => void;
|
|
47
|
+
onClose: () => void;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export class LinkBrowserComponent implements Component {
|
|
51
|
+
readonly #deps: LinkBrowserDeps;
|
|
52
|
+
#builder: ChatTranscriptBuilder;
|
|
53
|
+
readonly #browser: TranscriptBrowser;
|
|
54
|
+
readonly #hints = new LinkHints();
|
|
55
|
+
/** The last frame without tags: what a click is traced back through. */
|
|
56
|
+
#frame: readonly string[] = [];
|
|
57
|
+
/** Some row in view has more links than their tags could fit side by side, so none are drawn. */
|
|
58
|
+
#crowded = false;
|
|
59
|
+
/** Opens at the bottom; afterwards the scroll offset only moves on the user's request. */
|
|
60
|
+
#scrollToEnd = true;
|
|
61
|
+
/** The whole branch: only its recent part is replayed until the view reaches the top. */
|
|
62
|
+
readonly #entries: TranscriptEntry[];
|
|
63
|
+
/** Older entries are still unreplayed. */
|
|
64
|
+
#truncated: boolean;
|
|
65
|
+
/** Transcript components the older history added above the ones replayed first. */
|
|
66
|
+
#olderChildren = 0;
|
|
67
|
+
/**
|
|
68
|
+
* The rows those components take at the last layout. Hint tags key a label by its content row
|
|
69
|
+
* less these, so a label keeps its tag when history loads above it, and when a resize or a
|
|
70
|
+
* redraw changes only the older rows' height.
|
|
71
|
+
*/
|
|
72
|
+
#prependedRows = 0;
|
|
73
|
+
/** Frame width of the last render, which a history load lays out at; 0 before the first. */
|
|
74
|
+
#width = 0;
|
|
75
|
+
/**
|
|
76
|
+
* Body rows held after a reply was redrawn, blank below the transcript if it shrank, so the
|
|
77
|
+
* scroll offset is not clamped and the rows above it stay put; dropped once the user scrolls or
|
|
78
|
+
* the body reaches it.
|
|
79
|
+
*/
|
|
80
|
+
#rowFloor = 0;
|
|
81
|
+
|
|
82
|
+
constructor(entries: TranscriptEntry[], deps: LinkBrowserDeps) {
|
|
83
|
+
this.#deps = deps;
|
|
84
|
+
this.#entries = entries;
|
|
85
|
+
const recent = recentTranscriptEntries(entries);
|
|
86
|
+
this.#truncated = recent.length < entries.length;
|
|
87
|
+
this.#builder = this.#replay(recent);
|
|
88
|
+
// Not following the tail: a reply redrawn taller grows in place below the rows in view.
|
|
89
|
+
this.#browser = new TranscriptBrowser({
|
|
90
|
+
getHeight: () => deps.ui.terminal?.rows || process.stdout.rows || 40,
|
|
91
|
+
frame: context => this.#compose(context.contentWidth),
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Whether the transcript draws any extension link at frame width `width`. The recent part is
|
|
97
|
+
* checked first; the whole branch is replayed only when that part has none.
|
|
98
|
+
*/
|
|
99
|
+
hasLinks(width: number): boolean {
|
|
100
|
+
const contentWidth = Math.max(1, width - 1);
|
|
101
|
+
const drawsLink = () => this.#body(contentWidth).some(row => extensionLinkLabels(row).length > 0);
|
|
102
|
+
return drawsLink() || (this.#loadOlder() && drawsLink());
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Redraw the browser's copy of the reply sent at `timestamp`, re-running the text renderers;
|
|
107
|
+
* returns whether it holds one. The rows above it stay where they are on screen, and the links
|
|
108
|
+
* below it keep their tags on the rows they move to.
|
|
109
|
+
*/
|
|
110
|
+
rerenderMessage(timestamp: number): boolean {
|
|
111
|
+
const children = this.#builder.container.children;
|
|
112
|
+
const contentWidth = Math.max(1, this.#width - 1);
|
|
113
|
+
const heights = () => this.#browser.renderOutlineRows(children, contentWidth).map(rows => rows.length);
|
|
114
|
+
const before = this.#width > 0 ? heights() : undefined;
|
|
115
|
+
let redrawn = false;
|
|
116
|
+
for (const child of children) {
|
|
117
|
+
if (child instanceof AssistantMessageComponent && child.rerenderMessage(timestamp)) redrawn = true;
|
|
118
|
+
}
|
|
119
|
+
if (!redrawn) return false;
|
|
120
|
+
if (before) {
|
|
121
|
+
// The body row each resized reply ended on, and how far the rows from there on moved.
|
|
122
|
+
const after = heights();
|
|
123
|
+
const moves: { end: number; by: number }[] = [];
|
|
124
|
+
let end = 0;
|
|
125
|
+
let by = 0;
|
|
126
|
+
for (const [index, height] of after.entries()) {
|
|
127
|
+
end += before[index]!;
|
|
128
|
+
if (height === before[index]) continue;
|
|
129
|
+
by += height - before[index]!;
|
|
130
|
+
moves.push({ end, by });
|
|
131
|
+
}
|
|
132
|
+
// Tags key a label by its body row less the older history's rows, which the redraw may
|
|
133
|
+
// have changed too.
|
|
134
|
+
const prepended = this.#prependedRows;
|
|
135
|
+
this.#prependedRows = this.#olderRows(after);
|
|
136
|
+
const shift = prepended - this.#prependedRows;
|
|
137
|
+
this.#hints.moveRows(row => row + shift + (moves.findLast(move => row + prepended >= move.end)?.by ?? 0));
|
|
138
|
+
}
|
|
139
|
+
this.#rowFloor = this.#browser.visibleEnd;
|
|
140
|
+
this.#deps.requestRender();
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
invalidate(): void {
|
|
145
|
+
this.#builder.container.invalidate();
|
|
146
|
+
this.#browser.invalidate();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
dispose(): void {
|
|
150
|
+
this.#builder.dispose();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
handleInput(data: string): void {
|
|
154
|
+
if (data.startsWith("\x1b[<")) {
|
|
155
|
+
routeSgrMouseInput(data, event => {
|
|
156
|
+
if (event.wheel !== null) {
|
|
157
|
+
// Dropping the floor lets the offset settle within the transcript: draw that too.
|
|
158
|
+
const moved = this.#browser.scroll(event.wheel * 3) || this.#rowFloor > 0;
|
|
159
|
+
this.#rowFloor = 0;
|
|
160
|
+
if (this.#loadOlderAtTop() || moved) this.#deps.requestRender();
|
|
161
|
+
} else if (event.leftClick) {
|
|
162
|
+
const url = extensionLinkLabels(this.#frame[event.row] ?? "").find(
|
|
163
|
+
label => event.col >= label.start && event.col < label.end,
|
|
164
|
+
)?.url;
|
|
165
|
+
if (url !== undefined) this.#deps.onActivate(url);
|
|
166
|
+
}
|
|
167
|
+
return true;
|
|
168
|
+
});
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (matchesKey(data, "escape") || matchesSelectCancel(data)) {
|
|
172
|
+
this.#deps.onClose();
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (this.#browser.handleScrollKey(data)) {
|
|
176
|
+
this.#rowFloor = 0;
|
|
177
|
+
// Loading older history keeps the rows in view in place; Home still means the very top.
|
|
178
|
+
if (this.#loadOlderAtTop() && matchesKey(data, "home")) this.#browser.scrollToTop();
|
|
179
|
+
this.#deps.requestRender();
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const key = parseKey(data);
|
|
183
|
+
if (this.#crowded || key === undefined || !/^[a-z]$/.test(key)) return;
|
|
184
|
+
const picked = this.#hints.type(key);
|
|
185
|
+
if (typeof picked === "object") this.#deps.onActivate(picked.url);
|
|
186
|
+
this.#deps.requestRender();
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
render(width: number): readonly string[] {
|
|
190
|
+
// A resize rewraps every row, so the rows above a redrawn reply cannot stay put anyway.
|
|
191
|
+
if (width !== this.#width) this.#rowFloor = 0;
|
|
192
|
+
this.#width = width;
|
|
193
|
+
if (this.#scrollToEnd) {
|
|
194
|
+
this.#scrollToEnd = false;
|
|
195
|
+
this.#browser.render(width);
|
|
196
|
+
this.#browser.scrollToBottom();
|
|
197
|
+
}
|
|
198
|
+
const contentWidth = Math.max(1, width - 1);
|
|
199
|
+
let frame = this.#browser.render(width);
|
|
200
|
+
// Without the scrollbar column: a label wrapped at the row's end must end its row to be
|
|
201
|
+
// read as one link with its continuation below. Drawing the frame measured the older
|
|
202
|
+
// history's rows at this width (see #body).
|
|
203
|
+
this.#hints.update(
|
|
204
|
+
frame.map(row => sliceByColumn(row, 0, contentWidth)),
|
|
205
|
+
this.#browser.frameRowOffset - this.#prependedRows,
|
|
206
|
+
);
|
|
207
|
+
const crowded = this.#hints.crowded(contentWidth);
|
|
208
|
+
if (crowded !== this.#crowded) {
|
|
209
|
+
// The footer says why no tags are drawn; it takes the same row, so the labels stay put.
|
|
210
|
+
this.#crowded = crowded;
|
|
211
|
+
frame = this.#browser.render(width);
|
|
212
|
+
}
|
|
213
|
+
this.#frame = frame;
|
|
214
|
+
// The last column is the scrollbar's: tags stay left of it.
|
|
215
|
+
return crowded ? frame : this.#hints.paint(frame, contentWidth);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
#replay(entries: TranscriptEntry[]): ChatTranscriptBuilder {
|
|
219
|
+
const builder = new ChatTranscriptBuilder({
|
|
220
|
+
ui: this.#deps.ui,
|
|
221
|
+
getTool: this.#deps.getTool,
|
|
222
|
+
isBuiltInTool: this.#deps.isBuiltInTool,
|
|
223
|
+
getMessageRenderer: this.#deps.getMessageRenderer,
|
|
224
|
+
cwd: this.#deps.cwd,
|
|
225
|
+
hideThinkingBlock: this.#deps.hideThinkingBlock,
|
|
226
|
+
proseOnlyThinking: this.#deps.proseOnlyThinking,
|
|
227
|
+
expandThinkingBlocks: this.#deps.expandThinkingBlocks,
|
|
228
|
+
linkTargets: this.#deps.linkTargets,
|
|
229
|
+
textRenderers: this.#deps.textRenderers,
|
|
230
|
+
requestRender: this.#deps.requestRender,
|
|
231
|
+
});
|
|
232
|
+
builder.rebuild(entries);
|
|
233
|
+
return builder;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/** Replay the older history once the view has scrolled to the top of what is replayed. */
|
|
237
|
+
#loadOlderAtTop(): boolean {
|
|
238
|
+
return this.#browser.atTop && this.#loadOlder();
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Replay the whole branch, keeping the rows in view where they are on screen; returns whether
|
|
243
|
+
* there was older history to load. Pays the full replay once, only when it is needed.
|
|
244
|
+
*/
|
|
245
|
+
#loadOlder(): boolean {
|
|
246
|
+
if (!this.#truncated) return false;
|
|
247
|
+
const contentWidth = Math.max(1, this.#width - 1);
|
|
248
|
+
const before = this.#width > 0 ? this.#body(contentWidth).length : 0;
|
|
249
|
+
const previous = this.#builder;
|
|
250
|
+
this.#builder = this.#replay(this.#entries);
|
|
251
|
+
this.#olderChildren = this.#builder.container.children.length - previous.container.children.length;
|
|
252
|
+
previous.dispose();
|
|
253
|
+
this.#truncated = false;
|
|
254
|
+
this.#browser.invalidate();
|
|
255
|
+
if (this.#width === 0) return true;
|
|
256
|
+
const added = this.#body(contentWidth).length - before;
|
|
257
|
+
this.#browser.render(this.#width);
|
|
258
|
+
this.#browser.scroll(added);
|
|
259
|
+
return true;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** The body rows the older history's components take, given every component's `heights`. */
|
|
263
|
+
#olderRows(heights: readonly number[]): number {
|
|
264
|
+
let total = 0;
|
|
265
|
+
for (let index = 0; index < this.#olderChildren; index++) total += heights[index]!;
|
|
266
|
+
return total;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* The whole transcript's rows at `contentWidth`, indented as the other transcript browsers draw
|
|
271
|
+
* it. Also measures the older history's rows, so a frame pays one pass over the transcript.
|
|
272
|
+
*/
|
|
273
|
+
#body(contentWidth: number): string[] {
|
|
274
|
+
const children = this.#builder.container.children;
|
|
275
|
+
const rows = this.#browser.renderOutlineRows(children, contentWidth);
|
|
276
|
+
this.#prependedRows = this.#olderRows(rows.map(child => child.length));
|
|
277
|
+
return composeOutlineColumn(rows, 0, children.length, [], -1, contentWidth, undefined).lines;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
#compose(contentWidth: number): TranscriptBrowserFrame {
|
|
281
|
+
const hint = this.#crowded
|
|
282
|
+
? theme.fg("warning", "Too many links on one row to tag; widen the terminal · PgUp/PgDn scroll · Esc close")
|
|
283
|
+
: theme.fg("dim", "Type a tag or click a link · PgUp/PgDn scroll · Esc close");
|
|
284
|
+
const body = this.#body(contentWidth);
|
|
285
|
+
if (body.length >= this.#rowFloor) this.#rowFloor = 0;
|
|
286
|
+
else body.push(...Array<string>(this.#rowFloor - body.length).fill(""));
|
|
287
|
+
return {
|
|
288
|
+
header: [
|
|
289
|
+
`${theme.bold("Extension links")}${theme.sep.dot}${theme.fg("dim", "pick one anywhere in the transcript")}`,
|
|
290
|
+
],
|
|
291
|
+
body: { lines: body },
|
|
292
|
+
footer: [hint],
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
}
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import { type AgentHubRegistry, MAIN_AGENT_ID } from "./agent-hub-types";
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function getRunningSubagentBadgeRegistry<T extends AgentHubRegistry>(
|
|
8
|
-
collabGuest: RunningSubagentRegistrySource<T> | undefined,
|
|
9
|
-
localRegistry: T,
|
|
10
|
-
): T {
|
|
11
|
-
return collabGuest?.agentRegistry ?? localRegistry;
|
|
3
|
+
export function getRunningSubagentBadgeRegistry<T extends AgentHubRegistry>(localRegistry: T): T {
|
|
4
|
+
return localRegistry;
|
|
12
5
|
}
|
|
13
6
|
|
|
14
7
|
export function getRunningSubagentBadgeAgentIds(registry: AgentHubRegistry): string[] {
|
|
@@ -183,6 +183,11 @@ function createSettingsTextField(
|
|
|
183
183
|
});
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
+
/** An enum setting's values as choices, each labelled by its value. */
|
|
187
|
+
function enumOptions(def: SettingDef & { type: "enum" }): SelectItem[] {
|
|
188
|
+
return def.values.map(value => ({ value, label: value }));
|
|
189
|
+
}
|
|
190
|
+
|
|
186
191
|
/**
|
|
187
192
|
* Single-choice setting field backed by the shared select form field.
|
|
188
193
|
* Preserves the current selection, live async previews, footer previews,
|
|
@@ -981,7 +986,7 @@ export class SettingsSelectorComponent implements Component {
|
|
|
981
986
|
case "boolean":
|
|
982
987
|
return { k: "switch", on: value === true };
|
|
983
988
|
case "enum":
|
|
984
|
-
return { k: "choice", value: shown, options: def
|
|
989
|
+
return { k: "choice", value: shown, options: enumOptions(def) };
|
|
985
990
|
case "submenu": {
|
|
986
991
|
const labels = numberSteps(def);
|
|
987
992
|
if (labels) {
|
|
@@ -1156,7 +1161,10 @@ export class SettingsSelectorComponent implements Component {
|
|
|
1156
1161
|
if (typeof value === "boolean") list.applyValue(id, String(value));
|
|
1157
1162
|
return;
|
|
1158
1163
|
case "enum":
|
|
1159
|
-
if (typeof value
|
|
1164
|
+
if (typeof value !== "string") return;
|
|
1165
|
+
// A pick from the row's open menu closes it.
|
|
1166
|
+
if (list.openSubmenu?.id === id) list.handleInput(ESCAPE);
|
|
1167
|
+
list.applyValue(id, value);
|
|
1160
1168
|
return;
|
|
1161
1169
|
case "submenu": {
|
|
1162
1170
|
const choice =
|
|
@@ -1583,7 +1591,13 @@ export class SettingsSelectorComponent implements Component {
|
|
|
1583
1591
|
return { ...item, currentValue: currentValue ? "true" : "false", values: ["true", "false"] };
|
|
1584
1592
|
|
|
1585
1593
|
case "enum":
|
|
1586
|
-
return {
|
|
1594
|
+
return {
|
|
1595
|
+
...item,
|
|
1596
|
+
currentValue: String(currentValue ?? ""),
|
|
1597
|
+
values: [...def.values],
|
|
1598
|
+
menu: (cv, done) =>
|
|
1599
|
+
createSettingsSelectField(def.label, def.description, enumOptions(def), cv, done, () => done()),
|
|
1600
|
+
};
|
|
1587
1601
|
|
|
1588
1602
|
case "submenu":
|
|
1589
1603
|
return {
|