From 5dc2c61f1df30d2dd84fbba6d0e8895a62c3b2b5 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 16 Nov 2026 23:46:16 -0300 Subject: Export a session to a file of its own, and import one export-session [S] FILE writes session S (this run's by default, committed first), with the marks and clips that point into it, as session 0 of a new database: written beside FILE, synced, renamed over it. import FILE appends each session of such a file to this database, from "import ", its marks and clips renamed NAME@ (cut to 32 bytes). The copy is value by value, the same few lines for both, over whatever a session holds; sessions lists where one came from. test-import records test/past.script's session, exports it, imports it into another database and replays it there: the mark it carries is the State half a second in exactly, and two seconds in is frame 120's. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- build.zig | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'build.zig') diff --git a/build.zig b/build.zig index 809ddb1..d8da703 100644 --- a/build.zig +++ b/build.zig @@ -386,6 +386,29 @@ pub fn build(b: *Build) void { test_step.dependOn(&past.step); b.step("test-past", "Replay past sessions, to a time and across a code change").dependOn(&past.step); + // A session exported from one database and imported into another plays + // there to the same State: at the mark it carries, and two seconds in. + const moved = b.addSystemCommand(&.{ "sh", "-c", + \\set -e + \\mkdir -p "$4"; d=$(realpath "$4"); rm -f "$d"/* + \\"$0" --headless --script "$1" --state "$d/a.state" "$5" + \\"$0" --headless --script "$2" --state "$d/a.state" --define file="$d/one.xitdb" "$5" + \\"$0" --headless --script "$3" --state "$d/z.state" --define file="$d/one.xitdb" "$5" + \\test "$(stat -c %s "$d/one.xitdb")" -lt 1048576 + \\rm -f "$d"/* + }); + moved.setName("export and import a session"); + moved.addArtifactArg(host_exe); + moved.addFileArg(b.path("test/past.script")); + moved.addFileArg(b.path("test/session_export.script")); + moved.addFileArg(b.path("test/session_import.script")); + _ = moved.addOutputDirectoryArg("import"); + moved.addArtifactArg(recorded); + moved.has_side_effects = true; + moved.expectExitCode(0); + test_step.dependOn(&moved.step); + b.step("test-import", "Export a session from one database, import it into another, replay it").dependOn(&moved.step); + // Where files go. Without --state: the XDG data directory, state and // sessions. In .sketchbook/ (`zig build run`'s): a .gitignore, and an // older build's state moved in, once, never over a file there. -- cgit v1.3