@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
|
@@ -51,6 +51,8 @@ export interface ExtensionAskDialogResultItem {
|
|
|
51
51
|
customInputImages?: ImageContent[];
|
|
52
52
|
note?: string;
|
|
53
53
|
noteImages?: ImageContent[];
|
|
54
|
+
/** Label of the option the note is on; unset when it is on the custom answer. */
|
|
55
|
+
noteOption?: string;
|
|
54
56
|
timedOut?: boolean;
|
|
55
57
|
}
|
|
56
58
|
|
|
@@ -145,14 +147,21 @@ interface AskDialogCallbacks {
|
|
|
145
147
|
): Promise<AskDialogPromptValue | undefined>;
|
|
146
148
|
}
|
|
147
149
|
|
|
150
|
+
/**
|
|
151
|
+
* Routes typing to a composer draft that was in progress when the dialog
|
|
152
|
+
* opened, so in-flight keystrokes never answer by accident. The up/down select
|
|
153
|
+
* keys are the explicit hand-off: they release the guard for the rest of the
|
|
154
|
+
* dialog's life and the draft stays parked (intact) beneath it.
|
|
155
|
+
*/
|
|
148
156
|
interface AskDialogInputGuard {
|
|
149
157
|
isBlocked(): boolean;
|
|
150
158
|
handleInput(keyData: string): void;
|
|
159
|
+
/** Shown after the release keys while the guard holds input. */
|
|
151
160
|
hint: string;
|
|
152
161
|
/** Mirror the guard's blocked state onto the proxied draft surface each
|
|
153
162
|
* render, so a draft that owns input shows a visible insertion cursor even
|
|
154
|
-
* though this dialog holds TUI focus. */
|
|
155
|
-
syncPresentation?(): void;
|
|
163
|
+
* though this dialog holds TUI focus, and drops it once the dialog takes over. */
|
|
164
|
+
syncPresentation?(blocked: boolean): void;
|
|
156
165
|
}
|
|
157
166
|
|
|
158
167
|
interface AskDialogOptions {
|
|
@@ -404,7 +413,7 @@ function describeAnswer(question: ExtensionAskDialogQuestion, state: QuestionSta
|
|
|
404
413
|
push(optionLabelSpans(question, index, labels[index] ?? option.label));
|
|
405
414
|
});
|
|
406
415
|
if (state.customInput !== undefined) push([span(`“${normalizedInlineInput(state.customInput)}”`)]);
|
|
407
|
-
const note = noteForSubmittedAnswer(question, state)?.trim();
|
|
416
|
+
const note = noteForSubmittedAnswer(question, state)?.text.trim();
|
|
408
417
|
if (note) spans.push(span(" ✎ ", "dim"), span(normalizedInlineInput(note), "em"));
|
|
409
418
|
return spans;
|
|
410
419
|
}
|
|
@@ -448,13 +457,17 @@ function clearNoteUnlessRow(state: QuestionState, rowKey: string): void {
|
|
|
448
457
|
if (state.noteRowKey !== undefined && state.noteRowKey !== rowKey) clearNote(state);
|
|
449
458
|
}
|
|
450
459
|
|
|
451
|
-
|
|
460
|
+
/** The note that goes out with the answer (its row is part of it), and the option it is on (unset for Other). */
|
|
461
|
+
function noteForSubmittedAnswer(
|
|
462
|
+
question: ExtensionAskDialogQuestion,
|
|
463
|
+
state: QuestionState,
|
|
464
|
+
): { text: string; option?: string } | undefined {
|
|
452
465
|
if (state.note === undefined || state.noteRowKey === undefined) return undefined;
|
|
453
|
-
if (state.noteRowKey === "other") return state.customInput !== undefined ? state.note : undefined;
|
|
466
|
+
if (state.noteRowKey === "other") return state.customInput !== undefined ? { text: state.note } : undefined;
|
|
454
467
|
const match = /^option:(\d+)$/.exec(state.noteRowKey);
|
|
455
468
|
const optionIndex = match?.[1] === undefined ? Number.NaN : Number.parseInt(match[1], 10);
|
|
456
469
|
const option = Number.isInteger(optionIndex) ? question.options[optionIndex] : undefined;
|
|
457
|
-
return option && state.selectedOptions.has(option.label) ? state.note : undefined;
|
|
470
|
+
return option && state.selectedOptions.has(option.label) ? { text: state.note, option: option.label } : undefined;
|
|
458
471
|
}
|
|
459
472
|
|
|
460
473
|
function renderRowLabel(
|
|
@@ -581,10 +594,18 @@ export class AskDialogComponent implements Component {
|
|
|
581
594
|
#native: NativeNode | undefined;
|
|
582
595
|
/** Input-guard blocked state {@link #native} was described with (the guard flips outside this dialog). */
|
|
583
596
|
#nativeBlocked = false;
|
|
597
|
+
/** Set once the user explicitly takes the dialog (up/down, or a pointer action) while a draft held input. */
|
|
598
|
+
#guardReleased = false;
|
|
584
599
|
/** When the countdown runs out (epoch ms), for the native ring. */
|
|
585
600
|
#countdownDeadline = 0;
|
|
586
601
|
/** Once-a-second re-describe while the native countdown ring is shown. */
|
|
587
602
|
#ringTick: NodeJS.Timeout | undefined;
|
|
603
|
+
/**
|
|
604
|
+
* The answer whose pick just moved the dialog on to the next question. Note annotates it, not the
|
|
605
|
+
* next question's highlighted row, until that question is answered or any other input arrives:
|
|
606
|
+
* a Tern click commits a single-choice row, so picking then pressing Note is the mouse flow.
|
|
607
|
+
*/
|
|
608
|
+
#justAnswered: { questionIndex: number; rowKey: string } | undefined;
|
|
588
609
|
readonly #panel: OverlayPanel;
|
|
589
610
|
readonly #headerRegion: PanelRows;
|
|
590
611
|
readonly #bodyRegion: PanelRows;
|
|
@@ -682,6 +703,7 @@ export class AskDialogComponent implements Component {
|
|
|
682
703
|
// closed/prompt guards, matching HookSelector/HookInput semantics.
|
|
683
704
|
this.#countdown?.reset();
|
|
684
705
|
this.#native = undefined;
|
|
706
|
+
if (keyData !== "n" && keyData !== "N") this.#justAnswered = undefined;
|
|
685
707
|
if (matchesSelectCancel(keyData)) {
|
|
686
708
|
this.#finishCancel();
|
|
687
709
|
return;
|
|
@@ -696,9 +718,15 @@ export class AskDialogComponent implements Component {
|
|
|
696
718
|
this.toggleQuestionExpansion();
|
|
697
719
|
return;
|
|
698
720
|
}
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
721
|
+
if (this.#guardBlocks()) {
|
|
722
|
+
if (
|
|
723
|
+
getKeybindings().matches(keyData, "tui.select.up") ||
|
|
724
|
+
getKeybindings().matches(keyData, "tui.select.down")
|
|
725
|
+
) {
|
|
726
|
+
this.#releaseGuard();
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
729
|
+
this.options.inputGuard?.handleInput(keyData);
|
|
702
730
|
this.#requestRender();
|
|
703
731
|
return;
|
|
704
732
|
}
|
|
@@ -723,7 +751,7 @@ export class AskDialogComponent implements Component {
|
|
|
723
751
|
// Keep the proxied draft's cursor visible while it owns input (the editor
|
|
724
752
|
// renders as the next sibling in the same container, so this lands in the
|
|
725
753
|
// same frame).
|
|
726
|
-
this.options.inputGuard?.syncPresentation?.();
|
|
754
|
+
this.options.inputGuard?.syncPresentation?.(this.#guardBlocks());
|
|
727
755
|
if (this.#hidden) return this.#renderHidden(width);
|
|
728
756
|
const innerWidth = Math.max(1, width - 4);
|
|
729
757
|
this.#contentWidth = innerWidth;
|
|
@@ -768,10 +796,9 @@ export class AskDialogComponent implements Component {
|
|
|
768
796
|
* countdown, Hide, then Note, Skip and the primary Submit/Next).
|
|
769
797
|
*/
|
|
770
798
|
describe(cx: DescribeContext): NativeNode {
|
|
771
|
-
const inputGuard = this.options.inputGuard;
|
|
772
799
|
// Same draft-cursor mirroring as render(): the proxied draft describes itself next to this dialog.
|
|
773
|
-
|
|
774
|
-
|
|
800
|
+
const blocked = this.#guardBlocks();
|
|
801
|
+
this.options.inputGuard?.syncPresentation?.(blocked);
|
|
775
802
|
const ring = this.#countdown !== undefined && cx.supports("meter");
|
|
776
803
|
if (ring) this.#startRingTick();
|
|
777
804
|
if (this.#native && this.#nativeBlocked === blocked) return this.#native;
|
|
@@ -985,7 +1012,10 @@ export class AskDialogComponent implements Component {
|
|
|
985
1012
|
if (blocked && inputGuard) {
|
|
986
1013
|
return actionBar([
|
|
987
1014
|
...lead,
|
|
988
|
-
text([span(plainText(inputGuard
|
|
1015
|
+
text([span(plainText(this.#guardHint(inputGuard)), "muted")], {
|
|
1016
|
+
truncate: "end",
|
|
1017
|
+
role: "zeta.ask.summary",
|
|
1018
|
+
}),
|
|
989
1019
|
skip,
|
|
990
1020
|
]);
|
|
991
1021
|
}
|
|
@@ -1006,7 +1036,10 @@ export class AskDialogComponent implements Component {
|
|
|
1006
1036
|
tone: "accent",
|
|
1007
1037
|
title: question?.multi ? `${enterLabel} enter · Toggle space` : `${enterLabel} enter`,
|
|
1008
1038
|
});
|
|
1009
|
-
const note = actionButton("Note", "note", {
|
|
1039
|
+
const note = actionButton("Note", "note", {
|
|
1040
|
+
keys: "n",
|
|
1041
|
+
title: "Add a note to the highlighted answer, or to the one just picked n",
|
|
1042
|
+
});
|
|
1010
1043
|
return actionBar([...lead, null, note, skip, submit]);
|
|
1011
1044
|
}
|
|
1012
1045
|
|
|
@@ -1014,11 +1047,12 @@ export class AskDialogComponent implements Component {
|
|
|
1014
1047
|
* Pointer actions: a tab click switches to it; a click on an answer row is
|
|
1015
1048
|
* Enter on it (Space for a multi-select option, so it toggles; its
|
|
1016
1049
|
* double-click `activate` is Enter); the action bar's Submit, Note and Skip
|
|
1017
|
-
* run
|
|
1050
|
+
* run what Enter (see {@link #pressEnter} for Other), `n` and Esc run on the highlighted row; Hide/Show
|
|
1018
1051
|
* collapse and restore the dialog.
|
|
1019
1052
|
*/
|
|
1020
1053
|
handleNativeEvent(event: NativeUiEvent): void {
|
|
1021
1054
|
if (this.#closed || this.#promptActive) return;
|
|
1055
|
+
if (event.type !== "action" || event.act !== "note") this.#justAnswered = undefined;
|
|
1022
1056
|
if (event.type === "action") {
|
|
1023
1057
|
if (event.act === "cancel") {
|
|
1024
1058
|
this.#finishCancel();
|
|
@@ -1028,13 +1062,16 @@ export class AskDialogComponent implements Component {
|
|
|
1028
1062
|
this.#setHidden(event.act === "hide");
|
|
1029
1063
|
return;
|
|
1030
1064
|
}
|
|
1031
|
-
if (this.#hidden
|
|
1065
|
+
if (this.#hidden) return;
|
|
1066
|
+
// A pointer action on the dialog is an explicit hand-off from the draft.
|
|
1067
|
+
this.#releaseGuardForPointer();
|
|
1032
1068
|
if (event.act === "submit") this.#pressEnter();
|
|
1033
1069
|
else if (event.act === "note") this.#pressNote();
|
|
1034
1070
|
return;
|
|
1035
1071
|
}
|
|
1036
1072
|
if (event.type !== "select" && event.type !== "activate") return;
|
|
1037
|
-
if (this.#hidden
|
|
1073
|
+
if (this.#hidden) return;
|
|
1074
|
+
this.#releaseGuardForPointer();
|
|
1038
1075
|
const key = leafKey(event.key);
|
|
1039
1076
|
if (key === "tabs") {
|
|
1040
1077
|
if (!this.#hasSubmitTab()) return;
|
|
@@ -1062,7 +1099,13 @@ export class AskDialogComponent implements Component {
|
|
|
1062
1099
|
this.#requestRender();
|
|
1063
1100
|
}
|
|
1064
1101
|
|
|
1065
|
-
/**
|
|
1102
|
+
/**
|
|
1103
|
+
* The action bar's Submit/Next: submit on the Review tab, else commit the highlighted row —
|
|
1104
|
+
* except Other, whose row (click or Enter) already opens the editor. Reopening it here trapped a
|
|
1105
|
+
* cancelled Other: Next kept bringing the editor back instead of moving on. With a Review tab to
|
|
1106
|
+
* land on, Next keeps any custom answer and moves on; a lone single-select question has nowhere
|
|
1107
|
+
* to go but submitting nothing, so it still asks.
|
|
1108
|
+
*/
|
|
1066
1109
|
#pressEnter(): void {
|
|
1067
1110
|
this.#countdown?.reset();
|
|
1068
1111
|
if (this.#isSubmitTab()) {
|
|
@@ -1072,18 +1115,38 @@ export class AskDialogComponent implements Component {
|
|
|
1072
1115
|
const active = this.#activeQuestionState();
|
|
1073
1116
|
const rowItem = active ? this.#questionRows(active.question)[active.state.cursorIndex] : undefined;
|
|
1074
1117
|
if (!active || !rowItem) return;
|
|
1118
|
+
if (rowItem.kind === "other" && this.#hasSubmitTab()) {
|
|
1119
|
+
this.#advanceAfterQuestion(active.state.customInput === undefined ? undefined : rowItem.key);
|
|
1120
|
+
return;
|
|
1121
|
+
}
|
|
1075
1122
|
this.#commitRow(active.question, active.state, rowItem, true);
|
|
1076
1123
|
this.#requestRender();
|
|
1077
1124
|
}
|
|
1078
1125
|
|
|
1079
|
-
/** `n`: a note on the
|
|
1126
|
+
/** `n`: a note on the {@link #noteTarget} row (questions only). */
|
|
1080
1127
|
#pressNote(): void {
|
|
1081
1128
|
if (this.#isSubmitTab()) return;
|
|
1082
1129
|
this.#countdown?.reset();
|
|
1130
|
+
const target = this.#noteTarget();
|
|
1131
|
+
if (target) void this.#promptForNote(target.question, target.state, target.rowItem);
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
/**
|
|
1135
|
+
* The row a note goes to: the answer just picked while the question it moved on to is still
|
|
1136
|
+
* unanswered, else the highlighted row.
|
|
1137
|
+
*/
|
|
1138
|
+
#noteTarget(): { question: ExtensionAskDialogQuestion; state: QuestionState; rowItem: QuestionRow } | undefined {
|
|
1083
1139
|
const active = this.#activeQuestionState();
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1140
|
+
if (!active) return undefined;
|
|
1141
|
+
const last = this.#justAnswered;
|
|
1142
|
+
if (last && last.questionIndex !== this.#currentQuestionIndex() && !isAnswered(active.state)) {
|
|
1143
|
+
const question = this.#questions[last.questionIndex];
|
|
1144
|
+
const state = this.#states[last.questionIndex];
|
|
1145
|
+
const rowItem = question ? this.#questionRows(question).find(row => row.key === last.rowKey) : undefined;
|
|
1146
|
+
if (question && state && rowItem) return { question, state, rowItem };
|
|
1147
|
+
}
|
|
1148
|
+
const rowItem = this.#questionRows(active.question)[active.state.cursorIndex];
|
|
1149
|
+
return rowItem ? { question: active.question, state: active.state, rowItem } : undefined;
|
|
1087
1150
|
}
|
|
1088
1151
|
|
|
1089
1152
|
/** Re-describe once a second while a countdown ring is shown (the ring's value is data, not a terminal clock). */
|
|
@@ -1169,16 +1232,39 @@ export class AskDialogComponent implements Component {
|
|
|
1169
1232
|
this.#requestRender();
|
|
1170
1233
|
}
|
|
1171
1234
|
|
|
1235
|
+
/** True while a draft that predates the dialog still owns typing. */
|
|
1236
|
+
#guardBlocks(): boolean {
|
|
1237
|
+
return !this.#guardReleased && (this.options.inputGuard?.isBlocked() ?? false);
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
/** Up/down hand the keyboard to the dialog for good; the draft stays untouched beneath it. */
|
|
1241
|
+
#releaseGuard(): void {
|
|
1242
|
+
this.#guardReleased = true;
|
|
1243
|
+
this.#native = undefined;
|
|
1244
|
+
this.#hidden = false;
|
|
1245
|
+
this.#requestRender();
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
#releaseGuardForPointer(): void {
|
|
1249
|
+
if (!this.#guardBlocks()) return;
|
|
1250
|
+
this.#guardReleased = true;
|
|
1251
|
+
this.#native = undefined;
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
#guardHint(inputGuard: AskDialogInputGuard): string {
|
|
1255
|
+
return `${editorKeys("tui.select.up", "tui.select.down")} answer · ${inputGuard.hint}`;
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1172
1258
|
/** Hidden: one line in the composer's place — title (with countdown), the question clipped to fit, and how to bring it back. */
|
|
1173
1259
|
#renderHidden(width: number): readonly string[] {
|
|
1174
1260
|
const hideKey = editorKey("app.ask.hide");
|
|
1175
1261
|
const enter = formatKeyHint("enter");
|
|
1176
1262
|
const inputGuard = this.options.inputGuard;
|
|
1177
|
-
const blocked =
|
|
1263
|
+
const blocked = this.#guardBlocks();
|
|
1178
1264
|
// While a draft owns input, Enter goes to the draft, so only the hide key restores.
|
|
1179
1265
|
const show = blocked ? hideKey : hideKey ? `${hideKey}/${enter}` : enter;
|
|
1180
1266
|
const hints: string[] = [];
|
|
1181
|
-
if (blocked && inputGuard) hints.push(inputGuard
|
|
1267
|
+
if (blocked && inputGuard) hints.push(this.#guardHint(inputGuard));
|
|
1182
1268
|
if (show) hints.push(`${show} show`);
|
|
1183
1269
|
hints.push(`${editorKey("tui.select.cancel")} cancel`);
|
|
1184
1270
|
const hint = theme.fg("dim", ` · ${hints.join(" · ")}`);
|
|
@@ -1262,7 +1348,7 @@ export class AskDialogComponent implements Component {
|
|
|
1262
1348
|
const enter = formatKeyHint("enter");
|
|
1263
1349
|
const upDown = editorKeys("tui.select.up", "tui.select.down");
|
|
1264
1350
|
const inputGuard = this.options.inputGuard;
|
|
1265
|
-
if (inputGuard
|
|
1351
|
+
if (inputGuard && this.#guardBlocks()) return `${this.#guardHint(inputGuard)}${this.#expandHint()} · ${cancel}`;
|
|
1266
1352
|
if (this.#isSubmitTab()) {
|
|
1267
1353
|
const scroll = indicator ? ` ${indicator} scroll ·` : "";
|
|
1268
1354
|
return `${enter} submit · ${upDown} scroll ·${scroll} ${cancel}`;
|
|
@@ -1334,9 +1420,7 @@ export class AskDialogComponent implements Component {
|
|
|
1334
1420
|
const rowItem = rows[state.cursorIndex];
|
|
1335
1421
|
if (!rowItem) return;
|
|
1336
1422
|
if (keyData === "n" || keyData === "N") {
|
|
1337
|
-
|
|
1338
|
-
void this.#promptForNote(question, state, rowItem);
|
|
1339
|
-
}
|
|
1423
|
+
this.#pressNote();
|
|
1340
1424
|
return;
|
|
1341
1425
|
}
|
|
1342
1426
|
const isEnter = matchesKey(keyData, "enter") || matchesKey(keyData, "return") || keyData === "\n";
|
|
@@ -1364,7 +1448,7 @@ export class AskDialogComponent implements Component {
|
|
|
1364
1448
|
// focused option; Space toggles. Advances to the next question
|
|
1365
1449
|
// (submitting only for a single-question dialog), matching
|
|
1366
1450
|
// single-select Enter (#8252).
|
|
1367
|
-
this.#advanceAfterQuestion();
|
|
1451
|
+
this.#advanceAfterQuestion(state.selectedOptions.has(option.label) ? rowItem.key : undefined);
|
|
1368
1452
|
return;
|
|
1369
1453
|
}
|
|
1370
1454
|
if (state.selectedOptions.has(option.label)) {
|
|
@@ -1380,7 +1464,7 @@ export class AskDialogComponent implements Component {
|
|
|
1380
1464
|
state.customInput = undefined;
|
|
1381
1465
|
state.customInputImages = undefined;
|
|
1382
1466
|
clearNoteUnlessRow(state, rowItem.key);
|
|
1383
|
-
this.#advanceAfterQuestion();
|
|
1467
|
+
this.#advanceAfterQuestion(rowItem.key);
|
|
1384
1468
|
}
|
|
1385
1469
|
|
|
1386
1470
|
#handleSubmitTabInput(keyData: string): void {
|
|
@@ -1405,8 +1489,13 @@ export class AskDialogComponent implements Component {
|
|
|
1405
1489
|
this.#submitScrollOffset = 0;
|
|
1406
1490
|
}
|
|
1407
1491
|
|
|
1408
|
-
|
|
1492
|
+
/** Move past the current question; `answeredRowKey` is the row whose pick did it, for {@link #noteTarget}. */
|
|
1493
|
+
#advanceAfterQuestion(answeredRowKey?: string): void {
|
|
1409
1494
|
const current = this.#currentQuestionIndex();
|
|
1495
|
+
this.#justAnswered =
|
|
1496
|
+
answeredRowKey !== undefined && this.#questions.length > 1
|
|
1497
|
+
? { questionIndex: current, rowKey: answeredRowKey }
|
|
1498
|
+
: undefined;
|
|
1410
1499
|
if (this.#questions.length === 1) {
|
|
1411
1500
|
this.#finishSubmit();
|
|
1412
1501
|
return;
|
|
@@ -1458,7 +1547,7 @@ export class AskDialogComponent implements Component {
|
|
|
1458
1547
|
this.#activeTabIndex = this.#submitTabIndex();
|
|
1459
1548
|
this.#submitScrollOffset = 0;
|
|
1460
1549
|
} else {
|
|
1461
|
-
this.#advanceAfterQuestion();
|
|
1550
|
+
this.#advanceAfterQuestion(rowItem.key);
|
|
1462
1551
|
}
|
|
1463
1552
|
} finally {
|
|
1464
1553
|
this.#promptActive = false;
|
|
@@ -1590,7 +1679,7 @@ export class AskDialogComponent implements Component {
|
|
|
1590
1679
|
const label = questionTabLabel(question, index);
|
|
1591
1680
|
const answer = renderAnswerSummary(question, state);
|
|
1592
1681
|
allLines.push(`${theme.fg("dim", `${index + 1}. ${label}:`)} ${answer}`);
|
|
1593
|
-
const submittedNote = noteForSubmittedAnswer(question, state);
|
|
1682
|
+
const submittedNote = noteForSubmittedAnswer(question, state)?.text;
|
|
1594
1683
|
if (submittedNote?.trim()) {
|
|
1595
1684
|
const note = normalizedInlineInput(submittedNote);
|
|
1596
1685
|
allLines.push(
|
|
@@ -1724,8 +1813,9 @@ export class AskDialogComponent implements Component {
|
|
|
1724
1813
|
selectedOptions,
|
|
1725
1814
|
customInput: state.customInput,
|
|
1726
1815
|
customInputImages: state.customInputImages,
|
|
1727
|
-
note,
|
|
1816
|
+
note: note?.text,
|
|
1728
1817
|
noteImages: note === undefined ? undefined : state.noteImages,
|
|
1818
|
+
noteOption: note?.option,
|
|
1729
1819
|
timedOut: state.timedOut || undefined,
|
|
1730
1820
|
});
|
|
1731
1821
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ImageContent } from "@linxiraos/pi-ai";
|
|
1
2
|
import {
|
|
2
3
|
type Component,
|
|
3
4
|
type Focusable,
|
|
@@ -15,8 +16,12 @@ import {
|
|
|
15
16
|
type BtwHistoryTurn,
|
|
16
17
|
getBtwCopyText,
|
|
17
18
|
getBtwLatestTurn,
|
|
19
|
+
getBtwTopicLabel,
|
|
18
20
|
getBtwTurns,
|
|
19
21
|
} from "./btw-history";
|
|
22
|
+
import { compactImageMarkers, formatVisionMarker } from "../prompt/composer-attachments";
|
|
23
|
+
import { extractImagePastePathsFromText } from "../prompt/custom-editor";
|
|
24
|
+
import { BracketedPasteHandler } from "../bracketed-paste";
|
|
20
25
|
import { getMarkdownTheme, type ThemeColor, theme } from "../theme/theme";
|
|
21
26
|
import {
|
|
22
27
|
matchesSelectCancel,
|
|
@@ -39,13 +44,28 @@ import type { NativeChild, NativeNode, NativeScroll, NativeUiEvent } from "../na
|
|
|
39
44
|
import { col, md, node, span, text } from "../native/describe";
|
|
40
45
|
import { actionBar, actionButton } from "../native/overlay";
|
|
41
46
|
|
|
47
|
+
/** The turns as shown: a titled topic's opening question displays as its title, e.g. `/sitrep`. */
|
|
48
|
+
function getDisplayTurns(record: BtwHistoryRecord): readonly BtwHistoryTurn[] {
|
|
49
|
+
const turns = getBtwTurns(record);
|
|
50
|
+
return record.title === undefined ? turns : [{ ...turns[0]!, question: record.title }, ...turns.slice(1)];
|
|
51
|
+
}
|
|
52
|
+
|
|
42
53
|
interface BtwHistoryPanelOptions {
|
|
43
54
|
records: readonly BtwHistoryRecord[];
|
|
44
55
|
onClose: () => void;
|
|
45
56
|
onCopy: (record: BtwHistoryRecord) => void;
|
|
46
57
|
onCancel: (record: BtwHistoryRecord) => void;
|
|
47
58
|
canFollowUp?: (record: BtwHistoryRecord) => boolean;
|
|
48
|
-
onFollowUp?: (
|
|
59
|
+
onFollowUp?: (
|
|
60
|
+
record: BtwHistoryRecord,
|
|
61
|
+
question: string,
|
|
62
|
+
signal: AbortSignal,
|
|
63
|
+
images?: ImageContent[],
|
|
64
|
+
) => Promise<boolean>;
|
|
65
|
+
/** Read a clipboard image into the follow-up (an empty paste, as terminals send for one). */
|
|
66
|
+
onPasteImage?: () => Promise<unknown>;
|
|
67
|
+
/** Attach an image file whose path was pasted or dropped into the follow-up. */
|
|
68
|
+
onPasteImagePath?: (path: string) => Promise<void>;
|
|
49
69
|
/** Configured push-to-talk keys for a follow-up composer. */
|
|
50
70
|
spaceHoldKeys?: readonly KeyId[];
|
|
51
71
|
spaceHold?: (input: Input) => SpaceHoldHandler;
|
|
@@ -63,6 +83,11 @@ interface FollowUpComposer {
|
|
|
63
83
|
recordId: string;
|
|
64
84
|
input: Input;
|
|
65
85
|
abortController: AbortController;
|
|
86
|
+
/** Images pasted into this follow-up, numbered by their `[Image #N]` markers. */
|
|
87
|
+
images: ImageContent[];
|
|
88
|
+
/** Image pastes still loading, in paste order; Enter waits for them. */
|
|
89
|
+
pendingPastes: { settled: boolean; text: string | undefined }[];
|
|
90
|
+
submitQueued: boolean;
|
|
66
91
|
notice?: string;
|
|
67
92
|
}
|
|
68
93
|
|
|
@@ -126,6 +151,7 @@ export class BtwHistoryPanel implements Component, Focusable {
|
|
|
126
151
|
#listHeight = 1;
|
|
127
152
|
#focused = false;
|
|
128
153
|
#composer: FollowUpComposer | undefined;
|
|
154
|
+
readonly #pasteHandler = new BracketedPasteHandler();
|
|
129
155
|
#followUpPending = false;
|
|
130
156
|
#followLatest = false;
|
|
131
157
|
#turns: RenderedTurn[] = [];
|
|
@@ -305,7 +331,14 @@ export class BtwHistoryPanel implements Component, Focusable {
|
|
|
305
331
|
input.placeholder = "Ask about this answer…";
|
|
306
332
|
if (this.#options.spaceHoldKeys !== undefined) input.spaceHold.keys = this.#options.spaceHoldKeys;
|
|
307
333
|
input.spaceHold.handler = this.#options.spaceHold?.(input);
|
|
308
|
-
const composer: FollowUpComposer = {
|
|
334
|
+
const composer: FollowUpComposer = {
|
|
335
|
+
recordId: record.id,
|
|
336
|
+
input,
|
|
337
|
+
abortController: new AbortController(),
|
|
338
|
+
images: [],
|
|
339
|
+
pendingPastes: [],
|
|
340
|
+
submitQueued: false,
|
|
341
|
+
};
|
|
309
342
|
input.onEscape = () => {
|
|
310
343
|
composer.abortController.abort();
|
|
311
344
|
this.#composer = undefined;
|
|
@@ -322,7 +355,11 @@ export class BtwHistoryPanel implements Component, Focusable {
|
|
|
322
355
|
|
|
323
356
|
async #submitFollowUp(composer: FollowUpComposer, value: string): Promise<void> {
|
|
324
357
|
if (this.#followUpPending || this.#composer !== composer) return;
|
|
325
|
-
|
|
358
|
+
if (composer.pendingPastes.length > 0) {
|
|
359
|
+
composer.submitQueued = true;
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
let question = value.trim();
|
|
326
363
|
if (!question) {
|
|
327
364
|
composer.notice = "Enter a follow-up question.";
|
|
328
365
|
return;
|
|
@@ -335,8 +372,20 @@ export class BtwHistoryPanel implements Component, Focusable {
|
|
|
335
372
|
this.#followUpPending = true;
|
|
336
373
|
composer.notice = "Starting follow-up…";
|
|
337
374
|
this.#options.requestRender();
|
|
375
|
+
let images: ImageContent[] | undefined;
|
|
376
|
+
if (composer.images.length > 0) {
|
|
377
|
+
// Path pastes attach as they finish loading; submit numbers images in text order.
|
|
378
|
+
const compacted = compactImageMarkers(question, composer.images.length, { byAppearance: true });
|
|
379
|
+
images = compacted ? compacted.keep.map(index => composer.images[index]!) : composer.images;
|
|
380
|
+
if (compacted) question = compacted.text.trim();
|
|
381
|
+
}
|
|
338
382
|
try {
|
|
339
|
-
const accepted = await this.#options.onFollowUp!(
|
|
383
|
+
const accepted = await this.#options.onFollowUp!(
|
|
384
|
+
record,
|
|
385
|
+
question,
|
|
386
|
+
composer.abortController.signal,
|
|
387
|
+
images?.length ? images : undefined,
|
|
388
|
+
);
|
|
340
389
|
if (this.#composer !== composer) return;
|
|
341
390
|
if (accepted) {
|
|
342
391
|
this.#composer = undefined;
|
|
@@ -361,14 +410,74 @@ export class BtwHistoryPanel implements Component, Focusable {
|
|
|
361
410
|
return this.#composer?.input.capturesInput(data) ?? false;
|
|
362
411
|
}
|
|
363
412
|
|
|
364
|
-
/**
|
|
413
|
+
/** False while a follow-up is sent: it already took its images, and the composer clears after. */
|
|
414
|
+
get acceptsImages(): boolean {
|
|
415
|
+
return this.#composer !== undefined && !this.#followUpPending;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/** Attach an image to the follow-up; returns its `[Image #N, WxH]` marker to paste. */
|
|
419
|
+
attachImage(image: ImageContent, dims?: { width: number; height: number }): string | undefined {
|
|
420
|
+
const composer = this.#composer;
|
|
421
|
+
if (!composer || this.#followUpPending) return undefined;
|
|
422
|
+
composer.images.push(image);
|
|
423
|
+
return formatVisionMarker("image", composer.images.length, dims);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/** Reserve ordered delivery for an image paste. Completion delivers its marker once, or releases on undefined. */
|
|
427
|
+
beginPaste(): (text: string | undefined) => boolean {
|
|
428
|
+
const composer = this.#composer;
|
|
429
|
+
if (!composer) return () => false;
|
|
430
|
+
const pending: { settled: boolean; text: string | undefined } = { settled: false, text: undefined };
|
|
431
|
+
composer.pendingPastes.push(pending);
|
|
432
|
+
return text => {
|
|
433
|
+
if (this.#composer !== composer || pending.settled) return false;
|
|
434
|
+
pending.settled = true;
|
|
435
|
+
pending.text = text;
|
|
436
|
+
// A failed read releases the wait, but must not send the follow-up without its image.
|
|
437
|
+
if (!text) composer.submitQueued = false;
|
|
438
|
+
let delivered = 0;
|
|
439
|
+
for (const paste of composer.pendingPastes) {
|
|
440
|
+
if (!paste.settled) break;
|
|
441
|
+
if (paste.text) composer.input.pasteText(paste.text);
|
|
442
|
+
delivered++;
|
|
443
|
+
}
|
|
444
|
+
composer.pendingPastes.splice(0, delivered);
|
|
445
|
+
if (composer.pendingPastes.length === 0 && composer.submitQueued) {
|
|
446
|
+
composer.submitQueued = false;
|
|
447
|
+
void this.#submitFollowUp(composer, composer.input.getValue());
|
|
448
|
+
}
|
|
449
|
+
this.#options.requestRender();
|
|
450
|
+
return !!text;
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/** Enhanced clipboard pastes belong only to the active composer, behind any image still loading. */
|
|
365
455
|
pasteText(text: string): void {
|
|
366
|
-
|
|
367
|
-
|
|
456
|
+
const composer = this.#composer;
|
|
457
|
+
if (!composer) return;
|
|
458
|
+
if (composer.pendingPastes.length > 0) this.beginPaste()(text);
|
|
459
|
+
else composer.input.pasteText(text);
|
|
368
460
|
this.#options.requestRender();
|
|
369
461
|
}
|
|
462
|
+
|
|
463
|
+
/** A pasted image path or an empty (clipboard image) paste attaches an image; other text is typed. */
|
|
464
|
+
#paste(content: string): void {
|
|
465
|
+
const imagePaths = extractImagePastePathsFromText(content);
|
|
466
|
+
if (content.length === 0 && this.#options.onPasteImage) void this.#options.onPasteImage();
|
|
467
|
+
else if (imagePaths && this.#options.onPasteImagePath) {
|
|
468
|
+
for (const path of imagePaths) void this.#options.onPasteImagePath(path);
|
|
469
|
+
} else this.pasteText(content);
|
|
470
|
+
}
|
|
471
|
+
|
|
370
472
|
handleInput(data: string): void {
|
|
371
473
|
if (this.#composer) {
|
|
474
|
+
const paste = this.#pasteHandler.process(data);
|
|
475
|
+
if (paste.handled) {
|
|
476
|
+
if (paste.pasteContent !== undefined) this.#paste(paste.pasteContent);
|
|
477
|
+
if (paste.remaining.length > 0) this.handleInput(paste.remaining);
|
|
478
|
+
this.#options.requestRender();
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
372
481
|
// The input owns every key it handles, including panel shortcuts and
|
|
373
482
|
// pasted text; the line keys it ignores still scroll the answer above.
|
|
374
483
|
if (!this.#composer.input.handleInput(data)) this.#scrollDetail(data);
|
|
@@ -564,7 +673,7 @@ export class BtwHistoryPanel implements Component, Focusable {
|
|
|
564
673
|
if (followUps > 0) detail.push(span(` · ${followUps} follow-up${followUps === 1 ? "" : "s"}`));
|
|
565
674
|
const status = describeStatus(getBtwLatestTurn(record).status);
|
|
566
675
|
// The question is markdown: its `code` reads as mono, without the backticks.
|
|
567
|
-
const label = sanitizeDisplayLine(record
|
|
676
|
+
const label = sanitizeDisplayLine(getBtwTopicLabel(record))
|
|
568
677
|
.split(/`([^`]+)`/)
|
|
569
678
|
.flatMap((part, index) => (part ? [span(part, index % 2 === 1 ? "mono" : undefined)] : []));
|
|
570
679
|
return node("item", { label, detail, ...(status ? { value: status } : {}) }, undefined, record.id);
|
|
@@ -580,7 +689,7 @@ export class BtwHistoryPanel implements Component, Focusable {
|
|
|
580
689
|
|
|
581
690
|
/** The selected side question as a short document: the asked question titles each answer. */
|
|
582
691
|
#describeThread(record: BtwHistoryRecord): NativeNode {
|
|
583
|
-
const turns =
|
|
692
|
+
const turns = getDisplayTurns(record);
|
|
584
693
|
const children: NativeChild[] = turns.map((turn, index) => this.#describeTurn(turn, index, `turn-${index}`));
|
|
585
694
|
if (this.#composer) children.push(this.#describeComposer(this.#composer));
|
|
586
695
|
return node("col", { role: "zeta.btw.thread" }, children, "thread");
|
|
@@ -703,7 +812,7 @@ export class BtwHistoryPanel implements Component, Focusable {
|
|
|
703
812
|
const time = theme.fg("dim", this.#timeFormat.format(record.createdAt));
|
|
704
813
|
const badge = theme.fg(status.color, status.label);
|
|
705
814
|
const prefix = `${cursor} ${time} ${badge} `;
|
|
706
|
-
const question = sanitizeDisplayLine(record
|
|
815
|
+
const question = sanitizeDisplayLine(getBtwTopicLabel(record));
|
|
707
816
|
const snippet = truncateToWidth(
|
|
708
817
|
question,
|
|
709
818
|
Math.max(0, contentWidth - (rowSpan === 2 ? 2 : visibleWidth(prefix))),
|
|
@@ -796,7 +905,7 @@ export class BtwHistoryPanel implements Component, Focusable {
|
|
|
796
905
|
lines.push(...wrapTextWithAnsi(theme.fg("success", "✓ Copied to clipboard"), inner), "");
|
|
797
906
|
}
|
|
798
907
|
if (record) {
|
|
799
|
-
const turns =
|
|
908
|
+
const turns = getDisplayTurns(record);
|
|
800
909
|
for (let index = 0; index < turns.length; index++) {
|
|
801
910
|
const cached = this.#renderTurn(turns[index]!, this.#turns[index], inner);
|
|
802
911
|
this.#turns[index] = cached;
|
|
@@ -871,7 +980,10 @@ export class BtwHistoryPanel implements Component, Focusable {
|
|
|
871
980
|
const availableRows = Math.max(1, height - chrome - 1);
|
|
872
981
|
if (availableRows >= 2) {
|
|
873
982
|
composerLines.push(
|
|
874
|
-
theme.fg(
|
|
983
|
+
theme.fg(
|
|
984
|
+
"dim",
|
|
985
|
+
truncateToWidth(`Topic: ${sanitizeDisplayLine(record ? getBtwTopicLabel(record) : "")}`, inner),
|
|
986
|
+
),
|
|
875
987
|
);
|
|
876
988
|
}
|
|
877
989
|
if (composer.notice && availableRows >= 3) {
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import type { ImageContent } from "@linxiraos/pi-ai";
|
|
2
|
+
|
|
1
3
|
export interface BtwHistoryTurn {
|
|
2
4
|
question: string;
|
|
5
|
+
/** Images attached to the question, sent again with it on later follow-ups. */
|
|
6
|
+
images?: readonly ImageContent[];
|
|
3
7
|
answer: string;
|
|
4
8
|
status: "running" | "complete" | "cancelled" | "error" | "interrupted";
|
|
5
9
|
createdAt: number;
|
|
@@ -10,9 +14,16 @@ export interface BtwHistoryTurn {
|
|
|
10
14
|
export interface BtwHistoryRecord extends BtwHistoryTurn {
|
|
11
15
|
id: string;
|
|
12
16
|
leafId: string | null;
|
|
17
|
+
/** Display heading for the topic, e.g. `/sitrep`; `question` keeps the full text sent to the model. */
|
|
18
|
+
title?: string;
|
|
13
19
|
followUps?: readonly BtwHistoryTurn[];
|
|
14
20
|
}
|
|
15
21
|
|
|
22
|
+
/** The topic's display heading: its title, else the opening question. */
|
|
23
|
+
export function getBtwTopicLabel(record: BtwHistoryRecord): string {
|
|
24
|
+
return record.title ?? record.question;
|
|
25
|
+
}
|
|
26
|
+
|
|
16
27
|
export function getBtwLatestTurn(record: BtwHistoryRecord): BtwHistoryTurn {
|
|
17
28
|
return record.followUps?.at(-1) ?? record;
|
|
18
29
|
}
|
|
@@ -14,6 +14,8 @@ type BtwPanelState = "running" | "complete" | "branching" | "aborted" | "error";
|
|
|
14
14
|
|
|
15
15
|
interface BtwPanelComponentOptions {
|
|
16
16
|
question: string;
|
|
17
|
+
/** Heading shown instead of `/btw <question>`, e.g. `/sitrep the migration` for a side command. */
|
|
18
|
+
title?: string;
|
|
17
19
|
tui: TUI;
|
|
18
20
|
canBranch?: () => boolean;
|
|
19
21
|
canFollowUp?: () => boolean;
|
|
@@ -30,15 +32,13 @@ export class BtwPanelComponent extends OverlayPanel {
|
|
|
30
32
|
#closed = false;
|
|
31
33
|
#copied = false;
|
|
32
34
|
#baseTitle: string;
|
|
33
|
-
readonly #question: string;
|
|
34
35
|
readonly #content: StreamingPanelContent;
|
|
35
36
|
#native: { node: NativeNode; canFollowUp: boolean; canBranch: boolean } | undefined;
|
|
36
37
|
|
|
37
38
|
constructor(options: BtwPanelComponentOptions) {
|
|
38
|
-
const baseTitle = `/btw ${
|
|
39
|
+
const baseTitle = replaceTabs(options.title ?? `/btw ${options.question}`);
|
|
39
40
|
super(baseTitle, "zeta.overlay.btw");
|
|
40
41
|
this.#baseTitle = baseTitle;
|
|
41
|
-
this.#question = replaceTabs(options.question);
|
|
42
42
|
this.#tui = options.tui;
|
|
43
43
|
this.#canBranch = options.canBranch;
|
|
44
44
|
this.#canFollowUp = options.canFollowUp;
|
|
@@ -138,7 +138,11 @@ export class BtwPanelComponent extends OverlayPanel {
|
|
|
138
138
|
const memo = this.#native;
|
|
139
139
|
if (memo && memo.canFollowUp === canFollowUp && memo.canBranch === canBranch) return memo.node;
|
|
140
140
|
// Inline in the dock, styled as a sheet by role: a borderless column headed by the question.
|
|
141
|
-
|
|
141
|
+
// The command word is the accent; the rest of the heading is the question or arguments.
|
|
142
|
+
const space = this.#baseTitle.indexOf(" ");
|
|
143
|
+
const command = space === -1 ? this.#baseTitle : this.#baseTitle.slice(0, space);
|
|
144
|
+
const rest = space === -1 ? "" : this.#baseTitle.slice(space);
|
|
145
|
+
const title = text([span(command, "accent"), ...(rest ? [span(rest)] : [])], { truncate: "end", lines: 1 });
|
|
142
146
|
const live = this.#state === "running" || this.#state === "branching";
|
|
143
147
|
const head = node("row", { role: "zeta.sheet.head", gap: "sm", align: "center" }, [
|
|
144
148
|
...(live ? [node("spinner", {})] : []),
|