summaryrefslogtreecommitdiff
path: root/runtime/session.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-20 04:01:55 -0300
committerGabriel Schneider <[email protected]>2026-11-20 04:07:22 -0300
commit6e8735895d04c0073eb28cc1a2f431a2ba587e9d (patch)
tree9641fb6bfaf29b9c2286e0feff1a4d6d9035d2c2 /runtime/session.zig
parent47649a2fe6884b660e57f8f7564c9a62128970e0 (diff)
parent680cfe1fa5a15be3770d310153258ba9ded13dd8 (diff)
downloadpardes-6e8735895d04c0073eb28cc1a2f431a2ba587e9d.tar.gz
pardes-6e8735895d04c0073eb28cc1a2f431a2ba587e9d.zip
integration: a session's file watches and its language servers' client once, on the attach that is always a client: pardes-services-2b (file_watch.Watches owned by the session loop, both frontends' readers deleted; the language client through the session's one queue, the terminal's own copy and its blocking post deleted) and pardes-merge29; one conflict, a doc comment in runtime/session.zig where both sides rewrote the frontend calls' list (the attach's words for note kept, the watched() line dropped: the watches' change deleted that call); tui core-test 856/1007 (151 skipped), shell-test 1047/1050, the window builds; the coordinator's gate in the ledger (reorg/merge30)
Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'runtime/session.zig')
-rw-r--r--runtime/session.zig36
1 files changed, 21 insertions, 15 deletions
diff --git a/runtime/session.zig b/runtime/session.zig
index 4172ba8d..fdd72c2b 100644
--- a/runtime/session.zig
+++ b/runtime/session.zig
@@ -3,11 +3,13 @@
//! the session's allocators and workers, its core (an upgrade's, a dump's
//! or a new one), the prompt files its shells start with, its 9P listener
//! its replica clients (`Peers`), its queue (the workers' and readers'
-//! posts, `Inbox`) and its ptys (`Ptys`): a step, its unit to the clients
-//! and theirs taken in, an Upgrade or a Restore between steps; and the
-//! order its parts end in. Its other devices (the files watched, the LSP's
-//! and the pipes' and addons' jobs, the session's own input) are still its
-//! frontend's (each `Shell`). What a frontend does is:
+//! posts, `Inbox`), its ptys (`Ptys`) and the files it watches
+//! (`file_watch.Watches`): a step, its unit to the clients and theirs
+//! taken in, an Upgrade or a Restore between steps; and the order its
+//! parts end in. Its other devices (the LSP's and the pipes' and addons'
+//! jobs, the session's own input) are still its frontend's (each `Shell`);
+//! the language servers' answers come through its queue (`Inbox.startLsp`).
+//! What a frontend does is:
//!
//! - `options(o)`: before the core: what it gives the core it starts (a
//! window's size, for a dump's layout).
@@ -17,15 +19,14 @@
//! core's first effects (an upgraded terminal's panes its own again,
//! whether anyone looks).
//! - `close(l)`: its devices stopped, after the clients are let go and
-//! before the ptys, the queue and the core go.
-//! - `start(l)`: after the first effects, the ptys read: its input, its
-//! readers, the
-//! listener's wake, a detached session's first wait (`l.watch`).
+//! before the watches, the ptys, the queue and the core go.
+//! - `start(l)`: after the first effects, the ptys and the watches
+//! read: its input, its readers, the listener's wake, a detached
+//! session's first wait (`l.watch`).
//! - `sent()`: after each step's unit went to the clients.
//! - `upgradeAsked()`: an Upgrade asked in the step, done (it execs).
//! - `note(n)`: what the daemon says (an adopted shell, a client's
//! connection, a new daemon's hello taken), onto its queue.
-//! - `watched()`: the files it watches (a Restore stops watching them).
//! - `restoring(nc)`, `restored(l)`: a Restore's new core, before it
//! replaces the old one (its devices let go, what it is told of the
//! frontend) and after (its own view of it again).
@@ -39,9 +40,6 @@ const daemon = @import("daemon.zig");
const upgrade = @import("upgrade.zig");
const ninep_io = @import("9p_io.zig");
-/// The files a frontend watches (host_io.restoreCore lets them go).
-pub const Watched = struct { fd: c_int, table: *file_watch.Table };
-
pub fn Loop(comptime Frontend: type) type {
return struct {
const L = @This();
@@ -58,6 +56,7 @@ pub fn Loop(comptime Frontend: type) type {
/// to take in its wait.
inbox: host_io.Inbox = undefined,
ptys: Ptys = undefined,
+ watches: file_watch.Watches = undefined,
fs: ?*ninep_io.Listener = null,
peers: replica.Peers = .{},
host: pardes.Host = undefined,
@@ -91,8 +90,13 @@ pub fn Loop(comptime Frontend: type) type {
l.peers = .{ .gpa = l.gpa, .io = l.io, .name = daemon.name() };
l.inbox = .{ .io = l.io, .gpa = l.gpa, .lsp_allocator = l.allocs.lsp };
defer l.inbox.deinit();
+ // The language servers' status lines, from the first effects on.
+ pardes.lsp.setStatusSink(&l.inbox, host_io.Inbox.lspStatus);
+ defer pardes.lsp.setStatusSink(null, null);
l.ptys = .{ .queue = &l.inbox, .prompt_rcs = &l.prompt_rcs };
defer l.ptys.deinit();
+ l.watches = .open(l.io, l.gpa, &l.inbox);
+ defer l.watches.deinit();
l.host = try fe.open(&l);
defer fe.close(&l);
@@ -107,6 +111,7 @@ pub fn Loop(comptime Frontend: type) type {
l.effects();
}
l.ptys.start(l.core);
+ l.watches.start();
try fe.start(&l);
while (!l.core.quit) {
@@ -155,9 +160,10 @@ pub fn Loop(comptime Frontend: type) type {
/// let go (host_io.restoreCore); its shells and the frontend's
/// devices with it.
fn restore(l: *L, path: []const u8) void {
- const w = l.fe.watched();
- const nc = host_io.restoreCore(l.gpa, l.core, path, &l.peers, w.fd, w.table) orelse return;
+ const nc = host_io.restoreCore(l.gpa, l.core, path, &l.peers, l.watches.fd, &l.watches.table) orelse return;
l.fe.restoring(nc);
+ // An answer to the old core's query is turned away.
+ l.inbox.discardCompletions();
l.ptys.stop();
nc.host = l.host;
if (l.fs) |f| f.reset(nc);