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
perf(desktop): open dialogs instantly and lazily render shortcuts (#220)
Dee58a250def920
diff --git a/desktop/lib/shared/widgets/app_dialog.dart b/desktop/lib/shared/widgets/app_dialog.dartindex 22f8f50f9..70a30cd24 100644--- a/desktop/lib/shared/widgets/app_dialog.dart+++ b/desktop/lib/shared/widgets/app_dialog.dart@@ -1,16 +1,5 @@-/// One way to open a dialog, so every dialog in the app stands on the same-/// veil.-///-/// Material's `showDialog` can only TINT what is behind a dialog —-/// `barrierColor` is a flat fill, and this app's background is terminals. Dimmed-/// text is still text: at any alpha that keeps the window feeling alive, the-/// lines behind a panel stay legible enough to read, and a reader's eye goes on-/// picking words out of them instead of settling on the thing that just opened.-///-/// So the barrier is BUILT rather than coloured — a [BackdropFilter] under a-/// tint, the pairing `task_palette.dart` already uses for its own veil. Blur-/// destroys the letterforms; the tint then sets the depth. Together they make-/// what is behind read as *behind*.+/// Shared instant dialogs. An opaque-enough tint separates terminal text from+/// the dialog without filtering live terminal pixels on every frame.library;import 'dart:ui' show ImageFilter;@@ -18,20 +7,14 @@ import 'dart:ui' show ImageFilter;import 'package:flutter/material.dart';import 'package:flutter/services.dart';-/// How far the app blurs what sits behind a dialog.-///-/// ⚠️ Bounded on purpose. A terminal is high-contrast text on a dark ground,-/// and far enough past this the glyphs stop reading as letters at all and-/// become a grey haze that looks like a rendering fault rather than depth. 7-/// is where a line behind the panel is unmistakably gone while the window-/// still reads as the window.-const double kDialogVeilBlur = 7;+/// Dialogs do not blur the live workspace by default.+const double kDialogVeilBlur = 0;/// Shared dark backdrop for dialogs and centered pickers. Terminal output/// stays in the background while the active surface has the user's attention.const Color kDialogVeilTint = Color(0xE6000000);-/// The app's dialog barrier: a blur, then a tint, then whatever opened.+/// The app's dialog barrier: a flat tint and the active surface.////// Use it in place of `showDialog` wherever a panel should take the window's/// full attention. It keeps `showDialog`'s shape — the same `builder`,@@ -50,7 +33,7 @@ Future<T?> showAppDialog<T>({String barrierLabel = 'Dismiss',Color veilTint = kDialogVeilTint,double veilBlur = kDialogVeilBlur,- Duration transitionDuration = const Duration(milliseconds: 140),+ Duration transitionDuration = Duration.zero,}) => showGeneralDialog<T>(context: context,// The route's own barrier draws nothing: the veil below is the barrier.@@ -60,17 +43,20 @@ Future<T?> showAppDialog<T>({// over a barrier it believes is there, including a tap on the dialog.barrierDismissible: false,barrierLabel: barrierLabel,- transitionDuration: transitionDuration,+ transitionDuration: MediaQuery.disableAnimationsOf(context)+ ? Duration.zero+ : transitionDuration,pageBuilder: (context, _, _) => _AppDialogVeil(tint: veilTint,blur: veilBlur,dismissible: barrierDismissible,child: Builder(builder: builder),),- transitionBuilder: (context, anim, _, child) => FadeTransition(- opacity: CurvedAnimation(parent: anim, curve: Curves.easeOut),- child: child,- ),+ transitionBuilder: (context, anim, _, child) =>+ transitionDuration == Duration.zero ||+ MediaQuery.disableAnimationsOf(context)+ ? child+ : FadeTransition(opacity: anim, child: child),);/// The veil, and the dialog standing on it.diff --git a/desktop/lib/shortcuts/shortcuts_browser.dart b/desktop/lib/shortcuts/shortcuts_browser.dartindex e447dc3cb..b7bb93c4f 100644--- a/desktop/lib/shortcuts/shortcuts_browser.dart+++ b/desktop/lib/shortcuts/shortcuts_browser.dart@@ -1,3 +1,4 @@+import 'dart:async';import 'dart:math' as math;import 'package:flutter/material.dart';@@ -33,6 +34,7 @@ class _ShortcutsBrowserState extends State<ShortcutsBrowser> {final _rowKeys = <String, GlobalKey>{};List<KeyboardLesson> _visible = [];int _cursor = -1;+ int _revealRequest = 0;AppKeymap get _keymap => KeymapTheme.of(context, listen: false) ?? _fallback;@@ -65,10 +67,9 @@ class _ShortcutsBrowserState extends State<ShortcutsBrowser> {setState(() => _cursor = (_cursor + delta).clamp(0, _visible.length - 1),);+ final request = ++_revealRequest;WidgetsBinding.instance.addPostFrameCallback((_) {- if (!mounted || _cursor < 0 || _cursor >= _visible.length) return;- final target = _rowKeys[_visible[_cursor].id]?.currentContext;- if (target != null) Scrollable.ensureVisible(target, alignment: .5);+ unawaited(_revealCursor(request));});}return KeyEventResult.handled;@@ -82,16 +83,52 @@ class _ShortcutsBrowserState extends State<ShortcutsBrowser> {return KeyEventResult.ignored;}+ Future<void> _revealCursor(int request) async {+ // Adjacent rows are normally in the viewport/cache already. A page jump+ // can cross unbuilt rows, especially with large text: advance by a viewport+ // until the target is laid out, then reveal its exact bounds. No guessed+ // fixed row height, and a newer key/filter cancels the pending reveal.+ while (mounted &&+ request == _revealRequest &&+ _cursor >= 0 &&+ _cursor < _visible.length &&+ _scroll.hasClients) {+ final target = _rowKeys[_visible[_cursor].id]?.currentContext;+ if (target != null && target.mounted) {+ await Scrollable.ensureVisible(target, alignment: .5);+ return;+ }+ final firstBuilt = _visible.indexWhere(+ (lesson) => _rowKeys[lesson.id]?.currentContext != null,+ );+ final position = _scroll.position;+ final direction = firstBuilt >= 0 && _cursor < firstBuilt ? -1 : 1;+ final next = (position.pixels + direction * position.viewportDimension)+ .clamp(position.minScrollExtent, position.maxScrollExtent);+ if (next == position.pixels) return;+ _scroll.jumpTo(next);+ await WidgetsBinding.instance.endOfFrame;+ }+ }+Future<void> _practice(KeyboardLesson lesson) async {await showKeyboardPractice(context, keymap: _keymap, initialLesson: lesson);if (mounted) _input.requestFocus();}void _filterChanged(String _) {+ _revealRequest++;setState(() => _cursor = -1);if (_scroll.hasClients) _scroll.jumpTo(0);}+ Widget _lessonRow(KeyboardLesson lesson) => _ShortcutBrowserRow(+ key: _rowKeys.putIfAbsent(lesson.id, GlobalKey.new),+ lesson: lesson,+ selected: _cursor >= 0 && _visible[_cursor].id == lesson.id,+ onTap: () => _practice(lesson),+ );+@overrideWidget build(BuildContext context) {grid.AppTheme.watch(context);@@ -227,57 +264,65 @@ class _ShortcutsBrowserState extends State<ShortcutsBrowser> {constraints.maxWidth >= 760 * math.max(1, scale)? 2: 1;- final width =- (constraints.maxWidth - 32 - (columns - 1) * 20) /- columns;return Scrollbar(controller: _scroll,- child: SingleChildScrollView(+ child: ListView(controller: _scroll,padding: const EdgeInsets.fromLTRB(16, 8, 16, 24),- child: Column(- crossAxisAlignment: CrossAxisAlignment.stretch,- children: [- for (final name in names) ...[- Padding(- padding: const EdgeInsets.fromLTRB(- 12,- 20,- 12,- 10,- ),- child: Text(- name == 'Essentials' ? 'General' : name,- style: terminalTextStyle(- color: grid.AppPalette.textSecondary,- ),+ children: [+ for (final name in names) ...[+ Padding(+ padding: const EdgeInsets.fromLTRB(+ 12,+ 20,+ 12,+ 10,+ ),+ child: Text(+ name == 'Essentials' ? 'General' : name,+ style: terminalTextStyle(+ color: grid.AppPalette.textSecondary,),),- Wrap(- spacing: 20,- runSpacing: 4,- children: [- for (final lesson in groups[name]!)- SizedBox(- width: width,- child: _ShortcutBrowserRow(- key: _rowKeys.putIfAbsent(- lesson.id,- GlobalKey.new,+ ),+ for (+ var row = 0;+ row < groups[name]!.length;+ row += columns+ )+ Padding(+ padding: EdgeInsets.only(+ bottom:+ row + columns < groups[name]!.length+ ? 4+ : 0,+ ),+ child: Row(+ crossAxisAlignment:+ CrossAxisAlignment.start,+ children: [+ for (+ var column = 0;+ column < columns;+ column+++ ) ...[+ if (column > 0)+ const SizedBox(width: 20),+ if (row + column >=+ groups[name]!.length)+ const Expanded(child: SizedBox())+ else+ Expanded(+ child: _lessonRow(+ groups[name]![row + column],+ ),),- lesson: lesson,- selected:- _cursor >= 0 &&- _visible[_cursor].id ==- lesson.id,- onTap: () => _practice(lesson),- ),- ),- ],+ ],+ ],+ ),),- ],],- ),+ ],),);},@@ -343,6 +388,7 @@ class _ShortcutBrowserRow extends StatelessWidget {selected: selected,label: '${lesson.label}, ${lesson.keys}. Practice shortcut',child: Material(+ animationDuration: Duration.zero,color: selected ? grid.AppSurface.selectedFill : Colors.transparent,borderRadius: BorderRadius.circular(6),child: InkWell(diff --git a/desktop/lib/widgets/task_palette.dart b/desktop/lib/widgets/task_palette.dartindex 8ef3a8c03..cf1356327 100644--- a/desktop/lib/widgets/task_palette.dart+++ b/desktop/lib/widgets/task_palette.dart@@ -1,5 +1,4 @@import 'dart:async';-import 'dart:ui' show ImageFilter;import 'package:flutter/material.dart';import 'package:flutter/services.dart';@@ -73,22 +72,16 @@ Future<void> showTaskPalette(AppNotifier notifier, {SpokenTask? spoken,}) {- // showGeneralDialog, not showDialog, and the barrier is BUILT rather than coloured: the design's veil- // is `rgba(0,0,0,.74)` over `backdrop-filter: blur(3px)`, and `barrierColor` can only do the first- // half. The blur is what makes the terminals behind read as *behind* instead of as text competing with- // the field — at 74% flat they are dimmed but still legible, which is worse than either extreme.+ // A keyboard palette opens fully drawn on its first frame.return showGeneralDialog<void>(context: context,barrierDismissible: true,barrierLabel: 'Dismiss',barrierColor: Colors.transparent,- transitionDuration: const Duration(milliseconds: 160),+ transitionDuration: Duration.zero,pageBuilder: (context, _, _) =>_TaskPalette(notifier: notifier, spoken: spoken),- transitionBuilder: (context, anim, _, child) => FadeTransition(- opacity: CurvedAnimation(parent: anim, curve: Curves.easeOut),- child: child,- ),+ transitionBuilder: (context, anim, _, child) => child,// Every exit lands here — Esc, a tap on the veil, and the self-close after a send. A commit has// already answered by then and this does nothing; anything else is a person walking away, which the// dial has to hear about or it keeps showing work that is not happening.@@ -102,12 +95,11 @@ Future<void> showTaskPalette(/// confidence column. Naming them together is what keeps a later "small tidy" from drifting off it one/// value at a time; if the page changes, this block is the diff.abstract final class _D {- /// The frosted sheet.+ /// The opaque sheet.static const width = 680.0;static const radius = 16.0;- static const fill = Color(0xE11E1E21); // rgba(30,30,33,.88)+ static const fill = Color(0xFF1E1E21);static const rim = Color(0x1FFFFFFF); // rgba(255,255,255,.12)- static const blur = 24.0;/// The lit top edge — `inset 0 1px 0 rgba(255,255,255,.06)`. A one-pixel highlight is most of what/// makes glass read as glass rather than as a grey box.@@ -115,7 +107,6 @@ abstract final class _D {/// The veil.static const veil = kDialogVeilTint;- static const veilBlur = 3.0;/// ABOVE the middle, deliberately: the list grows downwards, and a box pinned to the centre would/// jump every time the answer arrived. Anchored high, it stays put and the results unroll beneath it.@@ -345,7 +336,7 @@ class _TaskPaletteState extends State<_TaskPalette> {Scrollable.ensureVisible(target,alignment: 0.5,- duration: const Duration(milliseconds: 120),+ duration: Duration.zero,curve: Curves.easeOut,),);@@ -470,13 +461,8 @@ class _TaskPaletteState extends State<_TaskPalette> {Positioned.fill(child: GestureDetector(onTap: () => Navigator.of(context).maybePop(),- child: BackdropFilter(- filter: ImageFilter.blur(- sigmaX: _D.veilBlur,- sigmaY: _D.veilBlur,- ),- child: const ColoredBox(color: _D.veil),- ),+ behavior: HitTestBehavior.opaque,+ child: const ColoredBox(color: _D.veil),),),Center(@@ -495,53 +481,47 @@ class _TaskPaletteState extends State<_TaskPalette> {);}- /// The frosted sheet: a clip, the blur behind it, the fill and rim on top, and a one-pixel lit edge.- ///- /// The order matters. The blur has to be INSIDE the same clip as the fill or it squares off the- /// corners, and the lit edge has to sit above the fill or the fill covers it.+ /// An opaque sheet avoids compositing and blurring the live terminals.Widget _sheet() {return ClipRRect(borderRadius: BorderRadius.circular(_D.radius),- child: BackdropFilter(- filter: ImageFilter.blur(sigmaX: _D.blur, sigmaY: _D.blur),- child: DecoratedBox(- decoration: BoxDecoration(- color: _D.fill,- borderRadius: BorderRadius.circular(_D.radius),- border: Border.all(color: _D.rim),- boxShadow: const [- BoxShadow(- color: Color(0x99000000),- blurRadius: 100,- offset: Offset(0, 40),+ child: DecoratedBox(+ decoration: BoxDecoration(+ color: _D.fill,+ borderRadius: BorderRadius.circular(_D.radius),+ border: Border.all(color: _D.rim),+ boxShadow: const [+ BoxShadow(+ color: Color(0x99000000),+ blurRadius: 12,+ offset: Offset(0, 4),+ ),+ ],+ ),+ // TRANSPARENT Material, and it is required rather than decorative: dropping Dialog for a+ // hand-built veil dropped the Material ancestor with it, and TextField and InkWell both+ // assert without one. `transparency` provides it while painting nothing, so the glass above+ // stays the only surface — a MaterialType.canvas here would put an opaque sheet over it.+ child: Material(+ type: MaterialType.transparency,+ child: Stack(+ children: [+ Column(+ mainAxisSize: MainAxisSize.min,+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [_field(), _results()],),- ],- ),- // TRANSPARENT Material, and it is required rather than decorative: dropping Dialog for a- // hand-built veil dropped the Material ancestor with it, and TextField and InkWell both- // assert without one. `transparency` provides it while painting nothing, so the glass above- // stays the only surface — a MaterialType.canvas here would put an opaque sheet over it.- child: Material(- type: MaterialType.transparency,- child: Stack(- children: [- Column(- mainAxisSize: MainAxisSize.min,- crossAxisAlignment: CrossAxisAlignment.stretch,- children: [_field(), _results()],- ),- // `inset 0 1px 0 rgba(255,255,255,.06)`.- const Positioned(- left: 0,- right: 0,- top: 0,- child: ColoredBox(- color: _D.innerLight,- child: SizedBox(height: 1),- ),+ // `inset 0 1px 0 rgba(255,255,255,.06)`.+ const Positioned(+ left: 0,+ right: 0,+ top: 0,+ child: ColoredBox(+ color: _D.innerLight,+ child: SizedBox(height: 1),),- ],- ),+ ),+ ],),),),diff --git a/desktop/test/app_dialog_responsiveness_test.dart b/desktop/test/app_dialog_responsiveness_test.dartnew file mode 100644index 000000000..70c4c0ac7--- /dev/null+++ b/desktop/test/app_dialog_responsiveness_test.dart@@ -0,0 +1,41 @@+import 'package:flutter/material.dart';+import 'package:flutter/services.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/shared/widgets/app_dialog.dart';++void main() {+ testWidgets(+ 'dialogs open fully on the first frame and dismiss without a fade',+ (tester) async {+ ModalRoute<dynamic>? route;+ await tester.pumpWidget(+ MaterialApp(+ home: Builder(+ builder: (context) => TextButton(+ onPressed: () => showAppDialog<void>(+ context: context,+ builder: (context) {+ route = ModalRoute.of(context);+ return const Center(+ child: Material(child: Text('Ready dialog')),+ );+ },+ ),+ child: const Text('Open'),+ ),+ ),+ ),+ );+ await tester.tap(find.text('Open'));+ await tester.pump();+ expect(find.text('Ready dialog'), findsOneWidget);+ expect(route!.animation!.isCompleted, isTrue);+ expect(find.byType(BackdropFilter), findsNothing);+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);+ await tester.pump();+ await tester.pump();+ expect(find.text('Ready dialog'), findsNothing);+ expect(tester.takeException(), isNull);+ },+ );+}diff --git a/desktop/test/settings_review_render_test.dart b/desktop/test/settings_review_render_test.dartindex ae8f8d55c..847a01dc0 100644--- a/desktop/test/settings_review_render_test.dart+++ b/desktop/test/settings_review_render_test.dart@@ -244,6 +244,17 @@ void main() {}}if (section == SettingsSection.shortcuts) {+ // Rows outside the viewport are now built on demand.+ await tester.scrollUntilVisible(+ find.text('Workspace'),+ 200,+ scrollable: find+ .descendant(+ of: find.byType(ListView),+ matching: find.byType(Scrollable),+ )+ .last,+ );final label = tester.renderObject<RenderParagraph>(find.text('Workspace'),);diff --git a/desktop/test/shortcuts_browser_test.dart b/desktop/test/shortcuts_browser_test.dartnew file mode 100644index 000000000..056463cb4--- /dev/null+++ b/desktop/test/shortcuts_browser_test.dart@@ -0,0 +1,75 @@+import 'package:flutter/material.dart';+import 'package:flutter/services.dart';+import 'package:flutter_test/flutter_test.dart';+import 'package:harness/shortcuts/app_keymap.dart';+import 'package:harness/shortcuts/keyboard_practice.dart';+import 'package:harness/shortcuts/shortcuts_browser.dart';++import 'keymap_host_test.dart' show key;+import 'support/real_fonts.dart';++void main() {+ for (final (size, scale) in [+ (const Size(1000, 700), 1.0),+ (const Size(480, 420), 1.8),+ ]) {+ testWidgets('lazy shortcuts keep keyboard paging visible at $size/$scale', (+ tester,+ ) async {+ await tester.runAsync(loadRealFonts);+ tester.view.physicalSize = size;+ tester.view.devicePixelRatio = 1;+ addTearDown(tester.view.reset);+ final map = AppKeymap();+ addTearDown(map.dispose);+ await tester.pumpWidget(+ MaterialApp(+ builder: (context, child) => MediaQuery(+ data: MediaQuery.of(context)+ .copyWith(textScaler: TextScaler.linear(scale)),+ child: child!,+ ),+ home: KeymapProvider(+ keymap: map,+ child: const Scaffold(body: ShortcutsBrowser(autofocus: true)),+ ),+ ),+ );+ await tester.pumpAndSettle();+ final rows = find.byWidgetPredicate(+ (widget) =>+ widget is Semantics &&+ widget.properties.label?.endsWith('Practice shortcut') == true,+ );+ expect(rows.evaluate().length, lessThan(keyboardLessons(map).length));+ final selected = find.byWidgetPredicate(+ (widget) => widget is Semantics && widget.properties.selected == true,+ );+ // Cross every group in both directions, including rows not built yet.+ for (final direction in [+ LogicalKeyboardKey.pageDown,+ LogicalKeyboardKey.pageUp,+ ]) {+ for (var page = 0; page < 20; page++) {+ await key(tester, direction);+ await tester.pumpAndSettle();+ expect(selected, findsOneWidget);+ final viewport = tester.getRect(find.byType(ListView));+ expect(viewport.contains(tester.getCenter(selected)), isTrue);+ expect(tester.takeException(), isNull);+ }+ }+ await tester.enterText(+ find.byKey(const ValueKey('shortcuts-search')),+ 'clone',+ );+ await tester.pumpAndSettle();+ expect(find.text('Clone Harness'), findsOneWidget);+ await key(tester, LogicalKeyboardKey.arrowDown);+ await key(tester, LogicalKeyboardKey.enter);+ await tester.pumpAndSettle();+ expect(find.byType(KeyboardPractice), findsOneWidget);+ await tester.pumpWidget(const SizedBox());+ });+ }+}diff --git a/docs/performance/screenshots/shortcuts-dark.png b/docs/performance/screenshots/shortcuts-dark.pngnew file mode 100644index 000000000..ea03c1a03Binary files /dev/null and b/docs/performance/screenshots/shortcuts-dark.png differdiff --git a/docs/performance/screenshots/shortcuts-narrow-large.png b/docs/performance/screenshots/shortcuts-narrow-large.pngnew file mode 100644index 000000000..aeaf1e61bBinary files /dev/null and b/docs/performance/screenshots/shortcuts-narrow-large.png differ