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: an unread mark per harness, counted on the icon and shown in the list
bitcoinbuilder86035b5ebc98
diff --git a/desktop/lib/notify/agent_alerts.dart b/desktop/lib/notify/agent_alerts.dartindex 7b27bb4d4..14676cc12 100644--- a/desktop/lib/notify/agent_alerts.dart+++ b/desktop/lib/notify/agent_alerts.dart@@ -142,3 +142,55 @@ class AgentAlerts extends ChangeNotifier {super.dispose();}}++/// Which agents have news the person has not looked at yet.+///+/// Separate from [AgentAlerts] and from the sound, and NOT behind either of+/// their switches, because it is not an interruption: a banner appears over the+/// work and a sound reaches another room, while this is a mark that sits still+/// until somebody goes looking. Somebody who turned the noisy halves off still+/// wants the window to be able to say which agent moved while they were away.+class AgentUnread extends ChangeNotifier {+ final _unread = <String, AlertKind>{};++ static String keyFor(String machineId, String agentId) =>+ '$machineId/$agentId';++ /// How many agents are carrying something unread. Agents, not events — the+ /// number answers "how many should I look at", and an agent that finished+ /// three turns is still one place to go.+ int get count => _unread.length;++ bool get isEmpty => _unread.isEmpty;++ /// What this agent's mark says, or null when it has none.+ AlertKind? kindFor(String machineId, String agentId) =>+ _unread[keyFor(machineId, agentId)];++ /// Record that an agent did something. The NEWEST kind wins: an agent that+ /// finished and then asked a question is waiting on a person, and that is the+ /// mark worth showing.+ void mark(String machineId, String agentId, AlertKind kind) {+ final key = keyFor(machineId, agentId);+ if (_unread[key] == kind) return;+ _unread[key] = kind;+ notifyListeners();+ }++ /// The person went and looked. Silent when there was nothing to clear, so a+ /// pane being focused for any other reason does not rebuild the window.+ void clear(String machineId, String agentId) {+ if (_unread.remove(keyFor(machineId, agentId)) == null) return;+ notifyListeners();+ }++ /// An agent that no longer exists cannot be gone to. Called when one is+ /// deleted, so its mark does not sit in the count forever.+ void forget(String machineId, String agentId) => clear(machineId, agentId);++ void clearAll() {+ if (_unread.isEmpty) return;+ _unread.clear();+ notifyListeners();+ }+}diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dartindex c1a88c9f4..050e9d61d 100644--- a/desktop/lib/screens/swarm_screen.dart+++ b/desktop/lib/screens/swarm_screen.dart@@ -226,6 +226,9 @@ class _SwarmScreenState extends State<SwarmScreen>_recordNavigation();app.addListener(_recordNavigation);app.addListener(_observeLearning);+ // Its own notifier, so marking one agent does not rebuild the workspace —+ // which means the badge has to ask for its own redraw.+ app.agentUnread.addListener(_unreadChanged);unawaited(_learning.load().then((_) {if (mounted) _observeLearning();@@ -294,6 +297,7 @@ class _SwarmScreenState extends State<SwarmScreen>terminalFontStore.removeListener(_fontChanged);app.removeListener(_recordNavigation);app.removeListener(_observeLearning);+ app.agentUnread.removeListener(_unreadChanged);if (widget.learning == null) _learning.dispose();FocusManager.instance.removeListener(_restoreEmptyFocus);FocusManager.instance.removeListener(_syncKeyContext);@@ -499,6 +503,25 @@ class _SwarmScreenState extends State<SwarmScreen>int get _attention =>harnessSessions(app).where((row) => row.needsInput).length;+ /// Agents carrying news nobody has looked at.+ ///+ /// This is what the icon's badge counts now, and it is a wider question than+ /// [_attention]: a harness that FINISHED is also something to go and see, and+ /// the badge that only counted blocked ones said nothing at all about the+ /// work that was actually done while you were away. The panel behind the icon+ /// still separates the two — its "Needs input" tab is exactly [_attention].+ int get _unread => app.agentUnread.count;++ void _unreadChanged() {+ if (!mounted) return;+ setState(() {});+ // The native titlebar draws its own badge, and its state is pushed from+ // `_syncNative` — which is subscribed to the APP, not to this notifier. A+ // mark that only called setState redrew a tab strip the native window does+ // not use, and the badge a person can actually see never moved.+ if (_native) _syncNative();+ }+void _restoreEmptyFocus() {if (!mounted ||app.panes.isNotEmpty ||@@ -593,6 +616,13 @@ class _SwarmScreenState extends State<SwarmScreen>},],'attention': _attention,+ // The badge the NATIVE titlebar draws. It is a wider question than+ // `attention`, which counts only harnesses that are blocked: a harness+ // that FINISHED is also something to go and see. Sent beside the old key+ // rather than replacing it, because the native side still words its+ // accessibility value from "needs input" and an older Runner ignores a+ // key it does not know.+ 'unread': _unread,'sessionsOpen': _sessionsOverlay != null,'runningSessions': harnessSessions(app).where((row) => row.running)@@ -3416,15 +3446,16 @@ class _SwarmScreenState extends State<SwarmScreen>onPressed: _toggleSessions,isSelected: _sessionsOverlay != null,icon: Badge(- isLabelVisible: _attention > 0,+ key: const ValueKey('swarm-unread-badge'),+ isLabelVisible: _unread > 0,backgroundColor: const Color(0xffcf4038),textColor: Colors.white,largeSize: 13,alignment: Alignment.topRight,label: Text(- _attention > 99 ? '99+' : '$_attention',+ _unread > 99 ? '99+' : '$_unread',semanticsLabel:- '$_attention ${_attention == 1 ? 'harness needs' : 'harnesses need'} input',+ '$_unread ${_unread == 1 ? 'harness has' : 'harnesses have'} news you have not seen',style: const TextStyle(fontSize: 9,fontWeight: FontWeight.w600,diff --git a/desktop/lib/state/app_state.dart b/desktop/lib/state/app_state.dartindex d3c35d934..d065f087c 100644--- a/desktop/lib/state/app_state.dart+++ b/desktop/lib/state/app_state.dart@@ -433,6 +433,10 @@ class AppNotifier extends ChangeNotifier {/// a banner appearing does not rebuild the workspace.final AgentAlerts agentAlerts;+ /// Which agents have news nobody has looked at. Marked on the same two+ /// moments and NOT behind the banner or sound switches — see [AgentUnread].+ final AgentUnread agentUnread;+AppConfig config;late ApiClient api;@@ -1521,8 +1525,10 @@ class AppNotifier extends ChangeNotifier {this.turnActivityTimeout = const Duration(seconds: 12),AlertSounds? alerts,AgentAlerts? agentAlerts,+ AgentUnread? agentUnread,}) : alerts = alerts ?? AlertSounds(store: alertSoundStore),agentAlerts = agentAlerts ?? AgentAlerts(),+ agentUnread = agentUnread ?? AgentUnread(),_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@@ -5811,6 +5817,9 @@ class AppNotifier extends ChangeNotifier {/// Put one agent's news on screen, named the way the window names it.void _raiseAlert(MachineState machine, String agentId, AlertKind kind) {final agent = machine.agents.where((a) => a.id == agentId).firstOrNull;+ // Before the banner and outside its switch: the mark is what the window can+ // still say when somebody has turned the interrupting halves off.+ agentUnread.mark(machine.machine.machineId, agentId, kind);agentAlerts.post(AgentAlert(machineId: machine.machine.machineId,@@ -5833,6 +5842,7 @@ class AppNotifier extends ChangeNotifier {/// Only an agent with no view at all is placed, on the current Swarm, in the/// same order [placeFork] uses for the same reason.Future<void> revealAgentFromAlert(String machineId, String agentId) async {+ markAgentSeen(machineId, agentId);agentAlerts.dismiss(AgentAlert(machineId: machineId,@@ -5848,6 +5858,12 @@ class AppNotifier extends ChangeNotifier {revealAgentView(machineId, agentId);}+ /// The person has gone to this agent — by clicking its row, its banner, or+ /// anything else that puts it in front of them. Whatever it was carrying has+ /// been seen.+ void markAgentSeen(String machineId, String agentId) =>+ agentUnread.clear(machineId, agentId);+String? _eventAgentId(MachineState machine,Map<String, dynamic> event,@@ -9891,6 +9907,8 @@ class AppNotifier extends ChangeNotifier {}break;case 'agent_deleted':+ final goneId = _eventAgentId(machine, event, payload);+ if (goneId != null) agentUnread.forget(machineId, goneId);final agentId = _eventAgentId(machine, event, payload);if (agentId != null) {await _removeAgent(machine, agentId);@@ -10067,6 +10085,7 @@ class AppNotifier extends ChangeNotifier {sessionPreviews.dispose();// Its sweep timer would otherwise outlive the window it was drawing into.agentAlerts.dispose();+ agentUnread.dispose();_disposed = true;_sharingDiscoveryTimer?.cancel();_stopMachineRecovery();diff --git a/desktop/lib/widgets/harness_session_manager.dart b/desktop/lib/widgets/harness_session_manager.dartindex 051da90d6..94f8c95eb 100644--- a/desktop/lib/widgets/harness_session_manager.dart+++ b/desktop/lib/widgets/harness_session_manager.dart@@ -11,6 +11,7 @@ import '../state/app_state.dart';import '../state/harness_sessions.dart';import '../state/swarm_navigation.dart';import 'engine_identity.dart';+import '../notify/alert_sounds.dart';/// A compact, live inventory. Action receipts belong to AppNotifier, so/// dismissing this surface never cancels a pause or launches a second resume.@@ -54,6 +55,9 @@ class _HarnessSessionManagerState extends State<HarnessSessionManager> {_filter = widget.initialFilter;_clock = Timer.periodic(const Duration(minutes: 1), (_) => _changed());widget.app.addListener(_changed);+ // Its own notifier — marking one agent must not rebuild the workspace — so+ // this list asks for its own redraw while it is open.+ widget.app.agentUnread.addListener(_changed);}void _changed() {@@ -63,6 +67,7 @@ class _HarnessSessionManagerState extends State<HarnessSessionManager> {@overridevoid dispose() {widget.app.removeListener(_changed);+ widget.app.agentUnread.removeListener(_changed);_clock?.cancel();_search.dispose();_searchFocus.dispose();@@ -120,6 +125,10 @@ class _HarnessSessionManagerState extends State<HarnessSessionManager> {}Future<void> _open(HarnessSession row, {bool answering = false}) async {+ // Going to the harness is what makes its news read. Done here rather than+ // after the open succeeds: the person has decided to look, and a mark that+ // outlived the click would read as the click not having worked.+ widget.app.markAgentSeen(row.machine.machine.machineId, row.agent.id);if (answering) {final current = widget.app.questionFor(row.machineId, row.agent.id);if (current == null || row.question?.sameAs(current) != true) return;@@ -509,6 +518,10 @@ class _HarnessSessionManagerState extends State<HarnessSessionManager> {height: rowHeight,now: now,showQuestion: showingQuestions,+ unread: widget.app.agentUnread.kindFor(+ row.machine.machine.machineId,+ row.agent.id,+ ),selected:_selected != null && selected?.id == row.id,busy: busy,@@ -545,6 +558,7 @@ class _SessionRow extends StatelessWidget {required this.height,required this.now,required this.showQuestion,+ required this.unread,required this.selected,required this.busy,required this.pendingLabel,@@ -558,6 +572,11 @@ class _SessionRow extends StatelessWidget {final DateTime now;final bool selected, busy, showQuestion;final String pendingLabel;++ /// News nobody has looked at yet, or null. Drawn beside the name, so the mark+ /// sits with the thing it is about rather than in a column of its own.+ final AlertKind? unread;+final VoidCallback onOpen, onToggle, onAnswer;final String? error;@@ -731,7 +750,7 @@ class _SessionRow extends StatelessWidget {maxLines: 1,overflow: TextOverflow.ellipsis,style: AppType.monoMeta(- color: const Color(0xffd9ad70),+ color: _UnreadMark.waitingTint,height: 1.3,),),@@ -759,6 +778,24 @@ class _SessionRow extends StatelessWidget {semanticLabel:'Needs input for ${row.agent.displayName}',),+ )+ // The SAME SLOT, never both: a row is either waiting on a+ // person or it is not, and the amber question already says+ // the first case. This says the other one — work that is done+ // and has not been looked at — in the one place the eye is+ // already checking for a row's state.+ else if (unread == AlertKind.done)+ IconButton(+ key: ValueKey('session-unread-done:${row.id}'),+ tooltip: 'Finished',+ onPressed: canOpen ? onOpen : null,+ color: _UnreadMark.doneTint,+ icon: Icon(+ LucideIcons.circleCheckBig,+ size: 17,+ semanticLabel:+ 'Finished, not yet seen: ${row.agent.displayName}',+ ),),Tooltip(message: busy@@ -825,3 +862,22 @@ class _SessionRow extends StatelessWidget {);}}++/// The two tints an unread harness is drawn in.+///+/// Named here rather than written at each use, so this and the "needs input"+/// button beside it cannot drift into two different yellows.+///+/// There is no widget any more. A left-hand pip was tried and removed: the row+/// already had a place for its state — the amber question button on the right —+/// so a second marker beside the name said the same thing twice for a question,+/// while putting "finished" somewhere the eye was not looking. Both live in+/// that one slot now, and never both at once.+abstract final class _UnreadMark {+ /// Waiting on a person. The amber the question button has always used.+ static const waitingTint = Color(0xffd9ad70);++ /// Finished. Green because it is the one colour nobody reads as "act now",+ /// which is exactly the difference being drawn.+ static const doneTint = Color(0xff6fbf8b);+}diff --git a/desktop/macos/Runner/SwarmTitlebar.swift b/desktop/macos/Runner/SwarmTitlebar.swiftindex 7244f6a4e..2eb803c70 100644--- a/desktop/macos/Runner/SwarmTitlebar.swift+++ b/desktop/macos/Runner/SwarmTitlebar.swift@@ -1641,10 +1641,20 @@ private final class SwarmTabStrip: NSView {let expandedState = sessionsButton.expanded ? "Expanded" : "Collapsed"sessionsButton.toolTip = sessionsButton.running > 0 ? "Harnesses · \(sessionsButton.running) running" : "Harnesses"let attention = state["attention"] as? Int ?? 0- sessionsButton.attention = attention+ // What the badge COUNTS is `unread` — harnesses carrying news nobody has looked at, which+ // includes the ones that simply finished. `attention` is the narrower "blocked, waiting on a+ // person" figure and still words the sentence below, because that is the half worth saying+ // out loud. An older Flutter sends no `unread`, and then the badge is what it always was.+ let unread = state["unread"] as? Int ?? attention+ sessionsButton.attention = unreadlet attentionState = "\(attention) \(attention == 1 ? "needs" : "need") input"- sessionsButton.setAccessibilityValue(attention > 0 ? "\(expandedState), \(attentionState)" : expandedState)- if attention > 0 { sessionsButton.toolTip = "Harnesses · \(attentionState)" }+ let unreadState = "\(unread) \(unread == 1 ? "harness has" : "harnesses have") news you have not seen"+ sessionsButton.setAccessibilityValue(unread > 0 ? "\(expandedState), \(unreadState)" : expandedState)+ if unread > 0 {+ sessionsButton.toolTip = attention > 0+ ? "Harnesses · \(unreadState) · \(attentionState)"+ : "Harnesses · \(unreadState)"+ }needsLayout = truelayoutSubtreeIfNeeded()if ids != previousOrder {diff --git a/desktop/test/agent_unread_test.dart b/desktop/test/agent_unread_test.dartnew file mode 100644index 000000000..8c1a87cce--- /dev/null+++ b/desktop/test/agent_unread_test.dart@@ -0,0 +1,76 @@+// The marks that say which harnesses moved while you were not looking: what sets one, what the+// badge counts, and what takes one away.+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/notify/agent_alerts.dart';+import 'package:harness/notify/alert_sounds.dart';++void main() {+ late AgentUnread unread;++ setUp(() => unread = AgentUnread());+ tearDown(() => unread.dispose());++ test('nothing is unread to begin with', () {+ expect(unread.count, 0);+ expect(unread.isEmpty, isTrue);+ expect(unread.kindFor('m1', 'a1'), isNull);+ });++ test('a mark says WHICH kind of news it is', () {+ unread.mark('m1', 'a1', AlertKind.done);+ expect(unread.kindFor('m1', 'a1'), AlertKind.done);+ expect(unread.count, 1);+ });++ test('the newest kind wins — a finished agent that then asks is waiting', () {+ // Which is the mark worth showing: one of these is work you can read later, the other is work+ // that has stopped until somebody answers.+ unread.mark('m1', 'a1', AlertKind.done);+ unread.mark('m1', 'a1', AlertKind.needsYou);+ expect(unread.kindFor('m1', 'a1'), AlertKind.needsYou);+ });++ test('the count is AGENTS, not events', () {+ // "How many should I look at" — an agent that finished three turns is still one place to go.+ unread.mark('m1', 'a1', AlertKind.done);+ unread.mark('m1', 'a1', AlertKind.done);+ unread.mark('m1', 'a1', AlertKind.needsYou);+ expect(unread.count, 1);+ });++ test('the same agent id on two machines is two marks', () {+ unread.mark('m1', 'a1', AlertKind.done);+ unread.mark('m2', 'a1', AlertKind.done);+ expect(unread.count, 2);+ });++ test('going to a harness clears its mark and nobody else’s', () {+ unread.mark('m1', 'a1', AlertKind.done);+ unread.mark('m1', 'a2', AlertKind.needsYou);+ unread.clear('m1', 'a1');+ expect(unread.kindFor('m1', 'a1'), isNull);+ expect(unread.kindFor('m1', 'a2'), AlertKind.needsYou);+ expect(unread.count, 1);+ });++ test('a deleted agent stops being counted', () {+ // An agent that no longer exists cannot be gone to, so a mark it left would sit in the badge+ // forever with nowhere to send anybody.+ unread.mark('m1', 'a1', AlertKind.done);+ unread.forget('m1', 'a1');+ expect(unread.count, 0);+ });++ test('clearing nothing notifies nobody', () {+ // A pane being focused for any other reason must not rebuild the window.+ var rebuilds = 0;+ unread.addListener(() => rebuilds++);+ unread.clear('m1', 'nobody');+ expect(rebuilds, 0);+ unread.mark('m1', 'a1', AlertKind.done);+ expect(rebuilds, 1);+ // Re-marking the same agent with the same kind is not news either.+ unread.mark('m1', 'a1', AlertKind.done);+ expect(rebuilds, 1);+ });+}diff --git a/desktop/test/pending_question_test.dart b/desktop/test/pending_question_test.dartindex f5d738b6a..2592a5b0b 100644--- a/desktop/test/pending_question_test.dart+++ b/desktop/test/pending_question_test.dart@@ -345,6 +345,50 @@ void main() {expect(app.agentAlerts.alerts.single.kind, AlertKind.needsYou);});+ test('both moments mark the harness unread, whatever the switches say', () async {+ // The mark is not an interruption — it sits still until somebody goes looking — so it is+ // deliberately outside the banner and sound switches. Somebody who turned the noisy halves+ // off still wants the window to say which agent moved while they were away.+ final app = AppNotifier(+ config: AppConfig.dev,+ authSession: AuthSession(),+ alerts: AlertSounds(store: store(on: false), channel: channel),+ agentAlerts: AgentAlerts(+ store: ScreenAlertStore(storage: _Memory()),+ ),+ );+ addTearDown(app.dispose);+ app.machines = [_machine];+ app.machineStates['m1'] = MachineState(_machine);++ await app.handleMachineEventForTest('m1', {+ 'type': 'turn_ended',+ 'agentId': 'a1',+ 'payload': {'agentId': 'a1'},+ });+ expect(app.agentUnread.kindFor('m1', 'a1'), AlertKind.done);+ expect(app.agentAlerts.alerts, isEmpty, reason: 'banners were off');++ await app.handleMachineEventForTest('m1', asked());+ expect(app.agentUnread.kindFor('m1', 'a1'), AlertKind.needsYou);++ // And going to it is what makes it read.+ app.markAgentSeen('m1', 'a1');+ expect(app.agentUnread.count, 0);+ });++ test('a deleted harness stops being counted', () async {+ final app = wired();+ addTearDown(app.dispose);+ await app.handleMachineEventForTest('m1', asked());+ expect(app.agentUnread.count, 1);+ await app.handleMachineEventForTest('m1', {+ 'type': 'agent_deleted',+ 'payload': {'agentId': 'a1'},+ });+ expect(app.agentUnread.count, 0);+ });+test('nothing is heard while the switch is off', () async {final off = store(on: false);final app = AppNotifier(