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.

Threads page: card text can be selected and copied, #-links open their task (#3361)

harness-for-autonomous[bot]3bfd989a766f
diff --git a/desktop/lib/super_tabs/threads_page.dart b/desktop/lib/super_tabs/threads_page.dart
index 43226f144..f7fb9d3f8 100644
--- a/desktop/lib/super_tabs/threads_page.dart
+++ b/desktop/lib/super_tabs/threads_page.dart
@@ -94,24 +94,28 @@ class _SuperTabThreadsPageState extends State<SuperTabThreadsPage> {
onOpenThread: widget.onOpenThread,
message: widget.message,
);
- return LaidOutListView(
- key: const ValueKey('super-threads-list'),
- padding: const EdgeInsets.only(bottom: grid.AppDesktop.groupGap),
- children: [
- if (attention.error case final error?)
- superTabPageError(error, () => unawaited(attention.load())),
- if (unread.isEmpty && read.isEmpty)
- superTabPageEmpty('No threads yet')
- else ...[
- for (final t in unread) card(t),
- for (final t in read) card(t),
- if (attention.canReadMore)
- SuperTabReadMore(
- key: const ValueKey('super-threads-more'),
- onShown: attention.readMore,
- ),
+ // As in the chat and the thread pane, a message's text can be selected
+ // and copied (task #3751); a tap on a card's title still opens it.
+ return SelectionArea(
+ child: LaidOutListView(
+ key: const ValueKey('super-threads-list'),
+ padding: const EdgeInsets.only(bottom: grid.AppDesktop.groupGap),
+ children: [
+ if (attention.error case final error?)
+ superTabPageError(error, () => unawaited(attention.load())),
+ if (unread.isEmpty && read.isEmpty)
+ superTabPageEmpty('No threads yet')
+ else ...[
+ for (final t in unread) card(t),
+ for (final t in read) card(t),
+ if (attention.canReadMore)
+ SuperTabReadMore(
+ key: const ValueKey('super-threads-more'),
+ onShown: attention.readMore,
+ ),
+ ],
],
- ],
+ ),
);
},
);
@@ -313,12 +317,14 @@ class _ThreadCardState extends State<_ThreadCard> {
),
),
if (attention.followSupported)
- quietDecisionAction(
- key: ValueKey('super-thread-card-unfollow:$_key'),
- label: 'Unfollow',
- onPressed: attention.following.contains(_key)
- ? null
- : () => unawaited(attention.setFollow(t, false)),
+ SelectionContainer.disabled(
+ child: quietDecisionAction(
+ key: ValueKey('super-thread-card-unfollow:$_key'),
+ label: 'Unfollow',
+ onPressed: attention.following.contains(_key)
+ ? null
+ : () => unawaited(attention.setFollow(t, false)),
+ ),
),
],
);
@@ -395,19 +401,21 @@ class _ThreadCardState extends State<_ThreadCard> {
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: card.loadingOlder
- ? null
- : () => unawaited(widget.cards.expand(t)),
- child: Text(
- card.loadingOlder
- ? 'Loading replies…'
- : hidden == 1
- ? 'Show 1 more reply'
- : 'Show $hidden more replies',
+ SelectionContainer.disabled(
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: TextButton(
+ key: ValueKey('super-thread-card-more:$_key'),
+ onPressed: card.loadingOlder
+ ? null
+ : () => unawaited(widget.cards.expand(t)),
+ child: Text(
+ card.loadingOlder
+ ? 'Loading replies…'
+ : hidden == 1
+ ? 'Show 1 more reply'
+ : 'Show $hidden more replies',
+ ),
),
),
),
@@ -481,7 +489,9 @@ class _ThreadCardState extends State<_ThreadCard> {
children: [
..._messages(card),
const SizedBox(height: grid.AppDesktop.controlGap),
- _replyBox(),
+ // What was said is selectable; the card's controls are not
+ // (task #3751), as the chat's composer is outside its selection.
+ SelectionContainer.disabled(child: _replyBox()),
if (_alsoOffered)
Padding(
padding: const EdgeInsets.only(
@@ -489,14 +499,16 @@ class _ThreadCardState extends State<_ThreadCard> {
),
child: Align(
alignment: Alignment.centerLeft,
- child: SuperTabComposerToggle(
- key: ValueKey('super-thread-card-also:$_key'),
- on: _alsoSend,
- label: _alsoLabel,
- hint: '$_alsoLabel as well as this thread',
- onChanged: _writable
- ? (on) => setState(() => _alsoSend = on)
- : null,
+ child: SelectionContainer.disabled(
+ child: SuperTabComposerToggle(
+ key: ValueKey('super-thread-card-also:$_key'),
+ on: _alsoSend,
+ label: _alsoLabel,
+ hint: '$_alsoLabel as well as this thread',
+ onChanged: _writable
+ ? (on) => setState(() => _alsoSend = on)
+ : null,
+ ),
),
),
),
diff --git a/desktop/lib/super_tabs/view.dart b/desktop/lib/super_tabs/view.dart
index 83b093eb9..50726503e 100644
--- a/desktop/lib/super_tabs/view.dart
+++ b/desktop/lib/super_tabs/view.dart
@@ -4306,7 +4306,12 @@ class _SuperTabViewState extends State<SuperTabView>
},
references: _references,
onOpenGroup: (id) {
- setState(() => _showPullRequests = _showTasks = false);
+ setState(() {
+ _showPullRequests = _showTasks = false;
+ // From a page's card (Threads), the chat comes forward: changing
+ // only the chat behind the page left the link looking dead (#3751).
+ _page = null;
+ });
c.select(id);
c.selectTerminal(id, null);
},
diff --git a/desktop/test/super_tab_places_view_test.dart b/desktop/test/super_tab_places_view_test.dart
index 223835334..6ee039a9b 100644
--- a/desktop/test/super_tab_places_view_test.dart
+++ b/desktop/test/super_tab_places_view_test.dart
@@ -1,3 +1,4 @@
+import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness/shared/theme/app_theme.dart' as grid;
@@ -5,7 +6,7 @@ import 'package:harness/super_tabs/controller.dart';
import 'package:harness/super_tabs/places.dart';
import 'package:harness/super_tabs/view.dart';
-import 'super_tab_activity_lists_test.dart' show swarm;
+import 'super_tab_activity_lists_test.dart' show swarm, unreadThread;
import 'support/super_tab_fixture.dart';
/// The Swarm view of task #2996: the sidebar's three rows open their pages,
@@ -25,13 +26,15 @@ void main() {
Finder key(String k) => find.byKey(ValueKey(k));
Future<(SuperTabController, ConversationServer)> show(
- WidgetTester tester,
- ) async {
+ WidgetTester tester, {
+ void Function(ConversationServer server)? prepare,
+ }) async {
await tester.binding.setSurfaceSize(const Size(1300, 800));
addTearDown(() => tester.binding.setSurfaceSize(null));
final server = swarm();
server.append('A root to thread on');
server.ask(['Ship it?']);
+ prepare?.call(server);
final c = server.controller(
account: 'owner',
initial: {'tabId': 'tab', 'accountId': 'owner', 'selectedId': 'lead'},
@@ -83,6 +86,57 @@ void main() {
await end(tester, c);
});
+ // Tuan, task #3751: on the Threads page a card's #-link to a task changed the chat behind the page, so
+ // nothing on screen moved and the link read as dead.
+ testWidgets('a #-link in a Threads card opens its task, as in the chat', (
+ tester,
+ ) async {
+ final (c, _) = await show(
+ tester,
+ prepare: (server) {
+ (server.state['conversations'] as List)
+ .cast<Map<String, dynamic>>()
+ .firstWhere((g) => g['id'] == 'offline')['number'] =
+ 42;
+ server.append('See #42 for the fix.');
+ final root = server.messages.last['id'] as String;
+ server.followedThreads = {
+ 'unread': [
+ unreadThread(root, text: 'See #42 for the fix.')
+ ..['conversationId'] = 'lead',
+ ],
+ 'read': [],
+ 'more': false,
+ };
+ },
+ );
+ await tap(tester, 'super-threads');
+ expect(key('super-threads-list'), findsOneWidget);
+
+ TextSpan? link;
+ for (final text in tester.widgetList<RichText>(
+ find.descendant(
+ of: key('super-threads-list'),
+ matching: find.byType(RichText),
+ ),
+ )) {
+ text.text.visitChildren((span) {
+ if (span is TextSpan &&
+ span.text == '#42' &&
+ span.recognizer is TapGestureRecognizer) {
+ link = span;
+ }
+ return true;
+ });
+ }
+ expect(link, isNotNull, reason: 'the card shows #42 as a link');
+ (link!.recognizer! as TapGestureRecognizer).onTap!();
+ await _settle(tester);
+ expect(key('super-threads-list'), findsNothing);
+ expect(c.selectedId, 'offline');
+ await end(tester, c);
+ });
+
testWidgets('Back returns from a chat to the page it was opened from, and '
'Forward goes to the chat again', (tester) async {
final (c, _) = await show(tester);
diff --git a/desktop/test/super_tab_threads_page_shots_test.dart b/desktop/test/super_tab_threads_page_shots_test.dart
index 0ea772300..c0a7e36c7 100644
--- a/desktop/test/super_tab_threads_page_shots_test.dart
+++ b/desktop/test/super_tab_threads_page_shots_test.dart
@@ -183,6 +183,16 @@ void main() {
shots,
'threads-page-expanded-${brightness.name}',
);
+ // Task #3751: the cards' text can be selected and copied, as in the chat.
+ tester
+ .state<SelectableRegionState>(find.byType(SelectableRegion).first)
+ .selectAll(SelectionChangedCause.keyboard);
+ await tester.pumpAndSettle();
+ await captureWindow(
+ tester,
+ shots,
+ 'threads-page-selected-${brightness.name}',
+ );
});
});
}
diff --git a/desktop/test/super_tab_threads_page_test.dart b/desktop/test/super_tab_threads_page_test.dart
index 91a6f5ff7..dce68f140 100644
--- a/desktop/test/super_tab_threads_page_test.dart
+++ b/desktop/test/super_tab_threads_page_test.dart
@@ -2,6 +2,7 @@ import 'dart:async';
import 'package:clock/clock.dart';
import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness/shared/theme/app_theme.dart' as grid;
import 'package:harness/super_tabs/activity.dart';
@@ -254,6 +255,59 @@ void main() {
Finder inCard(String id, Finder f) =>
find.descendant(of: _key('super-thread-card:lead/$id'), matching: f);
+ testWidgets('a card\'s text can be selected and copied, and a tap on its '
+ 'title still opens the thread (task #3751)', (tester) async {
+ String? copied;
+ final messenger =
+ TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger;
+ messenger.setMockMethodCallHandler(SystemChannels.platform, (call) async {
+ if (call.method == 'Clipboard.setData') {
+ copied = (call.arguments as Map)['text'] as String;
+ }
+ return null;
+ });
+ addTearDown(
+ () => messenger.setMockMethodCallHandler(SystemChannels.platform, null),
+ );
+ final server = swarm();
+ final id = _thread(
+ server,
+ 'Can we copy this?',
+ replies: [('Kestrel', 'Yes, select it.')],
+ );
+ server.followedThreads = {
+ 'unread': [],
+ 'read': [_followed(server, id)],
+ 'more': false,
+ };
+ await withClock(Clock.fixed(_now), () async {
+ final opened = await _show(tester, await _loaded(tester, server));
+ final reply = inCard(id, find.text('Yes, select it.'));
+ expect(reply, findsOneWidget);
+ final region = find.ancestor(
+ of: reply,
+ matching: find.byType(SelectableRegion),
+ );
+ expect(region, findsOneWidget, reason: 'the card text is selectable');
+ tester
+ .state<SelectableRegionState>(region)
+ .selectAll(SelectionChangedCause.keyboard);
+ await tester.pump();
+ Actions.invoke(tester.element(reply), CopySelectionTextIntent.copy);
+ await tester.pump();
+ expect(copied, contains('Yes, select it.'));
+ expect(copied, contains('Can we copy this?'));
+ // Only what was said: the card's controls are not part of the text.
+ expect(copied, isNot(contains('Reply…')));
+ expect(copied, isNot(contains('Unfollow')));
+ expect(copied, isNot(contains('Also send')));
+
+ await tester.tap(_key('super-thread-card-title:lead/$id'));
+ await _settle(tester);
+ expect(opened, [('lead', id)]);
+ });
+ });
+
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;