pi-bro 0.37.0 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/README.md +18 -22
- package/docs/README.md +7 -7
- package/docs/elevate.md +10 -93
- package/docs/examples.md +1 -1
- package/docs/feature-map.md +33 -0
- package/docs/features/architecture.md +1 -1
- package/docs/features/elevate.md +122 -0
- package/docs/features/explain.md +16 -20
- package/docs/features/grill-me.md +65 -0
- package/docs/features/guided-review.md +150 -0
- package/docs/features/overthink.md +66 -0
- package/docs/features/remember-me.md +92 -0
- package/docs/features/show.md +9 -15
- package/docs/getting-started.md +5 -5
- package/docs/grill-me.md +5 -51
- package/docs/guided-review.md +14 -113
- package/docs/overthink.md +7 -46
- package/docs/piG-agent-shell-qualification.md +3 -3
- package/docs/pig-compatibility.md +1 -1
- package/docs/reference/commands.md +18 -33
- package/docs/reference/data-and-permissions.md +9 -9
- package/docs/reference/settings.md +8 -8
- package/docs/reference/troubleshooting.md +3 -3
- package/docs/remember-me.md +6 -75
- package/docs/user-guide.md +4 -4
- package/package.json +6 -4
- package/src/advisor.ts +1 -1
- package/src/architecture.ts +1 -1
- package/src/backend.ts +1 -0
- package/src/bro.ts +47 -189
- package/src/btw.ts +10 -199
- package/src/composer-modal.ts +197 -0
- package/src/explain-modal.ts +28 -79
- package/src/grill.ts +3 -2
- package/src/overthink-state.ts +3 -3
- package/src/overthink.ts +2 -2
- package/src/remember.ts +3 -2
- package/src/session-state.ts +46 -28
- package/src/settings.ts +11 -3
- package/src/simplify-engine.ts +50 -24
- package/src/simplify-ui.ts +165 -126
- package/src/sources.ts +3 -3
package/src/btw.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import { copyToClipboard
|
|
3
|
-
import { Input, Markdown, matchesKey, wrapTextWithAnsi, type Focusable } from "@earendil-works/pi-tui";
|
|
2
|
+
import { copyToClipboard } from "@earendil-works/pi-coding-agent";
|
|
4
3
|
import { execute as executeBackend, textProgressThrottle, type BackendProgress, type BackendSelection } from "./backend.ts";
|
|
5
4
|
import { buildBtwPrompt } from "./prompt.ts";
|
|
6
5
|
import {
|
|
@@ -13,8 +12,8 @@ import {
|
|
|
13
12
|
selectionLabel,
|
|
14
13
|
} from "./settings.ts";
|
|
15
14
|
import { captureShowTranscript } from "./show.ts";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
15
|
+
import { openBroOverlay, startProgressClock } from "./modal-kit.ts";
|
|
16
|
+
import { ComposerModal } from "./composer-modal.ts";
|
|
18
17
|
import { errorMessage } from "./util.ts";
|
|
19
18
|
|
|
20
19
|
export const BTW_CONTEXT_TURNS = 8;
|
|
@@ -171,198 +170,6 @@ export async function runBtwTurn(
|
|
|
171
170
|
}
|
|
172
171
|
}
|
|
173
172
|
|
|
174
|
-
export class BtwModal implements Focusable {
|
|
175
|
-
private _focused = false;
|
|
176
|
-
private readonly markdown = new Markdown("", 0, 0, getMarkdownTheme());
|
|
177
|
-
private readonly input = new Input();
|
|
178
|
-
private noticeText = "";
|
|
179
|
-
private noticeTone: NoticeTone = "info";
|
|
180
|
-
private rawArea: Area | undefined;
|
|
181
|
-
// Follows the newest text until the reader scrolls up; scrolling back to the end follows again.
|
|
182
|
-
private readonly scroller = new Scroller(
|
|
183
|
-
() => {
|
|
184
|
-
this.noticeText = "";
|
|
185
|
-
this.tui.requestRender();
|
|
186
|
-
},
|
|
187
|
-
{ followEnd: true },
|
|
188
|
-
);
|
|
189
|
-
private running = false;
|
|
190
|
-
private progressText = "";
|
|
191
|
-
private full = false;
|
|
192
|
-
private model = "";
|
|
193
|
-
private customMode = "";
|
|
194
|
-
private disposed = false;
|
|
195
|
-
onInput?: () => void;
|
|
196
|
-
onKey?: (data: string) => boolean;
|
|
197
|
-
private suggestions = "";
|
|
198
|
-
|
|
199
|
-
setSuggestions(text: string): void {
|
|
200
|
-
this.suggestions = text;
|
|
201
|
-
this.tui.requestRender();
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
get focused(): boolean {
|
|
205
|
-
return this._focused;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
set focused(value: boolean) {
|
|
209
|
-
this._focused = value;
|
|
210
|
-
this.input.focused = value;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
constructor(
|
|
214
|
-
private readonly tui: TuiLike,
|
|
215
|
-
private readonly theme: Theme,
|
|
216
|
-
private readonly onClose: () => void,
|
|
217
|
-
private readonly onSubmit: (value: string) => void,
|
|
218
|
-
private readonly onDispose: () => void,
|
|
219
|
-
private readonly appearance: { title?: string; commands?: string; inputLabel?: string; idleHint?: string } = {},
|
|
220
|
-
) {
|
|
221
|
-
this.input.onSubmit = (value) => {
|
|
222
|
-
if (!this.running) this.onSubmit(value);
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
// Keeps the reader's place; the scroller clamps when the text shrinks (e.g. /clear).
|
|
227
|
-
setText(text: string): void {
|
|
228
|
-
this.markdown.setText(text);
|
|
229
|
-
this.tui.requestRender();
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/** Start at the top of a static or single-document view. */
|
|
233
|
-
scrollToStart(): void {
|
|
234
|
-
this.scroller.toStart();
|
|
235
|
-
this.tui.requestRender();
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/** Show the newest text and keep following it while a reply streams. */
|
|
239
|
-
scrollToEnd(): void {
|
|
240
|
-
this.scroller.toEnd();
|
|
241
|
-
this.tui.requestRender();
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
get notice(): string {
|
|
245
|
-
return this.noticeText;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
set notice(notice: string) {
|
|
249
|
-
this.setNotice(notice);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
setNotice(notice: string, tone: NoticeTone = "info"): void {
|
|
253
|
-
if (this.disposed) return;
|
|
254
|
-
this.noticeText = notice;
|
|
255
|
-
this.noticeTone = tone;
|
|
256
|
-
this.tui.requestRender();
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
setRunning(running: boolean): void {
|
|
260
|
-
this.running = running;
|
|
261
|
-
if (!running) this.progressText = "";
|
|
262
|
-
this.tui.requestRender();
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
/** Ephemeral in-flight status; never enters the thread or clipboard. */
|
|
266
|
-
setProgress(text: string): void {
|
|
267
|
-
if (this.disposed || !this.running) return;
|
|
268
|
-
this.progressText = text;
|
|
269
|
-
this.tui.requestRender();
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
setModel(model: string): void {
|
|
273
|
-
this.model = model;
|
|
274
|
-
this.tui.requestRender();
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
setFull(full: boolean): void {
|
|
278
|
-
this.full = full;
|
|
279
|
-
this.tui.requestRender();
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
/** Reuse the BTW modal for independent interview flows without sharing BTW state. */
|
|
283
|
-
setCustomMode(label: string): void {
|
|
284
|
-
this.customMode = label;
|
|
285
|
-
this.tui.requestRender();
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
clearComposer(): void {
|
|
289
|
-
this.input.setValue("");
|
|
290
|
-
this.tui.requestRender();
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
getComposerText(): string {
|
|
294
|
-
return this.input.getValue();
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
setComposerText(text: string): void {
|
|
298
|
-
this.input.setValue(text);
|
|
299
|
-
(this.input as unknown as { cursor: number }).cursor = text.length;
|
|
300
|
-
this.tui.requestRender();
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
invalidate(): void {
|
|
304
|
-
this.markdown.invalidate();
|
|
305
|
-
this.input.invalidate();
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
handleMouse(event: BroMouseEvent): BroMouseResult {
|
|
309
|
-
return this.scroller.handleMouse(event);
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
handleInput(data: string): void {
|
|
313
|
-
if (this.onKey?.(data)) return;
|
|
314
|
-
if (matchesKey(data, "escape")) {
|
|
315
|
-
this.onClose();
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
if (this.scroller.handleKey(data, this.rawArea)) return;
|
|
319
|
-
this.input.handleInput(data);
|
|
320
|
-
this.onInput?.();
|
|
321
|
-
this.tui.requestRender();
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
render(width: number): string[] {
|
|
325
|
-
const inner = Math.max(1, width - 2);
|
|
326
|
-
const height = modalHeight(this.tui, BRO_OVERLAY, 34);
|
|
327
|
-
this.rawArea = broOverlayArea(this.tui, width, height);
|
|
328
|
-
return renderFrame(this.theme, width, height, {
|
|
329
|
-
header: () => {
|
|
330
|
-
const scroll = this.scroller.indicator();
|
|
331
|
-
const model = this.model ? this.theme.fg("dim", ` · ${this.model}`) : "";
|
|
332
|
-
const mode = this.customMode
|
|
333
|
-
? this.theme.fg("dim", this.customMode)
|
|
334
|
-
: this.theme.fg("dim", " · ") + (this.full ? this.theme.fg("accent", this.theme.bold(btwModeLabel(true))) : this.theme.fg("dim", btwModeLabel(false)));
|
|
335
|
-
const title = this.theme.fg("accent", this.theme.bold(this.appearance.title ?? "Bro · btw"));
|
|
336
|
-
// Keep Grill's access warning ahead of text the frame may truncate.
|
|
337
|
-
const header = this.customMode ? `${mode} · ${title}${model}` : title + model + mode;
|
|
338
|
-
return header + this.theme.fg("dim", scroll ? ` · ${scroll}` : "");
|
|
339
|
-
},
|
|
340
|
-
body: (rows, innerWidth) => this.scroller.view(this.markdown.render(innerWidth), rows),
|
|
341
|
-
// The frame drops lines from the top when space runs out, so the composer goes last.
|
|
342
|
-
footer: [
|
|
343
|
-
...(this.appearance.commands === "" ? [] : wrapTextWithAnsi(this.appearance.commands ?? "Commands: /mode · /copy · /copy-all · /clear · /retry · /help", inner)),
|
|
344
|
-
...(this.suggestions ? wrapTextWithAnsi(this.theme.fg("accent", this.suggestions), inner) : []),
|
|
345
|
-
this.theme.fg("accent", this.theme.bold(this.appearance.inputLabel ?? "Your message to Bro")),
|
|
346
|
-
this.input.render(inner)[0] ?? "",
|
|
347
|
-
],
|
|
348
|
-
notice: this.noticeText ? formatNotice(this.theme, this.noticeText, this.noticeTone) : undefined,
|
|
349
|
-
// A tool label may be long. Preserve the elapsed seconds and Esc
|
|
350
|
-
// on one line; shorten only the stage so transcript height stays put.
|
|
351
|
-
hints: this.running
|
|
352
|
-
? runningHint(this.progressText || "Bro is thinking…", inner, [
|
|
353
|
-
" · Esc close (stops reply)", " · Esc close",
|
|
354
|
-
])
|
|
355
|
-
: (this.appearance.idleHint ?? "Enter send · Esc close"),
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
dispose(): void {
|
|
360
|
-
if (this.disposed) return;
|
|
361
|
-
this.disposed = true;
|
|
362
|
-
this.onDispose();
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
|
|
366
173
|
export async function openBtwModal(
|
|
367
174
|
ctx: ExtensionCommandContext,
|
|
368
175
|
options: { thread: BtwThread; initialQuestion?: string; onChange?: () => void },
|
|
@@ -418,7 +225,7 @@ export async function openBtwModal(
|
|
|
418
225
|
done(undefined);
|
|
419
226
|
};
|
|
420
227
|
|
|
421
|
-
const modal = new
|
|
228
|
+
const modal = new ComposerModal(tui, theme, close, submit, () => {
|
|
422
229
|
if (closed) return; // Close already saved and cleaned this thread.
|
|
423
230
|
closed = true;
|
|
424
231
|
saveDraft();
|
|
@@ -426,6 +233,10 @@ export async function openBtwModal(
|
|
|
426
233
|
controller?.abort();
|
|
427
234
|
discardUnfinished();
|
|
428
235
|
options.onChange?.();
|
|
236
|
+
}, {
|
|
237
|
+
title: "Bro · btw",
|
|
238
|
+
commands: "Commands: /mode · /copy · /copy-all · /clear · /retry · /help",
|
|
239
|
+
inputLabel: "Your message to Bro",
|
|
429
240
|
});
|
|
430
241
|
modal.onInput = () => {
|
|
431
242
|
composerTouched = true;
|
|
@@ -571,7 +382,7 @@ export async function openBtwModal(
|
|
|
571
382
|
|
|
572
383
|
const toggleMode = () => {
|
|
573
384
|
toggleBtwMode(thread);
|
|
574
|
-
modal.
|
|
385
|
+
modal.setTrailingMode(btwModeLabel(thread.full), thread.full);
|
|
575
386
|
modal.setNotice(`Mode: ${btwModeLabel(thread.full)}`, "info");
|
|
576
387
|
options.onChange?.();
|
|
577
388
|
};
|
|
@@ -653,7 +464,7 @@ export async function openBtwModal(
|
|
|
653
464
|
void runTurn(action.text);
|
|
654
465
|
}
|
|
655
466
|
|
|
656
|
-
modal.
|
|
467
|
+
modal.setTrailingMode(btwModeLabel(thread.full), thread.full);
|
|
657
468
|
modal.setModel(btwHeaderLabel(thread));
|
|
658
469
|
modal.setText(transcript());
|
|
659
470
|
modal.scrollToEnd();
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { getMarkdownTheme } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { Input, Markdown, matchesKey, wrapTextWithAnsi, type Focusable } from "@earendil-works/pi-tui";
|
|
3
|
+
import { BRO_OVERLAY, broOverlayArea, formatNotice, modalHeight, renderFrame, runningHint, Scroller, type Area, type NoticeTone, type Theme, type TuiLike } from "./modal-kit.ts";
|
|
4
|
+
import type { BroMouseEvent, BroMouseResult } from "./ui-capabilities.ts";
|
|
5
|
+
|
|
6
|
+
export class ComposerModal implements Focusable {
|
|
7
|
+
private _focused = false;
|
|
8
|
+
private readonly markdown = new Markdown("", 0, 0, getMarkdownTheme());
|
|
9
|
+
private readonly input = new Input();
|
|
10
|
+
private noticeText = "";
|
|
11
|
+
private noticeTone: NoticeTone = "info";
|
|
12
|
+
private rawArea: Area | undefined;
|
|
13
|
+
// Follows the newest text until the reader scrolls up; scrolling back to the end follows again.
|
|
14
|
+
private readonly scroller = new Scroller(
|
|
15
|
+
() => {
|
|
16
|
+
this.noticeText = "";
|
|
17
|
+
this.tui.requestRender();
|
|
18
|
+
},
|
|
19
|
+
{ followEnd: true },
|
|
20
|
+
);
|
|
21
|
+
private running = false;
|
|
22
|
+
private progressText = "";
|
|
23
|
+
private trailingMode?: { label: string; emphasized: boolean };
|
|
24
|
+
private model = "";
|
|
25
|
+
private customMode = "";
|
|
26
|
+
private disposed = false;
|
|
27
|
+
onInput?: () => void;
|
|
28
|
+
onKey?: (data: string) => boolean;
|
|
29
|
+
private suggestions = "";
|
|
30
|
+
|
|
31
|
+
setSuggestions(text: string): void {
|
|
32
|
+
this.suggestions = text;
|
|
33
|
+
this.tui.requestRender();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
get focused(): boolean {
|
|
37
|
+
return this._focused;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
set focused(value: boolean) {
|
|
41
|
+
this._focused = value;
|
|
42
|
+
this.input.focused = value;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
constructor(
|
|
46
|
+
private readonly tui: TuiLike,
|
|
47
|
+
private readonly theme: Theme,
|
|
48
|
+
private readonly onClose: () => void,
|
|
49
|
+
private readonly onSubmit: (value: string) => void,
|
|
50
|
+
private readonly onDispose: () => void,
|
|
51
|
+
private readonly appearance: { title?: string; commands?: string; inputLabel?: string; idleHint?: string | (() => string) } = {},
|
|
52
|
+
) {
|
|
53
|
+
this.input.onSubmit = (value) => {
|
|
54
|
+
if (!this.running) this.onSubmit(value);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Keeps the reader's place; the scroller clamps when the text shrinks (e.g. /clear).
|
|
59
|
+
setText(text: string): void {
|
|
60
|
+
this.markdown.setText(text);
|
|
61
|
+
this.tui.requestRender();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Start at the top of a static or single-document view. */
|
|
65
|
+
scrollToStart(): void {
|
|
66
|
+
this.scroller.toStart();
|
|
67
|
+
this.tui.requestRender();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Show the newest text and keep following it while a reply streams. */
|
|
71
|
+
scrollToEnd(): void {
|
|
72
|
+
this.scroller.toEnd();
|
|
73
|
+
this.tui.requestRender();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
get notice(): string {
|
|
77
|
+
return this.noticeText;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
set notice(notice: string) {
|
|
81
|
+
this.setNotice(notice);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
setNotice(notice: string, tone: NoticeTone = "info"): void {
|
|
85
|
+
if (this.disposed) return;
|
|
86
|
+
this.noticeText = notice;
|
|
87
|
+
this.noticeTone = tone;
|
|
88
|
+
this.tui.requestRender();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
setRunning(running: boolean): void {
|
|
92
|
+
this.running = running;
|
|
93
|
+
if (!running) this.progressText = "";
|
|
94
|
+
this.tui.requestRender();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Ephemeral in-flight status; never enters the thread or clipboard. */
|
|
98
|
+
setProgress(text: string): void {
|
|
99
|
+
if (this.disposed || !this.running) return;
|
|
100
|
+
this.progressText = text;
|
|
101
|
+
this.tui.requestRender();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
setModel(model: string): void {
|
|
105
|
+
this.model = model;
|
|
106
|
+
this.tui.requestRender();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
setTrailingMode(label: string, emphasized = false): void {
|
|
110
|
+
this.trailingMode = { label, emphasized };
|
|
111
|
+
this.tui.requestRender();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
setCustomMode(label: string): void {
|
|
115
|
+
this.customMode = label;
|
|
116
|
+
this.tui.requestRender();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
clearComposer(): void {
|
|
120
|
+
this.input.setValue("");
|
|
121
|
+
this.tui.requestRender();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
getComposerText(): string {
|
|
125
|
+
return this.input.getValue();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
setComposerText(text: string): void {
|
|
129
|
+
this.input.setValue(text);
|
|
130
|
+
(this.input as unknown as { cursor: number }).cursor = text.length;
|
|
131
|
+
this.tui.requestRender();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
invalidate(): void {
|
|
135
|
+
this.markdown.invalidate();
|
|
136
|
+
this.input.invalidate();
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
handleMouse(event: BroMouseEvent): BroMouseResult {
|
|
140
|
+
return this.scroller.handleMouse(event);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
handleInput(data: string): void {
|
|
144
|
+
if (this.onKey?.(data)) return;
|
|
145
|
+
if (matchesKey(data, "escape")) {
|
|
146
|
+
this.onClose();
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
if (this.scroller.handleKey(data, this.rawArea)) return;
|
|
150
|
+
this.input.handleInput(data);
|
|
151
|
+
this.onInput?.();
|
|
152
|
+
this.tui.requestRender();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
render(width: number): string[] {
|
|
156
|
+
const inner = Math.max(1, width - 2);
|
|
157
|
+
const height = modalHeight(this.tui, BRO_OVERLAY, 34);
|
|
158
|
+
this.rawArea = broOverlayArea(this.tui, width, height);
|
|
159
|
+
return renderFrame(this.theme, width, height, {
|
|
160
|
+
header: () => {
|
|
161
|
+
const scroll = this.scroller.indicator();
|
|
162
|
+
const model = this.model ? this.theme.fg("dim", ` · ${this.model}`) : "";
|
|
163
|
+
const mode = this.customMode
|
|
164
|
+
? this.theme.fg("dim", this.customMode)
|
|
165
|
+
: this.trailingMode
|
|
166
|
+
? this.theme.fg("dim", " · ") + (this.trailingMode.emphasized ? this.theme.fg("accent", this.theme.bold(this.trailingMode.label)) : this.theme.fg("dim", this.trailingMode.label))
|
|
167
|
+
: "";
|
|
168
|
+
const title = this.theme.fg("accent", this.theme.bold(this.appearance.title ?? "Bro"));
|
|
169
|
+
// A leading label stays visible when the title and model must be truncated.
|
|
170
|
+
const header = this.customMode ? `${mode} · ${title}${model}` : title + model + mode;
|
|
171
|
+
return header + this.theme.fg("dim", scroll ? ` · ${scroll}` : "");
|
|
172
|
+
},
|
|
173
|
+
body: (rows, innerWidth) => this.scroller.view(this.markdown.render(innerWidth), rows),
|
|
174
|
+
// The frame drops lines from the top when space runs out, so the composer goes last.
|
|
175
|
+
footer: [
|
|
176
|
+
...(this.appearance.commands ? wrapTextWithAnsi(this.appearance.commands, inner) : []),
|
|
177
|
+
...(this.suggestions ? wrapTextWithAnsi(this.theme.fg("accent", this.suggestions), inner) : []),
|
|
178
|
+
this.theme.fg("accent", this.theme.bold(this.appearance.inputLabel ?? "Your message")),
|
|
179
|
+
this.input.render(inner)[0] ?? "",
|
|
180
|
+
],
|
|
181
|
+
notice: this.noticeText ? formatNotice(this.theme, this.noticeText, this.noticeTone) : undefined,
|
|
182
|
+
// A tool label may be long. Preserve the elapsed seconds and Esc
|
|
183
|
+
// on one line; shorten only the stage so transcript height stays put.
|
|
184
|
+
hints: this.running
|
|
185
|
+
? runningHint(this.progressText || "Bro is thinking…", inner, [
|
|
186
|
+
" · Esc close (stops reply)", " · Esc close",
|
|
187
|
+
])
|
|
188
|
+
: (typeof this.appearance.idleHint === "function" ? this.appearance.idleHint() : this.appearance.idleHint ?? "Enter send · Esc close"),
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
dispose(): void {
|
|
193
|
+
if (this.disposed) return;
|
|
194
|
+
this.disposed = true;
|
|
195
|
+
this.onDispose();
|
|
196
|
+
}
|
|
197
|
+
}
|