graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
Merge branch 'fix/tui-chrome-width' into ui/tui-scrollbar-osc52
Rach Pradhan7359d8002af5
diff --cc TUI/chrome.zigindex 777dd153,2229b790..47a40b4e--- a/TUI/chrome.zig+++ b/TUI/chrome.zig@@@ -162,11 -167,8 +167,11 @@@ pub fn slashMenu(self: *const Model, avar i: usize = first;while (i < first + show) : (i += 1) {const it = catalog.items[idx[i]];- const mark: []const u8 = if (i == sel) "› " else " ";+ const mark = glyphs.frame(&glyphs.row_mark, @intFromBool(i != sel));- const line = try std.fmt.allocPrint(a, "{s}{s} {s}", .{ mark, it.name, it.desc });+ // One menu entry is one ROW: a click maps a screen row straight back to+ // an item, so a long description is CUT, never wrapped — wrapping+ // would slide every entry below it off its own row.+ const line = theme_mod.takeCols(try std.fmt.allocPrint(a, "{s}{s} {s}", .{ mark, it.name, it.desc }), width);try out.appendSlice(if (i == sel) try theme_mod.paint(a, th.accent, line) else try theme_mod.paint(a, th.muted, line));try out.append('\n');}@@@ -189,9 -192,8 +194,9 @@@ fn listOverlay(self: *const Model, a: svar i: usize = 0;while (i < show) : (i += 1) {const it = catalog.items[idx[i]];- const mark: []const u8 = if (i == sel) "› " else " ";+ const mark = glyphs.frame(&glyphs.row_mark, @intFromBool(i != sel));- const line = try std.fmt.allocPrint(a, "{s}{s} {s}", .{ mark, it.name, it.desc });+ // Same rule as the inline menu: one entry, one row, cut to fit.+ const line = theme_mod.takeCols(try std.fmt.allocPrint(a, "{s}{s} {s}", .{ mark, it.name, it.desc }), width);try out.appendSlice(if (i == sel) try theme_mod.paint(a, th.accent, line) else try theme_mod.paint(a, th.muted, line));try out.append('\n');}diff --cc TUI/keys.zigindex ac74c0e7,44241992..6646dd6a--- a/TUI/keys.zig+++ b/TUI/keys.zig@@@ -215,20 -215,17 +215,29 @@@ fn scrollbackKey(self: *Model, k: Key)return .stay;}-fn mouseKey(self: *Model, ev: key_mod.Mouse) Effect {- if (ev.btn == 64 or ev.btn == 65) {- // The band is anchored to screen rows, so scrolling it would slide it- // onto other content — drop it and scroll.- selection.clear(self);- // An open picker or the completion menu owns the wheel: one notch is- // one ITEM there, never a scroll of the transcript underneath.- if (@import("overlays.zig").wheel(self, ev.btn == 64)) return .stay;- scrollBy(self, if (ev.btn == 64) 3 else -3);+/// Apply `notches` of wheel scroll. One report and a whole coalesced momentum+/// run go through the SAME door (pacing.zig folds consecutive reports into one+/// delta), so a storm can never mean something a single report does not.+pub fn wheelScroll(self: *Model, notches: i32) Effect {+ if (notches == 0) return .stay;+ // The band is anchored to screen rows, so scrolling it would slide it onto+ // other content — drop it and scroll.+ selection.clear(self);++ // An open picker or the completion menu owns the wheel: one notch is one++ // ITEM there, never a scroll of the transcript underneath. A coalesced run++ // moves the selection once per notch, so momentum still travels a list.++ const up = notches > 0;++ var steps: u32 = @intCast(@abs(notches));++ if (@import("overlays.zig").wheel(self, up)) {++ while (steps > 1) : (steps -= 1) _ = @import("overlays.zig").wheel(self, up);+ return .stay;+ }+ scrollBy(self, notches *| @import("pacing.zig").lines_per_notch);+ return .stay;+}++fn mouseKey(self: *Model, ev: key_mod.Mouse) Effect {+ if (@import("pacing.zig").wheelNotch(.{ .mouse = ev })) |n| return wheelScroll(self, n);// A drag or its release belongs to the selection; a press only ANCHORS one// and falls through, so a plain click keeps its meaning (#529).if (selection.mouse(self, ev)) return .stay;diff --cc TUI/render.zigindex ac512940,a7420bcc..54322b61--- a/TUI/render.zig+++ b/TUI/render.zig@@@ -8,9 -7,8 +8,10 @@@ const anchor = @import("anchor.zig")const app = @import("app.zig");const chrome = @import("chrome.zig");const engine = @import("engine.zig");+ const glyphs = @import("glyphs.zig");+const layout_cache = @import("layout_cache.zig");const scrollback = @import("scrollback.zig");+const scrollpaint = @import("scrollpaint.zig");const selection = @import("selection.zig");const theme_mod = @import("theme.zig");const welcome = @import("welcome.zig");diff --cc TUI/root.zigindex 7252b0a6,9ba63518..78c9f076--- a/TUI/root.zig+++ b/TUI/root.zig@@@ -59,10 -59,9 +59,11 @@@ test_ = @import("turn.zig");_ = @import("bgop.zig");_ = @import("welcome.zig");+ _ = @import("glyphs.zig");_ = @import("scrollback.zig");+ _ = @import("layout_cache.zig");_ = @import("selection.zig");+ _ = @import("selection_tests.zig");_ = @import("chrome.zig");_ = @import("models.zig");_ = @import("markdown.zig");diff --cc TUI/run.zigindex d39ba6e3,050be625..cd6419be--- a/TUI/run.zig+++ b/TUI/run.zig@@@ -89,11 -80,14 +89,17 @@@ pub fn runw.writeAll(enable_seq) catch {};w.writeAll("\x1b]11;?\x07") catch {}; // background query -> auto light/dark (key.zig bg_report)w.flush() catch {};+ // Registered BEFORE the restore below, so LIFO puts the line on the normal+ // screen after the alt screen is gone. No-op unless GRAFF_TUI_PAINT_STATS.+ defer pacing.report(w);+ // Nothing may write to the real terminal around the frame painter: park+ // fd 2 on .graff/tui-stderr.log so std.debug.print from any thread (a+ // subagent's status card, a worker line) cannot scroll the alt screen and+ // bleed stale rows through the diff paint. Every exit path unparks it.+ restore_mod.muteStderr();traj.open(io);defer {+ restore_mod.unmuteStderr();w.writeAll(restore_mod.seq) catch {};w.flush() catch {};}diff --cc TUI/scrollback.zigindex 1b765a5a,83aa3570..675a34e1--- a/TUI/scrollback.zig+++ b/TUI/scrollback.zig@@@ -269,9 -269,9 +270,9 @@@ pub fn row(self: *const Model, a: std.m.user => try @import("markdown.zig").renderUser(a, raw, th.accent, th.text),else => raw,};- const sel: []const u8 = if (selected) "› " else " ";+ const sel = glyphs.frame(&glyphs.row_mark, @intFromBool(!selected));if (e.kind == .user) {- const line = try std.fmt.allocPrint(a, "{s}{s}#{d}{s} {s}", .{ sel, th.muted, userNo(self, idx), theme_mod.reset, body });+ const line = try std.fmt.allocPrint(a, "{s}{s}#{d}{s} {s}", .{ sel, th.muted, user_no, theme_mod.reset, body });return theme_mod.wrapToWidth(a, line, width);}if (e.kind == .pending) {diff --cc scripts/eval-tier1.shindex b8776e9b,884777f5..5edc55f5--- a/scripts/eval-tier1.sh+++ b/scripts/eval-tier1.sh@@@ -243,55 -242,13 +243,56 @@@ if wanted tuiguard; theif python3 scripts/test-tui-typed-events.py zig-out/bin/graff; then :; elserecord_fail tuiguardfi- <<<<<<< HEAD+ # Same invariants, read off a VIRTUAL SCREEN instead of raw bytes+ # (scripts/ptyharness.py): the VT interpreter's own selftest, the ported+ # mode-balance check, and out-of-band screen corruption fed straight to the+ # tty.+ if python3 scripts/test-tui-screenstate.py zig-out/bin/graff; then :; else+ record_fail tuiguard+ fi- =======- >>>>>>> perf/tui-event-pacing+ # The frame painter may never show anything but the current frame. Storms+ # the window size, fills the screen with glyphs terminals measure+ # differently from us, then reads the SCREEN back and compares it cell for+ # cell against a forced full repaint of the same frame.+ if python3 scripts/test-tui-painter.py zig-out/bin/graff; then :; else+ record_fail tuiguard+ fi- <<<<<<< HEAD+ # Scrolling is a viewport SLICE of one cached layout, not a re-layout+ # (TUI/layout_cache.zig). Reads the screen back on every scroll step and+ # after every width change: the markers on screen must be a contiguous+ # ascending run, which a stale block or a mis-offset slice cannot fake.+ if python3 scripts/test-tui-layout-cache.py zig-out/bin/graff; then :; else+ record_fail tuiguard+ fi- =======- >>>>>>> perf/tui-event-pacing+ # The viewport must not jump when the terminal changes width: drives+ # TIOCSWINSZ across five widths mid-scroll and reads the screen back. With+ # the logical scroll anchor removed the marker leaves the screen on the+ # FIRST width change, so this is a real gate, not a smoke test.+ if python3 scripts/test-tui-resize-anchor.py zig-out/bin/graff; then :; else+ record_fail tuiguard+ fi+ # A wheel notch must be a scroll region + SU, not a screen rewrite — and a+ # storm of them must still leave the screen equal to a forced full repaint.+ # With the hint refused the probe fails on the FIRST notch (verified), so+ # this is a gate on both halves, not a smoke test.+ if python3 scripts/test-tui-scroll-paint.py zig-out/bin/graff; then :; else+ record_fail tuiguard+ fi+ # Trackpad momentum must be COALESCED and BUDGETED, not queued. Drives 500+ # SGR wheel reports twice — all at once, then spread over ~1s the way+ # momentum really arrives — and reads the loop's own paint counters back.+ # With the frame budget removed the paced storm paints 503 times instead of+ # ~105, so this is a real gate, not a smoke test.+ if python3 scripts/test-tui-event-pacing.py zig-out/bin/graff; then :; else+ record_fail tuiguard+ fi+ # grok-build's one-column rule for ANIMATED chrome: watches the live blink+ # on a background op's pending row and fails if the label beside it moves a+ # column, or if a frame is not East-Asian-Narrow. TUI/glyphs.zig holds the+ # same law for the frame sets; this is the pixels.+ if python3 scripts/test-tui-chrome-width.py zig-out/bin/graff; then :; else+ record_fail tuiguard+ fififi