durable-chat 1.0.0 → 1.0.2
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/README.md +95 -17
- package/dist/config.js +10 -1
- package/dist/jobs.js +34 -1
- package/dist/tool.js +5 -27
- package/dist/tui/app.js +294 -165
- package/dist/tui/clipboard.js +78 -0
- package/dist/tui/composer.js +53 -0
- package/dist/tui/format.js +40 -16
- package/dist/tui/markdown-copy.js +97 -0
- package/dist/tui/selection.js +44 -4
- package/dist/tui/transcript.js +4 -4
- package/package.json +1 -1
package/dist/tui/app.js
CHANGED
|
@@ -1,28 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Input, matchesKey, stripTerminalSequences, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
|
|
1
|
+
import { isKeyRelease, matchesKey, stripTerminalSequences, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
|
|
3
2
|
import { getNativeClipboard } from "@earendil-works/pi-tui";
|
|
4
3
|
import { withCancel } from "@earendil-works/chord/context";
|
|
5
4
|
import { selectModel } from "../models.js";
|
|
6
5
|
import { rollbackChoices, rollbackSource } from "../rollback.js";
|
|
7
|
-
import { describeConfig } from "../config.js";
|
|
6
|
+
import { describeConfig, setConfigValue } from "../config.js";
|
|
8
7
|
import { parseId } from "../commands.js";
|
|
9
8
|
import { jobView } from "../format.js";
|
|
10
|
-
import { announceJobStart, compactConversation, createJobInCommit, findJobConversation, jobConversationId, jobCreateOptionsOf, jobRecord, jobInputDraft, normalizeBrief, scanJobs, } from "../jobs.js";
|
|
9
|
+
import { announceJobStart, compactConversation, createJobInCommit, findJobConversation, jobConversationId, jobCreateOptionsOf, jobRecord, jobInputDraft, queueJobSteering, normalizeBrief, scanJobs, } from "../jobs.js";
|
|
11
10
|
import { buildJobRows, clampScroll, filterJobs, moveSelection, reconcileJobSelection, targetLabel } from "./state.js";
|
|
12
|
-
import { backgroundLine, bold, dim, fg, padLines, shortenHome, statusText, usageTotals, ACCENT,
|
|
11
|
+
import { transcriptLine, backgroundLine, bold, dim, fg, padLines, shortenHome, statusText, usageTotals, ACCENT, COMPOSER_BG, GREEN, MUTED, RED, TEXT, TRANSCRIPT_BG, YELLOW } from "./format.js";
|
|
13
12
|
import { attachmentLabel, createImagePaster, MAX_ATTACHMENTS } from "../images.js";
|
|
14
13
|
import { compactionLimit, contextPercent, formatTokenCount } from "../context-usage.js";
|
|
15
14
|
import { Transcript } from "./transcript.js";
|
|
16
15
|
import { overlayDialog } from "./dialog.js";
|
|
17
16
|
import { JOB_KIND } from "../tasks.js";
|
|
18
17
|
import { TranscriptSelection } from "./selection.js";
|
|
18
|
+
import { createTextCopier, copyNotice } from "./clipboard.js";
|
|
19
19
|
import { openBrowser } from "./browser.js";
|
|
20
|
+
import { Composer, isComposerNewline, isComposerQueue } from "./composer.js";
|
|
20
21
|
const FLASH_MS = 5000;
|
|
21
22
|
const QUIT_REPEAT_MS = 1500;
|
|
22
23
|
const CHROME_ROWS = 8; // Header + spacer, status spacer + status, three composer rows, and hint.
|
|
23
24
|
const PANE_HEADING_ROWS = 2; // Title + spacer.
|
|
24
25
|
const MIN_ROWS = CHROME_ROWS + PANE_HEADING_ROWS + 1;
|
|
25
26
|
const JOB_ROW_HEIGHT = 3; // Status, brief, and a spacer between jobs.
|
|
27
|
+
const CONTEXT_BREAKPOINT = 140;
|
|
28
|
+
const MIN_CONTEXT_WIDTH = 26;
|
|
29
|
+
const MIN_TRANSCRIPT_WITH_CONTEXT = 80;
|
|
26
30
|
function shortcut(keys, description) {
|
|
27
31
|
return `${bold(keys.toUpperCase())} ${fg(description, MUTED)}`;
|
|
28
32
|
}
|
|
@@ -30,6 +34,7 @@ function shortcut(keys, description) {
|
|
|
30
34
|
export class Dashboard {
|
|
31
35
|
capturesViewportInput = true;
|
|
32
36
|
selection;
|
|
37
|
+
copyText;
|
|
33
38
|
runtime;
|
|
34
39
|
rowsOf;
|
|
35
40
|
requestRender;
|
|
@@ -42,11 +47,8 @@ export class Dashboard {
|
|
|
42
47
|
onEditConfig;
|
|
43
48
|
paster;
|
|
44
49
|
attachments = [];
|
|
45
|
-
input
|
|
46
|
-
|
|
47
|
-
placeholder: "type a message or Ctrl-N for a job",
|
|
48
|
-
placeholderStyle: (text) => fg(text, BORDER, { dim: true }),
|
|
49
|
-
});
|
|
50
|
+
input;
|
|
51
|
+
composerHeight = 3;
|
|
50
52
|
state = {
|
|
51
53
|
focus: "composer",
|
|
52
54
|
target: { kind: "main" },
|
|
@@ -54,7 +56,6 @@ export class Dashboard {
|
|
|
54
56
|
filter: "",
|
|
55
57
|
showFinished: true,
|
|
56
58
|
toolsExpanded: false,
|
|
57
|
-
steer: false,
|
|
58
59
|
};
|
|
59
60
|
main;
|
|
60
61
|
current;
|
|
@@ -66,7 +67,12 @@ export class Dashboard {
|
|
|
66
67
|
scroll = 0;
|
|
67
68
|
jobsScroll;
|
|
68
69
|
contextScroll = 0;
|
|
69
|
-
|
|
70
|
+
/** Display state is independent of the composer/action target while browsing jobs. */
|
|
71
|
+
displayTarget = { kind: "main" };
|
|
72
|
+
displayConversationId;
|
|
73
|
+
previewJobId;
|
|
74
|
+
displayLoad;
|
|
75
|
+
displayCancel;
|
|
70
76
|
lastWidth = 120;
|
|
71
77
|
toast;
|
|
72
78
|
actionLabel;
|
|
@@ -87,17 +93,17 @@ export class Dashboard {
|
|
|
87
93
|
scanning = false;
|
|
88
94
|
scanAgain = false;
|
|
89
95
|
started = false;
|
|
90
|
-
|
|
96
|
+
stopping = false;
|
|
97
|
+
displayVersion = 0;
|
|
91
98
|
quitRequested = false;
|
|
92
99
|
quitArmedAt;
|
|
93
100
|
quitArmTimer;
|
|
94
101
|
constructor(options) {
|
|
95
|
-
this.
|
|
96
|
-
|
|
97
|
-
return true;
|
|
98
|
-
}), (result) => this.flash(result === true ? "copied to clipboard" : typeof result === "string" ? result : "Copy failed", result === true ? "info" : "error"), options.requestRender, options.openUrl ?? ((url) => { void openBrowser(url).catch((error) => this.flash(`Could not open link: ${message(error)}`, "error")); }));
|
|
102
|
+
this.copyText = options.copySelection ?? createTextCopier();
|
|
103
|
+
this.selection = new TranscriptSelection(this.copyText, (result) => { const notice = copyNotice(result); this.flash(notice.text, notice.kind); }, options.requestRender, options.openUrl ?? ((url) => { void openBrowser(url).catch((error) => this.flash(`Could not open link: ${message(error)}`, "error")); }));
|
|
99
104
|
this.runtime = options.runtime;
|
|
100
105
|
this.rowsOf = options.rows;
|
|
106
|
+
this.input = new Composer(options.rows, options.requestRender);
|
|
101
107
|
this.requestRender = options.requestRender;
|
|
102
108
|
this.onQuit = options.onQuit;
|
|
103
109
|
this.onReboot = options.onReboot;
|
|
@@ -111,6 +117,7 @@ export class Dashboard {
|
|
|
111
117
|
this.main.onUpdate = () => this.renderSoon();
|
|
112
118
|
}
|
|
113
119
|
async start() {
|
|
120
|
+
this.stopping = false;
|
|
114
121
|
await this.main.start(this.runtime.context, this.runtime.config.contextWindow);
|
|
115
122
|
this.current = this.main;
|
|
116
123
|
await this.refreshJobs(true);
|
|
@@ -137,6 +144,9 @@ export class Dashboard {
|
|
|
137
144
|
async stop() {
|
|
138
145
|
this.selection.reset();
|
|
139
146
|
this.started = false;
|
|
147
|
+
this.stopping = true;
|
|
148
|
+
this.displayVersion++;
|
|
149
|
+
this.displayCancel?.();
|
|
140
150
|
this.modelController?.abort();
|
|
141
151
|
this.modelVersion++;
|
|
142
152
|
this.disarmQuit();
|
|
@@ -213,89 +223,130 @@ export class Dashboard {
|
|
|
213
223
|
applyView() {
|
|
214
224
|
const previous = this.visible;
|
|
215
225
|
this.visible = filterJobs(this.rowsAll, this.state.filter, this.state.showFinished);
|
|
216
|
-
|
|
226
|
+
// New arrivals must not move a row the user is currently reading.
|
|
227
|
+
const selectionTarget = this.previewJobId === undefined ? this.state.target : { kind: "job", id: this.previewJobId };
|
|
228
|
+
const selected = reconcileJobSelection(this.visible, previous, selectionTarget, this.state.selectedJobId);
|
|
217
229
|
if (selected !== this.state.selectedJobId)
|
|
218
230
|
this.jobsScroll = undefined;
|
|
219
231
|
this.state.selectedJobId = selected;
|
|
232
|
+
if (this.state.focus === "jobs" || this.previewJobId !== undefined)
|
|
233
|
+
this.previewSelected();
|
|
234
|
+
else if (this.current === undefined)
|
|
235
|
+
void this.showTarget(this.state.target);
|
|
220
236
|
}
|
|
221
|
-
|
|
222
|
-
this.
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
237
|
+
previewSelected() {
|
|
238
|
+
this.previewJobId = this.state.selectedJobId;
|
|
239
|
+
void this.showTarget(this.previewJobId === undefined ? this.state.target : { kind: "job", id: this.previewJobId });
|
|
240
|
+
}
|
|
241
|
+
setFocus(focus) {
|
|
242
|
+
this.state.focus = focus;
|
|
243
|
+
this.input.focused = focus === "composer";
|
|
244
|
+
if (focus === "jobs")
|
|
245
|
+
this.previewSelected();
|
|
246
|
+
else if (focus === "composer") {
|
|
247
|
+
this.previewJobId = undefined;
|
|
248
|
+
void this.showTarget(this.state.target);
|
|
227
249
|
}
|
|
228
|
-
|
|
250
|
+
}
|
|
251
|
+
async pinMain() {
|
|
252
|
+
this.previewJobId = undefined;
|
|
229
253
|
this.state.target = { kind: "main" };
|
|
230
254
|
this.state.selectedJobId = reconcileJobSelection(this.visible, [], this.state.target, this.state.selectedJobId);
|
|
231
|
-
this.targetConversationId = undefined;
|
|
232
255
|
this.scroll = 0;
|
|
233
|
-
this.jobsScroll = undefined;
|
|
234
256
|
this.contextScroll = 0;
|
|
235
|
-
this.
|
|
257
|
+
this.jobsScroll = undefined;
|
|
258
|
+
await this.showTarget(this.state.target);
|
|
236
259
|
}
|
|
237
260
|
async pinJob(id) {
|
|
238
|
-
|
|
239
|
-
const row = this.rowsAll.find((item) => item.id === id);
|
|
261
|
+
this.previewJobId = undefined;
|
|
240
262
|
this.state.target = { kind: "job", id };
|
|
263
|
+
this.state.selectedJobId = id;
|
|
241
264
|
this.scroll = 0;
|
|
242
|
-
this.jobsScroll = undefined;
|
|
243
265
|
this.contextScroll = 0;
|
|
244
|
-
this.
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
if (
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
this.
|
|
255
|
-
|
|
256
|
-
return
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
return false;
|
|
265
|
-
}
|
|
266
|
+
this.jobsScroll = undefined;
|
|
267
|
+
return this.showTarget(this.state.target);
|
|
268
|
+
}
|
|
269
|
+
/** Only the displayed transcript changes here; never the send/action destination. */
|
|
270
|
+
showTarget(target) {
|
|
271
|
+
if (this.stopping)
|
|
272
|
+
return Promise.resolve(false);
|
|
273
|
+
const same = target.kind === this.displayTarget.kind
|
|
274
|
+
&& (target.kind === "main" || (this.displayTarget.kind === "job" && target.id === this.displayTarget.id));
|
|
275
|
+
if (same && this.displayLoad !== undefined)
|
|
276
|
+
return this.displayLoad;
|
|
277
|
+
if (same && this.current !== undefined)
|
|
278
|
+
return Promise.resolve(true);
|
|
279
|
+
const version = ++this.displayVersion;
|
|
280
|
+
this.displayCancel?.();
|
|
281
|
+
const cancellable = target.kind === "job" ? withCancel(this.runtime.context) : undefined;
|
|
282
|
+
this.displayCancel = cancellable?.cancel;
|
|
283
|
+
const context = cancellable?.context ?? this.runtime.context;
|
|
284
|
+
this.displayTarget = target;
|
|
285
|
+
this.displayConversationId = undefined;
|
|
266
286
|
const old = this.current;
|
|
267
|
-
|
|
268
|
-
transcript.onUpdate = () => this.renderSoon();
|
|
269
|
-
try {
|
|
270
|
-
await transcript.start(this.runtime.context, this.runtime.config.contextWindow);
|
|
271
|
-
}
|
|
272
|
-
catch (error) {
|
|
273
|
-
await transcript.stop();
|
|
274
|
-
this.current = undefined;
|
|
275
|
-
this.flash(`could not read the job transcript: ${message(error)}`, "error");
|
|
276
|
-
this.renderSoon();
|
|
277
|
-
return false;
|
|
278
|
-
}
|
|
279
|
-
if (version !== this.pinVersion) {
|
|
280
|
-
void transcript.stop();
|
|
281
|
-
return false;
|
|
282
|
-
}
|
|
287
|
+
this.current = target.kind === "main" ? this.main : undefined;
|
|
283
288
|
if (old !== undefined && old !== this.main)
|
|
284
289
|
void old.stop();
|
|
285
|
-
this.
|
|
290
|
+
this.selection.reset();
|
|
291
|
+
this.scroll = 0;
|
|
292
|
+
this.contextScroll = 0;
|
|
286
293
|
this.renderSoon();
|
|
287
|
-
|
|
294
|
+
const load = async () => {
|
|
295
|
+
if (target.kind === "main")
|
|
296
|
+
return true;
|
|
297
|
+
let transcript;
|
|
298
|
+
try {
|
|
299
|
+
const row = this.rowsAll.find((item) => item.id === target.id);
|
|
300
|
+
const conversationId = row?.conversationId ?? await jobConversationId(this.runtime.harness, target.id, context);
|
|
301
|
+
if (version !== this.displayVersion)
|
|
302
|
+
return false;
|
|
303
|
+
this.displayConversationId = conversationId;
|
|
304
|
+
if (conversationId === undefined)
|
|
305
|
+
return false; // Retried on job refresh once startup creates it.
|
|
306
|
+
const conversation = await this.runtime.harness.conversation(conversationId, context);
|
|
307
|
+
if (version !== this.displayVersion)
|
|
308
|
+
return false;
|
|
309
|
+
if (conversation === undefined)
|
|
310
|
+
throw new Error(`conversation #${conversationId} is unavailable`);
|
|
311
|
+
transcript = new Transcript(conversation);
|
|
312
|
+
transcript.onUpdate = () => { if (version === this.displayVersion)
|
|
313
|
+
this.renderSoon(); };
|
|
314
|
+
await transcript.start(context, this.runtime.config.contextWindow);
|
|
315
|
+
if (version !== this.displayVersion) {
|
|
316
|
+
await transcript.stop();
|
|
317
|
+
return false;
|
|
318
|
+
}
|
|
319
|
+
this.current = transcript;
|
|
320
|
+
return true;
|
|
321
|
+
}
|
|
322
|
+
catch (error) {
|
|
323
|
+
await transcript?.stop();
|
|
324
|
+
if (version === this.displayVersion)
|
|
325
|
+
this.flash(`could not read the job transcript: ${message(error)}`, "error");
|
|
326
|
+
return false;
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
this.displayLoad = load().finally(() => {
|
|
330
|
+
if (version === this.displayVersion) {
|
|
331
|
+
this.displayLoad = undefined;
|
|
332
|
+
this.renderSoon();
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
return this.displayLoad;
|
|
336
|
+
}
|
|
337
|
+
steerInput(target = this.state.target) {
|
|
338
|
+
return target.kind === "job" && (this.nodes.has(target.id) || this.records.get(target.id)?.state.status === "running");
|
|
288
339
|
}
|
|
289
340
|
async openSelected() {
|
|
290
341
|
const id = this.state.selectedJobId;
|
|
291
342
|
if (id === undefined)
|
|
292
343
|
return;
|
|
293
344
|
try {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
345
|
+
const loaded = this.pinJob(id);
|
|
346
|
+
// Activation is immediate, even during a slow preview read. Its completion must not steal focus.
|
|
347
|
+
this.setFocus("composer");
|
|
348
|
+
this.renderSoon();
|
|
349
|
+
await loaded;
|
|
299
350
|
}
|
|
300
351
|
catch (error) {
|
|
301
352
|
this.flash(message(error), "error");
|
|
@@ -328,16 +379,30 @@ export class Dashboard {
|
|
|
328
379
|
this.renderSoon();
|
|
329
380
|
}
|
|
330
381
|
resizeContext(delta) {
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
this.state.contextPane = Math.max(20, Math.min(max, current + delta));
|
|
382
|
+
const current = this.state.contextPane ?? (this.contextWidth(this.lastWidth) || 30);
|
|
383
|
+
this.state.contextPane = Math.max(MIN_CONTEXT_WIDTH, Math.min(48, current + delta));
|
|
334
384
|
this.renderSoon();
|
|
335
385
|
}
|
|
386
|
+
setContextPanel(visible = this.runtime.config.contextPanel === false) {
|
|
387
|
+
try {
|
|
388
|
+
// Edit the resolved highest-precedence file, not a lower global layer or conversation.
|
|
389
|
+
setConfigValue(this.runtime.config.configPath, "contextPanel", String(visible));
|
|
390
|
+
this.runtime.config.contextPanel = visible;
|
|
391
|
+
this.runtime.config.configFound = true;
|
|
392
|
+
if (!this.runtime.config.configPaths.includes(this.runtime.config.configPath))
|
|
393
|
+
this.runtime.config.configPaths.push(this.runtime.config.configPath);
|
|
394
|
+
this.flash(visible
|
|
395
|
+
? `Context panel enabled${this.contextWidth(this.lastWidth) === 0 ? " (hidden until there is room)" : ""}; saved`
|
|
396
|
+
: "Context panel off; saved");
|
|
397
|
+
}
|
|
398
|
+
catch (error) {
|
|
399
|
+
this.flash(`Could not save context panel preference: ${message(error)}`, "error");
|
|
400
|
+
}
|
|
401
|
+
}
|
|
336
402
|
beginPrompt(mode) {
|
|
337
403
|
this.state.mode = mode;
|
|
338
404
|
this.input.setValue("");
|
|
339
|
-
this.
|
|
340
|
-
this.input.focused = true;
|
|
405
|
+
this.setFocus("composer");
|
|
341
406
|
this.renderSoon();
|
|
342
407
|
}
|
|
343
408
|
cancelPrompt() {
|
|
@@ -413,7 +478,7 @@ export class Dashboard {
|
|
|
413
478
|
this.flash(`attached ${attachmentLabel(this.attachments)}`);
|
|
414
479
|
this.renderSoon();
|
|
415
480
|
}
|
|
416
|
-
async submit() {
|
|
481
|
+
async submit(followUp = false) {
|
|
417
482
|
const value = this.input.getValue();
|
|
418
483
|
const text = value.trim();
|
|
419
484
|
if (this.state.mode === "newJob") {
|
|
@@ -446,7 +511,7 @@ export class Dashboard {
|
|
|
446
511
|
this.runtime.harness.resume();
|
|
447
512
|
await this.refreshJobs();
|
|
448
513
|
await this.pinJob(Number(started.taskId));
|
|
449
|
-
this.
|
|
514
|
+
this.setFocus("transcript");
|
|
450
515
|
this.flash(notifyError === undefined
|
|
451
516
|
? `job #${started.taskId} started`
|
|
452
517
|
: `job #${started.taskId} started; main was not notified: ${notifyError}`, notifyError === undefined ? "info" : "error");
|
|
@@ -513,7 +578,9 @@ export class Dashboard {
|
|
|
513
578
|
if (text.length === 0 && this.attachments.length === 0)
|
|
514
579
|
return;
|
|
515
580
|
if (text.startsWith("/")) {
|
|
516
|
-
|
|
581
|
+
// Addressed job input retains its draft until admission succeeds.
|
|
582
|
+
if (!/^\/(?:send|steer)(?:\s|$)/i.test(text))
|
|
583
|
+
this.input.setValue("");
|
|
517
584
|
try {
|
|
518
585
|
await this.submitSlash(text);
|
|
519
586
|
}
|
|
@@ -528,29 +595,48 @@ export class Dashboard {
|
|
|
528
595
|
this.flash("images go to main only", "error");
|
|
529
596
|
return;
|
|
530
597
|
}
|
|
531
|
-
const attachments = this.attachments;
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
598
|
+
const attachments = [...this.attachments];
|
|
599
|
+
let steer = !followUp && this.steerInput(target);
|
|
600
|
+
const admitted = () => {
|
|
601
|
+
// Admission may finish after the user has begun editing the next draft.
|
|
602
|
+
if (this.input.getValue() === value)
|
|
603
|
+
this.input.setValue("");
|
|
604
|
+
this.attachments = this.attachments.filter((image) => !attachments.includes(image));
|
|
605
|
+
this.scroll = 0;
|
|
606
|
+
};
|
|
607
|
+
await this.runAction(`${steer ? "steering" : "queuing to"} ${targetLabel(target)}`, async (context) => {
|
|
537
608
|
if (target.kind === "main") {
|
|
538
609
|
const content = attachments.length === 0
|
|
539
|
-
?
|
|
540
|
-
: [...(text.length > 0 ? [{ type: "text", text }] : []), ...attachments.map((image) => ({ type: "image", data: image.data, mimeType: image.mimeType }))];
|
|
610
|
+
? value
|
|
611
|
+
: [...(text.length > 0 ? [{ type: "text", text: value }] : []), ...attachments.map((image) => ({ type: "image", data: image.data, mimeType: image.mimeType }))];
|
|
541
612
|
await this.runtime.root.submit({
|
|
542
613
|
type: "input",
|
|
543
614
|
content,
|
|
544
|
-
whenBusy:
|
|
615
|
+
whenBusy: steer ? "steer" : "followUp",
|
|
545
616
|
}, context);
|
|
546
|
-
|
|
617
|
+
admitted();
|
|
618
|
+
this.flash(steer ? "steered main" : "sent to main");
|
|
547
619
|
return;
|
|
548
620
|
}
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
621
|
+
if (!followUp) {
|
|
622
|
+
// Graph/list refresh is debounced; use the durable status for the automatic ingress default.
|
|
623
|
+
const job = await this.runtime.harness.getTask(target.id, context);
|
|
624
|
+
if (job === undefined || job.kind !== JOB_KIND)
|
|
625
|
+
throw new Error(`No job #${target.id}.`);
|
|
626
|
+
steer = job.state.status !== "terminal";
|
|
627
|
+
}
|
|
628
|
+
if (steer) {
|
|
629
|
+
await queueJobSteering(this.runtime.harness, target.id, value, context);
|
|
630
|
+
}
|
|
631
|
+
else {
|
|
632
|
+
const conversation = await findJobConversation(this.runtime.harness, target.id, context);
|
|
633
|
+
if (conversation === undefined)
|
|
634
|
+
throw new Error(`job #${target.id} has no conversation`);
|
|
635
|
+
// One-shot follow-up also continues completed conversations; it does not steer a live run.
|
|
636
|
+
await conversation.submit({ ...jobInputDraft(value, false), content: value }, context);
|
|
637
|
+
}
|
|
638
|
+
admitted();
|
|
639
|
+
this.flash(steer ? `steering queued for job #${target.id}; delivery at next boundary` : `follow-up queued for job #${target.id}`);
|
|
554
640
|
});
|
|
555
641
|
}
|
|
556
642
|
async submitSlash(text) {
|
|
@@ -566,6 +652,14 @@ export class Dashboard {
|
|
|
566
652
|
case "info":
|
|
567
653
|
this.state.mode = "inspector";
|
|
568
654
|
return;
|
|
655
|
+
case "context":
|
|
656
|
+
if (tail === "" || tail === "toggle")
|
|
657
|
+
this.setContextPanel();
|
|
658
|
+
else if (tail === "on" || tail === "off")
|
|
659
|
+
this.setContextPanel(tail === "on");
|
|
660
|
+
else
|
|
661
|
+
throw new Error("Usage: /context [on|off|toggle]");
|
|
662
|
+
return;
|
|
569
663
|
case "model": {
|
|
570
664
|
if (this.onModel === undefined)
|
|
571
665
|
throw new Error("Model switching is unavailable here.");
|
|
@@ -657,7 +751,7 @@ export class Dashboard {
|
|
|
657
751
|
return;
|
|
658
752
|
case "tasks":
|
|
659
753
|
await this.refreshJobs();
|
|
660
|
-
this.
|
|
754
|
+
this.setFocus(this.lastWidth >= 64 ? "jobs" : "transcript");
|
|
661
755
|
if (this.lastWidth < 64)
|
|
662
756
|
this.flash(`${this.visible.length} jobs: ${this.visible.map((row) => `#${row.id}`).join(", ") || "none"}`);
|
|
663
757
|
return;
|
|
@@ -670,7 +764,7 @@ export class Dashboard {
|
|
|
670
764
|
throw new Error(`No job #${id}.`);
|
|
671
765
|
if (!(await this.pinJob(id)))
|
|
672
766
|
return;
|
|
673
|
-
this.
|
|
767
|
+
this.setFocus("transcript");
|
|
674
768
|
if (command === "cancel")
|
|
675
769
|
this.requestCancel();
|
|
676
770
|
return;
|
|
@@ -691,11 +785,18 @@ export class Dashboard {
|
|
|
691
785
|
if (content.length === 0)
|
|
692
786
|
throw new Error(`Usage: /${command} <id> <message>`);
|
|
693
787
|
await this.runAction(`${command} job #${id}`, async (context) => {
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
788
|
+
if (command === "steer") {
|
|
789
|
+
await queueJobSteering(this.runtime.harness, id, content, context);
|
|
790
|
+
}
|
|
791
|
+
else {
|
|
792
|
+
const conversation = await findJobConversation(this.runtime.harness, id, context);
|
|
793
|
+
if (conversation === undefined)
|
|
794
|
+
throw new Error(`No conversation for job #${id}.`);
|
|
795
|
+
await conversation.submit(jobInputDraft(content, false), context);
|
|
796
|
+
}
|
|
797
|
+
if (this.input.getValue().trim() === text)
|
|
798
|
+
this.input.setValue("");
|
|
799
|
+
this.flash(command === "steer" ? `steering queued for job #${id}; delivery at next boundary` : `follow-up queued for job #${id}`);
|
|
699
800
|
});
|
|
700
801
|
return;
|
|
701
802
|
}
|
|
@@ -861,8 +962,7 @@ export class Dashboard {
|
|
|
861
962
|
this.pendingResetHandoff = undefined;
|
|
862
963
|
this.state.mode = "reset";
|
|
863
964
|
this.input.setValue("");
|
|
864
|
-
this.
|
|
865
|
-
this.input.focused = true;
|
|
965
|
+
this.setFocus("composer");
|
|
866
966
|
this.renderSoon();
|
|
867
967
|
}
|
|
868
968
|
requestAbortMain() {
|
|
@@ -875,7 +975,7 @@ export class Dashboard {
|
|
|
875
975
|
return [];
|
|
876
976
|
const lines = [...this.current.lines(width, this.state.toolsExpanded), ...this.current.liveLines(width)];
|
|
877
977
|
// A trailing entry spacer must not occupy the only content row in a short terminal.
|
|
878
|
-
while (lines.length > 0 && stripTerminalSequences(lines.at(-1)).trim().length === 0)
|
|
978
|
+
while (lines.length > 0 && stripTerminalSequences(lines.at(-1).text).trim().length === 0)
|
|
879
979
|
lines.pop();
|
|
880
980
|
return lines;
|
|
881
981
|
}
|
|
@@ -899,7 +999,7 @@ export class Dashboard {
|
|
|
899
999
|
return Math.max(1, this.bodyHeight() - PANE_HEADING_ROWS);
|
|
900
1000
|
}
|
|
901
1001
|
bodyHeight() {
|
|
902
|
-
return Math.max(3, Math.max(MIN_ROWS, Math.round(this.rowsOf())) - CHROME_ROWS);
|
|
1002
|
+
return Math.max(3, Math.max(MIN_ROWS, Math.round(this.rowsOf())) - CHROME_ROWS - (this.composerHeight - 3));
|
|
903
1003
|
}
|
|
904
1004
|
/** Shared by rendering, transcript wrapping and pointer hit testing after pane resizes. */
|
|
905
1005
|
paneWidths(width) {
|
|
@@ -926,15 +1026,16 @@ export class Dashboard {
|
|
|
926
1026
|
return Math.max(24, Math.min(30, Math.round(width * 0.22)));
|
|
927
1027
|
}
|
|
928
1028
|
contextWidth(width) {
|
|
929
|
-
if (this.
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
1029
|
+
if (this.runtime.config.contextPanel === false || width < CONTEXT_BREAKPOINT)
|
|
1030
|
+
return 0;
|
|
1031
|
+
const available = width - this.jobsWidth(width) - 2 - MIN_TRANSCRIPT_WITH_CONTEXT;
|
|
1032
|
+
if (available < MIN_CONTEXT_WIDTH)
|
|
1033
|
+
return 0;
|
|
1034
|
+
const preferred = this.state.contextPane ?? Math.max(MIN_CONTEXT_WIDTH, Math.min(36, Math.round(width * 0.2)));
|
|
1035
|
+
return Math.min(preferred, available);
|
|
935
1036
|
}
|
|
936
|
-
copy() {
|
|
937
|
-
const target = this.
|
|
1037
|
+
async copy() {
|
|
1038
|
+
const target = this.displayTarget;
|
|
938
1039
|
let text = "";
|
|
939
1040
|
if (target.kind === "job") {
|
|
940
1041
|
const record = this.records.get(target.id);
|
|
@@ -957,12 +1058,19 @@ export class Dashboard {
|
|
|
957
1058
|
this.flash("nothing to copy", "error");
|
|
958
1059
|
return;
|
|
959
1060
|
}
|
|
960
|
-
|
|
961
|
-
|
|
1061
|
+
try {
|
|
1062
|
+
const notice = copyNotice(await this.copyText(text));
|
|
1063
|
+
this.flash(notice.text, notice.kind);
|
|
1064
|
+
}
|
|
1065
|
+
catch {
|
|
1066
|
+
this.flash("Copy failed", "error");
|
|
1067
|
+
}
|
|
962
1068
|
}
|
|
963
1069
|
render(width) {
|
|
964
1070
|
this.lastWidth = width;
|
|
965
1071
|
const height = Math.max(MIN_ROWS, Math.round(this.rowsOf()));
|
|
1072
|
+
const composer = this.renderComposer(width);
|
|
1073
|
+
this.composerHeight = composer.length;
|
|
966
1074
|
const bodyHeight = this.bodyHeight();
|
|
967
1075
|
if (this.state.mode !== "chat")
|
|
968
1076
|
this.selection.update();
|
|
@@ -991,7 +1099,7 @@ export class Dashboard {
|
|
|
991
1099
|
...padLines(body, bodyHeight, width),
|
|
992
1100
|
" ".repeat(width),
|
|
993
1101
|
this.renderStatus(width),
|
|
994
|
-
...
|
|
1102
|
+
...composer,
|
|
995
1103
|
this.renderHint(width),
|
|
996
1104
|
].slice(0, height);
|
|
997
1105
|
if (this.state.mode === "confirmRollback")
|
|
@@ -1014,10 +1122,11 @@ export class Dashboard {
|
|
|
1014
1122
|
renderBody(width, height) {
|
|
1015
1123
|
const { jobsWidth, transcriptWidth, contextWidth } = this.paneWidths(width);
|
|
1016
1124
|
const jobs = jobsWidth > 0 ? padLines(this.renderJobs(jobsWidth, height), height, jobsWidth) : [];
|
|
1017
|
-
const
|
|
1125
|
+
const rows = this.renderTranscript(transcriptWidth, height);
|
|
1126
|
+
const transcript = padLines(rows.map((line) => line.text), height, transcriptWidth)
|
|
1018
1127
|
.map((line) => backgroundLine(line, transcriptWidth, TRANSCRIPT_BG));
|
|
1019
1128
|
if (this.state.mode === "chat") {
|
|
1020
|
-
this.selection.update({ x: jobsWidth > 0 ? jobsWidth + 1 : 0, y: 2 + PANE_HEADING_ROWS, width: transcriptWidth, lines: transcript.slice(PANE_HEADING_ROWS), source: this.current });
|
|
1129
|
+
this.selection.update({ x: jobsWidth > 0 ? jobsWidth + 1 : 0, y: 2 + PANE_HEADING_ROWS, width: transcriptWidth, lines: transcript.slice(PANE_HEADING_ROWS), copyBounds: rows.slice(PANE_HEADING_ROWS), source: this.current });
|
|
1021
1130
|
transcript.splice(PANE_HEADING_ROWS, height - PANE_HEADING_ROWS, ...this.selection.lines());
|
|
1022
1131
|
}
|
|
1023
1132
|
const context = contextWidth > 0 ? padLines(this.renderContext(contextWidth, height), height, contextWidth) : [];
|
|
@@ -1044,10 +1153,10 @@ export class Dashboard {
|
|
|
1044
1153
|
content.push("");
|
|
1045
1154
|
const selected = row.id === this.state.selectedJobId;
|
|
1046
1155
|
const marker = selected ? fg("▸", ACCENT) : " ";
|
|
1047
|
-
const id = `#${row.id
|
|
1156
|
+
const id = `#${String(row.id).padEnd(7)}`;
|
|
1048
1157
|
const state = truncateToWidth(compactJobStatus(row.status), 9).padEnd(9);
|
|
1049
1158
|
const age = row.startedAt === undefined ? "—" : compactDuration(Math.max(0, (row.endedAt ?? this.now()) - row.startedAt));
|
|
1050
|
-
const head = `${marker} ${selected ? bold(id) : id}${statusText(state)} ${dim(age.padStart(3))}`;
|
|
1159
|
+
const head = `${marker} ${selected ? bold(id) : id} ${statusText(state)} ${dim(age.padStart(3))}`;
|
|
1051
1160
|
content.push(truncateToWidth(head, width, "", true));
|
|
1052
1161
|
const briefWidth = Math.max(4, width - 3);
|
|
1053
1162
|
const origin = row.fork === undefined ? "" : `↳ ${row.fork.jobId === undefined ? "main" : `#${row.fork.jobId}`} · `;
|
|
@@ -1061,20 +1170,20 @@ export class Dashboard {
|
|
|
1061
1170
|
return [...lines, ...content.slice(start, start + Math.max(1, height - PANE_HEADING_ROWS))];
|
|
1062
1171
|
}
|
|
1063
1172
|
renderTranscript(width, height) {
|
|
1064
|
-
const target = targetLabel(this.
|
|
1173
|
+
const target = `${targetLabel(this.displayTarget)}${this.previewJobId === undefined ? "" : " (preview)"}`;
|
|
1065
1174
|
const live = this.current?.live;
|
|
1066
1175
|
const active = live?.generation !== undefined || live?.tools?.some((slot) => slot.status === "running") === true;
|
|
1067
1176
|
const title = `${bold("TRANSCRIPT")} ${dim(target)}${active ? fg(" ● live", GREEN) : ""}${this.scroll > 0 ? dim(` ↑${this.scroll}`) : ""}`;
|
|
1068
|
-
const lines = [truncateToWidth(title, width, "", true), ""];
|
|
1177
|
+
const lines = [transcriptLine(truncateToWidth(title, width, "", true)), transcriptLine("")];
|
|
1069
1178
|
const transcript = this.current;
|
|
1070
1179
|
if (transcript === undefined) {
|
|
1071
|
-
lines.push(dim(" No conversation is available for this job yet."));
|
|
1180
|
+
lines.push(transcriptLine(dim(this.displayLoad === undefined ? " No conversation is available for this job yet." : " Loading job transcript…"), 2));
|
|
1072
1181
|
return lines;
|
|
1073
1182
|
}
|
|
1074
1183
|
const contentHeight = Math.max(1, height - PANE_HEADING_ROWS);
|
|
1075
1184
|
const all = this.transcriptLines(width);
|
|
1076
1185
|
if (all.length === 0) {
|
|
1077
|
-
lines.push(dim(" No messages yet. Type below and press Enter."));
|
|
1186
|
+
lines.push(transcriptLine(dim(" No messages yet. Type below and press Enter."), 2));
|
|
1078
1187
|
return lines;
|
|
1079
1188
|
}
|
|
1080
1189
|
const offset = clampScroll(this.scroll, all.length, contentHeight);
|
|
@@ -1091,16 +1200,18 @@ export class Dashboard {
|
|
|
1091
1200
|
return [truncateToWidth(bold("CONTEXT"), width, "", true), "", ...content.slice(this.contextScroll, this.contextScroll + viewport)];
|
|
1092
1201
|
}
|
|
1093
1202
|
contextLines(width) {
|
|
1094
|
-
const target = this.
|
|
1203
|
+
const target = this.displayTarget;
|
|
1095
1204
|
const transcript = this.current;
|
|
1096
1205
|
const usage = usageTotals(transcript?.usage);
|
|
1097
1206
|
const live = transcript?.live;
|
|
1098
1207
|
const rows = [];
|
|
1099
|
-
rows.push(["target", targetLabel(target)]);
|
|
1208
|
+
rows.push(["target", targetLabel(this.state.target)]);
|
|
1209
|
+
if (this.previewJobId !== undefined)
|
|
1210
|
+
rows.push(["preview", targetLabel(target)]);
|
|
1100
1211
|
if (target.kind === "job") {
|
|
1101
1212
|
const row = this.rowsAll.find((item) => item.id === target.id);
|
|
1102
1213
|
rows.push(["status", row?.status ?? "unknown"]);
|
|
1103
|
-
const conversation = this.
|
|
1214
|
+
const conversation = this.displayConversationId ?? row?.conversationId;
|
|
1104
1215
|
rows.push(["conversation", conversation === undefined ? "…" : `#${conversation}`]);
|
|
1105
1216
|
rows.push(["brief", row?.brief ?? "(unknown)"]);
|
|
1106
1217
|
if (row?.tags?.length)
|
|
@@ -1155,9 +1266,8 @@ export class Dashboard {
|
|
|
1155
1266
|
const focus = dim(`focus ${this.state.focus}`);
|
|
1156
1267
|
const contextTokens = this.current?.contextTokens;
|
|
1157
1268
|
const window = this.runtime.config.contextWindow;
|
|
1158
|
-
const
|
|
1159
|
-
|
|
1160
|
-
: `ctx ~${formatTokenCount(contextTokens)}/${formatTokenCount(window)}`;
|
|
1269
|
+
const meter = contextTokens === undefined ? "ctx …" : `ctx ~${formatTokenCount(contextTokens)}/${formatTokenCount(window)}`;
|
|
1270
|
+
const context = this.previewJobId === undefined ? meter : `preview ${meter}`;
|
|
1161
1271
|
const line = ` ${dim("target")} ${bold(target)} ${focus} ${dim(context)}${activity}`;
|
|
1162
1272
|
return truncateToWidth(line, width, "", true);
|
|
1163
1273
|
}
|
|
@@ -1179,23 +1289,25 @@ export class Dashboard {
|
|
|
1179
1289
|
case "confirmAbortMain":
|
|
1180
1290
|
return "— › ";
|
|
1181
1291
|
default: {
|
|
1182
|
-
const steer = this.
|
|
1292
|
+
const steer = this.steerInput() ? " (steer)" : "";
|
|
1183
1293
|
return `to ${targetLabel(this.state.target)}${steer} › `;
|
|
1184
1294
|
}
|
|
1185
1295
|
}
|
|
1186
1296
|
}
|
|
1187
1297
|
renderComposer(width) {
|
|
1188
|
-
const prefix = ` ${this.composerPrefix()}
|
|
1298
|
+
const prefix = truncateToWidth(` ${this.composerPrefix()}`, Math.max(0, width - 3), "");
|
|
1189
1299
|
const active = this.state.focus === "composer"
|
|
1190
1300
|
&& this.state.mode !== "help"
|
|
1191
1301
|
&& this.state.mode !== "inspector"
|
|
1192
1302
|
&& !this.state.mode.startsWith("confirm");
|
|
1193
1303
|
this.input.focused = active;
|
|
1194
1304
|
const inner = Math.max(1, width - visibleWidth(prefix) - 1);
|
|
1195
|
-
const
|
|
1196
|
-
const
|
|
1197
|
-
|
|
1198
|
-
|
|
1305
|
+
const maxContentRows = Math.max(1, Math.max(MIN_ROWS, Math.round(this.rowsOf())) - CHROME_ROWS - PANE_HEADING_ROWS);
|
|
1306
|
+
const rendered = this.input.render(inner, maxContentRows);
|
|
1307
|
+
return rendered.map((line, index) => {
|
|
1308
|
+
const label = index === 1 ? fg(prefix, active ? ACCENT : MUTED) : " ".repeat(visibleWidth(prefix));
|
|
1309
|
+
return backgroundLine(`${label}${line}`, width, COMPOSER_BG);
|
|
1310
|
+
});
|
|
1199
1311
|
}
|
|
1200
1312
|
renderHint(width) {
|
|
1201
1313
|
let hint;
|
|
@@ -1219,11 +1331,11 @@ export class Dashboard {
|
|
|
1219
1331
|
else if (this.actionLabel !== undefined)
|
|
1220
1332
|
hint = shortcut("CTRL-C", "stop waiting (work stays durable)");
|
|
1221
1333
|
else if (this.state.focus === "composer")
|
|
1222
|
-
hint = [shortcut("ENTER", "send")
|
|
1334
|
+
hint = [shortcut("ENTER", this.state.target.kind === "main" ? "send" : this.steerInput() ? "steer" : "queue"), ...(this.state.target.kind === "job" && this.steerInput() ? [shortcut("CMD-SHIFT-ENTER", "queue")] : []), shortcut(this.input.getValue().length === 0 ? "?" : "TAB ?", "help"), shortcut("TAB", "focus"), shortcut("SHIFT-ENTER", "newline"), ...(this.attachments.length === 0 ? [] : [fg(`${this.attachments.length} attached`, YELLOW)])].join(separator);
|
|
1223
1335
|
else if (this.state.focus === "jobs")
|
|
1224
|
-
hint = [shortcut("
|
|
1336
|
+
hint = [shortcut("ENTER", "message"), shortcut("↑/↓ J/K", "preview"), shortcut("?", "help"), shortcut("TAB", "focus")].join(separator);
|
|
1225
1337
|
else
|
|
1226
|
-
hint = [shortcut("J/K", "scroll"), shortcut("
|
|
1338
|
+
hint = [shortcut("↑/↓ J/K", "scroll"), shortcut("?", "help"), shortcut("S", "compose"), shortcut("TAB", "focus")].join(separator);
|
|
1227
1339
|
if (this.scroll > 0 && this.state.focus === "transcript")
|
|
1228
1340
|
hint += dim(` · ↑${this.scroll}`);
|
|
1229
1341
|
return truncateToWidth(` ${hint}`, width, "", true);
|
|
@@ -1231,25 +1343,29 @@ export class Dashboard {
|
|
|
1231
1343
|
renderHelp(width, height) {
|
|
1232
1344
|
const bindings = [
|
|
1233
1345
|
["TAB / SHIFT-TAB", "cycle composer, jobs, transcript"],
|
|
1346
|
+
["CTRL-X", "toggle context pane (saved in active config)"],
|
|
1234
1347
|
["CTRL-T", "target main ↔ selected job"],
|
|
1235
1348
|
["CTRL-N", "new job brief"],
|
|
1236
|
-
["
|
|
1349
|
+
["SHIFT-ENTER", "insert a newline (Ctrl-J or Alt-Enter fallback); Enter sends"],
|
|
1350
|
+
["CMD-SHIFT-ENTER", "queue once from composer (if reported); /send <id> <text> fallback"],
|
|
1237
1351
|
["CTRL-V", "paste an image into the composer (main only)"],
|
|
1238
|
-
["ENTER", "send,
|
|
1352
|
+
["ENTER", "send input, or pin job and focus composer; confirm prompt"],
|
|
1353
|
+
["S (JOBS)", "pin highlighted job and compose; running jobs default to steer"],
|
|
1239
1354
|
["[ / ]", "resize the jobs pane"],
|
|
1240
1355
|
["{ / }", "resize the context pane"],
|
|
1241
1356
|
["0", "reset pane widths"],
|
|
1242
|
-
["J / K", "move job selection or scroll"],
|
|
1357
|
+
["↑ / ↓ or J / K", "move job selection or scroll (not while typing)"],
|
|
1243
1358
|
["WHEEL", "scroll the pane under the pointer"],
|
|
1244
1359
|
["G / SHIFT-G", "jump to oldest / newest"],
|
|
1245
1360
|
["N / C / M / SHIFT-R", "new · cancel · compact · reset"],
|
|
1246
|
-
["S / T / I / F / Y", "
|
|
1361
|
+
["S / T / I / F / Y", "compose · tools · inspector · finished · copy"],
|
|
1247
1362
|
["/", "filter jobs outside composer; commands inside"],
|
|
1248
1363
|
["CTRL-C", "stop waiting / clear prompt / close overlay"],
|
|
1249
1364
|
["CTRL-C ×2", "quit within 1.5s (confirms with live work)"],
|
|
1250
1365
|
];
|
|
1251
1366
|
return this.panel("Help", [
|
|
1252
1367
|
bold("Slash commands (composer)"),
|
|
1368
|
+
"/context off · /context on · /context toggle",
|
|
1253
1369
|
"/help · /info · /tasks · /task <id> · /log <id>",
|
|
1254
1370
|
"/new [brief] · /send <id> <text> · /steer <id> <text>",
|
|
1255
1371
|
"/cancel <id> · /compact [focus] · /reset [handoff]",
|
|
@@ -1285,7 +1401,7 @@ export class Dashboard {
|
|
|
1285
1401
|
`live jobs: ${this.rowsAll.filter((row) => row.live).length}`,
|
|
1286
1402
|
`context: ~${formatTokenCount(this.current?.contextTokens ?? 0)} / ${formatTokenCount(this.runtime.config.contextWindow)} ` +
|
|
1287
1403
|
`(compact at ~${formatTokenCount(compactionLimit(this.runtime.config.contextWindow))})`,
|
|
1288
|
-
|
|
1404
|
+
`${this.previewJobId === undefined ? "target" : "preview"} spend: ${formatTokenCount(usage.tokens)} tokens${usage.cost > 0 ? `, $${usage.cost.toFixed(4)}` : ""}`,
|
|
1289
1405
|
`job tools: ${this.runtime.jobExtensions.flatMap((extension) => extension.tools?.map((tool) => tool.name) ?? []).join(", ") || "(none)"}`,
|
|
1290
1406
|
...this.runtime.mcpNotes.slice(0, 8).map((note) => `mcp: ${note}`),
|
|
1291
1407
|
"",
|
|
@@ -1330,10 +1446,7 @@ export class Dashboard {
|
|
|
1330
1446
|
cycleFocus(backwards) {
|
|
1331
1447
|
const order = this.lastWidth < 64 ? ["composer", "transcript"] : ["composer", "jobs", "transcript"];
|
|
1332
1448
|
const index = Math.max(0, order.indexOf(this.state.focus));
|
|
1333
|
-
this.
|
|
1334
|
-
this.input.focused = this.state.focus === "composer";
|
|
1335
|
-
if (this.state.focus === "jobs" && this.state.selectedJobId === undefined)
|
|
1336
|
-
this.state.selectedJobId = this.visible[0]?.id;
|
|
1449
|
+
this.setFocus(order[(index + (backwards ? order.length - 1 : 1)) % order.length]);
|
|
1337
1450
|
this.renderSoon();
|
|
1338
1451
|
}
|
|
1339
1452
|
handleMouse(event) {
|
|
@@ -1369,6 +1482,9 @@ export class Dashboard {
|
|
|
1369
1482
|
return handled;
|
|
1370
1483
|
}
|
|
1371
1484
|
handleInput(data) {
|
|
1485
|
+
// TUI normally filters releases; keep direct dashboard delivery safe too.
|
|
1486
|
+
if (isKeyRelease(data))
|
|
1487
|
+
return;
|
|
1372
1488
|
this.selection.reset();
|
|
1373
1489
|
this.renderSoon();
|
|
1374
1490
|
if (matchesKey(data, "ctrl+c")) {
|
|
@@ -1406,6 +1522,11 @@ export class Dashboard {
|
|
|
1406
1522
|
this.cancelPrompt();
|
|
1407
1523
|
return;
|
|
1408
1524
|
}
|
|
1525
|
+
if ((this.state.focus === "composer" || this.state.mode !== "chat") && isComposerNewline(data)) {
|
|
1526
|
+
this.input.handleInput("\n");
|
|
1527
|
+
this.renderSoon();
|
|
1528
|
+
return;
|
|
1529
|
+
}
|
|
1409
1530
|
if (this.state.mode === "model") {
|
|
1410
1531
|
if (matchesKey(data, "escape"))
|
|
1411
1532
|
this.cancelPrompt();
|
|
@@ -1433,6 +1554,13 @@ export class Dashboard {
|
|
|
1433
1554
|
this.renderSoon();
|
|
1434
1555
|
return;
|
|
1435
1556
|
}
|
|
1557
|
+
// Ctrl-X is unused by the editor and has an unambiguous legacy control byte.
|
|
1558
|
+
// Keep only literal Meta-C as an alias: extended Alt-C matching can also
|
|
1559
|
+
// match printable non-Latin keys via Kitty's base-layout key fallback.
|
|
1560
|
+
if (matchesKey(data, "ctrl+x") || data === "\x1bc") {
|
|
1561
|
+
this.setContextPanel();
|
|
1562
|
+
return;
|
|
1563
|
+
}
|
|
1436
1564
|
if (matchesKey(data, "ctrl+t")) {
|
|
1437
1565
|
void this.toggleTarget();
|
|
1438
1566
|
return;
|
|
@@ -1441,14 +1569,9 @@ export class Dashboard {
|
|
|
1441
1569
|
this.beginPrompt("newJob");
|
|
1442
1570
|
return;
|
|
1443
1571
|
}
|
|
1444
|
-
if (matchesKey(data, "alt+s")) {
|
|
1445
|
-
this.state.steer = !this.state.steer;
|
|
1446
|
-
this.flash(this.state.steer
|
|
1447
|
-
? `${targetLabel(this.state.target)} input will steer the current run`
|
|
1448
|
-
: `${targetLabel(this.state.target)} input will queue as a follow-up`);
|
|
1449
|
-
return;
|
|
1450
|
-
}
|
|
1451
1572
|
if (this.state.focus === "composer") {
|
|
1573
|
+
if (isComposerQueue(data))
|
|
1574
|
+
return this.submit(true);
|
|
1452
1575
|
if (this.input.getValue().length === 0 && data === "?") {
|
|
1453
1576
|
this.state.mode = "help";
|
|
1454
1577
|
this.renderSoon();
|
|
@@ -1493,30 +1616,37 @@ export class Dashboard {
|
|
|
1493
1616
|
if (matchesKey(data, "escape")) {
|
|
1494
1617
|
if (this.state.target.kind === "job")
|
|
1495
1618
|
void this.pinMain();
|
|
1496
|
-
this.
|
|
1497
|
-
this.input.focused = true;
|
|
1619
|
+
this.setFocus("composer");
|
|
1498
1620
|
this.renderSoon();
|
|
1499
1621
|
return;
|
|
1500
1622
|
}
|
|
1501
1623
|
if (this.state.focus === "jobs") {
|
|
1502
1624
|
this.jobsScroll = undefined;
|
|
1625
|
+
if (data === "s") {
|
|
1626
|
+
void this.openSelected();
|
|
1627
|
+
return;
|
|
1628
|
+
}
|
|
1503
1629
|
if (matchesKey(data, "down") || data === "j") {
|
|
1504
1630
|
this.state.selectedJobId = moveSelection(this.visible, this.state.selectedJobId, 1);
|
|
1631
|
+
this.previewSelected();
|
|
1505
1632
|
this.renderSoon();
|
|
1506
1633
|
return;
|
|
1507
1634
|
}
|
|
1508
1635
|
if (matchesKey(data, "up") || data === "k") {
|
|
1509
1636
|
this.state.selectedJobId = moveSelection(this.visible, this.state.selectedJobId, -1);
|
|
1637
|
+
this.previewSelected();
|
|
1510
1638
|
this.renderSoon();
|
|
1511
1639
|
return;
|
|
1512
1640
|
}
|
|
1513
1641
|
if (data === "g") {
|
|
1514
1642
|
this.state.selectedJobId = this.visible[0]?.id;
|
|
1643
|
+
this.previewSelected();
|
|
1515
1644
|
this.renderSoon();
|
|
1516
1645
|
return;
|
|
1517
1646
|
}
|
|
1518
1647
|
if (data === "G") {
|
|
1519
1648
|
this.state.selectedJobId = this.visible.at(-1)?.id;
|
|
1649
|
+
this.previewSelected();
|
|
1520
1650
|
this.renderSoon();
|
|
1521
1651
|
return;
|
|
1522
1652
|
}
|
|
@@ -1595,8 +1725,7 @@ export class Dashboard {
|
|
|
1595
1725
|
return;
|
|
1596
1726
|
}
|
|
1597
1727
|
if (data === "s") {
|
|
1598
|
-
this.
|
|
1599
|
-
this.input.focused = true;
|
|
1728
|
+
this.setFocus("composer");
|
|
1600
1729
|
this.renderSoon();
|
|
1601
1730
|
return;
|
|
1602
1731
|
}
|
|
@@ -1627,7 +1756,7 @@ export class Dashboard {
|
|
|
1627
1756
|
return;
|
|
1628
1757
|
}
|
|
1629
1758
|
if (data === "y") {
|
|
1630
|
-
this.copy();
|
|
1759
|
+
void this.copy();
|
|
1631
1760
|
return;
|
|
1632
1761
|
}
|
|
1633
1762
|
if (data === "q") {
|