From 6cb07327b717603be983fdd6df0e6d9009aae39a Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 30 Oct 2026 16:00:52 -0300 Subject: replica: what stopped each input's speculation is counted by name (PARDES_REPLICA_STATS's `stops`: a host function's, a site's, or a poison's reason, which tape.poison now takes; PARDES_REPLICA_TRACE says it with the input); a window client's PARDES_TEST_LATENCY says each input (`I seq ns at-once`) and, after each unit, the first of its own not confirmed (`U ns seq`), so a harness finds the frame that shows an input that waited Co-Authored-By: Claude Opus 5.5 --- src/terminal.zig | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/terminal.zig') diff --git a/src/terminal.zig b/src/terminal.zig index e9d628aa..be886044 100644 --- a/src/terminal.zig +++ b/src/terminal.zig @@ -607,16 +607,16 @@ pub const emulator_gpa = std.heap.c_allocator; /// A replica's speculation leaves an emulator be: it is the authority's /// (docs/next-daemon.md, phase 5), so the input waits for its order. -fn authorityOnly() bool { +fn authorityOnly(comptime why: []const u8) bool { if (!pardes.tape.speculating()) return false; - pardes.tape.poison(); + pardes.tape.poison(why); return true; } /// Move the emulator's viewport by `delta` shell rows (negative scrolls back). pub fn scrollGrid(pane: *Pane, delta: i32) void { if (comptime !enabled) return; - if (authorityOnly()) return; + if (authorityOnly("scroll a terminal")) return; const state = pane.terminal orelse return; state.vt.screens.active.scroll(.{ .delta_row = delta }); state.changes +%= 1; @@ -632,7 +632,7 @@ pub fn atBottom(pane: *const Pane) bool { /// Snap the viewport back onto live output. pub fn followOutput(pane: *Pane) void { if (comptime !enabled) return; - if (authorityOnly()) return; + if (authorityOnly("follow a terminal")) return; const state = pane.terminal orelse return; const moved = state.vt.screens.active.pages.viewport != .active; state.vt.screens.active.scroll(.active); @@ -643,7 +643,7 @@ pub fn followOutput(pane: *Pane) void { /// a scrollback; the next resize retries with the same numbers. pub fn resizeGrid(pane: *Pane, gpa: std.mem.Allocator, cols: u16, rows: u16) void { if (comptime !enabled) return; - if (authorityOnly()) return; + if (authorityOnly("resize a terminal")) return; const state = pane.terminal orelse return; if (cols != pane.cols) for (0..pane.sel.len) |button| { pane.clearPointerSelection(button); @@ -868,7 +868,7 @@ pub fn screenTextLen(pane: *Pane) usize { /// Release the emulator's heap. The Pane allocation itself is the core's. pub fn deinitEmulator(pane: *Pane, gpa: std.mem.Allocator) void { if (comptime !enabled) return; - if (authorityOnly()) return; + if (authorityOnly("close a terminal")) return; const state = pane.terminal orelse return; if (comptime images_enabled) state.images.deinit(gpa); state.stream.deinit(); @@ -898,7 +898,7 @@ fn emulator(gpa: std.mem.Allocator, cols: u16, rows: u16) !ghostty_vt.Terminal { /// Allocate the live emulator half of a terminal pane. Slot ownership, serial /// assignment, and spawn effects remain core lifecycle invariants. pub fn create(gpa: std.mem.Allocator, cols: u16, rows: u16) !*Pane { - if (authorityOnly()) return error.OutOfMemory; + if (authorityOnly("open a terminal")) return error.OutOfMemory; const pane = try createDoc(gpa, cols, rows); errdefer gpa.destroy(pane); if (comptime !enabled) return pane; @@ -1163,7 +1163,7 @@ pub fn feedOutput(p: *Pardes, pane: *Pane, bytes: []const u8) void { // There are no pty reads at all without an emulator to parse them into. if (comptime !enabled) return; if (pane.terminal == null) return; - if (authorityOnly()) return; + if (authorityOnly("a terminal's output")) return; const has_positions = pane.ovl != null or pane.body.cur_pinned or pane.body.vsel.active or pane.body.msel.active or pane.body.nsel > 0 or pane.body.last_edit != null or pane.look_at != null or pane.body.ed_undo_len > 0 or pane.body.ed_redo_len > 0 or pointerRowCount(pane) > 0; -- cgit v1.3