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
Merge batch 11-06 k0850: #3290 (#3295)
0xken15b8b8c8eab545
diff --git a/desktop/lib/app_shell.dart b/desktop/lib/app_shell.dartindex 313607316..0ca79f603 100644--- a/desktop/lib/app_shell.dart+++ b/desktop/lib/app_shell.dart@@ -129,7 +129,15 @@ class HarnessApp extends StatelessWidget {this.keymap,required this.authenticatedScreen,this.frame,+ this.deferFirstScreen,});++ /// Whether the first frame draws only the window colour, leaving the app+ /// state and the screen to the next frame (task #3563). Null: on, except in+ /// widget tests, which expect the screen on their first pump, and on the web,+ /// which this change did not measure.+ final bool? deferFirstScreen;+final AppKeymap? keymap;final AuthenticatedScreenBuilder authenticatedScreen;final AppFrameBuilder? frame;@@ -144,6 +152,10 @@ class HarnessApp extends StatelessWidget {Widget _app(AppearancePrefs prefs) {grid.AppTheme.palette.value = prefs.palette;+ // Also the brightness `AppPalette.windowBg` resolves against: the+ // placeholder of the first frame is drawn before `_GridTokenScope` (inside+ // the deferred shell) would set it, and a light palette must not flash dark.+ grid.AppTheme.brightness.value = prefs.palette.brightness;return MaterialApp(title: 'Harness',// OAuth callback paths are consumed by the sign-in adapter during boot.@@ -171,13 +183,19 @@ class HarnessApp extends StatelessWidget {// Desktop forms respect the platform's text size. Fixed-grid terminal// surfaces own their no-scaling boundary alongside terminal zoom.builder: (context, child) {- final app = child ?? const SizedBox.shrink();- final framed = _TeamSetupHold(child: frame?.call(app) ?? app);- return _GridTokenScope(- child: keymap == null- ? framed- : KeymapProvider(keymap: keymap!, child: framed),- );+ Widget shell() {+ final app = child ?? const SizedBox.shrink();+ final framed = _TeamSetupHold(child: frame?.call(app) ?? app);+ return _GridTokenScope(+ child: keymap == null+ ? framed+ : KeymapProvider(keymap: keymap!, child: framed),+ );+ }++ return deferFirstScreen ?? !(kUnderTest || kIsWeb)+ ? _AfterFirstFrame(build: shell)+ : shell();},home: StatsLifecycle(child: RootShell(authenticatedScreen: authenticatedScreen),@@ -186,6 +204,52 @@ class HarnessApp extends StatelessWidget {}}+/// Draws only the window's own colour on the first frame, then [build] on the+/// next one (task #3563).+///+/// The app state (its bootstrap starts when it is first read), the menu and+/// device strips, the keymap and the screen are built inside [build]. The+/// first frame no longer waits for them: its mark moves from ~82 ms to ~55 ms+/// after the window is configured, and the boot screen is on screen about+/// 10 ms earlier than before, because the next frame starts straight after+/// this one. The window colour matches the screen's, so nothing flashes.+class _AfterFirstFrame extends StatefulWidget {+ const _AfterFirstFrame({required this.build});++ final Widget Function() build;++ @override+ State<_AfterFirstFrame> createState() => _AfterFirstFrameState();+}++class _AfterFirstFrameState extends State<_AfterFirstFrame> {+ bool _ready = false;++ @override+ void initState() {+ super.initState();+ WidgetsBinding.instance.addPostFrameCallback((_) {+ if (!mounted) return;+ setState(() => _ready = true);+ speedMarks.launch('first screen built');+ WidgetsBinding.instance.addPostFrameCallback(+ (_) => speedMarks.launch('first screen painted'),+ );+ });+ }++ @override+ Widget build(BuildContext context) {+ if (!_ready) {+ return ColoredBox(+ key: const Key('first-frame-placeholder'),+ color: grid.AppPalette.windowBg,+ );+ }+ return widget.build();+ }+}+/// The whole window, every route and dialog included, waits while this/// computer's Harness Team account must be set up after it joined a Swarm/// (super_tabs/team_account_setup.dart).diff --git a/desktop/test/first_frame_deferral_test.dart b/desktop/test/first_frame_deferral_test.dartnew file mode 100644index 000000000..945e330af--- /dev/null+++ b/desktop/test/first_frame_deferral_test.dart@@ -0,0 +1,113 @@+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);+ });+}