Settle process-signal races across the services layer

A Process's exited and streamFinished signals aren't guaranteed to
fire in order, and several services decided an outcome on whichever
fired first: KdeConnect could report a successful file transfer as
failed if exited landed before the real stdout payload; Clipboard
could present a failed history query as an empty-but-healthy one;
Brightness could strand the last queued write of a drag; SoundFeedback
and SystemLocale could drop or misapply a rapid second toggle/click
because re-arming an already-running Process is a no-op. All five now
wait for both signals and let the authoritative one decide, matching
the pattern HomeAssistantConfig.qml already used correctly.

Health's "copy report" never enabled stdin, so it copied nothing
while claiming success. Capture announced every recording as saved
regardless of the recorder's actual exit code. Connectivity never
restarted Bluetooth discovery when the adapter was enabled from an
already-open page. CalendarAgenda left the UI in "loading" forever if
its helper died at startup, and the helper itself could crash
unguarded instead of reporting unavailable. Geocoding silently
dropped a query typed while the previous one was still in flight.
Notifs leaked tracked-but-undisplayed notifications under Do Not
Disturb, and dismissAll() skipped them.

Claude-Session: https://claude.ai/code/session_01E6TJUAh41HaP25MVHWkhRZ
This commit is contained in:
Gabriel Brown
2026-08-18 21:23:07 -04:00
parent e6b4d3c1a1
commit 8b59b78d9f
12 changed files with 323 additions and 45 deletions
@@ -46,9 +46,25 @@ Singleton {
list.running = true;
}
// A picker click while a change is still applying is queued rather than
// fired directly: assigning `running = true` to an already-running
// Process is a no-op, so a second set() here would otherwise be silently
// dropped and apply.onExited would then adopt the second value as if it
// had actually been applied. requestedValue always holds the latest
// request; apply.onExited re-fires with it once the in-flight apply
// settles, mirroring Brightness.qml's pending-write queue.
property string requestedValue: ""
function set(value: string): void {
if (value === root.current)
return;
root.requestedValue = value;
if (!apply.running)
root._applyValue(value);
}
function _applyValue(value: string): void {
root.requestedValue = "";
apply.command = [root.helperPath, "set", value];
apply.pendingValue = value;
apply.running = true;
@@ -94,6 +110,16 @@ Singleton {
} else {
root.lastError = "The system did not accept that language. It may have needed a password.";
}
// A set() call that arrived while this apply was running only
// queued itself in requestedValue (see the comment above). Fire
// it now if it still names something other than what was just
// applied, so the UI never settles on a locale the system was
// never actually asked for.
if (root.requestedValue !== "" && root.requestedValue !== apply.pendingValue)
root._applyValue(root.requestedValue);
else
root.requestedValue = "";
}
}
}