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.

fix(desktop): a hovered row's tooltip can no longer freeze the mouse (#2526)

0xken1552e7c69e8ecc
diff --git a/desktop/lib/super_tabs/activity_view.dart b/desktop/lib/super_tabs/activity_view.dart
index 3a546a4aa..14ab4ab7d 100644
--- a/desktop/lib/super_tabs/activity_view.dart
+++ b/desktop/lib/super_tabs/activity_view.dart
@@ -11,6 +11,7 @@ import 'machine_status.dart' show superTabAgo;
import 'notifications.dart';
import 'profile_model.dart';
import 'section_heading.dart';
+import '../widgets/laid_out_list.dart';
/// Slack's Activity, where Notifications was (Lead, 10-31): decisions asked
/// of the reader first, then one list, newest first, of their tags, the
@@ -348,7 +349,7 @@ class _SuperTabActivityViewState extends State<SuperTabActivityView> {
? const <_Entry>[]
: _entries();
final error = a.error ?? a.mentions.error;
- return ListView(
+ return LaidOutListView(
key: const ValueKey('super-activity-list'),
padding: const EdgeInsets.only(bottom: grid.AppDesktop.groupGap),
children: [
diff --git a/desktop/lib/super_tabs/composer_tags.dart b/desktop/lib/super_tabs/composer_tags.dart
index 507c74e08..a8d26a03d 100644
--- a/desktop/lib/super_tabs/composer_tags.dart
+++ b/desktop/lib/super_tabs/composer_tags.dart
@@ -6,6 +6,7 @@ import '../widgets/desktop_chrome.dart';
import 'controller.dart';
import 'identity.dart';
import 'model.dart';
+import '../widgets/laid_out_list.dart';
/// `@` tags in a composer, the same in the main chat's box and a thread's
/// reply box: where a tag is being typed, who it offers, how a pick goes into
@@ -194,7 +195,7 @@ class SuperTabCompletionList extends StatelessWidget {
constraints: BoxConstraints(
maxHeight: MediaQuery.sizeOf(context).height * .3,
),
- child: ListView(
+ child: LaidOutListView(
key: listKey,
shrinkWrap: true,
padding: const EdgeInsets.symmetric(
diff --git a/desktop/lib/super_tabs/decisions_view.dart b/desktop/lib/super_tabs/decisions_view.dart
index 3e0636ad6..cb3bbac8e 100644
--- a/desktop/lib/super_tabs/decisions_view.dart
+++ b/desktop/lib/super_tabs/decisions_view.dart
@@ -7,6 +7,7 @@ import '../widgets/desktop_chrome.dart';
import 'decisions.dart';
import 'model.dart';
import 'section_heading.dart';
+import '../widgets/laid_out_list.dart';
/// The reader's decisions in the Notifications pane: what is open first, one
/// batch per ask, then the last few answered.
@@ -92,7 +93,7 @@ class SuperTabDecisionsPanel extends StatelessWidget {
final folded = shown.isEmpty;
return ConstrainedBox(
constraints: const BoxConstraints(maxHeight: 320),
- child: ListView(
+ child: LaidOutListView(
key: const ValueKey('super-pm-decisions'),
shrinkWrap: true,
padding: EdgeInsets.only(bottom: folded ? 0 : 8),
diff --git a/desktop/lib/super_tabs/machines.dart b/desktop/lib/super_tabs/machines.dart
index ecef6f2a6..3ebe0f626 100644
--- a/desktop/lib/super_tabs/machines.dart
+++ b/desktop/lib/super_tabs/machines.dart
@@ -37,6 +37,7 @@ import 'model.dart';
import 'join_machine.dart' show superTabSuggestedAgentSlots;
import 'team_account_setup.dart';
import 'section_heading.dart';
+import '../widgets/laid_out_list.dart';
export 'machine_status.dart';
@@ -2175,7 +2176,7 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {
mainAxisSize: MainAxisSize.min,
children: children,
)
- : ListView(children: children);
+ : LaidOutListView(children: children);
}
}
diff --git a/desktop/lib/super_tabs/notifications.dart b/desktop/lib/super_tabs/notifications.dart
index c91d9d27e..984558d7b 100644
--- a/desktop/lib/super_tabs/notifications.dart
+++ b/desktop/lib/super_tabs/notifications.dart
@@ -12,6 +12,7 @@ import 'identity.dart';
import 'machine_status.dart' show superTabAgo;
import 'model.dart';
import 'section_heading.dart';
+import '../widgets/laid_out_list.dart';
/// A Lead's tag of the reader in one message (spec 2026-10-24-lead-mentions.md).
class SuperTabMention {
@@ -468,7 +469,7 @@ class _SuperTabNotificationsState extends State<SuperTabNotifications> {
builder: (context, _) {
grid.AppTheme.watch(context);
final m = widget.mentions;
- return ListView(
+ return LaidOutListView(
padding: const EdgeInsets.only(bottom: 16),
children: [
if (m.error case final error?)
diff --git a/desktop/lib/super_tabs/project_sidebar.dart b/desktop/lib/super_tabs/project_sidebar.dart
index 1bba09454..5a7062585 100644
--- a/desktop/lib/super_tabs/project_sidebar.dart
+++ b/desktop/lib/super_tabs/project_sidebar.dart
@@ -32,6 +32,7 @@ import 'swarm_switcher.dart';
import 'task_status.dart';
import 'workgroup_name.dart';
import 'project_github.dart';
+import '../widgets/laid_out_list.dart';
/// The reader's one Buddy for the whole Swarm, listed first among the projects
/// as a channel (Dee, 10-31).
@@ -931,7 +932,7 @@ class ProjectSidebar extends StatelessWidget {
final reading = _SidebarReading(controller, needsHuman, attention);
return Material(
color: DesktopChrome.surface,
- child: ListView(
+ child: LaidOutListView(
padding: const EdgeInsets.all(8),
children: [
if ((app, onNewSwarm) case (final app?, final onNewSwarm?))
diff --git a/desktop/lib/super_tabs/pull_requests.dart b/desktop/lib/super_tabs/pull_requests.dart
index dd5c585ef..5e910a412 100644
--- a/desktop/lib/super_tabs/pull_requests.dart
+++ b/desktop/lib/super_tabs/pull_requests.dart
@@ -13,6 +13,7 @@ import '../state/app_state.dart';
import '../widgets/desktop_chrome.dart';
import 'controller.dart';
import 'model.dart';
+import '../widgets/laid_out_list.dart';
List<Uri> superTabPullRequestLinks(String text) => {
for (final match in RegExp(
@@ -550,7 +551,7 @@ class _SuperTabPullRequestsState extends State<SuperTabPullRequests> {
),
),
)
- : ListView(
+ : LaidOutListView(
padding: const EdgeInsets.only(bottom: 16),
children: [
if (_unsupported)
diff --git a/desktop/lib/super_tabs/quick_switcher.dart b/desktop/lib/super_tabs/quick_switcher.dart
index c8710e876..73befbdc3 100644
--- a/desktop/lib/super_tabs/quick_switcher.dart
+++ b/desktop/lib/super_tabs/quick_switcher.dart
@@ -17,6 +17,7 @@ import 'dialog_scope.dart';
import 'identity.dart';
import 'model.dart';
import 'profile_sheet.dart';
+import '../widgets/laid_out_list.dart';
const _gap = grid.AppDesktop.controlGap;
@@ -475,7 +476,7 @@ class _QuickSwitcherState extends State<_QuickSwitcher> {
style: DesktopChrome.text(),
),
)
- : ListView.builder(
+ : LaidOutListView.builder(
controller: _scroll,
padding: const EdgeInsets.symmetric(
horizontal: grid.AppDesktop.panelPadding,
diff --git a/desktop/lib/super_tabs/roster.dart b/desktop/lib/super_tabs/roster.dart
index 8c375736b..9e0ad6e51 100644
--- a/desktop/lib/super_tabs/roster.dart
+++ b/desktop/lib/super_tabs/roster.dart
@@ -30,6 +30,7 @@ import 'model.dart';
import 'profile_sheet.dart';
import 'section_heading.dart';
import 'agent_line.dart';
+import '../widgets/laid_out_list.dart';
/// The current Swarm's authorized people, each with their week on the
/// leaderboard of the open conversation's project, and every agent of the
@@ -627,7 +628,7 @@ class _SuperTabRosterState extends State<SuperTabRoster> {
terminalThemeStore,
appearancePrefsStore,
]),
- builder: (context, _) => ListView(
+ builder: (context, _) => LaidOutListView(
key: PageStorageKey('super-tab-resources-${c.tabId}'),
padding: const EdgeInsets.symmetric(vertical: 12),
children: _members(),
diff --git a/desktop/lib/super_tabs/thread_panel.dart b/desktop/lib/super_tabs/thread_panel.dart
index 908ebae8d..f3e468935 100644
--- a/desktop/lib/super_tabs/thread_panel.dart
+++ b/desktop/lib/super_tabs/thread_panel.dart
@@ -16,6 +16,7 @@ import 'controller.dart';
import 'jump_to_latest.dart';
import 'model.dart';
import 'thread_scroll.dart';
+import '../widgets/laid_out_list.dart';
/// 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.
@@ -372,7 +373,7 @@ class _SuperTabThreadPanelState extends State<SuperTabThreadPanel> {
children: [
// As in the chat, a message's text can be selected and copied.
SelectionArea(
- child: ListView(
+ child: LaidOutListView(
controller: _scroll,
padding: const EdgeInsets.symmetric(
vertical: grid.AppDesktop.controlGap,
diff --git a/desktop/lib/super_tabs/threads_view.dart b/desktop/lib/super_tabs/threads_view.dart
index 6cf70ecb8..f3111e495 100644
--- a/desktop/lib/super_tabs/threads_view.dart
+++ b/desktop/lib/super_tabs/threads_view.dart
@@ -15,6 +15,7 @@ import 'model.dart';
import 'reply_box.dart';
import 'section_heading.dart';
import 'workgroup_name.dart';
+import '../widgets/laid_out_list.dart';
/// How many threads with new replies read their replies when the view opens;
/// the rest show their root and count until opened.
@@ -87,7 +88,7 @@ class _SuperTabThreadsViewState extends State<SuperTabThreadsView> {
unawaited(a.showReplies(thread));
}
});
- return ListView(
+ return LaidOutListView(
key: const ValueKey('super-threads-view'),
padding: const EdgeInsets.only(bottom: grid.AppDesktop.groupGap),
children: [
diff --git a/desktop/lib/super_tabs/view.dart b/desktop/lib/super_tabs/view.dart
index dff4a94eb..9fb053832 100644
--- a/desktop/lib/super_tabs/view.dart
+++ b/desktop/lib/super_tabs/view.dart
@@ -68,6 +68,7 @@ import 'project_options.dart';
import 'project_status_card.dart';
import 'pane_layout.dart';
import '../widgets/dial_list_scroll.dart';
+import '../widgets/laid_out_list.dart';
typedef _ComposerChoice = SuperTabComposerChoice;
@@ -1516,7 +1517,7 @@ class _SuperTabViewState extends State<SuperTabView>
: 'No archived conversations.',
),
)
- : ListView(
+ : LaidOutListView(
children: [
for (final group in groups)
ListTile(
@@ -3437,7 +3438,7 @@ class _SuperTabViewState extends State<SuperTabView>
),
),
),
- SliverList(
+ LaidOutSliverList(
delegate: SliverChildBuilderDelegate(
(context, index) =>
row(split - 1 - index),
@@ -3455,7 +3456,7 @@ class _SuperTabViewState extends State<SuperTabView>
padding: EdgeInsets.only(
bottom: grid.AppDesktop.controlGap,
),
- sliver: SliverList(
+ sliver: LaidOutSliverList(
delegate: SliverChildBuilderDelegate(
// Messages on their way end the list.
(context, index) => row(split + index),
diff --git a/desktop/lib/widgets/cloud_chat_pane.dart b/desktop/lib/widgets/cloud_chat_pane.dart
index 0df1dacc1..5225828b9 100644
--- a/desktop/lib/widgets/cloud_chat_pane.dart
+++ b/desktop/lib/widgets/cloud_chat_pane.dart
@@ -17,6 +17,7 @@ import 'harness_activity_mark.dart';
import 'engine_identity.dart';
import 'pane_header_actions.dart';
import 'rename_agent_dialog.dart';
+import 'laid_out_list.dart';
/// One message of a cloud harness's conversation, as `cloud_transcript` gives it.
typedef CloudMessage = ({String id, String from, String text});
@@ -315,7 +316,7 @@ class _CloudChatPaneState extends State<CloudChatPane> {
return Center(child: Text('Reading the conversation…', style: muted));
}
// Newest at the bottom, kept in view as messages arrive.
- return ListView(
+ return LaidOutListView(
key: const ValueKey('cloud-conversation'),
controller: _scroll,
reverse: true,
diff --git a/desktop/lib/widgets/laid_out_list.dart b/desktop/lib/widgets/laid_out_list.dart
new file mode 100644
index 000000000..90a2e049a
--- /dev/null
+++ b/desktop/lib/widgets/laid_out_list.dart
@@ -0,0 +1,85 @@
+import 'package:flutter/material.dart';
+import 'package:flutter/rendering.dart';
+
+/// A [ListView] whose rows stay safe to hit test while they are kept alive off
+/// screen. Every list of rows that can show a [Tooltip] uses it.
+///
+/// A plain list leaves a kept-alive row out of layout. An [InkWell] keeps its
+/// row alive while it is hovered, and a [Tooltip] on that row opens its overlay
+/// box in the [Overlay], not in the list. If the row falls past the list's
+/// trailing edge in the frame the tooltip opens, the box joins the Overlay and
+/// is never laid out. Every later hit test then throws "Cannot hit test a render
+/// box that has never been laid out", the mouse tracker never reaches the row's
+/// exit, and clicks stay dead until the app restarts.
+///
+/// A list with an item extent does not need this: its rows are tightly sized,
+/// so each one is a relayout boundary that Flutter lays out wherever it is.
+class LaidOutListView extends ListView {
+ LaidOutListView({
+ super.key,
+ super.scrollDirection,
+ super.reverse,
+ super.controller,
+ super.primary,
+ super.physics,
+ super.shrinkWrap,
+ super.padding,
+ super.scrollCacheExtent,
+ super.children,
+ super.semanticChildCount,
+ super.keyboardDismissBehavior,
+ super.restorationId,
+ super.clipBehavior,
+ });
+
+ LaidOutListView.builder({
+ super.key,
+ super.scrollDirection,
+ super.reverse,
+ super.controller,
+ super.primary,
+ super.physics,
+ super.shrinkWrap,
+ super.padding,
+ required super.itemBuilder,
+ super.findChildIndexCallback,
+ super.itemCount,
+ super.scrollCacheExtent,
+ super.semanticChildCount,
+ super.keyboardDismissBehavior,
+ super.restorationId,
+ super.clipBehavior,
+ }) : super.builder();
+
+ @override
+ Widget buildChildLayout(BuildContext context) =>
+ LaidOutSliverList(delegate: childrenDelegate);
+}
+
+/// The sliver of [LaidOutListView], for a [CustomScrollView] of the same rows.
+class LaidOutSliverList extends SliverList {
+ const LaidOutSliverList({super.key, required super.delegate});
+
+ @override
+ RenderSliverList createRenderObject(BuildContext context) =>
+ _RenderLaidOutSliverList(
+ childManager: context as SliverMultiBoxAdaptorElement,
+ );
+}
+
+class _RenderLaidOutSliverList extends RenderSliverList {
+ _RenderLaidOutSliverList({required super.childManager});
+
+ @override
+ void performLayout() {
+ super.performLayout();
+ // Layout returns at once for a clean row with the same constraints, so
+ // this costs only what a kept-alive row actually needs.
+ final rowConstraints = constraints.asBoxConstraints();
+ visitChildren((child) {
+ final row = child as RenderBox;
+ final data = row.parentData! as SliverMultiBoxAdaptorParentData;
+ if (data.keptAlive) row.layout(rowConstraints, parentUsesSize: true);
+ });
+ }
+}
diff --git a/desktop/lib/widgets/new_harness_form.dart b/desktop/lib/widgets/new_harness_form.dart
index b8106d38d..40227f9de 100644
--- a/desktop/lib/widgets/new_harness_form.dart
+++ b/desktop/lib/widgets/new_harness_form.dart
@@ -29,6 +29,7 @@ import 'finger_target.dart';
import 'new_harness_attachments.dart';
import 'new_harness_paste.dart';
import 'engine_identity.dart';
+import 'laid_out_list.dart';
/// Desktop composer and legacy terminal launch form sharing the same draft.
/// Enter on the selected launch action starts with the displayed defaults.
@@ -4448,7 +4449,7 @@ class _RoleFieldState extends State<_RoleField> {
maxWidth: _roleFieldWidth,
maxHeight: grid.AppControl.menuMaxHeight,
),
- child: ListView(
+ child: LaidOutListView(
padding: grid.AppMenu.panelPadding,
shrinkWrap: true,
children: [
diff --git a/desktop/lib/widgets/session_tail_view.dart b/desktop/lib/widgets/session_tail_view.dart
index a000a99b5..76cc28a76 100644
--- a/desktop/lib/widgets/session_tail_view.dart
+++ b/desktop/lib/widgets/session_tail_view.dart
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import '../state/harness_sessions.dart';
import '../state/session_tail.dart';
+import 'laid_out_list.dart';
/// Use the same under-a-minute wording as the search result's activity label.
String sessionPreviewAge(DateTime at, DateTime now) =>
@@ -153,7 +154,7 @@ class _SessionTailViewState extends State<SessionTailView> {
}
return false;
},
- child: ListView.builder(
+ child: LaidOutListView.builder(
key: ValueKey(
'session-tail:${tailKey.machineId}:${tailKey.sessionId}',
),
diff --git a/desktop/lib/widgets/session_work_dialog.dart b/desktop/lib/widgets/session_work_dialog.dart
index d079e1928..eb7eb351f 100644
--- a/desktop/lib/widgets/session_work_dialog.dart
+++ b/desktop/lib/widgets/session_work_dialog.dart
@@ -11,6 +11,7 @@ import '../core/models.dart';
import '../shared/theme/app_theme.dart' as grid;
import '../shared/theme/pull_request_icon.dart';
import 'desktop_chrome.dart';
+import 'laid_out_list.dart';
/// Inspection only. This surface never sends terminal input or mutates a checkout.
class SessionWorkDialog extends StatefulWidget {
@@ -312,7 +313,7 @@ class _SessionWorkDialogState extends State<SessionWorkDialog> {
),
),
)
- : ListView.builder(
+ : LaidOutListView.builder(
key: ValueKey(
_branches
? 'git-branches-list'
diff --git a/desktop/lib/widgets/swarm_resource_preview.dart b/desktop/lib/widgets/swarm_resource_preview.dart
index ab878ac9f..f638b4569 100644
--- a/desktop/lib/widgets/swarm_resource_preview.dart
+++ b/desktop/lib/widgets/swarm_resource_preview.dart
@@ -39,6 +39,7 @@ import 'desktop_chrome.dart';
import '../models/coding_model.dart';
import 'swarm_model_tile.dart';
import 'key_hints.dart';
+import 'laid_out_list.dart';
const resourcePickerCommands = {
'picker.resource_toggle',
@@ -1395,7 +1396,7 @@ class _SwarmResourcePreviewState extends State<SwarmResourcePreview> {
List<String> errors = const [],
}) {
final error = Theme.of(context).colorScheme.error;
- return ListView(
+ return LaidOutListView(
key: const ValueKey('swarm-model-card'),
controller: _scroll,
padding: const EdgeInsets.fromLTRB(24, 24, 24, 16),
@@ -1845,7 +1846,7 @@ class _SwarmResourcePreviewState extends State<SwarmResourcePreview> {
);
}
- final lines = ListView(
+ final lines = LaidOutListView(
controller: _scroll,
padding: EdgeInsets.symmetric(
horizontal: cell.width * 2,
@@ -2314,7 +2315,7 @@ class _SwarmResourcePreviewState extends State<SwarmResourcePreview> {
/// pair is a labelled row — [_kDetailLabelColumns] terminal columns of label.
Widget _details(List<Object> lines, {bool controls = false}) {
if (DesktopChrome.of(context)) {
- return ListView(
+ return LaidOutListView(
controller: _scroll,
padding: const EdgeInsets.all(18),
children: [
@@ -2352,7 +2353,7 @@ class _SwarmResourcePreviewState extends State<SwarmResourcePreview> {
terminalThemeStore.value,
);
final muted = terminalContentStyle(color: theme.muted);
- return ListView(
+ return LaidOutListView(
controller: _scroll,
padding: EdgeInsets.symmetric(
horizontal: cell.width * 2,
@@ -2392,7 +2393,7 @@ class _SwarmResourcePreviewState extends State<SwarmResourcePreview> {
Widget _typeHints() {
if (DesktopChrome.of(context)) {
- return ListView(
+ return LaidOutListView(
controller: _scroll,
padding: const EdgeInsets.all(18),
children: [
@@ -2437,7 +2438,7 @@ class _SwarmResourcePreviewState extends State<SwarmResourcePreview> {
grid.AppTheme.palette.value,
terminalThemeStore.value,
);
- return ListView(
+ return LaidOutListView(
controller: _scroll,
padding: EdgeInsets.symmetric(
horizontal: cell.width * 2,
diff --git a/desktop/lib/widgets/swarm_search_preview.dart b/desktop/lib/widgets/swarm_search_preview.dart
index ea4ae81cd..003d751a7 100644
--- a/desktop/lib/widgets/swarm_search_preview.dart
+++ b/desktop/lib/widgets/swarm_search_preview.dart
@@ -24,6 +24,7 @@ import 'engine_identity.dart';
import 'search_result_text.dart' show SessionSnippetText;
import 'session_tail_view.dart';
import 'swarm_preview_scroll.dart';
+import 'laid_out_list.dart';
typedef _PreviewAgent = ({MachineState machine, Agent agent});
@@ -466,7 +467,7 @@ class _SwarmSearchPreviewState extends State<SwarmSearchPreview> {
return Semantics(
container: true,
label: 'Command preview',
- child: ListView(
+ child: LaidOutListView(
key: ValueKey('preview-content:${row.id}'),
controller: _scroll,
padding: padding,
@@ -514,7 +515,7 @@ class _SwarmSearchPreviewState extends State<SwarmSearchPreview> {
final agents = _agents(app, row);
if (row.isGroup || agents.length != 1) _scroll.reversed = false;
final content = row.isGroup || agents.length != 1
- ? ListView.builder(
+ ? LaidOutListView.builder(
key: ValueKey('preview-content:${row.id}'),
controller: _scroll,
padding: padding,
diff --git a/desktop/test/laid_out_list_test.dart b/desktop/test/laid_out_list_test.dart
new file mode 100644
index 000000000..c89783a8e
--- /dev/null
+++ b/desktop/test/laid_out_list_test.dart
@@ -0,0 +1,200 @@
+import 'dart:io';
+
+import 'package:flutter/gestures.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/widgets/laid_out_list.dart';
+
+/// A hovered row whose tooltip opens in the frame the row falls past the
+/// list's trailing cache edge: the trigger of the frozen mouse.
+const _viewport = 500.0;
+const _rowHeight = 40.0;
+
+Widget _row(int i) => Tooltip(
+ message: 'row $i',
+ waitDuration: Duration.zero,
+ child: InkWell(
+ onTap: () {},
+ child: SizedBox(height: _rowHeight, child: Text('row $i')),
+ ),
+);
+
+Widget _frame(Widget list) => MaterialApp(
+ home: Scaffold(
+ body: Align(
+ alignment: Alignment.topCenter,
+ child: SizedBox(height: _viewport, child: list),
+ ),
+ ),
+);
+
+Future<TestGesture> _openTooltipAsRowLeaves(
+ WidgetTester tester,
+ ScrollController controller,
+) async {
+ final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);
+ addTearDown(mouse.removePointer);
+ // Starts below the list, so nothing is hovered yet.
+ await mouse.addPointer(location: const Offset(5, _viewport + 50));
+ await tester.pump();
+ await mouse.moveTo(const Offset(5, _viewport - 20));
+ controller.jumpTo(controller.offset - 1500);
+ await tester.pump();
+ return mouse;
+}
+
+void main() {
+ group('LaidOutListView', () {
+ testWidgets('a plain ListView shows the bug this list exists to prevent', (
+ tester,
+ ) async {
+ final controller = ScrollController(initialScrollOffset: 4000);
+ addTearDown(controller.dispose);
+ await tester.pumpWidget(
+ _frame(
+ ListView.builder(
+ controller: controller,
+ itemCount: 200,
+ itemBuilder: (context, i) => _row(i),
+ ),
+ ),
+ );
+ final errors = <FlutterErrorDetails>[];
+ final previous = FlutterError.onError;
+ FlutterError.onError = errors.add;
+ addTearDown(() => FlutterError.onError = previous);
+ final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);
+ await mouse.addPointer(location: const Offset(5, _viewport + 50));
+ await tester.pump();
+ await mouse.moveTo(const Offset(5, _viewport - 20));
+ controller.jumpTo(controller.offset - 1500);
+ Object? thrown;
+ try {
+ await tester.pump();
+ await mouse.moveTo(const Offset(5, 100));
+ } catch (error) {
+ thrown = error;
+ }
+ FlutterError.onError = previous;
+ final all = [
+ ...errors.map((e) => e.exceptionAsString()),
+ '$thrown',
+ '${tester.takeException()}',
+ ].join('\n');
+ expect(all, contains('never been laid out'));
+ // The tree is broken on purpose; replace it so teardown stays quiet.
+ FlutterError.onError = (_) {};
+ try {
+ await tester.pumpWidget(const SizedBox());
+ } catch (_) {}
+ tester.takeException();
+ FlutterError.onError = previous;
+ });
+
+ testWidgets('a row leaving as its tooltip opens stays hit-testable', (
+ tester,
+ ) async {
+ final controller = ScrollController(initialScrollOffset: 4000);
+ addTearDown(controller.dispose);
+ var tapped = 0;
+ await tester.pumpWidget(
+ _frame(
+ LaidOutListView.builder(
+ controller: controller,
+ itemCount: 200,
+ itemBuilder: (context, i) => Tooltip(
+ message: 'row $i',
+ waitDuration: Duration.zero,
+ child: InkWell(
+ onTap: () => tapped++,
+ child: SizedBox(height: _rowHeight, child: Text('row $i')),
+ ),
+ ),
+ ),
+ ),
+ );
+ final mouse = await _openTooltipAsRowLeaves(tester, controller);
+ expect(tester.takeException(), isNull);
+ await mouse.moveTo(const Offset(5, 100));
+ expect(tester.takeException(), isNull);
+ await tester.pump(const Duration(seconds: 1));
+ expect(tester.takeException(), isNull);
+ // Clicks still land.
+ await mouse.down(const Offset(5, 100));
+ await mouse.up();
+ await tester.pump(const Duration(seconds: 1));
+ expect(tapped, 1);
+ expect(tester.takeException(), isNull);
+ });
+
+ testWidgets('a kept-alive row scrolled back still works', (tester) async {
+ final controller = ScrollController(initialScrollOffset: 4000);
+ addTearDown(controller.dispose);
+ await tester.pumpWidget(
+ _frame(
+ LaidOutListView.builder(
+ controller: controller,
+ itemCount: 200,
+ itemBuilder: (context, i) => _row(i),
+ ),
+ ),
+ );
+ await _openTooltipAsRowLeaves(tester, controller);
+ controller.jumpTo(4000);
+ await tester.pump();
+ await tester.pump(const Duration(seconds: 1));
+ expect(tester.takeException(), isNull);
+ expect(find.text('row 112'), findsWidgets);
+ });
+
+ testWidgets('a list with an item extent is safe as a plain ListView', (
+ tester,
+ ) async {
+ final controller = ScrollController(initialScrollOffset: 4000);
+ addTearDown(controller.dispose);
+ await tester.pumpWidget(
+ _frame(
+ ListView.builder(
+ controller: controller,
+ itemExtent: _rowHeight,
+ itemCount: 200,
+ itemBuilder: (context, i) => _row(i),
+ ),
+ ),
+ );
+ final mouse = await _openTooltipAsRowLeaves(tester, controller);
+ expect(tester.takeException(), isNull);
+ await mouse.moveTo(const Offset(5, 100));
+ expect(tester.takeException(), isNull);
+ });
+ });
+
+ test(
+ 'Swarm lists use LaidOutListView unless their rows are tightly sized',
+ () {
+ final bare = RegExp(r'(?<![\w.<])(ListView(\.builder)?|SliverList)\(');
+ final offenders = <String>[];
+ for (final dir in ['lib/super_tabs', 'lib/widgets']) {
+ for (final file in Directory(dir).listSync(recursive: true)) {
+ if (file is! File || !file.path.endsWith('.dart')) continue;
+ if (file.path.endsWith('laid_out_list.dart')) continue;
+ final source = file.readAsStringSync();
+ for (final match in bare.allMatches(source)) {
+ var depth = 0;
+ var end = match.end - 1;
+ do {
+ if (source[end] == '(') depth++;
+ if (source[end] == ')') depth--;
+ end++;
+ } while (depth > 0 && end < source.length);
+ final call = source.substring(match.start, end);
+ if (!call.contains('itemExtent')) {
+ offenders.add('${file.path}: ${match.group(0)}');
+ }
+ }
+ }
+ }
+ expect(offenders, isEmpty);
+ },
+ );
+}
diff --git a/desktop/test/resource_picker_test.dart b/desktop/test/resource_picker_test.dart
index 958098806..1e847de88 100644
--- a/desktop/test/resource_picker_test.dart
+++ b/desktop/test/resource_picker_test.dart
@@ -27,6 +27,7 @@ import 'package:harness/widgets/machine_picker_form.dart';
import 'package:harness/widgets/swarm_switcher.dart';
import 'package:harness/widgets/search_result_text.dart';
import 'package:harness/ws/local_cli_discovery.dart';
+import 'package:harness/widgets/laid_out_list.dart';
import 'package:xterm/xterm.dart' show TerminalStyle;
import 'keymap_host_test.dart' show MemoryKeymap, key;
@@ -1586,7 +1587,7 @@ void main() {
.widget<ListView>(
find.descendant(
of: find.byType(SwarmResourcePreview),
- matching: find.byType(ListView),
+ matching: find.byType(LaidOutListView),
),
)
.controller!
diff --git a/desktop/test/super_tab_jump_to_latest_shots_test.dart b/desktop/test/super_tab_jump_to_latest_shots_test.dart
index da783a2e7..2dd47d57e 100644
--- a/desktop/test/super_tab_jump_to_latest_shots_test.dart
+++ b/desktop/test/super_tab_jump_to_latest_shots_test.dart
@@ -6,6 +6,7 @@ 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 'package:harness/widgets/laid_out_list.dart';
import 'box_render_preview_test.dart' show loadPreviewFonts;
import 'support/super_tab_fixture.dart';
@@ -89,7 +90,7 @@ void main() {
.widget<ListView>(
find.descendant(
of: find.byKey(const ValueKey('super-thread-panel')),
- matching: find.byType(ListView),
+ matching: find.byType(LaidOutListView),
),
)
.controller!;
diff --git a/desktop/test/super_tab_jump_to_latest_test.dart b/desktop/test/super_tab_jump_to_latest_test.dart
index dbbb9d174..6da4a5811 100644
--- a/desktop/test/super_tab_jump_to_latest_test.dart
+++ b/desktop/test/super_tab_jump_to_latest_test.dart
@@ -3,6 +3,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:harness/shared/theme/app_theme.dart' as grid;
import 'package:harness/super_tabs/controller.dart';
import 'package:harness/super_tabs/view.dart';
+import 'package:harness/widgets/laid_out_list.dart';
import 'support/super_tab_fixture.dart';
@@ -51,7 +52,7 @@ void main() {
Finder inPanel(Finder finder) =>
find.descendant(of: panel(), matching: finder);
ScrollController threadScroll(WidgetTester tester) =>
- tester.widget<ListView>(inPanel(find.byType(ListView))).controller!;
+ tester.widget<ListView>(inPanel(find.byType(LaidOutListView))).controller!;
ConversationServer chat(int count) {
final server = ConversationServer();
diff --git a/desktop/test/super_tab_thread_scroll_shots_test.dart b/desktop/test/super_tab_thread_scroll_shots_test.dart
index 63b6f876c..c389732d9 100644
--- a/desktop/test/super_tab_thread_scroll_shots_test.dart
+++ b/desktop/test/super_tab_thread_scroll_shots_test.dart
@@ -6,6 +6,7 @@ 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 'package:harness/widgets/laid_out_list.dart';
import 'box_render_preview_test.dart' show loadPreviewFonts;
import 'support/super_tab_fixture.dart';
@@ -83,7 +84,7 @@ void main() {
.widget<ListView>(
find.descendant(
of: find.byKey(const ValueKey('super-thread-panel')),
- matching: find.byType(ListView),
+ matching: find.byType(LaidOutListView),
),
)
.controller!;
diff --git a/desktop/test/super_tab_thread_scroll_test.dart b/desktop/test/super_tab_thread_scroll_test.dart
index a4334f6f0..7a13194f3 100644
--- a/desktop/test/super_tab_thread_scroll_test.dart
+++ b/desktop/test/super_tab_thread_scroll_test.dart
@@ -7,6 +7,7 @@ import 'package:harness/super_tabs/controller.dart';
import 'package:harness/super_tabs/model.dart';
import 'package:harness/super_tabs/thread_panel.dart';
import 'package:harness/super_tabs/view.dart';
+import 'package:harness/widgets/laid_out_list.dart';
import 'support/super_tab_fixture.dart';
@@ -48,7 +49,7 @@ void main() {
Finder inPanel(Finder finder) =>
find.descendant(of: panel(), matching: finder);
ScrollPosition threadScroll(WidgetTester tester) => tester
- .widget<ListView>(inPanel(find.byType(ListView)))
+ .widget<ListView>(inPanel(find.byType(LaidOutListView)))
.controller!
.position;
@@ -200,7 +201,7 @@ void main() {
c.openThread('message-1');
await tester.pumpAndSettle();
- await tester.drag(inPanel(find.byType(ListView)), const Offset(0, 400));
+ await tester.drag(inPanel(find.byType(LaidOutListView)), const Offset(0, 400));
await tester.pumpAndSettle();
final read = threadScroll(tester).pixels;
expect(threadScroll(tester).extentAfter, greaterThan(40));
@@ -224,7 +225,7 @@ void main() {
/// Flings the thread back up and lets it coast for a moment, still moving.
Future<void> flingUp(WidgetTester tester) async {
await tester.fling(
- inPanel(find.byType(ListView)),
+ inPanel(find.byType(LaidOutListView)),
const Offset(0, 600),
4000,
);
diff --git a/desktop/test/super_tab_tooltip_freeze_test.dart b/desktop/test/super_tab_tooltip_freeze_test.dart
new file mode 100644
index 000000000..08af893bb
--- /dev/null
+++ b/desktop/test/super_tab_tooltip_freeze_test.dart
@@ -0,0 +1,124 @@
+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;
+import 'package:harness/super_tabs/view.dart';
+
+import 'super_tab_roster_test.dart' show RosterFixture;
+import 'support/humans_fixture.dart';
+
+/// Scholes, 11-02: the mouse froze on the Swarm screen after a hovered row's
+/// tooltip opened in the frame the row left the list ("Cannot hit test a render
+/// box that has never been laid out"). The theme's hover wait is 500 ms, so a
+/// test passes this to run the tooltip's timer without drawing a frame.
+const _pastHoverWait = Duration(milliseconds: 600);
+
+void main() {
+ testWidgets('a roster row leaving as its tooltip opens keeps clicks alive', (
+ tester,
+ ) async {
+ await tester.binding.setSurfaceSize(const Size(420, 400));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ final fixture = RosterFixture();
+ addTearDown(fixture.app.dispose);
+ addTearDown(fixture.controller.dispose);
+ await fixture.initialize();
+ fixture.server.state['agents'] = [
+ for (var i = 0; i < 60; i++)
+ {
+ 'id': 'agent-$i',
+ 'projectId': 'lead',
+ 'name': 'Lead',
+ 'displayName': 'Agent $i',
+ 'machineId': 'm',
+ 'harnessId': 'a$i',
+ 'contributorId': 'owner',
+ 'configuration': {'engine': 'codex'},
+ },
+ ];
+ await fixture.controller.refresh();
+ await fixture.show(tester);
+
+ final list = tester.state<ScrollableState>(find.byType(Scrollable).first);
+ list.position.jumpTo(list.position.maxScrollExtent);
+ await tester.pumpAndSettle();
+
+ final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);
+ addTearDown(mouse.removePointer);
+ await mouse.addPointer(location: const Offset(100, 380));
+ await tester.pump();
+ await tester.binding.delayed(_pastHoverWait);
+ list.position.jumpTo(list.position.pixels - 1500);
+ await tester.pump();
+ expect(tester.takeException(), isNull);
+
+ await mouse.moveTo(const Offset(100, 100));
+ expect(tester.takeException(), isNull);
+ await tester.pump(const Duration(seconds: 1));
+ expect(tester.takeException(), isNull);
+ });
+
+ testWidgets(
+ 'clicking around the Swarm screen and toggling Machines logs no error',
+ (tester) async {
+ await tester.binding.setSurfaceSize(const Size(1300, 500));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ final server = modelsSwarm();
+ final controller = server.controller(
+ account: 'peer',
+ initial: {'tabId': 'tab', 'accountId': 'peer', 'selectedId': 'lead'},
+ );
+ addTearDown(controller.dispose);
+ await controller.refresh();
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: grid.buildAppTheme(brightness: Brightness.light),
+ home: Scaffold(
+ body: SuperTabView(
+ controller: controller,
+ onInvite: () {},
+ onAddAgent: (_) {},
+ onOpenTerminal: (_) {},
+ machineName: (_) => 'Mac Studio',
+ ),
+ ),
+ ),
+ );
+ await tester.pumpAndSettle();
+
+ final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);
+ addTearDown(mouse.removePointer);
+ await mouse.addPointer(location: Offset.zero);
+
+ Future<void> click(Finder target) async {
+ await mouse.moveTo(tester.getCenter(target));
+ await tester.pump();
+ await tester.binding.delayed(_pastHoverWait);
+ await mouse.down(tester.getCenter(target));
+ await mouse.up();
+ await tester.pump();
+ await tester.pump(const Duration(seconds: 1));
+ expect(tester.takeException(), isNull);
+ }
+
+ for (var round = 0; round < 3; round++) {
+ await click(find.byTooltip('Collapse Machines'));
+ expect(controller.machinesGroupOpen, isFalse);
+ await click(find.byTooltip('Expand Machines'));
+ expect(controller.machinesGroupOpen, isTrue);
+ // Hover a row below Machines, then open Machines as its tooltip opens.
+ await click(find.byTooltip('Collapse Machines'));
+ await mouse.moveTo(const Offset(100, 480));
+ await tester.pump();
+ await tester.binding.delayed(_pastHoverWait);
+ controller.toggleMachinesGroup();
+ await tester.pump();
+ expect(tester.takeException(), isNull);
+ await mouse.moveTo(const Offset(100, 60));
+ expect(tester.takeException(), isNull);
+ await tester.pump(const Duration(seconds: 1));
+ expect(tester.takeException(), isNull);
+ }
+ },
+ );
+}