@oh-my-pi/pi-tui 18.12.3 → 18.12.4
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 +27 -48
- package/dist/types/render/output-block.d.ts +2 -0
- package/dist/types/render/tool-card.d.ts +2 -0
- package/dist/types/terminal-capabilities.d.ts +5 -0
- package/dist/types/tools/bash.d.ts +2 -0
- package/dist/types/tools/default-renderer.d.ts +3 -0
- package/dist/types/tools/eval.d.ts +9 -8
- package/dist/types/tools/json-tree.d.ts +2 -0
- package/dist/types/tools/line-ranges.d.ts +8 -1
- package/dist/types/tools/mcp.d.ts +23 -0
- package/dist/types/tools/read.d.ts +8 -2
- package/dist/types/tools/renderer.d.ts +8 -2
- package/dist/types/tools/result-card.d.ts +1 -1
- package/package.json +9 -9
- package/src/chat/tool-execution.ts +35 -0
- package/src/chrome/transcript-container.ts +85 -12
- package/src/components/markdown.ts +11 -3
- package/src/native/backend.ts +25 -5
- package/src/overlays/jobs-panel.ts +14 -2
- package/src/render/output-block.ts +25 -12
- package/src/render/tool-card.ts +6 -0
- package/src/terminal-capabilities.ts +39 -2
- package/src/tools/bash.ts +25 -9
- package/src/tools/default-renderer.ts +54 -17
- package/src/tools/eval.ts +32 -14
- package/src/tools/find.ts +4 -5
- package/src/tools/glob.ts +4 -6
- package/src/tools/grep.ts +4 -6
- package/src/tools/json-tree.ts +8 -0
- package/src/tools/line-ranges.ts +23 -13
- package/src/tools/mcp.ts +44 -1
- package/src/tools/read.ts +64 -21
- package/src/tools/renderer.ts +8 -2
- package/src/tools/result-card.ts +1 -2
- package/src/tools/wait.ts +208 -123
package/src/tools/wait.ts
CHANGED
|
@@ -351,6 +351,87 @@ function jobsRenderResult(
|
|
|
351
351
|
previewRows.set(job, { expanded, width: continuationWidth, lines });
|
|
352
352
|
return lines;
|
|
353
353
|
};
|
|
354
|
+
// Collapsed card: one line per settled job, or the bare "waiting on N jobs"
|
|
355
|
+
// header while nothing has settled. Repeated polls then read as a short
|
|
356
|
+
// completion log instead of a re-printed (and shrinking) job tree; Ctrl+O
|
|
357
|
+
// restores the full tree with output previews. A running job's live widget
|
|
358
|
+
// still draws its tile: that chart is the job's progress, not a copy of it.
|
|
359
|
+
const settledJobs = sortedJobs.filter(job => job.status !== "running");
|
|
360
|
+
const widgetJobs = sortedJobs.filter(job => job.status === "running" && job.widget?.state === "live");
|
|
361
|
+
const compactJobLines = (width: number, live: boolean): string[] => {
|
|
362
|
+
const lines: string[] = [];
|
|
363
|
+
const indent = " ".repeat(visibleWidth(formatStatusIcon("done", uiTheme)) + 1);
|
|
364
|
+
// Failures sort first, so the cap never hides one behind successes;
|
|
365
|
+
// Ctrl+O lists the rest.
|
|
366
|
+
for (const job of settledJobs.slice(0, PREVIEW_LIMITS.COLLAPSED_ITEMS)) {
|
|
367
|
+
const icon = formatStatusIcon(statusToIcon(job.status), uiTheme);
|
|
368
|
+
const word = job.status === "completed" ? "done" : job.status;
|
|
369
|
+
const exit =
|
|
370
|
+
job.exitCode !== undefined && job.exitCode !== 0
|
|
371
|
+
? `${uiTheme.sep.dot}${uiTheme.fg("error", `exit ${job.exitCode}`)}`
|
|
372
|
+
: "";
|
|
373
|
+
// The outcome (status, exit, duration) is reserved first; a long id
|
|
374
|
+
// gives way so a failure is never cut off the row.
|
|
375
|
+
const outcome = ` ${uiTheme.fg(statusToColor(job.status), word)}${exit}${uiTheme.sep.dot}${uiTheme.fg("dim", formatDuration(job.durationMs))}`;
|
|
376
|
+
const id = truncateToWidth(
|
|
377
|
+
replaceTabs(job.id).replace(/\s+/g, " "),
|
|
378
|
+
Math.max(1, width - visibleWidth(`${icon} `) - visibleWidth(outcome)),
|
|
379
|
+
Ellipsis.Unicode,
|
|
380
|
+
);
|
|
381
|
+
let line = `${icon} ${uiTheme.fg("accent", id)}${outcome}`;
|
|
382
|
+
const label = replaceTabs(jobRowLabel(job).split(/\r?\n/)[0] ?? "").trim();
|
|
383
|
+
const labelBudget = width - visibleWidth(line) - 2;
|
|
384
|
+
if (label && label !== job.id && labelBudget >= 8) {
|
|
385
|
+
line += ` ${uiTheme.fg("muted", truncateToWidth(label, labelBudget, Ellipsis.Unicode))}`;
|
|
386
|
+
}
|
|
387
|
+
lines.push(line);
|
|
388
|
+
// A failure says why on the collapsed row; the rest of its output
|
|
389
|
+
// stays behind Ctrl+O.
|
|
390
|
+
const reason =
|
|
391
|
+
job.status === "failed"
|
|
392
|
+
? stripOutputNotice(job.errorText ?? "", job.meta)
|
|
393
|
+
.split(/\r?\n/)
|
|
394
|
+
.find(part => part.trim())
|
|
395
|
+
?.trim()
|
|
396
|
+
: undefined;
|
|
397
|
+
if (reason) {
|
|
398
|
+
lines.push(
|
|
399
|
+
`${indent}${uiTheme.fg("error", truncateToWidth(replaceTabs(reason), Math.max(1, width - indent.length), Ellipsis.Unicode))}`,
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
// The root warning is suppressed when a row owns the failure, so the
|
|
403
|
+
// compact row carries it too — otherwise it only shows after Ctrl+O.
|
|
404
|
+
const artifactError = job.meta?.artifactError ?? job.artifactError;
|
|
405
|
+
if (artifactError) {
|
|
406
|
+
lines.push(uiTheme.fg("warning", truncateToWidth(formatArtifactErrorNotice(artifactError), width)));
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
const hiddenSettled = settledJobs.length - PREVIEW_LIMITS.COLLAPSED_ITEMS;
|
|
410
|
+
if (hiddenSettled > 0) lines.push(`${indent}${uiTheme.fg("dim", `… ${hiddenSettled} more settled`)}`);
|
|
411
|
+
const shownWidgetJobs = widgetJobs.slice(0, PREVIEW_LIMITS.COLLAPSED_ITEMS);
|
|
412
|
+
for (const job of shownWidgetJobs) {
|
|
413
|
+
const typeBadge = formatBadge(job.type, statusToColor(job.status), uiTheme);
|
|
414
|
+
const icon = formatStatusIcon("running", uiTheme, live ? options.spinnerFrame : undefined);
|
|
415
|
+
const meta = compact([
|
|
416
|
+
job.completionPercent !== undefined ? uiTheme.fg("accent", `${job.completionPercent}%`) : undefined,
|
|
417
|
+
uiTheme.fg("dim", formatDuration(job.durationMs)),
|
|
418
|
+
]).join(" ");
|
|
419
|
+
lines.push(
|
|
420
|
+
...renderJobTileLines(jobTile(job, live), width, uiTheme, {
|
|
421
|
+
lead: `${icon} ${typeBadge} `,
|
|
422
|
+
meta,
|
|
423
|
+
full: false,
|
|
424
|
+
}),
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
// Running jobs without a drawn tile (no widget, or past the cap) collapse
|
|
428
|
+
// into one count; the header already carries it while nothing settled.
|
|
429
|
+
const quietRunning = counts.running - shownWidgetJobs.length;
|
|
430
|
+
if (quietRunning > 0 && (settledJobs.length > 0 || shownWidgetJobs.length < widgetJobs.length)) {
|
|
431
|
+
lines.push(`${indent}${uiTheme.fg("dim", `${quietRunning} still running`)}`);
|
|
432
|
+
}
|
|
433
|
+
return lines;
|
|
434
|
+
};
|
|
354
435
|
return {
|
|
355
436
|
render(width: number): readonly string[] {
|
|
356
437
|
const expanded = options.expanded;
|
|
@@ -373,113 +454,121 @@ function jobsRenderResult(
|
|
|
373
454
|
.digest();
|
|
374
455
|
if (!shimmerActive && cached?.key === key) return cached.lines;
|
|
375
456
|
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
const maxLabelLines = expanded ? LABEL_LINES_EXPANDED : LABEL_LINES_COLLAPSED;
|
|
404
|
-
const visibleLabelLines = rawLabelLines
|
|
405
|
-
.slice(0, maxLabelLines)
|
|
406
|
-
.map(l => truncateToWidth(replaceTabs(l), LABEL_MAX_WIDTH, Ellipsis.Unicode));
|
|
407
|
-
if (rawLabelLines.length > maxLabelLines && visibleLabelLines.length > 0) {
|
|
408
|
-
const last = visibleLabelLines[visibleLabelLines.length - 1]!;
|
|
409
|
-
visibleLabelLines[visibleLabelLines.length - 1] = `${last} …`;
|
|
410
|
-
}
|
|
411
|
-
const rowPrefix = `${icon} ${typeBadge} `;
|
|
412
|
-
const live = job.status === "running" && options.spinnerFrame !== undefined;
|
|
413
|
-
const continuationWidth = Math.max(0, rowWidth - visibleWidth(" "));
|
|
414
|
-
if (job.widget?.state === "live") {
|
|
415
|
-
const meta = compact([
|
|
416
|
-
job.status === "running" && job.completionPercent !== undefined
|
|
417
|
-
? uiTheme.fg("accent", `${job.completionPercent}%`)
|
|
418
|
-
: undefined,
|
|
419
|
-
uiTheme.fg("dim", formatDuration(job.durationMs)),
|
|
420
|
-
]).join(" ");
|
|
421
|
-
lines.push(
|
|
422
|
-
...renderJobTileLines(jobTile(job, live), rowWidth, uiTheme, {
|
|
423
|
-
lead: rowPrefix,
|
|
424
|
-
meta,
|
|
425
|
-
full: expanded,
|
|
426
|
-
}),
|
|
427
|
-
);
|
|
428
|
-
} else {
|
|
429
|
-
const modelIdentity = job.resolvedModelIdentity ?? job.resolvedModel;
|
|
430
|
-
const modelBadge =
|
|
431
|
-
job.type === "task" && showModelBadge && typeof modelIdentity === "string"
|
|
432
|
-
? formatFeedModelBadge(
|
|
433
|
-
modelIdentity,
|
|
434
|
-
job.resolvedThinkingLevel,
|
|
435
|
-
job.advisor === true,
|
|
436
|
-
uiTheme,
|
|
437
|
-
Math.min(
|
|
438
|
-
FEED_MODEL_BADGE_WIDTH,
|
|
439
|
-
Math.max(
|
|
440
|
-
0,
|
|
441
|
-
rowWidth - visibleWidth(`${rowPrefix}${displayId}${durationSuffix}`) - 1,
|
|
442
|
-
),
|
|
443
|
-
),
|
|
444
|
-
)
|
|
445
|
-
: "";
|
|
446
|
-
const modelLead = modelBadge ? `${modelBadge} ` : "";
|
|
447
|
-
const headRaw = displayId;
|
|
448
|
-
// Running rows in a live block shimmer their label; once the block
|
|
449
|
-
// stops animating (sealed, or a settled snapshot — spinnerFrame
|
|
450
|
-
// cleared) they render static so scrollback never keeps a mid-sweep
|
|
451
|
-
// shimmer band.
|
|
452
|
-
const headLabel = live
|
|
453
|
-
? shimmerEnabled()
|
|
454
|
-
? shimmerText(headRaw, uiTheme)
|
|
455
|
-
: uiTheme.fg("accent", headRaw)
|
|
456
|
-
: uiTheme.fg("toolOutput", headRaw);
|
|
457
|
-
let row = `${rowPrefix}${modelLead}${headLabel}`;
|
|
458
|
-
const distinctLabel = rowLabel.trim() !== job.id;
|
|
459
|
-
const label = visibleLabelLines[0] ?? "";
|
|
460
|
-
const inlineLabel = distinctLabel && visibleWidth(`${row} ${label}${durationSuffix}`) <= rowWidth;
|
|
461
|
-
if (inlineLabel) row += ` ${uiTheme.fg("toolOutput", label)}`;
|
|
462
|
-
row += durationSuffix;
|
|
463
|
-
lines.push(truncateToWidth(row, rowWidth, ""));
|
|
464
|
-
for (let i = distinctLabel && !inlineLabel ? 0 : 1; i < visibleLabelLines.length; i++) {
|
|
465
|
-
lines.push(
|
|
466
|
-
` ${uiTheme.fg("toolOutput", truncateToWidth(visibleLabelLines[i]!, continuationWidth))}`,
|
|
457
|
+
const compactView = !expanded && jobs.length > 0;
|
|
458
|
+
const itemLines = compactView
|
|
459
|
+
? compactJobLines(width, counts.running > 0 && options.spinnerFrame !== undefined)
|
|
460
|
+
: renderTreeList<JobSnapshot>(
|
|
461
|
+
{
|
|
462
|
+
items: sortedJobs,
|
|
463
|
+
expanded,
|
|
464
|
+
maxCollapsed: PREVIEW_LIMITS.COLLAPSED_ITEMS,
|
|
465
|
+
itemType: "job",
|
|
466
|
+
renderItem: (job, context) => {
|
|
467
|
+
const rowWidth = Math.max(0, width - (context.prefixWidth ?? 0));
|
|
468
|
+
const lines: string[] = [];
|
|
469
|
+
const icon = `${formatStatusIcon(
|
|
470
|
+
statusToIcon(job.status),
|
|
471
|
+
uiTheme,
|
|
472
|
+
job.status === "running" ? options.spinnerFrame : undefined,
|
|
473
|
+
)}${job.exitCode === undefined ? "" : `${uiTheme.sep.dot}${uiTheme.fg(job.exitCode === 0 ? "muted" : "error", `exit ${job.exitCode}`)}`}`;
|
|
474
|
+
const typeBadge = formatBadge(job.type, statusToColor(job.status), uiTheme);
|
|
475
|
+
const completion =
|
|
476
|
+
job.status === "running" && job.completionPercent !== undefined
|
|
477
|
+
? `${uiTheme.sep.dot}${uiTheme.fg("accent", `${job.completionPercent}%`)}`
|
|
478
|
+
: "";
|
|
479
|
+
const durationSuffix = `${completion}${uiTheme.sep.dot}${uiTheme.fg("dim", formatDuration(job.durationMs))}`;
|
|
480
|
+
const displayId = truncateToWidth(
|
|
481
|
+
replaceTabs(job.id).replace(/\s+/g, " "),
|
|
482
|
+
Math.max(0, rowWidth - visibleWidth(`${icon} ${typeBadge} ${durationSuffix}`)),
|
|
483
|
+
Ellipsis.Unicode,
|
|
467
484
|
);
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
485
|
+
const rowLabel = jobRowLabel(job);
|
|
486
|
+
const rawLabelLines = (rowLabel || "(no label)").split(/\r?\n/);
|
|
487
|
+
const maxLabelLines = expanded ? LABEL_LINES_EXPANDED : LABEL_LINES_COLLAPSED;
|
|
488
|
+
const visibleLabelLines = rawLabelLines
|
|
489
|
+
.slice(0, maxLabelLines)
|
|
490
|
+
.map(l => truncateToWidth(replaceTabs(l), LABEL_MAX_WIDTH, Ellipsis.Unicode));
|
|
491
|
+
if (rawLabelLines.length > maxLabelLines && visibleLabelLines.length > 0) {
|
|
492
|
+
const last = visibleLabelLines[visibleLabelLines.length - 1]!;
|
|
493
|
+
visibleLabelLines[visibleLabelLines.length - 1] = `${last} …`;
|
|
494
|
+
}
|
|
495
|
+
const rowPrefix = `${icon} ${typeBadge} `;
|
|
496
|
+
const live = job.status === "running" && options.spinnerFrame !== undefined;
|
|
497
|
+
const continuationWidth = Math.max(0, rowWidth - visibleWidth(" "));
|
|
498
|
+
if (job.widget?.state === "live") {
|
|
499
|
+
const meta = compact([
|
|
500
|
+
job.status === "running" && job.completionPercent !== undefined
|
|
501
|
+
? uiTheme.fg("accent", `${job.completionPercent}%`)
|
|
502
|
+
: undefined,
|
|
503
|
+
uiTheme.fg("dim", formatDuration(job.durationMs)),
|
|
504
|
+
]).join(" ");
|
|
505
|
+
lines.push(
|
|
506
|
+
...renderJobTileLines(jobTile(job, live), rowWidth, uiTheme, {
|
|
507
|
+
lead: rowPrefix,
|
|
508
|
+
meta,
|
|
509
|
+
full: expanded,
|
|
510
|
+
}),
|
|
511
|
+
);
|
|
512
|
+
} else {
|
|
513
|
+
const modelIdentity = job.resolvedModelIdentity ?? job.resolvedModel;
|
|
514
|
+
const modelBadge =
|
|
515
|
+
job.type === "task" && showModelBadge && typeof modelIdentity === "string"
|
|
516
|
+
? formatFeedModelBadge(
|
|
517
|
+
modelIdentity,
|
|
518
|
+
job.resolvedThinkingLevel,
|
|
519
|
+
job.advisor === true,
|
|
520
|
+
uiTheme,
|
|
521
|
+
Math.min(
|
|
522
|
+
FEED_MODEL_BADGE_WIDTH,
|
|
523
|
+
Math.max(
|
|
524
|
+
0,
|
|
525
|
+
rowWidth - visibleWidth(`${rowPrefix}${displayId}${durationSuffix}`) - 1,
|
|
526
|
+
),
|
|
527
|
+
),
|
|
528
|
+
)
|
|
529
|
+
: "";
|
|
530
|
+
const modelLead = modelBadge ? `${modelBadge} ` : "";
|
|
531
|
+
const headRaw = displayId;
|
|
532
|
+
// Running rows in a live block shimmer their label; once the block
|
|
533
|
+
// stops animating (sealed, or a settled snapshot — spinnerFrame
|
|
534
|
+
// cleared) they render static so scrollback never keeps a mid-sweep
|
|
535
|
+
// shimmer band.
|
|
536
|
+
const headLabel = live
|
|
537
|
+
? shimmerEnabled()
|
|
538
|
+
? shimmerText(headRaw, uiTheme)
|
|
539
|
+
: uiTheme.fg("accent", headRaw)
|
|
540
|
+
: uiTheme.fg("toolOutput", headRaw);
|
|
541
|
+
let row = `${rowPrefix}${modelLead}${headLabel}`;
|
|
542
|
+
const distinctLabel = rowLabel.trim() !== job.id;
|
|
543
|
+
const label = visibleLabelLines[0] ?? "";
|
|
544
|
+
const inlineLabel =
|
|
545
|
+
distinctLabel && visibleWidth(`${row} ${label}${durationSuffix}`) <= rowWidth;
|
|
546
|
+
if (inlineLabel) row += ` ${uiTheme.fg("toolOutput", label)}`;
|
|
547
|
+
row += durationSuffix;
|
|
548
|
+
lines.push(truncateToWidth(row, rowWidth, ""));
|
|
549
|
+
for (let i = distinctLabel && !inlineLabel ? 0 : 1; i < visibleLabelLines.length; i++) {
|
|
550
|
+
lines.push(
|
|
551
|
+
` ${uiTheme.fg("toolOutput", truncateToWidth(visibleLabelLines[i]!, continuationWidth))}`,
|
|
552
|
+
);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
const artifactError = job.meta?.artifactError ?? job.artifactError;
|
|
556
|
+
if (artifactError) {
|
|
557
|
+
lines.push(
|
|
558
|
+
uiTheme.fg(
|
|
559
|
+
"warning",
|
|
560
|
+
truncateToWidth(formatArtifactErrorNotice(artifactError), rowWidth),
|
|
561
|
+
),
|
|
562
|
+
);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
for (const previewLine of jobPreviewRows(job, expanded, continuationWidth))
|
|
566
|
+
lines.push(previewLine);
|
|
567
|
+
return lines;
|
|
568
|
+
},
|
|
569
|
+
},
|
|
570
|
+
uiTheme,
|
|
571
|
+
);
|
|
483
572
|
|
|
484
573
|
// Agents run outside job control; render them as their own tree so
|
|
485
574
|
// they never skew the job counts or the "waiting on N jobs" title.
|
|
@@ -522,7 +611,7 @@ function jobsRenderResult(
|
|
|
522
611
|
uiTheme,
|
|
523
612
|
);
|
|
524
613
|
|
|
525
|
-
const all = [header];
|
|
614
|
+
const all = compactView && settledJobs.length > 0 ? [] : [header];
|
|
526
615
|
if (aggregateArtifactError) {
|
|
527
616
|
all.push(uiTheme.fg("warning", formatArtifactErrorNotice(aggregateArtifactError)));
|
|
528
617
|
}
|
|
@@ -624,22 +713,18 @@ export function createIrcMessageCard(
|
|
|
624
713
|
if (card.replyTo) meta.push("reply");
|
|
625
714
|
const age = messageAge(card.timestamp);
|
|
626
715
|
if (age) meta.push(age);
|
|
627
|
-
const component = createCachedComponent(
|
|
628
|
-
|
|
629
|
-
(
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
return lines.map(line => truncateToWidth(line, width, Ellipsis.Unicode));
|
|
640
|
-
},
|
|
641
|
-
{ paddingX: 1 },
|
|
642
|
-
);
|
|
716
|
+
const component = createCachedComponent(getExpanded, (width, expanded) => {
|
|
717
|
+
const lines = [renderStatusLine({ iconOverride: ircGlyph(uiTheme), title, meta }, uiTheme)];
|
|
718
|
+
if (body.trim()) {
|
|
719
|
+
lines.push(
|
|
720
|
+
...bodyLines(body, expanded, uiTheme, {
|
|
721
|
+
indent: " ",
|
|
722
|
+
collapsedLines: 3,
|
|
723
|
+
}),
|
|
724
|
+
);
|
|
725
|
+
}
|
|
726
|
+
return lines.map(line => truncateToWidth(line, width, Ellipsis.Unicode));
|
|
727
|
+
});
|
|
643
728
|
// Terminal-local collapse replaces `getExpanded`; the node never changes after creation.
|
|
644
729
|
const described = cardNode(
|
|
645
730
|
{
|