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
Web: a ⋯ on each machine row opens its menu; the browser's menu stays off while it is open (Huy) (#2545)
0xken15fa2f7ce93d97
diff --git a/desktop/lib/super_tabs/machines.dart b/desktop/lib/super_tabs/machines.dartindex 2e3ead4a5..b1c3ff8c6 100644--- a/desktop/lib/super_tabs/machines.dart+++ b/desktop/lib/super_tabs/machines.dart@@ -2,6 +2,7 @@ import 'dart:async';import 'package:clock/clock.dart';import 'package:flutter/material.dart';+import 'package:flutter/services.dart';import '../core/machine_resources.dart';import '../core/models.dart';@@ -785,6 +786,9 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {/// Once a second, so that ages, states and the heading's count follow the clock between the Swarm's reads.Timer? _tick;final _tips = <String, GlobalKey<TooltipState>>{};++ /// One per Swarm menu open now, each keeping the browser's menu off.+ final _menuHolds = <Object>{};ModelsMenuController? _usage;Timer? _timer;bool _reading = false;@@ -919,6 +923,8 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {@overridevoid dispose() {+ _menuHolds.forEach(BrowserMenuGuard.release);+ _menuHolds.clear();_revision++;_timer?.cancel();_tick?.cancel();@@ -1622,26 +1628,37 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {/// A machine row's right-click: its details, and Remove from Swarm for whoever may.Future<void> _menu(_MachineView view, Offset at) async {- final choice = await showMenu<String>(- context: context,- position: RelativeRect.fromLTRB(at.dx, at.dy, at.dx, at.dy),- items: [- const PopupMenuItem(value: 'details', child: Text('Details')),- if (_canRemove(view.id))- PopupMenuItem(- key: ValueKey('super-machine-menu-remove'),- value: 'remove',- enabled: _removeReason(view.id) == null,- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- const Text('Remove from Swarm'),- if (_removeReason(view.id) case final reason?) Text(reason),- ],+ // The menu's barrier takes the pointer from the row, so a second right-click would bring up the browser's menu+ // over this one. Off until it closes; dispose lets go too, for a screen that goes with the menu still up.+ final hold = Object();+ _menuHolds.add(hold);+ BrowserMenuGuard.hold(hold);+ final String? choice;+ try {+ choice = await showMenu<String>(+ context: context,+ position: RelativeRect.fromLTRB(at.dx, at.dy, at.dx, at.dy),+ items: [+ const PopupMenuItem(value: 'details', child: Text('Details')),+ if (_canRemove(view.id))+ PopupMenuItem(+ key: ValueKey('super-machine-menu-remove'),+ value: 'remove',+ enabled: _removeReason(view.id) == null,+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ const Text('Remove from Swarm'),+ if (_removeReason(view.id) case final reason?) Text(reason),+ ],+ ),),- ),- ],- );+ ],+ );+ } finally {+ _menuHolds.remove(hold);+ BrowserMenuGuard.release(hold);+ }if (!mounted) return;if (choice == 'details') await _openDetails(view);if (choice == 'remove' &&@@ -1778,44 +1795,61 @@ class _SuperTabMachinesState extends State<SuperTabMachines> {final selected = _selectedMachineId == view.id;final row = BrowserMenuOff(active: true,- child: Material(- color: selected ? grid.AppSurface.selectedFill : Colors.transparent,- borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),- clipBehavior: Clip.antiAlias,- // No chevron (Dee, 2026-10-27): a click expands the machine, and its- // details are in the right-click menu, or a long press on a touch screen.- child: Builder(- builder: (rowContext) => InkWell(- key: ValueKey('super-machine-${view.id}'),- onTap: () {- c.toggleMachineExpanded(view.id);- _changed();- },- onLongPress: () => unawaited(_menu(view, _longPressAt(rowContext))),- onSecondaryTapUp: (event) =>- unawaited(_menu(view, event.globalPosition)),- hoverColor: grid.AppSurface.hoverFill,- focusColor: grid.AppSurface.hoverFill,- borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),- onFocusChange: (focused) {- if (focused &&- FocusManager.instance.highlightMode ==- FocusHighlightMode.traditional) {- tipKey.currentState?.ensureTooltipVisible();- } else if (!focused) {- Tooltip.dismissAllToolTips();- }- },- child: Semantics(- expanded: expanded,- child: _MachineLine(- view: view,- onSetUpTeam: view.setUpTeam- ? () async {- await showTeamAccountSetup(context, widget.app!);- await _readTeamSetup();- }- : null,+ child: _RowHoverRegion(+ child: Material(+ color: selected ? grid.AppSurface.selectedFill : Colors.transparent,+ borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),+ clipBehavior: Clip.antiAlias,+ // No chevron (Dee, 2026-10-27): a click expands the machine, and its+ // details are in the right-click menu, or a long press on a touch screen.+ child: Builder(+ builder: (rowContext) => CallbackShortcuts(+ bindings: {+ const SingleActivator(LogicalKeyboardKey.contextMenu): () =>+ unawaited(_menu(view, _longPressAt(rowContext))),+ const SingleActivator(+ LogicalKeyboardKey.f10,+ shift: true,+ ): () =>+ unawaited(_menu(view, _longPressAt(rowContext))),+ },+ child: InkWell(+ key: ValueKey('super-machine-${view.id}'),+ onTap: () {+ c.toggleMachineExpanded(view.id);+ _changed();+ },+ onLongPress: () =>+ unawaited(_menu(view, _longPressAt(rowContext))),+ onSecondaryTapUp: (event) =>+ unawaited(_menu(view, event.globalPosition)),+ hoverColor: grid.AppSurface.hoverFill,+ focusColor: grid.AppSurface.hoverFill,+ borderRadius: BorderRadius.circular(DesktopChrome.rowRadius),+ onFocusChange: (focused) {+ if (focused &&+ FocusManager.instance.highlightMode ==+ FocusHighlightMode.traditional) {+ tipKey.currentState?.ensureTooltipVisible();+ } else if (!focused) {+ Tooltip.dismissAllToolTips();+ }+ },+ child: Semantics(+ expanded: expanded,+ child: _MachineLine(+ view: view,+ onMore: BrowserMenuGuard.inBrowser+ ? (at) => _menu(view, at)+ : null,+ onSetUpTeam: view.setUpTeam+ ? () async {+ await showTeamAccountSetup(context, widget.app!);+ await _readTeamSetup();+ }+ : null,+ ),+ ),),),),@@ -2444,10 +2478,13 @@ const _noQuotaLeft = 'No quota left until it resets.';/// The same leading icon/name and trailing status column as projects.class _MachineLine extends StatelessWidget {- const _MachineLine({required this.view, this.onSetUpTeam});+ const _MachineLine({required this.view, this.onSetUpTeam, this.onMore});final _MachineView view;+ /// In a browser, opens the machine's menu at a point until it closes: the ⋯ that needs no right-click.+ final Future<void> Function(Offset at)? onMore;+/// This Mac's row, without its Harness Team account: Set up under the paused line.final VoidCallback? onSetUpTeam;@@ -2554,6 +2591,11 @@ class _MachineLine extends StatelessWidget {padding: const EdgeInsets.only(left: 6),child: Text('Cleaning up', style: DesktopChrome.metadata()),),+ if (onMore case final open?)+ _MachineMore(+ key: ValueKey('super-machine-more-${view.id}'),+ onOpen: open,+ ),SizedBox(width: 32,child: Center(@@ -2575,6 +2617,104 @@ class _MachineLine extends StatelessWidget {}}+/// The ⋯ on a machine row. It takes no room until the row is pointed at or the button has focus, and stays in the+/// focus order the whole time, so a key can reach it.+class _MachineMore extends StatefulWidget {+ const _MachineMore({super.key, required this.onOpen});++ final Future<void> Function(Offset at) onOpen;++ /// The button's width and height when shown: [AppIconButton]'s target.+ static const width = 32.0;++ @override+ State<_MachineMore> createState() => _MachineMoreState();+}++class _MachineMoreState extends State<_MachineMore> {+ bool _focused = false;++ /// With its menu up the row loses the pointer to the menu's barrier; the ⋯ stays, so the row does not jump.+ bool _open = false;++ Future<void> _press() async {+ final box = context.findRenderObject();+ if (box is! RenderBox || !box.hasSize) return;+ setState(() => _open = true);+ try {+ await widget.onOpen(box.localToGlobal(Offset(0, box.size.height)));+ } finally {+ if (mounted) setState(() => _open = false);+ }+ }++ @override+ Widget build(BuildContext context) {+ final shown = _focused || _open || _RowHover.of(context);+ return Focus(+ canRequestFocus: false,+ skipTraversal: true,+ onFocusChange: (focused) => setState(() => _focused = focused),+ child: SizedBox(+ width: shown ? _MachineMore.width : 0,+ height: _MachineMore.width,+ child: OverflowBox(+ alignment: Alignment.centerRight,+ minWidth: _MachineMore.width,+ maxWidth: _MachineMore.width,+ child: Opacity(+ opacity: shown ? 1 : 0,+ child: IgnorePointer(+ ignoring: !shown,+ child: AppIconButton(+ icon: AppIcons.ellipsis,+ tooltip: 'More',+ size: 16,+ onPressed: () => unawaited(_press()),+ ),+ ),+ ),+ ),+ ),+ );+ }+}++/// Whether the pointer is over the row below it.+class _RowHover extends InheritedWidget {+ const _RowHover({required this.hovered, required super.child});++ final bool hovered;++ static bool of(BuildContext context) =>+ context.dependOnInheritedWidgetOfExactType<_RowHover>()?.hovered ?? false;++ @override+ bool updateShouldNotify(_RowHover oldWidget) => hovered != oldWidget.hovered;+}++/// Tells [_RowHover] readers below it when the pointer enters and leaves.+class _RowHoverRegion extends StatefulWidget {+ const _RowHoverRegion({required this.child});++ final Widget child;++ @override+ State<_RowHoverRegion> createState() => _RowHoverRegionState();+}++class _RowHoverRegionState extends State<_RowHoverRegion> {+ bool _hovered = false;++ @override+ Widget build(BuildContext context) => MouseRegion(+ opaque: false,+ onEnter: (_) => setState(() => _hovered = true),+ onExit: (_) => setState(() => _hovered = false),+ child: _RowHover(hovered: _hovered, child: widget.child),+ );+}+/// The expanded reading block wraps complete values, without filling missing slots.class _MachineReadings extends StatelessWidget {const _MachineReadings({required this.view});diff --git a/desktop/lib/super_tabs/roster.dart b/desktop/lib/super_tabs/roster.dartindex 00da3d233..ee41d14df 100644--- a/desktop/lib/super_tabs/roster.dart+++ b/desktop/lib/super_tabs/roster.dart@@ -13,6 +13,7 @@ import '../shared/widgets/app_select_field.dart';import '../state/app_state.dart';import '../terminal/terminal_theme.dart';import '../terminal/terminal_theme_store.dart';+import '../widgets/browser_menu_guard.dart';import '../widgets/desktop_chrome.dart';import '../widgets/harness_activity_mark.dart';import 'agent_details.dart';@@ -453,75 +454,79 @@ class _SuperTabRosterState extends State<SuperTabRoster> {return Tooltip(message: tooltip,constraints: const BoxConstraints(maxWidth: 820),- child: GestureDetector(- onSecondaryTapUp: (event) async {- final choice = await showMenu<String>(- context: context,- position: RelativeRect.fromLTRB(- event.globalPosition.dx,- event.globalPosition.dy,- event.globalPosition.dx,- event.globalPosition.dy,- ),- items: [- const PopupMenuItem(value: 'details', child: Text('Details')),- if (_canRemove(c.snapshot?.agent(agent.id) ?? agent))- PopupMenuItem(- value: 'remove',- enabled: _removeReason(agent) == null,- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- const Text('Remove from Swarm'),- if (_removeReason(agent) case final reason?) Text(reason),- ],+ child: BrowserMenuOff(+ active: true,+ child: GestureDetector(+ onSecondaryTapUp: (event) async {+ final choice = await showMenu<String>(+ context: context,+ position: RelativeRect.fromLTRB(+ event.globalPosition.dx,+ event.globalPosition.dy,+ event.globalPosition.dx,+ event.globalPosition.dy,+ ),+ items: [+ const PopupMenuItem(value: 'details', child: Text('Details')),+ if (_canRemove(c.snapshot?.agent(agent.id) ?? agent))+ PopupMenuItem(+ value: 'remove',+ enabled: _removeReason(agent) == null,+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ const Text('Remove from Swarm'),+ if (_removeReason(agent) case final reason?)+ Text(reason),+ ],+ ),),- ),- ],- );- if (choice == 'details' && mounted) await _details(agent);- if (choice == 'remove' && mounted) {- final current = c.snapshot?.agent(agent.id);- if (current != null &&- _canRemove(current) &&- _removeReason(current) == null) {- await _remove(current);+ ],+ );+ if (choice == 'details' && mounted) await _details(agent);+ if (choice == 'remove' && mounted) {+ final current = c.snapshot?.agent(agent.id);+ if (current != null &&+ _canRemove(current) &&+ _removeReason(current) == null) {+ await _remove(current);+ }}- }- },- child: SuperTabMemberRow(- rowKey: ValueKey('super-member-${agent.id}'),- onTap: open,- onLongPress: () => unawaited(_details(agent)),- avatar: SuperTabAvatar.agent(- agent,- name: name,- size: SuperTabAvatar.rowSize,- engineBadge: false,- ),- name: _agentIdentity(- name,- role,- badge,- model: glance.modelEffort,- modelKey: ValueKey('super-member-model-${agent.id}'),- ),- detail: Text(- detail,- key: ValueKey('super-member-line-${agent.id}'),- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: DesktopChrome.metadata(),- ),- trailing: ActivityMark(- key: ValueKey('super-member-mark-${agent.id}'),- activity: shown,- tooltip: false,- showIdle: true,- color: activityColor(- shown,- theme,- color: appearancePrefsStore.value.prompt.color,+ },+ child: SuperTabMemberRow(+ rowKey: ValueKey('super-member-${agent.id}'),+ onTap: open,+ onLongPress: () => unawaited(_details(agent)),+ avatar: SuperTabAvatar.agent(+ agent,+ name: name,+ size: SuperTabAvatar.rowSize,+ engineBadge: false,+ ),+ name: _agentIdentity(+ name,+ role,+ badge,+ model: glance.modelEffort,+ modelKey: ValueKey('super-member-model-${agent.id}'),+ ),+ detail: Text(+ detail,+ key: ValueKey('super-member-line-${agent.id}'),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: DesktopChrome.metadata(),+ ),+ trailing: ActivityMark(+ key: ValueKey('super-member-mark-${agent.id}'),+ activity: shown,+ tooltip: false,+ showIdle: true,+ color: activityColor(+ shown,+ theme,+ color: appearancePrefsStore.value.prompt.color,+ ),),),),diff --git a/desktop/lib/widgets/browser_menu_guard.dart b/desktop/lib/widgets/browser_menu_guard.dartindex acdd3b7ce..da97e83b5 100644--- a/desktop/lib/widgets/browser_menu_guard.dart+++ b/desktop/lib/widgets/browser_menu_guard.dart@@ -32,6 +32,9 @@ class BrowserMenuGuard {static bool get _web => debugWeb ?? kIsWeb;+ /// Whether this runs in a browser, where a right-click is not sure to reach the app.+ static bool get inBrowser => _web;+/// Whether the browser's menu is off now.static bool get isOff => _off;diff --git a/desktop/lib/widgets/machines_panel.dart b/desktop/lib/widgets/machines_panel.dartindex 32b59a4c4..0c8be018f 100644--- a/desktop/lib/widgets/machines_panel.dart+++ b/desktop/lib/widgets/machines_panel.dart@@ -1,3 +1,5 @@+import 'browser_menu_guard.dart';+import 'dart:async';import 'package:harness/shared/theme/app_icons.dart';@@ -1116,14 +1118,17 @@ class _MachineRow extends StatelessWidget {}return KeyEventResult.ignored;},- child: InkWell(- onTap: onTap,- onSecondaryTapDown: menu == null- ? null- : (details) => openMenu(details.localPosition),- onLongPress: menu == null ? null : openMenu,- borderRadius: BorderRadius.circular(8),- child: row,+ child: BrowserMenuOff(+ active: menu != null,+ child: InkWell(+ onTap: onTap,+ onSecondaryTapDown: menu == null+ ? null+ : (details) => openMenu(details.localPosition),+ onLongPress: menu == null ? null : openMenu,+ borderRadius: BorderRadius.circular(8),+ child: row,+ ),),);return Semantics(diff --git a/desktop/scripts/web-machine-menu-check.mjs b/desktop/scripts/web-machine-menu-check.mjsnew file mode 100644index 000000000..a93258029--- /dev/null+++ b/desktop/scripts/web-machine-menu-check.mjs@@ -0,0 +1,131 @@+#!/usr/bin/env node+// Right-clicks and clicks a machine row in a real browser, on a release build. No CI job runs Flutter in a browser, so+// a change to the row's menu runs this by hand. It uses Node's own WebSocket and installs nothing.+//+// flutter build web --release --no-wasm-dry-run --no-web-resources-cdn \+// -t test/web/release/machine_row_app.dart --output=OUT+// CHROME_EXECUTABLE=/path/to/chrome-headless-shell node scripts/web-machine-menu-check.mjs OUT+//+// Exits 1 if any check fails.+import { spawn } from 'node:child_process';+import { mkdtempSync, readFileSync, rmSync } from 'node:fs';+import { createServer } from 'node:http';+import { tmpdir } from 'node:os';+import { extname, join, normalize } from 'node:path';++const dir = process.argv[2];+const exe = process.env.CHROME_EXECUTABLE;+if (!dir || !exe) {+ console.error('usage: CHROME_EXECUTABLE=... node web-machine-menu-check.mjs BUILD_DIR');+ process.exit(2);+}+const types = { '.html': 'text/html', '.js': 'text/javascript', '.json': 'application/json', '.wasm': 'application/wasm' };+const server = createServer((req, res) => {+ const path = normalize(new URL(req.url, 'http://x').pathname);+ try {+ const body = readFileSync(join(dir, path === '/' ? 'index.html' : path));+ res.writeHead(200, { 'content-type': types[extname(path) || '.html'] ?? 'application/octet-stream' });+ res.end(body);+ } catch {+ res.writeHead(404).end();+ }+});+await new Promise((done) => server.listen(0, '127.0.0.1', done));+const profile = mkdtempSync(join(tmpdir(), 'web-machine-menu-'));+const chrome = spawn(exe, ['--no-sandbox', '--remote-debugging-port=0', `--user-data-dir=${profile}`, '--window-size=1400,800', 'about:blank'], { stdio: ['ignore', 'ignore', 'pipe'] });++const sleep = (ms) => new Promise((done) => setTimeout(done, ms));+let failed = 0;+try {+ const port = await new Promise((done, fail) => {+ let text = '';+ chrome.stderr.on('data', (chunk) => {+ text += chunk;+ const found = text.match(/ws:\/\/127\.0\.0\.1:(\d+)\//);+ if (found) done(found[1]);+ });+ setTimeout(() => fail(new Error('the browser did not start')), 30000);+ });+ const pages = await (await fetch(`http://127.0.0.1:${port}/json/list`)).json();+ const socket = new WebSocket(pages.find((p) => p.type === 'page').webSocketDebuggerUrl);+ await new Promise((done) => socket.addEventListener('open', done));+ let id = 0;+ const waiting = new Map();+ socket.addEventListener('message', ({ data }) => {+ const reply = JSON.parse(data);+ waiting.get(reply.id)?.(reply);+ waiting.delete(reply.id);+ });+ const send = (method, params = {}) =>+ new Promise((done) => {+ waiting.set(++id, done);+ socket.send(JSON.stringify({ id, method, params }));+ });+ const read = async (expression) => (await send('Runtime.evaluate', { expression, returnByValue: true })).result.result.value;++ await send('Page.enable');+ await send('Page.navigate', { url: `http://127.0.0.1:${server.address().port}/` });+ const rect = async (key) => {+ const all = (await read('document.body.dataset.rects')) ?? '';+ const row = all.split(';').find((r) => r.startsWith(`${key}=`));+ if (!row) return null;+ const [x, y, w, h] = row.split('=')[1].split(',').map(Number);+ return { x: x + w / 2, y: y + h / 2, w };+ };+ for (let i = 0; i < 120 && !(await rect('super-machine-studio')); i++) await sleep(500);+ await read(`window.__menus = []; window.addEventListener('contextmenu', (e) => window.__menus.push(e.defaultPrevented))`);++ const mouse = (type, { x, y }, button = 'none', buttons = 0) =>+ send('Input.dispatchMouseEvent', { type, x, y, button, buttons, clickCount: button === 'none' ? 0 : 1 });+ const move = async (at) => { await mouse('mouseMoved', at); await sleep(300); };+ const click = async (at, button) => {+ const buttons = button === 'right' ? 2 : 1;+ await mouse('mousePressed', at, button, buttons);+ await mouse('mouseReleased', at, button, 0);+ await sleep(500);+ };+ const escape = async () => {+ const key = { key: 'Escape', code: 'Escape', windowsVirtualKeyCode: 27 };+ await send('Input.dispatchKeyEvent', { type: 'keyDown', ...key });+ await send('Input.dispatchKeyEvent', { type: 'keyUp', ...key });+ await sleep(500);+ };+ const browserMenu = async () => (await read('window.__menus.at(-1)')) === false;+ const swarmMenu = async () => (await read('document.title')) === 'menu-open';+ const check = (name, ok) => {+ console.log(`${ok ? 'PASS' : 'FAIL'} ${name}`);+ if (!ok) failed++;+ };++ const row = await rect('super-machine-studio');+ const terminal = await rect('super-machine-check-terminal');+ await move(row);+ await click(row, 'right');+ check('right-click on a machine row opens the Swarm menu, not the browser menu', (await swarmMenu()) && !(await browserMenu()));+ await click({ x: row.x, y: row.y + 200 }, 'right');+ check('a second right-click with that menu open does not bring up the browser menu', !(await browserMenu()));+ if (await swarmMenu()) await escape();++ await move(terminal);+ await click(terminal, 'right');+ check("a terminal's right-click still gives the browser's Copy and Paste", await browserMenu());++ await move(row);+ const more = await rect('super-machine-more-studio');+ check('pointing at the row shows the ⋯', !!more && more.w > 0);+ if (more) {+ await move(more);+ await click(more, 'left');+ check('a left click on the ⋯ opens the Swarm menu', await swarmMenu());+ if (await swarmMenu()) await escape();+ }+ await move(terminal);+ await click(terminal, 'right');+ check("after the menu closes the terminal's right-click is the browser's again", await browserMenu());+} finally {+ chrome.kill();+ server.close();+ await sleep(200);+ rmSync(profile, { recursive: true, force: true });+}+process.exit(failed ? 1 : 0);diff --git a/desktop/test/machines_panel_test.dart b/desktop/test/machines_panel_test.dartindex af54b34aa..ad430703a 100644--- a/desktop/test/machines_panel_test.dart+++ b/desktop/test/machines_panel_test.dart@@ -22,6 +22,7 @@ import 'package:harness/shared/theme/app_theme.dart' as grid;import 'package:harness/shortcuts/app_keymap.dart';import 'package:harness/shortcuts/keymap_host.dart';import 'package:harness/state/app_state.dart';+import 'package:harness/widgets/browser_menu_guard.dart';import 'package:harness/widgets/machines_panel.dart';import 'package:harness/widgets/sign_in_step.dart';@@ -281,6 +282,26 @@ void main() {const ValueKey('connect-password-remote-input'),);+ testWidgets(+ 'in a browser, pointing at a machine with a menu switches the browser menu off',+ (tester) async {+ final told = <bool>[];+ BrowserMenuGuard.debugWeb = true;+ BrowserMenuGuard.debugSink = (off) async => told.add(off);+ addTearDown(BrowserMenuGuard.debugReset);+ await mount(tester);+ final row = find.byKey(const ValueKey('machine-local'));+ await tester.ensureVisible(row);+ final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);+ addTearDown(mouse.removePointer);+ await mouse.addPointer(location: const Offset(1, 1));+ await mouse.moveTo(tester.getCenter(row));+ await tester.pump();+ expect(told, [true]);+ await tester.pumpWidget(const SizedBox());+ },+ );+testWidgets('a full machine list stays quiet and reveals all setup steps', (tester,) async {diff --git a/desktop/test/super_tab_machines_test.dart b/desktop/test/super_tab_machines_test.dartindex ccd121b2e..b9e2a26ee 100644--- a/desktop/test/super_tab_machines_test.dart+++ b/desktop/test/super_tab_machines_test.dart@@ -1657,6 +1657,196 @@ void main() {},);+ group('in a browser, the ⋯ on a machine row', () {+ final more = find.byKey(const ValueKey('super-machine-more-studio'));+ final rowKey = find.byKey(const ValueKey('super-machine-studio'));+ double width(WidgetTester tester) => tester.getSize(more).width;++ Future<dynamic> browser(+ WidgetTester tester, {+ String owner = 'owner',+ }) async {+ BrowserMenuGuard.debugWeb = true;+ BrowserMenuGuard.debugSink = (_) async {};+ addTearDown(BrowserMenuGuard.debugReset);+ final server = _RemovalServer();+ server.state['machines'] = [machine(owner)];+ final c = server.controller();+ await c.refresh();+ await mount(tester, c);+ return c;+ }++ Future<void> hover(WidgetTester tester) async {+ final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);+ addTearDown(mouse.removePointer);+ await mouse.addPointer(location: const Offset(900, 700));+ await mouse.moveTo(tester.getCenter(rowKey));+ await tester.pump();+ }++ Future<void> done(WidgetTester tester, dynamic c) async {+ await tester.pumpWidget(const SizedBox());+ await c.flush();+ c.dispose();+ }++ testWidgets('shows on pointing and opens the same menu on a left click', (+ tester,+ ) async {+ final c = await browser(tester);+ expect(width(tester), 0, reason: 'nothing until pointed at');+ await hover(tester);+ expect(width(tester), greaterThan(0));+ await tester.tap(more);+ await tester.pumpAndSettle();+ expect(find.text('Details'), findsOneWidget);+ expect(+ find.byKey(const ValueKey('super-machine-menu-remove')),+ findsOneWidget,+ );+ // The click stayed on the button: the row did not expand as well.+ expect(c.isMachineExpanded('studio'), isFalse);+ await tester.tap(find.text('Details'));+ await tester.pumpAndSettle();+ expect(+ find.byKey(const ValueKey('super-machine-remove')),+ findsOneWidget,+ );+ await tester.tap(find.byTooltip('Close').last);+ await tester.pumpAndSettle();+ await done(tester, c);+ });++ testWidgets(+ 'keeps Desktop\'s permissions: another person\'s machine has Details alone',+ (tester) async {+ final c = await browser(tester, owner: 'someone-else');+ await hover(tester);+ await tester.tap(more);+ await tester.pumpAndSettle();+ expect(find.text('Details'), findsOneWidget);+ expect(find.text('Remove from Swarm'), findsNothing);+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);+ await tester.pumpAndSettle();+ await done(tester, c);+ },+ );++ testWidgets('a key reaches it: focus shows it and Enter opens the menu', (+ tester,+ ) async {+ final c = await browser(tester);+ // Tab, as a person does: the row first, the ⋯ after the sidebar's other rows.+ for (var i = 0; i < 20 && width(tester) == 0; i++) {+ await tester.sendKeyEvent(LogicalKeyboardKey.tab);+ await tester.pump();+ }+ expect(width(tester), greaterThan(0));+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);+ await tester.pumpAndSettle();+ expect(find.text('Details'), findsOneWidget);+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);+ await tester.pumpAndSettle();+ await done(tester, c);+ });++ testWidgets('the menu key on the row itself opens the menu', (+ tester,+ ) async {+ final c = await browser(tester);+ Focus.of(+ tester.element(+ find.byKey(const ValueKey('super-machine-name-studio')),+ ),+ ).requestFocus();+ await tester.pump();+ await tester.sendKeyEvent(LogicalKeyboardKey.contextMenu);+ await tester.pumpAndSettle();+ expect(find.text('Details'), findsOneWidget);+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);+ await tester.pumpAndSettle();+ await done(tester, c);+ });++ testWidgets('a computer has no ⋯: its right-click stays the way in', (+ tester,+ ) async {+ final server = _RemovalServer();+ server.state['machines'] = [machine('owner')];+ final c = server.controller();+ await c.refresh();+ await mount(tester, c);+ expect(more, findsNothing);+ await done(tester, c);+ });+ });++ testWidgets(+ 'the browser menu stays off while the Swarm menu is open, and comes back when it closes',+ (tester) async {+ final told = <bool>[];+ BrowserMenuGuard.debugWeb = true;+ BrowserMenuGuard.debugSink = (off) async => told.add(off);+ addTearDown(BrowserMenuGuard.debugReset);+ final server = _RemovalServer();+ server.state['machines'] = [machine('owner')];+ final c = server.controller();+ await c.refresh();+ await mount(tester, c);+ final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);+ addTearDown(mouse.removePointer);+ await mouse.addPointer(location: const Offset(900, 700));+ final row = find.byKey(const ValueKey('super-machine-studio'));+ await mouse.moveTo(tester.getCenter(row));+ await tester.pump();+ await tester.tap(row, buttons: kSecondaryMouseButton);+ await tester.pumpAndSettle();+ expect(find.text('Details'), findsOneWidget);+ // The menu's barrier took the pointer from the row: a second right-click+ // lands on the barrier and must not bring up the browser's menu.+ await mouse.moveTo(const Offset(900, 700));+ await tester.pump();+ expect(told, [true], reason: 'still off with the menu open');+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);+ await tester.pumpAndSettle();+ expect(told, [+ true,+ false,+ ], reason: 'a terminal has its Copy and Paste again');+ await tester.pumpWidget(const SizedBox());+ await c.flush();+ c.dispose();+ },+ );++ testWidgets(+ 'losing the screen with the Swarm menu open gives the browser menu back',+ (tester) async {+ final told = <bool>[];+ BrowserMenuGuard.debugWeb = true;+ BrowserMenuGuard.debugSink = (off) async => told.add(off);+ addTearDown(BrowserMenuGuard.debugReset);+ final server = _RemovalServer();+ server.state['machines'] = [machine('owner')];+ final c = server.controller();+ await c.refresh();+ await mount(tester, c);+ await tester.tap(+ find.byKey(const ValueKey('super-machine-studio')),+ buttons: kSecondaryMouseButton,+ );+ await tester.pumpAndSettle();+ expect(BrowserMenuGuard.isOff, isTrue);+ // Sign-out or access lost: the workspace goes, Navigator and all.+ await tester.pumpWidget(const SizedBox());+ expect(BrowserMenuGuard.isOff, isFalse);+ expect(told.last, isFalse);+ await c.flush();+ c.dispose();+ },+ );+testWidgets('machine with a Product Manager cannot be removed', (tester,) async {diff --git a/desktop/test/super_tab_roster_test.dart b/desktop/test/super_tab_roster_test.dartindex 794eb776d..f278dbb8d 100644--- a/desktop/test/super_tab_roster_test.dart+++ b/desktop/test/super_tab_roster_test.dart@@ -15,6 +15,7 @@ import 'package:harness/super_tabs/agent_details.dart';import 'package:harness/super_tabs/model.dart';import 'package:harness/super_tabs/identity.dart';import 'package:harness/super_tabs/roster.dart';+import 'package:harness/widgets/browser_menu_guard.dart';import 'package:harness/widgets/engine_identity.dart';import 'package:harness/widgets/harness_activity_mark.dart';@@ -941,6 +942,25 @@ void main() {await f.close(tester);});+ testWidgets(+ 'in a browser, pointing at an agent row switches the browser menu off',+ (tester) async {+ final told = <bool>[];+ BrowserMenuGuard.debugWeb = true;+ BrowserMenuGuard.debugSink = (off) async => told.add(off);+ addTearDown(BrowserMenuGuard.debugReset);+ final f = await fixture(tester);+ await f.show(tester);+ final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);+ addTearDown(mouse.removePointer);+ await mouse.addPointer(location: const Offset(1, 1));+ await mouse.moveTo(tester.getCenter(f.row(0)));+ await tester.pump();+ expect(told, [true]);+ await f.close(tester);+ },+ );+testWidgets('project Product Manager cannot be removed from the roster', (tester,) async {diff --git a/desktop/test/web/release/machine_row_app.dart b/desktop/test/web/release/machine_row_app.dartnew file mode 100644index 000000000..2be90def2--- /dev/null+++ b/desktop/test/web/release/machine_row_app.dart@@ -0,0 +1,86 @@+// A release-build page holding the real Swarm view on made-up data, beside a real terminal. Driven in a real browser+// by scripts/web-machine-menu-check.mjs, which says how to build it. Never shipped: nothing else imports it.+import 'package:flutter/material.dart';+import 'package:harness/shared/theme/app_theme.dart' as grid;+import 'package:harness/super_tabs/view.dart';+import 'package:web/web.dart' as web;+import 'package:xterm/xterm.dart';++import '../../support/super_tab_fixture.dart';++class _Routes extends NavigatorObserver {+ @override+ void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) =>+ web.document.title = route is PopupRoute ? 'menu-open' : 'no-menu';+ @override+ void didPop(Route<dynamic> route, Route<dynamic>? previousRoute) =>+ web.document.title = 'no-menu';+}++/// Publishes where the keyed widgets are, for the script to point at them.+void _publish() {+ final rects = <String>[];+ void visit(Element element) {+ final key = element.widget.key;+ if (key is ValueKey<String> && key.value.startsWith('super-machine')) {+ final box = element.findRenderObject();+ if (box is RenderBox && box.hasSize) {+ final at = box.localToGlobal(Offset.zero);+ rects.add(+ '${key.value}=${at.dx},${at.dy},${box.size.width},${box.size.height}',+ );+ }+ }+ element.visitChildren(visit);+ }++ WidgetsBinding.instance.rootElement?.visitChildren(visit);+ web.document.body?.setAttribute('data-rects', rects.join(';'));+}++Future<void> main() async {+ WidgetsFlutterBinding.ensureInitialized();+ final server = ConversationServer();+ server.state['machines'] = [+ {+ 'machineId': 'studio',+ 'name': 'Studio',+ 'contributorId': 'owner',+ 'scope': 'all',+ 'engines': ['codex'],+ 'maxAgents': 2,+ 'availableSlots': 2,+ },+ ];+ final controller = server.controller();+ await controller.refresh();+ runApp(+ MaterialApp(+ theme: grid.buildAppTheme(brightness: Brightness.dark),+ navigatorObservers: [_Routes()],+ home: Scaffold(+ body: Row(+ children: [+ SizedBox(+ width: 1000,+ child: SuperTabView(+ controller: controller,+ onInvite: () {},+ onAddAgent: (_) {},+ onOpenTerminal: (_) {},+ machineName: (_) => 'Studio',+ ),+ ),+ Expanded(+ child: TerminalView(+ Terminal(),+ key: const ValueKey('super-machine-check-terminal'),+ ),+ ),+ ],+ ),+ ),+ ),+ );+ WidgetsBinding.instance.addPersistentFrameCallback((_) => _publish());+}diff --git a/docs/plans/2026-11-02-web-machine-row-menu-plan.md b/docs/plans/2026-11-02-web-machine-row-menu-plan.mdnew file mode 100644index 000000000..fc7fc8a2a--- /dev/null+++ b/docs/plans/2026-11-02-web-machine-row-menu-plan.md@@ -0,0 +1,19 @@+# Web: a ⋯ on machine rows, and a browser check of their right-click++**Goal:** a machine's Swarm menu opens on the web without depending on a right-click, and a real browser proves what+the right-click does on a release build.++**What the browser showed:** the deployed v1.3.88 bundle holds #2518's guard, and a release build of that code opens the+Swarm menu on a right-click, in the sidebar alone and in the full Swarm view. Huy's report did not reproduce here. What+did fail in the browser: a second right-click while the Swarm menu is open brings up the browser's menu. Reading the code+found the same gap on agent rows and in the Machines panel, which open menus of their own with no guard.++## Steps (test first)++1. Widget tests: ⋯ shows on pointing, opens the same menu with Desktop's permissions, is reached by Tab; the menu key+ opens it on the row; no ⋯ on a computer. Then `_MachineMore` on the row, in a browser only.+2. Widget tests: the browser menu stays off while the Swarm menu is open, and comes back on closing or when the screen+ goes with the menu up. Then a hold in `_menu`, released in `finally` and in `dispose`.+3. Widget tests: agent rows and Machines panel rows switch the browser menu off. Then `BrowserMenuOff` on both.+4. Browser check: `desktop/scripts/web-machine-menu-check.mjs` drives a release build of+ `test/web/release/machine_row_app.dart` in a real browser, on v1.3.88's code (red) and on this branch (green).