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-03 b1806: #2781 (#2799)
0xken1599612dccb298
diff --git a/desktop/lib/shared/theme/app_theme.dart b/desktop/lib/shared/theme/app_theme.dartindex 56deaf7ef..d42166e7e 100644--- a/desktop/lib/shared/theme/app_theme.dart+++ b/desktop/lib/shared/theme/app_theme.dart@@ -1437,6 +1437,32 @@ abstract final class AppDesktop {static const double dialogRadius = 20;static const double dialogElevation = 16;static const Color shadow = Color(0x3D000000);++ /// The soft shade a right-side pane (a thread, a task, Members) lays over+ /// the chat along its left edge, as in Slack (Huy, 11-03): a strip+ /// [paneEdgeShadeWidth] wide, darkest at the pane, fading to nothing over+ /// the chat. A gradient rather than a blurred shadow: a straight edge needs+ /// no blur, and a blur is paid on every repaint of the window. Darker in+ /// dark mode, where a light shade would not show on charcoal.+ static const double paneEdgeShadeWidth = 12;+ static LinearGradient get paneEdgeShade {+ final edge = AppTheme.pick(+ const Color(0x17000000),+ const Color(0x66000000),+ );+ return LinearGradient(+ begin: Alignment.centerRight,+ end: Alignment.centerLeft,+ colors: [+ edge,+ edge.withValues(alpha: edge.a * 0.55),+ edge.withValues(alpha: edge.a * 0.2),+ edge.withValues(alpha: 0),+ ],+ stops: const [0, 0.3, 0.65, 1],+ );+ }+static const double menuRadius = 16;static const double rowRadius = 10;static const double fieldRadius = 10;diff --git a/desktop/lib/super_tabs/pane_layout.dart b/desktop/lib/super_tabs/pane_layout.dartindex 54e0db9e1..f9985a74d 100644--- a/desktop/lib/super_tabs/pane_layout.dart+++ b/desktop/lib/super_tabs/pane_layout.dart@@ -5,6 +5,7 @@ import 'dart:math' as math;import 'package:flutter/material.dart';import '../core/local_key_value_store.dart';+import '../shared/theme/app_theme.dart' as grid;import '../state/pane_arrangement.dart';import '../widgets/desktop_chrome.dart';import '../widgets/pane_resize_handle.dart';@@ -165,7 +166,7 @@ class _SuperTabPaneLayoutState extends State<SuperTabPaneLayout> {SizedBox(key: const ValueKey('super-right-pane'),width: right,- child: widget.right,+ child: SuperTabRightPane(child: widget.right!),),],),@@ -229,3 +230,39 @@ class _SuperTabPaneLayoutState extends State<SuperTabPaneLayout> {},);}++/// A pane on the right of a Swarm chat (a thread, a task, Members), beside it+/// or over it as a drawer. Along its left edge it lays the design system's+/// pane shade over the chat, so the two read as separate surfaces, as in+/// Slack (Huy, 11-03). The pane is drawn after the chat, so the shade lies on+/// the chat; it takes no pointer, so the chat beneath it still gets clicks.+class SuperTabRightPane extends StatelessWidget {+ const SuperTabRightPane({super.key, required this.child});++ final Widget child;++ @override+ Widget build(BuildContext context) {+ grid.AppTheme.watch(context);+ return Stack(+ fit: StackFit.passthrough,+ clipBehavior: Clip.none,+ children: [+ child,+ Positioned(+ top: 0,+ bottom: 0,+ left: -grid.AppDesktop.paneEdgeShadeWidth,+ width: grid.AppDesktop.paneEdgeShadeWidth,+ child: IgnorePointer(+ child: DecoratedBox(+ decoration: BoxDecoration(+ gradient: grid.AppDesktop.paneEdgeShade,+ ),+ ),+ ),+ ),+ ],+ );+ }+}diff --git a/desktop/lib/super_tabs/view.dart b/desktop/lib/super_tabs/view.dartindex 4e51c1748..b3bfe8f09 100644--- a/desktop/lib/super_tabs/view.dart+++ b/desktop/lib/super_tabs/view.dart@@ -4515,7 +4515,7 @@ class _SuperTabViewState extends State<SuperTabView>constraints.maxWidth,max: SuperTabPaneLayout.threadWidth,),- child: thread,+ child: SuperTabRightPane(child: thread),),),),@@ -4548,7 +4548,7 @@ class _SuperTabViewState extends State<SuperTabView>width: SuperTabPaneLayout.drawerWidth(constraints.maxWidth,),- child: roster,+ child: SuperTabRightPane(child: roster),),),),diff --git a/desktop/test/benchmarks/super_tab_pane_shadow_benchmark.dart b/desktop/test/benchmarks/super_tab_pane_shadow_benchmark.dartnew file mode 100644index 000000000..3dbdaaa3c--- /dev/null+++ b/desktop/test/benchmarks/super_tab_pane_shadow_benchmark.dart@@ -0,0 +1,126 @@+// Run explicitly: flutter test test/benchmarks/super_tab_pane_shadow_benchmark.dart --reporter expanded+// Headless measurements of the Swarm view with a thread open on the right,+// where the right pane shades the chat along its left edge (#2424): CPU per frame while+// the thread's divider is dragged (every frame lays out and repaints the+// panes), and software rasterization of the whole window, with real shadows+// (the composer's among them).+// Neither is display latency; compare heads measured the same way.+import 'dart:convert';+import 'dart:ui' as ui;++import 'package:flutter/material.dart';+import 'package:flutter/rendering.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/shared/theme/app_theme.dart' as grid;+import 'package:harness/super_tabs/view.dart';++import '../support/super_tab_fixture.dart';+import 'swarm_benchmark.dart' show distribution;++void main() {+ for (final brightness in Brightness.values) {+ testWidgets('Swarm view with a thread open: divider drag and raster '+ '(${brightness.name})', (tester) async {+ final picture = GlobalKey();+ final server = ConversationServer()..threads = true;+ server.append('Should we do thread replies?');+ for (var i = 1; i <= 20; i++) {+ server.append('Reply $i: the reconnect keeps every edit in order.');+ server.messages.last+ ..['thread'] = 'message-1'+ ..['replyTo'] = 'message-1';+ }+ for (var i = 1; i <= 40; i++) {+ server.append('Update $i: pushed the branch; the checks are running.');+ }+ final c = server.controller();+ addTearDown(c.dispose);+ await c.refresh();+ grid.AppTheme.brightness.value = brightness;+ addTearDown(() => grid.AppTheme.brightness.value = Brightness.light);+ // The real, blurred shadow, not flutter_test's hard-edged stand-in.+ debugDisableShadows = false;+ addTearDown(() => debugDisableShadows = true);+ await tester.binding.setSurfaceSize(const Size(1400, 800));+ addTearDown(() => tester.binding.setSurfaceSize(null));+ await tester.pumpWidget(+ MaterialApp(+ theme: grid.buildAppTheme(brightness: brightness),+ builder: (context, child) =>+ RepaintBoundary(key: picture, child: child),+ home: Scaffold(+ body: SuperTabView(+ controller: c,+ onInvite: () {},+ onAddAgent: (_) {},+ onOpenTerminal: (_) {},+ machineName: (_) => 'Mac Studio',+ ),+ ),+ ),+ );+ await tester.pumpAndSettle();+ c.openThread('message-1');+ await tester.pumpAndSettle();+ expect(find.byKey(const ValueKey('super-thread-panel')), findsOne);++ final drag = await tester.startGesture(+ tester.getCenter(find.byKey(const ValueKey('super-resize-right'))),+ );+ // Past the drag slop first, so every measured frame resizes the panes.+ await drag.moveBy(const Offset(-40, 0));+ await tester.pump();+ final right = find.byKey(const ValueKey('super-right-pane'));+ var step = 0;+ Future<int> frame() async {+ final watch = Stopwatch()..start();+ await drag.moveBy(Offset((step++).isEven ? -8 : 8, 0));+ await tester.pump();+ return watch.elapsedMicroseconds;+ }++ final before = tester.getSize(right).width;+ await frame();+ expect(tester.getSize(right).width, isNot(before), reason: 'resized');+ for (var i = 0; i < 20; i++) {+ await frame();+ }+ final frames = [for (var i = 0; i < 200; i++) await frame()];+ await drag.up();+ await tester.pumpAndSettle();++ final boundary =+ picture.currentContext!.findRenderObject()! as RenderRepaintBoundary;+ final rasters = (await tester.runAsync(() async {+ Future<int> raster() async {+ final watch = Stopwatch()..start();+ final image = await boundary.toImage();+ await image.toByteData(format: ui.ImageByteFormat.rawRgba);+ final elapsed = watch.elapsedMicroseconds;+ image.dispose();+ return elapsed;+ }++ for (var i = 0; i < 5; i++) {+ await raster();+ }+ return [for (var i = 0; i < 40; i++) await raster()];+ }))!;++ // ignore: avoid_print+ print(+ jsonEncode({+ 'benchmark': 'super_tab_pane_shadow',+ 'brightness': brightness.name,+ 'dividerDragFrame': distribution(frames),+ 'windowRaster': distribution(rasters),+ }),+ );+ // flutter_test checks its debug flags before tear-downs run.+ debugDisableShadows = true;+ await tester.pumpWidget(const SizedBox());+ await tester.pump(const Duration(seconds: 5));+ await c.flush();+ });+ }+}diff --git a/desktop/test/super_tab_pane_layout_test.dart b/desktop/test/super_tab_pane_layout_test.dartindex bfb425156..d7ba0bce3 100644--- a/desktop/test/super_tab_pane_layout_test.dart+++ b/desktop/test/super_tab_pane_layout_test.dart@@ -310,4 +310,79 @@ void main() {expect(tester.getSize(left).width, 400, reason: saved);}});++ // Huy, 11-03: an open thread (or task, or Members) is set apart from the+ // chat by a soft shadow on its left edge, as in Slack, in both themes.+ for (final brightness in Brightness.values) {+ testWidgets('the right pane lays the shared shade over the chat along its '+ 'left edge; the chat casts none (${brightness.name})', (tester) async {+ await tester.binding.setSurfaceSize(const Size(1400, 800));+ addTearDown(() => tester.binding.setSurfaceSize(null));+ grid.AppTheme.brightness.value = brightness;+ addTearDown(() => grid.AppTheme.brightness.value = Brightness.light);+ final page = grid.AppDesktop.surface;+ var chatTaps = 0;+ await tester.pumpWidget(+ MaterialApp(+ theme: grid.buildAppTheme(brightness: brightness),+ home: Scaffold(+ body: SuperTabPaneLayout(+ storage: MemoryStore(),+ onLeave: () {},+ left: SizedBox.expand(child: ColoredBox(color: page)),+ right: SizedBox.expand(child: ColoredBox(color: page)),+ center: GestureDetector(+ onTap: () => chatTaps++,+ child: SizedBox.expand(child: ColoredBox(color: page)),+ ),+ ),+ ),+ ),+ );+ await tester.pumpAndSettle();++ // A strip of the design system's one gradient just outside the pane's+ // left edge, darkest at the pane, fading out over the chat. A gradient,+ // not a blurred shadow: a straight edge needs no blur, and a blur costs+ // every repaint of the window (ENGINEERING.md 4).+ Finder shadesIn(Finder pane) => find.descendant(+ of: pane,+ matching: find.byWidgetPredicate(+ (w) =>+ w is DecoratedBox &&+ w.decoration is BoxDecoration &&+ ((w.decoration as BoxDecoration).gradient != null ||+ (w.decoration as BoxDecoration).boxShadow != null),+ ),+ );+ expect(shadesIn(center), findsNothing);+ expect(shadesIn(left), findsNothing);+ final shade = shadesIn(right);+ expect(shade, findsOne);+ final decoration =+ tester.widget<DecoratedBox>(shade).decoration as BoxDecoration;+ expect(decoration.boxShadow, isNull);+ final gradient = grid.AppDesktop.paneEdgeShade;+ expect(decoration.gradient, gradient);+ expect(gradient.begin, Alignment.centerRight);+ expect(gradient.colors.first.a, greaterThan(0));+ expect(gradient.colors.last.a, 0);+ final strip = tester.getRect(shade), pane = tester.getRect(right);+ expect(strip.right, pane.left);+ expect(strip.width, grid.AppDesktop.paneEdgeShadeWidth);+ expect(strip.top, pane.top);+ expect(strip.bottom, pane.bottom);+ expect(strip.left, greaterThan(tester.getRect(center).left));++ // It never takes a click meant for the chat beneath it.+ await tester.tapAt(strip.centerLeft + const Offset(2, 0));+ expect(chatTaps, 1);++ final row = tester.widget<Row>(+ find.ancestor(of: right, matching: find.byType(Row)).first,+ );+ expect(row.children.last.key, const ValueKey('super-right-pane'));+ expect(tester.takeException(), isNull);+ });+ }}diff --git a/desktop/test/super_tab_pane_shadow_shots_test.dart b/desktop/test/super_tab_pane_shadow_shots_test.dartnew file mode 100644index 000000000..24b12a498--- /dev/null+++ b/desktop/test/super_tab_pane_shadow_shots_test.dart@@ -0,0 +1,184 @@+import 'dart:io';+import 'dart:ui' as ui;++import 'package:flutter/material.dart';+import 'package:flutter/rendering.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/shared/theme/app_theme.dart' as grid;+import 'package:harness/super_tabs/pane_layout.dart';+import 'package:harness/super_tabs/roster.dart';+import 'package:harness/super_tabs/view.dart';++import 'box_render_preview_test.dart' show loadPreviewFonts;+import 'support/super_tab_fixture.dart';++/// Set to a folder to write the PR's screenshots there.+final shots = Platform.environment['SUPER_TAB_PANE_SHADOW_SHOTS'];++const _updates = [+ 'Reading the offline queue before the reconnect.',+ 'The reconnect keeps every queued edit in order.',+ 'Two devices editing at once settle on the newest edit.',+ 'Pushed the branch; the checks are running.',+];++/// Huy, 11-03: a thread, and Members, open on the right with a soft shadow on+/// their left edge, as in Slack: beside the chat in a wide window, and over it+/// as a drawer in a narrow one. Each takes the one shared shadow.+void main() {+ setUpAll(() async {+ if (shots != null) await loadPreviewFonts();+ });++ for (final brightness in Brightness.values) {+ for (final (name, size, members) in [+ ('thread', const Size(1400, 800), false),+ ('thread-drawer', const Size(900, 700), false),+ ('members', const Size(1400, 800), true),+ ('members-drawer', const Size(900, 700), true),+ ]) {+ testWidgets('$name casts the shared shadow (${brightness.name})', (+ tester,+ ) async {+ final picture = GlobalKey();+ const peer = {+ 'kind': 'person',+ 'id': 'peer',+ 'name': '[email protected]',+ };+ final server = ConversationServer()..threads = true;+ (server.state['people'] as List).add({+ 'id': 'peer',+ 'email': '[email protected]',+ 'role': 'collaborator',+ });+ server.append('Should we do thread replies?');+ for (var i = 1; i <= 6; i++) {+ server.append(_updates[i % _updates.length]);+ server.messages.last+ ..['thread'] = 'message-1'+ ..['replyTo'] = 'message-1'+ ..['author'] = peer;+ }+ for (var i = 1; i <= 12; i++) {+ server.append(_updates[i % _updates.length]);+ server.messages.last['author'] = {+ 'kind': 'agent',+ 'id': 'lead-agent',+ 'name': 'Lead',+ };+ }+ final c = server.controller();+ addTearDown(c.dispose);+ await c.refresh();+ grid.AppTheme.brightness.value = brightness;+ addTearDown(() => grid.AppTheme.brightness.value = Brightness.light);+ await tester.binding.setSurfaceSize(size);+ addTearDown(() => tester.binding.setSurfaceSize(null));+ await tester.pumpWidget(+ MaterialApp(+ theme: grid.buildAppTheme(brightness: brightness),+ builder: (context, child) =>+ RepaintBoundary(key: picture, child: child),+ home: Scaffold(+ body: SuperTabView(+ controller: c,+ onInvite: () {},+ onAddAgent: (_) {},+ onOpenTerminal: (_) {},+ machineName: (_) => 'Mac Studio',+ ),+ ),+ ),+ );+ await tester.pumpAndSettle();+ if (members) {+ await tester.tap(find.byKey(const ValueKey('super-members-button')));+ } else {+ c.openThread('message-1');+ }+ await tester.pumpAndSettle();++ final pane = members+ ? find.byType(SuperTabRoster)+ : find.byKey(const ValueKey('super-thread-panel'));+ expect(pane, findsOne);+ // Written before the check, so a base without the shadow gives the+ // before pictures.+ if (shots != null) {+ await tester.runAsync(() async {+ final boundary =+ picture.currentContext!.findRenderObject()!+ as RenderRepaintBoundary;+ final image = await boundary.toImage(pixelRatio: 1.5);+ final bytes = await image.toByteData(+ format: ui.ImageByteFormat.png,+ );+ await Directory(shots!).create(recursive: true);+ await File('$shots/pane-shadow-$name-${brightness.name}.png')+ .writeAsBytes(bytes!.buffer.asUint8List());+ image.dispose();+ });+ }+ final container = find.ancestor(+ of: pane,+ matching: find.byType(SuperTabRightPane),+ );+ expect(container, findsOne);+ final shade = find.descendant(+ of: container,+ matching: find.byWidgetPredicate(+ (w) =>+ w is DecoratedBox &&+ w.decoration is BoxDecoration &&+ (w.decoration as BoxDecoration).gradient != null,+ ),+ );+ expect(shade, findsOne);+ expect(+ (tester.widget<DecoratedBox>(shade).decoration as BoxDecoration)+ .gradient,+ grid.AppDesktop.paneEdgeShade,+ );++ // What a person sees (where the chat is not under the dark drawer+ // veil, which is already black): on most rows down the pane, the chat just left+ // of its edge is darker than the chat a little further in.+ if (!name.endsWith('drawer') || brightness == Brightness.light) {+ final edge = tester.getRect(container);+ final rows = [+ for (var i = 1; i <= 9; i++) edge.top + edge.height * i / 10,+ ];+ final darker = await tester.runAsync(() async {+ final boundary =+ picture.currentContext!.findRenderObject()!+ as RenderRepaintBoundary;+ final image = await boundary.toImage();+ final data = (await image.toByteData(+ format: ui.ImageByteFormat.rawRgba,+ ))!;+ int luma(double x, double y) {+ final at = (y.round() * image.width + x.round()) * 4;+ return (data.getUint8(at) * 299 ++ data.getUint8(at + 1) * 587 ++ data.getUint8(at + 2) * 114) ~/+ 1000;+ }++ final count = rows+ .where(+ (y) => luma(edge.left - 40, y) - luma(edge.left - 2, y) >= 3,+ )+ .length;+ image.dispose();+ return count;+ });+ expect(darker, greaterThanOrEqualTo(6), reason: 'shaded rows of 9');+ }++ await tester.pumpWidget(const SizedBox());+ await c.flush();+ });+ }+ }+}