summaryrefslogtreecommitdiff
path: root/core/Core.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-19 15:52:33 -0300
committerGabriel Schneider <[email protected]>2026-11-19 15:52:33 -0300
commit8fea4ab90a04acd5f20528b00342c23d42f8c83e (patch)
treebe264d2cd8ba57492e227d9d6a65027f3d7680c9 /core/Core.zig
parent553a62bac675bfc0a64254718488d3c8012f533e (diff)
parentee2e79dea10c93c104b70cf1eedccd7ba85003fc (diff)
downloadpardes-8fea4ab90a04acd5f20528b00342c23d42f8c83e.tar.gz
pardes-8fea4ab90a04acd5f20528b00342c23d42f8c83e.zip
integration: the soak on the real session loop and the cli's serve thread joined, with the tape's handle through the kinds, the core's own files and the small ones: pardes-runners-d (10c's last changes) and pardes-handle-2 (the handle's steps 3 to 5 and its two rules as tests), merged without a conflict; gates in the coordinator's ledger
Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/Core.zig')
-rw-r--r--core/Core.zig33
1 files changed, 17 insertions, 16 deletions
diff --git a/core/Core.zig b/core/Core.zig
index b4745b24..769d16cd 100644
--- a/core/Core.zig
+++ b/core/Core.zig
@@ -514,16 +514,17 @@ pub const perform = @import("Effect.zig").perform;
/// second copy of this drifted once, leaving restored tags without an
/// allocator and every 9P mtime 0.
pub fn create(gpa: std.mem.Allocator, opts: Options) !*Pardes {
+ // The global still set beside the field (P20): a core made while
+ // a tape records (PARDES_RECORD, a replica's step) is its.
+ const tape = opts.tape orelse pardes.tape.on orelse &pardes.tape.none;
const p = try gpa.create(Pardes);
p.* = .{
.gpa = gpa,
.image_gpa = opts.image_allocator orelse gpa,
- .kinds = .started(opts.addons),
+ .kinds = .started(tape, opts.addons),
.tree_sitter_gpa = opts.tree_sitter_allocator orelse gpa,
.opts = opts,
- // The global still set beside the field (P20): a core made while
- // a tape records (PARDES_RECORD, a replica's step) is its.
- .tape = opts.tape orelse pardes.tape.on orelse &pardes.tape.none,
+ .tape = tape,
.tty_toggle = opts.tty_toggle,
.views = .{ View{
.frontend = .{ .windowed = opts.windowed },
@@ -710,7 +711,7 @@ pub fn recentGpa(_: *const Pardes) std.mem.Allocator {
pub fn loadRecent(p: *Pardes) void {
// A replica's Recent is its own, in memory: the recording session's
// state file is every session's of its user (core/tape.zig).
- if (pardes.tape.replaying()) p.db.kind = .off;
+ if (p.tape.replaying()) p.db.kind = .off;
p.db.readRecent(p);
}
@@ -773,11 +774,11 @@ pub fn recentDot(pane: *const Pane) ?struct { path: []const u8, line: u32, col:
/// reads them: its process's options, so the authority's
/// (`tape.authority`); a replica's are its own process's.
pub fn configDir(p: *Pardes) ?[]const u8 {
- return pardes.tape.authority(optsConfigDir, .{p});
+ return p.tape.authority(optsConfigDir, .{p});
}
pub fn startupPath(p: *Pardes) ?[]const u8 {
- return pardes.tape.authority(optsStartupPath, .{p});
+ return p.tape.authority(optsStartupPath, .{p});
}
fn optsConfigDir(p: *Pardes) ?[]const u8 {
@@ -792,7 +793,7 @@ fn optsStartupPath(p: *Pardes) ?[]const u8 {
/// in scratch. Recent is the authority's (every window of its user
/// writes it): a replica has its answer (`tape.authority`).
pub fn recentByHash(p: *Pardes, hash: u64) ?recent_files.Entry {
- return pardes.tape.authority(recentFound, .{ p, hash });
+ return p.tape.authority(recentFound, .{ p, hash });
}
fn recentFound(p: *Pardes, hash: u64) ?recent_files.Entry {
@@ -926,7 +927,7 @@ fn reportFocus(p: *Pardes) void {
// session's step makes the write, off the tape on both sides
// (tape.hostCall's pty_write), so the switch shows at once and the
// program hears of it a round trip later.
- if (pardes.tape.speculating() and pardes.tape.screenState()) return;
+ if (p.tape.speculating and p.tape.screen_state) return;
if (v.focus_told) |old| if (p.panes[old.id]) |pane| {
if (pane.serial == old.serial and pardes.Term.modes(pane.terminal).focus) p.emitWrite(old.id, "\x1b[O");
};
@@ -1360,7 +1361,7 @@ fn sayShellFailure(p: *Pardes, id: u8, err: anyerror) void {
// The script is there; the program its `#!` names is not.
var said: pardes.Kind.Buf(320) = .{};
var interp: [256]u8 = undefined;
- const name = pardes.tape.value(.interpreter, missingInterpreter, .{ pane.shell orelse p.shellBin(), &interp });
+ const name = p.tape.value(.interpreter, missingInterpreter, .{ pane.shell orelse p.shellBin(), &interp });
p.reportFailure(id, if (name) |n| said.print("shell: interpreter {s} not found", .{n}) else "shell: interpreter not found");
} else {
p.reportError(id, "shell", err);
@@ -1744,15 +1745,15 @@ fn fsReport(p: *Pardes) void {
pub fn readSessionFacts(p: *Pardes) void {
// A dump made since carries them all: its shell is never empty.
if (p.session_shell_len != 0) return;
- if (p.session_dir_len == null) if (pardes.tape.value(.env, processDir, .{&p.session_dir})) |dir| {
+ if (p.session_dir_len == null) if (p.tape.value(.env, processDir, .{&p.session_dir})) |dir| {
std.mem.copyForwards(u8, &p.session_dir, dir);
p.session_dir_len = @intCast(dir.len);
};
- if (pardes.tape.value(.env, filesystem.processHome, .{})) |home| if (home.len <= p.session_home.len) {
+ if (p.tape.value(.env, filesystem.processHome, .{})) |home| if (home.len <= p.session_home.len) {
@memcpy(p.session_home[0..home.len], home);
p.session_home_len = @intCast(home.len);
};
- const shell = pardes.tape.value(.env, config.defaultShell, .{});
+ const shell = p.tape.value(.env, config.defaultShell, .{});
const kept = shell[0..@min(shell.len, p.session_shell.len)];
@memcpy(p.session_shell[0..kept.len], kept);
p.session_shell_len = @intCast(kept.len);
@@ -1955,7 +1956,7 @@ pub fn sync(p: *Pardes) void {
// A directory pane's entries follow its width, as acme's
// columns do (Dir.fit).
if (pane.file) |file| if (file.listing != null and r.h > pane.tag_rows) pardes.panes.Dir.fit(p, pane, pane.cols);
- if (pane.pending_command.wait == .input) pane.releasePendingCommand(p, id, pardes.tape.value(.prompt, struct {
+ if (pane.pending_command.wait == .input) pane.releasePendingCommand(p, id, p.tape.value(.prompt, struct {
fn ready(at: *const Pane) bool {
return pardes.Term.prompt(at.terminal).input_ready;
}
@@ -1967,7 +1968,7 @@ pub fn sync(p: *Pardes) void {
// its shell's FIRST prompt, or never: typed later it would land
// in whatever runs then, or in the middle of a line someone
// typed (Pane.greeting).
- if (pane.greet and pane.isTerminal() and p.resize_count > 0) switch (pardes.tape.value(.prompt, Pane.greeting, .{pane})) {
+ if (pane.greet and pane.isTerminal() and p.resize_count > 0) switch (p.tape.value(.prompt, Pane.greeting, .{pane})) {
.wait => {},
.never => pane.greet = false,
.now => {
@@ -2103,7 +2104,7 @@ fn advanceInner(p: *Pardes, now_ns: u64) void {
// The session's ticks are the recording session's: a picture still
// decoding or a fade still moving asks for frames the way a message
// waiting to go does, and a replica that draws nothing has none.
- while (pardes.tape.value(.wake, nextWake, .{p})) |due| {
+ while (p.tape.value(.wake, nextWake, .{p})) |due| {
if (due > now_ns) break;
// Only waiting until `due`: its counters move there at once.
const held = (due - p.clock.stepped_ns) / frame;