graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
Pin every animated chrome glyph to one terminal column
Rach Pradhan023f249ee3db
diff --git a/TUI/chrome.zig b/TUI/chrome.zigindex 00006a16..2229b790 100644--- a/TUI/chrome.zig+++ b/TUI/chrome.zig@@ -5,6 +5,7 @@ const std = @import("std");const app = @import("app.zig");const catalog = @import("catalog.zig");const engine = @import("engine.zig");+const glyphs = @import("glyphs.zig");const theme_mod = @import("theme.zig");const Model = app.Model;@@ -41,7 +42,7 @@ pub fn promptBox(self: *const Model, a: std.mem.Allocator, width: usize) ![]constry out.appendSlice(theme_mod.reset);try out.append('\n');var body = std.array_list.Managed(u8).init(a);- try body.appendSlice("› ");+ try body.appendSlice(glyphs.caret ++ " ");if (self.images.items.len > 0) {try body.appendSlice(try imageChips(self, a));try body.appendSlice(" ");@@ -61,9 +62,13 @@ pub fn promptBox(self: *const Model, a: std.mem.Allocator, width: usize) ![]cons// The context share comes from the engine's meter and appears only once a// turn has reported usage — a "0%" before the first response would be the// char-counter's old habit of showing a number it had not measured (#551).+ // The share is right-aligned in a THREE-column field. The footer label is+ // centred, so a meter ticking 9% → 10% used to widen the label by one and+ // slide every character of the footer half a cell sideways mid-turn — the+ // same class of jitter a two-column spinner frame causes (glyphs.zig).var pct_buf: [16]u8 = undefined;const pct: []const u8 = if (self.contextPercent()) |p|- (std.fmt.bufPrint(&pct_buf, " · {d}%", .{p}) catch "")+ (std.fmt.bufPrint(&pct_buf, " · {d: >3}%", .{p}) catch "")else"";const label = try std.fmt.allocPrint(a, " {s} ({s}) · {s}{s} ", .{ model, @tagName(self.effort), self.modeSlug(), pct });@@ -162,7 +167,7 @@ pub fn slashMenu(self: *const Model, a: std.mem.Allocator, width: usize) ![]consvar 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 });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');@@ -187,7 +192,7 @@ fn listOverlay(self: *const Model, a: std.mem.Allocator, width: usize) ![]constvar 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 });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');@@ -203,7 +208,7 @@ fn themeOverlay(self: *const Model, a: std.mem.Allocator) ![]const u8 {try out.append('\n');const sel = self.overlay_sel % theme_mod.all.len;for (theme_mod.all, 0..) |id, i| {- const mark: []const u8 = if (i == sel) "› " else " ";+ const mark = glyphs.frame(&glyphs.row_mark, @intFromBool(i != sel));const cur: []const u8 = if (id == self.theme_id) " (current)" else "";const line = try std.fmt.allocPrint(a, "{s}{s}{s}", .{ mark, id.label(), cur });try out.appendSlice(if (i == sel) try theme_mod.paint(a, th.accent, line) else try theme_mod.paint(a, th.muted, line));@@ -228,7 +233,7 @@ fn jumpOverlay(self: *const Model, a: std.mem.Allocator) ![]const u8 {if (e.kind != .user) continue;const nl = std.mem.indexOfScalar(u8, e.text, '\n') orelse e.text.len;const clip = e.text[0..@min(nl, 60)];- const mark: []const u8 = if (no == sel) "› " else " ";+ const mark = glyphs.frame(&glyphs.row_mark, @intFromBool(no != sel));const line = try std.fmt.allocPrint(a, "{s}#{d} {s}", .{ mark, no + 1, clip });try out.appendSlice(if (no == sel) try theme_mod.paint(a, th.accent, line) else try theme_mod.paint(a, th.muted, line));try out.append('\n');@@ -402,7 +407,7 @@ fn settingsOverlay(self: *const Model, a: std.mem.Allocator) ![]const u8 {};const sel = self.overlay_sel % rows.len;for (rows, 0..) |r, 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:<10} {s}", .{ mark, r[0], r[1] });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');@@ -424,6 +429,33 @@ fn debugOverlay(self: *const Model, a: std.mem.Allocator) ![]const u8 {});}+test "the composer footer holds its columns as the context meter ticks" {+ // The footer label is CENTRED, so a share that widened from 9% to 10%+ // shifted every character of it one column mid-turn. Same class of defect+ // as a two-column animation frame, same rule: the field is fixed-width.+ engine.g_model_name = "grok-4";+ defer engine.g_model_name = "";+ var m: Model = undefined;+ m.setup(std.testing.allocator);+ defer m.deinit();+ var arena = std.heap.ArenaAllocator.init(std.testing.allocator);+ defer arena.deinit();+ var col: ?usize = null;+ for ([_]u64{ 5, 9, 10, 99, 100 }) |pct| {+ m.setStatus(.{ .model = "grok-4", .provider_id = "xai", .has_context = true, .tokens = pct, .window = 100 });+ const box = try promptBox(&m, arena.allocator(), 80);+ var it = std.mem.splitScalar(u8, box, '\n');+ var footer_row: []const u8 = "";+ while (it.next()) |ln| {+ if (std.mem.indexOf(u8, ln, "╰") != null) footer_row = ln;+ }+ const at = std.mem.indexOf(u8, footer_row, "grok-4") orelse return error.NoFooterLabel;+ const start = theme_mod.visibleLen(footer_row[0..at]);+ if (col) |want| try std.testing.expectEqual(want, start) else col = start;+ try std.testing.expectEqual(@as(usize, 80), theme_mod.visibleLen(footer_row));+ }+}+test "prompt box wraps a long draft onto several rows" {var m: Model = undefined;m.setup(std.testing.allocator);diff --git a/TUI/glyphs.zig b/TUI/glyphs.zignew file mode 100644index 00000000..5f770900--- /dev/null+++ b/TUI/glyphs.zig@@ -0,0 +1,190 @@+//! The chrome glyph registry — presentation only, no engine facts.+//!+//! Every non-text glyph the chrome paints is named here ONCE, with the terminal+//! width class it belongs to, and every animation is a frame SET rather than a+//! pair of literals at a call site. Scattered literals are how an animation+//! acquires a frame that measures two columns: the label beside it then steps+//! sideways on every tick, which is exactly what grok-build's one-column+//! discipline exists to prevent.+//!+//! Width classes. A terminal decides a glyph's cell count from a width table+//! built on Unicode's East_Asian_Width property, never from the font — a glyph+//! drawn from a fallback face still advances the cells its class says it does.+//!+//! narrow EAW N or Na. ONE column in every terminal, including one+//! configured to draw East-Asian-Ambiguous glyphs double-width.+//! ambiguous EAW A. One column by default — what theme.charWidth returns, and+//! what every western terminal does — but TWO under the CJK+//! ambiguous-wide setting (xterm -cjk_width, iTerm2's+//! "ambiguous characters are double-width", Terminal.app's).+//!+//! LAW: an ANIMATED glyph is narrow-class, and every frame of one animation+//! renders the same number of columns. Both halves are asserted below.+//!+//! The static chrome keeps its ambiguous members on purpose. The composer's+//! own walls (╭ ─ ╮ │ ╰ ╯), the meter separators and the block cursor are all+//! EAW A, so a terminal that widens ● has already widened the box around it —+//! ambiguous-wide is unsupported wholesale, and swapping three marks would buy+//! no alignment while changing the transcript's look. What must never happen is+//! an animation that shifts its neighbours in a NORMAL terminal, and that is+//! what the registry pins.+//!+//! Audit (Unicode 15 EastAsianWidth, 2026-08). Animated and gutter glyphs:+//!+//! U+2759 ❙ N pending blink, frame 0 one column everywhere+//! U+2758 ❘ N pending blink, frame 1 one column everywhere+//! U+203A › N selection mark, composer caret+//! U+276F ❯ N sticky header prompt mark+//! U+2298 ⊘ N denied tool+//! U+2717 ✗ N failed tool+//! U+21B3 ↳ N queued/nested row+//! U+25CF ● A assistant / error mark static, box-class+//! U+25C6 ◆ A tool mark static, box-class+//! U+00B7 · A system mark, meter separator static, box-class+//! U+258B ▋ A composer cursor static, box-class+//! U+25A0 ■ A stopped/interrupted row static, box-class+//!+//! The two blink frames were the suspect ones — they read like the ambiguous+//! Geometric Shapes neighbours — but Dingbats U+2758..U+2767 are Neutral, so+//! the pair is genuinely pad-stable and needed no substitution.++const std = @import("std");+const theme = @import("theme.zig");++pub const Class = enum { narrow, ambiguous };++pub const Glyph = struct {+ cp: u21,+ cols: u2,+ class: Class,+ /// What it means, so the registry doubles as the audit table.+ role: []const u8,+};++/// Every chrome codepoint the TUI paints. Anything animated must appear here+/// as `.narrow` — `animations` is checked against this list.+pub const registry = [_]Glyph{+ .{ .cp = 0x2759, .cols = 1, .class = .narrow, .role = "pending blink, frame 0" },+ .{ .cp = 0x2758, .cols = 1, .class = .narrow, .role = "pending blink, frame 1" },+ .{ .cp = 0x203A, .cols = 1, .class = .narrow, .role = "selection mark / composer caret" },+ .{ .cp = 0x276F, .cols = 1, .class = .narrow, .role = "sticky header prompt mark" },+ .{ .cp = 0x2298, .cols = 1, .class = .narrow, .role = "denied tool" },+ .{ .cp = 0x2717, .cols = 1, .class = .narrow, .role = "failed tool" },+ .{ .cp = 0x21B3, .cols = 1, .class = .narrow, .role = "queued / nested row" },+ .{ .cp = 0x25CF, .cols = 1, .class = .ambiguous, .role = "assistant / error mark" },+ .{ .cp = 0x25C6, .cols = 1, .class = .ambiguous, .role = "tool mark" },+ .{ .cp = 0x00B7, .cols = 1, .class = .ambiguous, .role = "system mark / meter separator" },+ .{ .cp = 0x258B, .cols = 1, .class = .ambiguous, .role = "composer cursor" },+ .{ .cp = 0x25A0, .cols = 1, .class = .ambiguous, .role = "stopped / interrupted row" },+};++// ── animated ────────────────────────────────────────────────────────────────++/// The pending row's blink. A fully static frame let run.zig's hash-diff+/// suppress every paint for a background op's whole duration, so the row has to+/// change — but only in ways that keep the label's column fixed.+pub const thinking = [_][]const u8{ "\u{2759}", "\u{2758}" };++/// The scrollback's selection mark. Both frames are a TWO-column field, so a+/// row's body starts at the same column selected or not.+pub const row_mark = [_][]const u8{ "\u{203A} ", " " };++pub const Animation = struct { name: []const u8, frames: []const []const u8 };++pub const animations = [_]Animation{+ .{ .name = "pending-blink", .frames = &thinking },+ .{ .name = "row-mark", .frames = &row_mark },+};++/// Frame `i` of an animation, wrapping — call sites index by time, never by a+/// literal.+pub fn frame(anim: []const []const u8, i: usize) []const u8 {+ return anim[i % anim.len];+}++// ── static ──────────────────────────────────────────────────────────────────++pub const caret = "\u{203A}"; // composer prompt+pub const prompt_mark = "\u{276F}"; // sticky header+pub const assistant = "\u{25CF}";+pub const tool = "\u{25C6}";+pub const system = "\u{00B7}";+pub const denied = "\u{2298}";+pub const failed = "\u{2717}";+pub const cursor = "\u{258B}";++fn lookup(cp: u21) ?Glyph {+ for (registry) |g| {+ if (g.cp == cp) return g;+ }+ return null;+}++const testing = std.testing;++test "every registered glyph measures the columns it claims" {+ var buf: [4]u8 = undefined;+ for (registry) |g| {+ try testing.expectEqual(@as(u2, 1), g.cols); // chrome is single-cell, always+ try testing.expectEqual(g.cols, theme.charWidth(g.cp));+ const n = try std.unicode.utf8Encode(g.cp, &buf);+ try testing.expectEqual(@as(usize, g.cols), theme.visibleLen(buf[0..n]));+ }+}++test "every frame of every animation renders the same visibleLen" {+ // The whole point of the registry: a frame that measured differently would+ // move the label or timer beside it on every tick.+ for (animations) |anim| {+ try testing.expect(anim.frames.len >= 2); // an animation that cannot change is a still+ const want = theme.visibleLen(anim.frames[0]);+ try testing.expect(want > 0);+ for (anim.frames) |f| {+ try testing.expectEqual(want, theme.visibleLen(f));+ // ...and no two frames may be identical, or the paint loop stalls.+ }+ for (anim.frames, 0..) |f, i| {+ for (anim.frames[i + 1 ..]) |other| {+ try testing.expect(!std.mem.eql(u8, f, other));+ }+ }+ }+}++test "every animated glyph is narrow-class — one column in EVERY terminal" {+ for (animations) |anim| {+ for (anim.frames) |f| {+ var i: usize = 0;+ while (i < f.len) {+ const len = try std.unicode.utf8ByteSequenceLength(f[i]);+ const cp = try std.unicode.utf8Decode(f[i .. i + len]);+ i += len;+ if (cp == ' ') continue; // padding, always one column+ const g = lookup(cp) orelse {+ std.debug.print("unregistered animated glyph U+{X:0>4}\n", .{cp});+ return error.UnregisteredGlyph;+ };+ try testing.expectEqual(Class.narrow, g.class);+ }+ }+ }+}++test "the blink frames live in the registry and nowhere else" {+ // A second copy of the pair at a call site is how the frame set drifts:+ // one gets replaced, the other does not, and the animation starts stepping.+ for ([_][]const u8{+ @embedFile("scrollback.zig"),+ @embedFile("chrome.zig"),+ @embedFile("render.zig"),+ @embedFile("input.zig"),+ }) |src| {+ for (thinking) |f| try testing.expect(std.mem.indexOf(u8, src, f) == null);+ }+}++test "frame() indexes by time and wraps" {+ try testing.expectEqualStrings(thinking[0], frame(&thinking, 0));+ try testing.expectEqualStrings(thinking[1], frame(&thinking, 1));+ try testing.expectEqualStrings(thinking[0], frame(&thinking, 2));+}diff --git a/TUI/input.zig b/TUI/input.zigindex 490cf5c7..f4916ae7 100644--- a/TUI/input.zig+++ b/TUI/input.zig@@ -1,6 +1,7 @@//! Composer buffer. Soft-wrap lives in chrome; undo is Ctrl/Cmd+Z.const std = @import("std");+const glyphs = @import("glyphs.zig");const Key = @import("key.zig").Key;const Snap = struct { text: []u8, cursor: usize };@@ -132,11 +133,11 @@ pub const Input = struct {var out = std.array_list.Managed(u8).init(a);if (self.buf.items.len == 0) {try out.appendSlice(self.placeholder);- try out.appendSlice("▋");+ try out.appendSlice(glyphs.cursor);return out.items;}try out.appendSlice(self.buf.items[0..self.cursor]);- try out.appendSlice("▋");+ try out.appendSlice(glyphs.cursor);try out.appendSlice(self.buf.items[self.cursor..]);return out.items;}diff --git a/TUI/render.zig b/TUI/render.zigindex 8086592c..a7420bcc 100644--- a/TUI/render.zig+++ b/TUI/render.zig@@ -7,6 +7,7 @@ const std = @import("std");const app = @import("app.zig");const chrome = @import("chrome.zig");const engine = @import("engine.zig");+const glyphs = @import("glyphs.zig");const scrollback = @import("scrollback.zig");const selection = @import("selection.zig");const theme_mod = @import("theme.zig");@@ -106,7 +107,7 @@ pub fn render(self: *Model, gpa: std.mem.Allocator, width: usize, height: usize,const th = self.theme();var head = std.array_list.Managed(u8).init(a);try head.appendSlice(th.accent);- try head.appendSlice("\u{276F} ");+ try head.appendSlice(glyphs.prompt_mark ++ " ");try head.appendSlice(th.text);var one = utext;if (std.mem.indexOfScalar(u8, utext, '\n')) |nl| one = utext[0..nl];diff --git a/TUI/root.zig b/TUI/root.zigindex 3349e7a1..9ba63518 100644--- a/TUI/root.zig+++ b/TUI/root.zig@@ -59,6 +59,7 @@ test {_ = @import("turn.zig");_ = @import("bgop.zig");_ = @import("welcome.zig");+ _ = @import("glyphs.zig");_ = @import("scrollback.zig");_ = @import("selection.zig");_ = @import("chrome.zig");diff --git a/TUI/scrollback.zig b/TUI/scrollback.zigindex 1186e025..83aa3570 100644--- a/TUI/scrollback.zig+++ b/TUI/scrollback.zig@@ -4,6 +4,7 @@const std = @import("std");const app = @import("app.zig");+const glyphs = @import("glyphs.zig");const theme_mod = @import("theme.zig");const Model = app.Model;@@ -218,20 +219,20 @@ fn summary(self: *const Model, a: std.mem.Allocator, start: usize, end: usize, sif (rowIsMcp(e)) mcp_n += 1;if (isSearch(classifyOn(e))) searches += 1 else calls += 1;}- const sel: []const u8 = if (selected) "› " else " ";+ const sel = glyphs.frame(&glyphs.row_mark, @intFromBool(!selected));// No live bar here: liveness belongs to the pending row alone. A bar on// every summary made the whole transcript pulse and shift while thinking.var out = std.array_list.Managed(u8).init(a);if (calls > 0) {const label = if (mcp_n == calls + searches)- try std.fmt.allocPrint(a, "{s}◆ Called {d} MCP tool{s}", .{ sel, calls, if (calls == 1) "" else "s" })+ try std.fmt.allocPrint(a, "{s}{s} Called {d} MCP tool{s}", .{ sel, glyphs.tool, calls, if (calls == 1) "" else "s" })else- try std.fmt.allocPrint(a, "{s}◆ Called {d} tool{s}", .{ sel, calls, if (calls == 1) "" else "s" });+ try std.fmt.allocPrint(a, "{s}{s} Called {d} tool{s}", .{ sel, glyphs.tool, calls, if (calls == 1) "" else "s" });try out.appendSlice(try theme_mod.paint(a, if (selected) th.accent else th.muted, label));}if (searches > 0) {if (out.items.len > 0) try out.append('\n');- const label = try std.fmt.allocPrint(a, "{s}◆ Searched {d} MCP tool{s}", .{ sel, searches, if (searches == 1) "" else "s" });+ const label = try std.fmt.allocPrint(a, "{s}{s} Searched {d} MCP tool{s}", .{ sel, glyphs.tool, searches, if (searches == 1) "" else "s" });try out.appendSlice(try theme_mod.paint(a, if (selected) th.accent else th.muted, label));}return out.items;@@ -241,10 +242,10 @@ fn row(self: *const Model, a: std.mem.Allocator, idx: usize, e: app.Entry, widthconst th = self.theme();const mark: []const u8 = switch (e.kind) {.user => "",- .assistant => "●",- .tool => "◆",- .system => "·",- .err => "●",+ .assistant => glyphs.assistant,+ .tool => glyphs.tool,+ .system => glyphs.system,+ .err => glyphs.assistant,.pending => thinkingGlyph(now_ms),};const color: []const u8 = switch (e.kind) {@@ -268,7 +269,7 @@ fn row(self: *const Model, a: std.mem.Allocator, idx: usize, e: app.Entry, width.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 });return theme_mod.wrapToWidth(a, line, width);@@ -332,7 +333,7 @@ fn displayName(name: []const u8) []const u8 {fn toolTitle(a: std.mem.Allocator, named: app.Entry, status: app.Entry) ![]const u8 {const t = named.tool orelse return named.text;const mark: []const u8 = if (status.tool) |s|- (if (s.denied) "⊘ " else if (s.is_error) "✗ " else "")+ (if (s.denied) glyphs.denied ++ " " else if (s.is_error) glyphs.failed ++ " " else "")else"";const name = displayName(t.name);@@ -365,10 +366,10 @@ fn toolVisual(}fn toolCard(a: std.mem.Allocator, th: theme_mod.Theme, call: app.Entry, outcome: app.Entry, selected: bool, width: usize) ![]const u8 {- const sel: []const u8 = if (selected) "› " else " ";+ const sel = glyphs.frame(&glyphs.row_mark, @intFromBool(!selected));const title = try toolTitle(a, call, outcome);const preview = toolPreview(outcome);- const head = try std.fmt.allocPrint(a, "{s}{s}◆{s}{s} {s}", .{ sel, if (selected) th.accent else th.muted, theme_mod.reset, th.text, title });+ const head = try std.fmt.allocPrint(a, "{s}{s}{s}{s}{s} {s}", .{ sel, if (selected) th.accent else th.muted, glyphs.tool, theme_mod.reset, th.text, title });if (preview == null) return theme_mod.wrapToWidth(a, head, width);const body = try std.fmt.allocPrint(a, "{s}{s}│ {s}{s}", .{ sel, th.muted, preview.?, theme_mod.reset });const joined = try std.fmt.allocPrint(a, "{s}\n{s}", .{ try theme_mod.wrapToWidth(a, head, width), try theme_mod.wrapToWidth(a, body, width) });@@ -380,13 +381,15 @@ fn thinkingGlyph(now_ms: u64) []const u8 {// run.zig's hash-diff suppress every paint for a background op's whole// duration — 8s of literally zero terminal output read as a freeze. One// changing glyph on one line keeps the paints flowing while historical- // rows stay byte-identical (the earlier full-transcript pulse bug).- return if ((now_ms / 500) % 2 == 0) "❙" else "❘";+ // rows stay byte-identical (the earlier full-transcript pulse bug). The+ // frames come from the registry, which pins each to ONE column so the+ // label beside them never steps sideways as they tick (glyphs.zig).+ return glyphs.frame(&glyphs.thinking, now_ms / 500);}fn thinkingLabel(now_ms: u64) []const u8 {_ = now_ms;- // Grok: static "Thinking" — motion is only the ❙ flicker.+ // Grok: static "Thinking" — motion is only the one-column blink.return "Thinking";}@@ -430,10 +433,10 @@ test "firstLine stops at newline" {try std.testing.expectEqualStrings("ab", firstLine("ab\ncd"));}-test "thinking animation is Grok ❙ flicker plus static Thinking" {+test "thinking animation is a one-column blink plus a static Thinking" {try std.testing.expectEqualStrings("Thinking", thinkingLabel(0));try std.testing.expectEqualStrings(thinkingLabel(0), thinkingLabel(320));- try std.testing.expectEqualStrings("❙", thinkingGlyph(0));+ try std.testing.expectEqualStrings(glyphs.thinking[0], thinkingGlyph(0));// The glyph must actually FLICKER across a half-period, and be stable// within one — a fully static pending row suppressed every paint for a// background op's whole duration (verified live: 8s of zero output).@@ -470,7 +473,7 @@ test "a live turn never pulses or shifts historical rows" {while (it.next()) |ln| {if (std.mem.indexOf(u8, ln, "Called") != null) {saw_summary = true;- try std.testing.expect(std.mem.indexOf(u8, ln, "❙") == null);+ try std.testing.expect(std.mem.indexOf(u8, ln, glyphs.thinking[0]) == null);}}try std.testing.expect(saw_summary);diff --git a/TUI/scrollback_tests.zig b/TUI/scrollback_tests.zigindex ede4694a..feb1eef8 100644--- a/TUI/scrollback_tests.zig+++ b/TUI/scrollback_tests.zig@@ -6,9 +6,68 @@const std = @import("std");const app = @import("app.zig");+const glyphs = @import("glyphs.zig");const scrollback = @import("scrollback.zig");+const theme_mod = @import("theme.zig");const Model = app.Model;+/// The COLUMN `needle` starts at on its rendered row — SGR and glyph widths+/// resolved, which is the only measure a terminal agrees with.+fn labelCol(text: []const u8, needle: []const u8) ?usize {+ var it = std.mem.splitScalar(u8, text, '\n');+ while (it.next()) |ln| {+ const at = std.mem.indexOf(u8, ln, needle) orelse continue;+ return theme_mod.visibleLen(ln[0..at]);+ }+ return null;+}++test "the pending label holds its column across every blink frame" {+ // grok-build's rule: animated chrome is exactly one column, so the label+ // and any timer beside it never step sideways as the animation ticks.+ var m: Model = undefined;+ m.setup(std.testing.allocator);+ defer m.deinit();+ try m.push(.pending, "");+ var arena = std.heap.ArenaAllocator.init(std.testing.allocator);+ defer arena.deinit();+ var col: ?usize = null;+ var seen = std.mem.zeroes([glyphs.thinking.len]bool);+ // Six samples across three blink periods: more than the four frames the+ // live pty proof watches, and enough to see both frames twice.+ for ([_]u64{ 0, 500, 1000, 1500, 2000, 2500 }) |now_ms| {+ const text = try scrollback.render(&m, arena.allocator(), 80, now_ms);+ const at = labelCol(text, "Thinking") orelse return error.NoPendingLabel;+ if (col) |want| try std.testing.expectEqual(want, at) else col = at;+ for (glyphs.thinking, 0..) |f, i| {+ if (std.mem.indexOf(u8, text, f) != null) seen[i] = true;+ }+ }+ for (seen) |s| try std.testing.expect(s); // it really animated+ // Two columns of selection field, one of glyph, one of space.+ try std.testing.expectEqual(@as(usize, 4), col.?);+}++test "a settled row's body starts in the same column the pending row used" {+ // The gutter is shared: the blink is replaced by a static mark when the+ // turn lands, and a mark of a different width would jerk the whole answer+ // sideways at exactly the moment the reader starts reading it.+ var arena = std.heap.ArenaAllocator.init(std.testing.allocator);+ defer arena.deinit();+ var live_m: Model = undefined;+ live_m.setup(std.testing.allocator);+ defer live_m.deinit();+ try live_m.push(.pending, "");+ const live = try scrollback.render(&live_m, arena.allocator(), 80, 0);+ const pending_col = labelCol(live, "Thinking") orelse return error.NoPendingLabel;+ var done_m: Model = undefined;+ done_m.setup(std.testing.allocator);+ defer done_m.deinit();+ try done_m.push(.assistant, "Landed");+ const done = try scrollback.render(&done_m, arena.allocator(), 80, 0);+ try std.testing.expectEqual(pending_col, labelCol(done, "Landed") orelse return error.NoBody);+}+test "classification reads the tool name, not the whole row (#551)" {// `bash` running a command that merely mentions a search word is a call,// not a search — the old whole-line substring test got this wrong.