Skip to content

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

Python

fix(tui): paint live markdown on the cached tail, one enable seq

Cursor Agent6377cdad4011
diff --git a/TUI/layout_cache.zig b/TUI/layout_cache.zig
index e242f5b9..07f4362e 100644
--- a/TUI/layout_cache.zig
+++ b/TUI/layout_cache.zig
@@ -199,9 +199,10 @@ const Walk = struct {
fn liveText(m: *Model, a: std.mem.Allocator, start: usize, end: usize, width: usize) ![]const u8 {
if (end != start) return steerText(m, a);
const job = m.pending orelse return "";
- const src = if (job.raw.len.load(.acquire) > 0) &job.raw else &job.stream;
+ const raw_bash = job.raw.len.load(.acquire) > 0;
+ const src = if (raw_bash) &job.raw else &job.stream;
const live = src.snapshot(a) orelse return "";
- return theme_mod.paint(a, m.theme().muted, try scrollback.tail(a, scrollback.strip(a, live), width, 4));
+ return theme_mod.paint(a, m.theme().muted, try scrollback.liveTail(m, a, live, raw_bash, width));
}
fn steerText(m: *Model, a: std.mem.Allocator) ![]const u8 {
diff --git a/TUI/run.zig b/TUI/run.zig
index 9b87d4c4..d6b19a0d 100644
--- a/TUI/run.zig
+++ b/TUI/run.zig
@@ -76,7 +76,9 @@ pub fn run(
var out_buf: [64 * 1024]u8 = undefined;
var stdout = Io.File.stdout().writer(io, &out_buf);
const w = &stdout.interface;
- w.writeAll(enable_seq) catch {};
+ // Claim already wrote enable_seq (kitty is a stack). Writing it again
+ // left a leftover push and failed mode-balance on the PTY probes.
+ if (claimed == null) w.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
diff --git a/TUI/scrollback.zig b/TUI/scrollback.zig
index ad006e0e..de366e41 100644
--- a/TUI/scrollback.zig
+++ b/TUI/scrollback.zig
@@ -341,7 +341,7 @@ pub fn strip(a: std.mem.Allocator, s: []const u8) []const u8 {
/// Live prose uses the same renderer as a settled assistant row. Raw bash
/// stays sanitized-only — those bytes are a terminal, not markdown.
-fn liveTail(self: *const Model, a: std.mem.Allocator, live: []const u8, raw_bash: bool, width: usize) ![]const u8 {
+pub fn liveTail(self: *const Model, a: std.mem.Allocator, live: []const u8, raw_bash: bool, width: usize) ![]const u8 {
const clean = strip(a, live);
if (raw_bash) return tail(a, clean, width, 4);
const painted = @import("markdown.zig").renderThemed(a, clean, self.theme(), width -| 4) catch clean;