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 Swarm chat: returning to a busy conversation shows the latest messages at once (#2003)
0xken15a54bdba9c404
diff --git a/desktop/lib/super_tabs/controller.dart b/desktop/lib/super_tabs/controller.dartindex 752004993..180afd581 100644--- a/desktop/lib/super_tabs/controller.dart+++ b/desktop/lib/super_tabs/controller.dart@@ -1795,7 +1795,13 @@ class SuperTabController extends ChangeNotifier {// Recorded only once the rows are refreshed: a read that fails leaves// the change for the next poll.final reactionSeq = older ? null : answer['reactionSeq'];- if (!_disposed &&+ // More than a page arrived after the newest held (back from another+ // conversation, or from sleep): the page after it would show messages+ // from hours ago as the newest. The latest page replaces what is held.+ final skipped = query.startsWith('?after=') && answer['next'] != null;+ if (!_disposed && skipped) {+ answer = await request('GET', _messagesPath(id));+ } else if (!_disposed &&!older &&(!light || reacted) &&tail != null &&@@ -1837,7 +1843,7 @@ class SuperTabController extends ChangeNotifier {}// The first read over a saved page replaces it: merged, the saved// page would leave a gap when more than a page arrived since.- final replacing = _showingSaved && !older;+ final replacing = (_showingSaved || skipped) && !older;if (replacing) _rows.remove(id);_keepRows(id, answer['messages'] as List);final combined = {diff --git a/desktop/test/super_tab_controller_test.dart b/desktop/test/super_tab_controller_test.dartindex b6fdae4c8..c78ee4c76 100644--- a/desktop/test/super_tab_controller_test.dart+++ b/desktop/test/super_tab_controller_test.dart@@ -339,24 +339,27 @@ void main() {expect(controller.outgoing('lead'), isEmpty);});- test(- 'reconnecting after more than a page of messages fills the gap in order',- () async {- final server = ConversationServer()..append('First');- final controller = await open(server);- for (var i = 0; i < 250; i++) {- server.append('Message $i');- }- for (var i = 0; i < 3; i++) {- await controller.refresh();- }- expect(controller.messages('lead'), hasLength(251));- expect(- controller.messages('lead').map((m) => m.sequence),- List.generate(251, (i) => i + 1),- );- },- );+ test('reconnecting after more than a page of messages shows the latest, '+ 'then fills the gap in order', () async {+ final server = ConversationServer()..append('First');+ final controller = await open(server);+ for (var i = 0; i < 250; i++) {+ server.append('Message $i');+ }+ await controller.refresh();+ expect(+ controller.messages('lead').map((m) => m.sequence),+ List.generate(100, (i) => i + 152),+ );+ while (controller.hasOlder('lead')) {+ await controller.loadMessages('lead', older: true);+ }+ expect(controller.messages('lead'), hasLength(251));+ expect(+ controller.messages('lead').map((m) => m.sequence),+ List.generate(251, (i) => i + 1),+ );+ });test('drafts and pending sends cannot cross accounts', () async {final server = ConversationServer()..loseReply = true;diff --git a/desktop/test/super_tab_message_paging_test.dart b/desktop/test/super_tab_message_paging_test.dartindex 31cfcd911..6c9868863 100644--- a/desktop/test/super_tab_message_paging_test.dart+++ b/desktop/test/super_tab_message_paging_test.dart@@ -80,7 +80,8 @@ void main() {];final c = server.controller();await c.refresh();- for (final text in ['r1', 'r2', 'r3']) {+ // One page of replies: more would make the poll read the latest page.+ for (final text in ['r1', 'r2']) {server.append(text);server.messages.last['author'] = {'kind': 'agent',@@ -116,6 +117,65 @@ void main() {},);+ test(+ 'returning after more than a page arrived shows the latest page at once',+ () async {+ final server = ConversationServer();+ for (var i = 1; i <= 100; i++) {+ server.append('lead $i');+ }+ server.append('result', conversationId: 'offline');+ final c = server.controller();+ await c.refresh();+ expect(c.messages('lead').last.sequence, 100);+ await c.select('offline');+ await c.loadMessages('offline');+ // Away from the conversation, 600 messages arrive.+ for (var i = 102; i <= 701; i++) {+ server.append('lead $i');+ }+ await c.refresh();++ // The one read that opening the conversation starts.+ await c.select('lead');+ await pumpEventQueue();++ final shown = c.messages('lead');+ expect(shown.last.sequence, 701);+ expect(shown, hasLength(100));+ expect(c.hasOlder('lead'), isTrue);+ // The view marks what it shows read: the newest message, nothing more.+ c.markRead('lead', through: 701);+ expect(c.unread(c.selected!), isFalse);+ },+ );++ test('an older page read while the latest page replaces the held ones leaves '+ 'no gap', () async {+ final server = ConversationServer()..messagePage = 2;+ for (final text in ['one', 'two', 'three', 'four']) {+ server.append(text);+ }+ final c = server.controller();+ await c.refresh();+ for (final text in ['five', 'six', 'seven']) {+ server.append(text);+ }+ final pages = server.holdReads = Completer<void>();++ // The reader scrolls up while the poll finds more than a page new.+ final newest = c.loadMessages('lead');+ final older = c.loadMessages('lead', older: true);+ server.holdReads = null;+ pages.complete();+ await Future.wait([newest, older]);++ final shown = c.messages('lead').map((m) => m.sequence).toList();+ expect(shown.last, 7);+ expect(shown, List.generate(shown.length, (i) => shown.first + i));+ expect(c.hasOlder('lead'), isTrue);+ });+test('a new message is read after the newest one', () async {final server = ConversationServer()..append('one');final c = server.controller();diff --git a/desktop/test/super_tab_pm_chat_pinned_test.dart b/desktop/test/super_tab_pm_chat_pinned_test.dartindex bee850f14..d2d8264da 100644--- a/desktop/test/super_tab_pm_chat_pinned_test.dart+++ b/desktop/test/super_tab_pm_chat_pinned_test.dart@@ -230,7 +230,9 @@ void main() {await c.refresh();await pumpEventQueue(times: 100);expect(c.unreadCount(c.pmChat('lead')!), 25);- expect(reads, hasLength(3));+ // The page after the held tail says more than a page arrived: the+ // latest page replaces it, and two earlier pages reach the read mark.+ expect(reads, hasLength(4));reads.clear();await c.refresh();