summaryrefslogtreecommitdiff
path: root/docs/typ
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-20 03:20:39 -0300
committerGabriel Schneider <[email protected]>2026-11-20 04:00:32 -0300
commita6c258bec5808ac2b6ef9d3362134e34e759c1c9 (patch)
treef785b15b2a3bcd0f7d3e8f92d7948af634c52b69 /docs/typ
parent1967cf64dc6d7490d386db874cf1866b764f235c (diff)
downloadpardes-a6c258bec5808ac2b6ef9d3362134e34e759c1c9.tar.gz
pardes-a6c258bec5808ac2b6ef9d3362134e34e759c1c9.zip
docs: an attach is always a client, and a session registers again with a restarted daemon, in the documents: the manual's "How pardes runs" (docs/typ/running.typ: one Attach section, its figure of the in-place attach deleted from figures.typ, the glance and survival tables, the words), the guide's Sessions, the reference's /sessions and command line, the building chapter's daemon, the cheatsheet's line, `pardes help attach` (runtime/main.zig, docs/typ/command-line.txt from builtins-json), the Detach word's doc (core/builtins.zig, both builtins JSONs), docs/next-run.md as built (what went, counted on the change: 305 lines deleted, 94 added; the re-registration as built; --detach forking still not) with its figure (Before / Now), and the changelog's Unreleased; the book and the cheatsheet render (typst), tui shell-test 1046/1049 (3 skipped), core-test 855/1005 (150 skipped: the base's 856/1006 less the deleted `find` test)
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'docs/typ')
-rw-r--r--docs/typ/building.typ17
-rw-r--r--docs/typ/builtins-gui.json2
-rw-r--r--docs/typ/builtins-tui.json2
-rw-r--r--docs/typ/cheatsheet.typ2
-rw-r--r--docs/typ/command-line.txt21
-rw-r--r--docs/typ/figures.typ46
-rw-r--r--docs/typ/guide.typ27
-rw-r--r--docs/typ/reference.typ18
-rw-r--r--docs/typ/running.typ148
9 files changed, 123 insertions, 160 deletions
diff --git a/docs/typ/building.typ b/docs/typ/building.typ
index 9350b484..8bfcb85b 100644
--- a/docs/typ/building.typ
+++ b/docs/typ/building.typ
@@ -501,10 +501,13 @@ life; the first session that finds none starts it (a double fork and an
exec) and it exits a second after it holds nothing. It is nobody's parent:
a session registers on one connection, sends it a dup of every pty master
it forks (so a session killed outright never hangs its shells up, and
-#word("Adopt") takes them into another), says whether a terminal or a
-window shows it, and is handed a terminal (`pardes --attach`) or a window
-request (`pardes-gui --attach`) through it. Messages are `SOCK_SEQPACKET`
-datagrams: a line of words and the fds it carries.
+#word("Adopt") takes them into another), says whether it has let its own
+terminal or window go, and is handed each client's connection through it
+(`pardes attach`, below). A daemon that dies is started again by the
+sessions: each one's link's reader, woken by the link's end, dials the
+next, says the hello again and tells it its masters and its clients.
+Messages are `SOCK_SEQPACKET` datagrams: a line of words and the fds it
+carries.
`pardes` in a terminal forks its session off before anything starts: the
session, in a session of its own (`setsid`), draws on the terminal it
@@ -512,9 +515,9 @@ opened, and the process the shell waits on stays as its stub, passing it
`SIGWINCH`, `SIGTERM`, `SIGINT` and `SIGQUIT` and ending with its status.
#word("Detach"), or the terminal's end (EIO, a hangup), puts
the terminal back and lets it go; the stub ends (exit 0) and the session
-runs on with nothing drawn, until `pardes --attach` hands it another
-terminal. A window's #word("Detach") closes the window and keeps the
-process; `pardes-gui --attach` opens one again. `PARDES_DAEMON=off` (the
+runs on with nothing drawn, detached for good: `pardes attach` is a client
+of it. A window's #word("Detach") closes the window and keeps the
+process, the same. `PARDES_DAEMON=off` (the
process tests) runs a session as before the daemon: in the terminal's
own process, ended by its hangup.
diff --git a/docs/typ/builtins-gui.json b/docs/typ/builtins-gui.json
index 732e66a7..34a46fa6 100644
--- a/docs/typ/builtins-gui.json
+++ b/docs/typ/builtins-gui.json
@@ -24,7 +24,7 @@
{"name": "DelAbove", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Close the pane, giving its rows to the pane above it."},
{"name": "DelBelow", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Close the pane, giving its rows to the pane below it."},
{"name": "Delcol", "leader": "SPC c d", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Close this column and its panes, refusing once over unsaved text."},
- {"name": "Detach", "leader": "SPC s D", "also": [], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Detach this pardes from its terminal or window, leaving the session running: `pardes --attach` (or `pardes-gui --attach`) takes it back."},
+ {"name": "Detach", "leader": "SPC s D", "also": [], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Detach this pardes from its terminal or window, leaving the session running: `pardes attach` (or `pardes-gui attach`) shows it as a client."},
{"name": "Diagnostics", "leader": "SPC l d", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "List the file's diagnostics from the language server."},
{"name": "Diff", "leader": null, "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Stack a diff's hunks as a diff viewer shows them, each under its place and the declarations around it, in a +Diff; on a +Diff, show the diff itself as text."},
{"name": "Down", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Move the keyboard to the pane below, off a tag onto the pane under it."},
diff --git a/docs/typ/builtins-tui.json b/docs/typ/builtins-tui.json
index 0a074c44..5919a77a 100644
--- a/docs/typ/builtins-tui.json
+++ b/docs/typ/builtins-tui.json
@@ -23,7 +23,7 @@
{"name": "DelAbove", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Close the pane, giving its rows to the pane above it."},
{"name": "DelBelow", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Close the pane, giving its rows to the pane below it."},
{"name": "Delcol", "leader": "SPC c d", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Close this column and its panes, refusing once over unsaved text."},
- {"name": "Detach", "leader": "SPC s D", "also": [], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Detach this pardes from its terminal or window, leaving the session running: `pardes --attach` (or `pardes-gui --attach`) takes it back."},
+ {"name": "Detach", "leader": "SPC s D", "also": [], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Detach this pardes from its terminal or window, leaving the session running: `pardes attach` (or `pardes-gui attach`) shows it as a client."},
{"name": "Diagnostics", "leader": "SPC l d", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "List the file's diagnostics from the language server."},
{"name": "Diff", "leader": null, "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Stack a diff's hunks as a diff viewer shows them, each under its place and the declarations around it, in a +Diff; on a +Diff, show the diff itself as text."},
{"name": "Down", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Move the keyboard to the pane below, off a tag onto the pane under it."},
diff --git a/docs/typ/cheatsheet.typ b/docs/typ/cheatsheet.typ
index e931effa..2df92b00 100644
--- a/docs/typ/cheatsheet.typ
+++ b/docs/typ/cheatsheet.typ
@@ -122,7 +122,7 @@ Helix-style: motions *select*, then an edit acts on the selection. Mode box: bla
- A query pane under the pane: line 1 the query, its first word the source: `/pat`, `Find name` (fuzzy), `Grep text` (literal), `Recent`, `Panes`, `Symbols`, `All`. #keys("Ctrl-n", "Ctrl-p") step, #key("Enter") lands and keeps the rows, #key("Esc") puts things back. #word("Help"), #word("Tutor").
== Sessions
-`pardes --detach=work`; `--attach=work` (`pardes-gui --attach=work`) takes it back; #word("Detach") leaves it running; #word("Adopt") takes in a killed session's shells. #doc("detached")
+`pardes --detach=work`; `pardes attach work` shows it here, as a client (`pardes-gui attach work`: in a window); #word("Detach") leaves it running; #word("Adopt") takes in a killed session's shells. #doc("detached")
== Config
#word("Config") (#key("SPC f c")): `~/.config/pardes/init`, a builtin a line (#word("Theme") `atelier`). #word("DumpConfig"): every setting. #word("Dump") / #word("Restore"): the workspace. #doc("config")
diff --git a/docs/typ/command-line.txt b/docs/typ/command-line.txt
index 0b06275e..3c73fed4 100644
--- a/docs/typ/command-line.txt
+++ b/docs/typ/command-line.txt
@@ -12,7 +12,7 @@ Open:
Sessions:
ps the daemon's sessions, their clients and shells
- attach [NAME] show a detached session here (HOST:NAME: over ssh)
+ attach [NAME] show a session here, as a client (HOST:NAME: over ssh)
kill NAME end a session and its shells (--all: every one)
new [flags] [FILE] start one: --detach=NAME --9p=NAME -n 3 (help new)
@@ -54,15 +54,16 @@ See also: attach, kill, /sessions
== pardes help attach
-Show a detached session here: in this terminal for pardes, a window
-for pardes-gui. Bare, the one detached session (with none, the one
-session). One with a frontend already, or of the other kind, is joined
-as a client. HOST:NAME is a client of session NAME on another machine,
-over `ssh -L` to its pardes-replica.sock ($PARDES_SSH: the ssh
-command, default ssh; $PARDES_REMOTE_RUNTIME: its runtime directory,
-if not this one's path); SOCK:NAME goes through a socket forwarded
-already (a path, with a '/'). Returns when the session detaches or
-ends.
+Show a session here as a client: a process of its own, with a copy of
+the session's core and a view of its own, in this terminal for pardes,
+a window for pardes-gui, whatever the session was started in. Bare,
+the one detached session (with none, the one session). HOST:NAME is a
+client of session NAME on another machine, over `ssh -L` to its
+pardes-replica.sock ($PARDES_SSH: the ssh command, default ssh;
+$PARDES_REMOTE_RUNTIME: its runtime directory, if not this one's
+path); SOCK:NAME goes through a socket forwarded already (a path, with
+a '/'). Returns when it is let go: its Detach or its terminal or window
+closing (the session runs on), or the session's end.
Usage:
pardes attach [NAME]
diff --git a/docs/typ/figures.typ b/docs/typ/figures.typ
index 4ca51c1a..15364e47 100644
--- a/docs/typ/figures.typ
+++ b/docs/typ/figures.typ
@@ -201,37 +201,9 @@
wire((14.1, 3.0), (14.1, 1.67), ends: none, dash: "dotted", label: [keeps each \ one open], at: (15.15, 2.33), width: 1.6)
})
-/// `pardes attach work` to a session with no frontend: a terminal's and a
-/// window's.
-#let run-attach-detached() = drawn(alt: "pardes attach to a detached session: the terminal handed to the session through the daemon; for a window, the session opens its own again", {
- import cetz.draw: *
- // A terminal's session.
- content((0, 8.75), anchor: "west", text(size: 8pt, weight: "bold")[a terminal's session: `pardes attach work`])
- screen(0, 6.4, 3.4, 1.7, [this terminal])
- proc(0, 3.9, 3.4, 2.0, "stub", "pardes attach work",
- ("plain", [now the job your shell waits on]), ("plain", [holds nothing]))
- daemon-box(5.5, 3.9)
- proc(11.0, 3.9, 5.0, 4.2, "session", "pardes --detach=work",
- core-truth, ptys, ninep("work"),
- ("plain", [draws on this terminal now]),
- ("plain", [the same process as before]))
- wire((3.4, 4.8), (5.5, 4.8), label: [① this terminal \ and a pipe], at: (4.45, 5.32), width: 1.8)
- wire((8.9, 4.8), (11.0, 4.8), dash: "dashed", label: [② handed on], at: (9.95, 5.15))
- wire((3.4, 7.25), (11.0, 7.25), ends: "both", label: [③ keys in, frames out], at: (7.2, 7.6))
- line((-0.1, 3.3), (16.1, 3.3), stroke: (paint: palette.rule, thickness: 0.6pt))
- // A window's session.
- content((0, 2.85), anchor: "west", text(size: 8pt, weight: "bold")[a window's session: `pardes-gui attach work`])
- proc(0, 0, 3.4, 2.0, "other", "pardes-gui attach work", ("plain", [asks, then exits: no stub]), dash: "dashed")
- daemon-box(5.5, 0)
- proc(11.0, 0, 5.0, 2.3, "session", "pardes-gui --detach=work",
- core-truth, ("plain", [opens its own window again]))
- wire((3.4, 0.9), (5.5, 0.9), label: [① asks], at: (4.45, 1.25))
- wire((8.9, 0.9), (11.0, 0.9), dash: "dashed", label: [② "attach"], at: (9.95, 1.25))
-})
-
-/// `pardes attach work` to a session that has a frontend (or is of the
-/// other kind): a client.
-#let run-attach-client() = drawn(alt: "pardes attach to a session with a frontend: a client process with its own replica core, joined through the daemon", {
+/// `pardes attach work`: a client, whether or not the session still has
+/// the frontend it was born with (here it has).
+#let run-attach-client() = drawn(alt: "pardes attach: a client process with its own replica core, joined through the daemon", {
import cetz.draw: *
screen(0, 3.4, 3.0, 1.7, [its own terminal])
proc(0, 0, 4.8, 2.9, "session", "pardes",
@@ -283,12 +255,12 @@
wire((10.6, 0.7), (12.2, 0.7), ends: "both", label: [a pty's bytes], at: (11.4, 1.05))
})
-// ---- docs/next-run.md: the ruled direction, not built ----
+// ---- docs/next-run.md: the ruling, built ----
-/// What `pardes attach` does today (four things) beside what it does once
-/// "an attach is always a client" is built (one). Drawn by
+/// What `pardes attach` did before 2026-11-20 (four things) beside what it
+/// does since "an attach is always a client" was built (one). Drawn by
/// docs/next-run.typ for the design note; no chapter shows it.
-#let run-attach-before-after() = drawn(alt: "pardes attach today: four mechanisms; after: always a client", {
+#let run-attach-before-after() = drawn(alt: "pardes attach before: four mechanisms; now: always a client", {
import cetz.draw: *
let row(x, y, when, typed, kind, said) = {
content((x, y + 1.2), anchor: "west", text(size: small, style: "italic", fill: palette.tag-fg, when))
@@ -299,13 +271,13 @@
rect((x + 3.9, y), (x + 7.5, y + 0.95), fill: tint(c), stroke: 1.3pt + c, radius: 3pt)
content((x + 5.7, y + 0.475), box(width: 3.4cm, align(center, text(size: small, said))))
}
- content((0, 8.15), anchor: "west", text(size: 9pt, weight: "bold")[Today: four mechanisms])
+ content((0, 8.15), anchor: "west", text(size: 9pt, weight: "bold")[Before: four mechanisms])
row(0, 6.0, [a terminal's session, detached], [pardes attach work], "session", [the session draws here; this process becomes its stub])
row(0, 4.3, [a window's session, detached], [pardes-gui attach work], "session", [the session opens its own window; this process exits])
row(0, 2.6, [it has a frontend, or is the other kind], [pardes attach work], "client", [a client: this process, with a replica])
row(0, 0.9, [on another machine], [pardes attach box:work], "client", [a client, through `ssh -L`])
line((7.95, -0.1), (7.95, 8.4), stroke: (paint: palette.rule, thickness: 0.8pt))
- content((8.45, 8.15), anchor: "west", text(size: 9pt, weight: "bold")[After: always a client])
+ content((8.45, 8.15), anchor: "west", text(size: 9pt, weight: "bold")[Now: always a client])
row(8.45, 6.0, [any session on this machine], [pardes attach work], "client", [a client: this process, with a replica])
row(8.45, 4.3, [on another machine], [pardes attach box:work], "client", [a client, through `ssh -L`])
content((8.45, 2.85), anchor: "west", box(width: 7.5cm, text(size: small)[A session's own frontend is only the one it was born with: a Detach, or its terminal or window closing, leaves it detached for good, and each attach after is a client.]))
diff --git a/docs/typ/guide.typ b/docs/typ/guide.typ
index e69c756a..3dd8107c 100644
--- a/docs/typ/guide.typ
+++ b/docs/typ/guide.typ
@@ -352,28 +352,29 @@ cheatsheet (#doc("cheatsheet")) say so.
```
pardes --detach=work & a session with no screen of its own
-pardes --attach=work show it here
-pardes-gui --attach=work a window session's window again
-pardes --ps every session the daemon lists, and its shells
-pardes --kill=work end it and its shells (--kill-all: every one)
+pardes attach work show it here, as a client
+pardes-gui attach work show it in a window, as a client
+pardes ps every session the daemon lists, and its shells
+pardes kill work end it and its shells (kill --all: every one)
```
#word("Detach") (#key("SPC s D")) lets the terminal or the window go and
leaves the session running, its panes, shells and files kept; so does a
terminal that closes, while the daemon (below) is there. A window that
-closes ends its session, unless the session has clients.
-`pardes --attach` takes it back in any terminal,
-`pardes-gui --attach` a window session's window: a terminal session takes
-a terminal, a window session a window. Attached already, it takes another
-view: each terminal or window has its own columns, focus, cursors and
-scroll over the same panes, texts and registers, and a terminal shown in
-two takes the size of the one that last typed into it. #word("Detach") in
-one lets only that one go. A session is named by `--9p=` or
+closes ends its session, unless the session has clients. Once let go, a
+session's own terminal or window never comes back: `pardes attach` shows
+it in any terminal, `pardes-gui attach` in a window, either kind of
+session, each as a client, a process of its own. Each terminal or window
+has its own view (columns, focus, cursors, scroll) over the same panes,
+texts and registers, and a terminal shown in two takes the size of the
+one that last typed into it. #word("Detach") in one lets only that one
+go. A session is named by `--9p=` or
`--detach=`, else its pid. A session killed outright leaves its shells
running; #word("Adopt") in another takes them in as terminal panes, what
they showed gone. One `pardes --daemon` per user lists the sessions and
holds their shells' terminals open; the first session starts it, it is
-nobody's parent, and it leaves once it holds nothing. Which processes
+nobody's parent, and it leaves once it holds nothing; killed, the
+sessions start it again. Which processes
run, and what survives what, is in #doc("running").
After a rebuild, #word("Upgrade")
(#key("SPC s U")) moves a running session onto the pardes now installed
diff --git a/docs/typ/reference.typ b/docs/typ/reference.typ
index 4c193e0f..425209a0 100644
--- a/docs/typ/reference.typ
+++ b/docs/typ/reference.typ
@@ -1014,7 +1014,7 @@ at 200, ending in `…`. Control characters become spaces.
of its own, a terminal or window; `pardes ps` says "has a frontend") with a `client <pid>` line for each of its clients and a
`shell <pid>` line for each shell it holds, then `orphan <pid>` for each
shell no session holds. Any of the
- names attaches (`pardes --attach=<name>`, either kind). Read fails `no
+ names attaches (`pardes attach <name>`, either kind, as a client). Read fails `no
pardes daemon answers` with none, or one too old to list (Upgrade it).
- #file("/os/"): existing regular files take read, write and truncation to
zero; create, remove, rename and mode changes are refused as not
@@ -1350,15 +1350,13 @@ to its end before the write is answered, and one that finds nothing fails,
which #word("Adopt") takes. `--kill=NAME` ends that session and its
shells (a TERM, then a KILL 2 s later; unsaved changes are lost),
`--kill-all` every session and every kept shell; with no daemon running
- each says so and exits 1. Bare `--detach` names the session after its pid; bare
- `--attach` needs exactly one detached session of its kind (a terminal's
- for `pardes`, a window's for `pardes-gui`), or with none detached the
- only session of that kind, joined as a client (with none of that kind,
- the only session there is); a second `--detach=NAME`
- while NAME runs (a plain session is named by its pid) says so in words
- and exits 1. A session with a frontend already is joined as a client, as one of
- the other kind is, and one on another machine (`--attach=HOST:NAME`, over
- `ssh -L`; `--attach=SOCKET:NAME` through a socket forwarded already): its
+ each says so and exits 1. Bare `--detach` names the session after its pid; a
+ second `--detach=NAME` while NAME runs (a plain session is named by its
+ pid) says so in words and exits 1. `attach NAME` (`--attach=NAME`) is
+ always a client of session NAME, either kind, here or on another machine
+ (`attach HOST:NAME`, over `ssh -L`; `attach SOCKET:NAME` through a socket
+ forwarded already); bare, of the one detached session, else the only
+ session (with several, it names them and exits 1): its
own process, listed under the session by `--ps`, up to three clients
(four views at once, the session's own among them): each
terminal or window its own layout, focus, cursors, selections, modes,
diff --git a/docs/typ/running.typ b/docs/typ/running.typ
index 1500845e..74eb8cbd 100644
--- a/docs/typ/running.typ
+++ b/docs/typ/running.typ
@@ -4,31 +4,32 @@
// attach); the direction not built yet is docs/next-run.md. The file:line
// that says each fact is in a comment beside it.
#import "style.typ": word, doc, pairs, file
-#import "figures.typ": run-legend, run-terminal, run-window, run-detach, run-attach-detached, run-attach-client, run-far, run-no-daemon
+#import "figures.typ": run-legend, run-terminal, run-window, run-detach, run-attach-client, run-far, run-no-daemon
A running pardes is up to four kinds of process. Which of them there are,
and what each holds, depends only on how it was started.
-// runtime/daemon.zig:8-16 (nobody's parent; dups; hands terminals,
-// windows, replicas); core/replica.zig:1-19, :747-794 (a client's core
+// runtime/daemon.zig:8-17 (nobody's parent; dups; lists the sessions,
+// hands a client's connection on); core/replica.zig:1-19, :747-794 (a client's core
// from the dump); dev/host_io.zig:548-551 (the shells are the session's
-// children); runtime/9p_io.zig:57 (the socket); runtime/daemon.zig:546-698
-// (the stub).
+// children); runtime/9p_io.zig:57 (the socket); runtime/daemon.zig forkSession,
+// stubWait (the stub).
#pairs(
[*session*], [the process with the truth: the one core every other copy follows, the shells' pty masters (the shells are its children) and the 9P socket. There is one a session, always.],
[*client*], [any further terminal or window on a session: a process of its own, with a copy of the session's core (a replica) loaded from the session's dump and kept in step with the session's tape. It has its own view (columns, focus, cursors, scroll) and draws it. It holds no shells and no 9P socket. A client on another machine is *far*.],
- [*daemon*], [`pardes --daemon`, one per user per machine: a switchboard. It spawns nothing and is nobody's parent. It keeps the list of sessions and a dup of every pty master, so that a session killed outright never hangs its shells up; clients dial its replica socket; it hands a terminal, a window's request or a client's connection to the session that takes it. The first session that finds none starts it, and it exits a second after it holds nothing.],
+ [*daemon*], [`pardes --daemon`, one per user per machine: a switchboard. It spawns nothing and is nobody's parent. It keeps the list of sessions and a dup of every pty master, so that a session killed outright never hangs its shells up; clients dial its replica socket, and it hands each client's connection to the session it names. The first session that finds none starts it, and it exits a second after it holds nothing. Killed, it is started again by its sessions, which register with the next one.],
[*stub*], [the process your shell waits on when the session is not it. It holds nothing: it passes signals on, and ends when the session leaves its terminal.],
)
-// dev/tui/tui.zig:590 (a session's terminal: one or none);
-// dev/gui/gui.zig:2433-2436 (the window, or none while detached);
-// runtime/daemon.zig:901-905 ("a session shows one frontend of its own").
+// dev/tui/tui.zig Screen (a session's terminal: the one it was born
+// with, or none); dev/gui/gui.zig Shell.gui (the window, or none once
+// detached); runtime/main.zig attachTo (an attach is a client).
A *frontend* is what draws: the terminal (`pardes`), the window
(`pardes-gui`), or the Mac's own build. A session draws at most one
-frontend of its own: the one it was started with, or one attached to it
-later. A session with none is *detached*; it may still have clients.
-To *attach* is to show a session here.
+frontend of its own: the one it was started with. Once it lets that one go
+(a #word("Detach"), its terminal closing) it is *detached*, for good; it
+may still have clients. To *attach* is to show a session here, and an
+attach is always a client.
In the figures a box with a heavy edge is a process: its kind, then the
command `ps` shows for it, then what it holds. The core with the truth is
@@ -41,11 +42,11 @@ travels on it.
#run-terminal()
-// runtime/main.zig:1570-1595, runtime/daemon.zig:663-698 (the fork,
-// setsid, the stub); runtime/daemon.zig:550-559, :567-616 (what the stub
-// forwards and how it ends); dev/tui/tui.zig:1685-1709 (the terminal's
-// end: detached while kept, else the end); runtime/daemon.zig:305-314
-// (kept: the daemon answered and is still there).
+// runtime/main.zig, the fork (daemon.forkSession: setsid, the stub);
+// runtime/daemon.zig forward, stubWait (what the stub forwards and how it
+// ends); dev/tui/tui.zig, the `.quit` arm (the terminal's end: detached
+// while kept, else the end); runtime/daemon.zig kept (the daemon
+// answered and is still there).
`pardes` forks the session off and stays as its stub. The session runs in a
POSIX session of its own, so it can outlive the job your shell waits on. It
reads the keys from the terminal and draws on it itself; the stub only
@@ -54,7 +55,7 @@ session too) and exits when the session leaves the terminal, with the
session's status, or 0 after a #word("Detach").
Closing the terminal detaches the session while a daemon keeps it. With no
-daemon, or after the daemon has died, it ends the session and its shells.
+daemon it ends the session and its shells.
= `pardes-gui` <run-window>
@@ -80,9 +81,9 @@ terminal hangs up.
// process).
The process you started is the session: nothing is forked, so the `&` that
puts it in the background is yours to type (`pardes new --detach=work` is
-the same). It draws nothing and is 160×50 until an attach or the root
-#file("ctl")'s `size` sizes it. Until something attaches, 9P is the only
-way in (#doc("scripting")).
+the same). It draws nothing and is 160×50 until the root #file("ctl")'s
+`size` sizes it; a client shows its own view, at its own size. Until a
+client attaches, 9P is the only way in (#doc("scripting")).
// runtime/main.zig, the --detach branch (the exec of the pardes beside it).
`pardes-gui --detach` runs the `pardes` installed beside it in its place:
@@ -95,55 +96,42 @@ a daemon keeps it; a window's binary's ends on it, as any job does. With no daem
`--detach` still starts a session, which nothing can attach to: only 9P
reaches it.
-= Attach, to a detached session <run-attach-detached>
-
-#run-attach-detached()
-
-// runtime/main.zig:1812-1842 (attachTo); runtime/daemon.zig:883-897
-// (handed on); dev/tui/tui.zig:1354-1382 (the terminal entered as the
-// first was); dev/gui/gui.zig:3384-3402, :2588-2601 (the window opened
-// again).
-For a terminal's session, `pardes attach work` hands its terminal and a
-pipe to the session through the daemon, and stays as the stub. For a
-window's, `pardes-gui attach work` asks, then exits, and the session opens
-its own window again. Either way the frontend is the session's own again,
-in the process that has been the session all along: what happens when
-it closes is what the first two sections say.
-
-// runtime/daemon.zig:901-972 (find: the bare attach, and `other`).
-The kind has to match. A terminal's session attached from `pardes-gui`,
-or a window's from `pardes`, is joined as a client (the next section).
-Bare, `pardes attach` takes the one detached session of its kind; with
-none, the one session of its kind, as a client; with no session of its
-kind, the only session there is, as a client. `--attach=work` is the older
-spelling of `attach work`.
-
-= Attach, to a session that has a frontend <run-attach-client>
+= Attach <run-attach-client>
#run-attach-client()
-// runtime/main.zig:1844-1850 (crossAttach); runtime/daemon.zig:974-1008
-// (the hello, the same build, handed on); core/replica.zig:1-19
-// (speculation and rollback); core/replica.zig:2204-2214, core/views.zig:31,
+// runtime/main.zig attachTo, bareAttach (a client, through the replica
+// socket; bare: the one detached session, else the one session);
+// runtime/daemon.zig hear (the hello, the same build, handed on);
+// core/replica.zig:1-19 (speculation and rollback); core/views.zig:31,
// core/Core.zig:1163-1203 (four views, the session's own among them);
-// core/replica.zig:2303-2325 (a client leaving); core/replica.zig initDump,
-// core/Addon.zig plainOps (a plain kind's code runs in the client that has
-// it; another's in the session alone); dev/gui/gui.zig:2200-2214 (a
-// client's notch: whole rows sent), :3673 (glideFrame: the picture on the
-// client's clock); dev/gui/gui.zig:595-623 (a client's font: the session's
-// request, by the face's name on this machine). Measured 2026-11-17
+// core/replica.zig closeViewOf (a client leaving); core/replica.zig
+// initDump, core/Addon.zig plainOps (a plain kind's code runs in the
+// client that has it; another's in the session alone);
+// dev/gui/gui.zig:2200-2214 (a client's notch: whole rows sent),
+// glideFrame (the picture on the client's clock); dev/gui/gui.zig
+// syncReplicaFont (a client's font: the session's request, by the face's
+// name on this machine). Measured 2026-11-17
// (.scratch/sketch/reports/pardes-measure.md sections A, C and E): a
// client's notch glides as the session's window does (5 frames, 0 to
// -22 px); a terminal's client 10-16 MB PSS idle, a window's about 110 MB
// (187 MB RSS), as a window session's, three quarters of it the GPU and
// display libraries.
-A session draws one frontend of its own, so the second attach is a client.
-The daemon checks the client's hello (the session's name, and the client's
-build: a client must be the build its session is) and hands its
-connection to the session; from then on the two talk directly. The client
-loads the session's dump into its own core, applies its own keys at once,
-and takes the session's tape (each step as the session took it) as the
-truth, rolling back when the session ordered things differently.
+`pardes attach work` is a client of session work, whatever the session was
+started in and whether or not it still has its own frontend: in a terminal
+for `pardes`, a window for `pardes-gui`. A session never takes a frontend
+of its own back: the one it was born with is the only one it ever has.
+Bare, `pardes attach` takes the one detached session; with none detached,
+the only session there is; with several, it names them and asks which.
+`--attach=work` is the older spelling of `attach work`.
+
+The client says its hello on the daemon's replica socket: the session's
+name, and the client's build (a client must be the build its session is).
+The daemon refuses a name no session has, and hands the connection to the
+session; from then on the two talk directly. The client loads the
+session's dump into its own core, applies its own keys at once, and takes
+the session's tape (each step as the session took it) as the truth,
+rolling back when the session ordered things differently.
// core/replica.zig:5316-5395 (may_wait: what a client waits for, each
// row's why); core/tape.zig:1163-1193 (keeps_stopping); core/Core.zig:1763-1778
@@ -163,7 +151,7 @@ opens here.
A session takes three clients: four views at once, its own among them. A
client's #word("Detach"), or its terminal or window closing, ends that
-client only; the last client of a detached session leaves its layout as
+client only (it says the session let it go, and exits 1); the last client of a detached session leaves its layout as
the session's, for the next one to find. In a client, an addon whose state
is plain (`PA_PLAIN`: the games, the picture, the PDF) runs in the client
that shows it, from that client's own addons; one the client lacks
@@ -202,18 +190,18 @@ of the session or a divergence of its own. `pardes attach /run/x.sock:work`
#run-no-daemon()
-// runtime/daemon.zig:52-61 (PARDES_DAEMON, PARDES_TEST), :34 (Linux and
-// FreeBSD only); runtime/main.zig:1576-1592 (no daemon reached: no fork);
-// dev/tui/tui.zig:1333-1334, dev/gui/gui.zig:2537, dev/host_io.zig:85
-// (Detach and Adopt refused); core/replica.zig:2087-2092 (a client only
-// through the daemon); core/root.zig:118 (can_attach);
-// runtime/main.zig:1513-1515 (a far attach needs no daemon here).
+// runtime/daemon.zig wanted (PARDES_DAEMON, PARDES_TEST), supported
+// (Linux and FreeBSD only); runtime/main.zig, the fork (no daemon reached:
+// no fork); dev/tui/tui.zig detach, dev/gui/gui.zig detachWindow,
+// dev/host_io.zig (Detach and Adopt refused); runtime/main.zig attachTo (a
+// client only through the daemon); core/root.zig can_attach;
+// runtime/main.zig, `attach HOST:NAME` (a far attach needs no daemon here).
With `PARDES_DAEMON=off`, in a window under test (`PARDES_TEST`), where
none could start, and in the Mac's own build, the session is the process
you started, with no stub. #word("Detach") and #word("Adopt") refuse, no
client can join (a client comes only through the daemon), and closing the
terminal or the window ends the session and its shells. A session whose
-daemon died is in the same place (#link(<run-survives>)[below]).
+daemon died is not: it starts the next one itself (#link(<run-survives>)[below]).
`pardes-gui` built for a Mac has no daemon either, but can still be a far
client.
@@ -234,8 +222,7 @@ client.
[`pardes`], [stub, session, daemon], [`pardes` twice (the stub, and its child the session), `pardes --daemon`], [the session], [the session, on your terminal], [the session detaches while a daemon keeps it; else it ends],
[`pardes-gui`], [session, daemon], [`pardes-gui`, the daemon], [the session], [the session, its window], [the session ends, unless it has clients and a daemon: then it runs on, detached],
[`pardes --detach=work &`], [session, daemon], [`pardes --detach=work`, the daemon], [the session], [nothing], [it has none; its terminal's hangup ends a window's, not a terminal's while a daemon keeps it],
- [`pardes attach work`, detached], [stub, session, daemon (a window's attach exits)], [`pardes attach work` (the stub), the session as it was], [the session], [the session, on this terminal (or its window)], [as for `pardes` (or `pardes-gui`)],
- [`pardes attach work`, it has a frontend], [client, session, daemon], [`pardes attach work` (the client), the session], [the session; the client has a replica], [each its own: the session its frontend, the client this terminal], [the client ends; the session runs on],
+ [`pardes attach work`], [client, session, daemon], [`pardes attach work` (the client), the session as it was], [the session; the client has a replica], [the client, this terminal (`pardes-gui`: a window); the session its own frontend, if it still has it], [the client ends; the session runs on],
[`pardes attach box:work`], [here: client, ssh; on box: daemon, session], [`pardes attach box:work`, `ssh -tt -q -o ExitOnForwardFailure=yes -L … box exec sleep 2147483647`], [the far session], [the client, here], [the client ends, and its ssh],
[no daemon], [session], [`pardes` (or `pardes-gui`)], [the session], [the session], [the session ends, with its shells],
)
@@ -247,13 +234,14 @@ started it. After an #word("Upgrade"), a session's command line starts with
= What survives what <run-survives>
-// core/replica.zig:2303-2325 (a client leaving); runtime/daemon.zig:485-502,
+// core/replica.zig closeViewOf (a client leaving); runtime/daemon.zig hangUp, quit,
// runtime/9p_io.zig:704-729, dev/tui/tui.zig:928-940 (TERM, HUP, INT: the
-// shells go); runtime/daemon.zig:755-765, :770-789 (killed outright: kept
+// shells go); runtime/daemon.zig Daemon.hangUp, Daemon.kill (killed outright: kept
// for Adopt; `kill`: not); dev/tui/tui.zig:598-600 (a HUP kept by a daemon
-// is a terminal's end, not the session's); runtime/daemon.zig:397,
-// runtime/main.zig:1566-1593 (registered at the start and at an Upgrade
-// only); runtime/upgrade.zig:1-15, core/replica.zig:2370-2393, :2988-3008
+// is a terminal's end, not the session's); runtime/daemon.zig readNotes,
+// redial, relinked, dev/Ptys.zig tellDaemon (the next daemon dialled by
+// the link's end alone, the hello and the shells' masters told it
+// again); runtime/upgrade.zig:1-15, core/replica.zig:2370-2393, :2988-3008
// (Upgrade); core/Db.zig:1-17, :385-410 (the state file: Recent, the dumps).
#{
set text(size: 0.85em)
@@ -268,7 +256,7 @@ started it. After an #word("Upgrade"), a session's command line starts with
[#word("Detach") in its own frontend], [runs on, detached (refused with no daemon)], [stay], [stay],
[it ends (#word("Exit"), `pardes kill`, a TERM or an INT)], [gone; a terminal's stub exits with its status], [hang up with it], [each told, and exits],
[it is killed outright (KILL) or crashes], [gone, its text with it unless dumped (#word("Dump"))], [run on while a daemon holds their terminals, and #word("Adopt") in another session takes them (what they showed is lost)], [each exits],
- [the daemon is killed], [runs on, but no daemon lists it again, this one or the next: `pardes ps` and attach do not find it, #word("Detach") and #word("Adopt") refuse, and its frontend closing ends it], [stay; the shells of sessions killed earlier, held only by the daemon, hang up], [the ones joined stay; no new one can join],
+ [the daemon is killed], [runs on, and dials the next daemon at once, starting it if none answers: `pardes ps` lists it again, clients attach, #word("Detach") and #word("Adopt") work], [stay, their terminals held by the next daemon too; the shells of sessions killed earlier, held only by the dead daemon, hang up], [the ones joined stay; new ones join through the next daemon],
[#word("Upgrade")], [the same pid on the new build, its dump loaded again; every view, terminal and stub kept; the daemon moves too. A build that cannot load the dump hands it back to the one before], [stay, the session's children still], [let go, and each joins again by itself (it tries for 20 s)],
[a reboot], [gone; what is on disk stays: saved files and the state file (`pardes.xitdb`: Recent and the dumps, which #word("Restore") brings back)], [gone], [gone],
)
@@ -282,8 +270,8 @@ started it. After an #word("Upgrade"), a session's command line starts with
[*client*], [any further terminal or window on a session: its own process, a replica core],
[*far*], [a client on another machine],
[*frontend*], [what draws: the terminal, the window, the Mac's own],
- [*detached*], [a session with no frontend of its own (it may have clients)],
- [*attach*], [show a session here],
+ [*detached*], [a session with no frontend of its own, for good once it has let go the one it was born with (it may have clients)],
+ [*attach*], [show a session here: always a client],
[*daemon*], [the per-user switchboard, `pardes --daemon`],
[*stub*], [the process your shell waits on when the session is not it],
)
@@ -295,7 +283,7 @@ and `headless` for detached):
// core/replica.zig:1-19 (authority); core/replica.zig:2006-2062, :3013
// (Peers, Link, Joining); dev/tui/tui.zig:1162, dev/gui/gui.zig:2431
// (Shell); core/Core.zig:313-315, core/replica.zig:2028-2030 (unattended
-// against detached); runtime/daemon.zig:283, :363, :799 (the daemon's
+// against detached); runtime/daemon.zig hello, setDetached, Daemon.list (the daemon's
// attached and detached), runtime/main.zig:1647 (`ps` says "has a
// frontend"); runtime/session.zig:1-30, runtime/client.zig:1-35 (the
// loops and what a frontend gives each).