@0perator/operator 0.1.160 → 0.1.161
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 +8 -0
- package/dist/ui/MouseProvider.js +81 -0
- package/dist/ui/mouse.js +10 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,14 @@ 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.161 — 2026-09-30 — TUI: MouseProvider + hooks (Phase 1 mouse layer mechanism)
|
|
8
|
+
- Builds on the SGR parser: `MouseProvider` (fullscreen-only) enables 1002+1006 tracking, parses stdin,
|
|
9
|
+
dispatches wheel→`useOnWheel` and left-press→hit-tested-region `onClick` (`useClickRegion`), and disables
|
|
10
|
+
on unmount + process `exit` (crash-safety — a stuck tracking mode after a crash is the #1 real mouse bug;
|
|
11
|
+
relies on `exit`, not signal handlers, so Ctrl-C is unchanged). `mouse.ts` gains pure `hitTest`. Inline
|
|
12
|
+
mode = disabled no-op (native scroll+copy preserved). Tested via ink-testing-library with simulated SGR
|
|
13
|
+
stdin. Next: wire into App.tsx fullscreen + click-to-select panels. Suite 732 green (+2).
|
|
14
|
+
|
|
7
15
|
## 0.1.160 — 2026-09-30 — TUI: SGR mouse parser (Phase 1 foundation) + Aurora speed plan
|
|
8
16
|
- New `src/ui/mouse.ts`: a pure SGR (mode 1006) mouse-sequence parser (`CSI < Cb;Cx;Cy M/m`) decoding
|
|
9
17
|
press/release/drag/move/wheel + shift/alt/ctrl, plus `MOUSE_ON`/`MOUSE_OFF` (mode 1002 button-event +
|
|
@@ -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/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.161",
|
|
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": {
|