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
Merge batch 11-05 i1320: #3104 #3102 #3008 (#3107)
0xken1551cc9b85e94f
diff --git a/cli/src/superTabs/native.spec.ts b/cli/src/superTabs/native.spec.tsindex 103931987..76b0f260b 100644--- a/cli/src/superTabs/native.spec.ts+++ b/cli/src/superTabs/native.spec.ts@@ -233,6 +233,33 @@ describe('durable native conversation recording', () => {expect(t.sent.map(e => e.kind)).toEqual(['prompt', 'gap', 'prompt', 'answer'])})+ // Task #3127: a core restart, and the history replay its re-attach brings, each start a new epoch. Two views of one+ // terminal across both posted four "recording interrupted" lines while nothing was lost.+ it('a restart with no unfinished recorded turn records no gap', async () => {+ const t = setup(true), host = t.open()+ await host.prepare('tab', alpha); await host.prepare('tab', beta)+ t.prompt('Finished before the restart'); t.answer('Answered'); await host.capture(); await host.flush()+ t.observer.ingest('harness', [], true)+ await host.capture(); await host.flush()+ t.observer.ingest('harness', [], true)+ await host.capture(); await host.flush()+ expect(t.sent.map(e => e.kind)).toEqual(['prompt', 'answer'])+ })++ it('one restart and the replay after it give one gap, for the view whose turn it cut', async () => {+ const t = setup(true), host = t.open()+ await host.prepare('tab', alpha); await host.prepare('tab', beta)+ t.prompt('Cut by the restart'); await host.capture(); await host.flush()+ t.time(100_000)+ t.observer.ingest('harness', [], true)+ await host.capture()+ t.observer.ingest('harness', [], true)+ await host.capture(); await host.flush()+ expect(t.sent.map(e => e.kind)).toEqual(['prompt', 'gap'])+ expect(t.sent[1]).toMatchObject({ gap: { reason: 'recording_restarted' } })+ expect(t.contexts.get(beta)!.lastEventId).toBeNull()+ })+it('finishes an already observed turn after closing the view, then stops observing the idle terminal', async () => {const t = setup(), host = t.open()await host.prepare('tab', alpha); t.prompt('Long task'); await host.capture(); await host.flush()diff --git a/cli/src/superTabs/native.ts b/cli/src/superTabs/native.tsindex 44c997766..e1fcd60cc 100644--- a/cli/src/superTabs/native.ts+++ b/cli/src/superTabs/native.ts@@ -244,10 +244,14 @@ export class NativeRecorder {this.gap(row, id, harnessId, reason === 'recording_restarted' ? page.cursor.epoch: `${page.cursor.epoch}:${page.cursor.sequence}`, reason)}- if (page.gap || page.observations.some(event => event.kind === 'prompt' && event.unattributedInput)) {- for (const [id, c] of Object.entries(row.contexts)) {- if (!c.blocked) gap(id, page.gap ? (page.cursor.epoch !== before.cursor.epoch ? 'recording_restarted' : 'history_lost') : 'unattributed_input')- }+ if (page.gap && page.cursor.epoch !== before.cursor.epoch) {+ // A new epoch comes with each core restart and each history replay or resumed turn after it (task #3127:+ // two views across one restart posted four gaps). It loses only a recorded turn left unfinished: that view+ // reports it, once. An idle view lost nothing.+ for (const id of new Set(Object.values(row.turns))) if (!row.contexts[id]!.blocked) gap(id, 'recording_restarted')+ row.turns = {}+ } else if (page.gap || page.observations.some(event => event.kind === 'prompt' && event.unattributedInput)) {+ for (const [id, c] of Object.entries(row.contexts)) if (!c.blocked) gap(id, page.gap ? 'history_lost' : 'unattributed_input')if (page.gap) row.turns = {}}for (const observation of page.observations) {diff --git a/desktop/lib/super_tabs/controller.dart b/desktop/lib/super_tabs/controller.dartindex 664be42c3..94bdcc21a 100644--- a/desktop/lib/super_tabs/controller.dart+++ b/desktop/lib/super_tabs/controller.dart@@ -2067,7 +2067,9 @@ class SuperTabController extends ChangeNotifier {);static bool _listed(SuperTabMessage m) =>- m.source['kind'] != 'update-request' && !m.terminalPrompt;+ m.source['kind'] != 'update-request' &&+ !m.terminalPrompt &&+ !m.terminalGap;/// [id]'s messages with its steps' rows merged in by time (task steps/// design): each step keeps its own conversation, shown inside its task.diff --git a/desktop/lib/super_tabs/model.dart b/desktop/lib/super_tabs/model.dartindex 7c0b8ede4..02400ea89 100644--- a/desktop/lib/super_tabs/model.dart+++ b/desktop/lib/super_tabs/model.dart@@ -1521,6 +1521,11 @@ class SuperTabMessage {/// What was typed into an agent's terminal, a scheduled prompt too: no chat/// row and nothing unread (Ken 11-04, task #2849). Its answer still is one.bool get terminalPrompt => fromTerminal && source['phase'] == 'prompt';++ /// A terminal's recording gap: no chat row and nothing unread, since it gives+ /// a person nothing to do (Dee 11-05, task #3127). The server keeps it for+ /// diagnosis, and a required recovery still reaches the coordinator.+ bool get terminalGap => fromTerminal && source['phase'] == 'gap';SuperTabRoute? get route => SuperTabRoute.fromSource(source);bool get routeOverride => source['kind'] == 'route-override';diff --git a/desktop/lib/super_tabs/project_sidebar.dart b/desktop/lib/super_tabs/project_sidebar.dartindex 493f69cb1..80ed59e32 100644--- a/desktop/lib/super_tabs/project_sidebar.dart+++ b/desktop/lib/super_tabs/project_sidebar.dart@@ -85,8 +85,8 @@ class ProjectSidebar extends StatelessWidget {/// The page holding the main pane, if one does.final SwarmPage? page;- /// What the three rows count; without it Decisions and Mentions count what- /// the server says waits, and Threads nothing.+ /// What the three rows read, to be bold or grey; without it Decisions and+ /// Mentions read what the server says waits, and Threads nothing.final SuperTabActivity? activity;/// The reader's places, for the back and forward arrows at the top;@@ -133,7 +133,6 @@ class ProjectSidebar extends StatelessWidget {required IconData icon,required VoidCallback? onTap,bool selected = false,- int badge = 0,Widget? trailing,bool? unread,}) => Padding(@@ -200,8 +199,7 @@ class ProjectSidebar extends StatelessWidget {),),),- if (trailing ?? (badge > 0 ? SuperTabCountBadge(badge) : null)- case final mark?)+ if (trailing case final mark?)Padding(padding: const EdgeInsets.only(right: 10), child: mark),],),@@ -210,28 +208,24 @@ class ProjectSidebar extends StatelessWidget {),);- /// Threads: bold with a plain count while followed threads have unread- /// replies, never red (anh Dee, 11-05).- Widget _threadsRow(ValueChanged<SwarmPage> onPage) {- final count = activity?.threadsCount ?? 0;- return _navigationRow(- key: 'super-threads',- label: 'Threads',- icon: AppIcons.messagesSquare,- onTap: () => onPage(SwarmPage.threads),- selected: page == SwarmPage.threads,- unread: count > 0,- trailing: count > 0- ? Text(- '$count',- style: SwarmType.sidebar(- compact: compact,- color: grid.SidebarInk.ink,- ).copyWith(fontWeight: grid.AppFont.semibold),- )- : null,- );- }+ /// A page row of Decisions, Mentions or Threads: no number and no red,+ /// bold at full strength while something waits, grey when nothing does+ /// (anh Dee, 11-05, task #3128).+ Widget _pageRow(+ ValueChanged<SwarmPage> onPage, {+ required SwarmPage target,+ required String key,+ required String label,+ required IconData icon,+ required int waiting,+ }) => _navigationRow(+ key: key,+ label: label,+ icon: icon,+ onTap: () => onPage(target),+ selected: page == target,+ unread: waiting > 0,+ );/// Back and forward over the reader's places (⌘[ and ⌘]), at the top.Widget _arrows(SuperTabPlaces places) => Row(@@ -676,6 +670,9 @@ class ProjectSidebar extends StatelessWidget {final snapshot = controller.snapshot;final projects = snapshot?.projects ?? const <SuperTabProject>[];final reading = _SidebarReading(controller, attention);+ final decisions = activity?.needsCount ?? snapshot?.decisionsWaiting ?? 0;+ final mentions = activity?.mentionsCount ?? snapshot?.mentionsWaiting ?? 0;+ final threads = activity?.threadsCount ?? 0;return Material(// The page's color: the rule at its edge is what separates them. A// theme may give the sidebar its own (Plum's plum).@@ -709,29 +706,36 @@ class ProjectSidebar extends StatelessWidget {),),// Three rows, each one thing, in anh Dee's order (11-05, task- // #2996): only Decisions and Mentions are ever red.+ // #2996): bold when something waits, grey when not, and no+ // numbers (task #3128). The Swarm switcher stands apart from+ // them by a control gap.if (onPage case final onPage?) ...[- _navigationRow(+ if (app != null && onNewSwarm != null)+ const SizedBox(height: DesktopChrome.controlGap),+ _pageRow(+ onPage,+ target: SwarmPage.decisions,key: 'super-decisions',label: 'Decisions',icon: AppIcons.flag,- onTap: () => onPage(SwarmPage.decisions),- selected: page == SwarmPage.decisions,- badge:- activity?.needsCount ?? snapshot?.decisionsWaiting ?? 0,+ waiting: decisions,),- _navigationRow(+ _pageRow(+ onPage,+ target: SwarmPage.mentions,key: 'super-mentions',label: 'Mentions',icon: AppIcons.atSign,- onTap: () => onPage(SwarmPage.mentions),- selected: page == SwarmPage.mentions,- badge:- activity?.mentionsCount ??- snapshot?.mentionsWaiting ??- 0,+ waiting: mentions,+ ),+ _pageRow(+ onPage,+ target: SwarmPage.threads,+ key: 'super-threads',+ label: 'Threads',+ icon: AppIcons.messagesSquare,+ waiting: threads,),- _threadsRow(onPage),],const SizedBox(height: 20),SuperTabSectionHeading(diff --git a/desktop/lib/super_tabs/recording_notice.dart b/desktop/lib/super_tabs/recording_notice.dartdeleted file mode 100644index 13ba8cdb9..000000000--- a/desktop/lib/super_tabs/recording_notice.dart+++ /dev/null@@ -1,113 +0,0 @@-import 'package:flutter/material.dart';--import '../shared/theme/app_icons.dart';-import '../widgets/desktop_chrome.dart';-import 'model.dart';--bool _recordingGap(SuperTabMessage message) =>- message.fromTerminal &&- message.source['phase'] == 'gap' &&- message.replyTo == null &&- message.deliveries.isEmpty;--/// Only coalesce identical, adjacent recording diagnostics from the same session.-/// Ordinary posts, source messages and their IDs remain untouched.-List<({SuperTabMessage message, int interruptions})> superTabTranscriptEntries(- List<SuperTabMessage> messages,-) {- final entries = <({SuperTabMessage message, int interruptions})>[];- for (final message in messages) {- final previous = entries.lastOrNull;- final first = previous?.message;- if (_recordingGap(message) &&- previous != null &&- previous.interruptions > 0 &&- first!.authorId == message.authorId &&- first.author['kind'] == message.author['kind'] &&- first.conversationId == message.conversationId &&- first.author['membershipGeneration'] ==- message.author['membershipGeneration'] &&- first.authorName == message.authorName &&- first.text == message.text &&- first.createdAt != null &&- message.createdAt != null &&- DateUtils.isSameDay(- first.createdAt!.toLocal(),- message.createdAt!.toLocal(),- ) &&- !message.createdAt!.difference(first.createdAt!).isNegative &&- message.createdAt!.difference(first.createdAt!) <=- const Duration(minutes: 5)) {- entries[entries.length - 1] = (- message: first,- interruptions: previous.interruptions + 1,- );- } else {- entries.add((- message: message,- interruptions: _recordingGap(message) ? 1 : 0,- ));- }- }- return entries;-}--class SuperTabRecordingNotice extends StatelessWidget {- const SuperTabRecordingNotice({- super.key,- required this.author,- required this.count,- this.onOpenTerminal,- });-- final String author;- final int count;- final VoidCallback? onOpenTerminal;-- @override- Widget build(BuildContext context) => Padding(- padding: const EdgeInsets.fromLTRB(24, 12, 24, 12),- child: Row(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Padding(- padding: const EdgeInsets.only(top: 5),- child: Icon(AppIcons.terminal, size: 16, color: DesktopChrome.muted),- ),- const SizedBox(width: 8),- Expanded(- child: Tooltip(- message:- 'Some terminal activity could not be recorded. '- 'Open the terminal for the full conversation.',- child: Wrap(- crossAxisAlignment: WrapCrossAlignment.center,- spacing: 6,- children: [- Text(- '$author’s terminal recording was interrupted'- '${count > 1 ? ' $count times' : ''}.',- style: DesktopChrome.metadata(),- ),- if (onOpenTerminal != null)- TextButton(- onPressed: onOpenTerminal,- style: TextButton.styleFrom(- foregroundColor: DesktopChrome.accent,- backgroundColor: Colors.transparent,- side: BorderSide.none,- minimumSize: const Size(0, 28),- padding: const EdgeInsets.symmetric(horizontal: 6),- tapTargetSize: MaterialTapTargetSize.shrinkWrap,- textStyle: DesktopChrome.metadata(),- ),- child: const Text('Open terminal'),- ),- ],- ),- ),- ),- ],- ),- );-}diff --git a/desktop/lib/super_tabs/view.dart b/desktop/lib/super_tabs/view.dartindex b7d2dcdbf..f80d28689 100644--- a/desktop/lib/super_tabs/view.dart+++ b/desktop/lib/super_tabs/view.dart@@ -30,7 +30,6 @@ import 'leaderboard/reader.dart';import 'jump_to_latest.dart';import 'unread_line.dart';import 'roster.dart';-import 'recording_notice.dart';import 'profile_actions.dart';import 'live_card.dart';import 'personal_lead.dart';@@ -844,11 +843,10 @@ class _SuperTabViewState extends State<SuperTabView>/// Whether [messageId]'s row in [id]'s list is below [position]'s view, by/// its place in the list.bool _below(String id, String messageId, ScrollPosition position) {- final entries = superTabTranscriptEntries(_shownMessages(id));- final row = _rowShowing(id, messageId);- final index = entries.indexWhere((e) => e.message.id == row);+ final shown = _shownMessages(id);+ final index = shown.indexWhere((m) => m.id == messageId);return index >= 0 &&- _estimate(position, index, entries.length) > position.pixels;+ _estimate(position, index, shown.length) > position.pixels;}/// Esc: everything loaded in the open conversation is read, line and all.@@ -1632,12 +1630,10 @@ class _SuperTabViewState extends State<SuperTabView>final row = _built[anchor.messageId];final top = row != null && row.mounted ? _topInList(row) : null;if (top == null) {- final entries = superTabTranscriptEntries(_shownMessages(id));- final index = entries.indexWhere(- (e) => e.message.id == anchor.messageId,- );+ final shown = _shownMessages(id);+ final index = shown.indexWhere((m) => m.id == anchor.messageId);if (index < 0) return;- scroll.jumpTo(_estimate(position, index, entries.length));+ scroll.jumpTo(_estimate(position, index, shown.length));continue;}if ((top - anchor.top).abs() < .5) return;@@ -2109,13 +2105,12 @@ class _SuperTabViewState extends State<SuperTabView>c.openThread(message.thread!, at: message.id);if (!message.inMainStream) return;}- final shownBy = _rowShowing(id, messageId) ?? messageId;setState(() {_page = null;_showManage = false;_showPullRequests = _showTasks = false;_back = null;- _target = shownBy;+ _target = messageId;_openedAtMessage = id;// Stop following the end: the linked message is what to see._scrollRequest++;@@ -2308,12 +2303,12 @@ class _SuperTabViewState extends State<SuperTabView>return _landed(landing!);}final scroll = _scroll[id];- final entries = superTabTranscriptEntries(_shownMessages(id));- final index = entries.indexWhere((e) => e.message.id == _target);+ final shown = _shownMessages(id);+ final index = shown.indexWhere((m) => m.id == _target);if (scroll == null || !scroll.hasClients || index < 0 || attempt > 20) {return _landed(landing!);}- scroll.jumpTo(_estimate(scroll.position, index, entries.length));+ scroll.jumpTo(_estimate(scroll.position, index, shown.length));_revealTarget(id, attempt + 1, arrived: arrived, landing: landing);});WidgetsBinding.instance.scheduleFrame();@@ -2376,24 +2371,10 @@ class _SuperTabViewState extends State<SuperTabView>static bool _shown(SuperTabMessage m) =>!_neverShown.contains(m.source['kind']);- /// The row of [id]'s list that shows [messageId]: its own, or the notice- /// that folds it in. Null while the message is not loaded.- String? _rowShowing(String id, String messageId) {- final message = _shownMessages(id)- .where((m) => m.id == messageId)- .firstOrNull;- if (message == null) return null;- // A step's row is a row of its own: no notice of the task folds it in.- if (message.conversationId != id) return message.id;- final shown = _ownShown(id);- return superTabTranscriptEntries(shown)- .lastWhere(- (e) => superTabMessageOrder(e.message, message) <= 0,- orElse: () => (message: message, interruptions: 0),- )- .message- .id;- }+ /// The row of [id]'s list that shows [messageId], its own. Null while the+ /// message is not loaded.+ String? _rowShowing(String id, String messageId) =>+ _shownMessages(id).any((m) => m.id == messageId) ? messageId : null;/// The top of [row] within the message list.double? _topInList(BuildContext row) {@@ -2507,10 +2488,7 @@ class _SuperTabViewState extends State<SuperTabView>if (_find != null && _findIn == id) return _findFocus.requestFocus();_closeFind(refocus: false);final find = SuperTabChatFind(- rows: () => [- for (final entry in superTabTranscriptEntries(_shownMessages(id)))- if (entry.interruptions == 0) entry.message,- ],+ rows: () => _shownMessages(id),hasOlder: () => c.hasOlder(id),readOlder: () async {final loaded = c.messages(id).length;@@ -4205,20 +4183,15 @@ class _SuperTabViewState extends State<SuperTabView>/// Where [id]'s list divides: the first row drawn when it opened. Older/// pages go above it and newer messages below, so neither moves the rows/// already there.- int _splitAt(- String id,- List<({SuperTabMessage message, int interruptions})> entries,- ) {- if (entries.isEmpty) return 0;+ int _splitAt(String id, List<SuperTabMessage> messages) {+ if (messages.isEmpty) return 0;final split = _split[id];final at = split == null? -1- : entries.indexWhere(- (e) => superTabMessageOrder(e.message, split) >= 0,- );+ : messages.indexWhere((m) => superTabMessageOrder(m, split) >= 0);if (at >= 0) return at;- _split[id] = entries.first.message;- c.keepFrom(id, entries.first.message);+ _split[id] = messages.first;+ c.keepFrom(id, messages.first);return 0;}@@ -4438,18 +4411,14 @@ class _SuperTabViewState extends State<SuperTabView>if (m.conversationId == c.selectedId) m,];final ownWithOutgoing = [...ownMessages, ...outgoing.map(_outgoingMessage)];- final entries = superTabTranscriptEntries(messages);final byId = {for (final message in messages) message.id: message};final rowIndex = {- for (final (index, entry) in entries.indexed)- _rowKey(c.messageIdentity(entry.message.id)): index,+ for (final (index, message) in messages.indexed)+ _rowKey(c.messageIdentity(message.id)): index,};// A row stays the same row as pages arrive above it, state and all.int? rowOf(Key key) => key is ValueKey<String> ? rowIndex[key.value] : null;- final split = _splitAt(- c.selectedId,- superTabTranscriptEntries(ownMessages),- );+ final split = _splitAt(c.selectedId, ownMessages);// Rows on their way group by the same rule, so a quick line keeps the// shape it will have once confirmed; one Not sent keeps its name and// actions.@@ -4464,12 +4433,8 @@ class _SuperTabViewState extends State<SuperTabView>// Find matches the rows as they are drawn now.final search = _findIn == c.selectedId ? (_find?..refresh()) : null;Widget row(int index) {- final entry = entries[index];- final message = entry.message;- final agent = message.fromAgent- ? c.snapshot?.agent(message.authorId)- : null;- final previous = index > 0 ? entries[index - 1].message : null;+ final message = messages[index];+ final previous = index > 0 ? messages[index - 1] : null;// Grouping is decided on the task's own rows; a step's row drawn between// two of them still ends the group, or the next would read as its agent's.final joined =@@ -4506,15 +4471,6 @@ class _SuperTabViewState extends State<SuperTabView>byId,grouped: joined,)- : entry.interruptions > 0- ? SuperTabRecordingNotice(- key: ValueKey('super-message-${message.id}'),- author: _shownAuthor(c, message),- count: entry.interruptions,- onOpenTerminal: agent == null- ? null- : () => _openAgent(agent),- ): _message(message,joined,@@ -4792,7 +4748,7 @@ class _SuperTabViewState extends State<SuperTabView>// Messages on their way end the list.(context, index) =>row(split + index),- childCount: entries.length - split,+ childCount: messages.length - split,findChildIndexCallback: (key) =>switch (rowOf(key)) {final i? when i >= split =>diff --git a/desktop/test/super_tab_activity_test.dart b/desktop/test/super_tab_activity_test.dartindex 6c6aeb72c..7abc7007b 100644--- a/desktop/test/super_tab_activity_test.dart+++ b/desktop/test/super_tab_activity_test.dart@@ -551,7 +551,7 @@ void main() {group('sidebar', () {for (final brightness in Brightness.values) {- testWidgets('Mentions counts the tag; a '+ testWidgets('Mentions is bold with the tag; a ''muted chat is greyed with its mark and no number ($brightness)', (tester,) async {@@ -564,9 +564,13 @@ void main() {await pumpSidebar(tester, c, brightness: brightness);expect(find.text('Notifications'), findsNothing);expect(inRow('super-mentions', find.text('Mentions')), findsOneWidget);- // Mentions counts the unread tag (#2887); the muted chat's own row- // carries no number.- expect(inRow('super-mentions', find.text('1')), findsOneWidget);+ // Mentions is bold for the unread tag (#2887) and carries no number+ // (task #3128); the muted chat's own row carries none either.+ expect(inRow('super-mentions', find.text('1')), findsNothing);+ expect(+ rowText(tester, 'super-mentions', 'Mentions').style?.fontWeight,+ grid.AppFont.semibold,+ );expect(find.byKey(const ValueKey('super-muted-lead')), findsOneWidget);expect(inRow('super-group-lead', find.byType(SuperTabCountBadge)),@@ -830,8 +834,8 @@ void main() {expect(activity.count, 1);});- testWidgets('before the tags and decisions are read, the sidebar counts '- 'the server\'s waiting ones', (tester) async {+ testWidgets('before the tags and decisions are read, the sidebar shows '+ 'the server\'s waiting ones bold', (tester) async {final server = withAgent();server.state['mentionsWaiting'] = 4;server.state['decisionsWaiting'] = 2;@@ -839,8 +843,18 @@ void main() {server.failMentions = true;final c = await openHere(server);await pumpSidebar(tester, c);- expect(inRow('super-decisions', find.text('2')), findsOneWidget);- expect(inRow('super-mentions', find.text('4')), findsOneWidget);+ for (final (row, label) in [+ ('super-decisions', 'Decisions'),+ ('super-mentions', 'Mentions'),+ ]) {+ expect(+ rowText(tester, row, label).style?.fontWeight,+ grid.AppFont.semibold,+ reason: row,+ );+ }+ expect(inRow('super-decisions', find.text('2')), findsNothing);+ expect(inRow('super-mentions', find.text('4')), findsNothing);await close(tester, c);});diff --git a/desktop/test/super_tab_decisions_test.dart b/desktop/test/super_tab_decisions_test.dartindex 66e986279..2a35f9f59 100644--- a/desktop/test/super_tab_decisions_test.dart+++ b/desktop/test/super_tab_decisions_test.dart@@ -89,6 +89,16 @@ Future<SuperTabController> showView(}Finder notificationsEntry() => find.byKey(const ValueKey('super-decisions'));++FontWeight? entryWeight(WidgetTester tester) => tester+ .widget<Text>(+ find.descendant(+ of: notificationsEntry(),+ matching: find.text('Decisions'),+ ),+ )+ .style+ ?.fontWeight;Finder option(String id, int index) =>find.byKey(ValueKey('super-decision-$id-$index'));Finder activityOption(String id, int index) =>@@ -313,10 +323,12 @@ void main() {(tester) async {final server = swarm()..ask(['Ship how?', 'Name it?']);await showView(tester, server);+ // Two waiting: the row is bold, with no number (task #3128).expect(find.descendant(of: notificationsEntry(), matching: find.text('2')),- findsOneWidget,+ findsNothing,);+ expect(entryWeight(tester), grid.AppFont.semibold);await tester.tap(notificationsEntry());await tester.pumpAndSettle();expect(find.text('Decisions'), findsWidgets);@@ -330,16 +342,14 @@ void main() {'decisionId': 'decision-2','choice': 1,});- // Answered, it leaves Needs you and the number.+ // Answered, it leaves Needs you; one still waits, so the row stays+ // bold.expect(find.byKey(const ValueKey('super-activity-row-decision:decision-2')),findsNothing,);expect(find.text('Ship how?'), findsOneWidget);- expect(- find.descendant(of: notificationsEntry(), matching: find.text('1')),- findsOneWidget,- );+ expect(entryWeight(tester), grid.AppFont.semibold);},);diff --git a/desktop/test/super_tab_mentions_test.dart b/desktop/test/super_tab_mentions_test.dartindex 0dd152543..2c72612bb 100644--- a/desktop/test/super_tab_mentions_test.dart+++ b/desktop/test/super_tab_mentions_test.dart@@ -577,7 +577,7 @@ void main() {group('notifications view', () {testWidgets(- 'the entry counts the unread tag; the Mentions tab lists only what is '+ 'the entry reads the unread tag; the Mentions tab lists only what is ''unread',(tester) async {final server = ConversationServer()@@ -590,11 +590,24 @@ void main() {..['resolvedBy'] = 'reply';server.state['mentionsWaiting'] = 1;await showView(tester, server);- // The Activity row counts the unread tag, as the Mentions tab does- // (#2887); the one answered before this server said where is read.+ // The Mentions row is bold for the unread tag, as the Mentions tab+ // lists it (#2887), and shows no number (task #3128); the one+ // answered before this server said where is read.expect(find.descendant(of: notificationsEntry(), matching: find.text('1')),- findsOneWidget,+ findsNothing,+ );+ expect(+ tester+ .widget<Text>(+ find.descendant(+ of: notificationsEntry(),+ matching: find.text('Mentions'),+ ),+ )+ .style+ ?.fontWeight,+ grid.AppFont.semibold,);await tester.tap(find.byKey(const ValueKey('super-mentions')));await tester.pumpAndSettle();diff --git a/desktop/test/super_tab_polish_test.dart b/desktop/test/super_tab_polish_test.dartindex 38cc0021a..40d59b805 100644--- a/desktop/test/super_tab_polish_test.dart+++ b/desktop/test/super_tab_polish_test.dart@@ -10,8 +10,6 @@ import 'package:flutter_test/flutter_test.dart';import 'package:harness/shared/theme/app_theme.dart' as grid;import 'package:harness/core/open_in_browser.dart';import 'package:harness/super_tabs/message_text.dart';-import 'package:harness/super_tabs/model.dart';-import 'package:harness/super_tabs/recording_notice.dart';import 'package:harness/super_tabs/view.dart';import 'support/super_tab_fixture.dart';@@ -249,40 +247,6 @@ void main() {},);- test('recording notices preserve authors, generations, chronology, replies and delivery records', () {- final server = ConversationServer();- gap(server);- gap(server);- gap(server);- server.append('A real update');- gap(server);- gap(server, author: 'builder');- gap(server, author: 'builder');- server.messages.last['author']['membershipGeneration'] = 2;- gap(server, author: 'builder');- server.messages.last['createdAt'] = '2026-10-19T00:00:00Z';- gap(server, author: 'builder');- server.messages.last['replyTo'] = 'message-4';- gap(server, author: 'builder');- server.messages.last['deliveries'] = [- {'id': 'receipt', 'status': 'uncertain'},- ];- final messages = server.messages.map(SuperTabMessage.fromJson).toList();- final entries = superTabTranscriptEntries(messages);- expect(entries.map((e) => e.interruptions), [3, 0, 1, 1, 1, 1, 0, 0]);- expect(entries.map((e) => e.message.id), [- 'message-1',- 'message-4',- 'message-5',- 'message-6',- 'message-7',- 'message-8',- 'message-9',- 'message-10',- ]);- expect(messages.length, 10);- });-for (final profile in [(name: 'dark',@@ -313,7 +277,6 @@ void main() {addTearDown(() => grid.AppTheme.brightness.value = previous);final server = polishFixture(), c = server.controller();await c.refresh();- var opened = '';final boundary = GlobalKey();await tester.pumpWidget(RepaintBoundary(@@ -334,7 +297,7 @@ void main() {onInvite: () {},onAddAgent: (_) {},onNewProject: () {},- onOpenTerminal: (agent) => opened = agent.id,+ onOpenTerminal: (_) {},machineName: (_) => 'M2',),),@@ -342,13 +305,9 @@ void main() {),);await tester.pumpAndSettle();- expect(find.byType(SuperTabRecordingNotice), findsOneWidget);- await tester.ensureVisible(find.byType(SuperTabRecordingNotice));- await tester.pumpAndSettle();- await tester.tap(find.text('Open terminal'));- await tester.pumpAndSettle();- expect(opened, 'lead-agent');- expect(c.messages('lead').length, 11);+ // The fixture's recording gap is no row (task #3127).+ expect(find.textContaining('recording was interrupted'), findsNothing);+ expect(c.messages('lead').length, 5);expect(tester.takeException(), isNull);Future<void> shot(String suffix) async {if (capture == null) return;diff --git a/desktop/test/super_tab_quiet_polish_test.dart b/desktop/test/super_tab_quiet_polish_test.dartindex ab0757686..bcd68cc9d 100644--- a/desktop/test/super_tab_quiet_polish_test.dart+++ b/desktop/test/super_tab_quiet_polish_test.dart@@ -52,11 +52,11 @@ void main() {await tester.pump(const Duration(milliseconds: 300));});- testWidgets("a project's red number ends where Activity's does", (+ testWidgets("a project's red number stays while Decisions shows none", (tester,) async {- // Activity's number is what was asked of the reader: a decision. The- // project row counts it with the tag, and both numbers end at one edge.+ // What was asked of the reader is a decision: the project row counts it+ // with the tag, and the Decisions row carries no number (task #3128).final server = swarm()..followedThreads = null;server.tag('message-1');server.ask(['Ship it?'], conversationId: 'lead');@@ -65,10 +65,8 @@ void main() {of: _key('super-decisions'),matching: find.byType(SuperTabCountBadge),);- expect(- tester.getTopRight(_key('super-mentions-lead')).dx,- tester.getTopRight(activity).dx,- );+ expect(activity, findsNothing);+ expect(_key('super-mentions-lead'), findsOneWidget);});testWidgets('a private project keeps its leading lock and mention number 'diff --git a/desktop/test/super_tab_recording_gap_rows_test.dart b/desktop/test/super_tab_recording_gap_rows_test.dartnew file mode 100644index 000000000..7dbd0f426--- /dev/null+++ b/desktop/test/super_tab_recording_gap_rows_test.dart@@ -0,0 +1,77 @@+import 'package:flutter_test/flutter_test.dart';++import 'super_tab_mentions_test.dart' show showView;+import 'super_tab_quiet_chat_test.dart' show project, row;++// Dee, 11-05 (task #3127): #lamp-gtm showed "Nico's terminal recording was+// interrupted 4 times. Open terminal", which gives a person nothing to do. A+// terminal's recording gap is no chat row and nothing unread; the server keeps+// it for diagnosis, and a required recovery still reaches the coordinator.++const _gapText =+ 'Some terminal activity could not be recorded. '+ 'Check the native session for the full conversation.';+const _recoveryText =+ 'Nico\'s terminal recording on "Lamp GTM" has a gap. '+ 'The work was interrupted by a restart of the terminal recording.';++Map<String, dynamic> _gap(int sequence) => row(+ 'gap-$sequence',+ sequence,+ _gapText,+ kind: 'native',+ source: {'phase': 'gap'},+);++Map<String, dynamic> _recovery(int sequence) => {+ ...row(+ 'recovery-$sequence',+ sequence,+ _recoveryText,+ kind: 'native',+ source: {+ 'phase': 'gap',+ 'recovery': {'reason': 'recording_restarted', 'required': true},+ },+ ),+ 'deliveries': [+ {'id': 'to-lead', 'status': 'delivered'},+ ],+};++void main() {+ testWidgets('a run of recording gaps is no chat row', (tester) async {+ final c = await showView(+ tester,+ project([+ row('m1', 1, 'A real update'),+ _gap(2),+ _gap(3),+ _recovery(4),+ _gap(5),+ ]),+ );+ await c.loadMessages('lead');+ await tester.pumpAndSettle();+ expect(find.text('A real update'), findsOneWidget);+ expect(find.textContaining('recording was interrupted'), findsNothing);+ expect(find.text('Terminal recording interrupted'), findsNothing);+ expect(find.text(_gapText), findsNothing);+ expect(find.textContaining('has a gap'), findsNothing);+ expect(find.text('Open terminal'), findsNothing);+ expect(tester.takeException(), isNull);+ });++ testWidgets('a chat whose only new rows are recording gaps shows as read', (+ tester,+ ) async {+ final server = project([row('m1', 1, 'Hello'), _gap(2), _gap(3)], read: 1);+ final c = server.controller();+ await c.refresh();+ addTearDown(c.dispose);+ await c.loadMessages('lead');+ final lead = c.snapshot!.conversation('lead')!;+ expect(c.unread(lead), isFalse);+ expect(c.unreadCount(lead), 0);+ });+}diff --git a/desktop/test/super_tab_sidebar_cleanup_test.dart b/desktop/test/super_tab_sidebar_cleanup_test.dartindex d9d890a6c..aa768630a 100644--- a/desktop/test/super_tab_sidebar_cleanup_test.dart+++ b/desktop/test/super_tab_sidebar_cleanup_test.dart@@ -86,10 +86,10 @@ void main() {// Dock. The rest moved// into Manage, at the foot (Quiet Swarm, screen 1).for (final platform in [TargetPlatform.macOS, TargetPlatform.linux]) {- testWidgets('the top reads Decisions with its count of asks, Mentions and '- 'Threads, and Manage is at the foot', (tester) async {+ testWidgets('the top reads Decisions, Mentions and Threads without '+ 'counts, and Manage is at the foot', (tester) async {final c = await showSwarm(tester);- expect(topRows(tester), ['Decisions1', 'Mentions', 'Threads']);+ expect(topRows(tester), ['Decisions', 'Mentions', 'Threads']);expect(tester.getTopLeft(find.byKey(const ValueKey('super-manage'))).dy,greaterThan(tester.getTopLeft(find.text('Projects')).dy),diff --git a/desktop/test/super_tab_sidebar_pages_test.dart b/desktop/test/super_tab_sidebar_pages_test.dartindex 759d8bfa0..b1efd73ee 100644--- a/desktop/test/super_tab_sidebar_pages_test.dart+++ b/desktop/test/super_tab_sidebar_pages_test.dart@@ -1,20 +1,30 @@+import 'dart:io';+import 'package:flutter/material.dart';+import 'package:flutter/rendering.dart';import 'package:flutter_test/flutter_test.dart';import 'package:harness/shared/theme/app_icons.dart';import 'package:harness/shared/theme/app_theme.dart' as grid;import 'package:harness/state/app_state.dart';+import 'package:harness/widgets/desktop_chrome.dart';import 'package:harness/super_tabs/activity.dart';import 'package:harness/super_tabs/buddy_rows.dart' show SuperTabCountBadge;import 'package:harness/super_tabs/places.dart';import 'package:harness/super_tabs/project_sidebar.dart';import 'super_tab_activity_lists_test.dart' show load, swarm, unreadThread;+import 'support/capture.dart';import 'swarm_state_test.dart' show createApp;+/// Set to a folder to write the PR's before and after pictures there.+final shots = Platform.environment['SUPER_TAB_SIDEBAR_SHOTS'];+/// The sidebar of task #2996 (anh Dee, 11-05): Decisions, Mentions and/// Threads under the Swarm, each one thing; Buddy first under Projects; the/// back and forward arrows at the top.void main() {+ setUpAll(() => loadCaptureFonts(shots));+Finder key(String k) => find.byKey(ValueKey(k));Finder inRow(String row, Finder what) =>find.descendant(of: key(row), matching: what);@@ -22,13 +32,17 @@ void main() {Future<({SuperTabActivity activity, List<SwarmPage> opened})> show(WidgetTester tester, {SwarmPage? page,+ bool waiting = true,+ GlobalKey? picture,}) async {final server = swarm()..state['swarmBuddy'] = true;- server.ask(['Ship it?']);- server.tag('message-1');- server.tag('message-2');+ if (waiting) {+ server.ask(['Ship it?']);+ server.tag('message-1');+ server.tag('message-2');+ }server.followedThreads = {- 'unread': [unreadThread('message-1')],+ 'unread': [if (waiting) unreadThread('message-1')],'read': [],'more': false,};@@ -42,19 +56,22 @@ void main() {await tester.pumpWidget(MaterialApp(theme: grid.buildAppTheme(brightness: Brightness.dark),- home: Scaffold(- body: ProjectSidebar(- controller: c,- app: app,- onSelect: c.select,- onNewSwarm: () {},- onNewProject: () {},- onPage: opened.add,- page: page,- activity: activity,- attention: activity.attention,- places: SuperTabPlaces.of(c),- onManage: () {},+ home: RepaintBoundary(+ key: picture,+ child: Scaffold(+ body: ProjectSidebar(+ controller: c,+ app: app,+ onSelect: c.select,+ onNewSwarm: () {},+ onNewProject: () {},+ onPage: opened.add,+ page: page,+ activity: activity,+ attention: activity.attention,+ places: SuperTabPlaces.of(c),+ onManage: () {},+ ),),),),@@ -94,23 +111,78 @@ void main() {expect(inRow('super-threads', find.text('Threads')), findsOneWidget);});- testWidgets('Decisions and Mentions have red counts; Threads is bold with '- 'a plain count, never red', (tester) async {+ // Anh Dee, 11-05, task #3128: each page row is bold at full strength while+ // something waits and grey when nothing does; no number, no red circle.+ FontWeight? weight(WidgetTester tester, String row, String label) =>+ tester.widget<Text>(inRow(row, find.text(label))).style?.fontWeight;+ Color? ink(WidgetTester tester, String row, String label) =>+ tester.widget<Text>(inRow(row, find.text(label))).style?.color;+ const rows = [+ ('super-decisions', 'Decisions'),+ ('super-mentions', 'Mentions'),+ ('super-threads', 'Threads'),+ ];++ testWidgets('Decisions, Mentions and Threads are grey and regular with '+ 'nothing waiting', (tester) async {+ await show(tester, waiting: false);+ for (final (row, label) in rows) {+ expect(ink(tester, row, label), grid.SidebarInk.inkMuted, reason: row);+ expect(weight(tester, row, label), isNot(grid.AppFont.semibold));+ }+ });++ testWidgets('Decisions, Mentions and Threads are bold at full strength '+ 'while something waits', (tester) async {await show(tester);- SuperTabCountBadge badge(String row) => tester.widget<SuperTabCountBadge>(- inRow(row, find.byType(SuperTabCountBadge)),- );- expect(badge('super-decisions').count, 1);- expect(badge('super-mentions').count, 2);- expect(- inRow('super-threads', find.byType(SuperTabCountBadge)),- findsNothing,- );- expect(inRow('super-threads', find.text('1')), findsOneWidget);- final label = tester.widget<Text>(- inRow('super-threads', find.text('Threads')),- );- expect(label.style?.fontWeight, grid.AppFont.semibold);+ expect(grid.SidebarInk.ink, isNot(grid.SidebarInk.inkMuted));+ for (final (row, label) in rows) {+ expect(ink(tester, row, label), grid.SidebarInk.ink, reason: row);+ expect(weight(tester, row, label), grid.AppFont.semibold, reason: row);+ }+ });++ testWidgets('no page row carries a number or a red circle, waiting or not', (+ tester,+ ) async {+ for (final waiting in [true, false]) {+ await show(tester, waiting: waiting);+ for (final (row, _) in rows) {+ expect(+ inRow(row, find.byType(SuperTabCountBadge)),+ findsNothing,+ reason: '$row, waiting: $waiting',+ );+ expect(+ inRow(+ row,+ find.byWidgetPredicate(+ (w) => w is Text && RegExp(r'^\d+$').hasMatch(w.data ?? ''),+ ),+ ),+ findsNothing,+ reason: '$row, waiting: $waiting',+ );+ }+ await tester.pumpWidget(const SizedBox());+ }+ });++ testWidgets('a selected row stays at full strength with nothing waiting', (+ tester,+ ) async {+ await show(tester, page: SwarmPage.decisions, waiting: false);+ expect(ink(tester, 'super-decisions', 'Decisions'), grid.SidebarInk.ink);+ expect(ink(tester, 'super-mentions', 'Mentions'), grid.SidebarInk.inkMuted);+ });++ testWidgets('the Swarm switcher is set apart from the three rows by a '+ 'spacing token, the other rows keeping their gap', (tester) async {+ await show(tester);+ double bottom(String k) => tester.getBottomLeft(key(k)).dy;+ final gap = top(tester, 'super-decisions') - bottom('super-swarm-switcher');+ final rowGap = top(tester, 'super-mentions') - bottom('super-decisions');+ expect(gap - rowGap, DesktopChrome.controlGap);});testWidgets('each row opens its page, and the open one is selected', (@@ -172,4 +244,22 @@ void main() {await tester.tap(key('super-back'));expect(places.takeStep(), const SuperTabPlace.page(SwarmPage.threads));});++ // The PR's picture (task #3128): the sidebar with nothing waiting and with+ // something waiting. Writes nothing unless SUPER_TAB_SIDEBAR_SHOTS is set.+ for (final waiting in [false, true]) {+ testWidgets('picture of the sidebar, ${waiting ? 'something' : 'nothing'} '+ 'waiting', (tester) async {+ if (shots == null) return;+ tester.view.devicePixelRatio = 2;+ final picture = GlobalKey();+ await show(tester, waiting: waiting, picture: picture);+ await captureBoundary(+ tester,+ picture.currentContext!.findRenderObject()! as RenderRepaintBoundary,+ shots,+ 'sidebar-${waiting ? 'waiting' : 'nothing-waiting'}',+ );+ });+ }}diff --git a/desktop/test/theme_sidebar_ink_test.dart b/desktop/test/theme_sidebar_ink_test.dartindex 32b54ce9c..7814e0ad5 100644--- a/desktop/test/theme_sidebar_ink_test.dart+++ b/desktop/test/theme_sidebar_ink_test.dart@@ -247,8 +247,8 @@ void main() {_expectReadable(_inks(tester, sidebar, ground), 'Cloud\'s sidebar');});- testWidgets('on Plum, Threads, Mentions and Decisions read too, counts '- 'and arrows included', (tester) async {+ testWidgets('on Plum, Threads, Mentions and Decisions read too, arrows '+ 'included', (tester) async {_wear(HarnessPalette.plum);final server = swarm()..state['swarmBuddy'] = true;server.ask(['Ship it?']);@@ -286,9 +286,10 @@ void main() {await tester.pump();addTearDown(() => tester.pumpWidget(const SizedBox()));final threads = find.byKey(const ValueKey('super-threads'));+ // No number on a page row (task #3128): it is bold instead.expect(find.descendant(of: threads, matching: find.text('1')),- findsOneWidget,+ findsNothing,);_expectReadable(_inks(tester, find.byType(ProjectSidebar), HarnessPalette.plum.sidebar),diff --git a/docs/plans/2026-11-04-phone-picture-test-load-race-plan.md b/docs/plans/2026-11-04-phone-picture-test-load-race-plan.mdnew file mode 100644index 000000000..86b70ca4f--- /dev/null+++ b/docs/plans/2026-11-04-phone-picture-test-load-race-plan.md@@ -0,0 +1,71 @@+# A phone picture test never deletes a picture file while its image is still loading Implementation Plan++> Implemented by the task's Engineer task by task, each failing test committed before its code (project instructions,+> Engineer). One independent review on the pull request.++**Goal:** A picture test in `swarm_attachment_test.dart` no longer fails with `PathNotFoundException ... resolving an+image codec` because its temp files went while an image was still being read from them. Seen in batch #2952's second CI+attempt: "open full screen, the picture goes with its account: a Swarm leaving the account's list closes it at once,+and lets the picture go" (task #2883, River, 2026-11-04).++**Architecture:** `opened` waits until the viewer's picture is in the image cache (`containsKey`), which is true as soon+as its load is *pending*, so the test went on to `store.clear()` / `keepOnly()` (a real recursive delete) while+`FileImage._loadAsync` had not yet opened the file. Two parts:++1. `picturesLoaded(tester)` (mobile/test/swarm/picture_loads.dart) waits, in real time, until every picture on screen+ has finished loading (decoded, or failed): it asks the image cache whether each `Image`'s key is still pending.+2. `opened` and `closed` call it, so no test deletes or tears down the temp folder under a load. A fixture gate on the+ fake store's file reads (`PictureReads`) holds a load open, so the race is forced rather than waited for.++**Tech Stack:** Flutter 3.47.2, flutter_test, package:file; test code only.++**Spec:** task #2883's brief. No app code changes.++## Global Constraints++- Test code only (mobile/test). No change in mobile/lib.+- Red first: the new test is committed failing before the helper that fixes it.+- No fixed sleeps: the tests wait for the load, and a held load is released by the test.+- Temp folders only from `createTempSync` (already the case).++## Design++- growth: N/A because nothing is stored.+- concurrency: the point of the change; teardown and deletes follow the load, not the other way round.+- read cost: N/A.+- scale: N/A.+- compatibility: N/A because no wire or saved format changes.+- migration + rollback: N/A; revert the commits.+- audience: N/A.+- identity: N/A.+- failure: a load that never finishes fails the helper's bounded wait with a reason, not a hang.+- platforms: macOS (local) and Linux (CI), where the failure was seen.++## Review Focus++- `picturesLoaded` cannot return early on an image whose key is not yet tracked (no `Image` is built in that case).+- Held reads are off by default: every other test sees the plain store.++## Task 1: a held load is waited for before the folder goes++**Files:** mobile/test/swarm/swarm_attachment_fakes.dart, mobile/test/swarm/picture_loads.dart,+mobile/test/swarm/picture_loads_test.dart++**Interfaces:** `PictureReads` (`hold`, `asked`), `storeIn(..., reads:)`, `bool picturesLoading(WidgetTester)`,+`Future<void> picturesLoaded(WidgetTester)`.++- [ ] Test: with the viewer's read held, `picturesLoading` is true; released, `picturesLoaded` returns, and clearing the+ store then leaves no error.+- [ ] Run red (stub says nothing is loading), commit; implement; run green, commit.++## Task 2: the picture tests wait for their loads++**Files:** mobile/test/swarm/swarm_attachment_test.dart++- [ ] `opened` waits with `picturesLoaded` instead of `containsKey`; `closed` calls it before the chat goes.+- [ ] Forced: the same tests with every read held a moment pass; without Task 2 they fail with the CI error.++## Evidence++- The CI failure reproduced by slowing every read (old `opened`/`closed`), then green with the fix; the phone suite+ green.diff --git a/docs/plans/2026-11-05-recording-gaps-plan.md b/docs/plans/2026-11-05-recording-gaps-plan.mdnew file mode 100644index 000000000..86b6080af--- /dev/null+++ b/docs/plans/2026-11-05-recording-gaps-plan.md@@ -0,0 +1,66 @@+# Recording gaps out of chats, and one gap per restart: plan++**Goal:** Chats on Desktop and the phone stop drawing terminal-recording gaps ("Nico's terminal recording was interrupted 4+times. Open terminal"), and the recorder reports a restart of Harness as at most one gap, none when nothing was lost+(task #3127, requested by Dee).++**Architecture:** The cause, from the code and this Mac's harness.log (CLI 0.5.43 at 11:32 and 0.5.44 at 12:31 VN, each a+core restart): the core's observer of native turns (cli/src/lib/nativeTurnObservations.ts) starts a new epoch whenever it+forgets an agent: a core restart, and also every history replay or turn resumed at attach (core/turns/funnel.ts passes+`replay || resumed`), which a restart's re-attach, a re-attach from the start or Claude's compaction bring. The recorder+(cli/src/superTabs/native.ts `capture`) reads each new epoch as `recording_restarted` and posts one gap **for every view it+holds of that agent**, open or not, whether or not a recorded turn was unfinished. Two views of one terminal across a+restart and the replay right after it make four gaps in seconds, the line Dee saw. The fix:++1. An epoch change is a loss only for a view whose recorded turn is unfinished (its prompt recorded, its answer not): that+ view, once, gets the gap. Idle views get none. An agent has at most one unfinished turn, and the restart clears it, so a+ replay right after adds nothing: one restart, at most one gap.+2. Desktop and the phone list no native `gap` row, as they already list no native `prompt` row (#2849): no chat row and+ nothing unread. The rows stay stored on the server, readable by `messages` for diagnosis, and a required recovery+ still reaches the coordinator as its delivery. The "interrupted N times" notice and its folding go.++**Tech Stack:** TypeScript (cli, vitest), Dart/Flutter (desktop, mobile).++**Spec:** task #3127 brief.++## Global Constraints++- Swarm code stays out of cli/src/core; the core's observer is unchanged.+- Journal and wire format unchanged: older saved outboxes and backends keep working.+- Desktop tests use a memory store and a fake sign-in; run check-ui-style and the laid-out list tests before Ready.++## Review Focus++- A prompt submitted in the instant before a reset, not yet seen as a turn, is not reported: the recorder never saw it.+ The person who typed it is watching that terminal. Every other loss still reports (history lost, unattributed input,+ expired view, agent stopped, answer without prompt).+- A view expired but kept for its unfinished turn still gets that turn's gap.+- A chat whose only new rows are gaps reads as read, and marking read passes over them (as for prompts).++## Task 1: the recorder reports a restart once, and not at all when nothing was unfinished++**Files:** Modify `cli/src/superTabs/native.ts` (`capture`); Test `cli/src/superTabs/native.spec.ts`.++- [ ] Failing tests: `a restart with no unfinished recorded turn records no gap` (alpha, beta prepared; alpha's prompt and+ answer recorded; `observer.ingest('harness', [], true)`; capture, flush: sent kinds `['prompt', 'answer']`), and+ `one restart and the replay after it give one gap, for the view whose turn it cut` (alpha's prompt open, beta idle;+ reset, capture, reset again, capture, flush: sent kinds `['prompt', 'gap']`, the gap on alpha).+- [ ] Run `npx vitest run src/superTabs/native.spec.ts` in cli: both fail (4 and 2 gaps). Commit.+- [ ] In `capture`, on `page.gap` with a new epoch, gap only the contexts in `Object.values(row.turns)`; history lost and+ unattributed input keep gapping every view. Run the spec: all pass. Commit.++## Task 2: chats list no recording gap++**Files:** Modify `desktop/lib/super_tabs/model.dart`, `controller.dart` (`_listed`), `view.dart` (drop+`superTabTranscriptEntries` and the notice); delete `desktop/lib/super_tabs/recording_notice.dart`; modify+`mobile/lib/swarm/model.dart`, `mobile/lib/swarm/swarm_conversation.dart` (`stream`). Tests:+`desktop/test/super_tab_recording_gap_rows_test.dart` (new), `desktop/test/super_tab_polish_test.dart`,+`mobile/test/swarm/swarm_special_rows_test.dart`.++- [ ] Failing tests: Desktop `a run of recording gaps is no chat row` (four gaps, one a required recovery with a+ delivery: no "recording was interrupted", no "Terminal recording interrupted", no gap text; the real message shows),+ `a chat whose only new rows are recording gaps shows as read`; phone `a recording gap is no chat row`.+- [ ] Run them (`flutter test` on each file): they fail. Commit.+- [ ] Add `bool get terminalGap => fromTerminal && source['phase'] == 'gap'` to both models; leave it out of Desktop's+ `_listed` and the phone's `stream`; remove the notice, its folding and its polish-test cases. Run the tests, the polish+ and laid-out list tests and check-ui-style: all pass. Commit.diff --git a/mobile/lib/swarm/model.dart b/mobile/lib/swarm/model.dartindex c20fdb8c8..f35f21bc3 100644--- a/mobile/lib/swarm/model.dart+++ b/mobile/lib/swarm/model.dart@@ -1464,6 +1464,11 @@ class SuperTabMessage {/// What was typed into an agent's terminal, a scheduled prompt too: no chat/// row (Ken 11-04, task #2849; the desktop's). Its answer still is one.bool get terminalPrompt => fromTerminal && source['phase'] == 'prompt';++ /// A terminal's recording gap: no chat row and nothing unread, since it gives+ /// a person nothing to do (Dee 11-05, task #3127). The server keeps it for+ /// diagnosis, and a required recovery still reaches the coordinator.+ bool get terminalGap => fromTerminal && source['phase'] == 'gap';SuperTabRoute? get route => SuperTabRoute.fromSource(source);bool get routeOverride => source['kind'] == 'route-override';diff --git a/mobile/lib/swarm/swarm_conversation.dart b/mobile/lib/swarm/swarm_conversation.dartindex 73db4eac8..1c71f645a 100644--- a/mobile/lib/swarm/swarm_conversation.dart+++ b/mobile/lib/swarm/swarm_conversation.dart@@ -179,13 +179,15 @@ class SwarmConversation extends ChangeNotifier/// The [messages] the chat lists: a reply only in its thread shows there/// alone ([SuperTabMessage.inMainStream], the desktop's main stream), and- /// what was typed into a terminal is no row- /// ([SuperTabMessage.terminalPrompt]).+ /// what was typed into a terminal or a gap in its recording is no row+ /// ([SuperTabMessage.terminalPrompt], [SuperTabMessage.terminalGap]).List<SuperTabMessage> get stream {if (!identical(_streamOf, messages)) {_streamOf = messages;_stream = List.unmodifiable(- messages.where((m) => m.inMainStream && !m.terminalPrompt),+ messages.where(+ (m) => m.inMainStream && !m.terminalPrompt && !m.terminalGap,+ ),);}return _stream;diff --git a/mobile/test/media_preview_page_test.dart b/mobile/test/media_preview_page_test.dartindex b252e9b31..9f60181ee 100644--- a/mobile/test/media_preview_page_test.dart+++ b/mobile/test/media_preview_page_test.dart@@ -10,6 +10,7 @@ import 'package:share_plus/share_plus.dart';import 'package:video_player/video_player.dart';import 'phone_edge/edge_fixture.dart';+import 'swarm/picture_loads.dart';/// A picture or video an agent printed, downloaded and shown in the app — the page a tap on a/// terminal's media link opens. Real files in a temporary folder, a share sheet and a player that@@ -267,6 +268,8 @@ void main() {final shot = file('shot.png', _png);await tester.pumpWidget(host(shot.path));await open(tester);+ // The folder goes with the test: after the picture is read.+ await picturesLoaded(tester);expect(find.byType(MediaPreviewPage), findsOneWidget);expect(find.text('terminal'), findsNothing);@@ -282,6 +285,7 @@ void main() {final shot = file('shot.png', _png);await tester.pumpWidget(host(shot.path));await open(tester);+ await picturesLoaded(tester);await tester.binding.handlePopRoute();await tester.pump();@@ -297,6 +301,7 @@ void main() {final shot = file('shot.png', _png);await tester.pumpWidget(host(shot.path));await open(tester);+ await picturesLoaded(tester);final pictureRoute =ModalRoute.of(tester.element(find.byType(MediaPreviewPage)))!as CupertinoPageRoute<void>;diff --git a/mobile/test/swarm/picture_loads.dart b/mobile/test/swarm/picture_loads.dartnew file mode 100644index 000000000..0ecd78dd4--- /dev/null+++ b/mobile/test/swarm/picture_loads.dart@@ -0,0 +1,35 @@+import 'package:flutter/widgets.dart';+import 'package:flutter_test/flutter_test.dart';++/// Whether a picture on screen is still loading: its load asked for, not yet+/// decoded or failed. The image cache counts a picture as there from the+/// moment its load is asked for, so a test that goes on once the cache has it+/// can delete the file a load has not yet opened ('PathNotFoundException ...+/// resolving an image codec', task #2883).+bool picturesLoading(WidgetTester tester) {+ for (final element in find.byType(Image, skipOffstage: false).evaluate()) {+ final provider = (element.widget as Image).image;+ // File pictures answer with their key at once.+ Object? key;+ provider.obtainKey(ImageConfiguration.empty).then((value) => key = value);+ if (key == null) {+ throw StateError('${provider.runtimeType} has no key to look up at once');+ }+ if (PaintingBinding.instance.imageCache.statusForKey(key!).pending) {+ return true;+ }+ }+ return false;+}++/// Real time (a load reads a file and decodes, outside the test's fake clock),+/// a frame after each step, until no picture on screen is loading.+Future<void> picturesLoaded(WidgetTester tester) async {+ for (var i = 0; i < 100 && picturesLoading(tester); i++) {+ await tester.runAsync(+ () => Future<void>.delayed(const Duration(milliseconds: 10)),+ );+ await tester.pump();+ }+ expect(picturesLoading(tester), isFalse, reason: 'a picture never loaded');+}diff --git a/mobile/test/swarm/swarm_attachment_fakes.dart b/mobile/test/swarm/swarm_attachment_fakes.dartindex d38164b3f..be6d49904 100644--- a/mobile/test/swarm/swarm_attachment_fakes.dart+++ b/mobile/test/swarm/swarm_attachment_fakes.dart@@ -1,8 +1,10 @@import 'dart:async';import 'dart:convert';import 'dart:io' as io;+import 'dart:typed_data';import 'package:file/file.dart' hide FileSystem;+import 'package:file/file.dart' as pkg show FileSystem;import 'package:file/local.dart';import 'package:flutter_cache_manager/flutter_cache_manager.dart';import 'package:harness_mobile/swarm/swarm_attachment_store.dart';@@ -65,34 +67,86 @@ class _Answer implements FileServiceResponse {String get fileExtension => '.png';}+/// The reads of kept files, as a picture's load makes them: how many were+/// asked, and a way to hold each one open before it touches the disk, as a+/// slow phone does. A test that deletes the files while one is held has the+/// load meet a file that is gone (task #2883).+class PictureReads {+ /// Set to hold every read until it completes.+ Completer<void>? hold;++ /// The reads asked for so far, held or not.+ int asked = 0;+}+/// Files under [folder], where the app keeps them under its temporary folder.class _Folder implements FileSystem {- _Folder(this.folder);+ _Folder(this.folder, this.reads);final io.Directory folder;+ final PictureReads? reads;@overrideFuture<File> createFile(String name) async {final directory = const LocalFileSystem().directory(folder.path);await directory.create(recursive: true);- return directory.childFile(name);+ final file = directory.childFile(name);+ final reads = this.reads;+ return reads == null ? file : _ReadFile(file, directory.fileSystem, reads);+ }+}++/// A kept file whose reads go through [PictureReads].+class _ReadFile extends ForwardingFileSystemEntity<File, io.File>+ with ForwardingFile {+ _ReadFile(this.delegate, this.fileSystem, this._reads);++ @override+ final io.File delegate;++ @override+ final pkg.FileSystem fileSystem;++ final PictureReads _reads;++ @override+ ForwardingFile wrap(io.File delegate) =>+ _ReadFile(delegate, fileSystem, _reads);++ @override+ Directory wrapDirectory(io.Directory delegate) =>+ fileSystem.directory(delegate.path);++ @override+ File wrapFile(io.File delegate) => wrap(delegate);++ @override+ Link wrapLink(io.Link delegate) => fileSystem.link(delegate.path);++ @override+ Future<Uint8List> readAsBytes() async {+ _reads.asked++;+ await _reads.hold?.future;+ return delegate.readAsBytes();}}/// A store over [root] and [storage], as the app's is over its temporary/// folder and the network. [reaching], when given, runs each time the store-/// asks for [root], as the app's asks the platform for its folder.+/// asks for [root], as the app's asks the platform for its folder. [reads],+/// when given, sees every read of a kept file.SwarmAttachmentStore storeIn(io.Directory root,FileService storage, {Future<void> Function()? reaching,+ PictureReads? reads,}) => SwarmAttachmentStore(root: () async {await reaching?.call();return root;},fileService: storage,- files: (folder) => _Folder(folder),+ files: (folder) => _Folder(folder, reads),);/// The files kept under [root], by their path below it.diff --git a/mobile/test/swarm/swarm_attachment_test.dart b/mobile/test/swarm/swarm_attachment_test.dartindex b00e5cabe..a149f1dfb 100644--- a/mobile/test/swarm/swarm_attachment_test.dart+++ b/mobile/test/swarm/swarm_attachment_test.dart@@ -11,6 +11,7 @@ import 'package:harness_mobile/swarm/swarm_attachment_store.dart';import 'package:harness_mobile/swarm/swarm_file_download.dart';import '../temp_folder.dart';+import 'picture_loads.dart';import 'swarm_attachment_fakes.dart';/// A picture in a chat shows in place, as Slack shows one (Dee, 10-29): a@@ -21,6 +22,7 @@ import 'swarm_attachment_fakes.dart';void main() {late Directory root;late FakeFileStorage storage;+ late PictureReads reads;late SwarmAttachmentStore store;final link = Uri.parse('https://cdn.example/swarm/a.png');@@ -37,7 +39,8 @@ void main() {setUp(() {root = Directory.systemTemp.createTempSync('swarm-attachments-');storage = FakeFileStorage();- store = storeIn(root, storage);+ reads = PictureReads();+ store = storeIn(root, storage, reads: reads);});// A test can end with a fetch still writing its picture in.tearDown(() => deleteTempFolder(root));@@ -96,9 +99,11 @@ void main() {expect(done(), isTrue);}- /// Ends a test that fetched: the chat closed, and the cache's own cleanup,+ /// Ends a test that fetched: its pictures loaded, the chat closed, and the cache's own cleanup,/// which it runs every few seconds, let run.Future<void> closed(WidgetTester tester) async {+ // A picture still loading when its file goes fails the test, after it.+ await picturesLoaded(tester);await tester.pumpWidget(const SizedBox());await tester.pump(const Duration(minutes: 1));}@@ -389,10 +394,9 @@ void main() {final key = (await tester.runAsync(() => picture.obtainKey(ImageConfiguration.empty),))!;- await until(- tester,- () => PaintingBinding.instance.imageCache.containsKey(key),- );+ // Asked for is not read: the account's files go next.+ await picturesLoaded(tester);+ expect(PaintingBinding.instance.imageCache.containsKey(key), isTrue);return key;}@@ -511,6 +515,37 @@ void main() {await closed(tester);});+ // The race behind a flake in CI (task #2883): a picture counted as loaded+ // once its load was asked for, and the files went while the load had not+ // yet opened its file ('PathNotFoundException ... resolving an image+ // codec'). Here the load is held open, so it is forced, not waited for.+ testWidgets('a picture still being read is waited for, and the account\'s '+ 'files go after it', (tester) async {+ await pump(tester);+ await until(tester, () => drawn(tester));+ expect(picturesLoading(tester), isFalse, reason: 'the preview is drawn');++ reads.hold = Completer();+ await tester.tap(preview);+ await tester.pumpAndSettle();+ await until(tester, () => reads.asked == 2);+ expect(+ picturesLoading(tester),+ isTrue,+ reason: 'the full screen picture is asked for, not read',+ );++ reads.hold!.complete();+ await picturesLoaded(tester);+ expect(picturesLoading(tester), isFalse);++ // Now the files can go: nothing reads them after.+ var changed = false;+ unawaited(store.clear().whenComplete(() => changed = true));+ await until(tester, () => changed);+ await closed(tester);+ });+testWidgets('the same account kept again leaves it open', (tester) async {await opened(tester);diff --git a/mobile/test/swarm/swarm_file_links_test.dart b/mobile/test/swarm/swarm_file_links_test.dartindex eaa5f6fa9..c5d10bba1 100644--- a/mobile/test/swarm/swarm_file_links_test.dart+++ b/mobile/test/swarm/swarm_file_links_test.dart@@ -12,6 +12,7 @@ import 'package:harness_mobile/swarm/swarm_message_row.dart';import 'package:harness_mobile/swarm/swarm_reader.dart';import 'package:harness_mobile/swarm/swarm_request.dart';+import 'picture_loads.dart';import 'swarm_attachment_fakes.dart';/// Chat files open through short-lived signed links (backend fileLinks.ts):@@ -411,6 +412,8 @@ void main() {.isNotEmpty;Future<void> closed(WidgetTester tester) async {+ // [shown] is a load asked for, not read: the folder goes after it.+ await picturesLoaded(tester);await tester.pumpWidget(const SizedBox());await tester.pump(const Duration(minutes: 1));}diff --git a/mobile/test/swarm/swarm_special_rows_test.dart b/mobile/test/swarm/swarm_special_rows_test.dartindex 888e75dd4..2b9564632 100644--- a/mobile/test/swarm/swarm_special_rows_test.dart+++ b/mobile/test/swarm/swarm_special_rows_test.dart@@ -374,6 +374,30 @@ void main() {expect(inRow('answered', find.text('Terminal answer')), findsOneWidget);});+ // Dee, 11-05 (task #3127): a terminal's recording gap gives a person+ // nothing to do, so it is no chat row; the server keeps it for diagnosis.+ testWidgets('a recording gap is no chat row', (tester) async {+ await show(+ tester,+ backend([+ row('said', 2, 'A real update', {}),+ for (final sequence in [3, 4])+ row(+ 'gap-$sequence',+ sequence,+ 'Some terminal activity could not be recorded.',+ {'kind': 'native', 'phase': 'gap'},+ ),+ ]),+ );+ expect(inRow('said', find.text('A real update')), findsOneWidget);+ expect(+ find.text('Some terminal activity could not be recorded.'),+ findsNothing,+ );+ expect(find.text('Terminal recording interrupted'), findsNothing);+ });+group('an ordinary message says', () {testWidgets('Terminal answer above a terminal\'s answer', (tester) async {await show(diff --git a/scripts/ui-style-allowlist/desktop.json b/scripts/ui-style-allowlist/desktop.jsonindex 19f83cf6d..8f6a2c0f5 100644--- a/scripts/ui-style-allowlist/desktop.json+++ b/scripts/ui-style-allowlist/desktop.json@@ -56,9 +56,6 @@"edge-insets": 3,"border-radius": 1},- "desktop/lib/super_tabs/recording_notice.dart": {- "edge-insets": 3- },"desktop/lib/super_tabs/roster.dart": {"edge-insets": 1},