@oh-my-pi/pi-tui 18.12.1 → 18.12.3
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 +33 -66
- package/dist/types/autocomplete.d.ts +6 -0
- package/dist/types/chat/skill-message.d.ts +3 -4
- package/dist/types/chrome/status-notice.d.ts +2 -0
- package/dist/types/components/sparkline.d.ts +34 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/native/describe.d.ts +7 -1
- package/dist/types/native/tone.d.ts +2 -0
- package/dist/types/overlays/agent-hub.d.ts +3 -3
- package/dist/types/overlays/approval-dialog.d.ts +15 -1
- package/dist/types/overlays/jobs-panel.d.ts +3 -0
- package/dist/types/overlays/model-browser.d.ts +1 -1
- package/dist/types/prompt/composer.d.ts +2 -0
- package/dist/types/sixel.d.ts +28 -0
- package/dist/types/status-line/host.d.ts +3 -0
- package/dist/types/tools/irc.d.ts +6 -0
- package/dist/types/tools/job-widget.d.ts +226 -0
- package/dist/types/tools/output-meta.d.ts +1 -1
- package/dist/types/tools/streaming-output.d.ts +1 -0
- package/dist/types/tools/task.d.ts +12 -0
- package/dist/types/tools/wait.d.ts +5 -0
- package/dist/types/tools/web-search-types.d.ts +1 -0
- package/package.json +9 -9
- package/src/autocomplete.ts +12 -1
- package/src/charts/table-data.ts +17 -6
- package/src/chat/skill-message.ts +19 -21
- package/src/chrome/status-notice.ts +5 -0
- package/src/components/editor.ts +17 -7
- package/src/components/image.ts +5 -4
- package/src/components/markdown.ts +21 -1
- package/src/components/sparkline.ts +89 -0
- package/src/index.ts +1 -0
- package/src/native/describe.ts +18 -1
- package/src/native/tone.ts +22 -0
- package/src/overlays/agent-hub.ts +14 -10
- package/src/overlays/agent-transcript-viewer.ts +2 -2
- package/src/overlays/approval-dialog.ts +59 -13
- package/src/overlays/jobs-panel.ts +10 -0
- package/src/overlays/model-browser.ts +3 -0
- package/src/prompt/attachment-chips.ts +1 -1
- package/src/prompt/composer-cache.ts +3 -0
- package/src/prompt/composer.ts +8 -2
- package/src/sixel.ts +185 -0
- package/src/status-line/component.ts +75 -3
- package/src/status-line/host.ts +3 -0
- package/src/stdin-buffer.ts +289 -61
- package/src/terminal-capabilities.ts +4 -1
- package/src/terminal.ts +30 -17
- package/src/theme/symbols.ts +5 -3
- package/src/tools/irc.ts +6 -0
- package/src/tools/job-widget.ts +1036 -0
- package/src/tools/output-meta.ts +1 -1
- package/src/tools/streaming-output.ts +11 -9
- package/src/tools/task.ts +25 -1
- package/src/tools/wait.ts +141 -85
- package/src/tools/web-search-types.ts +1 -0
- package/src/tui.ts +65 -12
|
@@ -3,6 +3,7 @@ import type { Theme } from "../theme/theme.js";
|
|
|
3
3
|
import { type OutputMeta } from "./output-meta.js";
|
|
4
4
|
import { type ConfiguredThinkingLevel } from "../render/render-utils.js";
|
|
5
5
|
import type { StructuredSubagentOutput } from "./task.js";
|
|
6
|
+
import { type JobWidgetView } from "./job-widget.js";
|
|
6
7
|
import type { RenderResultOptions, ToolActivitySummary } from "./renderer.js";
|
|
7
8
|
import type { IrcDeliveryReceipt, IrcMessage } from "./irc.js";
|
|
8
9
|
import type { NativeToolView, ToolRenderResult } from "./renderer.js";
|
|
@@ -29,6 +30,10 @@ export interface JobSnapshot {
|
|
|
29
30
|
advisor?: boolean;
|
|
30
31
|
/** The task agent's latest self-estimated completion (0–100); see `AgentProgress.completionPercent`. */
|
|
31
32
|
completionPercent?: number;
|
|
33
|
+
/** The task agent's latest stage in its own words; see `AgentProgress.stage`. */
|
|
34
|
+
stage?: string;
|
|
35
|
+
/** The job's live widget, while one is being drawn; frozen at its last state once the job settles. */
|
|
36
|
+
widget?: JobWidgetView;
|
|
32
37
|
resultText?: string;
|
|
33
38
|
errorText?: string;
|
|
34
39
|
/** Source-output metadata retained for per-job warnings and persisted row rendering. */
|
|
@@ -25,6 +25,7 @@ export declare const SEARCH_PROVIDER_LABELS: {
|
|
|
25
25
|
readonly tavily: "Tavily";
|
|
26
26
|
readonly firecrawl: "Firecrawl";
|
|
27
27
|
readonly brave: "Brave";
|
|
28
|
+
readonly deepseek: "DeepSeek";
|
|
28
29
|
readonly kimi: "Kimi";
|
|
29
30
|
readonly synthetic: "Synthetic";
|
|
30
31
|
readonly ollama: "Ollama";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@oh-my-pi/pi-tui",
|
|
4
|
-
"version": "18.12.
|
|
4
|
+
"version": "18.12.3",
|
|
5
5
|
"description": "Terminal User Interface library with differential rendering for efficient text-based applications",
|
|
6
6
|
"homepage": "https://omp.sh",
|
|
7
7
|
"author": {
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
"gen:glyphs": "bun scripts/gen-glyphs.ts"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@oh-my-pi/omptype": "18.12.
|
|
45
|
-
"@oh-my-pi/pi-agent-core": "18.12.
|
|
46
|
-
"@oh-my-pi/pi-ai": "18.12.
|
|
47
|
-
"@oh-my-pi/pi-catalog": "18.12.
|
|
48
|
-
"@oh-my-pi/pi-natives": "18.12.
|
|
49
|
-
"@oh-my-pi/pi-utils": "18.12.
|
|
50
|
-
"@oh-my-pi/pi-wire": "18.12.
|
|
51
|
-
"@oh-my-pi/snapcompact": "18.12.
|
|
44
|
+
"@oh-my-pi/omptype": "18.12.3",
|
|
45
|
+
"@oh-my-pi/pi-agent-core": "18.12.3",
|
|
46
|
+
"@oh-my-pi/pi-ai": "18.12.3",
|
|
47
|
+
"@oh-my-pi/pi-catalog": "18.12.3",
|
|
48
|
+
"@oh-my-pi/pi-natives": "18.12.3",
|
|
49
|
+
"@oh-my-pi/pi-utils": "18.12.3",
|
|
50
|
+
"@oh-my-pi/pi-wire": "18.12.3",
|
|
51
|
+
"@oh-my-pi/snapcompact": "18.12.3"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"kitty-vt-wasm": "^0.2.0"
|
package/src/autocomplete.ts
CHANGED
|
@@ -226,6 +226,12 @@ export interface AutocompleteItem {
|
|
|
226
226
|
state?: string;
|
|
227
227
|
/** Dim hint text shown inline after cursor when this item is selected */
|
|
228
228
|
hint?: string;
|
|
229
|
+
/**
|
|
230
|
+
* Slash command matched only through its description, not its name or an alias:
|
|
231
|
+
* a browse hit, so Enter submits the typed text instead of running it unless the
|
|
232
|
+
* user moved the selection onto it.
|
|
233
|
+
*/
|
|
234
|
+
descriptionMatch?: boolean;
|
|
229
235
|
}
|
|
230
236
|
|
|
231
237
|
type Awaitable<T> = T | Promise<T>;
|
|
@@ -437,6 +443,7 @@ function buildSlashCommandCompletions(
|
|
|
437
443
|
...(cmd.iconName && { iconName: cmd.iconName }),
|
|
438
444
|
...(fullDesc && { description: fullDesc }),
|
|
439
445
|
...nativeTextMemo,
|
|
446
|
+
...(nameScore === 0 && { descriptionMatch: true }),
|
|
440
447
|
};
|
|
441
448
|
}
|
|
442
449
|
|
|
@@ -444,7 +451,11 @@ function buildSlashCommandCompletions(
|
|
|
444
451
|
for (const alias of getCommandAliases(cmd)) {
|
|
445
452
|
if (alias === name) continue;
|
|
446
453
|
const aliasScore = scoreCommandTextMatch(lowerPrefix, alias.toLowerCase());
|
|
447
|
-
if (aliasScore === 0
|
|
454
|
+
if (aliasScore === 0) continue;
|
|
455
|
+
// An alias can match even when the description outranks it; Enter
|
|
456
|
+
// must still accept the command rather than submit the raw query.
|
|
457
|
+
if (best?.descriptionMatch) delete best.descriptionMatch;
|
|
458
|
+
if (best && aliasScore <= best.score) continue;
|
|
448
459
|
const fullDesc = resolveFullDesc();
|
|
449
460
|
best = {
|
|
450
461
|
value: alias,
|
package/src/charts/table-data.ts
CHANGED
|
@@ -148,7 +148,17 @@ export interface TableAnalysis {
|
|
|
148
148
|
readonly composition?: Composition;
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
|
|
151
|
+
/**
|
|
152
|
+
* A whole number as written: bare, or grouped in thousands by commas (`1,988`)
|
|
153
|
+
* or by spaces as many locales write it (`1 988`, also U+00A0 and U+202F).
|
|
154
|
+
* Space groups take exactly three digits, so `12 5` and `128 2560` stay apart.
|
|
155
|
+
*/
|
|
156
|
+
const INTEGER = String.raw`\d{1,3}(?:,\d{3})+|\d{1,3}(?:[ \u00A0\u202F]\d{3})+(?!\d)|\d+`;
|
|
157
|
+
const NUMBER = String.raw`(?:${INTEGER})(?:\.\d+)?(?:[eE][+-]?\d+)?|\.\d+`;
|
|
158
|
+
/** A cell holding one whole number and nothing else (`38`, `1,980`). */
|
|
159
|
+
const WHOLE = new RegExp(String.raw`^(?:${INTEGER})$`);
|
|
160
|
+
/** The first number of a figure, its whole part and its decimals apart. */
|
|
161
|
+
const WRITTEN = new RegExp(String.raw`(${INTEGER})(?:\.(\d+))?`);
|
|
152
162
|
const CELL = new RegExp(
|
|
153
163
|
String.raw`^(?<approx>~|≈|<=|>=|<|>|≤|≥)?\s*(?<sign>[+\-−±])?\s*(?<cur>[$€£¥])?\s*(?<num>${NUMBER})(?<plus>\+(?=\s*[A-Za-zµμ%]))?\s*(?<unit>%|[A-Za-zµμ×]+(?:\/[A-Za-z]+)?|\/s)?(?<rest>.*)$`,
|
|
154
164
|
);
|
|
@@ -517,8 +527,9 @@ export function parseCell(markdown: string): Cell {
|
|
|
517
527
|
return { ...cell, fit: "prose" };
|
|
518
528
|
}
|
|
519
529
|
|
|
530
|
+
/** The value of a number {@link NUMBER} matched, its comma or space group separators removed. */
|
|
520
531
|
function toNumber(written: string): number {
|
|
521
|
-
return Number(written.
|
|
532
|
+
return Number(written.replace(/[,\s]/g, ""));
|
|
522
533
|
}
|
|
523
534
|
|
|
524
535
|
/** A number of a list or sum: its value as written, its unit (known or a noun) and how it was marked. */
|
|
@@ -632,7 +643,7 @@ function listCell(text: string, base: CellBase): NumberCell | undefined {
|
|
|
632
643
|
// A spaced pair of bare numbers that is no score (`25.0 / 27.8`, `12.6 / 9.4`: the second is no whole, or
|
|
633
644
|
// the first exceeds it) lists two values of the column's quantity; `27 / 30` stays a score.
|
|
634
645
|
const [first, second] = items;
|
|
635
|
-
const whole =
|
|
646
|
+
const whole = WHOLE.test(text.slice(text.indexOf("/") + 1, end).trim());
|
|
636
647
|
const score = whole && first!.value >= 0 && first!.value <= second!.value;
|
|
637
648
|
const pair = items.length === 2 && !marked.some(Boolean) && separators[0] !== "/" && !score;
|
|
638
649
|
if (!pair && (!marked.at(-1) || !(marked.every(Boolean) || carried))) return undefined;
|
|
@@ -876,9 +887,9 @@ const WHOLE_HEADER = /\b(?:total|all|sum|overall)\b/i;
|
|
|
876
887
|
*/
|
|
877
888
|
export function writtenSlack(cell: NumberCell): number {
|
|
878
889
|
if (cell.denominator !== undefined && cell.dim === "percent") return 0;
|
|
879
|
-
const match =
|
|
890
|
+
const match = WRITTEN.exec(cell.figure);
|
|
880
891
|
if (!match) return 0;
|
|
881
|
-
const written =
|
|
892
|
+
const written = toNumber(`${match[1]!}${match[2] ? `.${match[2]}` : ""}`);
|
|
882
893
|
const factor = written ? Math.abs(cell.value) / written : 1;
|
|
883
894
|
const decimals = match[2]?.length ?? 0;
|
|
884
895
|
if (cell.dim === "count" && decimals === 0 && factor === 1 && !cell.approx) return 0;
|
|
@@ -1097,7 +1108,7 @@ const MIN_LISTS = 2;
|
|
|
1097
1108
|
/** A spaced slash between list items. */
|
|
1098
1109
|
const LIST_SLASH = /\s+\/\s+/;
|
|
1099
1110
|
/** A list item that is one number, as written (`12`, `~1,400`, `3.5 ms`, `40%`). */
|
|
1100
|
-
const LISTED_NUMBER =
|
|
1111
|
+
const LISTED_NUMBER = new RegExp(String.raw`^[~≈]?[$€£¥]?(?:${INTEGER})(?:\.\d+)?\s*(?:%|[A-Za-zµμ]+)?$`);
|
|
1101
1112
|
|
|
1102
1113
|
/**
|
|
1103
1114
|
* Rows folding several rows into one (`response anthropic / chat / responses /
|
|
@@ -13,8 +13,8 @@ import { fileHyperlink } from "../render";
|
|
|
13
13
|
import { collapseSkillTokens, skillChipLabel, skillChipStyle, skillToken } from "../prompt/composer-attachments";
|
|
14
14
|
import { type UserBubbleOptions, UserMessageComponent, userBubbleColor } from "./user-message";
|
|
15
15
|
import type { TspSpan } from "@oh-my-pi/pi-wire";
|
|
16
|
-
import { card, md, node, span
|
|
17
|
-
import { type NativeChild, type NativeNode, type NativeUiEvent
|
|
16
|
+
import { card, md, node, span } from "../native/describe";
|
|
17
|
+
import { type NativeChild, type NativeNode, type NativeUiEvent } from "../native/node";
|
|
18
18
|
import { Memo } from "../native/memo";
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -63,15 +63,13 @@ export class SkillMessageComponent extends Container {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
handleNativeEvent(event: NativeUiEvent): void {
|
|
66
|
-
|
|
67
|
-
if (expanded !== undefined) this.setExpanded(expanded);
|
|
66
|
+
if (event.type === "toggle" && event.key === "prompt") this.setExpanded(!event.collapsed);
|
|
68
67
|
}
|
|
69
68
|
|
|
70
69
|
/**
|
|
71
|
-
* A user-toned card (role `omp.skill`): the skill chip
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
* be large.
|
|
70
|
+
* A user-toned card (role `omp.skill`): the skill chip and prompt size in
|
|
71
|
+
* the head, the user's draft always visible, and only the loaded skill
|
|
72
|
+
* prompt behind a disclosure.
|
|
75
73
|
*/
|
|
76
74
|
override describe(): NativeNode {
|
|
77
75
|
return this.#native.get([this.#expanded], () => {
|
|
@@ -100,20 +98,20 @@ export class SkillMessageComponent extends Container {
|
|
|
100
98
|
const children: NativeChild[] = [];
|
|
101
99
|
if (draft) children.push(md(draft));
|
|
102
100
|
const promptText = this.#expanded ? this.#extractText() : "";
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
children.length > 0 ? children : [text([span(label, "muted")])],
|
|
101
|
+
children.push(
|
|
102
|
+
node(
|
|
103
|
+
"section",
|
|
104
|
+
{
|
|
105
|
+
head: [span("prompt", "muted")],
|
|
106
|
+
role: "omp.skill.prompt",
|
|
107
|
+
collapsible: true,
|
|
108
|
+
collapsed: !this.#expanded,
|
|
109
|
+
},
|
|
110
|
+
promptText ? [md(promptText)] : [],
|
|
111
|
+
"prompt",
|
|
112
|
+
),
|
|
116
113
|
);
|
|
114
|
+
return card({ role: "omp.skill", tone: "user", head }, children);
|
|
117
115
|
});
|
|
118
116
|
}
|
|
119
117
|
|
|
@@ -42,6 +42,11 @@ export class StatusNotice extends Container {
|
|
|
42
42
|
this.addChild(this.#text);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
/** The text the notice currently shows. */
|
|
46
|
+
get message(): string {
|
|
47
|
+
return this.#message;
|
|
48
|
+
}
|
|
49
|
+
|
|
45
50
|
setMessage(message: string, options: StatusNoticeOptions = {}): void {
|
|
46
51
|
const toast = options.toast ?? true;
|
|
47
52
|
this.#text.setStyleFn(options.styleFn);
|
package/src/components/editor.ts
CHANGED
|
@@ -704,6 +704,8 @@ export class Editor implements Component, Focusable {
|
|
|
704
704
|
| { line: number; startCol: number; endCol: number; original: string; cursorOffset: number }
|
|
705
705
|
| undefined;
|
|
706
706
|
#autocompletePrefix: string = "";
|
|
707
|
+
/** False while the popup's untouched top row is a description-only slash hit ({@link AutocompleteItem.descriptionMatch}): Enter then submits the typed text. */
|
|
708
|
+
#enterAcceptsSelection = true;
|
|
707
709
|
#autocompleteRequestId: number = 0;
|
|
708
710
|
#autocompletePendingRequest: AutocompleteRequest | undefined;
|
|
709
711
|
#autocompleteRequestRunning = false;
|
|
@@ -1916,6 +1918,7 @@ export class Editor implements Component, Focusable {
|
|
|
1916
1918
|
this.onAutocompleteUpdate?.();
|
|
1917
1919
|
} else {
|
|
1918
1920
|
this.#autocompleteList.handleInput(data);
|
|
1921
|
+
this.#enterAcceptsSelection = true;
|
|
1919
1922
|
this.onAutocompleteUpdate?.();
|
|
1920
1923
|
return;
|
|
1921
1924
|
}
|
|
@@ -1960,8 +1963,11 @@ export class Editor implements Component, Focusable {
|
|
|
1960
1963
|
// Check for stale autocomplete state while an async refresh is pending
|
|
1961
1964
|
const currentLine = this.#state.lines[this.#state.cursorLine] ?? "";
|
|
1962
1965
|
const currentTextBeforeCursor = currentLine.slice(0, this.#state.cursorCol);
|
|
1963
|
-
if (
|
|
1964
|
-
|
|
1966
|
+
if (
|
|
1967
|
+
!this.#autocompletePrefixMatchesCursorText(currentTextBeforeCursor, selected) ||
|
|
1968
|
+
!this.#enterAcceptsSelection
|
|
1969
|
+
) {
|
|
1970
|
+
// Stale, or a description-only hit the user never selected: submit the typed text.
|
|
1965
1971
|
this.#cancelAutocomplete();
|
|
1966
1972
|
} else {
|
|
1967
1973
|
if (selected && this.#autocompleteProvider) {
|
|
@@ -1993,10 +1999,12 @@ export class Editor implements Component, Focusable {
|
|
|
1993
1999
|
if (
|
|
1994
2000
|
!selected ||
|
|
1995
2001
|
!this.#autocompletePrefixMatchesCursorText(currentTextBeforeCursor, selected) ||
|
|
1996
|
-
this.#selectedSlashArgumentIsAlreadyTyped(selected)
|
|
2002
|
+
this.#selectedSlashArgumentIsAlreadyTyped(selected) ||
|
|
2003
|
+
!this.#enterAcceptsSelection
|
|
1997
2004
|
) {
|
|
1998
|
-
// Stale,
|
|
1999
|
-
// typed slash-command argument (`/mcp list` + Enter)
|
|
2005
|
+
// Stale, accepting would only append whitespace to an already fully
|
|
2006
|
+
// typed slash-command argument (`/mcp list` + Enter), or the row is a
|
|
2007
|
+
// description-only hit the user never selected: cancel and fall
|
|
2000
2008
|
// through to normal submission instead of swallowing the keypress.
|
|
2001
2009
|
this.#cancelAutocomplete();
|
|
2002
2010
|
} else {
|
|
@@ -2140,9 +2148,10 @@ export class Editor implements Component, Focusable {
|
|
|
2140
2148
|
) {
|
|
2141
2149
|
const syncResult = this.#autocompleteProvider.trySyncSlashCompletion(textBeforeCursor);
|
|
2142
2150
|
// The collapsed `/skill:` namespace row is not a runnable command; Enter submits
|
|
2143
|
-
// immediately after applying, so only a real command may be completed here
|
|
2151
|
+
// immediately after applying, so only a real command may be completed here, and
|
|
2152
|
+
// only one whose name matches: a description-only hit would run an unrelated command.
|
|
2144
2153
|
const selected = syncResult?.items.find(item => item.value !== SKILL_NAMESPACE);
|
|
2145
|
-
if (syncResult && selected) {
|
|
2154
|
+
if (syncResult && selected && !selected.descriptionMatch) {
|
|
2146
2155
|
// Invalidate any pending async autocomplete so its stale results are discarded
|
|
2147
2156
|
this.#autocompleteRequestId += 1;
|
|
2148
2157
|
// Apply the best match and submit the completed command
|
|
@@ -4871,6 +4880,7 @@ export class Editor implements Component, Focusable {
|
|
|
4871
4880
|
): void {
|
|
4872
4881
|
this.#autocompletePrefix = suggestions.prefix;
|
|
4873
4882
|
this.#autocompleteList = this.#createAutocompleteList(suggestions.prefix, suggestions.items);
|
|
4883
|
+
this.#enterAcceptsSelection = !suggestions.items[0]?.descriptionMatch;
|
|
4874
4884
|
this.#autocompleteState = state;
|
|
4875
4885
|
this.onAutocompleteUpdate?.();
|
|
4876
4886
|
}
|
package/src/components/image.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { encodeSixelAsync } from "@oh-my-pi/pi-natives";
|
|
2
2
|
import { getKittyGraphics } from "../kitty-graphics";
|
|
3
|
+
import { ensureSixelRasterWidth } from "../sixel";
|
|
3
4
|
import {
|
|
4
5
|
encodeSixelNow,
|
|
5
6
|
getCellDimensions,
|
|
@@ -736,7 +737,7 @@ export class Image implements Component {
|
|
|
736
737
|
const request: SixelEncode = { widthPx, heightPx, backgroundRgb };
|
|
737
738
|
this.#sixel = request;
|
|
738
739
|
const settle = (sequence: string | null): void => {
|
|
739
|
-
request.sequence = sequence;
|
|
740
|
+
request.sequence = sequence === null ? null : ensureSixelRasterWidth(sequence);
|
|
740
741
|
if (this.#sixel !== request || getTerminalBackgroundColor() !== backgroundRgb) return;
|
|
741
742
|
this.invalidate();
|
|
742
743
|
if (this.#options.requestRender) this.#options.requestRender();
|
|
@@ -845,9 +846,9 @@ export class Image implements Component {
|
|
|
845
846
|
// height. First (rows-1) lines are empty (TUI clears them); the last
|
|
846
847
|
// saves the final-row cursor, moves up to the image origin, emits the
|
|
847
848
|
// image sequence, then restores the final-row cursor. When the block
|
|
848
|
-
// straddles the viewport top, the renderer
|
|
849
|
-
//
|
|
850
|
-
// registered below.
|
|
849
|
+
// straddles the viewport top, the renderer crops the source raster
|
|
850
|
+
// for SIXEL or rewrites the Kitty placement's visible source slice
|
|
851
|
+
// from the geometry registered below.
|
|
851
852
|
if (this.#imageId != null && this.#budget !== undefined) {
|
|
852
853
|
this.#budget.registerPlacementGeometry(
|
|
853
854
|
this.#imageId,
|
|
@@ -4611,7 +4611,27 @@ export class Markdown implements Component {
|
|
|
4611
4611
|
const text = this.#renderInlineTokens(cell.tokens || [], styleContext);
|
|
4612
4612
|
return this.#wrapCellText(text, columnWidths[i]);
|
|
4613
4613
|
});
|
|
4614
|
-
|
|
4614
|
+
let rowLineCount = Math.max(...rowCellLines.map(c => c.length));
|
|
4615
|
+
// The open cell is laid out in widths measured without it, so it can
|
|
4616
|
+
// wrap past the lines its row's finished cells need. Those extra lines
|
|
4617
|
+
// come and go as the cell grows and the column widens, moving every row
|
|
4618
|
+
// below the table each frame; hold the row at its finished cells' height
|
|
4619
|
+
// until the cell closes and counts toward the widths. While lines are
|
|
4620
|
+
// held back, only the last kept line makes room for a `…`: it is
|
|
4621
|
+
// re-wrapped one column narrower, since the wrapper closes the line's
|
|
4622
|
+
// links and styles where truncation would cut them off, and dropped when
|
|
4623
|
+
// even that overflows (a wide glyph in a two-cell column).
|
|
4624
|
+
if (rowIndex === lastRow && rowCellLines[openCell]) {
|
|
4625
|
+
const settledLineCount = Math.max(1, ...rowCellLines.filter((_, i) => i !== openCell).map(c => c.length));
|
|
4626
|
+
if (rowCellLines[openCell].length > settledLineCount) {
|
|
4627
|
+
const width = columnWidths[openCell];
|
|
4628
|
+
const kept = rowCellLines[openCell].slice(0, settledLineCount);
|
|
4629
|
+
const last = width > 1 ? (this.#wrapCellText(kept[settledLineCount - 1], width - 1)[0] ?? "") : "";
|
|
4630
|
+
kept[settledLineCount - 1] = `${visibleWidth(last) < width ? last : ""}…`;
|
|
4631
|
+
rowCellLines[openCell] = kept;
|
|
4632
|
+
}
|
|
4633
|
+
rowLineCount = settledLineCount;
|
|
4634
|
+
}
|
|
4615
4635
|
|
|
4616
4636
|
for (let lineIdx = 0; lineIdx < rowLineCount; lineIdx++) {
|
|
4617
4637
|
const rowParts = rowCellLines.map((cellLines, colIdx) => {
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One-row block sparklines (`▁▂▃▅▇█`) for ANSI renderers: the usage history
|
|
3
|
+
* in `omp usage`, a job widget's series in the `wait` card and status line.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/** Block glyphs from lowest to highest. */
|
|
7
|
+
export const SPARK_LEVELS = ["▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"] as const;
|
|
8
|
+
|
|
9
|
+
/** How {@link renderSparkline} maps values to glyphs and styles them. */
|
|
10
|
+
export interface SparklineOptions {
|
|
11
|
+
/** Domain low end; values at or below it draw the lowest block. Default 0. */
|
|
12
|
+
readonly min?: number;
|
|
13
|
+
/** Domain high end; values at or above it draw the full block. Default the largest value. */
|
|
14
|
+
readonly max?: number;
|
|
15
|
+
/** Styles one glyph; `fraction` is the value's 0–1 position in the domain. */
|
|
16
|
+
readonly style?: (glyph: string, value: number, fraction: number) => string;
|
|
17
|
+
/** What a missing value draws, already styled. Default a space. */
|
|
18
|
+
readonly gap?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** The block glyph for a 0–1 fraction of the domain. */
|
|
22
|
+
export function sparkGlyph(fraction: number): string {
|
|
23
|
+
const clamped = Number.isFinite(fraction) ? Math.min(Math.max(fraction, 0), 1) : 0;
|
|
24
|
+
return SPARK_LEVELS[Math.min(SPARK_LEVELS.length - 1, Math.floor(clamped * SPARK_LEVELS.length))]!;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** One cell per value, oldest first; `undefined` (and non-finite) values draw the gap. */
|
|
28
|
+
export function renderSparkline(values: readonly (number | undefined)[], options: SparklineOptions = {}): string {
|
|
29
|
+
const min = options.min ?? 0;
|
|
30
|
+
let max = options.max;
|
|
31
|
+
if (max === undefined) {
|
|
32
|
+
max = min;
|
|
33
|
+
for (const value of values) if (value !== undefined && Number.isFinite(value) && value > max) max = value;
|
|
34
|
+
}
|
|
35
|
+
const span = max - min;
|
|
36
|
+
const gap = options.gap ?? " ";
|
|
37
|
+
let out = "";
|
|
38
|
+
for (const value of values) {
|
|
39
|
+
if (value === undefined || !Number.isFinite(value)) {
|
|
40
|
+
out += gap;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const fraction = span > 0 ? (value - min) / span : value > min ? 1 : 0;
|
|
44
|
+
const glyph = sparkGlyph(fraction);
|
|
45
|
+
out += options.style ? options.style(glyph, value, Math.min(Math.max(fraction, 0), 1)) : glyph;
|
|
46
|
+
}
|
|
47
|
+
return out;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* `values` squeezed into at most `cells` points by equal-count bucket means,
|
|
52
|
+
* newest bucket last; shorter series come back unchanged.
|
|
53
|
+
*/
|
|
54
|
+
export function fitSparkValues(values: readonly number[], cells: number): readonly number[] {
|
|
55
|
+
const count = Math.max(0, Math.floor(cells));
|
|
56
|
+
if (values.length <= count) return values;
|
|
57
|
+
const out: number[] = [];
|
|
58
|
+
for (let bucket = 0; bucket < count; bucket++) {
|
|
59
|
+
const from = Math.floor((bucket * values.length) / count);
|
|
60
|
+
const to = Math.max(from + 1, Math.floor(((bucket + 1) * values.length) / count));
|
|
61
|
+
let sum = 0;
|
|
62
|
+
for (let i = from; i < to; i++) sum += values[i]!;
|
|
63
|
+
out.push(sum / (to - from));
|
|
64
|
+
}
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The largest value per time bucket over `[sinceMs, nowMs]`, `cells` buckets
|
|
70
|
+
* wide; buckets without a point are `undefined` (a gap in the sparkline).
|
|
71
|
+
*/
|
|
72
|
+
export function peakBuckets(
|
|
73
|
+
points: Iterable<{ readonly at: number; readonly value: number }>,
|
|
74
|
+
sinceMs: number,
|
|
75
|
+
nowMs: number,
|
|
76
|
+
cells: number,
|
|
77
|
+
): (number | undefined)[] {
|
|
78
|
+
const span = Math.max(1, nowMs - sinceMs);
|
|
79
|
+
const count = Math.max(0, Math.floor(cells));
|
|
80
|
+
const buckets: (number | undefined)[] = Array.from({ length: count }, () => undefined);
|
|
81
|
+
if (count === 0) return buckets;
|
|
82
|
+
for (const point of points) {
|
|
83
|
+
const offset = Math.floor(((point.at - sinceMs) / span) * count);
|
|
84
|
+
const index = Math.min(count - 1, Math.max(0, offset));
|
|
85
|
+
const prev = buckets[index];
|
|
86
|
+
buckets[index] = prev === undefined ? point.value : Math.max(prev, point.value);
|
|
87
|
+
}
|
|
88
|
+
return buckets;
|
|
89
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -28,6 +28,7 @@ export * from "./components/section";
|
|
|
28
28
|
export * from "./components/select-list";
|
|
29
29
|
export * from "./components/settings-list";
|
|
30
30
|
export * from "./components/spacer";
|
|
31
|
+
export * from "./components/sparkline";
|
|
31
32
|
export * from "./components/tab-bar";
|
|
32
33
|
export * from "./components/table";
|
|
33
34
|
export * from "./components/text";
|
package/src/native/describe.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* ]);
|
|
10
10
|
* }
|
|
11
11
|
*/
|
|
12
|
-
import type { TspKind, TspProps, TspSpan, TspText } from "@oh-my-pi/pi-wire";
|
|
12
|
+
import type { TspKind, TspPropNode, TspProps, TspSpan, TspText } from "@oh-my-pi/pi-wire";
|
|
13
13
|
import type { NativeChild, NativeNode } from "./node";
|
|
14
14
|
|
|
15
15
|
/** A node of any kind. */
|
|
@@ -76,6 +76,23 @@ export function withHidden(described: NativeNode, hidden: boolean): NativeNode {
|
|
|
76
76
|
return node(described.k, { ...described.p, hidden: true } as TspProps, described.c, described.key);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
/**
|
|
80
|
+
* A described tree as the node tree a prop carries (a `hovercard`): plain
|
|
81
|
+
* nodes only, since nothing reconciles inside a prop; component children
|
|
82
|
+
* (which describe themselves per frame) are left out.
|
|
83
|
+
*/
|
|
84
|
+
export function propNode(described: NativeNode): TspPropNode {
|
|
85
|
+
const out: { k: TspKind; p?: TspProps; c?: TspPropNode[]; key?: string } = { k: described.k };
|
|
86
|
+
if (described.p !== undefined) out.p = described.p;
|
|
87
|
+
if (described.c !== undefined) {
|
|
88
|
+
const children: TspPropNode[] = [];
|
|
89
|
+
for (const child of described.c) if ("k" in child) children.push(propNode(child));
|
|
90
|
+
out.c = children;
|
|
91
|
+
}
|
|
92
|
+
if (described.key !== undefined) out.key = described.key;
|
|
93
|
+
return out as TspPropNode;
|
|
94
|
+
}
|
|
95
|
+
|
|
79
96
|
/** Stable node key for an arbitrary identity string; keys join into `/` keypaths, so identities are hashed. */
|
|
80
97
|
export function stableKey(identity: string): string {
|
|
81
98
|
return Bun.hash(identity).toString(36);
|
package/src/native/tone.ts
CHANGED
|
@@ -50,6 +50,28 @@ export function backgroundChrome(bg: ThemeBg | undefined): BackgroundChrome {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
/** The omp theme colour an ANSI renderer draws a TSP tone with (the inverse of {@link colorTone}). */
|
|
54
|
+
export function toneColor(tone: TspTone): ThemeColor {
|
|
55
|
+
switch (tone) {
|
|
56
|
+
case "neutral":
|
|
57
|
+
return "text";
|
|
58
|
+
case "accent":
|
|
59
|
+
case "info":
|
|
60
|
+
return "accent";
|
|
61
|
+
case "success":
|
|
62
|
+
return "success";
|
|
63
|
+
case "warning":
|
|
64
|
+
case "pending":
|
|
65
|
+
return "warning";
|
|
66
|
+
case "error":
|
|
67
|
+
return "error";
|
|
68
|
+
case "muted":
|
|
69
|
+
return "muted";
|
|
70
|
+
case "user":
|
|
71
|
+
return "customMessageLabel";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
53
75
|
/**
|
|
54
76
|
* Tone of an omp colour used as a severity or border colour; undefined for
|
|
55
77
|
* colours that carry no tone (callers pick their own fallback).
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
* - Table view: every registered agent except Main (Main IS the ambient
|
|
6
6
|
* chat), live from the global AgentHubRegistry — status, unread irc count,
|
|
7
7
|
* current/last task, last activity. Navigate with keys, wheel, hover, and
|
|
8
|
-
* click; `r` revives a parked agent, `x` aborts + releases one.
|
|
8
|
+
* click; `r` revives a parked or killed agent, `x` aborts + releases one.
|
|
9
9
|
* - Chat view: per-agent transcript (incremental session-file tail, absorbed
|
|
10
10
|
* from the old session observer overlay) plus an input line. Submitting
|
|
11
|
-
* revives a parked agent, then prompts/steers it; the message
|
|
12
|
-
* agent's persisted history via the normal prompt path.
|
|
11
|
+
* revives a parked or killed agent, then prompts/steers it; the message
|
|
12
|
+
* lands in the agent's persisted history via the normal prompt path.
|
|
13
13
|
*
|
|
14
14
|
* Replaces the old SessionObserverOverlayComponent (ctrl+s observer).
|
|
15
15
|
*/
|
|
@@ -894,7 +894,11 @@ export class AgentHubOverlayComponent<TRecord extends AgentRecordLike = AgentRec
|
|
|
894
894
|
id: "revive",
|
|
895
895
|
label: "Revive",
|
|
896
896
|
keys: ["r"],
|
|
897
|
-
disabled:
|
|
897
|
+
disabled:
|
|
898
|
+
readOnly ??
|
|
899
|
+
(selected?.status === "parked" || selected?.status === "aborted"
|
|
900
|
+
? undefined
|
|
901
|
+
: "Only parked or killed agents can be revived"),
|
|
898
902
|
},
|
|
899
903
|
{ id: "kill", label: "Kill", keys: ["x"], danger: true, disabled: readOnly ?? (selected ? undefined : true) },
|
|
900
904
|
{ id: "view", label: "By parent", keys: ["t"], on: this.#viewMode === "tree" },
|
|
@@ -2498,15 +2502,15 @@ export class AgentHubOverlayComponent<TRecord extends AgentRecordLike = AgentRec
|
|
|
2498
2502
|
#activateAgent(ref: TRecord): void {
|
|
2499
2503
|
this.#notice = undefined;
|
|
2500
2504
|
const focusAgent = this.#focusAgent;
|
|
2501
|
-
//
|
|
2502
|
-
//
|
|
2503
|
-
if (ref.kind === "advisor" ||
|
|
2505
|
+
// Advisor refs are read-only transcripts with no revivable session; open
|
|
2506
|
+
// the in-hub viewer instead of failing ensureLive.
|
|
2507
|
+
if (ref.kind === "advisor" || this.#remote || !focusAgent) {
|
|
2504
2508
|
this.openChat(ref.id);
|
|
2505
2509
|
return;
|
|
2506
2510
|
}
|
|
2507
2511
|
void (async () => {
|
|
2508
2512
|
try {
|
|
2509
|
-
await focusAgent(ref.id); // ensureLive inside revives parked
|
|
2513
|
+
await focusAgent(ref.id); // ensureLive inside revives parked and killed agents
|
|
2510
2514
|
this.#onDone();
|
|
2511
2515
|
} catch (error) {
|
|
2512
2516
|
this.#notice = error instanceof Error ? error.message : String(error);
|
|
@@ -2523,8 +2527,8 @@ export class AgentHubOverlayComponent<TRecord extends AgentRecordLike = AgentRec
|
|
|
2523
2527
|
this.#requestRender();
|
|
2524
2528
|
return;
|
|
2525
2529
|
}
|
|
2526
|
-
if (ref.status !== "parked") {
|
|
2527
|
-
this.#notice = `Agent "${ref.id}" is ${ref.status} — only parked agents can be revived.`;
|
|
2530
|
+
if (ref.status !== "parked" && ref.status !== "aborted") {
|
|
2531
|
+
this.#notice = `Agent "${ref.id}" is ${ref.status} — only parked or killed agents can be revived.`;
|
|
2528
2532
|
this.#requestRender();
|
|
2529
2533
|
return;
|
|
2530
2534
|
}
|
|
@@ -235,10 +235,10 @@ export class AgentTranscriptViewer implements Component {
|
|
|
235
235
|
this.#pollTimer.unref?.();
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
/** Advisor
|
|
238
|
+
/** Advisor transcripts are read-only; every other agent revives on send. */
|
|
239
239
|
get #sendable(): boolean {
|
|
240
240
|
const ref = this.#deps.registry.get(this.#deps.agentId);
|
|
241
|
-
if (!ref || ref.kind === "advisor"
|
|
241
|
+
if (!ref || ref.kind === "advisor") return false;
|
|
242
242
|
return Boolean(this.#deps.remote || this.#deps.lifecycle);
|
|
243
243
|
}
|
|
244
244
|
|