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-06 k1045: #3309 (#3319)
0xken153016ff25a0d5
diff --git a/desktop/lib/super_tabs/thread_cards.dart b/desktop/lib/super_tabs/thread_cards.dartindex 3cdb9e3e8..2a44e9028 100644--- a/desktop/lib/super_tabs/thread_cards.dart+++ b/desktop/lib/super_tabs/thread_cards.dart@@ -17,6 +17,10 @@ class SuperTabThreadCard {this.readThrough = -1,this.loading = false,this.error,+ this.expanded = false,+ this.next,+ this.loadingOlder = false,+ this.olderFailed = false,});/// The root message; null until read, or when the server no longer has it.@@ -35,6 +39,18 @@ class SuperTabThreadCard {final bool loading;final String? error;+ /// Show N more replies was pressed and every reply this card can read is+ /// held: the card draws all of them (task #3619).+ final bool expanded;++ /// Where the replies older than [replies] start (`before`, `beforeId` of the+ /// next page); null when [replies] reach the thread's first.+ final Map<String, dynamic>? next;+ final bool loadingOlder;++ /// The last read of older replies failed: the button stays, and says so.+ final bool olderFailed;+SuperTabThreadCard _copy({bool? loading, String? error}) =>SuperTabThreadCard(root: root,@@ -44,7 +60,31 @@ class SuperTabThreadCard {readThrough: readThrough,loading: loading ?? this.loading,error: error,+ expanded: expanded,+ next: next,+ loadingOlder: loadingOlder,+ olderFailed: olderFailed,);++ SuperTabThreadCard _older({+ List<SuperTabMessage>? replies,+ Map<String, dynamic>? next,+ bool? expanded,+ bool? loadingOlder,+ bool? olderFailed,+ }) => SuperTabThreadCard(+ root: root,+ replies: replies ?? this.replies,+ count: count,+ people: people,+ readThrough: readThrough,+ loading: loading,+ error: error,+ expanded: expanded ?? this.expanded,+ next: replies == null && next == null ? this.next : next,+ loadingOlder: loadingOlder ?? this.loadingOlder,+ olderFailed: olderFailed ?? this.olderFailed,+ );}/// The Threads page's cards, one per followed thread it lists: each read once@@ -65,13 +105,19 @@ class SuperTabThreadCards extends ChangeNotifier {final SuperTabController controller;final _cards = <String, SuperTabThreadCard>{};final _loading = <String, Future<void>>{};+ final _olderReads = <String, Future<void>>{};int? _epoch;+ /// Most pages of older replies one card reads, so a runaway thread cannot+ /// loop; a thread longer than that keeps its Show N more replies count.+ static const _olderPagesMost = 40;+/// Moves on [clear], so an answer for a page that closed is not kept.int _generation = 0;bool _disposed = false;static const failed = 'Could not load this thread.';+ static const olderFailedText = 'Could not load earlier replies.';SuperTabThreadCard? card(SuperTabFollowedThread thread) => _cards[thread.key];@@ -134,10 +180,21 @@ class SuperTabThreadCards extends ChangeNotifier {if (!current()) return;root = rowsOf(asked).where((m) => m.id == thread.rootId).firstOrNull;}- final replies = [+ final newest = [for (final m in rows)if (m.id != thread.rootId) m,];+ // An expanded card keeps the older replies it read, whatever arrives.+ final held = _cards[key];+ final keepOlder = held?.expanded == true;+ final replies = keepOlder+ ? ([+ for (final m in {+ for (final m in [...held!.replies, ...newest]) m.id: m,+ }.values)+ m,+ ]..sort(superTabMessageOrder))+ : newest;final summary = [for (final row in page['threads'] as List? ?? const [])if (superTabMap(row)['id'] == thread.rootId) superTabMap(row),@@ -161,6 +218,14 @@ class SuperTabThreadCards extends ChangeNotifier {thread.lastReplySequence,...replies.map((m) => m.sequence),].reduce((a, b) => a > b ? a : b),+ expanded: keepOlder,+ next: keepOlder+ ? held!.next+ : (held?.loadingOlder == true+ ? held!.next+ : (page['next'] is Map ? superTabMap(page['next']) : null)),+ loadingOlder: held?.loadingOlder ?? false,+ olderFailed: held?.olderFailed ?? false,);notifyListeners();} catch (_) {@@ -173,6 +238,90 @@ class SuperTabThreadCards extends ChangeNotifier {}}+ /// Show N more replies (task #3619): the card draws every reply. Reads the+ /// older pages the card lacks, joins a read under way, and keeps the button+ /// with a message when a page fails.+ Future<void> expand(SuperTabFollowedThread thread) {+ final held = _cards[thread.key];+ if (held == null || _disposed || controller.accessRevoked) {+ return Future.value();+ }+ if (_olderReads[thread.key] case final running?) return running;+ final read = _readOlder(thread)+ .whenComplete(() => _olderReads.remove(thread.key));+ _olderReads[thread.key] = read;+ return read;+ }++ Future<void> _readOlder(SuperTabFollowedThread thread) async {+ final key = thread.key;+ final generation = _generation, epoch = controller.visibilityEpoch;+ bool current() =>+ !_disposed &&+ !controller.accessRevoked &&+ generation == _generation &&+ epoch == controller.visibilityEpoch;+ var card = _cards[key];+ if (card == null) return;+ _cards[key] = card = card._older(loadingOlder: true, olderFailed: false);+ notifyListeners();+ final path =+ '/api/super-tabs/${Uri.encodeComponent(controller.tabId)}'+ '/conversations/${Uri.encodeComponent(thread.conversationId)}/messages';+ final replies = {for (final m in card.replies) m.id: m};+ var from = card.next;+ try {+ for (var page = 0; from != null && page < _olderPagesMost; page++) {+ final answer = await controller.request(+ 'GET',+ '$path?thread=${Uri.encodeQueryComponent(thread.rootId)}'+ '&before=${from['sequence']}'+ '&beforeId=${Uri.encodeQueryComponent(from['id'] as String)}',+ );+ if (!current()) return;+ for (final row in answer['messages'] as List? ?? const []) {+ final m = SuperTabMessage.fromJson(superTabMap(row));+ if (m.conversationId == thread.conversationId &&+ m.thread == thread.rootId &&+ m.id != thread.rootId) {+ replies[m.id] = m;+ }+ }+ from = answer['next'] is Map ? superTabMap(answer['next']) : null;+ }+ // A reply that came in while this read ran is in the card, not in+ // [replies]: both stay.+ final now = _cards[key] ?? card;+ final all = {+ ...replies,+ for (final m in now.replies) m.id: m,+ }.values.toList()..sort(superTabMessageOrder);+ _cards[key] = now._older(+ replies: List.unmodifiable(all),+ next: from,+ // Only when no older page is left: a read the cap stopped keeps its+ // button, with what is still hidden counted.+ expanded: from == null,+ loadingOlder: false,+ );+ } catch (_) {+ if (!current()) return;+ // What was read stays, so the next tap goes on from there.+ final now = _cards[key] ?? card;+ final all = {+ ...replies,+ for (final m in now.replies) m.id: m,+ }.values.toList()..sort(superTabMessageOrder);+ _cards[key] = now._older(+ replies: List.unmodifiable(all),+ next: from,+ loadingOlder: false,+ olderFailed: true,+ );+ }+ notifyListeners();+ }+/// Keeps only the cards of [keys], the threads the page lists now.void retain(Iterable<String> keys) {final kept = keys.toSet();@@ -184,6 +333,7 @@ class SuperTabThreadCards extends ChangeNotifier {_generation++;_cards.clear();_loading.clear();+ _olderReads.clear();}void _changed() {diff --git a/desktop/lib/super_tabs/threads_page.dart b/desktop/lib/super_tabs/threads_page.dartindex df4ef1d0e..43226f144 100644--- a/desktop/lib/super_tabs/threads_page.dart+++ b/desktop/lib/super_tabs/threads_page.dart@@ -365,10 +365,11 @@ class _ThreadCardState extends State<_ThreadCard> {),];}- final shown = card.replies.length > 2+ // Expanded (Show N more replies, task #3619): every reply, in the card.+ final shown = !card.expanded && card.replies.length > 2? card.replies.sublist(card.replies.length - 2): card.replies;- final hidden = card.count - shown.length;+ final hidden = card.expanded ? 0 : card.count - shown.length;final fresh = attention.isNew(t)? attention.newCount(t).clamp(0, shown.length): 0;@@ -387,17 +388,30 @@ class _ThreadCardState extends State<_ThreadCard> {),],),- if (hidden > 0)+ if (hidden > 0) ...[+ if (card.olderFailed)+ Text(+ SuperTabThreadCards.olderFailedText,+ key: ValueKey('super-thread-card-older-failed:$_key'),+ style: DesktopChrome.control(),+ ),Align(alignment: Alignment.centerLeft,child: TextButton(key: ValueKey('super-thread-card-more:$_key'),- onPressed: () => widget.onOpenThread(t.conversationId, t.rootId),+ onPressed: card.loadingOlder+ ? null+ : () => unawaited(widget.cards.expand(t)),child: Text(- hidden == 1 ? 'Show 1 more reply' : 'Show $hidden more replies',+ card.loadingOlder+ ? 'Loading replies…'+ : hidden == 1+ ? 'Show 1 more reply'+ : 'Show $hidden more replies',),),),+ ],for (final (index, reply) in shown.indexed) ...[if (fresh > 0 && index == shown.length - fresh) _newLine(),widget.message(reply),diff --git a/desktop/test/super_tab_threads_page_shots_test.dart b/desktop/test/super_tab_threads_page_shots_test.dartindex bf01c89c4..0ea772300 100644--- a/desktop/test/super_tab_threads_page_shots_test.dart+++ b/desktop/test/super_tab_threads_page_shots_test.dart@@ -170,6 +170,19 @@ void main() {await tester.pumpAndSettle();}await captureWindow(tester, shots, 'threads-page-${brightness.name}');+ // Task #3619: Show N more replies expands the card where it is.+ await tester.tap(find.text('Show 4 more replies'));+ for (var i = 0; i < 3; i++) {+ await tester.runAsync(+ () => Future<void>.delayed(const Duration(milliseconds: 30)),+ );+ await tester.pumpAndSettle();+ }+ await captureWindow(+ tester,+ shots,+ 'threads-page-expanded-${brightness.name}',+ );});});}diff --git a/desktop/test/super_tab_threads_page_test.dart b/desktop/test/super_tab_threads_page_test.dartindex 9b9f736d3..91a6f5ff7 100644--- a/desktop/test/super_tab_threads_page_test.dart+++ b/desktop/test/super_tab_threads_page_test.dart@@ -1,3 +1,5 @@+import 'dart:async';+import 'package:clock/clock.dart';import 'package:flutter/material.dart';import 'package:flutter_test/flutter_test.dart';@@ -225,9 +227,7 @@ void main() {});});- testWidgets('the title and Show more open the thread beside its chat', (- tester,- ) async {+ testWidgets('the title opens the thread beside its chat', (tester) async {final server = swarm();final id = _thread(server,@@ -243,14 +243,226 @@ void main() {final opened = await _show(tester, await _loaded(tester, server));await tester.tap(_key('super-thread-card-title:lead/$id'));await tester.pumpAndSettle();- await tester.tap(find.text('Show 1 more reply'));- await tester.pumpAndSettle();- expect(opened, [('lead', id), ('lead', id)]);+ expect(opened, [('lead', id)]);// A read thread has no New line.expect(_key('super-thread-card-new:lead/$id'), findsNothing);});});+ // Task #3619 (Tony, 11-06): Show N more replies expands the card where it+ // is. It used to open the chat with a Thread pane beside it.+ Finder inCard(String id, Finder f) =>+ find.descendant(of: _key('super-thread-card:lead/$id'), matching: f);++ testWidgets('Show N more replies expands the card with every reply, loading '+ 'the older ones, and opens no pane', (tester) async {+ final server = swarm()..messagePage = 3;+ final id = _thread(+ server,+ 'Long thread',+ replies: [for (var i = 1; i <= 8; i++) ('Kestrel', 'Reply $i')],+ );+ server.followedThreads = {+ 'unread': [],+ 'read': [_followed(server, id)],+ 'more': false,+ };+ final reads = <String>[];+ server.onRead = reads.add;+ await withClock(Clock.fixed(_now), () async {+ final opened = await _show(tester, await _loaded(tester, server));+ expect(inCard(id, find.text('Show 6 more replies')), findsOneWidget);+ expect(inCard(id, find.text('Reply 1')), findsNothing);+ await tester.tap(find.text('Show 6 more replies'));+ await _settle(tester);+ for (var i = 1; i <= 8; i++) {+ expect(inCard(id, find.text('Reply $i')), findsOneWidget);+ }+ // In order, root first, and the button is gone.+ expect(+ _top(tester, inCard(id, find.text('Reply 1'))),+ lessThan(_top(tester, inCard(id, find.text('Reply 8')))),+ );+ expect(inCard(id, find.textContaining('more repl')), findsNothing);+ expect(opened, isEmpty);+ expect(reads.where((p) => p.contains('before=')), isNotEmpty);+ });+ });++ testWidgets('a card that holds every reply already expands with no further '+ 'read', (tester) async {+ final server = swarm();+ final id = _thread(+ server,+ 'Short thread',+ replies: [for (var i = 1; i <= 4; i++) ('Kestrel', 'Reply $i')],+ );+ server.followedThreads = {+ 'unread': [],+ 'read': [_followed(server, id)],+ 'more': false,+ };+ final reads = <String>[];+ server.onRead = reads.add;+ await withClock(Clock.fixed(_now), () async {+ final opened = await _show(tester, await _loaded(tester, server));+ reads.clear();+ await tester.tap(find.text('Show 2 more replies'));+ await _settle(tester);+ for (var i = 1; i <= 4; i++) {+ expect(inCard(id, find.text('Reply $i')), findsOneWidget);+ }+ expect(opened, isEmpty);+ expect(reads.where((p) => p.contains('thread=$id')), isEmpty);+ });+ });++ testWidgets('a failed older read keeps the button and says so; the next tap '+ 'loads them', (tester) async {+ final server = swarm()..messagePage = 3;+ final id = _thread(+ server,+ 'Flaky long thread',+ replies: [for (var i = 1; i <= 8; i++) ('Kestrel', 'Reply $i')],+ );+ server.followedThreads = {+ 'unread': [],+ 'read': [_followed(server, id)],+ 'more': false,+ };+ var fail = true;+ server.onRead = (path) {+ if (fail && path.contains('before=')) throw StateError('Offline');+ };+ await withClock(Clock.fixed(_now), () async {+ final opened = await _show(tester, await _loaded(tester, server));+ await tester.tap(find.text('Show 6 more replies'));+ await _settle(tester);+ expect(+ inCard(id, find.text('Could not load earlier replies.')),+ findsOneWidget,+ );+ expect(inCard(id, find.text('Show 6 more replies')), findsOneWidget);+ expect(inCard(id, find.text('Reply 1')), findsNothing);+ fail = false;+ await tester.tap(find.text('Show 6 more replies'));+ await _settle(tester);+ expect(inCard(id, find.text('Reply 1')), findsOneWidget);+ expect(+ inCard(id, find.text('Could not load earlier replies.')),+ findsNothing,+ );+ expect(opened, isEmpty);+ });+ });++ testWidgets('a card that gets a new reply after expanding keeps its older '+ 'replies', (tester) async {+ final server = swarm()..messagePage = 3;+ final id = _thread(+ server,+ 'Growing thread',+ replies: [for (var i = 1; i <= 8; i++) ('Kestrel', 'Reply $i')],+ );+ server.followedThreads = {+ 'unread': [],+ 'read': [_followed(server, id)],+ 'more': false,+ };+ await withClock(Clock.fixed(_now), () async {+ final activity = await _loaded(tester, server);+ final opened = await _show(tester, activity);+ await tester.tap(find.text('Show 6 more replies'));+ await _settle(tester);+ expect(inCard(id, find.text('Reply 1')), findsOneWidget);+ // Reply 9 arrives, and the followed list says so.+ server.append('Reply 9');+ server.messages.last+ ..['thread'] = id+ ..['author'] = _author('Kestrel');+ server.followedThreads = {+ 'unread': [],+ 'read': [_followed(server, id)],+ 'more': false,+ };+ await tester.runAsync(activity.attention.load);+ await _settle(tester);+ expect(inCard(id, find.text('Reply 9')), findsOneWidget);+ expect(inCard(id, find.text('Reply 1')), findsOneWidget);+ expect(inCard(id, find.textContaining('more repl')), findsNothing);+ expect(opened, isEmpty);+ });+ });++ testWidgets('a reply that arrives while older replies load stays in the '+ 'card', (tester) async {+ final server = swarm()..messagePage = 3;+ final id = _thread(+ server,+ 'Busy thread',+ replies: [for (var i = 1; i <= 8; i++) ('Kestrel', 'Reply $i')],+ );+ server.followedThreads = {+ 'unread': [],+ 'read': [_followed(server, id)],+ 'more': false,+ };+ await withClock(Clock.fixed(_now), () async {+ final activity = await _loaded(tester, server);+ final opened = await _show(tester, activity);+ final hold = server.holdThreadPages = Completer<void>();+ await tester.tap(find.text('Show 6 more replies'));+ await _settle(tester);+ expect(inCard(id, find.text('Loading replies…')), findsOneWidget);+ // Reply 9 arrives while the older page is still on its way.+ server.append('Reply 9');+ server.messages.last+ ..['thread'] = id+ ..['author'] = _author('Kestrel');+ server.followedThreads = {+ 'unread': [],+ 'read': [_followed(server, id)],+ 'more': false,+ };+ await tester.runAsync(activity.attention.load);+ await _settle(tester);+ expect(inCard(id, find.text('Reply 9')), findsOneWidget);+ hold.complete();+ await _settle(tester);+ expect(inCard(id, find.text('Reply 9')), findsOneWidget);+ expect(inCard(id, find.text('Reply 1')), findsOneWidget);+ expect(inCard(id, find.textContaining('more repl')), findsNothing);+ expect(opened, isEmpty);+ });+ });++ testWidgets('a thread longer than the page cap keeps its button until every '+ 'reply is read', (tester) async {+ final server = swarm()..messagePage = 1;+ final id = _thread(+ server,+ 'Huge thread',+ replies: [for (var i = 1; i <= 45; i++) ('Kestrel', 'Reply $i')],+ );+ server.followedThreads = {+ 'unread': [],+ 'read': [_followed(server, id)],+ 'more': false,+ };+ await withClock(Clock.fixed(_now), () async {+ await _show(tester, await _loaded(tester, server));+ await tester.tap(find.textContaining('more replies'));+ await _settle(tester);+ // 40 pages are read at most: the card still says what is hidden.+ expect(inCard(id, find.text('Reply 1')), findsNothing);+ expect(inCard(id, find.textContaining('more replies')), findsOneWidget);+ await tester.tap(find.textContaining('more replies'));+ await _settle(tester);+ expect(inCard(id, find.text('Reply 1')), findsOneWidget);+ expect(inCard(id, find.textContaining('more repl')), findsNothing);+ });+ });+testWidgets('a reply from a card goes to its own thread, with Also send to ''#web-project, while another thread is open beside the chat', (tester,diff --git a/desktop/test/support/super_tab_fixture.dart b/desktop/test/support/super_tab_fixture.dartindex 5eedbc34e..b0e413792 100644--- a/desktop/test/support/super_tab_fixture.dart+++ b/desktop/test/support/super_tab_fixture.dart@@ -527,6 +527,9 @@ class ConversationServer {Map<String, dynamic>? saved;// While set, every read waits for it: a slow server.Completer<void>? holdReads;+ // While set, a thread's older pages (`thread` and `before`) wait for it, and+ // nothing else does: a slow older read while the page reloads.+ Completer<void>? holdThreadPages;// Makes every command answer with this refusal: {code, message}, with// [refuseStatus] as its HTTP status.Map<String, String>? refuse;@@ -2065,6 +2068,9 @@ class ConversationServer {final before = int.tryParse(query['before'] ?? '');final afterId = query['afterId'], beforeId = query['beforeId'];final messageId = query['messageId'], thread = query['thread'];+ if (thread != null && before != null && holdThreadPages != null) {+ await holdThreadPages!.future;+ }if (messageId != null) {if (forbidMessageReads.contains(conversationId)) {throw const SuperTabFailure(diff --git a/docs/plans/2026-11-06-threads-card-show-more-plan.md b/docs/plans/2026-11-06-threads-card-show-more-plan.mdnew file mode 100644index 000000000..8deba4ae6--- /dev/null+++ b/docs/plans/2026-11-06-threads-card-show-more-plan.md@@ -0,0 +1,44 @@+# Threads card: Show N more replies expands in place — Plan++**Goal:** On the Desktop Threads page, "Show N more replies" expands the same card to show every reply, loading older replies when the card holds only the newest page. The screen stays as it is: no chat opens, no Thread pane appears.+**Architecture:** `SuperTabThreadCards` (one per controller, `thread_cards.dart`) keeps each card's data. It gains an `expanded` flag and the older-page cursor (`next`) per card, and `expand(thread)` reads older pages of the thread (`?thread=ROOT&before=SEQ&beforeId=ID`, the thread pane's own paging) until it holds every reply. `_ThreadCard` shows all replies of an expanded card and drops the button. The title still opens the thread beside its chat.+**Tech Stack:** Flutter/Dart (Desktop), `flutter_test`, the `ConversationServer` fixture (`messagePage` makes a thread longer than one page).+**Spec:** Task #3619 (Tony, 2026-11-06).++## Design+- growth: replies of one expanded card are held in memory until the page closes (`clear`) or the thread leaves the list (`retain`); paging stops at 40 pages, so a runaway thread cannot loop.+- concurrency: single UI isolate; one older read per card at a time (joins a running one); answers for a closed page are dropped by the existing generation check.+- read cost: expanding reads only the older pages the card lacks; a card that already holds every reply reads nothing. Nothing polls.+- scale: a thread with thousands of replies takes pages until the cap; the button then keeps its count.+- compatibility: same read as the thread pane; an old server without `next` answers one page and the card shows what it holds.+- migration + rollback: none; revert the change.+- audience: the same reads the thread pane makes; the server enforces who may read.+- identity: unchanged.+- failure: a failed older read keeps the button, shows "Could not load earlier replies." and retries on the next tap.+- platforms: Desktop Dart only; no native or Windows-specific code.++## Global Constraints+- Out of scope: other ways to open a thread from the card, the Mentions and Decisions pages, the phone app.+- Tests use a memory store and a fake sign-in; nothing signs the real CLI in or out.+- Swarm code stays out of cli/src/core.++## Review Focus+- Expanding never calls `onOpenThread`.+- A card that reloads (a new reply arrives) keeps the older replies it loaded and stays expanded.+- The New line still sits above the first unread reply.++## Tasks++### Task 1: Test, then the data: expand loads every reply+**Files:** `desktop/test/super_tab_threads_page_test.dart`, `desktop/lib/super_tabs/thread_cards.dart`+**Interfaces:** `SuperTabThreadCard.expanded`, `.next`, `.loadingOlder`, `.olderError`; `SuperTabThreadCards.expand(SuperTabFollowedThread)`.+- [ ] Failing test: a card whose thread has more replies than one page shows every reply after Show N more replies, opens no pane.+- [ ] Failing test: a card that holds every reply already expands with no extra read.+- [ ] Failing test: a failed older read keeps the button and says so; the next tap loads.+- [ ] Failing test: a reload after expanding keeps the older replies.+- [ ] Implement `expand`, the `next` cursor and the merge on reload.++### Task 2: The card shows them+**Files:** `desktop/lib/super_tabs/threads_page.dart`+- [ ] The button calls `cards.expand`, not `onOpenThread`; an expanded card shows all replies and no button.+- [ ] Light and dark pictures of an expanded card (capture test).