summaryrefslogtreecommitdiff
path: root/dev/gui
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-20 12:36:59 -0300
committerGabriel Schneider <[email protected]>2026-11-20 13:09:56 -0300
commit9c50dd0b64ecaa8cbcfd4f76868dc83e5b9636e3 (patch)
tree1fd44d101a680ed4ff601c8760d2f6bd4139edc0 /dev/gui
parent1374e668fe568ad4f7f70c06156c1ecdbb8840b9 (diff)
parentc8ac386d8f2404417b6d09af1635e1104bcc66ae (diff)
downloadpardes-9c50dd0b64ecaa8cbcfd4f76868dc83e5b9636e3.tar.gz
pardes-9c50dd0b64ecaa8cbcfd4f76868dc83e5b9636e3.zip
integration: the addons' workers and the daemon's notes once, on the five faults a busy machine showed: pardes-services-3 (jobs, draws, pipes and a search through the session's one queue, their workers the queue's; the daemon's notes the loop's own: eight frontend calls; an Adopt's shells kept room in a full queue; a command's exit told after its reads are applied; the tty harness's end of a case) and pardes-merge36 (pardes-faults-5); two conflicts, both where the daemon's reader starts: the faults made daemon.watch() argument-free with daemon.notesTo, the services gave the loop its own note: daemon.notesTo(&l, note) and daemon.watch(); the terminal frontend's quit arm starts no reader (kept does), and Shell.session, whose one reader that line was, is deleted; tui core-test 861/1016 (155 skipped), shell-test 1058/1061, term-test 17/17, both soaks diverged 0, unequal 0, unlisted 0, the window builds; the coordinator's gate in the ledger (reorg/merge37)
Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'dev/gui')
-rw-r--r--dev/gui/gui.zig79
1 files changed, 9 insertions, 70 deletions
diff --git a/dev/gui/gui.zig b/dev/gui/gui.zig
index 59e70935..201c23df 100644
--- a/dev/gui/gui.zig
+++ b/dev/gui/gui.zig
@@ -379,7 +379,6 @@ fn sdlWake(_: ?*anyopaque) void {
sev.type = c.SDL_EVENT_USER;
_ = c.SDL_PushEvent(&sev);
}
-const PipeTasks = selection_pipe.Tasks;
const output_capacity = Queue.output_capacity;
const Gui = struct {
@@ -991,7 +990,6 @@ const Own = struct {
g: *Gui,
test_mode: bool,
detached: bool,
- pipe_tasks: PipeTasks = .{},
shell: Shell = undefined,
const Session = session_loop.Loop(Own);
@@ -1024,7 +1022,6 @@ const Own = struct {
.lsp_allocator = l.allocs.lsp,
.ptys = &l.ptys,
.queue = &l.inbox,
- .pipe_tasks = &o.pipe_tasks,
.watches = &l.watches,
.fs = l.fs,
.test_mode = o.test_mode,
@@ -1044,15 +1041,10 @@ const Own = struct {
return host;
}
- pub fn close(o: *Own, l: *Session) void {
- const io = l.io;
+ pub fn close(o: *Own, _: *Session) void {
o.shell.fs = null;
host_io.setExitWake(null, null);
pardes.Kind.drawer = null;
- o.shell.job_tasks.cancelAll(io);
- o.pipe_tasks.cancelAll(io);
- // Its worker may be waiting on the queue for room.
- l.core.stream.cancelTask();
o.g.hit_core = null;
}
@@ -1079,12 +1071,7 @@ const Own = struct {
if (o.shell.upgrade_asked) |pane| o.shell.upgradeNow(pane);
}
- pub fn note(o: *Own, n: daemon.Note) void {
- deliverNote(&o.shell, n);
- }
-
pub fn restoring(o: *Own, nc: *pardes.Pardes) void {
- o.pipe_tasks.cancelAll(o.shell.io);
// One view, the window's (host_io.restoreCore).
o.shell.gview = 0;
o.g.cells.clearImages();
@@ -1415,7 +1402,6 @@ fn clientSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_
var queue: Queue = .{ .io = io, .gpa = gpa, .lsp_allocator = start.allocs.lsp, .wake_fn = sdlWake };
defer queue.deinit();
var ptys: host_io.Ptys = .{ .queue = &queue, .prompt_rcs = undefined };
- var pipe_tasks: PipeTasks = .{};
var no_watches: file_watch.Watches = .{ .io = io, .gpa = gpa, .queue = &queue };
var no_peers: replica.Peers = .{};
var shell: Shell = .{
@@ -1426,7 +1412,6 @@ fn clientSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_
.lsp_allocator = start.allocs.lsp,
.ptys = &ptys,
.queue = &queue,
- .pipe_tasks = &pipe_tasks,
.watches = &no_watches,
.test_mode = test_mode,
.client = &window,
@@ -1435,7 +1420,6 @@ fn clientSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_
window.shell = &shell;
pardes.Kind.drawer = .{ .ctx = &shell, .go = kindDraw };
defer pardes.Kind.drawer = null;
- defer shell.job_tasks.cancelAll(io);
g.no_blink = test_mode;
defer g.hit_core = null;
_ = c.SDL_StartTextInput(g.window);
@@ -2357,8 +2341,6 @@ const Shell = struct {
queue: *Queue,
/// What drainQueue takes each wakeup, kept rather than rebuilt.
batch: Queue.Batch = .{},
- pipe_tasks: *PipeTasks,
- job_tasks: PipeTasks = .{},
/// The session's file watches (runtime/session.zig's); a client's,
/// none.
watches: *file_watch.Watches,
@@ -2567,10 +2549,7 @@ const Shell = struct {
fn takeDraws(s: *Shell) bool {
s.queue.takeInto(&s.batch);
for (s.batch.slice()) |m| switch (m) {
- .kind_job => |j| {
- s.job_tasks.finish(s.io, j.id);
- j.land(s.core);
- },
+ .kind_job => s.queue.land(s.core, m),
else => m.deinit(s.gpa, s.lsp_allocator),
};
return s.batch.slice().len > 0;
@@ -2586,33 +2565,10 @@ const Shell = struct {
for (msgs.slice()) |m| switch (m) {
.output => |o| s.ptys.output(s.core, o),
.eof => |e| s.ptys.eof(s.core, e),
- .lsp, .lsp_status => s.queue.landLsp(s.core, m),
- .pipe => |response_value| {
- var response = response_value;
- s.core.update(.{ .pipe_resp = .{
- .id = response.id,
- .success = response.success,
- .outputs = response.outputs,
- .failure = response.failure,
- } });
- response.deinit(s.gpa);
- s.pipe_tasks.finish(s.io, response_value.id);
- },
- .search => |b| {
- s.core.update(.{ .search = b });
- b.deinit(s.gpa);
- },
- .handed => |h| {
- s.core.update(.{ .handed = .{ .seq = h.seq, .to = if (h.ok) h.words else "", .failure = if (h.ok) null else h.words } });
- s.gpa.free(h.words);
- },
- .kind_job => |j| {
- s.job_tasks.finish(s.io, j.id);
- j.land(s.core);
- },
.files_changed => check_files = true,
.fs_ready => {},
.adopted => |a| s.ptys.adoptions.adoptShell(s.core, a.pid, a.fd),
+ else => s.queue.land(s.core, m),
};
if (check_files) s.watches.reload(s.core);
}
@@ -3119,21 +3075,6 @@ fn guiNow(ctx: ?*anyopaque) u64 {
return s.test_clock orelse s.paced_ns orelse c.SDL_GetTicksNS();
}
-/// The daemon's thread: what it says, onto the queue (drainQueue).
-fn deliverNote(ctx: *anyopaque, note: daemon.Note) void {
- const s: *Shell = @ptrCast(@alignCast(ctx));
- const q = s.queue;
- switch (note) {
- .relinked => q.wake(),
- .adopted => |a| {
- for (a.pids[0..a.n], a.fds[0..a.n]) |pid, fd| q.push(.{ .adopted = .{ .pid = pid, .fd = fd } });
- q.push(.{ .adopted = .{ .pid = 0, .fd = -1 } });
- },
- // Joined at the next step boundary (Peers, any thread).
- .replica => |j| s.peers.handed(j.fd, j.view),
- }
-}
-
fn writeDump(ctx: ?*anyopaque, bytes: []const u8) void {
host_io.writeDump(shellOf(ctx).core, bytes);
}
@@ -3184,7 +3125,7 @@ fn lsp(ctx: ?*anyopaque, req: host_io.Lsp.Request) void {
fn pipe(ctx: ?*anyopaque, id: u32) void {
const s = shellOf(ctx);
- if (s.threads_ok) return selection_pipe.start(s.io, s.gpa, s.core, s.pipe_tasks, id, s.queue, Queue.pushPipe);
+ if (s.threads_ok) return selection_pipe.start(s.io, s.gpa, s.core, &s.queue.pipe_tasks, id, s.queue, Queue.pushPipe);
s.core.update(.{ .pipe_resp = .{ .id = id, .success = false, .outputs = &.{} } });
s.core.reportError(.at(s.core.view().active), "pipe", error.WorkersUnavailable);
}
@@ -3192,13 +3133,13 @@ fn pipe(ctx: ?*anyopaque, id: u32) void {
/// A draw (api.draw) on a worker, as a job is.
fn kindDraw(ctx: ?*anyopaque, j: *host_io.KindJob) bool {
const s = shellOf(ctx);
- return (s.threads_ok or s.client != null) and host_io.KindJob.go(s.io, &s.job_tasks, j, s.queue, Queue.pushJob);
+ return (s.threads_ok or s.client != null) and host_io.KindJob.go(s.io, &s.queue.job_tasks, j, s.queue, Queue.pushJob);
}
fn kindJob(ctx: ?*anyopaque, id: pardes.Pane.Id, serial: u32, token: u32) void {
const pane = id.index();
const s = shellOf(ctx);
- if (s.threads_ok) return host_io.KindJob.start(s.io, s.core, &s.job_tasks, pane, serial, token, s.queue, Queue.pushJob);
+ if (s.threads_ok) return host_io.KindJob.start(s.io, s.core, &s.queue.job_tasks, pane, serial, token, s.queue, Queue.pushJob);
host_io.KindJob.runHere(s.core, pane, serial, token);
}
@@ -5982,7 +5923,6 @@ test "GUI worker setup failures finish matching LSP and pipe requests" {
.lsp_allocator = failing.allocator(),
};
defer queue.deinit();
- var tasks: PipeTasks = .{};
core.lspRequest(core.view().active, .status, "");
const req: host_io.Lsp.Request = .{
.id = core.lsp_ask.wait.?.id,
@@ -6014,11 +5954,11 @@ test "GUI worker setup failures finish matching LSP and pipe requests" {
core.update(.{ .key = .{ .cp = 't', .text = "tr a-z A-Z" } });
core.update(.{ .key = .{ .cp = pardes.Key.enter } });
const pipe_id = core.pipe.wait.?.id;
- selection_pipe.start(failing_io, failing.allocator(), core, &tasks, pipe_id, &queue, Queue.pushPipe);
+ selection_pipe.start(failing_io, failing.allocator(), core, &queue.pipe_tasks, pipe_id, &queue, Queue.pushPipe);
try std.testing.expect(core.pipe.wait == null);
try std.testing.expectEqualStrings("abc", pane.file.?.content);
try std.testing.expect(queue.lsp_task == null);
- try std.testing.expectEqual(@as(usize, 0), tasks.len);
+ try std.testing.expectEqual(@as(usize, 0), queue.pipe_tasks.len);
try std.testing.expectEqual(@as(usize, 0), queue.len);
}
}
@@ -7682,9 +7622,8 @@ test "a detached GUI authority follows terminal directory changes with no window
const rcs: host_io.Shell.PromptFiles = .{};
var ptys: host_io.Ptys = .{ .queue = &queue, .prompt_rcs = &rcs, .gens = @splat(1) };
defer ptys.deinit();
- var pipes: PipeTasks = .{};
var no_peers: replica.Peers = .{};
- var shell: Shell = .{ .core = core, .io = io, .gpa = gpa, .lsp_allocator = gpa, .ptys = &ptys, .queue = &queue, .pipe_tasks = &pipes, .watches = undefined, .peers = &no_peers };
+ var shell: Shell = .{ .core = core, .io = io, .gpa = gpa, .lsp_allocator = gpa, .ptys = &ptys, .queue = &queue, .watches = undefined, .peers = &no_peers };
const child = try host_io.forkShell(null, 0, &rcs, "/bin/sh", start, 24, 80);
ptys.slots[0] = .{ .fd = child.file.handle, .pid = child.pid };
try std.testing.expect(host_io.writeFd(child.file.handle, "cd child\n"));