@0perator/operator 0.1.160 → 0.1.162
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 +21 -0
- package/dist/ui/App.js +30 -2
- package/dist/ui/MouseProvider.js +81 -0
- package/dist/ui/Transcript.js +23 -4
- package/dist/ui/mouse.js +10 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,27 @@ 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.162 — 2026-09-30 — TUI: wheel-scrollback in fullscreen (mouse layer wired into App)
|
|
8
|
+
- The Phase 1 mouse mechanism is now live in the app. `App.tsx`'s fullscreen branch mounts `MouseProvider`
|
|
9
|
+
(enabled only on a mouse-capable TTY — inline stays a native-scroll no-op) and a new `FullscreenBody`
|
|
10
|
+
turns wheel events into **scrollback over the alt-screen transcript**, which previously had none: the
|
|
11
|
+
bottom-anchored clip simply hid older entries with no way to reach them. Wheel-up slides the window back
|
|
12
|
+
through history (with a `⋯ N newer below` marker), wheel-down returns toward the live bottom, and any new
|
|
13
|
+
settled output snaps straight back to it — you never get stranded in history while the answer grows.
|
|
14
|
+
- Windowing is a pure, unit-tested `boundedWindow(total, scrollBack, tail)` in `Transcript.tsx`: `scrollBack`
|
|
15
|
+
is clamped to `[0, total-1]` (the oldest entry always stays reachable) and `scrollBack === 0` returns the
|
|
16
|
+
last `BOUNDED_TAIL` entries — **byte-identical to the pre-scroll behavior**, so inline and non-scrolled
|
|
17
|
+
fullscreen are unchanged. Live stream is suppressed only while scrolled up (it belongs at the true bottom).
|
|
18
|
+
- Decision log: `_ai-docs/decisions/2026-09-30-tui-mouse-scrollback.md`. Suite 738 green (+6).
|
|
19
|
+
|
|
20
|
+
## 0.1.161 — 2026-09-30 — TUI: MouseProvider + hooks (Phase 1 mouse layer mechanism)
|
|
21
|
+
- Builds on the SGR parser: `MouseProvider` (fullscreen-only) enables 1002+1006 tracking, parses stdin,
|
|
22
|
+
dispatches wheel→`useOnWheel` and left-press→hit-tested-region `onClick` (`useClickRegion`), and disables
|
|
23
|
+
on unmount + process `exit` (crash-safety — a stuck tracking mode after a crash is the #1 real mouse bug;
|
|
24
|
+
relies on `exit`, not signal handlers, so Ctrl-C is unchanged). `mouse.ts` gains pure `hitTest`. Inline
|
|
25
|
+
mode = disabled no-op (native scroll+copy preserved). Tested via ink-testing-library with simulated SGR
|
|
26
|
+
stdin. Next: wire into App.tsx fullscreen + click-to-select panels. Suite 732 green (+2).
|
|
27
|
+
|
|
7
28
|
## 0.1.160 — 2026-09-30 — TUI: SGR mouse parser (Phase 1 foundation) + Aurora speed plan
|
|
8
29
|
- New `src/ui/mouse.ts`: a pure SGR (mode 1006) mouse-sequence parser (`CSI < Cb;Cx;Cy M/m`) decoding
|
|
9
30
|
press/release/drag/move/wheel + shift/alt/ctrl, plus `MOUSE_ON`/`MOUSE_OFF` (mode 1002 button-event +
|
package/dist/ui/App.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
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
7
|
import { termRows } from "./term.js";
|
|
8
|
+
import { caps } from "./capabilities.js";
|
|
9
|
+
import { MouseProvider, useOnWheel } from "./MouseProvider.js";
|
|
4
10
|
import { StatusRule } from "./StatusRule.js";
|
|
5
11
|
import { InputRule } from "./InputRule.js";
|
|
6
12
|
import { Transcript } from "./Transcript.js";
|
|
@@ -37,10 +43,32 @@ export function App(props) {
|
|
|
37
43
|
// region (non-Static tail) so the newest output sits just above a composer pinned to the very bottom —
|
|
38
44
|
// no dead space. Off by default: inline keeps the terminal's native scrollback (mouse-scroll + copy).
|
|
39
45
|
if (fullscreen) {
|
|
40
|
-
|
|
41
|
-
|
|
46
|
+
// Enable the SGR mouse layer ONLY in fullscreen on a mouse-capable TTY — inline keeps the terminal's
|
|
47
|
+
// native scroll+copy, so it must never receive tracking. FullscreenBody (under the provider) turns
|
|
48
|
+
// wheel events into scrollback over the alt-screen transcript, which otherwise has no way to scroll.
|
|
49
|
+
return (_jsx(MouseProvider, { enabled: caps().mouse, children: _jsx(FullscreenBody, { messages: messages, live: live, activity: activity, prompts: prompts, bottom: bottom }) }));
|
|
42
50
|
}
|
|
43
51
|
// Inline (default): the dynamic frame grows below the Static transcript; unused space sits below it and
|
|
44
52
|
// fills as the conversation grows. Native scrollback preserved.
|
|
45
53
|
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Transcript, { entries: messages, live: live }), activity, prompts, bottom] }));
|
|
46
54
|
}
|
|
55
|
+
// Entries the transcript window slides per wheel notch. A notch is one detent of the physical wheel; 3
|
|
56
|
+
// entries keeps scrollback brisk without leaping past short exchanges.
|
|
57
|
+
const WHEEL_STEP = 3;
|
|
58
|
+
// The fullscreen (alt-screen) layout body, mounted UNDER MouseProvider so useOnWheel receives events.
|
|
59
|
+
// It owns the scrollback offset: wheel-up slides the transcript window back through history (revealing the
|
|
60
|
+
// entries the bottom-anchored clip would otherwise hide), wheel-down returns toward the live bottom, and
|
|
61
|
+
// any new output snaps straight back to it — you never get stranded in history while the answer grows.
|
|
62
|
+
// Split out from App because useOnWheel must run inside the provider App itself returns.
|
|
63
|
+
function FullscreenBody({ messages, live, activity, prompts, bottom }) {
|
|
64
|
+
const rows = termRows();
|
|
65
|
+
const [scrollBack, setScrollBack] = useState(0);
|
|
66
|
+
// New settled output resets the view to the live bottom (messages.length only grows as entries settle).
|
|
67
|
+
useEffect(() => { setScrollBack(0); }, [messages.length]);
|
|
68
|
+
useOnWheel((e) => {
|
|
69
|
+
setScrollBack((s) => e.action === "wheel-up"
|
|
70
|
+
? Math.min(s + WHEEL_STEP, Math.max(0, messages.length - 1)) // clamp: the oldest entry stays reachable
|
|
71
|
+
: Math.max(0, s - WHEEL_STEP));
|
|
72
|
+
});
|
|
73
|
+
return (_jsxs(Box, { flexDirection: "column", height: rows, children: [_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] }));
|
|
74
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// Phase 1 mouse layer — the Ink provider on top of the pure parser (mouse.ts). Enables SGR tracking only
|
|
2
|
+
// in FULLSCREEN (inline keeps the terminal's native scroll + copy), parses stdin via parseMouse, and
|
|
3
|
+
// dispatches: wheel → useOnWheel subscribers (global, no hit-test), left-press → the hit-tested region's
|
|
4
|
+
// onClick (components register their measured bounds). Disables on unmount AND on process 'exit' — a
|
|
5
|
+
// tracking mode left enabled after a crash captures every click until a manual reset (the #1 real mouse
|
|
6
|
+
// bug). We rely on 'exit' (fires after the app's own SIGINT/SIGTERM handlers call process.exit) rather
|
|
7
|
+
// than adding our own signal handlers, so Ctrl-C behaviour is unchanged. Blueprint: _ai-docs/architecture/
|
|
8
|
+
// tui-enterprise-upgrade.md.
|
|
9
|
+
import React, { createContext, useCallback, useContext, useEffect, useRef } from "react";
|
|
10
|
+
import { useStdin } from "ink";
|
|
11
|
+
import { parseMouse, hitTest, MOUSE_ON, MOUSE_OFF } from "./mouse.js";
|
|
12
|
+
const Ctx = createContext({ enabled: false, registerRegion: () => () => { }, onWheel: () => () => { } });
|
|
13
|
+
export function MouseProvider({ enabled, children }) {
|
|
14
|
+
const { stdin, setRawMode, isRawModeSupported } = useStdin();
|
|
15
|
+
const regions = useRef(new Map());
|
|
16
|
+
const wheels = useRef(new Set());
|
|
17
|
+
const registerRegion = useCallback((r, onClick) => {
|
|
18
|
+
regions.current.set(r.id, { r, onClick });
|
|
19
|
+
return () => { regions.current.delete(r.id); };
|
|
20
|
+
}, []);
|
|
21
|
+
const onWheel = useCallback((h) => {
|
|
22
|
+
wheels.current.add(h);
|
|
23
|
+
return () => { wheels.current.delete(h); };
|
|
24
|
+
}, []);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (!enabled || !stdin)
|
|
27
|
+
return;
|
|
28
|
+
let off = false;
|
|
29
|
+
const disable = () => { if (off)
|
|
30
|
+
return; off = true; try {
|
|
31
|
+
process.stdout.write(MOUSE_OFF);
|
|
32
|
+
}
|
|
33
|
+
catch { /* stream gone */ } };
|
|
34
|
+
try {
|
|
35
|
+
if (isRawModeSupported)
|
|
36
|
+
setRawMode?.(true);
|
|
37
|
+
}
|
|
38
|
+
catch { /* */ }
|
|
39
|
+
try {
|
|
40
|
+
process.stdout.write(MOUSE_ON);
|
|
41
|
+
}
|
|
42
|
+
catch { /* */ }
|
|
43
|
+
const onData = (buf) => {
|
|
44
|
+
for (const e of parseMouse(typeof buf === "string" ? buf : buf.toString("utf8"))) {
|
|
45
|
+
if (e.action === "wheel-up" || e.action === "wheel-down") {
|
|
46
|
+
for (const h of wheels.current)
|
|
47
|
+
h(e);
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (e.action === "press" && e.button === "left") {
|
|
51
|
+
const hit = hitTest([...regions.current.values()].map((v) => v.r), e.x, e.y);
|
|
52
|
+
if (hit)
|
|
53
|
+
regions.current.get(hit.id)?.onClick(e);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
stdin.on("data", onData);
|
|
58
|
+
const onExit = () => disable(); // fires on normal exit + after the app's signal handlers call process.exit
|
|
59
|
+
process.on("exit", onExit);
|
|
60
|
+
return () => { stdin.off("data", onData); process.off("exit", onExit); disable(); };
|
|
61
|
+
}, [enabled, stdin, setRawMode, isRawModeSupported]);
|
|
62
|
+
return React.createElement(Ctx.Provider, { value: { enabled, registerRegion, onWheel } }, children);
|
|
63
|
+
}
|
|
64
|
+
/** The mouse context: `enabled` (false in inline mode) + registerRegion/onWheel. */
|
|
65
|
+
export const useMouse = () => useContext(Ctx);
|
|
66
|
+
/** Subscribe to wheel-scroll events (global; no hit-testing). Auto-unsubscribes on unmount. A no-op when
|
|
67
|
+
* the provider is disabled (inline mode) since nothing dispatches. */
|
|
68
|
+
export function useOnWheel(handler) {
|
|
69
|
+
const { onWheel } = useMouse();
|
|
70
|
+
useEffect(() => onWheel(handler), [onWheel, handler]);
|
|
71
|
+
}
|
|
72
|
+
/** Register a clickable region (absolute terminal-cell bounds, e.g. from Ink measureElement + position).
|
|
73
|
+
* The provider calls `onClick` on a left-press inside it. Auto-unregisters on unmount / bounds change. */
|
|
74
|
+
export function useClickRegion(region, onClick) {
|
|
75
|
+
const { registerRegion } = useMouse();
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (!region)
|
|
78
|
+
return;
|
|
79
|
+
return registerRegion(region, onClick);
|
|
80
|
+
}, [registerRegion, region?.id, region?.x, region?.y, region?.width, region?.height, onClick]);
|
|
81
|
+
}
|
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/dist/ui/mouse.js
CHANGED
|
@@ -45,6 +45,16 @@ export function parseMouse(chunk) {
|
|
|
45
45
|
}
|
|
46
46
|
return out;
|
|
47
47
|
}
|
|
48
|
+
/** The LAST matching region containing (x,y) — last-registered wins, so a child/overlay registered after
|
|
49
|
+
* its parent takes the hit (matches paint order). Returns null when the point hits no region. Pure. */
|
|
50
|
+
export function hitTest(regions, x, y) {
|
|
51
|
+
let hit = null;
|
|
52
|
+
for (const r of regions) {
|
|
53
|
+
if (x >= r.x && x < r.x + r.width && y >= r.y && y < r.y + r.height)
|
|
54
|
+
hit = r;
|
|
55
|
+
}
|
|
56
|
+
return hit;
|
|
57
|
+
}
|
|
48
58
|
// Enable/disable SGR mouse tracking. Mode 1002 (button-event) = press + release + drag-while-held + wheel
|
|
49
59
|
// — the practical default for a scrollable/clickable TUI; NEVER 1003 (any-event floods stdin on every
|
|
50
60
|
// move). Paired with 1006 (SGR encoding). Written to stdout ONLY in fullscreen (inline keeps the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0perator/operator",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.162",
|
|
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": {
|