@0perator/operator 0.1.161 → 0.1.163
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 -0
- package/dist/bus/inbox.js +58 -0
- package/dist/cli.js +16 -1
- package/dist/ui/App.js +36 -5
- package/dist/ui/BusTray.js +70 -0
- package/dist/ui/Transcript.js +23 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,33 @@ Operator is AXE's terminal coding agent (npm `@0perator/operator`), running on A
|
|
|
4
4
|
Newest first. Every release bumps `src/cli.tsx` VERSION + `package.json`, adds an entry here, and ships to
|
|
5
5
|
npm + both git remotes (memjar/kode, axetechnologies/kode). Test counts are the full suite at that release.
|
|
6
6
|
|
|
7
|
+
## 0.1.163 — 2026-09-30 — TUI: live Switchboard messages in the terminal (click-to-expand)
|
|
8
|
+
- Incoming Switchboard agent messages (the provider-agnostic on-box bus, memjar/switchboard) now surface
|
|
9
|
+
**live in the Operator terminal** as a click-to-expand tray — the end-to-end proof of the Phase-1 mouse
|
|
10
|
+
layer. `src/bus/inbox.ts` reads this session's inbox directly (same mailbox format, no cross-repo dep;
|
|
11
|
+
neutral defaults `SWITCHBOARD_DIR`→`~/.switchboard`, `SWITCHBOARD_AGENT`→`AXE_AGENT`→`role@host`); a 3s
|
|
12
|
+
poller in `cli.tsx` feeds a bounded tail to `<App>`.
|
|
13
|
+
- `src/ui/BusTray.tsx` renders each message as a collapsible card, **top-anchored** so each card's absolute
|
|
14
|
+
terminal row is deterministic (`trayLayout()`, pure + tested) — which is what makes left-click hit-testing
|
|
15
|
+
reliable without Ink absolute-position measurement. Click toggles the body; inline mode shows cards
|
|
16
|
+
read-only (no mouse there). A box without Switchboard installed shows nothing (empty-safe).
|
|
17
|
+
- Enterprise/AI-agnostic: no vendor lock, neutral env-overridable paths, works on any surface. Received
|
|
18
|
+
messages are DATA, never executed. Decision log: `_ai-docs/decisions/2026-09-30-switchboard-tui-bustray.md`.
|
|
19
|
+
Suite 748 green (+10).
|
|
20
|
+
|
|
21
|
+
## 0.1.162 — 2026-09-30 — TUI: wheel-scrollback in fullscreen (mouse layer wired into App)
|
|
22
|
+
- The Phase 1 mouse mechanism is now live in the app. `App.tsx`'s fullscreen branch mounts `MouseProvider`
|
|
23
|
+
(enabled only on a mouse-capable TTY — inline stays a native-scroll no-op) and a new `FullscreenBody`
|
|
24
|
+
turns wheel events into **scrollback over the alt-screen transcript**, which previously had none: the
|
|
25
|
+
bottom-anchored clip simply hid older entries with no way to reach them. Wheel-up slides the window back
|
|
26
|
+
through history (with a `⋯ N newer below` marker), wheel-down returns toward the live bottom, and any new
|
|
27
|
+
settled output snaps straight back to it — you never get stranded in history while the answer grows.
|
|
28
|
+
- Windowing is a pure, unit-tested `boundedWindow(total, scrollBack, tail)` in `Transcript.tsx`: `scrollBack`
|
|
29
|
+
is clamped to `[0, total-1]` (the oldest entry always stays reachable) and `scrollBack === 0` returns the
|
|
30
|
+
last `BOUNDED_TAIL` entries — **byte-identical to the pre-scroll behavior**, so inline and non-scrolled
|
|
31
|
+
fullscreen are unchanged. Live stream is suppressed only while scrolled up (it belongs at the true bottom).
|
|
32
|
+
- Decision log: `_ai-docs/decisions/2026-09-30-tui-mouse-scrollback.md`. Suite 738 green (+6).
|
|
33
|
+
|
|
7
34
|
## 0.1.161 — 2026-09-30 — TUI: MouseProvider + hooks (Phase 1 mouse layer mechanism)
|
|
8
35
|
- Builds on the SGR parser: `MouseProvider` (fullscreen-only) enables 1002+1006 tracking, parses stdin,
|
|
9
36
|
dispatches wheel→`useOnWheel` and left-press→hit-tested-region `onClick` (`useClickRegion`), and disables
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Switchboard inbox reader (Operator side of the provider-agnostic agent bus, memjar/switchboard).
|
|
2
|
+
// The bus is a file mailbox: one JSON file per message under <SWITCHBOARD_DIR>/agents/<agent>/inbox.
|
|
3
|
+
// This module reads THIS session's inbox so incoming messages can surface live in the TUI (BusTray) — the
|
|
4
|
+
// counterpart to the `switch`/`sb-msg` CLI other agents send with. We read the format directly rather than
|
|
5
|
+
// depend on the switchboard package, so kode-tsi stays self-contained.
|
|
6
|
+
//
|
|
7
|
+
// SECURITY: a bus message is DATA written by another agent — untrusted input. The UI surfaces it to the
|
|
8
|
+
// operator; nothing here executes message contents.
|
|
9
|
+
import { readdirSync, readFileSync, renameSync, mkdirSync, existsSync } from "node:fs";
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
import { homedir, hostname } from "node:os";
|
|
12
|
+
/** The bus state root — mirrors the switchboard CLI's SWITCHBOARD_DIR. Neutral default (~/.switchboard) so
|
|
13
|
+
* this works on any box/surface, not just the AXE fleet; the env var repoints it wherever the bus lives. */
|
|
14
|
+
export function busDir() {
|
|
15
|
+
return process.env.SWITCHBOARD_DIR || join(homedir(), ".switchboard");
|
|
16
|
+
}
|
|
17
|
+
/** This session's bus identity. Convention is role@node. SWITCHBOARD_AGENT is the neutral primary; AXE_AGENT
|
|
18
|
+
* is honored as a fleet fallback; else <role>@<host>. Vendor-neutral by default (no AI/product baked in). */
|
|
19
|
+
export function selfAgent() {
|
|
20
|
+
return process.env.SWITCHBOARD_AGENT || process.env.AXE_AGENT || `operator@${hostname().split(".")[0]}`;
|
|
21
|
+
}
|
|
22
|
+
const inboxOf = (agent) => join(busDir(), "agents", encodeURIComponent(agent), "inbox");
|
|
23
|
+
const readOf = (agent) => join(busDir(), "agents", encodeURIComponent(agent), "read");
|
|
24
|
+
/** Read `agent`'s inbox oldest-first. Unless `peek`, each message is moved to the read/ archive so it
|
|
25
|
+
* surfaces exactly once (delivered-once, matching the CLI). Corrupt or in-flight (.tmp-) files are
|
|
26
|
+
* skipped, never thrown — a bad drop can't wedge polling. Returns [] when the bus/inbox doesn't exist. */
|
|
27
|
+
export function pollBus(agent = selfAgent(), opts = {}) {
|
|
28
|
+
const dir = inboxOf(agent);
|
|
29
|
+
if (!existsSync(dir))
|
|
30
|
+
return [];
|
|
31
|
+
let files;
|
|
32
|
+
try {
|
|
33
|
+
files = readdirSync(dir).filter((f) => f.endsWith(".json") && !f.startsWith(".tmp-")).sort();
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
const out = [];
|
|
39
|
+
for (const f of files) {
|
|
40
|
+
const full = join(dir, f);
|
|
41
|
+
let msg = null;
|
|
42
|
+
try {
|
|
43
|
+
msg = JSON.parse(readFileSync(full, "utf8"));
|
|
44
|
+
}
|
|
45
|
+
catch { /* skip corrupt */ }
|
|
46
|
+
if (!msg || typeof msg.body !== "string")
|
|
47
|
+
continue;
|
|
48
|
+
out.push(msg);
|
|
49
|
+
if (!opts.peek) {
|
|
50
|
+
try {
|
|
51
|
+
mkdirSync(readOf(agent), { recursive: true });
|
|
52
|
+
renameSync(full, join(readOf(agent), f));
|
|
53
|
+
}
|
|
54
|
+
catch { /* already consumed by a concurrent read */ }
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return out;
|
|
58
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -11,6 +11,7 @@ import { mastheadLines } from "./ui/Masthead.js";
|
|
|
11
11
|
import { hyperlinkHint } from "./ui/capabilities.js";
|
|
12
12
|
import { shouldPromptPlanExit, resolvePlanExit, PLAN_EXIT_OPTIONS } from "./ui/planExit.js";
|
|
13
13
|
import { RemoteHost } from "./remote/host.js";
|
|
14
|
+
import { pollBus, selfAgent } from "./bus/inbox.js";
|
|
14
15
|
import { isErrorResult } from "./ui/format.js";
|
|
15
16
|
import { seedLiveTools, settleLiveTool } from "./ui/liveTools.js";
|
|
16
17
|
import { Session } from "./session.js";
|
|
@@ -415,6 +416,7 @@ function Root() {
|
|
|
415
416
|
// Gates the exit-time picker below — plan mode toggled on/off with no proposal stays silent.
|
|
416
417
|
const planProposedRef = useRef(false);
|
|
417
418
|
const [planExitPicker, setPlanExitPicker] = useState(null);
|
|
419
|
+
const [busMessages, setBusMessages] = useState([]); // live Switchboard messages for the click-to-expand tray
|
|
418
420
|
const alwaysAllowRef = useRef(new Set());
|
|
419
421
|
// Remembers the email a `/login <email>` sent a 6-digit code to, so the follow-up `/login <code>`
|
|
420
422
|
// knows which address to verify against — the in-session twin of the shell's email-code login.
|
|
@@ -1488,6 +1490,19 @@ function Root() {
|
|
|
1488
1490
|
const id = setInterval(() => setElapsed((Date.now() - turnStartRef.current) / 1000), 500); // 500ms: the elapsed readout shows whole/half seconds; 250ms doubled the whole-frame re-render rate (flashing)
|
|
1489
1491
|
return () => clearInterval(id);
|
|
1490
1492
|
}, [status]);
|
|
1493
|
+
// Switchboard poller: pull this session's incoming agent messages every few seconds and surface them in
|
|
1494
|
+
// the BusTray (click-to-expand). pollBus consumes each (moves to read/), so a message shows once; we keep a
|
|
1495
|
+
// bounded tail. Only runs once ready, and is a no-op when the bus dir doesn't exist — so a box without
|
|
1496
|
+
// Switchboard installed simply shows nothing. MUST be above the boot early-returns (stable hook order).
|
|
1497
|
+
useEffect(() => {
|
|
1498
|
+
if (boot !== "ready")
|
|
1499
|
+
return;
|
|
1500
|
+
const pull = () => { const incoming = pollBus(selfAgent()); if (incoming.length)
|
|
1501
|
+
setBusMessages((prev) => [...prev, ...incoming].slice(-20)); };
|
|
1502
|
+
pull();
|
|
1503
|
+
const id = setInterval(pull, 3000);
|
|
1504
|
+
return () => clearInterval(id);
|
|
1505
|
+
}, [boot]);
|
|
1491
1506
|
if (boot === "checking")
|
|
1492
1507
|
return _jsx(Text, { dimColor: true, children: bootDetail || "connecting to Operator…" });
|
|
1493
1508
|
if (boot === "down") {
|
|
@@ -1507,7 +1522,7 @@ function Root() {
|
|
|
1507
1522
|
? `${spin} reading your prompt… (${fmtDuration(elapsed)})`
|
|
1508
1523
|
: `${spin} ${fmtMeta(elapsed, liveTok)}`
|
|
1509
1524
|
: metrics;
|
|
1510
|
-
return (_jsx(App, { messages: entries, live: live, status: status, stepLabel: stepLabel, liveTools: liveTools, route: route, ctxPct: ctxPct, version: VERSION, fullscreen: FULLSCREEN, metrics: liveMetrics, sessionTokens: session.sessionTokens() + liveTok, authUser: authUser, tier: EVENT_ACTOR.tier, planMode: planMode, thinkMode: thinkMode, verbs: settings.verbs, bgAgents: bgAgents, tasks: tasks, onSubmit: onSubmit, onQueue: onQueue, onInterrupt: onInterrupt, onCycleMode: onCycleMode, opMode: opMode, approval: approval, question: question, modelPicker: modelPicker, planExitPicker: planExitPicker, onApprovalDecide: (allow, always) => {
|
|
1525
|
+
return (_jsx(App, { messages: entries, live: live, status: status, stepLabel: stepLabel, liveTools: liveTools, route: route, ctxPct: ctxPct, version: VERSION, fullscreen: FULLSCREEN, metrics: liveMetrics, sessionTokens: session.sessionTokens() + liveTok, authUser: authUser, tier: EVENT_ACTOR.tier, planMode: planMode, thinkMode: thinkMode, verbs: settings.verbs, bgAgents: bgAgents, tasks: tasks, onSubmit: onSubmit, onQueue: onQueue, onInterrupt: onInterrupt, onCycleMode: onCycleMode, opMode: opMode, approval: approval, question: question, modelPicker: modelPicker, planExitPicker: planExitPicker, busMessages: busMessages, onApprovalDecide: (allow, always) => {
|
|
1511
1526
|
const cur = approval;
|
|
1512
1527
|
if (cur)
|
|
1513
1528
|
settleApproval(cur.id, allow, always); // first-wins with any remote follower answer
|
package/dist/ui/App.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
// Composes the UI lane into the SPEC §6 shell. This is the whole UI/engine contract surface —
|
|
3
|
+
// the engine lane wires state + callbacks into these props; nothing below reaches into
|
|
4
|
+
// src/engine, src/tools, or src/router.
|
|
5
|
+
import { useEffect, useState } from "react";
|
|
2
6
|
import { Box, Text } from "ink";
|
|
3
|
-
import { termRows } from "./term.js";
|
|
7
|
+
import { termRows, termCols } from "./term.js";
|
|
8
|
+
import { caps } from "./capabilities.js";
|
|
9
|
+
import { MouseProvider, useOnWheel } from "./MouseProvider.js";
|
|
10
|
+
import { BusTray } from "./BusTray.js";
|
|
4
11
|
import { StatusRule } from "./StatusRule.js";
|
|
5
12
|
import { InputRule } from "./InputRule.js";
|
|
6
13
|
import { Transcript } from "./Transcript.js";
|
|
@@ -18,7 +25,7 @@ import { QuestionPrompt } from "./QuestionPrompt.js";
|
|
|
18
25
|
// calls at once; anything past the cap is summarized as a count instead of another row.
|
|
19
26
|
const MAX_LIVE_TOOL_ROWS = 6;
|
|
20
27
|
export function App(props) {
|
|
21
|
-
const { messages, live = null, status, thinkingVerb, verbs, stepLabel, liveTools = [], route, ctxPct, version, build, fullscreen = false, metrics, sessionTokens, authUser, tier, planMode, thinkMode, bgAgents, tasks = [], onSubmit, onQueue, onInterrupt, onCycleMode, opMode, approval = null, onApprovalDecide, question = null, modelPicker = null, planExitPicker = null } = props;
|
|
28
|
+
const { messages, live = null, status, thinkingVerb, verbs, stepLabel, liveTools = [], route, ctxPct, version, build, fullscreen = false, metrics, sessionTokens, authUser, tier, planMode, thinkMode, bgAgents, tasks = [], onSubmit, onQueue, onInterrupt, onCycleMode, opMode, approval = null, onApprovalDecide, question = null, modelPicker = null, planExitPicker = null, busMessages = [] } = props;
|
|
22
29
|
const thinking = status === "thinking" || status === "streaming";
|
|
23
30
|
// A parallel batch (2+ live rows) gets its own per-call view instead of the single-line StepSpinner —
|
|
24
31
|
// a lone call isn't worth a bordered block, the braille spinner + name already says enough.
|
|
@@ -37,10 +44,34 @@ export function App(props) {
|
|
|
37
44
|
// region (non-Static tail) so the newest output sits just above a composer pinned to the very bottom —
|
|
38
45
|
// no dead space. Off by default: inline keeps the terminal's native scrollback (mouse-scroll + copy).
|
|
39
46
|
if (fullscreen) {
|
|
40
|
-
|
|
41
|
-
|
|
47
|
+
// Enable the SGR mouse layer ONLY in fullscreen on a mouse-capable TTY — inline keeps the terminal's
|
|
48
|
+
// native scroll+copy, so it must never receive tracking. FullscreenBody (under the provider) turns
|
|
49
|
+
// wheel events into scrollback over the alt-screen transcript, which otherwise has no way to scroll.
|
|
50
|
+
return (_jsx(MouseProvider, { enabled: caps().mouse, children: _jsx(FullscreenBody, { messages: messages, live: live, activity: activity, prompts: prompts, bottom: bottom, busMessages: busMessages }) }));
|
|
42
51
|
}
|
|
43
52
|
// Inline (default): the dynamic frame grows below the Static transcript; unused space sits below it and
|
|
44
53
|
// fills as the conversation grows. Native scrollback preserved.
|
|
45
|
-
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Transcript, { entries: messages, live: live }), activity, prompts, bottom] }));
|
|
54
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(BusTray, { messages: busMessages, cols: termCols() }), _jsx(Transcript, { entries: messages, live: live }), activity, prompts, bottom] }));
|
|
55
|
+
}
|
|
56
|
+
// Entries the transcript window slides per wheel notch. A notch is one detent of the physical wheel; 3
|
|
57
|
+
// entries keeps scrollback brisk without leaping past short exchanges.
|
|
58
|
+
const WHEEL_STEP = 3;
|
|
59
|
+
// The fullscreen (alt-screen) layout body, mounted UNDER MouseProvider so useOnWheel receives events.
|
|
60
|
+
// It owns the scrollback offset: wheel-up slides the transcript window back through history (revealing the
|
|
61
|
+
// entries the bottom-anchored clip would otherwise hide), wheel-down returns toward the live bottom, and
|
|
62
|
+
// any new output snaps straight back to it — you never get stranded in history while the answer grows.
|
|
63
|
+
// Split out from App because useOnWheel must run inside the provider App itself returns.
|
|
64
|
+
function FullscreenBody({ messages, live, activity, prompts, bottom, busMessages }) {
|
|
65
|
+
const rows = termRows();
|
|
66
|
+
const [scrollBack, setScrollBack] = useState(0);
|
|
67
|
+
// New settled output resets the view to the live bottom (messages.length only grows as entries settle).
|
|
68
|
+
useEffect(() => { setScrollBack(0); }, [messages.length]);
|
|
69
|
+
useOnWheel((e) => {
|
|
70
|
+
setScrollBack((s) => e.action === "wheel-up"
|
|
71
|
+
? Math.min(s + WHEEL_STEP, Math.max(0, messages.length - 1)) // clamp: the oldest entry stays reachable
|
|
72
|
+
: Math.max(0, s - WHEEL_STEP));
|
|
73
|
+
});
|
|
74
|
+
// BusTray is the FIRST child so it top-anchors at row 1 — its cards' absolute rows are then deterministic
|
|
75
|
+
// (trayLayout topRow=1), which is what makes click hit-testing reliable. It renders nothing when empty.
|
|
76
|
+
return (_jsxs(Box, { flexDirection: "column", height: rows, children: [_jsx(BusTray, { messages: busMessages, cols: termCols() }), _jsxs(Box, { flexGrow: 1, flexDirection: "column", overflow: "hidden", justifyContent: "flex-end", children: [_jsx(Transcript, { entries: messages, live: live, bounded: true, scrollBack: scrollBack }), activity] }), prompts, bottom] }));
|
|
46
77
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// BusTray — live Switchboard messages surfaced in the Operator TUI as click-to-expand cards. Top-anchored
|
|
3
|
+
// in the fullscreen layout so each card's absolute terminal row is deterministic (topRow + Σ heights above),
|
|
4
|
+
// which is what makes mouse hit-testing reliable without Ink absolute-position measurement. Clicking a card
|
|
5
|
+
// toggles its body (the Phase-1 mouse layer in action). In inline mode (no mouse) the cards still render,
|
|
6
|
+
// just not clickable. Messages are DATA from other agents — shown, never executed.
|
|
7
|
+
import { useEffect, useState } from "react";
|
|
8
|
+
import { Box, Text } from "ink";
|
|
9
|
+
import { useMouse } from "./MouseProvider.js";
|
|
10
|
+
const MAX_BODY_LINES = 8; // cap an expanded card's body so one big message can't dominate the screen
|
|
11
|
+
function wrap(line, width) {
|
|
12
|
+
const w = Math.max(1, width);
|
|
13
|
+
if (line.length <= w)
|
|
14
|
+
return [line];
|
|
15
|
+
const out = [];
|
|
16
|
+
for (let i = 0; i < line.length; i += w)
|
|
17
|
+
out.push(line.slice(i, i + w));
|
|
18
|
+
return out;
|
|
19
|
+
}
|
|
20
|
+
/** Pure layout: assign each message a card with an absolute row (y) and height, given which ids are
|
|
21
|
+
* expanded and the terminal width. Deterministic top-to-bottom stacking from `topRow` — the basis for both
|
|
22
|
+
* render order and click hit-testing. Exported for unit tests. */
|
|
23
|
+
export function trayLayout(messages, expanded, cols, topRow = 1) {
|
|
24
|
+
const width = cols > 0 ? cols : 80;
|
|
25
|
+
const cards = [];
|
|
26
|
+
let y = topRow;
|
|
27
|
+
for (const msg of messages) {
|
|
28
|
+
const isExp = expanded.has(msg.id);
|
|
29
|
+
const bodyLines = isExp
|
|
30
|
+
? msg.body.split("\n").flatMap((l) => wrap(l, width - 2)).slice(0, MAX_BODY_LINES)
|
|
31
|
+
: [];
|
|
32
|
+
const height = 1 + bodyLines.length;
|
|
33
|
+
cards.push({ msg, y, height, expanded: isExp, bodyLines });
|
|
34
|
+
y += height;
|
|
35
|
+
}
|
|
36
|
+
return cards;
|
|
37
|
+
}
|
|
38
|
+
function preview(body, cols) {
|
|
39
|
+
const one = body.replace(/\s+/g, " ").trim();
|
|
40
|
+
const budget = Math.max(10, (cols > 0 ? cols : 80) - 28);
|
|
41
|
+
return one.length > budget ? one.slice(0, budget - 1) + "…" : one;
|
|
42
|
+
}
|
|
43
|
+
/** The tray. `cols` is the terminal width (for wrapping + region width). Renders nothing when empty. */
|
|
44
|
+
export function BusTray({ messages, cols }) {
|
|
45
|
+
const { registerRegion, enabled } = useMouse();
|
|
46
|
+
const [expanded, setExpanded] = useState(() => new Set());
|
|
47
|
+
const cards = trayLayout(messages, expanded, cols);
|
|
48
|
+
// Register every card's clickable region imperatively (one effect, not a hook-per-card — the message
|
|
49
|
+
// count varies, which would violate rules-of-hooks). A left-press anywhere on a card toggles its body.
|
|
50
|
+
const sig = cards.map((c) => `${c.msg.id}:${c.y}:${c.height}`).join("|");
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (!enabled || !cards.length)
|
|
53
|
+
return;
|
|
54
|
+
const disposers = cards.map((c) => registerRegion({ id: `bus:${c.msg.id}`, x: 1, y: c.y, width: Math.max(1, cols), height: c.height }, () => {
|
|
55
|
+
setExpanded((prev) => {
|
|
56
|
+
const next = new Set(prev);
|
|
57
|
+
if (next.has(c.msg.id))
|
|
58
|
+
next.delete(c.msg.id);
|
|
59
|
+
else
|
|
60
|
+
next.add(c.msg.id);
|
|
61
|
+
return next;
|
|
62
|
+
});
|
|
63
|
+
}));
|
|
64
|
+
return () => disposers.forEach((d) => d());
|
|
65
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
66
|
+
}, [enabled, registerRegion, cols, sig]);
|
|
67
|
+
if (!messages.length)
|
|
68
|
+
return null;
|
|
69
|
+
return (_jsx(Box, { flexDirection: "column", children: cards.map((c) => (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { color: "cyan", children: [c.expanded ? "▾" : "▸", " ", "📨 ", c.msg.from, c.msg.subject ? ` [${c.msg.subject}]` : "", c.expanded ? "" : `: ${preview(c.msg.body, cols)}`, enabled && !c.expanded ? _jsx(Text, { dimColor: true, children: " \u00B7 click to expand" }) : null] }), c.expanded ? c.bodyLines.map((l, i) => _jsx(Text, { dimColor: true, children: " " + l }, i)) : null] }, c.msg.id))) }));
|
|
70
|
+
}
|
package/dist/ui/Transcript.js
CHANGED
|
@@ -10,6 +10,20 @@ import { termCols, termRows } from "./term.js";
|
|
|
10
10
|
// the last N entries as a plain column the parent region clips to the visible height. N is generous — the
|
|
11
11
|
// parent's overflow:hidden + justifyContent:flex-end shows only what fits, bottom-anchored.
|
|
12
12
|
const BOUNDED_TAIL = 80;
|
|
13
|
+
/** The [start,end) slice of a `total`-entry history to render in the bounded (fullscreen) transcript, given
|
|
14
|
+
* how far the viewer has wheel-scrolled BACK from the live bottom. Pure so the windowing is unit-testable
|
|
15
|
+
* independently of Ink. `scrollBack` is clamped to [0, total-1] (the oldest entry always stays reachable);
|
|
16
|
+
* `scrollBack === 0` returns the last `tail` entries — byte-identical to the pre-scroll behavior. `olderOff`
|
|
17
|
+
* is how many entries sit above the window (older, clipped), `newerOff` how many sit below (newer, hidden
|
|
18
|
+
* only while scrolled up — new output resets scrollBack to 0, snapping the view back to them). */
|
|
19
|
+
export function boundedWindow(total, scrollBack, tail = BOUNDED_TAIL) {
|
|
20
|
+
if (total <= 0)
|
|
21
|
+
return { start: 0, end: 0, olderOff: 0, newerOff: 0 };
|
|
22
|
+
const sb = Math.min(Math.max(0, Math.floor(scrollBack)), total - 1);
|
|
23
|
+
const end = total - sb;
|
|
24
|
+
const start = Math.max(0, end - tail);
|
|
25
|
+
return { start, end, olderOff: start, newerOff: total - end };
|
|
26
|
+
}
|
|
13
27
|
function entryKey(entry) {
|
|
14
28
|
return entry.kind === "message" ? entry.message.id : entry.kind === "tool" ? entry.step.id : entry.kind === "summary" ? entry.summary.id : entry.id;
|
|
15
29
|
}
|
|
@@ -81,11 +95,16 @@ function renderEntry(entry, live = false) {
|
|
|
81
95
|
}
|
|
82
96
|
return _jsx(ToolStep, { step: entry.step });
|
|
83
97
|
}
|
|
84
|
-
export function Transcript({ entries, live, bounded }) {
|
|
98
|
+
export function Transcript({ entries, live, bounded, scrollBack = 0 }) {
|
|
85
99
|
if (bounded) {
|
|
86
|
-
// Fullscreen: no <Static>; render
|
|
87
|
-
|
|
88
|
-
|
|
100
|
+
// Fullscreen: no <Static>; render a wheel-scrollable window as a plain column the parent clips +
|
|
101
|
+
// bottom-anchors. scrollBack (from MouseProvider wheel events, via App) slides the window back through
|
|
102
|
+
// history; at 0 it's the newest `BOUNDED_TAIL` entries with the live stream pinned below.
|
|
103
|
+
const { start, end, olderOff, newerOff } = boundedWindow(entries.length, scrollBack);
|
|
104
|
+
const tail = entries.slice(start, end);
|
|
105
|
+
return (_jsxs(Box, { flexDirection: "column", children: [olderOff > 0 ? (_jsx(Text, { dimColor: true, children: `⋯ ${olderOff} earlier line(s) scrolled off` })) : null, tail.map((entry) => _jsx(Box, { children: renderEntry(entry) }, entryKey(entry))), newerOff > 0
|
|
106
|
+
? _jsx(Text, { dimColor: true, children: `⋯ ${newerOff} newer line(s) below — scroll down (new output jumps here)` })
|
|
107
|
+
: (live ? _jsx(Box, { children: renderEntry(live, true) }) : null)] }));
|
|
89
108
|
}
|
|
90
109
|
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Static, { items: entries, children: (entry) => _jsx(Box, { children: renderEntry(entry) }, entryKey(entry)) }), live ? _jsx(Box, { children: renderEntry(live, true) }) : null] }));
|
|
91
110
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0perator/operator",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.163",
|
|
4
4
|
"description": "Operator (KODE) — TypeScript + Ink terminal coding agent. Full-frame render, single-engine core shared across CLI/web/mobile; runs against a local Aurora model.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|