@0perator/operator 0.1.172 → 0.1.235
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 +858 -0
- package/README.md +4 -4
- package/dist/acp/agent.js +42 -3
- package/dist/acp/config-options.js +34 -0
- package/dist/acp/run.js +83 -2
- package/dist/auth/byo.js +118 -0
- package/dist/auth/commands.js +34 -1
- package/dist/autonomy/dream.js +1 -1
- package/dist/autonomy/index.js +16 -2
- package/dist/autonomy/media-robot.js +138 -0
- package/dist/autonomy/profile.js +77 -0
- package/dist/autonomy/session-factory.js +13 -9
- package/dist/background/index.js +8 -1
- package/dist/cli.js +132 -95
- package/dist/compose/client.js +56 -0
- package/dist/config/persona.js +186 -14
- package/dist/config/settings.js +49 -16
- package/dist/consolidation/scheduler.js +7 -4
- package/dist/consolidation/sleep.js +15 -1
- package/dist/engine/agent.js +152 -9
- package/dist/engine/aurora.js +73 -14
- package/dist/engine/compaction.js +129 -2
- package/dist/engine/computer-event.js +139 -0
- package/dist/engine/continuation.js +55 -0
- package/dist/engine/contract.js +3 -1
- package/dist/engine/grandmaster.js +13 -3
- package/dist/engine/messages.js +2 -2
- package/dist/engine/redact.js +25 -0
- package/dist/engine/rolling-summary.js +22 -7
- package/dist/engine/router-adapter.js +2 -0
- package/dist/engine/unrestricted.js +51 -0
- package/dist/engine/verify-gate.js +6 -0
- package/dist/index.browser.js +4 -0
- package/dist/index.js +4 -0
- package/dist/memory/index.js +0 -0
- package/dist/permissions/audit.js +4 -1
- package/dist/permissions/policy.js +4 -3
- package/dist/permissions/tier.js +31 -14
- package/dist/remote/host.js +9 -2
- package/dist/router/models.js +43 -2
- package/dist/session.js +113 -36
- package/dist/telemetry/events.js +8 -3
- package/dist/tools/computer.js +1 -1
- package/dist/tools/executor.js +22 -17
- package/dist/tools/mutating.js +6 -0
- package/dist/tools/registry.js +872 -27
- package/dist/tools/shell-session.js +36 -1
- package/dist/tools/tool-output-spill.js +2 -2
- package/dist/ui/ActivitySpinner.js +17 -6
- package/dist/ui/App.js +36 -14
- package/dist/ui/ArtifactPicker.js +109 -0
- package/dist/ui/BusTray.js +70 -0
- package/dist/ui/Composer.js +39 -8
- package/dist/ui/Markdown.js +5 -3
- package/dist/ui/MouseProvider.js +99 -19
- package/dist/ui/QuestionPrompt.js +24 -3
- package/dist/ui/ThinkingSpinner.js +9 -5
- package/dist/ui/ToolStep.js +17 -12
- package/dist/ui/Transcript.js +14 -7
- package/dist/ui/capabilities.js +0 -9
- package/dist/ui/listhit.js +23 -0
- package/dist/ui/mouse.js +22 -0
- package/dist/ui/osc.js +7 -4
- package/dist/ui/progressbar.js +46 -0
- package/dist/ui/shimmer.js +43 -0
- package/dist/ui/theme.js +2 -0
- package/dist/ui/tick.js +48 -0
- package/dist/ui/toolicons.js +69 -0
- package/dist/util/slash.js +1 -0
- package/package.json +2 -2
package/dist/ui/MouseProvider.js
CHANGED
|
@@ -1,29 +1,67 @@
|
|
|
1
|
-
// Phase 1 mouse layer — the Ink provider on top of the pure parser (mouse.ts).
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
|
|
1
|
+
// Phase 1 mouse layer — the Ink provider on top of the pure parser (mouse.ts). Two tracking policies:
|
|
2
|
+
// • FULLSCREEN (alwaysTrack): SGR tracking stays on for the whole session — wheel drives the alt-screen
|
|
3
|
+
// scrollback, and the geometry is deterministic (composer pinned to termRows bottom), so no DSR needed.
|
|
4
|
+
// • INLINE (demand-driven): tracking turns on ONLY while an overlay (picker/approval/question) is open —
|
|
5
|
+
// i.e. while ≥1 click region is registered — and off again the instant the last one unregisters, so the
|
|
6
|
+
// terminal's native wheel-scroll + drag-to-copy are untouched the rest of the time. Because the inline
|
|
7
|
+
// frame FLOATS, we learn the frame's bottom row with a DSR cursor probe (parsed out of the same stdin
|
|
8
|
+
// chunks as mouse events) and anchor click regions up from there (panelTopFromBottom + rowIndexAtY).
|
|
9
|
+
// Tracking left enabled after a crash captures every click until a manual reset (the #1 real mouse bug), so
|
|
10
|
+
// we disable on unmount AND on process 'exit' (which fires after the app's own SIGINT/SIGTERM → process.exit,
|
|
11
|
+
// leaving Ctrl-C behaviour unchanged). Blueprint: _ai-docs/architecture/tui-enterprise-upgrade.md.
|
|
12
|
+
import React, { createContext, useCallback, useContext, useEffect, useRef, useState } from "react";
|
|
10
13
|
import { useStdin } from "ink";
|
|
11
|
-
import { parseMouse, hitTest, MOUSE_ON, MOUSE_OFF } from "./mouse.js";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
import { parseMouse, parseCursorReport, hitTest, panelTopFromBottom, MOUSE_ON, MOUSE_OFF, DSR_QUERY } from "./mouse.js";
|
|
15
|
+
import { rowIndexAtY } from "./listhit.js";
|
|
16
|
+
import { termRows, termCols } from "./term.js";
|
|
17
|
+
const noop = () => () => { };
|
|
18
|
+
const Ctx = createContext({
|
|
19
|
+
enabled: false, registerRegion: noop, onWheel: noop,
|
|
20
|
+
frameBottomRow: 24, stackHeight: 0, setStackHeight: () => { }, probe: () => { },
|
|
21
|
+
});
|
|
22
|
+
export function MouseProvider({ enabled, alwaysTrack = false, children }) {
|
|
14
23
|
const { stdin, setRawMode, isRawModeSupported } = useStdin();
|
|
15
24
|
const regions = useRef(new Map());
|
|
16
25
|
const wheels = useRef(new Set());
|
|
26
|
+
const [activeCount, setActiveCount] = useState(0); // # registered click regions — drives demand tracking
|
|
27
|
+
const [measuredBottom, setMeasuredBottom] = useState(null); // last DSR result (inline)
|
|
28
|
+
const [stackHeight, setStackHeight] = useState(0);
|
|
17
29
|
const registerRegion = useCallback((r, onClick) => {
|
|
18
30
|
regions.current.set(r.id, { r, onClick });
|
|
19
|
-
|
|
31
|
+
setActiveCount((c) => c + 1);
|
|
32
|
+
return () => {
|
|
33
|
+
if (regions.current.delete(r.id))
|
|
34
|
+
setActiveCount((c) => Math.max(0, c - 1));
|
|
35
|
+
};
|
|
20
36
|
}, []);
|
|
21
37
|
const onWheel = useCallback((h) => {
|
|
22
38
|
wheels.current.add(h);
|
|
23
39
|
return () => { wheels.current.delete(h); };
|
|
24
40
|
}, []);
|
|
41
|
+
const probe = useCallback(() => {
|
|
42
|
+
if (alwaysTrack)
|
|
43
|
+
return; // fullscreen anchors to termRows() — no probe needed
|
|
44
|
+
try {
|
|
45
|
+
process.stdout.write(DSR_QUERY);
|
|
46
|
+
}
|
|
47
|
+
catch { /* stream gone */ }
|
|
48
|
+
}, [alwaysTrack]);
|
|
49
|
+
// Defensive: on mount in inline/demand mode, ensure SGR tracking is OFF so the terminal's native
|
|
50
|
+
// scroll + copy work from the first frame — a prior crash or stray enable could have left a tracking
|
|
51
|
+
// mode on (which breaks wheel-scroll in Terminal.app until a manual reset). The demand effect below turns
|
|
52
|
+
// tracking on ONLY while an overlay is open, and off again when it closes.
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (!enabled || alwaysTrack)
|
|
55
|
+
return;
|
|
56
|
+
try {
|
|
57
|
+
process.stdout.write(MOUSE_OFF);
|
|
58
|
+
}
|
|
59
|
+
catch { /* stream gone */ }
|
|
60
|
+
}, [enabled, alwaysTrack]);
|
|
61
|
+
// Tracking is ON in fullscreen always, or in inline only while an overlay registered a click region.
|
|
62
|
+
const shouldTrack = enabled && (alwaysTrack || activeCount > 0);
|
|
25
63
|
useEffect(() => {
|
|
26
|
-
if (!
|
|
64
|
+
if (!shouldTrack || !stdin)
|
|
27
65
|
return;
|
|
28
66
|
let off = false;
|
|
29
67
|
const disable = () => { if (off)
|
|
@@ -40,8 +78,18 @@ export function MouseProvider({ enabled, children }) {
|
|
|
40
78
|
process.stdout.write(MOUSE_ON);
|
|
41
79
|
}
|
|
42
80
|
catch { /* */ }
|
|
81
|
+
if (!alwaysTrack) {
|
|
82
|
+
try {
|
|
83
|
+
process.stdout.write(DSR_QUERY);
|
|
84
|
+
}
|
|
85
|
+
catch { /* */ }
|
|
86
|
+
} // learn the floating frame's bottom
|
|
43
87
|
const onData = (buf) => {
|
|
44
|
-
|
|
88
|
+
const chunk = typeof buf === "string" ? buf : buf.toString("utf8");
|
|
89
|
+
const cur = parseCursorReport(chunk);
|
|
90
|
+
if (cur)
|
|
91
|
+
setMeasuredBottom(cur.row);
|
|
92
|
+
for (const e of parseMouse(chunk)) {
|
|
45
93
|
if (e.action === "wheel-up" || e.action === "wheel-down") {
|
|
46
94
|
for (const h of wheels.current)
|
|
47
95
|
h(e);
|
|
@@ -58,13 +106,17 @@ export function MouseProvider({ enabled, children }) {
|
|
|
58
106
|
const onExit = () => disable(); // fires on normal exit + after the app's signal handlers call process.exit
|
|
59
107
|
process.on("exit", onExit);
|
|
60
108
|
return () => { stdin.off("data", onData); process.off("exit", onExit); disable(); };
|
|
61
|
-
}, [
|
|
62
|
-
|
|
109
|
+
}, [shouldTrack, alwaysTrack, stdin, setRawMode, isRawModeSupported]);
|
|
110
|
+
// In fullscreen the composer is pinned to the terminal bottom, so the frame bottom IS termRows(). In
|
|
111
|
+
// inline we use the DSR measurement once it lands, falling back to termRows() until then (a good guess
|
|
112
|
+
// whenever scrollback already fills the screen) so an early click is never wildly off.
|
|
113
|
+
const frameBottomRow = alwaysTrack ? termRows() : (measuredBottom ?? termRows());
|
|
114
|
+
return React.createElement(Ctx.Provider, { value: { enabled, registerRegion, onWheel, frameBottomRow, stackHeight, setStackHeight, probe } }, children);
|
|
63
115
|
}
|
|
64
|
-
/** The mouse context: `enabled` (false
|
|
116
|
+
/** The mouse context: `enabled` (false when the terminal can't do SGR mouse) + the registration/anchor API. */
|
|
65
117
|
export const useMouse = () => useContext(Ctx);
|
|
66
118
|
/** Subscribe to wheel-scroll events (global; no hit-testing). Auto-unsubscribes on unmount. A no-op when
|
|
67
|
-
* the provider
|
|
119
|
+
* the provider isn't tracking (inline with no overlay open) since nothing dispatches. */
|
|
68
120
|
export function useOnWheel(handler) {
|
|
69
121
|
const { onWheel } = useMouse();
|
|
70
122
|
useEffect(() => onWheel(handler), [onWheel, handler]);
|
|
@@ -79,3 +131,31 @@ export function useClickRegion(region, onClick) {
|
|
|
79
131
|
return registerRegion(region, onClick);
|
|
80
132
|
}, [registerRegion, region?.id, region?.x, region?.y, region?.width, region?.height, onClick]);
|
|
81
133
|
}
|
|
134
|
+
/** Make a scrolling list clickable: given the picker's OWN measured height and its row layout (everything
|
|
135
|
+
* except the absolute top row, which is derived), register one full-width region over the item rows and
|
|
136
|
+
* turn a left-click into the underlying item index via listhit.rowIndexAtY. The absolute anchor is
|
|
137
|
+
* computed from the frame bottom (DSR-measured inline, termRows() fullscreen) minus the composer block
|
|
138
|
+
* below it minus the picker's own height — so it tracks the floating inline frame without magic numbers.
|
|
139
|
+
* A no-op when `active` is false or the terminal can't do mouse, so pickers wire it unconditionally. */
|
|
140
|
+
export function useClickList(opts) {
|
|
141
|
+
const { enabled, frameBottomRow, stackHeight, probe } = useMouse();
|
|
142
|
+
const { id, active, headerLines, rowHeight, windowStart, visibleCount, onPick } = opts;
|
|
143
|
+
// Refresh the frame-bottom anchor whenever the picker opens or its geometry changes (open, resize, filter).
|
|
144
|
+
useEffect(() => { if (active && enabled)
|
|
145
|
+
probe(); }, [active, enabled, probe, stackHeight, visibleCount, windowStart]);
|
|
146
|
+
const on = active && enabled && visibleCount > 0 && rowHeight > 0;
|
|
147
|
+
// The active picker is the TOP of the measured stack, so its top row is frameBottom − stackHeight + 1
|
|
148
|
+
// (belowHeight folded into the single stack measurement); headerLines then steps to the first item.
|
|
149
|
+
const panelTopY = panelTopFromBottom(frameBottomRow, stackHeight, 0);
|
|
150
|
+
const firstRowY = panelTopY + headerLines;
|
|
151
|
+
const region = on
|
|
152
|
+
? { id, x: 1, y: firstRowY, width: termCols(), height: rowHeight * visibleCount }
|
|
153
|
+
: null;
|
|
154
|
+
const layout = { panelTopY, headerLines, rowHeight, windowStart, visibleCount };
|
|
155
|
+
const onClick = useCallback((e) => {
|
|
156
|
+
const idx = rowIndexAtY(e.y, layout);
|
|
157
|
+
if (idx !== null)
|
|
158
|
+
onPick(idx);
|
|
159
|
+
}, [panelTopY, headerLines, rowHeight, windowStart, visibleCount, onPick]);
|
|
160
|
+
useClickRegion(region, onClick);
|
|
161
|
+
}
|
|
@@ -5,8 +5,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
5
5
|
// boxed into the listed choices — picking it opens a free-text line whose typed answer is returned to the
|
|
6
6
|
// model verbatim. useInput is active ONLY while a question is pending (the Composer is suspended meanwhile),
|
|
7
7
|
// so a digit selects an option rather than typing into the prompt. Mirrors ApprovalPrompt.
|
|
8
|
-
import { useEffect, useState } from "react";
|
|
9
|
-
import { Box, Text, useInput } from "ink";
|
|
8
|
+
import { useEffect, useRef, useState } from "react";
|
|
9
|
+
import { Box, Text, useInput, measureElement } from "ink";
|
|
10
|
+
import { useClickList } from "./MouseProvider.js";
|
|
10
11
|
// The always-present final choice. Selecting it lets the owner type their own reply (or just talk it
|
|
11
12
|
// through) instead of picking one of the model's options — so every prompt has an out.
|
|
12
13
|
export const CHAT_LABEL = "Chat about it — type your own reply";
|
|
@@ -53,6 +54,8 @@ export function questionKey(st, input, key, options) {
|
|
|
53
54
|
}
|
|
54
55
|
export function QuestionPrompt({ pending }) {
|
|
55
56
|
const [st, setSt] = useState({ mode: "choose", buffer: "", highlight: 0 });
|
|
57
|
+
const qRef = useRef(null);
|
|
58
|
+
const [qLines, setQLines] = useState(1); // measured height of the (possibly wrapping) question line
|
|
56
59
|
useEffect(() => { setSt({ mode: "choose", buffer: "", highlight: 0 }); }, [pending]); // reset for each new question
|
|
57
60
|
useInput((input, key) => {
|
|
58
61
|
if (!pending)
|
|
@@ -63,8 +66,26 @@ export function QuestionPrompt({ pending }) {
|
|
|
63
66
|
else if (a.state)
|
|
64
67
|
setSt(a.state);
|
|
65
68
|
}, { isActive: !!pending });
|
|
69
|
+
// Click-to-select (hooks run every render → compute before the early return). The question can WRAP, so
|
|
70
|
+
// its height is measured rather than assumed; options + the chat escape are the clickable rows (1 line
|
|
71
|
+
// each). A click moves the highlight — Enter still commits — so a mis-anchored click is visibly correctable.
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (!qRef.current)
|
|
74
|
+
return;
|
|
75
|
+
const { height } = measureElement(qRef.current);
|
|
76
|
+
if (height > 0)
|
|
77
|
+
setQLines(height);
|
|
78
|
+
});
|
|
79
|
+
const optCount = (pending?.options.length ?? 0) + 1; // model options + the always-present chat escape
|
|
80
|
+
const headerLines = 1 /* marginTop */ + 1 /* top border */ + qLines;
|
|
81
|
+
useClickList({
|
|
82
|
+
id: "question-list",
|
|
83
|
+
active: !!pending && st.mode === "choose",
|
|
84
|
+
headerLines, rowHeight: 1, windowStart: 0, visibleCount: optCount,
|
|
85
|
+
onPick: (idx) => setSt((s) => ({ ...s, mode: "choose", highlight: idx })),
|
|
86
|
+
});
|
|
66
87
|
if (!pending)
|
|
67
88
|
return null;
|
|
68
89
|
const chatIndex = pending.options.length; // 0-based highlight index for the chat escape
|
|
69
|
-
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, borderStyle: "round", borderColor: "cyan", paddingX: 1, children: [_jsxs(Text, { color: "cyan", bold: true, children: ["? ", _jsx(Text, { color: "white", children: pending.question })] }), pending.options.map((o, i) => (_jsxs(Text, { children: [" ", st.mode === "choose" && st.highlight === i ? _jsx(Text, { color: "cyan", bold: true, children: "❯ " }) : _jsx(Text, { children: " " }), _jsxs(Text, { color: "cyan", children: ["[", i + 1, "]"] }), " ", _jsx(Text, { bold: st.mode === "choose" && st.highlight === i, children: o })] }, i))), _jsxs(Text, { children: [" ", st.mode === "choose" && st.highlight === chatIndex ? _jsx(Text, { color: "cyan", bold: true, children: "❯ " }) : _jsx(Text, { children: " " }), _jsxs(Text, { color: "cyan", children: ["[", chatIndex + 1, "]"] }), " ", _jsx(Text, { color: "magenta", bold: st.mode === "choose" && st.highlight === chatIndex, children: CHAT_LABEL })] }), st.mode === "type" ? (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsxs(Text, { children: [_jsx(Text, { color: "magenta", children: "› " }), st.buffer, _jsx(Text, { color: "cyan", children: "\u258C" })] }), _jsx(Text, { dimColor: true, children: " type your reply · Enter to send · Esc for the menu" })] })) : (_jsxs(Text, { dimColor: true, children: [" ↑/↓ to move · Enter to pick · or press 1-", chatIndex + 1, " to jump"] }))] }));
|
|
90
|
+
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, borderStyle: "round", borderColor: "cyan", paddingX: 1, children: [_jsx(Box, { ref: qRef, children: _jsxs(Text, { color: "cyan", bold: true, children: ["? ", _jsx(Text, { color: "white", children: pending.question })] }) }), pending.options.map((o, i) => (_jsxs(Text, { children: [" ", st.mode === "choose" && st.highlight === i ? _jsx(Text, { color: "cyan", bold: true, children: "❯ " }) : _jsx(Text, { children: " " }), _jsxs(Text, { color: "cyan", children: ["[", i + 1, "]"] }), " ", _jsx(Text, { bold: st.mode === "choose" && st.highlight === i, children: o })] }, i))), _jsxs(Text, { children: [" ", st.mode === "choose" && st.highlight === chatIndex ? _jsx(Text, { color: "cyan", bold: true, children: "❯ " }) : _jsx(Text, { children: " " }), _jsxs(Text, { color: "cyan", children: ["[", chatIndex + 1, "]"] }), " ", _jsx(Text, { color: "magenta", bold: st.mode === "choose" && st.highlight === chatIndex, children: CHAT_LABEL })] }), st.mode === "type" ? (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsxs(Text, { children: [_jsx(Text, { color: "magenta", children: "› " }), st.buffer, _jsx(Text, { color: "cyan", children: "\u258C" })] }), _jsx(Text, { dimColor: true, children: " type your reply · Enter to send · Esc for the menu" })] })) : (_jsxs(Text, { dimColor: true, children: [" ↑/↓ to move · Enter to pick · or press 1-", chatIndex + 1, " to jump"] }))] }));
|
|
70
91
|
}
|
|
@@ -6,15 +6,17 @@ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
|
6
6
|
// the live token/time metrics (formerly on StatusRule) ride beside that.
|
|
7
7
|
import { useEffect, useState } from "react";
|
|
8
8
|
import { Box, Text } from "ink";
|
|
9
|
-
import {
|
|
9
|
+
import { ShimmerText, PEARL } from "./shimmer.js";
|
|
10
10
|
const DEFAULT_VERBS = [
|
|
11
11
|
"Thinking", "Reasoning", "Noodling", "Synthesizing", "Percolating", "Untangling", "Weighing",
|
|
12
12
|
];
|
|
13
13
|
// Ink render props per tone — the truecolor equivalents of star_signal.py's ANSI TONES.
|
|
14
|
+
// Pearl tones (slate → white) so the STAR matches the thinking shimmer (shimmer.tsx PEARL). The heartbeat keeps
|
|
15
|
+
// its sun→burst motion; only the hue changed from amber to pearl, so star + shimmering verb read as one piece.
|
|
14
16
|
const TONE_STYLE = {
|
|
15
|
-
amber: { color:
|
|
16
|
-
bright: { color:
|
|
17
|
-
dim: { color:
|
|
17
|
+
amber: { color: "#aeb9cc" }, // pearl mid (slate-white)
|
|
18
|
+
bright: { color: "#ffffff", bold: true }, // pearl peak — the burst
|
|
19
|
+
dim: { color: "#7a8698", dim: true }, // pearl base
|
|
18
20
|
faint: { dim: true },
|
|
19
21
|
};
|
|
20
22
|
// (tone, glyph, ticks) — ticks is how many beats the frame holds. Sun → point → silence → burst.
|
|
@@ -60,5 +62,7 @@ metrics, }) {
|
|
|
60
62
|
const [tone, glyph] = SEQUENCE[tick];
|
|
61
63
|
const style = TONE_STYLE[tone];
|
|
62
64
|
const label = verb ?? verbs[verbIdx % verbs.length];
|
|
63
|
-
|
|
65
|
+
// Star keeps its amber tone animation; the VERB now carries a pearl (slate→white) shimmer sweep driven by the
|
|
66
|
+
// same tick — the continuous light replaces the old tone-flash as the "alive" cue.
|
|
67
|
+
return (_jsxs(Box, { children: [_jsxs(Text, { color: style.color, bold: style.bold, dimColor: style.dim, children: [glyph, " "] }), _jsx(ShimmerText, { text: `${label}…`, frame: tick, palette: PEARL }), metrics ? _jsx(Text, { dimColor: true, children: " " + metrics }) : null] }));
|
|
64
68
|
}
|
package/dist/ui/ToolStep.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
// Per-tool card: select -> run -> done/error, with a live sub-second timer while running
|
|
3
|
-
// (SPEC §3: real timers, never rounded to 0.0s).
|
|
4
|
-
import { useEffect, useState } from "react";
|
|
5
2
|
import { Box, Text } from "ink";
|
|
6
3
|
import { formatDuration } from "./format.js";
|
|
7
4
|
import { fileLink } from "./osc.js";
|
|
8
5
|
import { theme } from "./theme.js";
|
|
9
6
|
import { computeEditDiff } from "./editdiff.js";
|
|
7
|
+
import { useTick } from "./tick.js";
|
|
8
|
+
import { glyphFor, toolKind, KIND_HUE } from "./toolicons.js";
|
|
9
|
+
import { renderBar, mediaEtaMs, mediaProgressFraction } from "./progressbar.js";
|
|
10
|
+
import { ShimmerText, huePalette } from "./shimmer.js";
|
|
10
11
|
const PATH_KEYS = new Set(["path", "file", "filename"]);
|
|
11
|
-
|
|
12
|
+
// Icon is now per ACTION (see toolicons.ts: read ▤ · write ✎ · search ◎ · shell ❯ · web ◍ · git ❖ · skill ◆ ·
|
|
13
|
+
// agent ✺), animated while running; COLOR still carries the status (muted → amber → green → red).
|
|
12
14
|
const COLOR = { selected: theme.muted, running: theme.running, done: theme.success, error: theme.error };
|
|
13
15
|
// Args that identify WHAT a tool acted on — a path, a command, a URL. These are shown FIRST and IN FULL
|
|
14
16
|
// (never truncated), so you can always read the exact file name / path a tool wrote or read. Order matters:
|
|
@@ -49,13 +51,11 @@ export function argsPreview(args) {
|
|
|
49
51
|
return parts.join(", ");
|
|
50
52
|
}
|
|
51
53
|
export function ToolStep({ step }) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return () => clearInterval(id);
|
|
58
|
-
}, [step.status, step.startedAt]);
|
|
54
|
+
// ONE shared animation clock (tick.ts) drives both the per-action icon animation AND the live elapsed timer,
|
|
55
|
+
// so a running row needs no setInterval of its own — this replaces N per-row 250ms timers with a single
|
|
56
|
+
// ~8fps shared tick (richer motion, fewer timers). Settled rows don't subscribe, so they never re-render.
|
|
57
|
+
const frame = useTick(step.status === "running");
|
|
58
|
+
const now = Date.now();
|
|
59
59
|
const elapsed = step.durationMs ??
|
|
60
60
|
(step.status === "running" && step.startedAt
|
|
61
61
|
? now - step.startedAt
|
|
@@ -65,5 +65,10 @@ export function ToolStep({ step }) {
|
|
|
65
65
|
// Enterprise "what changed at a glance": only on a SETTLED edit (not mid-run, not errored — the write
|
|
66
66
|
// may never have landed), and only when the tool's own args are actually diffable.
|
|
67
67
|
const editDiff = step.status === "done" ? computeEditDiff(step.name, step.args) : undefined;
|
|
68
|
-
|
|
68
|
+
// Media-gen rows (image_generate/video_generate): the flux/video brokers report no percentage, so we
|
|
69
|
+
// fake a determinate feel from elapsed-vs-ETA (progressbar.ts), capped at 95% until the real result
|
|
70
|
+
// lands. Only RUNNING media rows get the bar — everything else renders exactly as before.
|
|
71
|
+
const isRunningMedia = toolKind(step.name) === "media" && step.status === "running";
|
|
72
|
+
const mediaFraction = isRunningMedia && elapsed != null ? mediaProgressFraction(elapsed, mediaEtaMs(step.name, step.args)) : undefined;
|
|
73
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { children: [_jsx(Text, { color: step.status === "running" ? KIND_HUE[toolKind(step.name)] : COLOR[step.status], bold: true, children: glyphFor(step.name, step.status, frame) }), " ", step.status === "running" ? _jsx(ShimmerText, { text: step.name, frame: frame, palette: huePalette(KIND_HUE[toolKind(step.name)]) }) : step.name, "(", argsPreview(step.args), ")", mediaFraction != null ? (_jsxs(Text, { children: [" ", _jsx(Text, { color: theme.mediaProgress, children: renderBar(mediaFraction) }), " ", Math.round(mediaFraction * 100), "%"] })) : null, elapsed != null ? _jsxs(Text, { dimColor: true, children: [" ", formatDuration(elapsed)] }) : null, editDiff ? (_jsxs(Text, { children: [" ", _jsxs(Text, { color: theme.success, children: ["+", editDiff.added] }), " ", _jsxs(Text, { color: theme.error, children: ["-", editDiff.removed] })] })) : null] }), step.summary ? _jsxs(Text, { dimColor: true, children: [" ", step.summary] }) : null, editDiff?.preview?.map((l, i) => (_jsxs(Text, { color: l.kind === "add" ? theme.success : theme.error, children: [" ", l.kind === "add" ? "+ " : "- ", l.text] }, i)))] }));
|
|
69
74
|
}
|
package/dist/ui/Transcript.js
CHANGED
|
@@ -111,14 +111,21 @@ function renderEntry(entry, live = false) {
|
|
|
111
111
|
// streaming we show only the tail that fits the window, so the dynamic frame can't overflow. Once the
|
|
112
112
|
// message settles it leaves `live` and renders in full via <Static> below, into scrollback.
|
|
113
113
|
if (live) {
|
|
114
|
-
//
|
|
115
|
-
//
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
// The in-flight tail only — never the whole message — height-bounded so the dynamic frame can't overflow.
|
|
115
|
+
// We show the model's THINKING (dim) and the ANSWER (full weight) TOGETHER so the owner follows the model's
|
|
116
|
+
// process through the WHOLE workflow, not just the gap before the answer starts. Before the answer begins,
|
|
117
|
+
// reasoning tails the full window; once the answer is streaming, reasoning keeps showing at lower opacity in
|
|
118
|
+
// a small reserved band above it, and the answer stays primary.
|
|
119
|
+
const rows = termRows(), cols = termCols();
|
|
120
|
+
const hasAnswer = !!message.content;
|
|
121
|
+
const reasoning = message.reasoning ?? "";
|
|
122
|
+
const rRows = hasAnswer ? Math.min(6, Math.max(0, Math.floor(rows / 3))) : rows; // dim band capped small once the answer is flowing
|
|
123
|
+
const r = reasoning && rRows > 0 ? liveTail(reasoning, rRows, cols) : null;
|
|
124
|
+
const aRows = Math.max(1, rows - (r ? rRows + 1 : 0)); // answer gets the remaining height (−1 for the band's clip notice)
|
|
125
|
+
const a = hasAnswer ? liveTail(message.content, aRows, cols) : null;
|
|
126
|
+
if (!r && !a)
|
|
118
127
|
return _jsx(Box, { marginBottom: 1 });
|
|
119
|
-
|
|
120
|
-
const dim = !message.content; // reasoning is dim; the answer is full weight
|
|
121
|
-
return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [clipped > 0 ? _jsx(Text, { dimColor: true, children: `⋯ +${clipped} more line${clipped === 1 ? "" : "s"} above (full text shown when complete)` }) : null, _jsx(Text, { dimColor: dim, children: text })] }));
|
|
128
|
+
return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [r && r.clipped > 0 ? _jsx(Text, { dimColor: true, children: `⋯ +${r.clipped} more thinking line${r.clipped === 1 ? "" : "s"} above` }) : null, r ? _jsx(Text, { dimColor: true, children: r.text }) : null, a && a.clipped > 0 ? _jsx(Text, { dimColor: true, children: `⋯ +${a.clipped} more line${a.clipped === 1 ? "" : "s"} above (full text shown when complete)` }) : null, a ? _jsx(Text, { children: a.text }) : null] }));
|
|
122
129
|
}
|
|
123
130
|
// Thought process first, dimmed; the real answer follows at full weight.
|
|
124
131
|
return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [message.reasoning ? _jsx(Text, { dimColor: true, children: message.reasoning }) : null, message.content ? _jsx(Markdown, { content: message.content }) : null] }));
|
package/dist/ui/capabilities.js
CHANGED
|
@@ -53,12 +53,3 @@ export function caps() {
|
|
|
53
53
|
_caps = detectCaps(process.env, !!process.stdout.isTTY);
|
|
54
54
|
return _caps;
|
|
55
55
|
}
|
|
56
|
-
/** One-line hint when the current terminal won't render clickable links — so the owner knows switching
|
|
57
|
-
* to iTerm2/Ghostty/Kitty/WezTerm makes URLs + artifact links clickable. Empty string when links work
|
|
58
|
-
* (or output isn't a TTY). Printed once after the INLINE boot masthead (cli.tsx); fullscreen/alt-screen
|
|
59
|
-
* sessions skip it here — they'll surface it via the status rule with the Phase 1 mouse-layer work. */
|
|
60
|
-
export function hyperlinkHint(c = caps()) {
|
|
61
|
-
if (!c.isTTY || c.osc8)
|
|
62
|
-
return "";
|
|
63
|
-
return `links aren't clickable in ${c.termName} — iTerm2, Ghostty, Kitty or WezTerm make URLs + artifact links clickable`;
|
|
64
|
-
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Click-to-select core for list panels (ArtifactPicker, model picker, plan-exit, …). Pure + testable
|
|
2
|
+
// WITHOUT a TTY — the one part of mouse click-to-select that doesn't need a live terminal to verify.
|
|
3
|
+
//
|
|
4
|
+
// The mouse layer (mouse.ts/MouseProvider) already turns a left-press into an (x,y) and hit-tests it to a
|
|
5
|
+
// Region. The remaining work for a scrolling list is: given the panel's top screen row and its layout, which
|
|
6
|
+
// VISIBLE row did (y) land on, and which underlying item index is that? This file is that mapping; the live
|
|
7
|
+
// step next session is only measuring `panelTopY` at render time (Ink doesn't expose absolute Y, so it's
|
|
8
|
+
// derived from the fullscreen layout) and registering one Region per row with `useClickRegion`.
|
|
9
|
+
/** The underlying item index a click at absolute row `y` selects, or null if `y` is outside the item rows
|
|
10
|
+
* (header, footer, border, or past the last visible item). Pure: the same inputs always map the same way,
|
|
11
|
+
* so it unit-tests without a terminal. */
|
|
12
|
+
export function rowIndexAtY(y, l) {
|
|
13
|
+
if (l.rowHeight <= 0 || l.visibleCount <= 0)
|
|
14
|
+
return null;
|
|
15
|
+
const firstRowY = l.panelTopY + l.headerLines;
|
|
16
|
+
const offset = y - firstRowY;
|
|
17
|
+
if (offset < 0)
|
|
18
|
+
return null; // clicked the header/border above the items
|
|
19
|
+
const visibleRow = Math.floor(offset / l.rowHeight);
|
|
20
|
+
if (visibleRow >= l.visibleCount)
|
|
21
|
+
return null; // clicked the footer/below the last item
|
|
22
|
+
return l.windowStart + visibleRow;
|
|
23
|
+
}
|
package/dist/ui/mouse.js
CHANGED
|
@@ -63,3 +63,25 @@ export function hitTest(regions, x, y) {
|
|
|
63
63
|
// reset (the single most common real-world mouse bug across every project surveyed).
|
|
64
64
|
export const MOUSE_ON = "\x1b[?1002h\x1b[?1006h";
|
|
65
65
|
export const MOUSE_OFF = "\x1b[?1006l\x1b[?1002l";
|
|
66
|
+
// DSR (Device Status Report) cursor-position probe — the one portable way to learn an absolute terminal
|
|
67
|
+
// row in INLINE mode, where Ink's dynamic frame FLOATS (no fixed bottom-anchor like the fullscreen/bounded
|
|
68
|
+
// path). The MouseProvider writes DSR_QUERY when an overlay registers a clickable list; the terminal
|
|
69
|
+
// replies `CSI row ; col R` on stdin, which parseCursorReport() pulls out of the same chunk stream the
|
|
70
|
+
// mouse events arrive on. We probe ONLY while a picker owns the keyboard (the composer is suspended then),
|
|
71
|
+
// so the reply can never land in the draft.
|
|
72
|
+
export const DSR_QUERY = "\x1b[6n";
|
|
73
|
+
const DSR = /\x1b\[(\d+);(\d+)R/;
|
|
74
|
+
/** The cursor {row,col} from a DSR reply embedded in a stdin chunk, or null if the chunk has none. Pure —
|
|
75
|
+
* so the provider can route a reply out of the same `data` events it already parses for mouse sequences. */
|
|
76
|
+
export function parseCursorReport(chunk) {
|
|
77
|
+
const m = DSR.exec(chunk);
|
|
78
|
+
return m ? { row: Number(m[1]), col: Number(m[2]) } : null;
|
|
79
|
+
}
|
|
80
|
+
/** Absolute terminal row of a floating inline panel's FIRST line (its top border), from the frame's
|
|
81
|
+
* measured bottom row and the heights — in rows — of the panel itself and everything rendered BELOW it
|
|
82
|
+
* (e.g. the suspended composer block). This is the inline counterpart to the fullscreen layout's fixed
|
|
83
|
+
* geometry: compose it with listhit.rowIndexAtY to turn a click's y into an item index. Pure; clamps to
|
|
84
|
+
* ≥1 so a mis-measured frame can never produce a negative (off-screen) anchor. */
|
|
85
|
+
export function panelTopFromBottom(frameBottomRow, panelHeight, belowHeight) {
|
|
86
|
+
return Math.max(1, frameBottomRow - belowHeight - panelHeight + 1);
|
|
87
|
+
}
|
package/dist/ui/osc.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// (incl. macOS Terminal.app) renders just the visible LABEL, and ansi-regex/string-width (Ink's own deps)
|
|
4
4
|
// treat the escapes as zero-width, so column math and truncation stay correct. Pure string ops.
|
|
5
5
|
import { resolve, isAbsolute } from "node:path";
|
|
6
|
+
import { caps } from "./capabilities.js";
|
|
6
7
|
const OPEN = "\x1b]8;;"; // OSC 8 ; params ; URI — params empty
|
|
7
8
|
const ST = "\x1b\\"; // string terminator
|
|
8
9
|
/** Tiny stable id (FNV-1a hash, base36) for an OSC 8 `id=` param — so a link that wraps across lines or
|
|
@@ -16,10 +17,12 @@ function linkId(seed) {
|
|
|
16
17
|
}
|
|
17
18
|
return (h >>> 0).toString(36);
|
|
18
19
|
}
|
|
19
|
-
/** True when we should emit hyperlink escapes:
|
|
20
|
-
*
|
|
20
|
+
/** True when we should emit OSC 8 hyperlink escapes: the terminal actually SUPPORTS them (caps().osc8 —
|
|
21
|
+
* which already requires a TTY) and they're not explicitly disabled. Gating on osc8 (not just isTTY) is
|
|
22
|
+
* the fix for Terminal.app, which silently renders a hyperlink as the bare LABEL — hiding the URL and not
|
|
23
|
+
* being clickable, the worst case. When this is false, callers show the URL as visible (dimmed) text. */
|
|
21
24
|
export function hyperlinksEnabled() {
|
|
22
|
-
return process.env.KODE_NO_HYPERLINKS !== "1" &&
|
|
25
|
+
return process.env.KODE_NO_HYPERLINKS !== "1" && caps().osc8;
|
|
23
26
|
}
|
|
24
27
|
/** Wrap `label` as a clickable hyperlink to `url`. Optional `id` sets the OSC 8 `id=` param so a link
|
|
25
28
|
* split across lines/redraws stays one hyperlink. Format: `OSC 8 ; [id=<id>] ; url ST label OSC 8 ;; ST`. */
|
|
@@ -33,7 +36,7 @@ export function link(label, url, id) {
|
|
|
33
36
|
* visual affordance (icon/color) is the caller's Ink <Text>; this only does the OSC 8 wrapping. */
|
|
34
37
|
export function artifactLink(label, url) {
|
|
35
38
|
if (!hyperlinksEnabled())
|
|
36
|
-
return label
|
|
39
|
+
return `${label} ${url}`; // not clickable here → show the URL so it's visible/copyable
|
|
37
40
|
return link(label, url, linkId(url));
|
|
38
41
|
}
|
|
39
42
|
/** Linkify a value that looks like a file path or an http(s) URL; return it unchanged otherwise. A
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Pure, testable progress-bar primitives shared by the media-gen bar (ToolStep.tsx) and the compaction
|
|
2
|
+
// sweep bar (ActivitySpinner.tsx). Font-safe per toolicons.ts's rule: only ▰ (U+25B0 filled) and
|
|
3
|
+
// ▱ (U+25B1 empty), both Geometric Shapes — no new Unicode blocks introduced.
|
|
4
|
+
const FILLED = "▰";
|
|
5
|
+
const EMPTY = "▱";
|
|
6
|
+
/** A determinate bar: `fraction` (0..1) of `width` cells filled, rounded to the nearest cell. Clamped so
|
|
7
|
+
* a stray out-of-range fraction can never render a negative-width slice or overfill the track. */
|
|
8
|
+
export function renderBar(fraction, width = 10) {
|
|
9
|
+
const clamped = Math.max(0, Math.min(1, fraction));
|
|
10
|
+
const filled = Math.round(clamped * width);
|
|
11
|
+
return FILLED.repeat(filled) + EMPTY.repeat(width - filled);
|
|
12
|
+
}
|
|
13
|
+
/** An indeterminate "sweep" bar: a `litWidth`-cell bright window that starts at `frame % width` and wraps
|
|
14
|
+
* around the track — for a process with no knowable percentage (context compaction has no %, unlike
|
|
15
|
+
* media-gen's elapsed/ETA estimate). `frame` is the shared ticker's frame index (see tick.ts). */
|
|
16
|
+
export function renderSweepBar(frame, width = 10, litWidth = 3) {
|
|
17
|
+
const start = ((frame % width) + width) % width; // frame is always >=0 from useTick, but stay safe
|
|
18
|
+
let out = "";
|
|
19
|
+
for (let i = 0; i < width; i++) {
|
|
20
|
+
const dist = (i - start + width) % width;
|
|
21
|
+
out += dist < litWidth ? FILLED : EMPTY;
|
|
22
|
+
}
|
|
23
|
+
return out;
|
|
24
|
+
}
|
|
25
|
+
// ETA heuristics for media-gen tools (image_generate / video_generate): the flux/video brokers report no
|
|
26
|
+
// percentage, so progress is derived from elapsed-time-vs-estimate instead. video scales with frame count —
|
|
27
|
+
// LTX on the flux/video workers runs ~210s at the 97-frame default, roughly linear below that.
|
|
28
|
+
const IMAGE_ETA_MS = 40_000;
|
|
29
|
+
const VIDEO_BASE_FRAMES = 97;
|
|
30
|
+
const VIDEO_BASE_ETA_MS = 210_000;
|
|
31
|
+
const VIDEO_MIN_ETA_MS = 60_000;
|
|
32
|
+
/** Estimated total duration for a media-gen tool call, from its own args when available. */
|
|
33
|
+
export function mediaEtaMs(toolName, args) {
|
|
34
|
+
if (/video_generate/i.test(toolName)) {
|
|
35
|
+
const frames = typeof args?.num_frames === "number" ? args.num_frames : VIDEO_BASE_FRAMES;
|
|
36
|
+
return Math.max(VIDEO_MIN_ETA_MS, (frames / VIDEO_BASE_FRAMES) * VIDEO_BASE_ETA_MS);
|
|
37
|
+
}
|
|
38
|
+
return IMAGE_ETA_MS; // image_generate (and any other media-kind tool) — flat-rate estimate
|
|
39
|
+
}
|
|
40
|
+
/** elapsed/ETA as a progress fraction, capped at 95% — a job can legitimately run past its estimate, and
|
|
41
|
+
* reading 100% before the real result arrives would make the bar lie while the user keeps waiting. */
|
|
42
|
+
export function mediaProgressFraction(elapsedMs, etaMs) {
|
|
43
|
+
if (etaMs <= 0)
|
|
44
|
+
return 0.95;
|
|
45
|
+
return Math.min(0.95, elapsedMs / etaMs);
|
|
46
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Text } from "ink";
|
|
3
|
+
// Thinking = pearl (slate → white). The per-SITUATION hues live in toolicons.ts (KIND_HUE) so a tool row's
|
|
4
|
+
// running glyph tells you WHAT is happening by colour; thinking stays neutral.
|
|
5
|
+
export const PEARL = { waveW: 6, base: [122, 134, 152], shine: [255, 255, 255] };
|
|
6
|
+
const clamp = (v) => Math.max(0, Math.min(255, Math.round(v)));
|
|
7
|
+
const hex = (r, g, b) => `#${[r, g, b].map((v) => clamp(v).toString(16).padStart(2, "0")).join("")}`;
|
|
8
|
+
const lerp = (a, b, t) => a + (b - a) * t;
|
|
9
|
+
/** Per-character hex colours for one shimmer frame: a bright band of half-width `waveW` sweeps across `len`
|
|
10
|
+
* cells, lerping each char base→shine by its distance from the sweep head. Pure — unit-tested. */
|
|
11
|
+
export function shimmerColors(len, frame, p) {
|
|
12
|
+
const pos = (frame % (len + p.waveW * 2)) - p.waveW; // sweep head, with lead-in/out padding so it fully exits
|
|
13
|
+
const out = [];
|
|
14
|
+
for (let i = 0; i < len; i++) {
|
|
15
|
+
const d = Math.abs(i - pos);
|
|
16
|
+
if (d < p.waveW) {
|
|
17
|
+
const f = 1 - d / p.waveW;
|
|
18
|
+
out.push(hex(lerp(p.base[0], p.shine[0], f), lerp(p.base[1], p.shine[1], f), lerp(p.base[2], p.shine[2], f)));
|
|
19
|
+
}
|
|
20
|
+
else
|
|
21
|
+
out.push(hex(p.base[0], p.base[1], p.base[2]));
|
|
22
|
+
}
|
|
23
|
+
return out;
|
|
24
|
+
}
|
|
25
|
+
/** A subtle palette for a RUNNING tool row's name, from that tool kind's hue (toolicons KIND_HUE): rests at
|
|
26
|
+
* ~55% of the hue and the sweep lifts it to the hue nudged toward white — a dim pulse that says "this one is
|
|
27
|
+
* working", never a flash. Narrower band (waveW 4) than the thinking shimmer: tool names are short. Pure. */
|
|
28
|
+
export function huePalette(hue) {
|
|
29
|
+
const n = parseInt(hue.replace("#", ""), 16);
|
|
30
|
+
const rgb = [(n >> 16) & 255, (n >> 8) & 255, n & 255];
|
|
31
|
+
return {
|
|
32
|
+
waveW: 4,
|
|
33
|
+
base: [clamp(rgb[0] * 0.55), clamp(rgb[1] * 0.55), clamp(rgb[2] * 0.55)],
|
|
34
|
+
shine: [clamp(lerp(rgb[0], 255, 0.35)), clamp(lerp(rgb[1], 255, 0.35)), clamp(lerp(rgb[2], 255, 0.35))],
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/** Text rendered with a sweeping shimmer — one <Text> per character so each takes its own colour. `frame`
|
|
38
|
+
* comes from the caller's tick; `palette` sets the hue (PEARL for thinking). */
|
|
39
|
+
export function ShimmerText({ text, frame, palette = PEARL, bold }) {
|
|
40
|
+
const chars = [...text];
|
|
41
|
+
const colors = shimmerColors(chars.length, frame, palette);
|
|
42
|
+
return (_jsx(Text, { bold: bold, children: chars.map((ch, i) => (_jsx(Text, { color: colors[i], children: ch }, i))) }));
|
|
43
|
+
}
|
package/dist/ui/theme.js
CHANGED
|
@@ -23,6 +23,8 @@ const PALETTE = {
|
|
|
23
23
|
starBright: { hex: "#ffe2a0", ansi: "yellowBright", hc: "whiteBright" }, // the star's bright burst
|
|
24
24
|
textBright: { hex: "#ffffff", ansi: "whiteBright", hc: "whiteBright" }, // emphasized foreground
|
|
25
25
|
muted: { hex: "#8a8a8a", ansi: "gray", hc: "white" }, // borders, idle glyphs (a POSITIVE gray, not dimColor)
|
|
26
|
+
mediaProgress: { hex: "#e6c84a", ansi: "yellow", hc: "yellowBright" }, // media-gen progress bar (image/video_generate) — James: yellow, not amber
|
|
27
|
+
compactProgress: { hex: "#ff6ac1", ansi: "magenta", hc: "magentaBright" }, // compaction/recovery sweep bar — James: pink, not amber (no ANSI-16 pink, magenta is the closest low-color fallback)
|
|
26
28
|
};
|
|
27
29
|
// The 8-stop purple ramp for the OPERATOR wordmark (Masthead). Kept here so the brand gradient is part
|
|
28
30
|
// of the one palette; Masthead imports it. chalk.hex downsamples each stop at low color levels.
|
package/dist/ui/tick.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// ONE animation clock for all TUI motion. Every animated glyph (per-tool icons, future
|
|
2
|
+
// per-kind spinners) subscribes to this single shared ticker instead of owning a setInterval.
|
|
3
|
+
// N running rows each with their own timer = N× whole-frame redraws; one shared ticker fires
|
|
4
|
+
// all subscribers in the same React tick, so Ink coalesces them into ONE redraw per frame —
|
|
5
|
+
// richer motion at LOWER render cost. The interval runs only while something is subscribed and
|
|
6
|
+
// stops when the last subscriber leaves, so an idle TUI holds zero timers.
|
|
7
|
+
import { useEffect, useState } from "react";
|
|
8
|
+
let frame = 0;
|
|
9
|
+
let timer;
|
|
10
|
+
const subs = new Set();
|
|
11
|
+
// ~120ms (≈8fps): the rate the existing star/braille spinners already run at — smooth motion
|
|
12
|
+
// that Terminal.app tolerates (faster than ~80ms flashed in testing). One clock, so the whole
|
|
13
|
+
// TUI pulses together.
|
|
14
|
+
export const TICK_MS = 120;
|
|
15
|
+
function ensureRunning() {
|
|
16
|
+
if (timer)
|
|
17
|
+
return;
|
|
18
|
+
timer = setInterval(() => {
|
|
19
|
+
frame = (frame + 1) % 1_000_000;
|
|
20
|
+
for (const fn of subs)
|
|
21
|
+
fn();
|
|
22
|
+
}, TICK_MS);
|
|
23
|
+
timer.unref?.(); // never keep the process alive just to animate
|
|
24
|
+
}
|
|
25
|
+
function maybeStop() {
|
|
26
|
+
if (subs.size === 0 && timer) {
|
|
27
|
+
clearInterval(timer);
|
|
28
|
+
timer = undefined;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/** Subscribe to the shared animation frame. Returns the current frame index; the component
|
|
32
|
+
* re-renders once per tick ONLY while `active` is true (e.g. a tool is running). When no
|
|
33
|
+
* component is active the underlying timer is stopped entirely. */
|
|
34
|
+
export function useTick(active) {
|
|
35
|
+
const [, force] = useState(0);
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (!active)
|
|
38
|
+
return;
|
|
39
|
+
const fn = () => force((n) => (n + 1) % 1_000_000);
|
|
40
|
+
subs.add(fn);
|
|
41
|
+
ensureRunning();
|
|
42
|
+
return () => {
|
|
43
|
+
subs.delete(fn);
|
|
44
|
+
maybeStop();
|
|
45
|
+
};
|
|
46
|
+
}, [active]);
|
|
47
|
+
return frame;
|
|
48
|
+
}
|