Tier 0: render what the services already decided, honestly
Claude-Session: https://claude.ai/code/session_01Ms2FbjQy31TVf3CEvQhGM8
This commit is contained in:
@@ -12,6 +12,11 @@ ShellRoot {
|
||||
property var appliedBatches: []
|
||||
property bool displayBlocked: false
|
||||
|
||||
// The held-open safety snapshot: `pendingSnapshotDone` is the completion
|
||||
// callback restoreDefaults handed over, waiting for the contract to answer.
|
||||
property var pendingSnapshotDone: null
|
||||
property bool snapshotRefusesToStart: false
|
||||
|
||||
function recordReset(name: string): void {
|
||||
const next = root.resetCalls.slice();
|
||||
next.push(name);
|
||||
@@ -43,10 +48,16 @@ ShellRoot {
|
||||
root.recordReset("display.block:" + blocked);
|
||||
root.displayBlocked = blocked;
|
||||
};
|
||||
// Recorded so the contract can prove the snapshot happens BEFORE the
|
||||
// stores are cleared, not merely that it happens.
|
||||
SystemSettings.takeSafetySnapshot = function() {
|
||||
root.recordReset("snapshot");
|
||||
// The real snapshot is another process reading settings.json, so the
|
||||
// stub is held open rather than answering inline: the contract drives
|
||||
// its completion by hand and can therefore prove that nothing is wiped
|
||||
// in the window between "snapshot started" and "snapshot finished",
|
||||
// and that a failed snapshot leaves the stores alone.
|
||||
SystemSettings.takeSafetySnapshot = function(done) {
|
||||
root.recordReset("snapshot.start");
|
||||
if (root.snapshotRefusesToStart)
|
||||
return false;
|
||||
root.pendingSnapshotDone = done;
|
||||
return true;
|
||||
};
|
||||
SystemSettings.reloadKeybinds = function() { root.recordReset("keybinds.reload"); };
|
||||
@@ -107,6 +118,33 @@ ShellRoot {
|
||||
return SystemSettings.restoreDefaults();
|
||||
}
|
||||
|
||||
// Whether the next safety snapshot is allowed to start at all -- the
|
||||
// "a backup is already running" case, which must refuse the reset
|
||||
// outright rather than proceed without one.
|
||||
function snapshotCanStart(allowed: bool): void {
|
||||
root.snapshotRefusesToStart = !allowed;
|
||||
}
|
||||
|
||||
// Answer the snapshot that restoreDefaults is waiting on. Everything
|
||||
// the reset does must happen after this and not before.
|
||||
function finishSnapshot(success: bool): bool {
|
||||
const done = root.pendingSnapshotDone;
|
||||
if (!done)
|
||||
return false;
|
||||
root.pendingSnapshotDone = null;
|
||||
root.recordReset("snapshot.finish:" + success);
|
||||
done(success);
|
||||
return true;
|
||||
}
|
||||
|
||||
function resetPending(): bool {
|
||||
return SystemSettings.resetPending;
|
||||
}
|
||||
|
||||
function clearError(): void {
|
||||
SystemSettings.lastError = "";
|
||||
}
|
||||
|
||||
function resetState(): string {
|
||||
return JSON.stringify({
|
||||
calls: root.resetCalls,
|
||||
|
||||
Reference in New Issue
Block a user