Skip to content

graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs

Python

Merge branch 'fix/tui-stream-markdown' into ui/tui-scrollbar-osc52

Rach Pradhan3f5cccc20858
diff --cc TUI/root.zig
index e690a4e5,3ab4dccf..4a167a43
--- a/TUI/root.zig
+++ b/TUI/root.zig
@@@ -67,8 -64,8 +67,9 @@@ test
_ = @import("chrome.zig");
_ = @import("models.zig");
_ = @import("markdown.zig");
+ _ = @import("markdown_stream_tests.zig");
_ = @import("syntax.zig");
+ _ = @import("diff.zig");
_ = @import("dump.zig");
_ = @import("effort.zig");
_ = @import("sim.zig");
diff --cc TUI/scrollback.zig
index 093e4780,76b10d57..015a190b
--- a/TUI/scrollback.zig
+++ b/TUI/scrollback.zig
@@@ -402,21 -395,14 +402,14 @@@ fn firstLine(s: []const u8) []const u8
return s;
}
+ /// The live tail is raw model bytes: escapes, C0 controls (a CR would rewind
+ /// the row) and the half glyph a delta boundary left behind all have to go
+ /// before it reaches a frame. Same filter the finished message gets.
-fn strip(a: std.mem.Allocator, s: []const u8) []const u8 {
+pub fn strip(a: std.mem.Allocator, s: []const u8) []const u8 {
- var out = std.array_list.Managed(u8).init(a);
- var i: usize = 0;
- while (i < s.len) {
- if (s[i] == 0x1b) {
- i = theme_mod.skipEsc(s, i);
- continue;
- }
- out.append(s[i]) catch {};
- i += 1;
- }
- return out.items;
+ return @import("markdown.zig").sanitize(a, s) catch s;
}
-fn tail(a: std.mem.Allocator, s: []const u8, width: usize, max_lines: usize) ![]const u8 {
+pub fn tail(a: std.mem.Allocator, s: []const u8, width: usize, max_lines: usize) ![]const u8 {
var lines = std.array_list.Managed([]const u8).init(a);
var it = std.mem.splitScalar(u8, s, '\n');
// No tool-line filter any more: the live buffer carries PROSE only —
diff --cc scripts/eval-tier1.sh
index 5edc55f5,25d02a54..1f9b5a7c
--- a/scripts/eval-tier1.sh
+++ b/scripts/eval-tier1.sh
@@@ -243,56 -242,12 +243,62 @@@ if wanted tuiguard; the
if python3 scripts/test-tui-typed-events.py zig-out/bin/graff; then :; else
record_fail tuiguard
fi
+ # 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
+ # 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
+ # 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
+ # 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
+ fi
+ # Streaming markdown: the answer arrives as 1-3 codepoint deltas whose
+ # boundaries land mid-escape, mid-fence and mid-marker. Both the live tail
+ # and the settled row must be free of the model's own CR/SGR bytes.
+ if python3 scripts/test-tui-stream-markdown.py zig-out/bin/graff; then :; else
+ record_fail tuiguard
+ fi
fi
fi