Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

desktop: banners are off by default too, and the wiring tests stop reading the app's own store

bitcoinbuilderf65e9096b45d
diff --git a/desktop/lib/notify/alert_sounds.dart b/desktop/lib/notify/alert_sounds.dart
index 5326bd199..9a4436476 100644
--- a/desktop/lib/notify/alert_sounds.dart
+++ b/desktop/lib/notify/alert_sounds.dart
@@ -69,28 +69,27 @@ class AlertSoundStore extends ValueNotifier<bool> {
/// Whether a banner appears in the window when an agent finishes or gets stuck.
///
-/// ON by default, unlike the sound. A banner is inside the app's own window and
-/// says nothing until an agent does something the person asked for — it is the
-/// half of this feature that answers "which one was that", and a default of off
-/// would leave the sound with nothing to point at.
+/// OFF by default, like the sound. Both are interruptions, and an app that
+/// interrupts without being asked is a bad guest whichever sense it reaches
+/// for. One switch each in Settings ▸ Notifications.
class ScreenAlertStore extends ValueNotifier<bool> {
ScreenAlertStore({LocalKeyValueStore? storage})
: _storage = storage ?? HarnessFileStore.shared,
- super(true);
+ super(false);
static const _key = 'app_screen_alerts';
final LocalKeyValueStore _storage;
Future<void>? _save;
- /// Only the exact string `off` switches it off — a truncated file lands on
- /// the default, which is the mirror of the rule [AlertSoundStore] follows for
- /// its own opposite default.
+ /// Only the exact string `on` switches it on — a truncated or hand-edited
+ /// file lands on the default, so a damaged store cannot start interrupting
+ /// somebody who never asked. The same rule [AlertSoundStore] follows.
Future<void> load() async {
try {
- value = (await _storage.read(_key)) != 'off';
+ value = (await _storage.read(_key)) == 'on';
} catch (_) {
- value = true;
+ value = false;
}
}
diff --git a/desktop/test/agent_alerts_test.dart b/desktop/test/agent_alerts_test.dart
index 6de879c1b..74acbe3be 100644
--- a/desktop/test/agent_alerts_test.dart
+++ b/desktop/test/agent_alerts_test.dart
@@ -43,8 +43,22 @@ void main() {
at: clock,
);
- test('the banner is ON by default — it is the half that says WHICH agent', () {
- expect(ScreenAlertStore(storage: _Memory()).value, isTrue);
+ test('the banner is OFF until somebody asks for it', () {
+ // Both channels are interruptions; neither is taken without being asked.
+ expect(ScreenAlertStore(storage: _Memory()).value, isFalse);
+ });
+
+ test('the choice survives a restart, and only a real "on" turns it on', () async {
+ final memory = _Memory();
+ await (ScreenAlertStore(storage: memory)).set(true);
+ final reopened = ScreenAlertStore(storage: memory);
+ await reopened.load();
+ expect(reopened.value, isTrue);
+
+ memory.values['app_screen_alerts'] = 'o';
+ final garbled = ScreenAlertStore(storage: memory);
+ await garbled.load();
+ expect(garbled.value, isFalse);
});
test('newest first, because that is the order they are read in', () {
diff --git a/desktop/test/pending_question_test.dart b/desktop/test/pending_question_test.dart
index 3dd376819..f5d738b6a 100644
--- a/desktop/test/pending_question_test.dart
+++ b/desktop/test/pending_question_test.dart
@@ -10,6 +10,7 @@ import 'package:harness/core/config.dart';
import 'package:harness/core/models.dart';
import 'package:harness/state/app_state.dart';
import 'package:harness/core/local_key_value_store.dart';
+import 'package:harness/notify/agent_alerts.dart';
import 'package:harness/notify/alert_sounds.dart';
import 'package:harness/state/pending_question.dart';
@@ -252,6 +253,13 @@ void main() {
channel: channel,
now: () => clock,
),
+ // Injected, and switched on. Left to the default this would read the app's own global
+ // store — the real file-backed one — so the banner assertions would pass or fail on a
+ // preference belonging to whoever ran the suite, and silently stop testing anything the
+ // day that default flipped. Which it has.
+ agentAlerts: AgentAlerts(
+ store: ScreenAlertStore(storage: _Memory())..value = true,
+ ),
);
notifier.machines = [_machine];
notifier.machineStates['m1'] = MachineState(_machine);