diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-19 05:01:46 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-19 05:54:00 -0300 |
| commit | 5b857bb55fae0a220f54b140bc1b46c3efb991bb (patch) | |
| tree | b7dc6411697229b6e26486f6e306f1c5d599ea30 /core/config.zig | |
| parent | 0a9546f1d206f4ab55063e1c26c668e9626b3929 (diff) | |
| download | pardes-5b857bb55fae0a220f54b140bc1b46c3efb991bb.tar.gz pardes-5b857bb55fae0a220f54b140bc1b46c3efb991bb.zip | |
core: the session's facts are the core's state, read once at its start (the reorganisation's 12b, the design round's step 3; the user's ruling P16 and the lean put with P17: a far client's `~`, default shell and "is this shell installed" are the session's): its home (`~`) and the shell its terminals run when no `Shell` is set ($SHELL if executable, else /bin/sh) are fields beside `session_dir`, `session_home` and `session_shell` (working names, the user's to rule), each read once with `session_dir` by Pardes.readSessionFacts (tape.value(.env): a replay of the boot reads the session's answers), at the session's start and after a load of a dump made before they were dumped, and carried by the dump; `sessionDir` no longer fills itself at first use (it was filled at the start already), and a client's step reads the session's, never its own machine's: Pardes.expandHome (`~` the session's home; `~user` a passwd read, taped, as before) at Save, a tag's name, Theme's path, Get, Incl, a Look of `~/x`, a 9P name and pager, Dump's path, sam's B, e, r and w (sam_edit.World.home) and DumpDir's check (config.Runtime.apply takes the home); bare `Shell`, the shell a terminal runs, the settings report and its 9P twins read `session_shell`; "is this shell installed" (Shell <bin>, Term <bin>, a 9P exec) is a question to the session's disk, tape.site, so far away it waits a round trip instead of answering from the client's machine and rolling back; deleted: the value reads at config.defaultShell (now the process's read, made at the start alone) and at Core.sessionDir, and the tape's `cwd` tag (the directory is read under `env` at the start); fs.expandHome stays for this process's own home, the launcher's (runtime/main.zig) and the state file's directory and a Restore's name (the session's side: a client's Restore waits, its replay reads the tape); the tape's shape changes (`cwd` gone, `shell` a site), so the semantics word moves (the tape's shape now hashes the sites too: it did not see a site gone or added, and this change alone left it as it was), adacca2db2b39264 -> 517cd1c276996a3c: an old build and a new refuse each other's clients, in words; a test at the end of core/replica.zig (a joined client's own `Look ~/x`, bare `Shell` and Tutor, a word run in the session's directory, record no `env` read; the client's shell and directory are the session's), shown failing on the change before (`Look ~/x` read the environment); not handled: a Restore of a dump carries that dump's facts (as `session_dir` did); tui core-test 833/976 (143 skipped), shell-test 1011/1014, pane-test 183/184, behaviour-test 275/275 and --replay 275/275, process-test 2 of 144 failed (lspcomplete, lspcompletemoved, the base's; hscroll flaked once), replicas --clients 5 diverged 0 unequal 0 deltas wrong 0 quiet differ 0 at 30/80/207 ms, stopped 89/73/108, gui unit-test 1609/1613 (its perf check's BaselineHarnessMismatch the base's), daemon.py plain, --far, --games, --window-clients pass; gate-w seam-b-3 against tree1: 77/77 frames byte-identical in Debug, its unit-test 1609/1613, perfab corpus2x +0.095% (pictures identical in all 10 runs), perfops 97 counts within 0.1% (largest +0.0198%, body-appends on longline)
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/config.zig')
| -rw-r--r-- | core/config.zig | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/core/config.zig b/core/config.zig index 5f63268e..5bbe1886 100644 --- a/core/config.zig +++ b/core/config.zig @@ -330,12 +330,8 @@ pub fn wheelTick(guard: *u8, vertical: bool) bool { /// The shell when no `Shell` is set: the user's login shell ($SHELL), as a /// terminal would start, else /bin/sh. An explicit `Shell` overrides it. +/// This process's: read once, at the session's start (Pardes.session_shell). pub fn defaultShell() []const u8 { - // As the session that recorded found it (core/tape.zig). - return pardes.tape.value(.env, defaultShellHost, .{}); -} - -fn defaultShellHost() []const u8 { if (std.c.getenv("SHELL")) |s| { const shell = std.mem.span(s); // One that is not there, or not executable, is no shell: /bin/sh. @@ -837,7 +833,8 @@ pub const Runtime = struct { @compileError("Shell, Theme, Font, TaglineSize and WindowOpacity actions must each occur exactly once"); } - pub fn apply(state: *Runtime, setting: Setting, argument: ?[]const u8) bool { + /// `home`: what `~` is (the session's: Pardes.session_home). + pub fn apply(state: *Runtime, setting: Setting, argument: ?[]const u8, home: ?[]const u8) bool { switch (setting.action) { // Every toggle names a bool field of its own, so one line covers // all of them and a new toggle needs no arm here. Bare, a toggle @@ -869,7 +866,7 @@ pub const Runtime = struct { if (text.len > 0) { if (text[0] != '/' and text[0] != '~') return false; var home_buf: [4096]u8 = undefined; - if (pardes.filesystem.deniedAbove(pardes.filesystem.expandHome(text, &home_buf))) return false; + if (pardes.filesystem.deniedAbove(pardes.filesystem.expandHomeFrom(text, &home_buf, home))) return false; } if (!state.dump_dir.set(text)) return false; }, @@ -1073,28 +1070,28 @@ pub const Runtime = struct { const verbose = find("Verbose").?; try std.testing.expect(state.verbose); // Bare, it flips: that is what a tagline word does. - try std.testing.expect(apply(&state, verbose, null)); + try std.testing.expect(apply(&state, verbose, null, null)); try std.testing.expect(!state.verbose); // Told, it SETS -- twice over, so the second call proves it is not // flipping past the value it was given. - try std.testing.expect(apply(&state, verbose, "on")); + try std.testing.expect(apply(&state, verbose, "on", null)); try std.testing.expect(state.verbose); - try std.testing.expect(apply(&state, verbose, " on\n")); + try std.testing.expect(apply(&state, verbose, " on\n", null)); try std.testing.expect(state.verbose); - try std.testing.expect(apply(&state, verbose, "off")); + try std.testing.expect(apply(&state, verbose, "off", null)); try std.testing.expect(!state.verbose); - try std.testing.expect(apply(&state, verbose, "off")); + try std.testing.expect(apply(&state, verbose, "off", null)); try std.testing.expect(!state.verbose); // And anything else is refused rather than silently flipping. - try std.testing.expect(!apply(&state, verbose, "maybe")); + try std.testing.expect(!apply(&state, verbose, "maybe", null)); try std.testing.expect(!state.verbose); } test "simple setting application mutates only its plain field" { var state: Runtime = .{}; - try std.testing.expect(apply(&state, find("Wrap").?, null)); + try std.testing.expect(apply(&state, find("Wrap").?, null, null)); try std.testing.expect(!state.wrap); - try std.testing.expect(apply(&state, find("Shell").?, " fish\n")); + try std.testing.expect(apply(&state, find("Shell").?, " fish\n", null)); try std.testing.expectEqualStrings("fish", state.shell.requested.get()); try std.testing.expect(state.shell.pending); } @@ -1104,13 +1101,13 @@ pub const Runtime = struct { var state: Runtime = .{}; for ([_][]const u8{ "1", " 82\n", "100" }) |argument| { - try std.testing.expect(apply(&state, setting, argument)); + try std.testing.expect(apply(&state, setting, argument, null)); try std.testing.expectEqual(try std.fmt.parseInt(u8, std.mem.trim(u8, argument, " \t\r\n"), 10), state.font.tagline_percent); } state.font.tagline_percent = 67; for ([_]?[]const u8{ null, "", "0", "101", "-1", "50%", "999999999999999999999" }) |argument| { - try std.testing.expect(!apply(&state, setting, argument)); + try std.testing.expect(!apply(&state, setting, argument, null)); try std.testing.expectEqual(@as(u8, 67), state.font.tagline_percent); } } @@ -1124,7 +1121,7 @@ pub const Runtime = struct { for ([_][]const u8{ "0", " 85\n", "100" }, [_]u8{ 0, 85, 100 }) |argument, expected| { state.window_opacity_pending = false; - try std.testing.expect(apply(&state, setting, argument)); + try std.testing.expect(apply(&state, setting, argument, null)); try std.testing.expectEqual(expected, state.window_opacity); try std.testing.expect(state.window_opacity_pending); } @@ -1132,12 +1129,12 @@ pub const Runtime = struct { state.window_opacity = 85; state.window_opacity_pending = false; for ([_]?[]const u8{ null, "", " \t\n", "101", "-1", "+85", "85%", "0.5", "85.0", "85 20", "8_5", "0x55", "999999999999999999999" }) |argument| { - try std.testing.expect(!apply(&state, setting, argument)); + try std.testing.expect(!apply(&state, setting, argument, null)); try std.testing.expectEqual(@as(u8, 85), state.window_opacity); try std.testing.expect(!state.window_opacity_pending); } // Reissuing the same request still asks the host to apply it again. - try std.testing.expect(apply(&state, setting, "85")); + try std.testing.expect(apply(&state, setting, "85", null)); try std.testing.expect(state.window_opacity_pending); } @@ -1193,7 +1190,7 @@ pub const Runtime = struct { .{ "GripWidth", "200" }, .{ "InactiveDim", "35" }, .{ "CallstackDepth", "16" }, .{ "Tab", "8" }, }; - for (values) |v| try std.testing.expect(apply(&state, find(v[0]).?, v[1])); + for (values) |v| try std.testing.expect(apply(&state, find(v[0]).?, v[1], null)); try std.testing.expect(state.font.requested_name.set("Wanted Mono")); try std.testing.expect(state.font.requested_path.set("/fonts/wanted.ttf")); state.font.requested_size_hundredths = 1850; @@ -1842,11 +1839,11 @@ test "CallstackDepth is bounded and keeps the last valid runtime limit" { var state: Runtime = .{}; try std.testing.expectEqual(@as(u8, 8), state.callstack_depth); for ([_][]const u8{ "1", "8", "16", "64" }) |value| { - try std.testing.expect(Runtime.apply(&state, Runtime.find("CallstackDepth").?, value)); + try std.testing.expect(Runtime.apply(&state, Runtime.find("CallstackDepth").?, value, null)); try std.testing.expectEqual(try std.fmt.parseInt(u8, value, 10), state.callstack_depth); } for ([_][]const u8{ "0", "65", "256", "-1", "+8", "1_6", "eight", "" }) |value| { - try std.testing.expect(!Runtime.apply(&state, Runtime.find("CallstackDepth").?, value)); + try std.testing.expect(!Runtime.apply(&state, Runtime.find("CallstackDepth").?, value, null)); try std.testing.expectEqual(@as(u8, 64), state.callstack_depth); } } |
