Skip to content

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.

Merge batch 11-04 b0700: #2864 (#2865)

0xken15beccfd21d6a7
diff --git a/desktop/lib/super_tabs/message_row.dart b/desktop/lib/super_tabs/message_row.dart
index 5a2e3e97f..232ed2d9b 100644
--- a/desktop/lib/super_tabs/message_row.dart
+++ b/desktop/lib/super_tabs/message_row.dart
@@ -172,13 +172,16 @@ class SuperTabMessageRow extends StatefulWidget {
/// Whether [current] joins [previous]'s header: the same sender, within five
/// minutes on the same day. In the chat, a thread reply shown there stands
- /// on its own with its Replied in thread line; [inThread], replies group.
+ /// on its own with its Replied in thread line; [inThread], replies group. A
+ /// line that draws its own row has no header to share, on either side.
static bool groupsWith(
SuperTabMessage current,
SuperTabMessage? previous, {
bool inThread = false,
}) {
if (previous == null ||
+ current.drawsOwnRow ||
+ previous.drawsOwnRow ||
// A message that started a session stands on its own, with its line.
current.sessionRoot ||
previous.sessionRoot ||
diff --git a/desktop/lib/super_tabs/model.dart b/desktop/lib/super_tabs/model.dart
index 1a1111384..6146f3b8c 100644
--- a/desktop/lib/super_tabs/model.dart
+++ b/desktop/lib/super_tabs/model.dart
@@ -1412,6 +1412,13 @@ class SuperTabMessage {
/// A note the backend writes about a terminal: a Lead's typing, or an alert.
bool get terminalEvent =>
source['kind'] == 'terminal-input' || source['kind'] == 'terminal-alert';
+
+ /// The project chat's line when linked work is Done (ship_row.dart).
+ bool get shipLine => source['kind'] == 'ship';
+
+ /// A line the chat draws as its own row, with no sender's header (view.dart):
+ /// a message after it has no header to join (Diego, #2547).
+ bool get drawsOwnRow => shipLine || terminalEvent || route != null;
String? get terminalNote {
if (!fromTerminal) return null;
final phase = source['phase'];
diff --git a/desktop/lib/super_tabs/ship_row.dart b/desktop/lib/super_tabs/ship_row.dart
index df5dbbba8..870421723 100644
--- a/desktop/lib/super_tabs/ship_row.dart
+++ b/desktop/lib/super_tabs/ship_row.dart
@@ -27,8 +27,7 @@ class SuperTabShipRow extends StatefulWidget {
@visibleForTesting
static void resetPlayed() => _played.clear();
- static bool shows(SuperTabMessage message) =>
- message.source['kind'] == 'ship';
+ static bool shows(SuperTabMessage message) => message.shipLine;
@override
State<SuperTabShipRow> createState() => _SuperTabShipRowState();
diff --git a/desktop/test/super_tab_message_grouping_test.dart b/desktop/test/super_tab_message_grouping_test.dart
index 22f58145d..cd338f04e 100644
--- a/desktop/test/super_tab_message_grouping_test.dart
+++ b/desktop/test/super_tab_message_grouping_test.dart
@@ -1,5 +1,9 @@
+import 'dart:io';
+import 'dart:ui' as ui;
+
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
+import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness/shared/theme/app_theme.dart' as grid;
import 'package:harness/super_tabs/message_row.dart';
@@ -7,13 +11,21 @@ import 'package:harness/super_tabs/model.dart';
import 'package:harness/super_tabs/thread_panel.dart';
import 'package:harness/super_tabs/view.dart';
+import 'box_render_preview_test.dart' show loadPreviewFonts;
import 'support/super_tab_fixture.dart';
+/// Set to a folder to write the PR's screenshots there.
+final shots = Platform.environment['SUPER_TAB_MESSAGE_GROUPING_SHOTS'];
+
/// Huy, 2026-11-03 (#2419): like Slack, one sender's messages within five
/// minutes of each other share one header, whatever their length; a gap over
/// five minutes, another sender, a new day or a thread reply shown in the
/// chat starts a new one, and hovering a grouped message shows its time.
void main() {
+ setUpAll(() async {
+ if (shots != null) await loadPreviewFonts();
+ });
+
const buddy = {
'kind': 'agent',
'id': 'pm',
@@ -30,6 +42,7 @@ void main() {
String text = 'An update.',
String? thread,
bool alsoInChat = false,
+ Map<String, Object?>? source,
}) => SuperTabMessage.fromJson({
'id': 'm$n',
'conversationId': 'lead',
@@ -42,8 +55,30 @@ void main() {
'createdAt': at.toUtc().toIso8601String(),
'author': author,
'deliveries': <dynamic>[],
+ 'source': ?source,
});
+ // The rows view.dart draws for themselves, with no header to join (Diego,
+ // #2547).
+ const routeLine = <String, Object?>{
+ 'kind': 'route',
+ 'decisionId': 'decision-1',
+ 'via': 'order',
+ 'why': 'Desktop chat grouping fix',
+ 'pick': {'id': 'c0', 'title': 'New agent · Claude opus high · Mac Studio'},
+ 'alternatives': <Object?>[],
+ };
+ const ownRows = <String, Map<String, Object?>>{
+ 'route': routeLine,
+ 'terminal input': {'kind': 'terminal-input'},
+ 'terminal alert': {
+ 'kind': 'terminal-alert',
+ 'alert': 'prompt',
+ 'agentId': 'pm',
+ },
+ 'ship': {'kind': 'ship', 'title': 'Shipped it'},
+ };
+
group('the rule', () {
test('one sender within five minutes groups at any length', () {
final long = List.filled(40, 'A long report line.').join(' ');
@@ -139,6 +174,177 @@ void main() {
isFalse,
);
});
+
+ for (final MapEntry(key: line, value: source) in ownRows.entries) {
+ group('after a $line line from the same sender', () {
+ final person = message(1, start, author: ken);
+ final row = message(
+ 2,
+ start.add(const Duration(seconds: 20)),
+ source: source,
+ );
+ final plan = message(3, start.add(const Duration(seconds: 30)));
+
+ test('the next message starts a header', () {
+ expect(
+ SuperTabMessageRow.consecutiveUpdates([person, row, plan]),
+ isNot(contains('m3')),
+ );
+ expect(SuperTabMessageRow.groupsWith(plan, row), isFalse);
+ });
+
+ test('the next reply in a thread starts a header', () {
+ expect(
+ SuperTabMessageRow.groupsWith(plan, row, inThread: true),
+ isFalse,
+ );
+ });
+
+ test('the line joins nothing above it', () {
+ expect(
+ SuperTabMessageRow.groupsWith(
+ message(
+ 4,
+ start.add(const Duration(seconds: 40)),
+ source: source,
+ ),
+ plan,
+ ),
+ isFalse,
+ );
+ });
+ });
+ }
+
+ test('two plain messages ten seconds apart still group', () {
+ expect(
+ SuperTabMessageRow.groupsWith(
+ message(2, start.add(const Duration(seconds: 10))),
+ message(1, start),
+ ),
+ isTrue,
+ );
+ });
+
+ test('a plain message that only looks like a line still groups', () {
+ // A route source the row cannot read draws as a plain message.
+ expect(
+ SuperTabMessageRow.groupsWith(
+ message(2, start.add(const Duration(seconds: 10))),
+ message(
+ 1,
+ start,
+ source: const {'kind': 'route', 'decisionId': 'decision-1'},
+ ),
+ ),
+ isTrue,
+ );
+ });
+ });
+
+ group('after a routing line', () {
+ /// Diego's case: a person asks, then the PM's routing line and its plan.
+ Future<void> show(
+ WidgetTester tester, {
+ Brightness brightness = Brightness.light,
+ Key? picture,
+ }) async {
+ grid.AppTheme.brightness.value = brightness;
+ addTearDown(() => grid.AppTheme.brightness.value = Brightness.light);
+ await tester.binding.setSurfaceSize(const Size(1400, 900));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ final server = ConversationServer()..threads = true;
+ (server.state['agents'] as List).add({
+ 'id': 'pm',
+ 'projectId': 'lead',
+ 'name': 'Lead',
+ 'displayName': 'River',
+ 'machineId': 'studio',
+ 'harnessId': 'h-pm',
+ 'contributorId': 'owner',
+ 'configuration': {'engine': 'claude', 'model': 'opus'},
+ });
+ (server.state['people'] as List).add({
+ 'id': 'ken',
+ 'email': '[email protected]',
+ 'role': 'collaborator',
+ });
+ void say(
+ String text,
+ Map<String, Object> author,
+ Duration after, {
+ Map<String, Object?>? source,
+ }) {
+ server.append(text);
+ server.messages.last
+ ..['author'] = author
+ ..['createdAt'] = start.add(after).toUtc().toIso8601String();
+ if (source != null) server.messages.last['source'] = source;
+ }
+
+ say('Please fix the chat header.', ken, Duration.zero);
+ say(
+ 'Routed to New agent · Claude opus high · Mac Studio',
+ buddy,
+ const Duration(seconds: 20),
+ source: routeLine,
+ );
+ say(
+ 'The plan: test first, then the fix.',
+ buddy,
+ const Duration(seconds: 30),
+ );
+ say('A second line of the plan.', buddy, const Duration(seconds: 40));
+ ((server.state['conversations'] as List)[0] as Map)['leadId'] = 'pm';
+ final c = server.controller();
+ await c.refresh();
+ addTearDown(c.dispose);
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: grid.buildAppTheme(brightness: brightness),
+ builder: (context, child) =>
+ RepaintBoundary(key: picture, child: child),
+ home: Scaffold(
+ body: SuperTabView(
+ controller: c,
+ onInvite: () {},
+ onAddAgent: (_) {},
+ onOpenTerminal: (_) {},
+ machineName: (_) => 'Mac Studio',
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ }
+
+ testWidgets("the PM's name is inside its plan's row", (tester) async {
+ await show(tester);
+ Finder name(String id) => find.descendant(
+ of: find.byKey(ValueKey('super-message-$id')),
+ matching: find.text('River'),
+ );
+ expect(name('message-3'), findsOneWidget);
+ // The next plain message still joins the plan's header.
+ expect(name('message-4'), findsNothing);
+ });
+
+ for (final brightness in Brightness.values) {
+ testWidgets('screenshot for review (${brightness.name})', (tester) async {
+ final picture = GlobalKey();
+ await show(tester, brightness: brightness, picture: picture);
+ final boundary =
+ picture.currentContext!.findRenderObject()!
+ as RenderRepaintBoundary;
+ await tester.runAsync(() async {
+ final image = await boundary.toImage(pixelRatio: 2);
+ final bytes = await image.toByteData(format: ui.ImageByteFormat.png);
+ image.dispose();
+ File('$shots/route-then-plan-${brightness.name}.png')
+ .writeAsBytesSync(bytes!.buffer.asUint8List());
+ });
+ }, skip: shots == null);
+ }
});
group('on screen', () {