Tier 0: render what the services already decided, honestly

Claude-Session: https://claude.ai/code/session_01Ms2FbjQy31TVf3CEvQhGM8
This commit is contained in:
Gabriel Brown
2026-08-25 00:24:30 -04:00
parent be0e55214b
commit 8b1205e4b8
38 changed files with 1474 additions and 260 deletions
@@ -25,6 +25,13 @@ Singleton {
property var snapshots: []
property string lastError: ""
// save() and create() are asynchronous: the helper is a separate process,
// and the call returns long before settings.json has been read. Anything
// that must not happen until the snapshot is safely on disk -- the reset in
// SystemSettings.restoreDefaults is the whole reason this exists -- waits
// for this rather than for the call to return.
signal saveFinished(bool success)
// Narrow service boundaries keep restore sequencing explicit and make it
// possible to verify the real handler in an isolated shell without ever
// calling the daily-driver compositor or wallpaper services.
@@ -93,6 +100,9 @@ Singleton {
}
onStarted: actionRun.outputText = ""
onExited: (exitCode, exitStatus) => {
// Read before any branch below can start the next verb and change
// it: only a save reports through saveFinished.
const wasSave = !actionRun.restoring && actionRun.doneAction === "saved";
if (exitCode !== 0) {
root.lastError = actionRun.restoring
? "That snapshot could not be restored."
@@ -104,6 +114,8 @@ Singleton {
root.protectedDisplays = ({});
root.protectedDisplayLayout = [];
}
if (wasSave)
root.saveFinished(false);
return;
}
if (actionRun.restoring) {
@@ -120,6 +132,8 @@ Singleton {
} else
root.lastError = "";
root.refresh();
if (wasSave)
root.saveFinished(true);
}
}
@@ -196,9 +210,21 @@ Singleton {
// Returns false when a snapshot is already running rather than queueing:
// the caller is about to wipe the stores, and a snapshot landing after
// that would record the wiped state as if it were the user's.
SystemSettings.takeSafetySnapshot = function() {
//
// The return value only says the snapshot STARTED. The helper reads
// settings.json in another process, so `done(success)` -- fired from
// saveFinished -- is the only point at which the file on disk is known
// to hold the user's settings rather than whatever the caller is about
// to replace them with. The caller does its irreversible work there.
SystemSettings.takeSafetySnapshot = function(done) {
if (actionRun.running)
return false;
const handler = function(success) {
root.saveFinished.disconnect(handler);
if (done)
done(success);
};
root.saveFinished.connect(handler);
root.save();
return true;
};