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
feat: polish native orchestrator viewers input notices and large project status
Deeb84e336fa983
diff --git a/cli/src/authCommand.spec.ts b/cli/src/authCommand.spec.tsindex 48bd1db33..63bb9ec9d 100644--- a/cli/src/authCommand.spec.ts+++ b/cli/src/authCommand.spec.ts@@ -49,6 +49,10 @@ function envFor(root: string, backendUrl?: string): NodeJS.ProcessEnv {HOME: root,HARNESS_AUTH_DIR: join(root, 'auth'),ADAPTER_DATA_DIR: join(root, 'data'),+ ADAPTER_RUNTIME_DIR: join(root, 'runtime'),+ // These tests assert the no-grid handoff. A developer's installed grid+ // must not turn this local auth fixture into a real network login attempt.+ HARNESS_GRID_BIN: join(root, 'grid-not-installed'),ADAPTER_CLI_DIR: join(root, 'cli'),ADAPTER_COMPUTER_ID_FILE: join(root, 'computer-id'),ADAPTER_UPDATE_DISABLE: 'true',diff --git a/cli/src/orchestrator/command.spec.ts b/cli/src/orchestrator/command.spec.tsnew file mode 100644index 000000000..8a0dd74ed--- /dev/null+++ b/cli/src/orchestrator/command.spec.ts@@ -0,0 +1,24 @@+import { describe, expect, it } from 'vitest'+import { summarizeOrchestratorReply, parseOrchestratorArgs } from './command.js'++describe('orchestrator tool output', () => {+ it('keeps large projects readable without discarding worker results or mutating UI state', () => {+ const reply = { project: {+ id: 'a'.repeat(32), state: 'active', fingerprint: 'private-request-hash',+ tasks: [{ id: 'shape', prompt: 'long brief'.repeat(2000), summary: 'Verified', artifacts: [{ path: 'shape.step', sha256: 'a'.repeat(64) }] }],+ messages: Array.from({ length: 200 }, (_, i) => ({ id: String(i), text: 'long conversation'.repeat(1500), delivery: 'started' })),+ } }+ const output = summarizeOrchestratorReply(reply)+ expect(JSON.stringify(output).length).toBeLessThan(8000)+ expect(output).toMatchObject({ project: { tasks: [{ id: 'shape', summary: 'Verified', artifacts: [{ path: 'shape.step' }] }] } })+ expect(reply.project.messages).toHaveLength(200)+ expect(reply.project.tasks[0].prompt.length).toBeGreaterThan(10000)+ })+ it('keeps coded refusals unchanged and parses scoped steering receipts', () => {+ const error = { error: 'TASK_INACTIVE', detail: 'Add a revision task.' }+ expect(summarizeOrchestratorReply(error)).toBe(error)+ expect(parseOrchestratorArgs(['--port', '1234', '--machine', 'fixture', 'steer', 'a'.repeat(32), 'shape', '2', 'Use millimeters', 'b'.repeat(32)]).payload).toMatchObject({+ action: 'steer', taskId: 'shape', attempt: 2, text: 'Use millimeters', messageId: 'b'.repeat(32),+ })+ })+})diff --git a/cli/src/orchestrator/command.ts b/cli/src/orchestrator/command.tsindex 8af5fe9fd..eb8f8ccbb 100644--- a/cli/src/orchestrator/command.ts+++ b/cli/src/orchestrator/command.ts@@ -57,10 +57,25 @@ export async function orchestratorCommand(argv: readonly string[]): Promise<numbtry {const { port, machineId, payload } = parseOrchestratorArgs(argv)const reply = await localOrchestratorRequest(port, machineId, payload)- console.log(JSON.stringify(reply, null, 2))+ console.log(JSON.stringify(summarizeOrchestratorReply(reply), null, 2))return reply.error ? 1 : 0} catch (error) {console.error(error instanceof Error ? error.message : 'Orchestrator request failed.')return 1}}++/** Tool output is a work ledger, not a repeated copy of the director's whole+ * conversation and every specialist brief. The UI still receives full state. */+export function summarizeOrchestratorReply(reply: Record<string, unknown>): Record<string, unknown> {+ if (!reply.project || typeof reply.project !== 'object' || Array.isArray(reply.project)) return reply+ const { fingerprint: _fingerprint, messages, tasks, ...project } = reply.project as Record<string, unknown>+ return { ...reply, project: {+ ...project,+ tasks: Array.isArray(tasks) ? tasks.map(({ prompt: _prompt, ...task }) => task) : [],+ deliveries: Array.isArray(messages) ? messages.filter(m => m.delivery).slice(-20).map(m => ({+ id: m.id, targetAgentId: m.targetAgentId, delivery: m.delivery,+ deliveryReason: m.deliveryReason, text: String(m.text).slice(0, 160),+ })) : [],+ } }+}diff --git a/cli/src/orchestrator/service.ts b/cli/src/orchestrator/service.tsindex 6f0e394fc..09935a8a7 100644--- a/cli/src/orchestrator/service.ts+++ b/cli/src/orchestrator/service.ts@@ -118,10 +118,11 @@ export class OrchestratorService {// A recovered project continues queued work only when it is requested again.this.pump(run)this.dispatchPending(run)+ const viewerHarnesses = new Set(this.catalog().filter(h => h.viewer).map(h => h.id))return {...structuredClone(run),directorAvailable: !!run.directorId && this.deps.agent(run.directorId) !== null,- tasks: run.tasks.map(t => ({ ...structuredClone(t), hasViewer: this.catalog().some(h => h.id === t.harness && h.viewer), runtime: t.agentId ? this.deps.agent(t.agentId) : null })),+ tasks: run.tasks.map(t => ({ ...structuredClone(t), hasViewer: viewerHarnesses.has(t.harness), runtime: t.agentId ? this.deps.agent(t.agentId) : null })),}}diff --git a/desktop/integration_test/orchestrator_native_viewers_test.dart b/desktop/integration_test/orchestrator_native_viewers_test.dartnew file mode 100644index 000000000..707420ac4--- /dev/null+++ b/desktop/integration_test/orchestrator_native_viewers_test.dart@@ -0,0 +1,143 @@+import 'dart:io';++import 'package:flutter/material.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:integration_test/integration_test.dart';+import 'package:webview_flutter/webview_flutter.dart';++import 'package:harness/auth/auth_session.dart';+import 'package:harness/core/config.dart';+import 'package:harness/core/local_key_value_store.dart';+import 'package:harness/orchestrator/orchestrator_controller.dart';+import 'package:harness/orchestrator/orchestrator_workspace.dart';+import 'package:harness/shared/theme/app_theme.dart' as grid;+import 'package:harness/state/app_state.dart';+import 'package:harness/widgets/terminal_panel.dart';+import 'package:harness/widgets/web_pane_panel.dart';++class _MemoryStore implements LocalKeyValueStore {+ final data = <String, String>{};+ @override+ Future<String?> read(String key) async => data[key];+ @override+ Future<void> write(String key, String value) async {+ data[key] = value;+ }++ @override+ Future<void> delete(String key) async {+ data.remove(key);+ }+}++void main() {+ IntegrationTestWidgetsFlutterBinding.ensureInitialized();+ testWidgets('real WKWebViews arrive without replacing the director draft', (+ tester,+ ) async {+ // This test must fail, not quietly exercise URL placeholders, if native+ // webviews are unavailable. The regular widget suite covers the fallback.+ expect(WebPanePanel.webviewAvailable, isTrue);+ await tester.binding.setSurfaceSize(const Size(1280, 900));+ addTearDown(() => tester.binding.setSurfaceSize(null));+ final server = await HttpServer.bind(InternetAddress.loopbackIPv4, 0);+ final visited = <String>{};+ server.listen((request) async {+ final path = request.uri.path;+ visited.add(path);+ request.response.headers.contentType = ContentType.html;+ request.response.write(+ '<!doctype html><body style="background:#172022;color:#e4f6ef;font:24px sans-serif"><h1>Live $path viewer</h1><p>Verified local fixture</p></body>',+ );+ await request.response.close();+ });+ addTearDown(() => server.close(force: true));+ final app = AppNotifier(+ config: AppConfig.dev,+ authSession: AuthSession(storage: _MemoryStore()),+ );+ addTearDown(app.dispose);+ const id = '77777777777777777777777777777777';+ final tasks = <Map<String, dynamic>>[];+ var revision = 0;+ final controller = OrchestratorController(+ id: id,+ request: (_) async => {+ 'project': {+ 'id': id,+ 'revision': ++revision,+ 'state': 'active',+ 'directorId': 'fixture-director',+ 'directorAvailable': true,+ 'tasks': List<Map<String, dynamic>>.of(tasks),+ 'messages': [+ {+ 'id': 'first',+ 'role': 'assistant',+ 'text': 'I’m coordinating the specialists.',+ },+ ],+ },+ },+ );+ addTearDown(controller.dispose);+ await tester.pumpWidget(+ MaterialApp(+ theme: grid.buildAppTheme(brightness: Brightness.dark),+ home: Scaffold(+ body: OrchestratorWorkspace(+ notifier: app,+ machineId: 'fixture',+ projectId: id,+ controller: controller,+ ),+ ),+ ),+ );+ await tester.pump();+ final composer = find.byKey(const ValueKey('orchestrator-composer'));+ await tester.tap(composer);+ // Native integration bindings do not register a fake text-input channel.+ tester.widget<TextField>(composer).controller!.text =+ 'Keep the base slimmer';+ for (final name in ['shape', 'scene', 'film']) {+ tasks.add({+ 'id': name,+ 'title': name,+ 'harness': 'fixture/$name',+ 'state': 'running',+ 'attempt': 1,+ 'agentId': 'fixture-$name',+ 'hasViewer': true,+ 'runtime': {+ 'viewerUrl': 'http://127.0.0.1:${server.port}/$name',+ 'viewerName': name,+ },+ });+ await controller.refresh();+ await tester.pump(const Duration(milliseconds: 100));+ }+ final deadline = DateTime.now().add(const Duration(seconds: 30));+ while (visited.length < 3 && DateTime.now().isBefore(deadline)) {+ await tester.pump(const Duration(milliseconds: 100));+ }+ expect(visited, containsAll(['/shape', '/scene', '/film']));+ expect(find.byType(WebViewWidget), findsNWidgets(3));+ for (final view in tester.widgetList<WebViewWidget>(+ find.byType(WebViewWidget),+ )) {+ final text = await view.platform.params.controller+ .runJavaScriptReturningResult('document.body.innerText')+ .timeout(const Duration(seconds: 10));+ expect(text.toString(), contains('Verified local fixture'));+ }+ expect(+ tester.widget<TextField>(composer).controller!.text,+ 'Keep the base slimmer',+ );+ expect(tester.widget<TextField>(composer).focusNode!.hasFocus, isTrue);+ expect(find.byType(TerminalPanel), findsNothing);+ expect(tester.takeException(), isNull);+ await tester.pumpWidget(const SizedBox());+ });+}diff --git a/desktop/lib/orchestrator/orchestrator_workspace.dart b/desktop/lib/orchestrator/orchestrator_workspace.dartindex 4e9476f20..f2051c433 100644--- a/desktop/lib/orchestrator/orchestrator_workspace.dart+++ b/desktop/lib/orchestrator/orchestrator_workspace.dart@@ -42,9 +42,14 @@ class _OrchestratorWorkspaceState extends State<OrchestratorWorkspace> {void initState() {super.initState();model.addListener(_changed);+ widget.notifier.addListener(_attentionChanged);model.watch();}+ void _attentionChanged() {+ if (mounted) setState(() {});+ }+void _changed() {if (!mounted) return;final follow =@@ -63,6 +68,7 @@ class _OrchestratorWorkspaceState extends State<OrchestratorWorkspace> {@overridevoid dispose() {model.removeListener(_changed);+ widget.notifier.removeListener(_attentionChanged);model.unwatch();_composer.dispose();_composerFocus.dispose();@@ -268,6 +274,9 @@ class _OrchestratorWorkspaceState extends State<OrchestratorWorkspace> {Widget _task(OrchestratorTask task) {final paneKey = '${task.id}/${task.attempt}';+ final question = task.agentId == null+ ? null+ : widget.notifier.questionFor(widget.machineId, task.agentId!);Widget content;final viewerUrl = task.viewerUrl;final uri = viewerUrl == null ? null : Uri.tryParse(viewerUrl);@@ -356,11 +365,11 @@ class _OrchestratorWorkspaceState extends State<OrchestratorWorkspace> {overflow: TextOverflow.ellipsis,),Text(- '${task.harness} · ${task.state}${task.attempt > 1 ? ' · attempt ${task.attempt}' : ''}',+ '${task.harness} · ${question != null ? 'needs input' : task.state}${task.attempt > 1 ? ' · attempt ${task.attempt}' : ''}',maxLines: 1,overflow: TextOverflow.ellipsis,style: TextStyle(- color: task.error == null+ color: task.error == null && question == null? grid.AppPalette.textSecondary: grid.AppPalette.warn,fontSize: 12,@@ -392,6 +401,16 @@ class _OrchestratorWorkspaceState extends State<OrchestratorWorkspace> {],),),+ if (question != null)+ Padding(+ padding: const EdgeInsets.fromLTRB(12, 0, 12, 8),+ child: Text(+ 'Needs your input: ${question.prompt}\nUse Inspect to answer in the original agent.',+ maxLines: 3,+ overflow: TextOverflow.ellipsis,+ style: TextStyle(color: grid.AppPalette.warn),+ ),+ ),if (safeViewer && task.error != null)Padding(padding: const EdgeInsets.fromLTRB(12, 0, 12, 8),@@ -424,6 +443,16 @@ class _OrchestratorWorkspaceState extends State<OrchestratorWorkspace> {),),const Divider(height: 1),+ if (model.directorId != null &&+ widget.notifier.questionFor(widget.machineId, model.directorId!) !=+ null)+ Padding(+ padding: const EdgeInsets.fromLTRB(18, 10, 18, 0),+ child: Text(+ 'The director needs your input. Use Inspect director to answer.',+ style: TextStyle(color: grid.AppPalette.warn),+ ),+ ),Expanded(child: SelectionArea(child: ListView.builder(diff --git a/desktop/macos/Runner/HarnessKeymap.swift b/desktop/macos/Runner/HarnessKeymap.swiftindex ff92eb18e..7791abadc 100644--- a/desktop/macos/Runner/HarnessKeymap.swift+++ b/desktop/macos/Runner/HarnessKeymap.swift@@ -1,4 +1,5 @@import Cocoa+import WebKit/// Canonical logical strokes match Dart's KeyStroke. No QWERTY letter table:/// AppKit translates the event through the current keyboard layout.@@ -173,6 +174,14 @@ final class HarnessNativeKeymap {bindings[context]?.first(where: { $0.command == command })?.hint}+ // WKWebView is a native responder, so it does not forward this app action+ // through Flutter's keyboard dispatcher. Respect the resolved user binding,+ // including remapping/unbinding, instead of hard-coding Command-P in AppKit.+ func viewerOrchestratorCommand(_ stroke: HarnessKeyStroke) -> String? {+ let command = match([stroke], context: "workspace").binding?.command+ return command == "project.orchestrate" ? command : nil+ }+/// Only explicitly identified Harness rows change. AppKit's Edit, Window,/// Services and font-size commands retain their native ownership.func applyMenuKeys(to menu: NSMenu, context: String) {@@ -202,6 +211,8 @@ final class HarnessKeymapMenu: NSMenu {static let actionPrefix = "harness.keymap."weak var ownerWindow: NSWindow?private var inputStrokes: Set<HarnessKeyStroke> = []+ private var keymap: HarnessNativeKeymap?+ var dispatchViewerCommand: ((String) -> Bool)?static func replacing(_ previous: NSMenu) -> HarnessKeymapMenu {let menu = HarnessKeymapMenu(title: previous.title)@@ -217,6 +228,7 @@ final class HarnessKeymapMenu: NSMenu {}func update(_ map: HarnessNativeKeymap, window: NSWindow) {+ keymap = mapownerWindow = windowinputStrokes = Set(map.bindings.values.flatMap { $0.compactMap { $0.keys.first } })}@@ -228,6 +240,19 @@ final class HarnessKeymapMenu: NSMenu {}override func performKeyEquivalent(with event: NSEvent) -> Bool {+ if let ownerWindow, (event.window ?? NSApp.keyWindow) === ownerWindow,+ let stroke = HarnessKeyStroke.fromEvent(event),+ let command = keymap?.viewerOrchestratorCommand(stroke) {+ var responder = ownerWindow.firstResponder as? NSView+ while let view = responder {+ if view is WKWebView {+ if event.isARepeat { return true }+ if dispatchViewerCommand?(command) == true { return true }+ break+ }+ responder = view.superview+ }+ }if defersToInput(event) { return false }return super.performKeyEquivalent(with: event)}diff --git a/desktop/macos/Runner/SwarmTitlebar.swift b/desktop/macos/Runner/SwarmTitlebar.swiftindex 300603350..0512c3a7b 100644--- a/desktop/macos/Runner/SwarmTitlebar.swift+++ b/desktop/macos/Runner/SwarmTitlebar.swift@@ -139,6 +139,11 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {let menu = main as? HarnessKeymapMenu ?? HarnessKeymapMenu.replacing(main)if NSApp.mainMenu !== menu { NSApp.mainMenu = menu }menu.update(map, window: window)+ menu.dispatchViewerCommand = { [weak self] command in+ guard let self, self.actionsEnabled else { return false }+ self.channel.invokeMethod("keymapCommand", arguments: ["command": command])+ return true+ }}syncMenuKeys()}diff --git a/desktop/test/orchestrator_test.dart b/desktop/test/orchestrator_test.dartindex e745005cb..581c517c2 100644--- a/desktop/test/orchestrator_test.dart+++ b/desktop/test/orchestrator_test.dart@@ -7,6 +7,7 @@ import 'package:harness/orchestrator/orchestrator_controller.dart';import 'package:harness/orchestrator/orchestrator_launcher.dart';import 'package:harness/orchestrator/orchestrator_workspace.dart';import 'package:harness/shortcuts/app_shortcuts.dart';+import 'package:harness/state/pending_question.dart';import 'package:harness/widgets/terminal_panel.dart';import 'package:harness/widgets/web_pane_panel.dart';import 'package:harness/ws/ws_conn.dart';@@ -236,6 +237,27 @@ void main() {expect(find.byType(WebPanePanel), findsNWidgets(2));expect(app.panes, isEmpty);expect(tester.takeException(), isNull);+ app.machineStates['m']!.blockedAgents['agent-cad'] = PendingQuestion(+ machineId: 'm',+ agentId: 'agent-cad',+ requestId: 'approval',+ answerKey: 'Continue?',+ prompt: 'Which material should I use?',+ options: const ['Wood', 'Metal'],+ multi: false,+ since: DateTime.now(),+ );+ app.notifyListeners();+ await tester.pump();+ expect(+ find.textContaining('Needs your input: Which material'),+ findsOneWidget,+ );+ expect(tester.widget<TextField>(composer).focusNode!.hasFocus, isTrue);+ app.machineStates['m']!.blockedAgents.clear();+ app.notifyListeners();+ await tester.pump();+ expect(find.textContaining('Needs your input:'), findsNothing);await tester.sendKeyEvent(LogicalKeyboardKey.enter);await tester.pump();expect(diff --git a/desktop/tool/keymap_native_checks.swift b/desktop/tool/keymap_native_checks.swiftindex dfbb036c2..98029c555 100644--- a/desktop/tool/keymap_native_checks.swift+++ b/desktop/tool/keymap_native_checks.swift@@ -17,6 +17,7 @@ for (key, command) in [("cmd+s", "pane.layout"), ("cmd+r", "pane.split_right"),("cmd+d", "pane.split_down"),("cmd+b", "task.route"), ("cmd+t", "swarm.new"),+ ("cmd+p", "project.orchestrate"),("cmd+o", "agent.add"), ("cmd+n", "agent.new"),("cmd+h", "pane.focus_left"), ("cmd+j", "pane.focus_below"),("cmd+k", "pane.focus_above"), ("cmd+l", "pane.focus_right"),@@ -24,6 +25,12 @@ for (key, command) in [try checkKeymap(defaults.match([stroke(key)], context: "workspace").binding?.command == command,"Preserve the current default for \(key)")}+try checkKeymap(defaults.viewerOrchestratorCommand(stroke("cmd+p")) == "project.orchestrate",+ "A focused native viewer can open the orchestrator")+try checkKeymap(defaults.viewerOrchestratorCommand(stroke("cmd+b")) == nil,+ "The viewer bridge does not change single-agent routing")+try checkKeymap(defaults.viewerOrchestratorCommand(stroke("cmd+shift+p")) == nil,+ "The viewer bridge does not take the command palette chord")for context in ["workspace", "terminal", "picker"] {try checkKeymap(defaults.match([stroke("cmd+shift+n")], context: context).binding == nil,"Shift-Command-N is unbound by default in \(context)")@@ -117,6 +124,12 @@ func payload(_ rows: [[String: Any]]) -> [String: Any] {["version": 1, "contexts": ["workspace": rows, "terminal": rows, "picker": rows]]}let prefix: [String: Any] = ["keys": ["cmd+k"], "command": "example", "hint": "⌘K", "repeatable": false]+let remappedOrchestrator = HarnessNativeKeymap(payload([+ ["keys": ["cmd+y"], "command": "project.orchestrate", "hint": "⌘Y", "repeatable": false],+]))!+try checkKeymap(remappedOrchestrator.viewerOrchestratorCommand(stroke("cmd+p")) == nil &&+ remappedOrchestrator.viewerOrchestratorCommand(stroke("cmd+y")) == "project.orchestrate",+ "Native viewers respect an orchestrator shortcut remap")let sequence: [String: Any] = ["keys": ["cmd+k", "cmd+n"], "command": "example", "hint": "⌘K ⌘N", "repeatable": false]try checkKeymap(HarnessNativeKeymap(payload([prefix, sequence])) == nil, "Reject ambiguous prefixes atomically")try checkKeymap(HarnessNativeKeymap(payload([prefix, prefix])) == nil, "Reject duplicate strokes atomically")diff --git a/desktop/tool/swarm_titlebar_checks.swift b/desktop/tool/swarm_titlebar_checks.swiftindex 440d2f4db..d1fae3978 100644--- a/desktop/tool/swarm_titlebar_checks.swift+++ b/desktop/tool/swarm_titlebar_checks.swift@@ -610,10 +610,7 @@ private extension SwarmTitlebar {canClosePane = truetry checkTitlebar(validateMenuItem(closePane), "Remove Agent is enabled for a focused pane")let create = agent.items.first(where: { $0.representedObject as? String == "new" })!- canCreateSwarm = false- try checkTitlebar(!validateMenuItem(create), "Native New Swarm respects the tab capacity")- canCreateSwarm = true- try checkTitlebar(validateMenuItem(create), "Native New Swarm returns below capacity")+ try checkTitlebar(validateMenuItem(create), "Native New Tab remains available without the retired tab capacity")let machineRows: [[String: Any]] = [["id": "office", "name": "iMac – Office", "status": "Online", "local": true, "agentCount": 2,"agents": [["id": "one", "title": "App work", "engine": "codex", "canOpen": true],@@ -679,11 +676,12 @@ private extension SwarmTitlebar {try checkTitlebar(!validateMenuItem(destinations[0]) && !validateMenuItem(agentItems[0]) &&machineMenu.item(withTitle: "No Machines Linked")?.isEnabled == false,"Unlinking computers clears destinations and invalidates stale actions")- let recentRows: [[String: Any]] = (0..<20).map { index -> [String: Any] in+ var recentRows: [[String: Any]] = (0..<20).map { index -> [String: Any] in["id": "agent:\(index)", "title": "Agent \(index) — Machine","detail": "Project \(index)", "machineName": "M2", "current": index == 0,"engine": index == 0 ? "claude" : "codex"]- } + [["id": "swarm:recent", "title": "Recent Swarm", "swarm": true]]+ }+ recentRows.append(["id": "swarm:recent", "title": "Recent Swarm", "swarm": true])let closedRows: [[String: Any]] = (0..<14).map {["id": "closed-\($0)", "title": "Closed Swarm \($0)", "detail": "3 agents", "swarm": true, "canReopen": true]}