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.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
desktop: a sound when an agent finishes, and one when it stops to ask you
bitcoinbuilder4662d6cc5616
diff --git a/desktop/lib/core/startup.dart b/desktop/lib/core/startup.dartindex 45c4ddbe8..1760edce8 100644--- a/desktop/lib/core/startup.dart+++ b/desktop/lib/core/startup.dart@@ -2,6 +2,7 @@ import '../shared/theme/appearance_prefs_store.dart';import '../stats/harness_stats.dart';import '../terminal/terminal_font_store.dart';import '../terminal/terminal_theme_store.dart';+import '../notify/alert_sounds.dart';/// Every preference that has to be in place BEFORE the first frame.///@@ -20,6 +21,7 @@ Future<void> loadPersistedSettings({TerminalThemeStore? terminalTheme,AppearancePrefsStore? appearance,HarnessStats? stats,+ AlertSoundStore? alertSounds,}) async {// Independent stores may load together, but all must finish before runApp.// Font and appearance share a serialized file store; each reads its related@@ -36,5 +38,8 @@ Future<void> loadPersistedSettings({// Counters begin moving with the first agent event. Loading them later// could overwrite a new event with the old count from disk.(stats ?? harnessStats).load(),+ // Before the first agent event, not after: the setting decides whether that event makes a+ // noise, and a late read would let one through on the default while the person had it off.+ (alertSounds ?? alertSoundStore).load(),]);}diff --git a/desktop/lib/notify/alert_sounds.dart b/desktop/lib/notify/alert_sounds.dartnew file mode 100644index 000000000..bc8abbe18--- /dev/null+++ b/desktop/lib/notify/alert_sounds.dart@@ -0,0 +1,125 @@+library;++import 'dart:async';++import 'package:flutter/foundation.dart';+import 'package:flutter/services.dart';++import '../core/harness_file_store.dart';+import '../core/local_key_value_store.dart';++/// What an alert is FOR. The two moments worth interrupting someone over.+enum AlertKind {+ /// An agent finished its turn. The work you were waiting on is on screen.+ done('Glass'),++ /// An agent stopped and is waiting on a person — a question, a permission.+ /// Nothing moves until somebody answers, which is why it is the more+ /// insistent of the two sounds.+ needsYou('Submarine');++ const AlertKind(this.sound);++ /// A macOS system alert sound, played by name. Using the ones every Mac+ /// already has means no audio asset ships with the app, nothing has to be+ /// decoded, and the sounds sit at the volume the person set for alerts.+ final String sound;+}++/// Whether this computer plays a sound when an agent finishes or gets stuck.+///+/// OFF by default. An app that makes a noise nobody asked for is a bad guest,+/// and a swarm is many agents: the first thing a new user would hear is a+/// sound they did not choose, from a window they may not be looking at. It is+/// one switch away in Settings ▸ Notifications for anybody who wants it.+class AlertSoundStore extends ValueNotifier<bool> {+ AlertSoundStore({LocalKeyValueStore? storage})+ : _storage = storage ?? HarnessFileStore.shared,+ super(false);++ static const _key = 'app_alert_sounds';++ final LocalKeyValueStore _storage;+ Future<void>? _save;++ /// Read the saved choice. Tolerant: a missing or hand-edited value lands on+ /// the default rather than throwing, the same rule the appearance store+ /// follows. Only the exact string `on` switches it on, so a truncated file+ /// cannot start making noises nobody asked for.+ Future<void> load() async {+ try {+ value = (await _storage.read(_key)) == 'on';+ } catch (_) {+ value = false;+ }+ }++ /// Apply now, persist in order — rapid flips coalesce so an older write+ /// cannot replace the final choice.+ Future<void> set(bool on) {+ if (value == on) return _save ?? Future.value();+ value = on;+ final pending = (_save ?? Future.value()).then(+ (_) => _storage.write(_key, on ? 'on' : 'off'),+ );+ _save = pending;+ return pending;+ }+}++/// The one store the app reads, loaded at start-up beside the other preferences.+final alertSoundStore = AlertSoundStore();++/// Plays the alerts.+///+/// Separate from the store so the thing that DECIDES whether to make a noise+/// and the thing that makes it can be tested apart — and so a test can hear+/// what would have played without a Mac making a sound in CI.+class AlertSounds {+ AlertSounds({+ required this.store,+ MethodChannel? channel,+ this.now = _systemNow,+ this.gap = const Duration(milliseconds: 1500),+ }) : _channel = channel ?? const MethodChannel('harness/swarm_tabs');++ static DateTime _systemNow() => DateTime.now();++ final AlertSoundStore store;+ final MethodChannel _channel;+ final DateTime Function() now;++ /// The least time between two sounds of the same kind.+ ///+ /// A swarm is many agents, and a batch of them finishing together is the+ /// ordinary case rather than the rare one — without this it is a burst of+ /// beeps that says nothing more than one beep would. Per KIND, so an agent+ /// finishing never swallows the more urgent "somebody is waiting on you".+ final Duration gap;++ final _lastPlayed = <AlertKind, DateTime>{};++ /// Ask for a sound. Silent when the feature is off, and when the same kind+ /// played within [gap].+ ///+ /// Never throws and never awaits anything the caller depends on: this is+ /// called from the event dispatcher, and a platform that cannot make a noise+ /// must not break the frame that carried the news.+ void play(AlertKind kind) {+ if (!store.value) return;+ final at = now();+ final last = _lastPlayed[kind];+ if (last != null && at.difference(last) < gap) return;+ _lastPlayed[kind] = at;+ unawaited(+ _channel+ .invokeMethod<void>('playAlert', {'sound': kind.sound})+ .catchError((_) {}),+ );+ }++ /// For tests, and for a window that has been away long enough that the next+ /// event is news again rather than a continuation.+ @visibleForTesting+ void forget() => _lastPlayed.clear();+}diff --git a/desktop/lib/settings/sections/alerts_card.dart b/desktop/lib/settings/sections/alerts_card.dartnew file mode 100644index 000000000..c07c7fb2c--- /dev/null+++ b/desktop/lib/settings/sections/alerts_card.dart@@ -0,0 +1,46 @@+library;++import 'dart:async';++import 'package:flutter/material.dart';++import '../../notify/alert_sounds.dart';+import '../../shared/theme/app_theme.dart' as grid;+import '../../shared/widgets/setting_row.dart';++/// Customize Harness ▸ Appearance: whether this Mac makes a noise for you.+///+/// One switch, because there is one decision. Splitting "finished" and "needs+/// you" into two was considered and dropped: somebody who wants to hear about+/// an agent that got stuck wants to hear about one that finished, and a second+/// switch buys a combination nobody asked for at the cost of a screen that+/// reads as configuration rather than as a preference.+class AlertsCard extends StatelessWidget {+ const AlertsCard({super.key, this.store});++ /// Injected by tests; the app reads the one the window loaded at start-up.+ final AlertSoundStore? store;++ @override+ Widget build(BuildContext context) {+ grid.AppTheme.watch(context);+ final store = this.store ?? alertSoundStore;+ return ValueListenableBuilder<bool>(+ valueListenable: store,+ builder: (context, on, _) => SettingRow(+ title: 'Alert sounds',+ detail:+ 'Play a sound when an agent finishes, or stops to ask you '+ 'something.',+ control: Align(+ alignment: Alignment.centerLeft,+ child: Switch(+ key: const Key('settings-alert-sounds'),+ value: on,+ onChanged: (next) => unawaited(store.set(next)),+ ),+ ),+ ),+ );+ }+}diff --git a/desktop/lib/settings/sections/notifications_section.dart b/desktop/lib/settings/sections/notifications_section.dartnew file mode 100644index 000000000..c887d45f4--- /dev/null+++ b/desktop/lib/settings/sections/notifications_section.dart@@ -0,0 +1,41 @@+library;++import 'package:flutter/material.dart';++import '../../shared/theme/app_theme.dart' as grid;+import '../../shared/widgets/section_scaffold.dart';+import 'alerts_card.dart';++/// Settings ▸ Notifications: how this Mac gets your attention.+///+/// Its own row in the rail rather than a card inside Customize, which is where+/// the alert switch started. Customize is about how the app LOOKS, and a sound+/// is not a look — somebody who wants to silence one does not go looking under+/// Appearance for it, which is exactly how it went the first time.+///+/// One switch today. The row exists because this is where the next ones belong+/// — a desktop notification, a single agent muted, a choice of sound — and each+/// of those would otherwise find the same wrong home for the same reason.+class NotificationsSection extends StatelessWidget {+ const NotificationsSection({super.key});++ @override+ Widget build(BuildContext context) {+ grid.AppTheme.watch(context);+ return const SectionScaffold(+ title: 'Notifications',+ subtitle: 'How Harness gets your attention while you work.',+ child: SingleChildScrollView(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ AlertsCard(),+ // Room under the last control so a scrolled-to-bottom pane does not+ // end flush against the window edge.+ SizedBox(height: 8),+ ],+ ),+ ),+ );+ }+}diff --git a/desktop/lib/settings/settings_screen.dart b/desktop/lib/settings/settings_screen.dartindex 2012dede2..0991d2932 100644--- a/desktop/lib/settings/settings_screen.dart+++ b/desktop/lib/settings/settings_screen.dart@@ -14,6 +14,7 @@ import 'sections/tracking_section.dart';import 'sections/usage_section.dart';import 'settings_nav.dart';import 'settings_section.dart';+import 'sections/notifications_section.dart';/// Opens Settings over the app.///@@ -188,6 +189,7 @@ class _SettingsBody extends StatelessWidget {SettingsSection.customize => throw StateError('Customization opens over the workspace.',),+ SettingsSection.notifications => const NotificationsSection(),SettingsSection.devices => const DevicesSection(),SettingsSection.shortcuts => const ShortcutsSection(),SettingsSection.debug => const DebugSection(),diff --git a/desktop/lib/settings/settings_section.dart b/desktop/lib/settings/settings_section.dartindex a687a517a..4f3fc110d 100644--- a/desktop/lib/settings/settings_section.dart+++ b/desktop/lib/settings/settings_section.dart@@ -13,6 +13,7 @@ enum SettingsSection {account(LucideIcons.user300, 'Account'),usage(LucideIcons.chartNoAxesColumn300, 'Usage'),customize(LucideIcons.palette300, 'Customize'),+ notifications(LucideIcons.bell300, 'Notifications'),devices(LucideIcons.zap300, 'Autonomous robots'),shortcuts(LucideIcons.keyboard300, 'Keyboard shortcuts'),debug(LucideIcons.bug300, 'Debug'),@@ -85,6 +86,11 @@ const _kSettingsGroups = [SettingsGroup('Preferences', [SettingsSection.usage,SettingsSection.customize,+ // Beside Customize because it is the same kind of decision — how this Mac behaves while you+ // work — and NOT inside it, which is where the alert switch started. Customize is about how+ // the app looks; a sound is not a look, and somebody turning one off does not think to look+ // under Appearance for it.+ SettingsSection.notifications,SettingsSection.devices,SettingsSection.account,]),diff --git a/desktop/lib/state/app_state.dart b/desktop/lib/state/app_state.dartindex 94163b5d3..50aa16d48 100644--- a/desktop/lib/state/app_state.dart+++ b/desktop/lib/state/app_state.dart@@ -67,6 +67,7 @@ import 'session_preview.dart';import '../usage/remote_usage.dart';import '../usage/usage_accounts.dart';import '../orchestrator/orchestrator_controller.dart';+import '../notify/alert_sounds.dart';enum AppStatus {bootstrapping,@@ -424,6 +425,9 @@ class _AgentStop {class AppNotifier extends ChangeNotifier {final AuthSession session;+ /// The noise this window makes when an agent finishes or gets stuck.+ final AlertSounds alerts;+AppConfig config;late ApiClient api;@@ -1510,7 +1514,9 @@ class AppNotifier extends ChangeNotifier {ViewerServices? viewer,PaneLayoutStore? paneLayoutStore,this.turnActivityTimeout = const Duration(seconds: 12),- }) : _paneLayout = paneLayoutStore,+ AlertSounds? alerts,+ }) : alerts = alerts ?? AlertSounds(store: alertSoundStore),+ _paneLayout = paneLayoutStore,// Remembers "a dial has been seen here" on the same terms the pane// layout is remembered: with a layout store there is a state file, and// without one (the tests) nothing is written anywhere.@@ -9875,10 +9881,14 @@ class AppNotifier extends ChangeNotifier {// original clock in that case: this is the same wait continuing,// and restarting it would make a long block look new.final known = machine.blockedAgents[agentId];- machine.blockedAgents[agentId] =- known != null && known.sameAs(asked)+ final repeat = known != null && known.sameAs(asked);+ machine.blockedAgents[agentId] = repeat? asked.withSince(known.since): asked;+ // Only a NEW question earns a sound. The daemon re-announces every open one after a+ // reconnect and when attaching to a turn that was already mid-dialog, and a window+ // that beeped at those would sound an alarm every time the network hiccuped.+ if (!repeat) alerts.play(AlertKind.needsYou);}}break;@@ -9931,6 +9941,9 @@ class AppNotifier extends ChangeNotifier {case 'turn_ended':final agentId = _eventAgentId(machine, event, payload);if (agentId != null) {+ // The work someone was waiting on is on screen. Played whether or not the pane is in+ // front: the whole point is the agent that finished while you were looking elsewhere.+ alerts.play(AlertKind.done);_cancelTurnActivity(machine.machine.machineId, agentId);} else {final sessionId = _eventSessionId(event, payload);diff --git a/desktop/macos/Runner/SwarmTitlebar.swift b/desktop/macos/Runner/SwarmTitlebar.swiftindex 0b11a45ea..7244f6a4e 100644--- a/desktop/macos/Runner/SwarmTitlebar.swift+++ b/desktop/macos/Runner/SwarmTitlebar.swift@@ -114,6 +114,15 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {sections: state["sections"] as? [[String: Any]] ?? [])result(nil)+ case "playAlert":+ // A named macOS system sound. Every Mac has these, so no audio asset ships with the app,+ // nothing has to be decoded, and the alert plays at whatever volume the person has set for+ // alerts rather than at one this app decided. An unknown name is silence, not a crash.+ let args = call.arguments as? [String: Any] ?? [:]+ if let name = args["sound"] as? String, let sound = NSSound(named: name) {+ sound.play()+ }+ result(nil)case "keymapState":guard let payload = call.arguments as? [String: Any],let map = HarnessNativeKeymap(payload) else {diff --git a/desktop/test/alert_sounds_test.dart b/desktop/test/alert_sounds_test.dartnew file mode 100644index 000000000..85e8916ee--- /dev/null+++ b/desktop/test/alert_sounds_test.dart@@ -0,0 +1,149 @@+// The noise the app makes when an agent finishes or gets stuck: when it plays, when it stays+// quiet, and what the switch in Settings actually controls.+import 'package:flutter/services.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/core/local_key_value_store.dart';+import 'package:harness/notify/alert_sounds.dart';++/// A key/value store that lives in memory, standing in for the file one.+class _Memory implements LocalKeyValueStore {+ final values = <String, String?>{};++ @override+ Future<String?> read(String key) async => values[key];++ @override+ Future<void> write(String key, String value) async => values[key] = value;++ @override+ Future<void> delete(String key) async => values.remove(key);+}++void main() {+ TestWidgetsFlutterBinding.ensureInitialized();++ /// Every `playAlert` the platform was asked for, in order.+ late List<String> played;+ late MethodChannel channel;++ setUp(() {+ played = [];+ channel = const MethodChannel('harness/swarm_tabs');+ TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger+ .setMockMethodCallHandler(channel, (call) async {+ if (call.method == 'playAlert') {+ played.add((call.arguments as Map)['sound'] as String);+ }+ return null;+ });+ });++ tearDown(() {+ TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger+ .setMockMethodCallHandler(channel, null);+ });++ AlertSounds sounds(AlertSoundStore store, {DateTime Function()? clock}) =>+ AlertSounds(+ store: store,+ channel: channel,+ now: clock ?? () => DateTime(2026, 9, 23, 12),+ );++ test('the feature is OFF until somebody asks for it', () {+ // An app that makes a noise nobody chose is a bad guest, and a swarm is many agents.+ expect(AlertSoundStore(storage: _Memory()).value, isFalse);+ });++ test('each kind has its own sound, and the urgent one is not the finished one', () {+ expect(AlertKind.done.sound, isNotEmpty);+ expect(AlertKind.needsYou.sound, isNotEmpty);+ expect(AlertKind.done.sound, isNot(AlertKind.needsYou.sound));+ });++ /// A store with the feature switched on — what every playback test needs now that the default+ /// is silence.+ Future<AlertSoundStore> switchedOn() async {+ final store = AlertSoundStore(storage: _Memory());+ await store.set(true);+ return store;+ }++ test('plays for a finished agent and for one that is waiting on a person', () async {+ final store = await switchedOn();+ final player = sounds(store);+ player.play(AlertKind.done);+ player.play(AlertKind.needsYou);+ await Future<void>.delayed(Duration.zero);+ expect(played, [AlertKind.done.sound, AlertKind.needsYou.sound]);+ });++ test('says nothing at all while the switch is off', () async {+ final store = AlertSoundStore(storage: _Memory());+ expect(store.value, isFalse, reason: 'off is the default, not a state a test has to set');+ final player = sounds(store);+ player.play(AlertKind.done);+ player.play(AlertKind.needsYou);+ await Future<void>.delayed(Duration.zero);+ expect(played, isEmpty);+ });++ test('a batch of agents finishing together is ONE sound, not a burst', () async {+ // A swarm finishing together is the ordinary case. Ten beeps say nothing that one does not.+ var at = DateTime(2026, 9, 23, 12);+ final player = sounds(await switchedOn(), clock: () => at);+ for (var i = 0; i < 10; i++) {+ at = at.add(const Duration(milliseconds: 40));+ player.play(AlertKind.done);+ }+ await Future<void>.delayed(Duration.zero);+ expect(played, hasLength(1));+ });++ test('the rate limit is per KIND, so a stuck agent is never swallowed by a busy one', () async {+ var at = DateTime(2026, 9, 23, 12);+ final player = sounds(await switchedOn(), clock: () => at);+ player.play(AlertKind.done);+ at = at.add(const Duration(milliseconds: 40));+ // "Somebody is waiting on you" is the more urgent of the two and must not be eaten by the+ // quieter one that just played.+ player.play(AlertKind.needsYou);+ await Future<void>.delayed(Duration.zero);+ expect(played, [AlertKind.done.sound, AlertKind.needsYou.sound]);+ });++ test('the same kind is heard again once the gap has passed', () async {+ var at = DateTime(2026, 9, 23, 12);+ final player = sounds(await switchedOn(), clock: () => at);+ player.play(AlertKind.done);+ at = at.add(const Duration(seconds: 5));+ player.play(AlertKind.done);+ await Future<void>.delayed(Duration.zero);+ expect(played, hasLength(2));+ });++ test('the choice survives a restart, and only a real "on" unmutes the app', () async {+ final memory = _Memory();+ final store = AlertSoundStore(storage: memory);+ await store.set(true);+ final reopened = AlertSoundStore(storage: memory);+ await reopened.load();+ expect(reopened.value, isTrue);++ // A truncated or hand-edited value lands on the default rather than starting to make noises.+ memory.values['app_alert_sounds'] = 'o';+ final garbled = AlertSoundStore(storage: memory);+ await garbled.load();+ expect(garbled.value, isFalse);+ });++ test('a platform that cannot make a noise does not break the frame that asked', () async {+ TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger+ .setMockMethodCallHandler(channel, (call) async {+ throw PlatformException(code: 'NO_AUDIO');+ });+ final player = sounds(await switchedOn());+ expect(() => player.play(AlertKind.done), returnsNormally);+ await Future<void>.delayed(Duration.zero);+ });+}diff --git a/desktop/test/pending_question_test.dart b/desktop/test/pending_question_test.dartindex 30a458771..c0d22cf63 100644--- a/desktop/test/pending_question_test.dart+++ b/desktop/test/pending_question_test.dart@@ -2,14 +2,31 @@// bookkeeping around two frames — `commander_question` and its close — which is// what decides whether a row can lie: a question that outlives its dialog, a// wait clock that resets itself, a stale close wiping a live question.+import 'package:flutter/services.dart';import 'package:flutter_test/flutter_test.dart';import 'package:harness/auth/auth_session.dart';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/alert_sounds.dart';import 'package:harness/state/pending_question.dart';+/// A key/value store that lives in memory. Tests must never touch the real one.+class _Memory implements LocalKeyValueStore {+ final values = <String, String?>{};++ @override+ Future<String?> read(String key) async => values[key];++ @override+ Future<void> write(String key, String value) async => values[key] = value;++ @override+ Future<void> delete(String key) async => values.remove(key);+}+const _machine = Machine(machineId: 'm1',authMode: MachineAuthMode.remote,@@ -55,6 +72,9 @@ Map<String, dynamic> closed({};void main() {+ // The alert group installs a mock method-call handler, which needs the binding up.+ TestWidgetsFlutterBinding.ensureInitialized();+group('shaping', () {test('reads the prompt, its options and its answer key', () {final question = PendingQuestion.fromPayload(@@ -180,4 +200,132 @@ void main() {expect(n.questionFor('m1', 'a1'), isNull);});});++ // ── the sound the window makes ────────────────────────────────────────────────────────────────+ //+ // Two moments are worth interrupting someone over: an agent finished, and an agent stopped to+ // ask. Everything else in this file is about what the window DRAWS; this is about what it plays.++ group('alert sounds', () {+ late List<String> played;+ const channel = MethodChannel('harness/swarm_tabs');++ setUp(() {+ played = [];+ TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger+ .setMockMethodCallHandler(channel, (call) async {+ if (call.method == 'playAlert') {+ played.add((call.arguments as Map)['sound'] as String);+ }+ return null;+ });+ });++ tearDown(() {+ TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger+ .setMockMethodCallHandler(channel, null);+ });++ /// A clock the test drives, so the rate limiter cannot be mistaken for the thing under test.+ /// Feeding repeats "instantly" made the re-announcement test pass with the guard REMOVED —+ /// the gap was swallowing them, not the guard.+ late DateTime clock;++ /// Never the default storage. `AlertSoundStore()` with no argument writes to the real+ /// preferences file on this machine, and the "switch off" test below turned the feature off+ /// for the developer running it — a test that silently changes the app you are building.+ AlertSoundStore store({bool on = true}) {+ final made = AlertSoundStore(storage: _Memory());+ // Switched ON explicitly: silence is the default now, so a wiring test that forgot this+ // would pass by making no sound for the wrong reason.+ if (on) made.value = true;+ return made;+ }++ AppNotifier wired() {+ clock = DateTime(2026, 9, 23, 12);+ final notifier = AppNotifier(+ config: AppConfig.dev,+ authSession: AuthSession(),+ alerts: AlertSounds(+ store: store(),+ channel: channel,+ now: () => clock,+ ),+ );+ notifier.machines = [_machine];+ notifier.machineStates['m1'] = MachineState(_machine);+ return notifier;+ }++ test('an agent that stops to ask is heard', () async {+ final app = wired();+ addTearDown(app.dispose);+ await app.handleMachineEventForTest('m1', asked());+ await Future<void>.delayed(Duration.zero);+ expect(played, [AlertKind.needsYou.sound]);+ });++ test('the daemon re-announcing the SAME question is not heard again', () async {+ // Every reconnect re-sends every open question, and attaching to a turn that is already+ // mid-dialog does too. A window that beeped at those would sound an alarm whenever the+ // network hiccuped — for a question the person has been looking at for ten minutes.+ final app = wired();+ addTearDown(app.dispose);+ await app.handleMachineEventForTest('m1', asked());+ // Well past the rate limiter, so silence here is the guard's doing and nothing else.+ clock = clock.add(const Duration(minutes: 5));+ await app.handleMachineEventForTest('m1', asked());+ clock = clock.add(const Duration(minutes: 5));+ await app.handleMachineEventForTest('m1', asked());+ await Future<void>.delayed(Duration.zero);+ expect(played, [AlertKind.needsYou.sound]);+ });++ test('a DIFFERENT question from the same agent is heard', () async {+ final app = wired();+ addTearDown(app.dispose);+ await app.handleMachineEventForTest('m1', asked(requestId: 'q_1'));+ clock = clock.add(const Duration(minutes: 5));+ await app.handleMachineEventForTest(+ 'm1',+ asked(requestId: 'q_2', prompt: 'Overwrite the file?'),+ );+ await Future<void>.delayed(Duration.zero);+ // Two questions, two answers owed, and far enough apart that the gap is not the reason.+ expect(played, [AlertKind.needsYou.sound, AlertKind.needsYou.sound]);+ });++ test('a finished turn is heard, with its own sound', () async {+ final app = wired();+ addTearDown(app.dispose);+ await app.handleMachineEventForTest('m1', {+ 'type': 'turn_ended',+ 'agentId': 'a1',+ 'payload': {'agentId': 'a1'},+ });+ await Future<void>.delayed(Duration.zero);+ expect(played, [AlertKind.done.sound]);+ });++ test('nothing is heard while the switch is off', () async {+ final off = store(on: false);+ final app = AppNotifier(+ config: AppConfig.dev,+ authSession: AuthSession(),+ alerts: AlertSounds(store: off, channel: channel),+ );+ addTearDown(app.dispose);+ app.machines = [_machine];+ app.machineStates['m1'] = MachineState(_machine);+ await app.handleMachineEventForTest('m1', asked());+ await app.handleMachineEventForTest('m1', {+ 'type': 'turn_ended',+ 'agentId': 'a1',+ 'payload': {'agentId': 'a1'},+ });+ await Future<void>.delayed(Duration.zero);+ expect(played, isEmpty);+ });+ });}diff --git a/desktop/test/settings_section_test.dart b/desktop/test/settings_section_test.dartindex 7eedc0af6..652725970 100644--- a/desktop/test/settings_section_test.dart+++ b/desktop/test/settings_section_test.dart@@ -33,6 +33,7 @@ void main() {// there is nothing here for a shipped build to hide.SettingsSection.usage,SettingsSection.customize,+ SettingsSection.notifications,SettingsSection.devices,SettingsSection.account,SettingsSection.shortcuts,