Repository navigation
Conversation
|
Priority: P0 — blocks release / data loss. An outside contributor cannot apply labels on this repository, so please label this P0, �ug, �rea: session, os: windows, size/S. Why P0: any Pebrel started as administrator never restores and never saves the workspace. Users lose the whole tab layout on every launch, and quitting writes nothing, so the previous snapshot is lost on the next start. On Windows, launching elevated is a normal way to run a terminal, so this is not an edge case. Base note: this targets |
d76827d to
b8bb5e7
Compare
`requires_isolation()` answers "is this process privileged?", and it was also used to switch off the workspace snapshot: an elevated instance never read `session.json` and never wrote it. Every administrator launch therefore opened a single home-directory tab, and both tray quit and safe quit saved nothing, even though the previous snapshot was intact on disk. The workspace snapshot is user-visible state, not a control-plane resource, so elevation is no longer an input to it: - `SessionPersistence` drops its `isolated` field; every instance takes the same write path. - An elevated instance that has an armed update still hands the workspace to the update transaction (`checkpoint_scheduled`) before writing, so the elevated relaunch keeps its own `scheduled-workspace.json`. - `update_windows()` prefers the persisted snapshot and falls back to the in-memory one, so a scheduled update still sees a complete workspace before the first successful write. - The restore path no longer short-circuits under isolation. Isolation keeps guarding the control plane: runtime port publication, both startup handovers, keep-session residency and mobile pairing. Tests: the negative "isolated windows never write shared storage" case becomes a positive one driven by the same constructor the app uses, plus a test that a failed checkpoint still leaves the workspace visible to the update handoff.
Why
An administrator-started Pebrel never restores or saves the workspace. Every launch opens a single tab in the user's home directory, and quitting — including through the tray — writes nothing, so the tab layout is lost on every run.
requires_isolation()(platform/elevation.rs) answers "is this process privileged?". It was also used to switch off the workspace snapshot in two places:workspace/session_persistence.rsrefused to writesession.jsonandworkspace/windowing/startup_geometry.rsrefused to read it. The result is a P0 data-loss path for anyone who launches elevated — which on Windows is a normal way to run a terminal.What it does
The workspace snapshot is user-visible state, not a control-plane resource, so elevation is no longer an input to it.
SessionPersistencedrops itsisolatedfield. Every instance takes the same write path, and the replayed snapshot is written on checkpoint, window close, closing all tabs and quit.checkpoint_scheduledbefore writing, so the elevated relaunch keeps its ownscheduled-workspace.json. That transaction snapshot is unchanged; it just no longer replaces the workspace snapshot.update_windows()prefers the persisted snapshot and falls back to the in-memory one, so a scheduled update still sees a complete workspace before the first successful write (previously the fallback only existed on the isolated path).Isolation keeps guarding everything it was introduced for: runtime port publication, the two startup handovers, keep-session residency and the mobile pairing key. This change does not touch those.
Reproduction
pebrel.exefrom an elevated shell or a shortcut marked "Run as administrator").Before this change: one tab in
%USERPROFILE%, and%APPDATA%\Pebrel\session.jsonkeeps its old mtime. After: the tabs come back and the file is rewritten on quit.Evidence from the reporting machine:
session.jsonheld 15 tabs withclean_exit: trueandboot_attempts: 0, and every tab's directory still existed, but its mtime was two days older thanpebrel_settings.txtand the command history — the snapshot was simply never read or written again.Verification
cargo check -p nebula --bin pebrel --features gpui-shellandcargo check --tests -p nebula --bin pebrelpass.cargo test -p nebula --bin pebrel session_persistence— 24 passed, 0 failed. The former negative case (isolated_windows_never_write_shared_session_storage) becomes a positive one driven by the same constructor the app uses, and a new test asserts the update handoff still sees a complete workspace after a failed checkpoint.cargo test -p nebula-settings— 113 passed.python scripts/check_architecture.py— no errors.Trade-off and known limitations
try_saveis an atomic write with no cross-process lock, so two instances running at once are last-writer-wins. That is the pre-existing behaviour of the non-isolated path and is unchanged here.session-elevated.json(two layouts for one user), and removingrequires_isolation()everywhere (that would let a low-privilege process hand commands to an elevated instance).A CHANGELOG entry is included under Unreleased.