@0perator/operator 0.1.161 → 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 CHANGED
@@ -4,6 +4,19 @@ 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
+
7
20
  ## 0.1.161 — 2026-09-30 — TUI: MouseProvider + hooks (Phase 1 mouse layer mechanism)
8
21
  - Builds on the SGR parser: `MouseProvider` (fullscreen-only) enables 1002+1006 tracking, parses stdin,
9
22
  dispatches wheel→`useOnWheel` and left-press→hit-tested-region `onClick` (`useClickRegion`), and disables
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
- const rows = termRows();
41
- 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 }), activity] }), prompts, bottom] }));
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
+ }
@@ -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 the tail as a plain column the parent clips + bottom-anchors.
87
- const tail = entries.length > BOUNDED_TAIL ? entries.slice(-BOUNDED_TAIL) : entries;
88
- return (_jsxs(Box, { flexDirection: "column", children: [entries.length > tail.length ? (_jsx(Text, { dimColor: true, children: `⋯ ${entries.length - tail.length} earlier line(s) scrolled off` })) : null, tail.map((entry) => _jsx(Box, { children: renderEntry(entry) }, entryKey(entry))), live ? _jsx(Box, { children: renderEntry(live, true) }) : null] }));
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.161",
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": {