Skip to content

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.

Merge batch 11-06 k0720: #3287 (#3288)

0xken15bf1d9df4ee5b
diff --git a/desktop/lib/core/desktop_window.dart b/desktop/lib/core/desktop_window.dart
index f0111db8b..105ea43c3 100644
--- a/desktop/lib/core/desktop_window.dart
+++ b/desktop/lib/core/desktop_window.dart
@@ -4,6 +4,7 @@ import 'package:flutter/services.dart';
import 'runtime_platform.dart';
import '../shared/theme/color_palette.dart';
import 'build_identity.dart';
+import '../measurement/speed_marks.dart';
/// Whether this build runs inside a window the app is allowed to manage.
///
@@ -29,6 +30,7 @@ Future<void> configureDesktopWindow({
}) async {
if (!hasManagedWindow) return;
await windowManager.ensureInitialized();
+ speedMarks.launch('window manager ready');
final options = WindowOptions(
size: const Size(1280, 800),
minimumSize: const Size(880, 560),
@@ -44,10 +46,12 @@ Future<void> configureDesktopWindow({
// The plugin's optional callback is a VoidCallback: an async callback would
// return before native setup finishes and detach any error from this future.
await windowManager.waitUntilReadyToShow(options);
+ speedMarks.launch('window ready to show');
if (RuntimePlatform.isMacOS) {
await const MethodChannel('harness/swarm_tabs').invokeMethod('configure', {
'palette': palette.nativeColors,
});
+ speedMarks.launch('titlebar configured');
}
// Always open filling the screen (owner, 2026-09-15): the tabs, a viewer
// beside its terminal and the rail all want the width. The options above
@@ -56,7 +60,16 @@ Future<void> configureDesktopWindow({
// Maximise AFTER show: a maximise asked of a window that has not been shown
// is dropped on Windows, which left the app opening at the 1280x800 default.
await windowManager.show();
- await windowManager.maximize();
+ speedMarks.launch('window shown');
+ // macOS: the window manager's maximize is AppKit's animated zoom, which
+ // blocks the main thread for ~400-500 ms before the first frame (task #3559).
+ // The native channel zooms the same way without the animation.
+ if (RuntimePlatform.isMacOS) {
+ await const MethodChannel('harness/swarm_tabs').invokeMethod('maximize');
+ } else {
+ await windowManager.maximize();
+ }
+ speedMarks.launch('window maximized');
await windowManager.focus();
}
diff --git a/desktop/macos/Runner/MainFlutterWindow.swift b/desktop/macos/Runner/MainFlutterWindow.swift
index 65d3e762b..e35fb5cfe 100644
--- a/desktop/macos/Runner/MainFlutterWindow.swift
+++ b/desktop/macos/Runner/MainFlutterWindow.swift
@@ -26,6 +26,16 @@ private let kFontsChannel = "harness/fonts"
private let kSystemSymbolsChannel = "harness/system_symbols"
class MainFlutterWindow: NSWindow {
+ /// True only while the opening maximise runs (task #3559). AppKit's zoom
+ /// animates the resize on the main thread, ~400-500 ms before the first
+ /// Flutter frame; at launch the window is not on screen long enough to be
+ /// worth animating. Every later zoom (the green button) keeps its animation.
+ var resizesInstantly = false
+
+ override func animationResizeTime(_ newFrame: NSRect) -> TimeInterval {
+ resizesInstantly ? 0 : super.animationResizeTime(newFrame)
+ }
+
private var swarmTitlebar: SwarmTitlebar?
private var menuChannel: FlutterMethodChannel?
private var clipboardImageChannel: FlutterMethodChannel?
diff --git a/desktop/macos/Runner/SwarmTitlebar.swift b/desktop/macos/Runner/SwarmTitlebar.swift
index 717d4dd91..cb9dc5aed 100644
--- a/desktop/macos/Runner/SwarmTitlebar.swift
+++ b/desktop/macos/Runner/SwarmTitlebar.swift
@@ -108,6 +108,15 @@ final class SwarmTitlebar: NSObject, NSMenuItemValidation, NSMenuDelegate {
let state = call.arguments as? [String: Any] ?? [:]
self.configure(palette: state["palette"] as? [String: Any])
result(true)
+ case "maximize":
+ // The opening maximise, without AppKit's animation. The zoom itself is
+ // unchanged, so the green button still returns to the frame it left.
+ if let window = self.window as? MainFlutterWindow, !window.isZoomed {
+ window.resizesInstantly = true
+ window.zoom(nil)
+ window.resizesInstantly = false
+ }
+ result(true)
case "update":
let state = call.arguments as? [String: Any] ?? [:]
self.actionsEnabled = state["enabled"] as? Bool == true
diff --git a/desktop/test/desktop_window_test.dart b/desktop/test/desktop_window_test.dart
index 5e11d1d9f..0642cf91b 100644
--- a/desktop/test/desktop_window_test.dart
+++ b/desktop/test/desktop_window_test.dart
@@ -1,4 +1,3 @@
-
import 'dart:async';
import 'dart:io';
@@ -25,18 +24,24 @@ void main() {
final binding = TestWidgetsFlutterBinding.ensureInitialized();
final calls = <String>[];
final nativeCalls = <MethodCall>[];
+ final windowCalls = <MethodCall>[];
+ // The palette call; `maximize` shares the channel since task #3559.
+ Iterable<MethodCall> configureCalls() =>
+ nativeCalls.where((call) => call.method == 'configure');
Future<Object?> Function(MethodCall)? nativeReply;
Future<Object?> Function(MethodCall)? windowReply;
setUp(() {
calls.clear();
nativeCalls.clear();
+ windowCalls.clear();
nativeReply = null;
windowReply = null;
binding.defaultBinaryMessenger.setMockMethodCallHandler(_windowChannel, (
call,
) async {
calls.add(call.method);
+ windowCalls.add(call);
switch (call.method) {
case 'isFullScreen':
case 'isMaximized':
@@ -124,8 +129,7 @@ void main() {
final setup = configureDesktopWindow();
await tester.pump();
await setup;
- expect(nativeCalls.single.method, 'configure');
- expect(nativeCalls.single.arguments, {
+ expect(configureCalls().single.arguments, {
'palette': HarnessPalette.graphite.nativeColors,
});
expect(calls.indexOf('native:configure'), lessThan(calls.indexOf('show')));
@@ -140,7 +144,7 @@ void main() {
final setup = configureDesktopWindow(palette: palette);
await tester.pump();
await setup;
- expect(nativeCalls.single.arguments, {
+ expect(configureCalls().single.arguments, {
'palette': palette.nativeColors,
});
expect(
@@ -169,4 +173,37 @@ void main() {
expect(calls, isNot(contains('show')));
expect(calls, isNot(contains('focus')));
}, skip: !Platform.isMacOS);
+
+ // Task #3559: the window manager's maximize is AppKit's animated zoom. It
+ // blocks the main thread for ~400-500 ms (release build, M3 Pro) before the
+ // first Flutter frame. The window still ends up maximised, but through the
+ // native channel, which zooms without the animation.
+ testWidgets('macOS maximises through the native instant zoom', (
+ tester,
+ ) async {
+ final setup = configureDesktopWindow();
+ await tester.pump();
+ await setup;
+ expect(calls, contains('native:maximize'));
+ expect(calls, isNot(contains('maximize')));
+ // After show, so the maximise is not dropped on an unshown window.
+ expect(calls.indexOf('show'), lessThan(calls.indexOf('native:maximize')));
+ expect(calls.indexOf('native:maximize'), lessThan(calls.indexOf('focus')));
+ }, skip: !Platform.isMacOS);
+
+ testWidgets('the window keeps its 1280x800 frame to return to', (
+ tester,
+ ) async {
+ final setup = configureDesktopWindow();
+ await tester.pump();
+ await setup;
+ final sized = windowCalls.where(
+ (call) =>
+ call.method == 'setBounds' &&
+ (call.arguments as Map)['width'] == 1280.0 &&
+ (call.arguments as Map)['height'] == 800.0,
+ );
+ expect(sized, isNotEmpty);
+ expect(calls.indexOf('setBounds'), lessThan(calls.indexOf('show')));
+ }, skip: !Platform.isMacOS);
}