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
// Settings is a screen now, not a dialog — so what this guards is the shape a
// dialog never had: a rail you pick a section from, a pane that follows it, a
// filter over the rail, and a way back out.
//
// Deliberately never calls a mutating method on the real global
// `terminalFontStore` singleton: it persists through the real
// `HarnessFileStore` (the user's actual `~/.harness/desktop-app/state.json`).
// This only reads the store's untouched default.
import 'dart:async';
import 'dart:ui' show SemanticsAction, Tristate;
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:harness/auth/auth_session.dart';
import 'package:harness/core/config.dart';
import 'package:harness/settings/settings_screen.dart';
import 'package:harness/settings/settings_nav.dart';
import 'package:harness/settings/settings_section.dart';
import 'package:harness/settings/experimental_features.dart';
import 'package:harness/settings/sections/shortcuts_section.dart';
import 'package:harness/shared/theme/app_theme.dart';
import 'package:harness/shared/theme/app_icons.dart';
import 'package:harness/shared/layouts/widgets/sidebar_item.dart';
import 'package:harness/shortcuts/keyboard_practice.dart';
import 'package:harness/state/app_state.dart';
import 'package:harness/widgets/harness_customize_pane.dart';
import 'support/experimental_settings.dart';
import 'swarm_state_test.dart' show MemoryStore;
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
// The About section prints the running version.
PackageInfo.setMockInitialValues(
appName: 'Harness',
packageName: 'ai.autonomous.harness',
version: '1.0.0',
buildNumber: '1',
buildSignature: '',
);
/// Opens Settings over a bare host screen and settles the push transition.
Future<AppNotifier> openSettings(
WidgetTester tester, {
ExperimentalFeaturesStore? experiments,
}) async {
final notifier = AppNotifier(
config: AppConfig.dev,
authSession: AuthSession(),
configStore: null,
);
addTearDown(notifier.dispose);
// Wide enough that the rail and the pane both have room — the window's own
// minimum is 880.
tester.view.physicalSize = const Size(1100 * 2, 760 * 2);
tester.view.devicePixelRatio = 2;
addTearDown(tester.view.reset);
await tester.pumpWidget(
MaterialApp(
theme: buildAppTheme(brightness: Brightness.light),
home: Builder(
builder: (context) {
AppTheme.brightness.value = Brightness.light;
return const BrightnessScope(child: Placeholder());
},
),
),
);
unawaited(
showSettingsScreen(
tester.element(find.byType(Placeholder)),
notifier,
source: 'account_menu',
experimentalFeatures: experiments,
),
);
await tester.pumpAndSettle();
return notifier;
}
testWidgets(
'Settings is settings only: Account, then General, Agents, Labs and Help',
(tester) async {
await openSettings(tester);
// Settings opens on Account, alone at the top with no caption over it.
expect(find.text('Account'), findsNWidgets(2));
for (final caption in ['General', 'Agents', 'Labs', 'Help']) {
expect(find.text(caption), findsOneWidget, reason: caption);
}
expect(find.text('PREFERENCES'), findsNothing);
final rows = [
'Account',
'Appearance',
'Notifications',
'Keyboard shortcuts',
'Connectors',
'Usage',
'Tab invites',
'Experimental',
'About',
'Debug',
];
final tops = [
for (final label in rows)
tester
.getTopLeft(
find.descendant(
of: find.byType(SettingsNav),
matching: find.text(label),
),
)
.dy,
];
expect(tops, [...tops]..sort(), reason: 'in this order');
// What moved out: robots to the Devices tab, devices and profiles to Machines, and what
// agents may do to Experimental (the account's, owner 2026-10-12). The one
// "Agents" left is the caption, not a row.
expect(
find.descendant(
of: find.byType(SettingsNav),
matching: find.text('Agents'),
),
findsOneWidget,
);
for (final gone in [
'Customize',
'Your devices',
'Profiles',
if (!kIsWeb) 'Privacy',
'Autonomous robots',
]) {
expect(find.text(gone), findsNothing, reason: gone);
}
expect(find.text('Back to app'), findsOneWidget);
expect(find.text('Terminal'), findsNothing);
expect(find.byKey(const Key('appearance-ui-size-field')), findsNothing);
expect(
find.byKey(const Key('terminal-font-family-dropdown')),
findsNothing,
);
// Appearance (was Customize) opens the workspace's panel, which is called Appearance too.
await tester.tap(find.text('Appearance'));
await tester.pumpAndSettle();
expect(find.byType(SettingsScreen), findsNothing);
expect(find.byType(Placeholder), findsOneWidget);
expect(find.byType(HarnessCustomizePane), findsOneWidget);
expect(
find.descendant(
of: find.byType(HarnessCustomizePane),
matching: find.text('Appearance'),
),
findsOneWidget,
reason: 'its title, and no tab of the same name under it',
);
expect(find.text('Customize Harness'), findsNothing);
for (final label in ['Status', 'Workspace', 'Terminal']) {
expect(find.text(label), findsOneWidget);
}
await tester.tap(find.byKey(const ValueKey('customize-appearance')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('appearance-ui-size-field')), findsNothing);
// Four tabs scroll at this window width; bring Terminal into view first.
final terminalTab = find.byKey(const ValueKey('customize-terminal'));
await tester.ensureVisible(terminalTab);
await tester.tap(terminalTab);
await tester.pumpAndSettle();
expect(
find.byKey(const Key('terminal-font-family-dropdown')),
findsOneWidget,
);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
expect(find.byType(SettingsScreen), findsNothing);
expect(find.byType(HarnessCustomizePane), findsNothing);
expect(tester.takeException(), isNull);
},
);
testWidgets('settings navigation announces and changes its selected section', (
tester,
) async {
final semantics = tester.ensureSemantics();
try {
await openSettings(tester);
Finder row(String label) => find.descendant(
of: find.byType(SettingsNav),
matching: find.widgetWithText(InkWell, label),
);
final account = tester.getSemantics(row('Account'));
final usage = tester.getSemantics(row('Usage'));
expect(account.getSemanticsData().flagsCollection.isButton, isTrue);
expect(
account.getSemanticsData().flagsCollection.isSelected,
Tristate.isTrue,
);
expect(
usage.getSemanticsData().flagsCollection.isSelected,
Tristate.isFalse,
);
expect(usage.getSemanticsData().hasAction(SemanticsAction.tap), isTrue);
// Assistive activation must take the same route as pointer/keyboard use.
tester
.renderObject(row('Usage'))
.owner!
.semanticsOwner!
.performAction(usage.id, SemanticsAction.tap);
await tester.pumpAndSettle();
expect(
tester.widget<SettingsNav>(find.byType(SettingsNav)).section,
SettingsSection.usage,
);
expect(
tester
.getSemantics(row('Usage'))
.getSemanticsData()
.flagsCollection
.isSelected,
Tristate.isTrue,
);
expect(
tester
.getSemantics(row('Account'))
.getSemanticsData()
.flagsCollection
.isSelected,
Tristate.isFalse,
);
} finally {
semantics.dispose();
}
});
testWidgets('shared sidebar semantics keep secondary actions independent', (
tester,
) async {
final semantics = tester.ensureSemantics();
try {
var opened = 0;
var closed = 0;
await tester.pumpWidget(
MaterialApp(
theme: buildAppTheme(brightness: Brightness.light),
home: Scaffold(
body: SizedBox(
width: 260,
child: Column(
children: [
SidebarItem(
label: 'Workspace',
selected: true,
onTap: () => opened++,
trailingAlwaysVisible: true,
trailing: IconButton(
tooltip: 'Close workspace',
onPressed: () => closed++,
icon: const Icon(AppIcons.close),
),
),
SidebarItem(
label: 'Unavailable workspace',
enabled: false,
onTap: () => fail('Disabled rows must not activate'),
),
],
),
),
),
),
);
await tester.pumpAndSettle();
final primary = tester.getSemantics(find.text('Workspace'));
final secondary = tester.getSemantics(find.byTooltip('Close workspace'));
final disabled = tester.getSemantics(find.text('Unavailable workspace'));
expect(primary.getSemanticsData().flagsCollection.isButton, isTrue);
expect(
primary.getSemanticsData().flagsCollection.isSelected,
Tristate.isTrue,
);
expect(secondary.id, isNot(primary.id));
expect(secondary.getSemanticsData().flagsCollection.isButton, isTrue);
expect(
disabled.getSemanticsData().flagsCollection.isEnabled,
Tristate.isFalse,
);
expect(
disabled.getSemanticsData().hasAction(SemanticsAction.tap),
isFalse,
);
final owner = tester
.renderObject(find.text('Workspace'))
.owner!
.semanticsOwner!;
owner.performAction(secondary.id, SemanticsAction.tap);
await tester.pump();
expect(closed, 1);
expect(opened, 0);
owner.performAction(primary.id, SemanticsAction.tap);
await tester.pump();
expect(opened, 1);
expect(closed, 1);
} finally {
semantics.dispose();
}
});
testWidgets('About prints the running version', (tester) async {
await openSettings(tester);
await tester.tap(find.text('About'));
await tester.pumpAndSettle();
// The version the account menu used to carry. It reads the same
// runningAppVersion() a release does — on Linux that means version.txt
// beside the executable first, then package metadata (mocked above), which
// is why this passes on either build host.
//
// The number, not a "Version" label: this branch draws About as one card
// where the version sits beside the update pill, so the label main's row
// had is gone. `about_section_test.dart` owns that shape; what this test
// owes is that the pane prints the running version at all.
expect(find.text('1.0.0'), findsOneWidget);
});
testWidgets(
'Experimental is searchable and its labelled switch works by keyboard',
(tester) async {
final storage = MemoryStore();
final experiments = MemoryExperimentalFeaturesStore(storage: storage);
addTearDown(experiments.dispose);
await openSettings(tester, experiments: experiments);
await tester.enterText(
find.byKey(const Key('settings-search-field')),
'experimental',
);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
final toggle = find.byKey(
const ValueKey('experimental-focus_bar_creature'),
);
expect(tester.widget<Switch>(toggle).value, isFalse);
final semantics = tester.ensureSemantics();
expect(
tester.getSemantics(toggle),
matchesSemantics(
label: 'Focus-bar creature',
hasToggledState: true,
hasEnabledState: true,
isEnabled: true,
isFocusable: true,
hasTapAction: true,
hasFocusAction: true,
),
);
semantics.dispose();
// Search → matching nav row → creature: usage sharing is a row further down, below Mark pull requests.
await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.space);
await tester.pumpAndSettle();
expect(tester.widget<Switch>(toggle).value, isTrue);
expect(
storage.values[experimentFixtureKey(
ExperimentalFeature.focusBarCreature,
)],
'on',
);
await tester.sendKeyEvent(LogicalKeyboardKey.space);
await tester.pumpAndSettle();
expect(tester.widget<Switch>(toggle).value, isFalse);
expect(
storage.values[experimentFixtureKey(
ExperimentalFeature.focusBarCreature,
)],
'off',
);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
expect(find.byType(SettingsScreen), findsNothing);
expect(tester.takeException(), isNull);
},
);
testWidgets('the rail filter narrows to matching rows, and says so when '
'nothing matches', (tester) async {
await openSettings(tester);
await tester.enterText(
find.byKey(const Key('settings-search-field')),
'key',
);
await tester.pumpAndSettle();
expect(find.text('Keyboard shortcuts'), findsOneWidget);
// Filtering the rail preserves the open pane.
expect(find.text('Account'), findsOneWidget);
expect(find.text('Terminal'), findsNothing);
// Its run's caption stays over it; the runs with no match go.
expect(find.text('General'), findsOneWidget);
expect(find.text('Agents'), findsNothing);
// Appearance by what its panel holds, and by its old name.
for (final query in ['wallpaper', 'customize']) {
await tester.enterText(
find.byKey(const Key('settings-search-field')),
query,
);
await tester.pumpAndSettle();
expect(
find.descendant(
of: find.byType(SettingsNav),
matching: find.text('Appearance'),
),
findsOneWidget,
reason: query,
);
expect(find.text('Keyboard shortcuts'), findsNothing, reason: query);
}
await tester.enterText(
find.byKey(const Key('settings-search-field')),
'zzz',
);
await tester.pumpAndSettle();
expect(find.text('No settings match'), findsOneWidget);
});
testWidgets('Back to app leaves Settings', (tester) async {
await openSettings(tester);
await tester.tap(find.text('Back to app'));
await tester.pumpAndSettle();
expect(find.text('Back to app'), findsNothing);
expect(find.text('Appearance'), findsNothing);
expect(find.byType(Placeholder), findsOneWidget);
});
testWidgets(
'Settings opens ready to type, Enter selects a match and Escape returns',
(tester) async {
await openSettings(tester);
final field = find.byKey(const Key('settings-search-field'));
expect(
tester.widget<TextField>(field).focusNode!.hasPrimaryFocus,
isTrue,
);
final initial = tester
.widget<SettingsNav>(find.byType(SettingsNav))
.section;
await tester.enterText(field, 'keyboard');
await tester.pumpAndSettle();
expect(
tester.widget<SettingsNav>(find.byType(SettingsNav)).section,
initial,
);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
expect(
tester.widget<SettingsNav>(find.byType(SettingsNav)).section,
SettingsSection.shortcuts,
);
expect(
tester.widget<TextField>(field).focusNode!.hasPrimaryFocus,
isTrue,
);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
expect(find.byType(SettingsScreen), findsNothing);
expect(find.byType(Placeholder), findsOneWidget);
},
);
testWidgets(
'an empty or unmatched settings query does not change the section',
(tester) async {
await openSettings(tester);
final field = find.byKey(const Key('settings-search-field'));
final initial = tester
.widget<SettingsNav>(find.byType(SettingsNav))
.section;
for (final text in ['', 'nothing-matches-this']) {
await tester.enterText(field, text);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
expect(
tester.widget<SettingsNav>(find.byType(SettingsNav)).section,
initial,
);
expect(
tester.widget<TextField>(field).focusNode!.hasPrimaryFocus,
isTrue,
);
}
await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
expect(
tester.widget<TextField>(field).focusNode!.hasPrimaryFocus,
isTrue,
);
},
);
testWidgets('Down enters the matching section row and Enter opens it', (
tester,
) async {
await openSettings(tester);
final field = find.byKey(const Key('settings-search-field'));
await tester.enterText(field, 'about');
await tester.pumpAndSettle();
await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
await tester.pump();
expect(tester.widget<TextField>(field).focusNode!.hasPrimaryFocus, isFalse);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
expect(
tester.widget<SettingsNav>(find.byType(SettingsNav)).section,
SettingsSection.about,
);
});
testWidgets(
'shortcut help can be searched, paged and practiced by keyboard',
(tester) async {
await openSettings(tester);
await tester.enterText(
find.byKey(const Key('settings-search-field')),
'keyboard',
);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
final search = find.byKey(const ValueKey('shortcuts-search'));
for (
var i = 0;
i < 4 && !tester.widget<TextField>(search).focusNode!.hasFocus;
i++
) {
await tester.sendKeyEvent(LogicalKeyboardKey.tab);
await tester.pump();
}
expect(tester.widget<TextField>(search).focusNode!.hasFocus, isTrue);
final scroll = tester.state<ScrollableState>(
find
.descendant(
of: find.byType(ShortcutsSection),
matching: find.byType(Scrollable),
)
.last,
);
await tester.sendKeyEvent(LogicalKeyboardKey.pageDown);
await tester.pumpAndSettle();
expect(scroll.position.pixels, greaterThan(0));
await tester.sendKeyEvent(LogicalKeyboardKey.pageUp);
await tester.pumpAndSettle();
await tester.enterText(search, 'Clone');
await tester.pump();
expect(find.text('Clone Harness'), findsOneWidget);
await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.pumpAndSettle();
expect(find.byType(KeyboardPractice), findsOneWidget);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
expect(find.byType(SettingsScreen), findsOneWidget);
expect(tester.widget<TextField>(search).focusNode!.hasFocus, isTrue);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
expect(find.byType(SettingsScreen), findsNothing);
expect(tester.takeException(), isNull);
},
);
testWidgets('Escape belongs to composition before it can leave Settings', (
tester,
) async {
await openSettings(tester);
final field = find.byKey(const Key('settings-search-field'));
tester.testTextInput.updateEditingValue(
const TextEditingValue(
text: 'keyboard',
selection: TextSelection.collapsed(offset: 8),
composing: TextRange(start: 0, end: 8),
),
);
await tester.pump();
final section = tester
.widget<SettingsNav>(find.byType(SettingsNav))
.section;
await tester.sendKeyEvent(LogicalKeyboardKey.enter);
await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
await tester.pump();
expect(
tester.widget<SettingsNav>(find.byType(SettingsNav)).section,
section,
);
expect(tester.widget<TextField>(field).focusNode!.hasPrimaryFocus, isTrue);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
expect(find.byType(SettingsScreen), findsOneWidget);
expect(tester.widget<TextField>(field).focusNode!.hasPrimaryFocus, isTrue);
tester.testTextInput.updateEditingValue(
const TextEditingValue(
text: 'keyboard',
selection: TextSelection.collapsed(offset: 8),
),
);
await tester.pump();
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
expect(find.byType(SettingsScreen), findsNothing);
});
}