pmacs/tests
Levi Neuwirth 3607df0afe feat(persistence): desktop-save --- buffers + layout + positions (Arc 3 phase 2)
Framing: docs/desktop-save-framing.md (Q#DS1-10). Save the open file
buffers, window layout, and per-window positions on quit; rebuild them
on startup. Emacs desktop.el, opt-in, local-mode only in v1.

All-Rust (Q#DS1) --- the core window enums are not serde and there is
no Lua tree API, so the layout mirror + structural rebuild live in Rust.
Lua adds only the opt-in switch and manual commands.

src/desktop.rs (new):
- Serde mirror (SavedDesktop / SavedBuffer / SavedNode / SavedLeaf /
  SavedOrientation): every open file buffer (visible OR hidden, so a
  switched-away file survives), the layout tree with orientation +
  weights + nesting, per-leaf cursor/view_top, and an active-leaf
  preorder index with a nearest-neighbor fallback (Q#DS10).
- session_key: SHA-256, name.<hex> when a socket name is set else
  cwd.<hex> (charset-safe for the pmacs.state key).
- save_session / restore_session take the &Lua that carries the
  SharedCore / StateDir / LocalInstanceInfo app-data, so they run
  identically from a pmacs.session.* binding and the startup trigger.
- restore ordering (Q#DS3): open all buffers; prune EVERY window of the
  old LOCAL layout (not just scratch); rebuild the tree; then per leaf
  in preorder activate its window and fire buffer.after-load once per
  newly-loaded buffer (hooks read active state), and write the exact
  cursor/view_top AFTER so desktop wins over saveplace (same file in two
  panes keeps distinct positions). A missing file collapses its leaf.

src/editor_core.rs: get_or_load_buffer(path) --- find_by_path else
load fresh, WITHOUT switching the active window; returns (id, newly).

src/lua_bindings: pmacs.session.{save_desktop, restore_desktop,
arm_restore, is_daemon}; DesktopRestoreArmed + DaemonMode markers;
fire_after_load_hook seam.

builtin/runtime/desktop.lua: pmacs.session.desktop_mode(on) wires
before-quit save + arms restore; desktop-save / desktop-restore
commands. No-op under a daemon (Q#DS9).

Startup trigger (Q#DS7): editor::run captures had_file before the match
consumes `file`, and restore_desktop_if_armed runs INSIDE the RunLocal
arm (after attach dispatch) so a hand-off to attach never populates an
EditorState it is about to drop. Daemon marks DaemonMode → desktop
stays local-only.

Tests: src/desktop.rs units (tree collapse, active-leaf fallback,
key/json round-trip) + tests/desktop_acceptance.rs (9): nested weighted
round-trip, hidden-buffer survival, after-load-active probe, same-file
two-pane distinct positions, missing-file collapse + focus fallback, no
orphan windows, name-vs-cwd key scoping, modified warning, startup gate.

Gates: fmt + workspace clippy clean; lib 1487; crdt 1658; desktop 9;
persistence 5; m4 90; m8 daemon 10/15; query-replace/completion/
listview/overlay/cua green; GPU 58; git diff --check clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 20:28:43 -04:00
..
common M11.1: semantic-frontend protocol scaffolding (wire + capability) 2026-05-18 19:39:07 -04:00
fixtures V0.2-prerequisite pull-forward + M10.11 clean audit round 2026-05-18 10:31:31 -04:00
acceptance.rs Collapse if-let nests into let-chains (MSRV-1.95 collapsible_if sweep) 2026-05-18 14:29:36 -04:00
completion_popup_acceptance.rs fix(completion): address TUI-validation findings (LSP query gaps, scoping, prefix keys, window scope) 2026-07-07 16:54:14 -04:00
cua_region_acceptance.rs CUA type-over is a single undo step (Q#U1) 2026-06-15 20:00:53 -04:00
desktop_acceptance.rs feat(persistence): desktop-save --- buffers + layout + positions (Arc 3 phase 2) 2026-07-08 20:28:43 -04:00
listview_acceptance.rs feat(panels): listview module, Q#P6 round-trip seam, references panel 2026-07-07 20:15:46 -04:00
m3_acceptance.rs Initial commit: v0.1.0 2026-05-03 19:51:06 -04:00
m4_acceptance.rs style(test): factor fake-LSP bootstrap out of the panel tests 2026-07-07 22:16:49 -04:00
m5_5_acceptance.rs Collapse if-let nests into let-chains (MSRV-1.95 collapsible_if sweep) 2026-05-18 14:29:36 -04:00
m5_6_acceptance.rs Initial commit: v0.1.0 2026-05-03 19:51:06 -04:00
m5_7_acceptance.rs CI fixes 2026-05-18 12:24:35 -04:00
m5_8_acceptance.rs tests: widen backoff timing signal 2026-05-25 13:32:54 -04:00
m5_perf_acceptance.rs M11.1: semantic-frontend protocol scaffolding (wire + capability) 2026-05-18 19:39:07 -04:00
m6_4_repl_acceptance.rs Fix PTY final-output drain race 2026-05-04 09:44:30 -04:00
m6_5_repl_acceptance.rs tests: quarantine macOS PTY marker cases 2026-05-25 13:02:46 -04:00
m6_7_scrollback_acceptance.rs Initial commit: v0.1.0 2026-05-03 19:51:06 -04:00
m6_8_multi_repl_acceptance.rs Collapse if-let nests into let-chains (MSRV-1.95 collapsible_if sweep) 2026-05-18 14:29:36 -04:00
m6_perf_acceptance.rs tests: tune M6 hosted perf profile 2026-05-25 13:43:28 -04:00
m7_3_acceptance.rs Fix CI and Documentation issues 2026-05-04 10:19:19 -04:00
m7_5_acceptance.rs fix(packages): basename-collision reject, SHA-256 cache key, timeout thread join, commit→revision, dead-code (F-005/F-009–F-012) 2026-07-03 18:47:23 -04:00
m7_6_acceptance.rs fix(packages): basename-collision reject, SHA-256 cache key, timeout thread join, commit→revision, dead-code (F-005/F-009–F-012) 2026-07-03 18:47:23 -04:00
m7_7_acceptance.rs M7 tail: package system, audit lint, lockfile, resolver 2026-05-07 16:50:37 -04:00
m7_8_acceptance.rs M7 tail: package system, audit lint, lockfile, resolver 2026-05-07 16:50:37 -04:00
m7_9_acceptance.rs M7 tail: package system, audit lint, lockfile, resolver 2026-05-07 16:50:37 -04:00
m7_10_acceptance.rs fix(packages): basename-collision reject, SHA-256 cache key, timeout thread join, commit→revision, dead-code (F-005/F-009–F-012) 2026-07-03 18:47:23 -04:00
m7_11_acceptance.rs M7 tail: package system, audit lint, lockfile, resolver 2026-05-07 16:50:37 -04:00
m7_review_acceptance.rs M7 tail: package system, audit lint, lockfile, resolver 2026-05-07 16:50:37 -04:00
m8_1_acceptance.rs Pin toolchain to 1.95.0 + mechanical clippy/rustc fixes 2026-05-18 11:38:57 -04:00
m8_1c_acceptance.rs M7 tail: package system, audit lint, lockfile, resolver 2026-05-07 16:50:37 -04:00
m8_1d_acceptance.rs M7 tail: package system, audit lint, lockfile, resolver 2026-05-07 16:50:37 -04:00
m8_2_acceptance.rs tests: stabilize hosted perf gates 2026-05-25 13:20:18 -04:00
m8_3_acceptance.rs M7 tail: package system, audit lint, lockfile, resolver 2026-05-07 16:50:37 -04:00
m8_5_acceptance.rs M7 tail: package system, audit lint, lockfile, resolver 2026-05-07 16:50:37 -04:00
m8_6_acceptance.rs M7 tail: package system, audit lint, lockfile, resolver 2026-05-07 16:50:37 -04:00
m8_7_acceptance.rs M7 tail: package system, audit lint, lockfile, resolver 2026-05-07 16:50:37 -04:00
m8_9_acceptance.rs V0.2-prerequisite pull-forward + M10.11 clean audit round 2026-05-18 10:31:31 -04:00
m8_10_acceptance.rs V0.2-prerequisite pull-forward + M10.11 clean audit round 2026-05-18 10:31:31 -04:00
m9_1_acceptance.rs T M4.5 async bridge: LSP requests settle async-runtime jobs 2026-05-18 19:36:17 -04:00
m9_2_acceptance.rs style: from_secs(1) for the m9_2 harvest wait (clippy duration units) 2026-06-10 12:07:08 -04:00
m9_3_acceptance.rs Collapse if-let nests into let-chains (MSRV-1.95 collapsible_if sweep) 2026-05-18 14:29:36 -04:00
m9_4_acceptance.rs M9 ship gate 2026-05-09 15:04:23 -04:00
m9_5_acceptance.rs M9 ship gate 2026-05-09 15:04:23 -04:00
m9_6_acceptance.rs M9 ship gate 2026-05-09 15:04:23 -04:00
m9_7_acceptance.rs M9 ship gate 2026-05-09 15:04:23 -04:00
m9_8_acceptance.rs M9 ship gate 2026-05-09 15:04:23 -04:00
m10_2_perf.rs M10.10 ship gate 2026-05-13 16:28:46 -04:00
m10_10_perf.rs M10.10 ship gate 2026-05-13 16:28:46 -04:00
m10_10_postcard_unknown_variant.rs M10.10 ship gate 2026-05-13 16:28:46 -04:00
m10_11_acceptance.rs M11.1: semantic-frontend protocol scaffolding (wire + capability) 2026-05-18 19:39:07 -04:00
m10_11_perf.rs M10.11: adversarial two-laptop acceptance + jitter; the M10 arc verified 2026-05-15 20:51:00 -04:00
m11_5_semantic_acceptance.rs M11.5: semantic frontend<->instance glue (SemanticClient + e2e) 2026-05-18 21:24:36 -04:00
overlay_reattach_acceptance.rs fix(panels): follow active buffer on semantic frontends; re-attach overlays on switch 2026-07-07 20:46:50 -04:00
persistence_acceptance.rs fix(persistence): symlink confinement, real test-inertness, view_top restore 2026-07-08 18:21:46 -04:00
query_replace_acceptance.rs fix(query-replace): pin the session to its origin buffer (wrong-buffer guard) 2026-07-08 17:07:08 -04:00
worker_shutdown_acceptance.rs fix(completion): address TUI-validation findings (LSP query gaps, scoping, prefix keys, window scope) 2026-07-07 16:54:14 -04:00