diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-20 00:51:28 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-20 01:04:49 -0300 |
| commit | 4bcf2055cb97d0c69fc94643b3e43b579d6fa30c (patch) | |
| tree | cc845bdc25436aca800fb4791a9709ad913f3d32 /core/Term.zig | |
| parent | 8e04bc6370916ac328f61ad0df6e3babeb9789b4 (diff) | |
| download | pardes-4bcf2055cb97d0c69fc94643b3e43b579d6fa30c.tar.gz pardes-4bcf2055cb97d0c69fc94643b3e43b579d6fa30c.zip | |
term: a kitty image's medium (a file, a temporary file, shared memory) is the session's read and a recorded answer on the tape, so every replica's emulator is handed the bytes the session read, or its failure, and never reads its own machine: ghostty's loader gets the bytes through `LoadingImage.read_medium` (an Edit in build/patches.zig, ghostty's own read handed to it, the report in docs/ghostty-kitty-medium.md), which the terminal module sets to the core's `Term.media`, a `tape.valueIn(.medium, ...)` site (a new Site; `valueIn` is `value` with the answer's slices in the loader's allocator, no yield inside a feed), so a read crosses to a client as a file read does (inline under 1 MiB, by hash at or over it), a temporary file is deleted and shared memory unlinked once, on the session, and the program is answered by the session alone; a replica no longer loads by direct data only: `Term.direct`, `State.direct` and the `direct` entry go (`media` in their place); under screen state the read stays the authority's (a screen-state replica feeds no emulator); FIRST the test through the replica's surface (a session and a bytes replica, four images shown, by a file, a temporary file, shared memory and a missing file): on the base the digests parted (expected 8810391091473565423, found 2236913079067993401: the replica's loader said "unsupported medium" and did not move its cursor), now they agree, the terminals dump the same bytes, the temporary file and the object are gone and the replica read nothing (ghostty's FileNotFound warned once); tui term-test 17/17, kitty-test 45/45, core-test 856/1007 (151 skipped), shell-test 1043/1046, unit-test -Dtest-filter=bytes: 23/23 (the perf check's BaselineHarnessMismatch, as on the base)
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/Term.zig')
| -rw-r--r-- | core/Term.zig | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/core/Term.zig b/core/Term.zig index 89773f77..aa05a68f 100644 --- a/core/Term.zig +++ b/core/Term.zig @@ -102,10 +102,9 @@ pub const State = struct { var arena: std.heap.ArenaAllocator = .init(gpa); defer arena.deinit(); const parts = try walk.load(iface.Parts, arena.allocator(), bytes[8..][0..n], null); + o.media(media); out.* = .{ .impl = try o.load(gpa, bytes[8 + n ..], &parts) }; writes +%= 1; - // A replica's (a join's, a closed terminal brought back in a step). - if (tape.replaying() or dump.terminal_gpa != null) o.direct(out.impl); } }; @@ -125,14 +124,27 @@ pub fn open(gpa: std.mem.Allocator, cols: u16, rows: u16) !*State { const o = ops orelse return error.NoTerminal; const s = try gpa.create(State); errdefer gpa.destroy(s); + o.media(media); s.* = .{ .impl = try o.open(gpa, cols, rows) }; writes +%= 1; - // A replica's emulator loads its program's images by direct data alone - // (P32): what is read off the session's machine is the session's. - if (tape.replaying()) o.direct(s.impl); return s; } +/// A kitty image's medium (a file, a temporary file, shared memory: the +/// session's machine's) as its emulator reads it, made the tape's answer +/// (P30: the device's answer as it was, as a file's bytes are): the session +/// reads it, a temporary file deleted and shared memory unlinked there once, +/// and every replica is handed the same bytes, or the same failure. Under +/// screen state a replica feeds no emulator: the read is the session's. +fn media(ctx: *const anyopaque, read: *const fn (*const anyopaque) iface.MediumError![]u8, gpa: std.mem.Allocator) iface.MediumError![]u8 { + if (tape.screenState()) return read(ctx); + return tape.valueIn(.medium, gpa, readMedium, .{ read, ctx }); +} + +fn readMedium(read: *const fn (*const anyopaque) iface.MediumError![]u8, ctx: *const anyopaque) iface.MediumError![]u8 { + return read(ctx); +} + /// It and what it holds, freed, all of it with its own allocator (the /// one it was opened with): the allocator a caller hands is not used. pub fn close(s: *State, _: std.mem.Allocator) void { |
