The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Repair what the main merge dropped, and retire the extracted tab strip
Dev jacob48714614c24a
diff --git a/desktop/lib/widgets/swarm_tab_strip.dart b/desktop/lib/widgets/swarm_tab_strip.dartdeleted file mode 100644index a3c956c96..000000000--- a/desktop/lib/widgets/swarm_tab_strip.dart+++ /dev/null@@ -1,210 +0,0 @@-import 'package:flutter/material.dart';--import '../shared/layouts/window_size.dart';-import '../shared/theme/app_theme.dart' as grid;-import '../shortcuts/app_keymap.dart';-import '../shortcuts/app_shortcuts.dart';-import '../state/app_state.dart';--/// What the overflow menu can run when the strip is too narrow to show the-/// actions as buttons.-enum _StripAction { newSwarm, navigate }--/// The swarm tabs, and the shell's global actions beside them.-///-/// Split out of `screens/swarm_screen.dart` because it is the one piece of-/// shell chrome that has to answer for its own width. The grid below it already-/// measures the window — `_SwarmGeometry` reads the viewport and `auto` picks-/// its column count from it (`widgets/pane_grid.dart`) — while this strip was-/// drawn at one fixed size: every tab 186pt whether four or twenty-four were-/// open, and four icon buttons holding ~176pt of the row no matter how little-/// was left. Below roughly 700pt that left the tabs a sliver to scroll inside.-///-/// Two things move with the width, and nothing else does:-///-/// * A tab shrinks, from [maxTabWidth] down to [minTabWidth], before the strip-/// starts scrolling. A window with room for full-width tabs is laid out-/// exactly as it was, so nothing changes on the size this was drawn for.-/// * At [WindowSizeClass.compact] the actions that are only shortcuts for-/// something reachable elsewhere fold into one overflow button.-/// Notifications stays out, because its badge is the only part of this strip-/// that carries state the user cannot see anywhere else.-class SwarmTabStrip extends StatelessWidget {- const SwarmTabStrip({- super.key,- required this.notifier,- required this.attention,- required this.onRename,- required this.onNavigate,- required this.onNotifications,- });-- /// Unchanged by width — only what sits in the strip moves, never its height.- static const double height = 44;-- /// What a tab is drawn at when the row has room for it.- static const double maxTabWidth = 186;-- /// Past this a tab has no room left for a name, so the strip scrolls rather- /// than shrinking into a row of identical stubs.- static const double minTabWidth = 112;-- final AppNotifier notifier;- final int attention;- final ValueChanged<String> onRename;- final VoidCallback onNavigate;- final VoidCallback onNotifications;-- @override- Widget build(BuildContext context) => Container(- height: height,- color: grid.AppPalette.swarmTabBar,- child: LayoutBuilder(- builder: (context, constraints) => Row(- children: [- const SizedBox(width: 10),- // The tabs measure what is left AFTER the actions have taken theirs,- // which is why this is an inner LayoutBuilder and not the outer one.- Expanded(child: _tabs()),- ..._actions(context, WindowSizeClass.fromWidth(constraints.maxWidth)),- const SizedBox(width: 6),- ],- ),- ),- );-- Widget _tabs() => LayoutBuilder(- builder: (context, constraints) {- final count = notifier.swarms.length;- final width = count == 0- ? maxTabWidth- : (constraints.maxWidth / count)- .clamp(minTabWidth, maxTabWidth)- .toDouble();- return ReorderableListView.builder(- scrollDirection: Axis.horizontal,- shrinkWrap: true,- buildDefaultDragHandles: false,- itemCount: count,- onReorderItem: (old, to) =>- notifier.reorderSwarm(notifier.swarms[old].id, to),- itemBuilder: (context, index) => _tab(index, width),- );- },- );-- Widget _tab(int index, double width) {- final swarm = notifier.swarms[index];- final active = notifier.activeSwarmId == swarm.id;- return ReorderableDragStartListener(- key: ValueKey(swarm.id),- index: index,- child: GestureDetector(- onDoubleTap: () => onRename(swarm.id),- child: Container(- width: width,- margin: const EdgeInsets.only(top: 6, right: 2),- decoration: BoxDecoration(- color: active ? grid.AppPalette.swarmField : Colors.transparent,- borderRadius: const BorderRadius.vertical(top: Radius.circular(9)),- ),- child: Row(- children: [- Expanded(- child: TextButton(- onPressed: () => notifier.selectSwarm(swarm.id),- style: TextButton.styleFrom(- animationDuration: Duration.zero,- foregroundColor: active ? Colors.white : Colors.white70,- ),- child: Text(- swarm.name,- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: const TextStyle(fontSize: 13),- ),- ),- ),- IconButton(- tooltip: 'Close ${swarm.name}',- onPressed: () => notifier.closeSwarm(swarm.id),- icon: const Icon(Icons.close, size: 13),- constraints: const BoxConstraints.tightFor(- width: 30,- height: 30,- ),- padding: EdgeInsets.zero,- ),- ],- ),- ),- ),- );- }-- List<Widget> _actions(BuildContext context, WindowSizeClass size) => [- if (!size.isCompact) ...[- IconButton(- tooltip: withEffectiveShortcutHint(- context,- 'New swarm',- ShortcutAction.newSwarm,- ),- onPressed: _canAddSwarm ? notifier.newSwarm : null,- icon: const Icon(Icons.add, size: 18),- ),- IconButton(- key: const ValueKey('swarm-search-button'),- tooltip: withEffectiveShortcutHint(- context,- 'Navigate',- ShortcutAction.switchAgent,- ),- onPressed: onNavigate,- icon: const Icon(Icons.explore_outlined, size: 20),- ),- ],- IconButton(- key: const ValueKey('swarm-notifications-button'),- tooltip: withEffectiveShortcutHint(- context,- 'Agents needing input',- ShortcutAction.showAttention,- ),- onPressed: onNotifications,- icon: Badge(- isLabelVisible: attention > 0,- child: const Icon(Icons.notifications_none, size: 20),- ),- ),- if (size.isCompact) _overflow(),- ];-- Widget _overflow() => PopupMenuButton<_StripAction>(- key: const ValueKey('swarm-overflow-button'),- tooltip: 'More',- constraints: const BoxConstraints(minWidth: 180),- icon: const Icon(Icons.more_vert, size: 20),- itemBuilder: (_) => [- PopupMenuItem(- value: _StripAction.newSwarm,- enabled: _canAddSwarm,- child: const Text('New swarm'),- ),- const PopupMenuItem(- value: _StripAction.navigate,- child: Text('Navigate'),- ),- ],- onSelected: (action) {- switch (action) {- case _StripAction.newSwarm:- notifier.newSwarm();- case _StripAction.navigate:- onNavigate();- }- },- );-- bool get _canAddSwarm => notifier.swarms.length < AppNotifier.maxSwarms;-}diff --git a/desktop/lib/widgets/terminal_panel.dart b/desktop/lib/widgets/terminal_panel.dartindex 8b451ab92..13ec9f1c0 100644--- a/desktop/lib/widgets/terminal_panel.dart+++ b/desktop/lib/widgets/terminal_panel.dart@@ -62,6 +62,11 @@ class TerminalPanel extends StatefulWidget {final (String, int)? paneLocation;final (int, int, int?)? layoutRequest;final bool compactHeader;++ /// The tile's own header strip — engine, title, status, pin, close. Off on a+ /// phone, whose page draws its own header and has no tile to pin, close or+ /// drag (`phone/terminal_page.dart` in the mobile package).+ final bool showHeader;final int focusRequest;/// Whether this tile's composer textbox is showing. Only consulted for a remote machine.@@ -90,6 +95,7 @@ class TerminalPanel extends StatefulWidget {this.paneLocation,this.layoutRequest,this.compactHeader = false,+ this.showHeader = true,this.focusRequest = 0,this.composerVisible = false,this.readOnly = false,@@ -323,6 +329,28 @@ class _TerminalPanelState extends State<TerminalPanel>void _onSessionChanged() {if (!mounted) return;_syncCursorBlink();+ // A pane can open BEFORE its screen exists: over the relay it mounts empty+ // and the retained scrollback is replayed a moment later, so the jump in+ // `_afterTerminalMounted` lands on nothing and the screen then fills in+ // above the reader. xterm does not close this — its own `_scrollToBottom`+ // answers typing and the keyboard opening, never new output.+ //+ // Gated on [_followTail], which is kept as "the view is showing its end",+ // so a pane the reader has scrolled up in — or one restored to a saved+ // position — is not at the end, and is never followed.+ // Visible only. A parked pane holds the offset it was left at while output+ // arrives behind it — `swarm_screen_test` pins that — and comes back to the+ // end through `_afterTerminalMounted`, which is where returning is handled.+ if (_followTail && widget.visible) {+ WidgetsBinding.instance.addPostFrameCallback((_) {+ if (!mounted || !widget.visible) return;+ if (!_followTail || !_scrollController.hasClients) return;+ final position = _scrollController.position;+ if (position.pixels != position.maxScrollExtent) {+ position.jumpTo(position.maxScrollExtent);+ }+ });+ }if (!_composerFocusPending) return;if (!widget.focused || !_showsComposer) {_composerFocusPending = false;@@ -1136,7 +1164,9 @@ class _TerminalPanelState extends State<TerminalPanel>maintainSize: true,maintainAnimation: true,maintainState: true,- child: _buildHeader(context),+ child: widget.showHeader+ ? _buildHeader(context)+ : const SizedBox.shrink(),),// Attach the focused pane's input before Find is requested.// Hidden/unfocused panes need no dormant editor or index.diff --git a/desktop/test/swarm_tab_strip_test.dart b/desktop/test/swarm_tab_strip_test.dartdeleted file mode 100644index b9d8465e5..000000000--- a/desktop/test/swarm_tab_strip_test.dart+++ /dev/null@@ -1,129 +0,0 @@-import 'package:flutter/material.dart';-import 'package:flutter_test/flutter_test.dart';-import 'package:harness/shared/layouts/window_size.dart';-import 'package:harness/shared/theme/app_theme.dart' as grid;-import 'package:harness/state/app_state.dart';-import 'package:harness/widgets/swarm_tab_strip.dart';--import 'swarm_state_test.dart' show createApp;--/// A tab carries a 2pt right margin inside its own box, so measuring the tab-/// measures the margin with it.-const double _margin = 2;--AppNotifier _appWith(int swarms) {- final app = createApp();- while (app.swarms.length < swarms) {- app.newSwarm();- }- addTearDown(app.dispose);- return app;-}--/// Sizes the WINDOW rather than wrapping the strip in a box: a `SizedBox` wider-/// than the test surface is silently clamped back to it, which would have every-/// wide case here quietly measuring 800pt instead.-Future<void> _mount(- WidgetTester tester,- AppNotifier app,- double width, {- VoidCallback? onNavigate,-}) async {- tester.view.devicePixelRatio = 1;- tester.view.physicalSize = Size(width, 200);- addTearDown(tester.view.resetPhysicalSize);- addTearDown(tester.view.resetDevicePixelRatio);- await tester.pumpWidget(- MaterialApp(- theme: grid.buildAppTheme(brightness: Brightness.dark),- home: Scaffold(- body: Align(- alignment: Alignment.topLeft,- child: SwarmTabStrip(- notifier: app,- attention: 0,- onRename: (_) {},- onNavigate: onNavigate ?? () {},- onNotifications: () {},- ),- ),- ),- ),- );- await tester.pump();-}--double _tabWidth(WidgetTester tester, AppNotifier app) =>- tester.getSize(find.byKey(ValueKey(app.swarms.first.id)).first).width -- _margin;--void main() {- testWidgets('a window with room draws every tab at its full width', (- tester,- ) async {- final app = _appWith(2);- await _mount(tester, app, 1400);-- expect(_tabWidth(tester, app), SwarmTabStrip.maxTabWidth);- });-- testWidgets('tabs give up width before the strip starts scrolling', (- tester,- ) async {- final app = _appWith(8);- await _mount(tester, app, 1400);-- final width = _tabWidth(tester, app);- expect(width, lessThan(SwarmTabStrip.maxTabWidth));- expect(width, greaterThan(SwarmTabStrip.minTabWidth));- });-- testWidgets('a tab stops shrinking at the width that still holds a name', (- tester,- ) async {- final app = _appWith(24);- await _mount(tester, app, 500);-- expect(_tabWidth(tester, app), SwarmTabStrip.minTabWidth);- });-- testWidgets('a wide strip keeps every action out as a button', (- tester,- ) async {- await _mount(tester, _appWith(2), 1400);-- expect(find.byKey(const ValueKey('swarm-search-button')), findsOneWidget);- expect(- find.byKey(const ValueKey('swarm-notifications-button')),- findsOneWidget,- );- expect(find.byKey(const ValueKey('swarm-overflow-button')), findsNothing);- });-- testWidgets('a compact strip folds the actions away but keeps the badge', (- tester,- ) async {- await _mount(tester, _appWith(2), WindowSizeClass.compactMax - 1);-- expect(find.byKey(const ValueKey('swarm-search-button')), findsNothing);- expect(- find.byKey(const ValueKey('swarm-notifications-button')),- findsOneWidget,- );- expect(find.byKey(const ValueKey('swarm-overflow-button')), findsOneWidget);- });-- testWidgets('the folded actions still run from the overflow menu', (- tester,- ) async {- var navigated = 0;- await _mount(tester, _appWith(2), 420, onNavigate: () => navigated++);-- await tester.tap(find.byKey(const ValueKey('swarm-overflow-button')));- await tester.pumpAndSettle();- await tester.tap(find.text('Navigate'));- await tester.pumpAndSettle();-- expect(navigated, 1);- });-}