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
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:harness/app_shell.dart';
import 'package:harness/shared/theme/app_theme.dart' as grid;
import 'package:harness/shared/theme/appearance_prefs_store.dart';
import 'package:harness/shared/theme/color_palette.dart';
import 'package:harness/state/app_state.dart';
import 'package:harness/widgets/bootstrapping_screen.dart';
import 'boot_flow_widget_test.dart' show makeNotifier;
// Task #3563: the first frame draws only the window's own colour. The app
// state, its bootstrap and the screen over it are built on the next frame, so
// the first frame does not wait for what is not on screen yet.
void main() {
Future<({AppNotifier app, bool Function() created})> mount(
WidgetTester tester,
AppStatus status, {
bool defer = true,
}) async {
tester.view.devicePixelRatio = 1;
tester.view.physicalSize = const Size(1280, 800);
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final app = makeNotifier(status);
addTearDown(app.dispose);
var created = false;
await tester.pumpWidget(
ProviderScope(
overrides: [
appStateProvider.overrideWith((ref) {
created = true;
return app;
}),
],
child: HarnessApp(
deferFirstScreen: defer,
authenticatedScreen: (_) =>
const Scaffold(body: Center(child: Text('Workspace'))),
),
),
);
return (app: app, created: () => created);
}
testWidgets('the first frame builds no app state and no screen', (
tester,
) async {
final mounted = await mount(tester, AppStatus.bootstrapping);
expect(mounted.created(), isFalse);
expect(find.byType(RootShell), findsNothing);
expect(find.byType(BootstrappingScreen), findsNothing);
expect(find.byKey(const Key('first-frame-placeholder')), findsOneWidget);
});
testWidgets('the next frame builds the app state and the boot screen', (
tester,
) async {
final mounted = await mount(tester, AppStatus.bootstrapping);
await tester.pump();
expect(mounted.created(), isTrue);
expect(find.byType(RootShell), findsOneWidget);
expect(find.byType(BootstrappingScreen), findsOneWidget);
expect(find.byKey(const Key('first-frame-placeholder')), findsNothing);
});
testWidgets('what was deferred still appears once loaded', (tester) async {
await mount(tester, AppStatus.authenticated);
expect(find.text('Workspace'), findsNothing);
await tester.pump();
expect(find.text('Workspace'), findsOneWidget);
// And it stays: later frames never bring the placeholder back.
await tester.pump(const Duration(seconds: 1));
expect(find.text('Workspace'), findsOneWidget);
expect(find.byKey(const Key('first-frame-placeholder')), findsNothing);
});
testWidgets('a light palette gets a light first frame, not a dark flash', (
tester,
) async {
final saved = appearancePrefsStore.value;
addTearDown(() {
appearancePrefsStore.value = saved;
grid.AppTheme.brightness.value = Brightness.dark;
grid.AppTheme.palette.value = HarnessPalette.graphite;
});
appearancePrefsStore.value = AppearancePrefs(
palette: HarnessPalette.paper,
mode: AppearanceMode.light,
);
await mount(tester, AppStatus.bootstrapping);
final placeholder = tester.widget<ColoredBox>(
find.byKey(const Key('first-frame-placeholder')),
);
expect(HarnessPalette.paper.brightness, Brightness.light);
// The colour the boot screen draws on (`AppPalette.windowBg`) in a light app.
expect(
placeholder.color,
grid.AppTheme.paletteFor(Brightness.light).background,
);
expect(placeholder.color, isNot(HarnessPalette.graphite.background));
});
testWidgets('without deferral the first frame holds the whole screen', (
tester,
) async {
final mounted = await mount(tester, AppStatus.authenticated, defer: false);
expect(mounted.created(), isTrue);
expect(find.text('Workspace'), findsOneWidget);
expect(find.byKey(const Key('first-frame-placeholder')), findsNothing);
});
}