Skip to content
This repository was archived by the owner on Nov 15, 2026. It is now read-only.

feat(desktop): the Server sheet, the ordered stop and lodge mode's notes - #61

Merged
bketelsen merged 8 commits into
mainfrom
irulan/server-sheet
Nov 6, 2026
Merged

bketelsen merged 8 commits into
mainfrom
irulan/server-sheet

Conversation

@frostyard-machines

@frostyard-machines frostyard-machines commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Plan 0002, Phase 6, part 2 (plan, ADR-0008, spec). Part 1 (#54) connects the window to lodge. This PR lets a person choose the mode, and tests the whole path against lodge's development build.

  • The Server sheet (web/src/components/ServerSheet.tsx). The sidebar's Connect to lodge… (or Lodge: HOST) opens it. It says what each change does in ADR-0008's words, from local facts only (the mode, and whether a local database exists), so it reads the same while lodge is unreachable.
  • The ordered stop (web/src-tauri/src/server.rs, server_save): it writes app.json (temporary file, synced, renamed, directory synced), then calls daemon.shutdown and waits for the data lock for up to 30 s. When the lock stays held, it writes local back and says This computer's reader did not stop. Frostread still uses it. The mode does not change half-way. Saving local writes app.json, then starts readd through the launcher's new frostread --start. One mode gate orders saves, connects and server_get, so a connect never acts on a mode a save has not settled; the lodge connect under it has a 10 s bound. Other members of app.json are kept as raw JSON.
  • The unreachable state: with a server control (the desktop only), a lost connection (a failed call, or the connection's close) shows a banner in place of the error sheet. The change watcher is the window's one retry schedule, every 10 s; a subscribe that takes reloads what the window missed. It never shows local data in lodge mode: the bridge never falls back.
  • Lodge mode's notes: save as note works when lodge's status says notes is ready, and Open in Notes opens lodge's note route in the browser through the opener.
  • The e2e test (web/e2e/lodge.e2e.ts, make app-e2e-lodge): in the nsl machine, scripts/app-e2e-lodge.sh starts make dev-lodge's script and drives the built app through local, lodge (readd stops, the local database stays, the window shows lodge's data), save as note and Open in Notes, a stopped lodge and the sheet's texts, local again (the same 5 local sources), a readd that does not stop (SIGSTOP: the mode stays local, with the error), and the state a crash leaves just after app.json is renamed to lodge (the next start ends the local readd and then shows lodge). In a plain make app-e2e the suite skips.

The lodge web frame is unchanged: the new UI shows only when the shell has a server control, which only the desktop entry gives.

Risk tier

Risk tier: 3 — the PR carries risk:high. Matched paths, and why each change is safe:

  • web/src-tauri/src/server.rs (new; added to the glob in this PR): writes the desktop's own app.json under $XDG_CONFIG_HOME/frostread (0700 directory, 0600 file, atomic rename) and stops or starts this computer's readd. It checks lodge's address with part 1's Lodge::parse (https, or http on loopback only) before it writes anything; it never reads a token or a credential, and it runs no command but frostread --start, a fixed name with no argument from the page.
  • web/src-tauri/src/main.rs: registers the 2 commands; the navigation and opener rules are unchanged, and the capability test now lists the 5 permissions exactly.
  • web/src-tauri/src/remote.rs: only makes mode_path_from and reject_duplicate_names visible in the crate; no logic changes.
  • web/src-tauri/src/bridge.rs: a connect now holds the mode gate for reading, and the lodge connect has a 10 s bound; the line moving and the origin rules are unchanged.
  • web/src-tauri/capabilities/default.json: grants allow-server-get and allow-server-save to the main window; still no core:default, dialog or opener permission. The page can choose only the mode, and lodge's address is checked in Rust.
  • packaging/flatpak/frostread.sh: moves the local start into a function shared by a plain launch and the new --start, which never runs the app; lodge mode and --background are unchanged. smoke-test.sh checks --start in both modes.
  • .github/risk-paths.json: adds server to the shell's glob, so the new file is a risk path.
  • Makefile: adds the app-e2e-lodge target only; no gate changes.

What must not break, and still holds: local mode (make app-e2e, make flatpak-smoke), and the flatpak.yml jobs (green on this head).

Docs housekeeping

  • Cross-links added in both directions: the spec's "The Server sheet", the design overview's shell section, plan 0002's Phase 6 status and AGENTS.md.

Verification

At head 7d90ec7:

  • make check green (host)
  • make app-check green (nsl): Biome, tsc, Vitest 21 files / 146 tests, the desktop build, cargo fmt, clippy and 66 tests
  • make app-build green (nsl, through the e2e targets)
  • make app-e2e-lodge green (nsl): 7 of 7
  • make app-e2e green (nsl): 9 passed, 7 skipped (the lodge suite), no process left. One earlier run at ff43089 had lists.e2e.ts and read.e2e.ts time out on POST /session after hostile.e2e.ts; 3 later runs passed, and its cause is not known.
  • make flatpak-smoke green (host), with the 2 new --start checks
  • make screenshots run and its 3 PNGs committed: the sidebar now shows Connect to lodge…
  • CI green on this head, the 2 Flatpak jobs included
  • Revert tests, each in a scratch worktree with the tests kept:
    • store.ts, desktop/shell.ts and rpc/transport/tauri.ts back to main: 4 Vitest tests fail on assertions (quiet disconnects, Open in Notes in lodge mode, CodeNotConnected on a refused connect, the banner's retry).
    • server.rs without the write-back of local: save_lodge_stop_failure_writes_local_exact_error and real_lock_stop_fails_and_save_backwrites_local fail.
    • The review fixes: shared_mode_table_saves_keep_raw_unknown_members, malformed_mode_stays_unchanged, save_gate_blocks_connect_until_stop_fails, server_get_waits_for_save, lodge_connect_timeout_bounds_accepting_silent_server, save_deadline_starts_after_gate_wait, null_mode_loads_and_saves_as_empty_object, the sheet's close-during-save test, the idle-close banner test, the 10 s spacing test, end kills a child that ignores SIGTERM and endGroup ends a process that the group started and nobody recorded each fail with their fix removed.
    • The e2e suite fails case b when server_save writes no lodge, and case f when the stop failure is ignored.
  • Blocking review points fixed: each has its guard (a test, or the AGENTS.md rule on ending only a run's own processes) and 1 line in .memory/corrections.jsonl (11 lines).

Cross-review

Reviewer openai/gpt-6.1-sol; coder github-copilot/mai-code-2-flash, with small edits by an Anthropic Claude model. Base 3e99fe3. The initial review (2 batches, 31 files; the 3 generated screenshots left out) found 6 blocking points at 2387468; re-review 1 at 565f68e found 3 more and 2 partly fixed; re-review 2 at ff43089 left 2 partly fixed; re-review 3 at 7d90ec7: Ready, Blocking: none.

…stop

server_save writes app.json, stops this computer's readd and waits for
its lock, and writes local back when the lock stays held after 30 s
(ADR-0008, steps 1 to 4). Saving local writes app.json, then starts
readd through the new frostread --start. server_get gives the sheet its
local facts: the mode and whether a local database exists.
…otes in lodge mode

The sheet says what each change does from local facts only, in
ADR-0008's words. A lost connection shows a banner that retries every
10 s instead of the error sheet, and never falls back to local data. In
lodge mode Open in Notes opens lodge's note route in the browser.
@github-actions github-actions Bot added the risk:high Touches a path in .github/risk-paths.json (core ADR-0068) label Nov 6, 2026
make app-e2e-lodge starts lodge's development build with Read and Notes
in the nsl machine and drives the built app through local, lodge, save
as note, a stopped lodge, local again, a readd that does not stop, and
the state a crash leaves just after app.json is renamed to lodge.
… show an idle drop, and end only the run's processes

A save keeps every other member of app.json as raw JSON and refuses a
file it cannot read. One mode gate orders saves, connects and
server_get, so a connect never acts on a provisional mode. The desktop
shows a closed connection in its banner and reloads its lists when the
subscription returns. The Server sheet cannot close while a save runs.
The e2e script ends only its own process group, and the harness ends
the app before it reads the launcher's pid file. Each fix has its guard
and a line in .memory/corrections.jsonl.
…e gate, save over a null app.json, retry every 10 s, and end the run's launchers

The lodge connect under the mode gate has a 10 s bound, so a server that
never finishes its handshake cannot hold a save for ever. The stop's
deadline starts once the save holds the gate. A null app.json, which
readd and the shell read as local mode, saves as an empty object. The
desktop's watcher retries every 10 s, as the banner says; lodge's frame
keeps its retry. The harness kills a child that ignores SIGTERM, and the
stand-in launchers before it reads the readd pid file.
…cess group in the harness

The change watcher is the desktop's only retry, 10 s after a drop or a
failed subscribe, and a subscribe that takes after either reloads the
window; an answer from before the latest drop counts for nothing. The
harness starts WebKitWebDriver as a process group leader and ends that
group, which holds the app, the stand-in launcher and its readd, so no
process escapes for want of a record.
@frostyard-machines
frostyard-machines marked this pull request as ready for review November 6, 2026 17:46
@frostyard-machines frostyard-machines added the ready-for-human Reviewed, CI green: ready for Brian to review and merge label Nov 6, 2026
@bketelsen
bketelsen merged commit cf3be44 into main Nov 6, 2026
10 checks passed
@bketelsen
bketelsen deleted the irulan/server-sheet branch November 6, 2026 18:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

ready-for-human Reviewed, CI green: ready for Brian to review and merge risk:high Touches a path in .github/risk-paths.json (core ADR-0068)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants