summaryrefslogtreecommitdiff
path: root/core/term
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-20 00:51:28 -0300
committerGabriel Schneider <[email protected]>2026-11-20 01:04:49 -0300
commit4bcf2055cb97d0c69fc94643b3e43b579d6fa30c (patch)
treecc845bdc25436aca800fb4791a9709ad913f3d32 /core/term
parent8e04bc6370916ac328f61ad0df6e3babeb9789b4 (diff)
downloadpardes-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')
-rw-r--r--core/term/term.zig2
-rw-r--r--core/term/terminal.zig27
2 files changed, 10 insertions, 19 deletions
diff --git a/core/term/term.zig b/core/term/term.zig
index b18f5875..59511727 100644
--- a/core/term/term.zig
+++ b/core/term/term.zig
@@ -32,7 +32,7 @@ pub const ops: iface.Ops = .{
.snapshot = cast(iface.Ops, "snapshot", terminal_.snapshot),
.load = cast(iface.Ops, "load", terminal_.load),
.reload = cast(iface.Ops, "reload", terminal_.reload),
- .direct = cast(iface.Ops, "direct", terminal_.direct),
+ .media = terminal_.media,
.feed = cast(iface.Ops, "feed", terminal_.feed),
.grid = cast(iface.Ops, "grid", terminal_.grid),
.viewTo = cast(iface.Ops, "viewTo", terminal_.viewTo),
diff --git a/core/term/terminal.zig b/core/term/terminal.zig
index 055c8981..e57193a6 100644
--- a/core/term/terminal.zig
+++ b/core/term/terminal.zig
@@ -195,11 +195,6 @@ pub const State = struct {
/// the step reads the grid it had, as its replicas' replays do, and the
/// rows sent them for it (Screens.fill) are of that grid's numbering.
resize_to: ?struct { cols: u16, rows: u16 } = null,
- /// Its program's kitty images by direct data alone (`direct`): a
- /// replica's emulator, which is not the session's. A file, a temporary
- /// file or shared memory is the session's machine's (and a temporary
- /// one is deleted by its first reader): its image is absent here.
- direct: bool = false,
/// The stream over the emulator, its answers to the program and its
/// size reports routed here, PNG decoded: what `create` and a dump's
@@ -343,11 +338,11 @@ pub fn reload(s: *State) !u64 {
var reply: [@typeInfo(@FieldType(State, "reply")).array.len]u8 = undefined;
@memcpy(reply[0..saved.reply.len], saved.reply);
saved.reply = reply[0..saved.reply.len];
- const kept = .{ s.changes, s.read, s.resize_to, s.direct };
+ const kept = .{ s.changes, s.read, s.resize_to };
if (comptime images_enabled) s.images.deinit(gpa);
s.stream.deinit();
s.vt.deinit(gpa);
- s.* = .{ .gpa = gpa, .vt = decoded.toOwned(), .stream = undefined, .changes = kept[0] +% 1, .read = kept[1], .resize_to = kept[2], .direct = kept[3] };
+ s.* = .{ .gpa = gpa, .vt = decoded.toOwned(), .stream = undefined, .changes = kept[0] +% 1, .read = kept[1], .resize_to = kept[2] };
// Short of room for its sequence in flight it goes on without it (lost
// at the next cut), as ghostty's stream does: not worth a terminal.
_ = install(s, decoded.continuation, &saved);
@@ -357,8 +352,8 @@ pub fn reload(s: *State) !u64 {
/// What a join compares of a snapshot (`reload`): every record of it but
/// its kitty images' (tags 8 to 10, which ghostty's framing makes optional:
/// snapshot/record.zig, a u16 tag, a u32 length, a u32 CRC and the payload,
-/// after a 10-byte envelope): an image by file or shared memory is the
-/// session's alone (P32, `direct`), and no digest reads an image.
+/// after a 10-byte envelope): an animation's current frame is stepped by
+/// each side's own draws, and no digest reads an image.
fn joinHash(bytes: []const u8) u64 {
const envelope = 10;
const head = 10;
@@ -379,7 +374,7 @@ fn joinHash(bytes: []const u8) u64 {
/// whether its stream had all the room it wanted (`wire`).
fn install(out: *State, continuation: ghostty_vt.snapshot.Continuation, saved: *const Term.Parts) bool {
if (comptime images_enabled) inline for (.{ .primary, .alternate }) |which| {
- if (out.vt.screens.get(which)) |screen| screen.kitty_images.image_limits = if (out.direct) .direct else .allWithTempDir(tempDir());
+ if (out.vt.screens.get(which)) |screen| screen.kitty_images.image_limits = .allWithTempDir(tempDir());
};
const whole = out.wire();
switch (continuation) {
@@ -409,14 +404,10 @@ fn install(out: *State, continuation: ghostty_vt.snapshot.Continuation, saved: *
return whole;
}
-/// Its program's kitty images by direct data alone from now on: the
-/// emulator of a replica that is not the session (P32).
-pub fn direct(s: *State) void {
- if (comptime !images_enabled) return;
- s.direct = true;
- inline for (.{ .primary, .alternate }) |which| {
- if (s.vt.screens.get(which)) |screen| screen.kitty_images.image_limits = .direct;
- }
+/// How every terminal's kitty loader has a medium's bytes from now on
+/// (ghostty's `read_medium`, build/patches.zig).
+pub fn media(read: Term.Media) void {
+ if (comptime images_enabled) ghostty_vt.kitty.graphics.LoadingImage.read_medium = read;
}
/// The allocator it was opened with, its own from then on.