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.

Thread reply box: options on one row, Also send names where it posts (#2429)

0xken15cd87859e015d
diff --git a/desktop/lib/super_tabs/composer_toggle.dart b/desktop/lib/super_tabs/composer_toggle.dart
index 931c4f424..a9bd1ee7b 100644
--- a/desktop/lib/super_tabs/composer_toggle.dart
+++ b/desktop/lib/super_tabs/composer_toggle.dart
@@ -1,11 +1,14 @@
import 'package:flutter/material.dart';
+import '../shared/theme/app_icons.dart';
import '../shared/theme/app_theme.dart' as grid;
import '../widgets/desktop_chrome.dart';
/// A composer choice on the send row (New session, Also send): the shared
-/// compact pill, quiet and outlined when off, accent when on. Its hover hint
-/// says what it does, or why it can't be chosen now ([onChanged] null).
+/// compact pill, read as an option to turn on (Scholes, 10-31). Off, it is
+/// outlined with an empty circle; on, accent-tinted with a check. Its hover
+/// hint says what it does, or why it can't be chosen now ([onChanged] null).
+/// A label too long for its place ends in "…"; the circle always shows.
class SuperTabComposerToggle extends StatelessWidget {
const SuperTabComposerToggle({
super.key,
@@ -20,18 +23,54 @@ class SuperTabComposerToggle extends StatelessWidget {
final String hint;
final ValueChanged<bool>? onChanged;
+ static const _textSize = 12.0;
+ static const _iconSize = 12.0;
+ static const _gap = 4.0;
+
+ /// The width this choice takes with [label] in one line, as drawn in
+ /// [context] (its text size included): what a send row measures to tell
+ /// whether a label fits. Matches [DesktopPill]'s compact choice: side
+ /// padding, the icon and its gap, and the reserved rim.
+ static double widthOf(BuildContext context, String label) {
+ final text = TextPainter(
+ text: TextSpan(
+ text: label,
+ style: DesktopChrome.text(size: _textSize, height: 1.25),
+ ),
+ textDirection: Directionality.of(context),
+ textScaler: MediaQuery.textScalerOf(context),
+ maxLines: 1,
+ )..layout();
+ final width = text.width;
+ text.dispose();
+ return 6 * 2 +
+ grid.AppDesktop.focusWidth * 2 +
+ _iconSize +
+ _gap +
+ width +
+ 1;
+ }
+
@override
Widget build(BuildContext context) {
grid.AppTheme.watch(context);
+ final ink = on ? DesktopChrome.accent : DesktopChrome.foreground;
return Semantics(
toggled: on,
child: DesktopPill(
label: label,
compact: true,
choice: true,
- textSize: 12,
+ textSize: _textSize,
selected: on,
foregroundColor: on ? DesktopChrome.accent : null,
+ leadingGap: _gap,
+ leading: Icon(
+ on ? AppIcons.circleCheck : AppIcons.circle,
+ key: ValueKey(on ? 'composer-toggle-check' : 'composer-toggle-off'),
+ size: _iconSize,
+ color: onChanged == null ? ink.withValues(alpha: .38) : ink,
+ ),
tooltip: hint,
onPressed: onChanged == null ? null : () => onChanged!(!on),
),
diff --git a/desktop/lib/super_tabs/pane_layout.dart b/desktop/lib/super_tabs/pane_layout.dart
index d1b8efb62..321196cdb 100644
--- a/desktop/lib/super_tabs/pane_layout.dart
+++ b/desktop/lib/super_tabs/pane_layout.dart
@@ -19,32 +19,45 @@ class SuperTabPaneLayout extends StatefulWidget {
this.left,
this.right,
this.storage,
+ this.rightDefault = rightWidth,
});
static const storageKey = 'super-tab-pane-widths';
static const leftWidth = 300.0;
static const rightWidth = 280.0;
+ /// A thread's default width (Scholes, 10-31): room for its reply box's
+ /// options on one row ("New session" and "Also to chat"). [rightWidth]
+ /// stays the narrowest the pane goes.
+ static const threadWidth = 340.0;
+
/// The roster drawer's share of a narrow window at most. On a phone it filled the screen, leaving no
/// veil to tap, so closing it was hard (owner, 2026-10-23).
static const drawerMaxFraction = 0.7;
- /// The roster drawer's width in a window [available] wide.
- static double drawerWidth(double available) =>
- (available * drawerMaxFraction).clamp(0, rightWidth).toDouble();
+ /// The roster drawer's width in a window [available] wide, at most [max]
+ /// (a thread's drawer passes [threadWidth]).
+ static double drawerWidth(double available, {double max = rightWidth}) =>
+ (available * drawerMaxFraction).clamp(0, max).toDouble();
final Widget? left, right;
final Widget center;
final VoidCallback onLeave;
final LocalKeyValueStore? storage;
+ /// The right pane's width until a person sets one by its divider (that
+ /// width, saved, wins): [threadWidth] while it shows a thread.
+ final double rightDefault;
+
@override
State<SuperTabPaneLayout> createState() => _SuperTabPaneLayoutState();
}
class _SuperTabPaneLayoutState extends State<SuperTabPaneLayout> {
- double _left = SuperTabPaneLayout.leftWidth,
- _right = SuperTabPaneLayout.rightWidth;
+ double _left = SuperTabPaneLayout.leftWidth;
+ // Null until a person sets it, or it is restored: the right pane then
+ // takes the widget's default for what it shows.
+ double? _right;
int _edit = 0;
Future<void> _writing = Future.value();
@@ -75,7 +88,13 @@ class _SuperTabPaneLayoutState extends State<SuperTabPaneLayout> {
: fallback;
setState(() {
_left = width('left', _left);
- _right = width('right', _right);
+ // Builds before 10-31 saved the right pane's default with any
+ // divider move: 280 is that default (and the minimum), so it reads as
+ // no choice and a thread still opens at its own width.
+ final right = width('right', -1);
+ if (right > 0 && right != SuperTabPaneLayout.rightWidth) {
+ _right = right;
+ }
});
} catch (_) {
// A missing or old preference must not prevent opening the workspace.
@@ -85,7 +104,7 @@ class _SuperTabPaneLayoutState extends State<SuperTabPaneLayout> {
void _save() {
final store = widget.storage;
if (store == null) return;
- final value = jsonEncode({'left': _left, 'right': _right});
+ final value = jsonEncode({'left': _left, 'right': ?_right});
_writing = _writing
.then((_) => store.write(SuperTabPaneLayout.storageKey, value))
.catchError((Object _) {});
@@ -109,7 +128,11 @@ class _SuperTabPaneLayoutState extends State<SuperTabPaneLayout> {
? limit(_left, leftMin, width - centerMin - rightMin)
: 0.0;
final right = hasRight
- ? limit(_right, rightMin, width - centerMin - left)
+ ? limit(
+ _right ?? widget.rightDefault,
+ rightMin,
+ width - centerMin - left,
+ )
: 0.0;
final arrangement = PaneArrangement([
if (hasLeft) Rect.fromLTRB(0, 0, left / width, 1),
diff --git a/desktop/lib/super_tabs/thread_panel.dart b/desktop/lib/super_tabs/thread_panel.dart
index 260a7750b..e14b0d64e 100644
--- a/desktop/lib/super_tabs/thread_panel.dart
+++ b/desktop/lib/super_tabs/thread_panel.dart
@@ -18,6 +18,7 @@ import 'composer_toggle.dart';
import 'controller.dart';
import 'jump_to_latest.dart';
import 'model.dart';
+import 'project_sidebar.dart' show kProductManagersChannel;
/// One thread beside the chat (Dee, 2026-10-29): its root, a "N replies"
/// divider, the replies, and a composer whose reply goes to the root.
@@ -159,18 +160,28 @@ class _SuperTabThreadPanelState extends State<SuperTabThreadPanel> {
advance(0);
}
- /// Where "Also send" also puts the reply, as the chat is named: its hover
- /// says so, the chip itself stays short enough for the send row.
- String get _alsoSendHint {
- final group = c.selected;
- if (group != null && c.snapshot?.isProjectLead(group.id) == true) {
- return 'Also send to the project chat';
+ /// Where "Also send" also puts the reply, full wording first (Scholes,
+ /// 10-31): the project chat as its sidebar row names it, else the main
+ /// chat. A narrower send row takes the short one, never shorter: it still
+ /// says what the option does and where.
+ List<String> get _alsoSendLabels {
+ final group = c.selected, snapshot = c.snapshot;
+ String? channel;
+ if (group != null && snapshot != null) {
+ if (snapshot.isProjectLead(group.id)) {
+ channel = snapshot.projectFor(group.id)?.name;
+ } else if (group.id == snapshot.leadsConversationId) {
+ channel = kProductManagersChannel;
+ }
}
- return group?.number != null
- ? 'Also send to the workgroup'
- : 'Also send to the chat';
+ return channel == null
+ ? const ['Also post to the main chat', 'Also to chat']
+ : ['Also post to #$channel', 'Also to #$channel'];
}
+ /// One line, always the full wording.
+ String get _alsoSendHint => '${_alsoSendLabels.first} as well as this thread';
+
bool get _writable =>
c.canWrite && c.selected?.archived == false && !c.hasPendingAction;
@@ -539,26 +550,7 @@ class _SuperTabThreadPanelState extends State<SuperTabThreadPanel> {
const SizedBox(height: grid.AppDesktop.controlGap),
Row(
children: [
- Expanded(
- child: Wrap(
- crossAxisAlignment: WrapCrossAlignment.center,
- spacing: 4,
- runSpacing: 4,
- children: [
- if (_offersSession) _sessionChoice(writable),
- if (_offersAlsoSend)
- SuperTabComposerToggle(
- key: const ValueKey('super-thread-also-send'),
- on: _alsoSend,
- label: 'Also send',
- hint: _alsoSendHint,
- onChanged: writable
- ? (on) => setState(() => _alsoSend = on)
- : null,
- ),
- ],
- ),
- ),
+ Expanded(child: _choices(writable)),
NewHarnessAttachButton(
attachments: files,
enabled: writable && !busy,
@@ -588,6 +580,57 @@ class _SuperTabThreadPanelState extends State<SuperTabThreadPanel> {
);
}
+ /// The send row's options, left of attach and send, on one line at any
+ /// width (Scholes, 10-31): Also send names where it posts in full where
+ /// that fits beside New session, else its short wording; where even that
+ /// has no room (a window too narrow for the thread's default width), the
+ /// labels end in "…", their circles still showing.
+ Widget _choices(bool writable) => LayoutBuilder(
+ builder: (context, constraints) {
+ double width(String label) =>
+ SuperTabComposerToggle.widthOf(context, label);
+ final session = _offersSession ? _sessionLabel : null;
+ final alsos = _offersAlsoSend ? _alsoSendLabels : null;
+ final room =
+ constraints.maxWidth -
+ (session == null
+ ? 0
+ : width(session) + (alsos == null ? 0 : _choiceGap));
+ final also = alsos?.firstWhere(
+ (label) => width(label) <= room,
+ orElse: () => alsos.last,
+ );
+ // Fixed while both fit, Also send taking what is left; sharing the row
+ // otherwise.
+ final fits = room >= (also == null ? 0 : width(also));
+ return Row(
+ children: [
+ if (session != null)
+ fits && also != null
+ ? _sessionChoice(writable)
+ : Flexible(child: _sessionChoice(writable)),
+ if (session != null && also != null)
+ const SizedBox(width: _choiceGap),
+ if (also != null)
+ Flexible(
+ child: SuperTabComposerToggle(
+ key: const ValueKey('super-thread-also-send'),
+ on: _alsoSend,
+ label: also,
+ hint: _alsoSendHint,
+ onChanged: writable
+ ? (on) => setState(() => _alsoSend = on)
+ : null,
+ ),
+ ),
+ ],
+ );
+ },
+ );
+
+ static const _choiceGap = 4.0;
+ static const _sessionLabel = 'New session';
+
/// New session, left of Also send: on and locked once the thread's session
/// ended; greyed while it can't start, its hover saying why.
Widget _sessionChoice(bool writable) {
@@ -599,7 +642,7 @@ class _SuperTabThreadPanelState extends State<SuperTabThreadPanel> {
return SuperTabComposerToggle(
key: const ValueKey('super-thread-new-session'),
on: locked || (_newSession && !full && blocked == null),
- label: 'New session',
+ label: _sessionLabel,
hint:
blocked ??
(locked
diff --git a/desktop/lib/super_tabs/view.dart b/desktop/lib/super_tabs/view.dart
index d57716f7d..2bba0366a 100644
--- a/desktop/lib/super_tabs/view.dart
+++ b/desktop/lib/super_tabs/view.dart
@@ -3774,6 +3774,9 @@ class _SuperTabViewState extends State<SuperTabView>
left: narrow ? null : _sidebar(),
// An open thread takes the roster's side, as in Slack.
right: !showRoster ? null : thread ?? roster,
+ rightDefault: thread == null
+ ? SuperTabPaneLayout.rightWidth
+ : SuperTabPaneLayout.threadWidth,
center: Column(
children: [
_header(c.selected, narrow, showRoster),
@@ -3832,6 +3835,7 @@ class _SuperTabViewState extends State<SuperTabView>
child: SizedBox(
width: SuperTabPaneLayout.drawerWidth(
constraints.maxWidth,
+ max: SuperTabPaneLayout.threadWidth,
),
child: thread,
),
diff --git a/desktop/lib/widgets/desktop_chrome.dart b/desktop/lib/widgets/desktop_chrome.dart
index 04e61641b..44e0d1827 100644
--- a/desktop/lib/widgets/desktop_chrome.dart
+++ b/desktop/lib/widgets/desktop_chrome.dart
@@ -144,12 +144,17 @@ class DesktopPill extends StatelessWidget {
this.truncateFromStart = false,
this.menuIcon = AppIcons.chevronDown,
this.highlightFocus = false,
+ this.leadingGap = 7,
});
final String label;
final VoidCallback? onPressed;
final IconData? icon;
final Widget? leading;
+
+ /// The space between [leading] (or [icon]) and the label: a narrow row's
+ /// on/off choice (a reply box's options) sets it tighter.
+ final double leadingGap;
final bool menu, monospace;
final bool? selected;
final String? tooltip;
@@ -262,7 +267,7 @@ class DesktopPill extends StatelessWidget {
children: [
if (leading != null || icon != null) ...[
leading ?? Icon(icon, size: 16),
- const SizedBox(width: 7),
+ SizedBox(width: leadingGap),
],
Flexible(
child: truncateFromStart
diff --git a/desktop/test/super_tab_buddy_sessions_test.dart b/desktop/test/super_tab_buddy_sessions_test.dart
index 96bd1934f..54dd4299d 100644
--- a/desktop/test/super_tab_buddy_sessions_test.dart
+++ b/desktop/test/super_tab_buddy_sessions_test.dart
@@ -200,10 +200,9 @@ void main() {
expect(newSession, findsOneWidget);
expect(alsoSend, findsOneWidget);
expect(box(tester, newSession).on, isFalse);
- // Before Also send in reading order: left of it on one row, or above it
- // where a narrow pane wraps them.
+ // Left of Also send on one row, at any width (Scholes, 10-31).
final a = tester.getRect(newSession), b = tester.getRect(alsoSend);
- expect(a.top < b.top || (a.top == b.top && a.left < b.left), isTrue);
+ expect(a.top == b.top && a.left < b.left, isTrue);
expect(
find.byTooltip('Starts a separate Buddy session for this thread'),
findsOneWidget,
@@ -240,8 +239,13 @@ void main() {
findsNothing,
);
expect(box(tester, newSession).label, 'New session');
- expect(box(tester, alsoSend).label, 'Also send');
- expect(find.byTooltip('Also send to the chat'), findsOneWidget);
+ // The default 280px pane has no room for the full wording beside New
+ // session: its hint keeps it.
+ expect(box(tester, alsoSend).label, 'Also to chat');
+ expect(
+ find.byTooltip('Also post to the main chat as well as this thread'),
+ findsOneWidget,
+ );
// Both sit on the send row, left of its buttons, and are compact: no
// taller than the send button. (One line at real fonts: the PR's
// screenshots; the test font is far wider.)
diff --git a/desktop/test/super_tab_pane_layout_test.dart b/desktop/test/super_tab_pane_layout_test.dart
index b79e4b23f..4f21fede4 100644
--- a/desktop/test/super_tab_pane_layout_test.dart
+++ b/desktop/test/super_tab_pane_layout_test.dart
@@ -28,6 +28,7 @@ void main() {
MemoryStore store, {
bool sides = true,
double scale = 1,
+ double rightDefault = SuperTabPaneLayout.rightWidth,
}) async {
await tester.pumpWidget(
MaterialApp(
@@ -41,6 +42,7 @@ void main() {
body: SuperTabPaneLayout(
storage: store,
onLeave: () {},
+ rightDefault: rightDefault,
left: sides ? const ColoredBox(color: Colors.black) : null,
right: sides ? const ColoredBox(color: Colors.black) : null,
center: const TextField(key: ValueKey('draft')),
@@ -171,4 +173,86 @@ void main() {
expect(tester.getSize(center).width, greaterThanOrEqualTo(720));
expect(tester.takeException(), isNull);
});
+
+ testWidgets('a thread opens at its own default width, the roster keeps '
+ 'its own, and a width set by the divider wins for both', (tester) async {
+ await tester.binding.setSurfaceSize(const Size(1400, 800));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ final store = MemoryStore();
+ const thread = SuperTabPaneLayout.threadWidth;
+ await mount(tester, store, rightDefault: thread);
+ expect(tester.getSize(right).width, 340);
+ await mount(tester, store);
+ expect(tester.getSize(right).width, 280);
+ await mount(tester, store, rightDefault: thread);
+ expect(tester.getSize(right).width, 340);
+ // Moving the left divider leaves the right pane's default alone.
+ await tester.drag(leftHandle, const Offset(40, 0));
+ await tester.pumpAndSettle();
+ expect(tester.getSize(right).width, 340);
+ expect(
+ jsonDecode(store.values[SuperTabPaneLayout.storageKey]!),
+ isNot(contains('right')),
+ );
+
+ await tester.drag(rightHandle, const Offset(40, 0));
+ await tester.pumpAndSettle();
+ expect(tester.getSize(right).width, closeTo(300, 1));
+ await mount(tester, store);
+ expect(tester.getSize(right).width, closeTo(300, 1));
+ await tester.pumpWidget(const SizedBox());
+ await mount(tester, store, rightDefault: thread);
+ expect(tester.getSize(right).width, closeTo(300, 1));
+ expect(tester.takeException(), isNull);
+ });
+
+ testWidgets('a thread narrower than its default only where the window '
+ 'leaves the chat no more than its minimum, never below 280', (
+ tester,
+ ) async {
+ final store = MemoryStore();
+ const thread = SuperTabPaneLayout.threadWidth;
+ await tester.binding.setSurfaceSize(const Size(1080, 800));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ await mount(tester, store, rightDefault: thread);
+ expect(tester.getSize(right).width, 340);
+ expect(tester.getSize(center).width, greaterThan(360));
+
+ await tester.binding.setSurfaceSize(const Size(960, 800));
+ await tester.pumpAndSettle();
+ expect(tester.getSize(center).width, closeTo(360, 1));
+ expect(tester.getSize(right).width, closeTo(300, 1));
+
+ await tester.binding.setSurfaceSize(const Size(900, 800));
+ await tester.pumpAndSettle();
+ expect(tester.getSize(right).width, closeTo(280, 1));
+ expect(tester.takeException(), isNull);
+ });
+
+ test('a thread drawer is as wide as a thread, within its share of the '
+ 'window', () {
+ const thread = SuperTabPaneLayout.threadWidth;
+ expect(SuperTabPaneLayout.drawerWidth(1000), 280);
+ expect(SuperTabPaneLayout.drawerWidth(1000, max: thread), 340);
+ expect(SuperTabPaneLayout.drawerWidth(400, max: thread), 280);
+ });
+
+ testWidgets('a saved 280 from older builds, written with any divider move, '
+ 'leaves a thread at its own default', (tester) async {
+ await tester.binding.setSurfaceSize(const Size(1400, 800));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ final store = MemoryStore()
+ ..values[SuperTabPaneLayout.storageKey] = '{"left":400,"right":280}';
+ await mount(tester, store, rightDefault: SuperTabPaneLayout.threadWidth);
+ expect(tester.getSize(left).width, 400);
+ expect(tester.getSize(right).width, 340);
+ await mount(tester, store);
+ expect(tester.getSize(right).width, 280);
+
+ final chosen = MemoryStore()
+ ..values[SuperTabPaneLayout.storageKey] = '{"left":400,"right":310}';
+ await tester.pumpWidget(const SizedBox());
+ await mount(tester, chosen, rightDefault: SuperTabPaneLayout.threadWidth);
+ expect(tester.getSize(right).width, 310);
+ });
}
diff --git a/desktop/test/super_tab_reply_box_shots_test.dart b/desktop/test/super_tab_reply_box_shots_test.dart
new file mode 100644
index 000000000..5ba1f914b
--- /dev/null
+++ b/desktop/test/super_tab_reply_box_shots_test.dart
@@ -0,0 +1,166 @@
+import 'dart:io';
+import 'dart:ui' as ui;
+
+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/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_REPLY_BOX_SHOTS'];
+
+/// The thread reply box's options as the PR shows them (Scholes, 10-31), in
+/// both appearances: a project thread and a Buddy thread, Also send off and
+/// on, at the thread's default width, widened, and dragged to the 280px
+/// minimum (the "…" fallback), and the hover hint.
+void main() {
+ setUpAll(() async {
+ if (shots != null) await loadPreviewFonts();
+ });
+
+ ConversationServer projectChat() {
+ final server = ConversationServer()..threads = true;
+ server.state['name'] = 'openharness';
+ server.append('Should the reply box name where Also send posts?');
+ server.append('Yes: one row, and say the chat.');
+ server.messages.last
+ ..['thread'] = 'message-1'
+ ..['replyTo'] = 'message-1';
+ return server;
+ }
+
+ ConversationServer buddyChat() {
+ final server = ConversationServer()..threads = true;
+ server.state['threadSessions'] = true;
+ (server.state['conversations'] as List)[1] as Map
+ ..['kind'] = 'buddy'
+ ..['buddyOwnerId'] = 'owner'
+ ..['title'] = 'Wren'
+ ..['agentIds'] = ['buddy-main'];
+ (server.state['agents'] as List).add({
+ 'id': 'buddy-main',
+ 'name': 'Wren',
+ 'displayName': 'Wren',
+ 'machineId': 'mac',
+ 'harnessId': 'h-main',
+ 'contributorId': 'owner',
+ 'buddyOf': {'personId': 'owner', 'generation': 'g1'},
+ 'configuration': {'engine': 'claude'},
+ });
+ server.append(
+ 'Measure prod CPU for the last day',
+ conversationId: 'offline',
+ );
+ server.append(
+ 'On it: reading the last 24 hours.',
+ conversationId: 'offline',
+ );
+ server.messages.last
+ ..['thread'] = 'message-1'
+ ..['replyTo'] = 'message-1';
+ return server;
+ }
+
+ for (final brightness in Brightness.values) {
+ for (final scene in [
+ 'project-off',
+ 'project-on',
+ 'buddy-off',
+ 'buddy-on',
+ 'buddy-hint',
+ 'buddy-session-on',
+ 'buddy-wide-off',
+ 'buddy-wide-on',
+ 'buddy-280-off',
+ 'buddy-280-on',
+ 'buddy-280-hint',
+ ]) {
+ testWidgets('screenshots for review ($scene, ${brightness.name})', (
+ tester,
+ ) async {
+ final picture = GlobalKey();
+ final buddy = scene.startsWith('buddy');
+ final server = buddy ? buddyChat() : projectChat();
+ final c = server.controller();
+ addTearDown(c.dispose);
+ await c.refresh();
+ grid.AppTheme.brightness.value = brightness;
+ addTearDown(() => grid.AppTheme.brightness.value = Brightness.light);
+ await tester.binding.setSurfaceSize(const Size(1280, 720));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ 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 c.select(buddy ? 'offline' : 'lead');
+ await tester.pumpAndSettle();
+ c.openThread('message-1');
+ await tester.pumpAndSettle();
+ if (scene.contains('wide') || scene.contains('280')) {
+ // Resize the thread pane by its divider, as a person drags it:
+ // wider, or to its narrowest.
+ await tester.drag(
+ find.byKey(const ValueKey('super-resize-right')),
+ Offset(scene.contains('wide') ? -220 : 200, 0),
+ );
+ await tester.pumpAndSettle();
+ }
+ await tester.enterText(
+ find.byKey(const ValueKey('super-thread-composer')),
+ 'Measure it now, and compare with last week.',
+ );
+ await tester.pump();
+ final also = find.byKey(const ValueKey('super-thread-also-send'));
+ if (scene == 'buddy-session-on') {
+ await tester.tap(
+ find.byKey(const ValueKey('super-thread-new-session')),
+ );
+ await tester.pump();
+ } else if (scene.endsWith('-on')) {
+ await tester.tap(also);
+ await tester.pump();
+ }
+ if (scene.endsWith('-hint')) {
+ final gesture = await tester.createGesture(
+ kind: ui.PointerDeviceKind.mouse,
+ );
+ await gesture.addPointer(location: Offset.zero);
+ addTearDown(gesture.removePointer);
+ await gesture.moveTo(tester.getCenter(also));
+ await tester.pump(const Duration(seconds: 2));
+ }
+ await tester.pumpAndSettle();
+
+ await tester.runAsync(() async {
+ final boundary =
+ picture.currentContext!.findRenderObject()!
+ as RenderRepaintBoundary;
+ final image = await boundary.toImage(pixelRatio: 2);
+ final bytes = await image.toByteData(format: ui.ImageByteFormat.png);
+ await Directory(shots!).create(recursive: true);
+ await File('$shots/reply-box-$scene-${brightness.name}.png')
+ .writeAsBytes(bytes!.buffer.asUint8List());
+ image.dispose();
+ });
+ await tester.pumpWidget(const SizedBox());
+ await c.flush();
+ }, skip: shots == null);
+ }
+ }
+}
diff --git a/desktop/test/super_tab_reply_box_test.dart b/desktop/test/super_tab_reply_box_test.dart
new file mode 100644
index 000000000..313da2d24
--- /dev/null
+++ b/desktop/test/super_tab_reply_box_test.dart
@@ -0,0 +1,381 @@
+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_theme.dart' as grid;
+import 'package:harness/super_tabs/composer_toggle.dart';
+import 'package:harness/super_tabs/controller.dart';
+import 'package:harness/super_tabs/model.dart';
+import 'package:harness/super_tabs/pane_layout.dart';
+import 'package:harness/super_tabs/thread_panel.dart';
+
+import 'box_render_preview_test.dart' show loadPreviewFonts;
+import 'support/super_tab_fixture.dart';
+
+/// The thread reply box's options (Scholes, 10-31): one row, options left and
+/// attach and send right; Also send names where it posts, shortened only
+/// where the pane is too narrow; both options read as on/off choices, with a
+/// one-line hover hint.
+void main() {
+ // The Mac's own face, where there is one: what the default width is chosen
+ // for. Every other test here measures whatever face it draws in.
+ final systemFace = File('/System/Library/Fonts/SFNS.ttf').existsSync();
+ setUpAll(() async {
+ if (!systemFace) return;
+ try {
+ await loadPreviewFonts();
+ } catch (_) {
+ // Icons from another pub cache: the text face is what counts here.
+ }
+ });
+
+ final newSession = find.byKey(const ValueKey('super-thread-new-session'));
+ final alsoSend = find.byKey(const ValueKey('super-thread-also-send'));
+ final send = find.byKey(const ValueKey('super-thread-send'));
+ final surface = find.byKey(const ValueKey('super-thread-composer-surface'));
+ final note = find.byKey(const ValueKey('super-thread-session-note'));
+
+ late SuperTabController shown;
+
+ void testBox(
+ String description,
+ Future<void> Function(WidgetTester) body, {
+ bool skip = false,
+ }) => testWidgets(description, (tester) async {
+ await body(tester);
+ await tester.pumpWidget(const SizedBox());
+ await shown.flush();
+ }, skip: skip);
+
+ /// A project chat ('lead', named "Pilot") with a thread on message-1.
+ ConversationServer projectChat() {
+ final server = ConversationServer()..threads = true;
+ server.append('Should we do thread replies?');
+ server.append('Yes, like Slack.');
+ server.messages.last
+ ..['thread'] = 'message-1'
+ ..['replyTo'] = 'message-1';
+ return server;
+ }
+
+ /// The reader's own Buddy chat ('offline') with their Buddy running and a
+ /// thread on message-1; New session is offered unless [sessions] is false.
+ ConversationServer buddyChat({bool sessions = true}) {
+ final server = ConversationServer()..threads = true;
+ if (sessions) server.state['threadSessions'] = true;
+ (server.state['conversations'] as List)[1] as Map
+ ..['kind'] = 'buddy'
+ ..['buddyOwnerId'] = 'owner'
+ ..['title'] = 'Wren'
+ ..['agentIds'] = ['buddy-main'];
+ (server.state['agents'] as List).add({
+ 'id': 'buddy-main',
+ 'name': 'Wren',
+ 'displayName': 'Wren',
+ 'machineId': 'mac',
+ 'harnessId': 'h-main',
+ 'contributorId': 'owner',
+ 'buddyOf': {'personId': 'owner', 'generation': 'g1'},
+ 'configuration': {'engine': 'claude'},
+ });
+ server.append(
+ 'Measure prod CPU for the last day',
+ conversationId: 'offline',
+ );
+ server.append('On it', conversationId: 'offline');
+ server.messages.last
+ ..['thread'] = 'message-1'
+ ..['replyTo'] = 'message-1';
+ return server;
+ }
+
+ /// The thread pane alone, [width] wide, at [textScale].
+ Future<SuperTabController> panel(
+ WidgetTester tester,
+ ConversationServer server,
+ String conversation, {
+ double width = SuperTabPaneLayout.threadWidth,
+ double textScale = 1,
+ }) async {
+ await tester.binding.setSurfaceSize(const Size(1400, 900));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ final c = shown = server.controller();
+ await c.refresh();
+ await c.select(conversation);
+ c.openThread('message-1');
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: grid.buildAppTheme(brightness: Brightness.light),
+ builder: (context, child) => MediaQuery(
+ data: MediaQuery.of(context)
+ .copyWith(textScaler: TextScaler.linear(textScale)),
+ child: child!,
+ ),
+ home: Scaffold(
+ body: Align(
+ alignment: Alignment.topLeft,
+ child: SizedBox(
+ width: width,
+ height: 600,
+ child: SuperTabThreadPanel(
+ controller: c,
+ root: 'message-1',
+ row: (SuperTabMessage m, bool _) => Text(m.text),
+ outgoing: (_) => const SizedBox(),
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+ return c;
+ }
+
+ SuperTabComposerToggle box(WidgetTester tester, Finder finder) =>
+ tester.widget<SuperTabComposerToggle>(finder);
+
+ /// The circle (off) or check (on) inside [chip], drawn inside its bounds.
+ void expectMark(WidgetTester tester, Finder chip, {required bool on}) {
+ final mark = find.descendant(
+ of: chip,
+ matching: find.byKey(
+ ValueKey(on ? 'composer-toggle-check' : 'composer-toggle-off'),
+ ),
+ );
+ expect(mark, findsOneWidget);
+ final rect = tester.getRect(mark), bounds = tester.getRect(chip);
+ expect(rect.width, greaterThan(0));
+ expect(bounds.contains(rect.center), isTrue);
+ expect(rect.right, lessThanOrEqualTo(bounds.right));
+ }
+
+ /// Every option sits on the send button's row, vertically centred with it,
+ /// left of attach and send, inside the box.
+ void expectOneRow(WidgetTester tester, List<Finder> chips) {
+ final sendRect = tester.getRect(send);
+ final box = tester.getRect(surface);
+ double? right;
+ for (final chip in chips) {
+ final rect = tester.getRect(chip);
+ expect((rect.center.dy - sendRect.center.dy).abs(), lessThan(1));
+ expect(rect.right, lessThan(sendRect.left));
+ expect(rect.left, greaterThanOrEqualTo(box.left));
+ if (right != null) expect(rect.left, greaterThan(right));
+ right = rect.right;
+ }
+ }
+
+ group('Also send names where it posts', () {
+ testBox('a project thread names the project chat in full', (tester) async {
+ await panel(tester, projectChat(), 'lead', width: 800);
+ expect(box(tester, alsoSend).label, 'Also post to #Pilot');
+ expect(
+ find.byTooltip('Also post to #Pilot as well as this thread'),
+ findsOneWidget,
+ );
+ expectOneRow(tester, [alsoSend]);
+ });
+
+ testBox('a Buddy thread with room says the main chat in full, beside '
+ 'New session', (tester) async {
+ await panel(tester, buddyChat(), 'offline', width: 800);
+ expect(box(tester, alsoSend).label, 'Also post to the main chat');
+ expect(
+ find.byTooltip('Also post to the main chat as well as this thread'),
+ findsOneWidget,
+ );
+ expectOneRow(tester, [newSession, alsoSend]);
+ });
+
+ /// The width the send row's options have in a thread pane [pane] wide:
+ /// the pane less the box's insets and attach and send, as laid out.
+ double Function(double pane) roomIn(WidgetTester tester) {
+ final sendRow = tester.getRect(
+ find.byKey(const ValueKey('new-harness-attach')),
+ );
+ final box = tester.getRect(surface);
+ final pane = tester.getRect(find.byType(SuperTabThreadPanel));
+ // The rim is drawn, not laid out: the options start 16 in.
+ final insets = pane.width - (sendRow.left - box.left - 16);
+ return (width) => width - insets;
+ }
+
+ double widthOf(WidgetTester tester, String label) =>
+ SuperTabComposerToggle.widthOf(tester.element(alsoSend), label);
+
+ for (final (kind, full, short) in [
+ ('project', 'Also post to #Pilot', 'Also to #Pilot'),
+ ('Buddy', 'Also post to the main chat', 'Also to chat'),
+ ]) {
+ testBox('a $kind thread steps down to "$short" where "$full" has no '
+ 'room, never shorter: below that the label ends in "…" and its '
+ 'circle shows', (tester) async {
+ final buddy = kind == 'Buddy';
+ ConversationServer server() => buddy ? buddyChat() : projectChat();
+ final conversation = buddy ? 'offline' : 'lead';
+ await panel(tester, server(), conversation, width: 800);
+ final room = roomIn(tester);
+ final beside = buddy ? widthOf(tester, 'New session') + 4 : 0.0;
+ final fullFits = widthOf(tester, full) + beside;
+ final shortFits = widthOf(tester, short) + beside;
+ double paneFor(double needed) => 800 - room(800) + needed;
+ await tester.pumpWidget(const SizedBox());
+ await shown.flush();
+
+ for (final (pane, label) in [
+ (paneFor(fullFits) + 1, full),
+ (paneFor(fullFits) - 1, short),
+ (paneFor(shortFits) + 1, short),
+ (paneFor(shortFits) - 12, short),
+ ]) {
+ await panel(tester, server(), conversation, width: pane);
+ expect(box(tester, alsoSend).label, label, reason: 'at $pane');
+ expect(
+ find.byTooltip('$full as well as this thread'),
+ findsOneWidget,
+ );
+ if (buddy) expect(box(tester, newSession).label, 'New session');
+ expectOneRow(tester, [if (buddy) newSession, alsoSend]);
+ expectMark(tester, alsoSend, on: false);
+ if (buddy) expectMark(tester, newSession, on: false);
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const SizedBox());
+ await shown.flush();
+ }
+ });
+ }
+ });
+
+ group('the options read as on/off choices', () {
+ testBox('off is an empty circle, on a check; tapping toggles it', (
+ tester,
+ ) async {
+ await panel(tester, projectChat(), 'lead', width: 800);
+ expect(box(tester, alsoSend).on, isFalse);
+ expectMark(tester, alsoSend, on: false);
+ bool? toggled() => tester
+ .widget<Semantics>(
+ find
+ .descendant(of: alsoSend, matching: find.byType(Semantics))
+ .first,
+ )
+ .properties
+ .toggled;
+ expect(toggled(), isFalse);
+
+ await tester.tap(alsoSend);
+ await tester.pump();
+ expect(box(tester, alsoSend).on, isTrue);
+ expectMark(tester, alsoSend, on: true);
+ expect(toggled(), isTrue);
+
+ await tester.tap(alsoSend);
+ await tester.pump();
+ expect(box(tester, alsoSend).on, isFalse);
+ expectMark(tester, alsoSend, on: false);
+ });
+
+ testBox('New session reads the same way, and while on it hides Also '
+ 'send and shows the note; the box never moves', (tester) async {
+ await panel(tester, buddyChat(), 'offline');
+ final before = tester.getRect(surface);
+ expectMark(tester, newSession, on: false);
+ expect(
+ find.byTooltip('Starts a separate Buddy session for this thread'),
+ findsOneWidget,
+ );
+
+ await tester.tap(alsoSend);
+ await tester.pump();
+ expect(tester.getRect(surface), before);
+
+ await tester.tap(newSession);
+ await tester.pump();
+ expectMark(tester, newSession, on: true);
+ expect(alsoSend, findsNothing);
+ expect(
+ tester
+ .widget<Visibility>(
+ find.ancestor(of: note, matching: find.byType(Visibility)),
+ )
+ .visible,
+ isTrue,
+ );
+ expect(tester.getRect(surface), before);
+
+ await tester.tap(newSession);
+ await tester.pump();
+ expect(alsoSend, findsOneWidget);
+ expect(tester.getRect(surface), before);
+ });
+ });
+
+ group('one row at any width and text size', () {
+ for (final (width, scale) in [
+ (SuperTabPaneLayout.threadWidth, 1.0),
+ // The pane's minimum grows with the text (pane_layout.dart).
+ (SuperTabPaneLayout.rightWidth * 1.6, 1.6),
+ (SuperTabPaneLayout.rightWidth * 2, 2.0),
+ // A window too narrow for the thread's default: "…", the marks stay.
+ (SuperTabPaneLayout.rightWidth, 1.0),
+ // Narrower than the app allows.
+ (SuperTabPaneLayout.rightWidth, 2.0),
+ ]) {
+ testBox('${width.round()}px at ${scale}x: one row, no overflow, both '
+ 'marks showing', (tester) async {
+ await panel(
+ tester,
+ buddyChat(),
+ 'offline',
+ width: width,
+ textScale: scale,
+ );
+ expect(tester.takeException(), isNull);
+ expectOneRow(tester, [newSession, alsoSend]);
+ expectMark(tester, newSession, on: false);
+ expectMark(tester, alsoSend, on: false);
+ // One line each: the same top and height, never wrapped below.
+ final a = tester.getRect(newSession), b = tester.getRect(alsoSend);
+ expect(a.top, b.top);
+ expect(a.height, b.height);
+ });
+ }
+
+ testBox('a project thread in a wide pane keeps its row with only Also '
+ 'send', (tester) async {
+ await panel(tester, projectChat(), 'lead', width: 800);
+ expect(newSession, findsNothing);
+ expectOneRow(tester, [alsoSend]);
+ });
+ });
+
+ testBox('at the thread\'s default width, in the Mac\'s face, a Buddy '
+ 'thread fits "New session" and "Also to chat" with no "…", and a '
+ 'project thread names #openharness in full', (tester) async {
+ await panel(tester, buddyChat(), 'offline');
+ expect(box(tester, newSession).label, 'New session');
+ expect(box(tester, alsoSend).label, 'Also to chat');
+ for (final (chip, label) in [
+ (newSession, 'New session'),
+ (alsoSend, 'Also to chat'),
+ ]) {
+ final text = find.descendant(of: chip, matching: find.text(label));
+ final paragraph = tester.renderObject<RenderParagraph>(text);
+ expect(paragraph.didExceedMaxLines, isFalse, reason: label);
+ expect(
+ paragraph.size.width,
+ greaterThanOrEqualTo(paragraph.getMaxIntrinsicWidth(100) - .5),
+ reason: label,
+ );
+ }
+ await tester.pumpWidget(const SizedBox());
+ await shown.flush();
+
+ final project = projectChat();
+ project.state['name'] = 'openharness';
+ await panel(tester, project, 'lead');
+ expect(box(tester, alsoSend).label, 'Also post to #openharness');
+ }, skip: !systemFace);
+}
diff --git a/desktop/test/super_tab_threads_test.dart b/desktop/test/super_tab_threads_test.dart
index 4e512366f..90fca6093 100644
--- a/desktop/test/super_tab_threads_test.dart
+++ b/desktop/test/super_tab_threads_test.dart
@@ -509,14 +509,18 @@ void main() {
});
testWidgets('a reply from the thread composer goes to the root, and '
- '"Also send to the project chat" sends it to both', (tester) async {
+ '"Also post to #Pilot" sends it to both', (tester) async {
final server = threaded();
final c = await show(tester, server);
+ // The test platform's touch handles sit under a typed reply's end:
+ // where the wide pane puts it, over send. Leaving the box hides them.
+ void hideHandles() => FocusManager.instance.primaryFocus?.unfocus();
await tester.tap(line('message-1'));
await tester.pumpAndSettle();
- expect(inPanel(find.text('Also send')), findsOneWidget);
+ // The label shortens where the test font leaves no room; its hint keeps
+ // the full wording (super_tab_reply_box_test.dart covers the label).
expect(
- inPanel(find.byTooltip('Also send to the project chat')),
+ inPanel(find.byTooltip('Also post to #Pilot as well as this thread')),
findsOneWidget,
);
await tester.enterText(
@@ -524,6 +528,8 @@ void main() {
'In the thread only.',
);
await tester.pump();
+ hideHandles();
+ await tester.pump();
await tester.tap(find.byKey(const ValueKey('super-thread-send')));
await tester.pumpAndSettle();
Map sentLast() => server.posts
@@ -541,6 +547,8 @@ void main() {
'Everyone should see this.',
);
await tester.pump();
+ hideHandles();
+ await tester.pump();
await tester.tap(find.byKey(const ValueKey('super-thread-send')));
await tester.pumpAndSettle();
expect(sentLast()['alsoSend'], isTrue);