Skip to content

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

Python

Merge branch 'perf/tui-layout-cache' into verify/tui-interaction-audit

Rach Pradhan3bf9e583a0ce
diff --cc TUI/render.zig
index 6405d8ff,375cfe71..1454847d
--- a/TUI/render.zig
+++ b/TUI/render.zig
@@@ -8,8 -8,7 +8,9 @@@ 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 scrollback = @import("scrollback.zig");
+ const layout_cache = @import("layout_cache.zig");
const selection = @import("selection.zig");
const theme_mod = @import("theme.zig");
const welcome = @import("welcome.zig");
diff --cc TUI/root.zig
index 2ced2580,0f24f9e0..8c0baba5
--- 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/scrollback.zig
index 8e7c8d6b,1b765a5a..015a190b
--- a/TUI/scrollback.zig
+++ b/TUI/scrollback.zig
@@@ -270,9 -269,9 +271,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) {
@@@ -401,14 -396,21 +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 —