Skip to content

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

Python

fix(repl): bracket peer-message blocks with blank lines

Rach Pradhan330040a95dd6
diff --git a/src/peer_channel.zig b/src/peer_channel.zig
index a80c1f92..2f161a9b 100644
--- a/src/peer_channel.zig
+++ b/src/peer_channel.zig
@@ -219,6 +219,13 @@ pub fn deliverInbound(root: *Agent) void {
if (deviceHears(m, own)) heard.append(root.arena, m) catch break else skipped += 1;
}
device_msgs = heard.items;
+ // A blank line of air on either side of the visible block: peer lines
+ // land mid-stream at a step boundary and used to butt straight against
+ // the assistant text above and whatever follows below — one clump.
+ const window = displayWindow(is_backlog_drain, local_msgs.len + device_msgs.len);
+ const any_visible = local_msgs.len + device_msgs.len > window.start or
+ (repl.g_debug and (note != null or omitted > 0 or skipped > 0 or window.hidden > 0));
+ if (any_visible) sink.emit(root.io, .{ .session_notice = .{ .text = "", .tone = .plain } });
var buf: std.ArrayList(u8) = .empty;
if (note) |n| {
buf.appendSlice(root.arena, n) catch {};
@@ -257,13 +264,13 @@ pub fn deliverInbound(root: *Agent) void {
// History gets every line (the model coordinates from it); the REPL prints
// only the tail of a first-drain backlog so a resume is not a wall of
// text. Live incremental drains render every line — those are new.
- const window = displayWindow(is_backlog_drain, lines.items.len);
if (window.hidden > 0) {
const marker = std.fmt.allocPrint(root.arena, "[#469 channel: {d} backlog message(s) delivered to context — showing last {d}]", .{ window.hidden, backlog_repl_show }) catch "";
if (marker.len > 0 and repl.g_debug) sink.emit(root.io, .{ .session_notice = .{ .text = marker, .tone = .plain } });
}
for (lines.items[window.start..]) |line|
sink.emit(root.io, .{ .session_notice = .{ .text = line, .tone = .plain } });
+ if (any_visible) sink.emit(root.io, .{ .session_notice = .{ .text = "", .tone = .plain } });
if (buf.items.len == 0) return;
buf.appendSlice(root.arena, "(reply with the peer_message tool — queued, one-way; everyone here hears it)") catch {};
var obj: std.json.ObjectMap = .empty;