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
Unify icon button hover and keyboard focus feedback
deefcd1f0beddac
diff --git a/desktop/lib/shared/theme/app_theme.dart b/desktop/lib/shared/theme/app_theme.dartindex 89a7eb5b6..11d6b265c 100644--- a/desktop/lib/shared/theme/app_theme.dart+++ b/desktop/lib/shared/theme/app_theme.dart@@ -1082,6 +1082,24 @@ ThemeData buildAppTheme({Brightness brightness = Brightness.light}) {textTheme: textTheme,primaryTextTheme: textTheme,iconTheme: IconThemeData(color: scheme.onSurfaceVariant, size: 18),+ iconButtonTheme: IconButtonThemeData(+ style: ButtonStyle(+ shape: WidgetStatePropertyAll(+ RoundedRectangleBorder(borderRadius: BorderRadius.circular(7)),+ ),+ overlayColor: WidgetStateProperty.resolveWith((states) {+ if (states.contains(WidgetState.disabled)) return Colors.transparent;+ if (states.contains(WidgetState.pressed)) {+ return isDark ? const Color(0x1AFFFFFF) : const Color(0x0D000000);+ }+ if (states.contains(WidgetState.hovered) ||+ states.contains(WidgetState.focused)) {+ return isDark ? const Color(0x0DFFFFFF) : const Color(0x07000000);+ }+ return Colors.transparent;+ }),+ ),+ ),switchTheme: SwitchThemeData(thumbColor: WidgetStateProperty.all(Colors.white),trackColor: WidgetStateProperty.resolveWith(diff --git a/desktop/lib/shared/widgets/app_icon_button.dart b/desktop/lib/shared/widgets/app_icon_button.dartindex d774bd42e..477036e59 100644--- a/desktop/lib/shared/widgets/app_icon_button.dart+++ b/desktop/lib/shared/widgets/app_icon_button.dart@@ -1,28 +1,10 @@import 'package:flutter/material.dart';+import 'package:flutter/services.dart';import '../theme/app_theme.dart';-/// A small icon affordance that lifts under the pointer.-///-/// Material's [IconButton] is unusable raw here for the same reason-/// `MenuItemButton` is: the app defines no `iconButtonTheme`, so a bare one-/// takes Material's defaults — a 48px tap target padded around a 40px circle,-/// an ink ripple the app disables everywhere else, and, worst, **no hover-/// treatment at all** beyond a faint circular overlay. Its glyph keeps its-/// resting ink while the pointer sits on it, which reads as decoration rather-/// than something you can press.-///-/// This is the formula the rest of the app uses (`_MenuTrigger` in-/// `project_menu.dart`, `_ChatMenuItem` in `chat_header.dart`): the glyph climbs-/// to [AppPalette.textPrimary] and [AppSurface.hoverFill] lays in behind it.-///-/// ### Owning its own hover matters-///-/// A row that already lightens on hover (an `ExtensionTileSurface`) does **not**-/// tell the button inside it where the pointer is. Without its own-/// [MouseRegion] the button stays at rest for the whole time it's hovered, and-/// without its own [fill] the user can't tell "on the row" from "on the button".-/// Both halves were live bugs before this widget existed.+/// A compact icon button with the same rounded hover and focus well as the+/// standard icon-button theme, plus optional progress and destructive states.class AppIconButton extends StatefulWidget {const AppIconButton({super.key,@@ -119,6 +101,7 @@ class AppIconButton extends StatefulWidget {class _AppIconButtonState extends State<AppIconButton>with SingleTickerProviderStateMixin {bool _hovered = false;+ bool _focused = false;/// One turn. Slow enough to read as deliberate rather than as a busy/// indicator thrashing, fast enough that a reload finishing inside a single@@ -179,32 +162,49 @@ class _AppIconButtonState extends State<AppIconButton>? danger: (widget.hoverColor ?? AppPalette.textPrimary);+ final emphasized = enabled && (_hovered || _focused);final button = MouseRegion(cursor: enabled ? SystemMouseCursors.click : MouseCursor.defer,onEnter: (_) => setState(() => _hovered = true),onExit: (_) => setState(() => _hovered = false),- child: GestureDetector(- onTap: enabled ? widget.onPressed : null,- child: AnimatedContainer(- duration: AppMotion.hover,- curve: AppMotion.curve,- width: AppIconButton._box,- height: AppIconButton._box,- alignment: Alignment.center,- decoration: BoxDecoration(- color: _hovered && enabled- ? (widget.hoverFill ?? AppSurface.hoverFill)- : Colors.transparent,- borderRadius: BorderRadius.circular(AppIconButton._radius),+ child: FocusableActionDetector(+ enabled: enabled,+ onFocusChange: (value) => setState(() => _focused = value),+ shortcuts: const {+ SingleActivator(LogicalKeyboardKey.enter): ActivateIntent(),+ SingleActivator(LogicalKeyboardKey.space): ActivateIntent(),+ },+ actions: {+ ActivateIntent: CallbackAction<ActivateIntent>(+ onInvoke: (_) {+ if (enabled) widget.onPressed?.call();+ return null;+ },),- child: RotationTransition(- turns: _spin,- child: Icon(- widget.icon,- size: widget.size,- color: pressable- ? (_hovered && enabled ? active : resting)- : AppPalette.textFaint,+ },+ child: GestureDetector(+ onTap: enabled ? widget.onPressed : null,+ child: AnimatedContainer(+ duration: AppMotion.hover,+ curve: AppMotion.curve,+ width: AppIconButton._box,+ height: AppIconButton._box,+ alignment: Alignment.center,+ decoration: BoxDecoration(+ color: emphasized+ ? (widget.hoverFill ?? AppSurface.hoverFill)+ : Colors.transparent,+ borderRadius: BorderRadius.circular(AppIconButton._radius),+ ),+ child: RotationTransition(+ turns: _spin,+ child: Icon(+ widget.icon,+ size: widget.size,+ color: pressable+ ? (emphasized ? active : resting)+ : AppPalette.textFaint,+ ),),),),@@ -212,6 +212,12 @@ class _AppIconButtonState extends State<AppIconButton>);final tooltip = widget.tooltip;- return tooltip == null ? button : Tooltip(message: tooltip, child: button);+ return Semantics(+ button: true,+ enabled: enabled,+ child: tooltip == null+ ? button+ : Tooltip(message: tooltip, child: button),+ );}}diff --git a/desktop/macos/Runner/SwarmTitlebar.swift b/desktop/macos/Runner/SwarmTitlebar.swiftindex 96932aaed..a733f90b5 100644--- a/desktop/macos/Runner/SwarmTitlebar.swift+++ b/desktop/macos/Runner/SwarmTitlebar.swift@@ -836,7 +836,54 @@ private struct SwarmNativePalette: Equatable {}}-private final class SwarmNotificationButton: NSButton {+/// Match the quiet rounded hover well used by the app's pane controls.+private class SwarmIconButton: NSButton {+ private var hovered = false+ private(set) var hasKeyboardFocus = false+ var showsHoverFill: Bool { true }+ override var acceptsFirstResponder: Bool { isEnabled }+ override var mouseDownCanMoveWindow: Bool { false }+ override var isEnabled: Bool {+ didSet {+ needsDisplay = true+ window?.invalidateCursorRects(for: self)+ }+ }++ override func updateTrackingAreas() {+ super.updateTrackingAreas()+ trackingAreas.forEach(removeTrackingArea)+ addTrackingArea(NSTrackingArea(rect: .zero,+ options: [.mouseEnteredAndExited, .activeAlways, .inVisibleRect], owner: self))+ }+ override func mouseEntered(with event: NSEvent) { hovered = true; needsDisplay = true }+ override func mouseExited(with event: NSEvent) { hovered = false; needsDisplay = true }+ override func resetCursorRects() {+ super.resetCursorRects()+ if isEnabled { addCursorRect(bounds, cursor: .pointingHand) }+ }+ override func becomeFirstResponder() -> Bool {+ guard super.becomeFirstResponder() else { return false }+ hasKeyboardFocus = true+ needsDisplay = true+ return true+ }+ override func resignFirstResponder() -> Bool {+ guard super.resignFirstResponder() else { return false }+ hasKeyboardFocus = false+ needsDisplay = true+ return true+ }+ override func draw(_ dirtyRect: NSRect) {+ if showsHoverFill && isEnabled && (hovered || hasKeyboardFocus || isHighlighted) {+ NSColor.white.withAlphaComponent(isHighlighted ? 0.10 : 0.05).setFill()+ NSBezierPath(roundedRect: bounds.insetBy(dx: 1, dy: 1), xRadius: 7, yRadius: 7).fill()+ }+ super.draw(dirtyRect)+ }+}++private final class SwarmNotificationButton: SwarmIconButton {var hasAttention = false { didSet { needsDisplay = true } }override func draw(_ dirtyRect: NSRect) {super.draw(dirtyRect)@@ -911,7 +958,7 @@ private final class SwarmTabStrip: NSView {var emit: ((String, Any?) -> Void)?private let scroll = NSScrollView()private let document = NSView()- fileprivate let newButton = NSButton()+ fileprivate let newButton = SwarmIconButton()fileprivate let notificationButton = SwarmNotificationButton()fileprivate let openButton = SwarmActionButton()fileprivate let createButton = SwarmActionButton()@@ -1324,20 +1371,17 @@ private final class SwarmTabButton: NSView, NSDraggingSource, NSMenuItemValidati/// Selection and closing are sibling accessibility buttons, so VoiceOver and/// UI automation can reach the close action without treating the tab as a leaf.-private class SwarmTabActionButton: NSButton {+private class SwarmTabActionButton: SwarmIconButton {weak var owner: SwarmTabButton?- private(set) var hasKeyboardFocus = false- override var mouseDownCanMoveWindow: Bool { false }+ override var showsHoverFill: Bool { false }override func becomeFirstResponder() -> Bool {guard super.becomeFirstResponder() else { return false }- hasKeyboardFocus = trueowner?.updateCloseVisibility()if let owner { owner.scrollToVisible(owner.bounds) }return true}override func resignFirstResponder() -> Bool {guard super.resignFirstResponder() else { return false }- hasKeyboardFocus = falseowner?.updateCloseVisibility()return true}@@ -1346,6 +1390,7 @@ private class SwarmTabActionButton: NSButton {/// Keep the close action reachable by keyboard and VoiceOver while its glyph/// rests quietly. Reserving its space avoids shifting labels on hover.private final class SwarmCloseButton: SwarmTabActionButton {+ override var showsHoverFill: Bool { true }var showsGlyph = false { didSet { if showsGlyph != oldValue { needsDisplay = true } } }override func draw(_ dirtyRect: NSRect) {if showsGlyph { super.draw(dirtyRect) }diff --git a/desktop/test/button_hover_test.dart b/desktop/test/button_hover_test.dartindex 5c77ab98f..75814a232 100644--- a/desktop/test/button_hover_test.dart+++ b/desktop/test/button_hover_test.dart@@ -12,11 +12,14 @@// 2. a `styleFrom` at a call site restates it, because `styleFrom` REPLACES// the theme's style rather than merging with it.import 'dart:math' as math;+import 'dart:ui' show PointerDeviceKind;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';+import 'package:harness/shared/widgets/app_icon_button.dart';const _hovered = {WidgetState.hovered};@@ -60,6 +63,7 @@ void main() {'text': theme.textButtonTheme.style,'outlined': theme.outlinedButtonTheme.style,'filled': theme.filledButtonTheme.style,+ 'icon': theme.iconButtonTheme.style,};kinds.forEach((name, style) {final overlay = style?.overlayColor?.resolve(_hovered);@@ -76,6 +80,15 @@ void main() {});});+ test('icon focus is visible and disabled icons stay quiet', () {+ final overlay = theme.iconButtonTheme.style!.overlayColor!;+ expect(overlay.resolve({WidgetState.focused})!.a, greaterThan(0));+ expect(+ overlay.resolve({WidgetState.disabled, WidgetState.hovered})!.a,+ 0,+ );+ });+// An overlay that exists but cannot be seen is the same bug wearing a// value. These are measured on the surfaces buttons actually sit on.test('the hover wash is visible on the surfaces buttons sit on', () {@@ -97,4 +110,44 @@ void main() {});});}++ testWidgets('compact icons respond to hover and keyboard activation', (+ tester,+ ) async {+ var presses = 0;+ await tester.pumpWidget(+ MaterialApp(+ theme: buildAppTheme(brightness: Brightness.dark),+ home: Scaffold(+ body: Center(+ child: AppIconButton(icon: Icons.add, onPressed: () => presses++),+ ),+ ),+ ),+ );+ final button = find.byType(AppIconButton);+ final fill = find.descendant(+ of: button,+ matching: find.byType(AnimatedContainer),+ );+ Color background() =>+ (tester.widget<AnimatedContainer>(fill).decoration! as BoxDecoration)+ .color!;+ expect(background().a, 0);+ final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);+ await mouse.addPointer(location: Offset.zero);+ await mouse.moveTo(tester.getCenter(button));+ await tester.pumpAndSettle();+ expect(background().a, greaterThan(0));+ await mouse.moveTo(Offset.zero);+ await tester.pumpAndSettle();+ expect(background().a, 0);+ await tester.sendKeyEvent(LogicalKeyboardKey.tab);+ await tester.pumpAndSettle();+ expect(background().a, greaterThan(0));+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);+ await tester.sendKeyEvent(LogicalKeyboardKey.space);+ expect(presses, 2);+ await mouse.removePointer();+ });}diff --git a/desktop/tool/swarm_titlebar_checks.swift b/desktop/tool/swarm_titlebar_checks.swiftindex 0c21e81dc..d72bd5a45 100644--- a/desktop/tool/swarm_titlebar_checks.swift+++ b/desktop/tool/swarm_titlebar_checks.swift@@ -16,7 +16,7 @@ private final class TitlebarMouseUpProbe: NSResponder {override func mouseUp(with event: NSEvent) { mouseUps += 1 }}-private extension SwarmActionButton {+private extension NSButton {func renderedPixels() -> Data {let bitmap = NSBitmapImageRep(bitmapDataPlanes: nil,pixelsWide: Int(bounds.width), pixelsHigh: Int(bounds.height),@@ -316,7 +316,10 @@ private extension SwarmTabStrip {let beforeStale = messenger.calls.countstale.clickBothActions()try checkTitlebar(messenger.calls.count == beforeStale, "A removed tab's retained controls cannot dispatch actions")+ let unfocusedNew = newButton.renderedPixels()try checkTitlebar(window.makeFirstResponder(newButton), "New swarm accepts keyboard focus")+ try checkTitlebar(newButton.hasKeyboardFocus && newButton.renderedPixels() != unfocusedNew,+ "Keyboard focus gives the new-tab icon the same visible background as hover")newButton.performClick(nil)messenger.finishNextReply()try checkTitlebar(window.firstResponder === window.contentInput && messenger.calls.last?.method == "new",@@ -910,6 +913,23 @@ do {try checkTitlebar(swarmRow.menuTitle().string == "My swarm", "Empty swarm rows have no invented machine label")let sharedSwarm = SwarmHistoryEntry(["id": "shared", "title": "Workshop", "swarm": true, "machineName": "2 machines"])!try checkTitlebar(sharedSwarm.menuTitle().string == "Workshop\t2 machines", "Swarm machine counts use the same trailing column as agent machines")+ for button in [SwarmIconButton(), SwarmNotificationButton(), SwarmCloseButton()] {+ button.frame = NSRect(x: 0, y: 0, width: 28, height: 28)+ button.image = NSImage(systemSymbolName: "plus", accessibilityDescription: nil)+ button.isBordered = false+ (button as? SwarmCloseButton)?.showsGlyph = true+ let rest = button.renderedPixels()+ let hover = NSEvent.mouseEvent(with: .mouseMoved, location: .zero, modifierFlags: [],+ timestamp: 0, windowNumber: 0, context: nil, eventNumber: 0, clickCount: 0, pressure: 0)!+ button.mouseEntered(with: hover)+ try checkTitlebar(button.renderedPixels() != rest, "Native icon buttons draw a hover background")+ button.mouseExited(with: hover)+ try checkTitlebar(button.renderedPixels() == rest, "Native icon backgrounds clear when the pointer leaves")+ button.isEnabled = false+ let disabled = button.renderedPixels()+ button.mouseEntered(with: hover)+ try checkTitlebar(button.renderedPixels() == disabled, "Disabled native icons do not highlight")+ }var assetReads = 0let icons = SwarmHistoryIcons(assetURL: { asset inassetReads += 1diff --git a/docs/harness-agent-first-tabs.md b/docs/harness-agent-first-tabs.mdindex 470f6d1fd..109fbfec6 100644--- a/docs/harness-agent-first-tabs.md+++ b/docs/harness-agent-first-tabs.md@@ -18,6 +18,9 @@ controls. Show a choice's name and useful preview; add explanation only when ithelps someone decide or recover from an error. Prefer whitespace and restrainedsurfaces over extra rules and nested cards. Apply this consistently withoutwaiting for the user to request copy removal one control at a time.+Icon buttons share a quiet rounded background on hover and keyboard focus.+Apply this to native tab close, new-tab and notification icons as well as+Flutter controls. Disabled icons do not highlight; decorative icons stay inert.Action order is **New → Open** in the titlebar, File menu and both split controls.The **New Harness page is the deliberate exception: Open → New** below search.