summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-20 03:10:38 -0300
committerGabriel Schneider <[email protected]>2026-11-20 03:19:55 -0300
commit8fb080c6208bccf9ef12eca630b0534312ae5fe7 (patch)
tree8fb4b75680589cce45ef55b0ca778ff72c989465 /core
parentc77e5a09af27976b2375a902ecb8efa428395a0c (diff)
downloadpardes-8fb080c6208bccf9ef12eca630b0534312ae5fe7.tar.gz
pardes-8fb080c6208bccf9ef12eca630b0534312ae5fe7.zip
tape: the 7 free calls the same under either terminal design on the handle, step 8a (reports/pardes-handle-69-design.md section 4): a terminal's output, its close (the poison and the refusal) read p.tape, the refusal to open one moves out of createTerminal into its two callers (newShell, newCommand: no parameter, no test changed), and the session's fonts and its shell checks (exec's Font and Shell, a 9P exec) are p.tape.site; the 3 the bytes would delete and the 11 that wait are left; the tape's bytes do not move (semantics 32640d4a722b811c unmoved, cross_replay both ways)
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core')
-rw-r--r--core/exec.zig4
-rw-r--r--core/ninep/pty.zig2
-rw-r--r--core/panes.zig10
3 files changed, 9 insertions, 7 deletions
diff --git a/core/exec.zig b/core/exec.zig
index 36879b70..74037db0 100644
--- a/core/exec.zig
+++ b/core/exec.zig
@@ -1018,7 +1018,7 @@ pub fn applySettingBuiltin(p: *Pardes, setting: config.Settings.Setting, arg: ?[
const spec = config.Settings.FontSpec.parse(arg orelse return) orelse return;
// The session's machine's fonts, a question to its disk: a
// client's replay takes the session's answer, never its own.
- const found = pardes.tape.site(.fonts, p.scratch.allocator(), fontNamed, .{ p.scratch.allocator(), spec.name });
+ const found = p.tape.site(.fonts, p.scratch.allocator(), fontNamed, .{ p.scratch.allocator(), spec.name });
const nul = std.mem.indexOfScalar(u8, found, 0) orelse return;
if (!p.settings.requestFont(found[0..nul], found[nul + 1 ..], spec.size_hundredths)) return;
p.font_request_taken = false;
@@ -1035,7 +1035,7 @@ pub fn applySettingBuiltin(p: *Pardes, setting: config.Settings.Setting, arg: ?[
return p.setMessage(.at(v.active), said.print("Shell: the default again, {s} ($SHELL, else /bin/sh)", .{p.sessionShell()[0..@min(p.sessionShell().len, 256)]}));
}
var why: [320]u8 = undefined;
- if (pardes.tape.site(.shell, null, @import("dev").host_io.Shell.refusal, .{ want[0..@min(want.len, 200)], &why })) |refused| {
+ if (p.tape.site(.shell, null, @import("dev").host_io.Shell.refusal, .{ want[0..@min(want.len, 200)], &why })) |refused| {
var text: pardes.Kind.Buf(340) = .{};
return p.reportFailure(v.active, text.print("Shell: {s}", .{refused}));
}
diff --git a/core/ninep/pty.zig b/core/ninep/pty.zig
index 26bb7661..938f3366 100644
--- a/core/ninep/pty.zig
+++ b/core/ninep/pty.zig
@@ -66,7 +66,7 @@ pub fn writeCtl(p: *Pardes, req: Req, id: usize) Reply {
// interpreter is not: refused, and the running shell kept.
const bin = pane.shell orelse p.shellBin();
var why: [320]u8 = undefined;
- if (pardes.tape.site(.shell, null, @import("dev").host_io.Shell.refusal, .{ bin[0..@min(bin.len, 200)], &why })) |refused|
+ if (p.tape.site(.shell, null, @import("dev").host_io.Shell.refusal, .{ bin[0..@min(bin.len, 200)], &why })) |refused|
return tree.failText(req.tag, E.NOENT, std.fmt.bufPrint(&p.fs.ename, "exec: {s}", .{refused[0..@min(refused.len, 300)]}) catch &p.fs.ename); // cut to ename's 320
};
if (verb(p, id, line, apply)) |why| return tree.failText(req.tag, E.INVAL, why);
diff --git a/core/panes.zig b/core/panes.zig
index 72ca3eea..7eb6cad2 100644
--- a/core/panes.zig
+++ b/core/panes.zig
@@ -709,7 +709,7 @@ pub const Pane = struct {
pub fn feedOutput(pane: *Pane, p: *Pardes, bytes: []const u8) void {
// There are no pty reads at all without an emulator to parse them into.
const state = pane.terminal orelse return;
- if (tape.authorityOnly("a terminal's output")) return;
+ if (p.tape.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.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 pane.pointerRowCount() > 0;
@@ -1133,7 +1133,6 @@ pub fn createDoc(gpa: std.mem.Allocator, cols: u16, rows: u16) !*Pane {
/// A terminal pane: a pane and its emulator. Slot ownership, serial
/// assignment and spawn effects remain core lifecycle invariants.
pub fn createTerminal(gpa: std.mem.Allocator, cols: u16, rows: u16) !*Pane {
- if (tape.authorityOnly("open a terminal")) return error.OutOfMemory;
const pane = try createDoc(gpa, cols, rows);
errdefer gpa.destroy(pane);
pane.terminal = try Term.open(emulatorGpa(gpa), cols, rows);
@@ -1196,7 +1195,7 @@ pub fn retirePane(p: *Pardes, pane: *Pane) void {
if (pane.isTerminal()) p.emit(.{ .close_pty = .{ .pane = .at(id) } });
// Its pty's end and its emulator are the authority's: a replica's
// speculation that closes a terminal waits for it.
- if (pane.terminal != null) tape.poison("close a terminal");
+ if (pane.terminal != null) p.tape.poison("close a terminal");
ctlfs.events.noteRetire(p, pane);
// ...and so do bytes still queued for the pty it no longer has.
p.dropPendingWrite(id);
@@ -1237,7 +1236,7 @@ pub fn teardownPane(p: *Pardes, pane: *Pane) void {
}
// A pane with none (a file's, a picker's, a preview's) closes in a
// speculation as anywhere.
- if (pane.terminal) |state| if (!tape.authorityOnly("close a terminal")) {
+ if (pane.terminal) |state| if (!p.tape.authorityOnly("close a terminal")) {
Term.close(state, p.gpa);
pane.terminal = null;
};
@@ -1273,6 +1272,8 @@ pub fn installPane(p: *Pardes, id: usize, pane: *Pane) void {
pub fn newShell(p: *Pardes, id: usize, cwd: []const u8) !*Pane {
std.debug.assert(p.panes[id] == null);
if (cwd.len > limits.host_path_cap) return error.PathTooLong;
+ // A speculation opens no emulator: a terminal is the authority's to open.
+ if (p.tape.authorityOnly("open a terminal")) return error.OutOfMemory;
const pane = try panes.createTerminal(p.gpa, p.view().screen_w, p.view().screen_h);
// Named by the directory it is started in from the first, so the
// shell saying it is there is no rename (`new N /` then `rename`);
@@ -1305,6 +1306,7 @@ pub fn newCommand(p: *Pardes, id: usize, cwd: []const u8, line: []const u8) !*Pa
if (cwd.len > limits.host_path_cap) return error.PathTooLong;
const owned = try p.gpa.dupe(u8, line);
errdefer p.gpa.free(owned);
+ if (p.tape.authorityOnly("open a terminal")) return error.OutOfMemory;
const pane = try panes.createTerminal(p.gpa, p.view().screen_w, p.view().screen_h);
pane.command = owned;
pane.command_pty = true;