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.

Fix Layout keyboard cycling and scaled presentation

deed5756aba2672
diff --git a/desktop/lib/widgets/layout_palette.dart b/desktop/lib/widgets/layout_palette.dart
index 722f17527..2d559fb12 100644
--- a/desktop/lib/widgets/layout_palette.dart
+++ b/desktop/lib/widgets/layout_palette.dart
@@ -5,6 +5,7 @@ import '../shared/theme/app_theme.dart' as grid;
import '../shared/widgets/app_dialog.dart';
import '../state/app_state.dart';
import '../shortcuts/app_keymap.dart';
+import '../shortcuts/keymap.dart';
import '../state/pane_preset.dart';
import '../theme/app_theme.dart';
@@ -75,6 +76,7 @@ int layoutPaletteMove(int at, int n, int dx, int dy, int perRow) {
class _Strip {
/// Wide enough that a diagram stays readable — see the note on the Wrap.
static const shape = 108.0;
+ static const diagram = 86.0;
static const gap = 10.0;
static const sidePadding = 14.0;
@@ -82,8 +84,8 @@ class _Strip {
static double width(int choices) => choices > 3 ? 500 : 420;
/// How many shapes sit on one line. The same arithmetic Wrap does.
- static int perRow(int choices) {
- final room = width(choices) - sidePadding * 2;
+ static int perRow(int choices, double width, double shape) {
+ final room = width - sidePadding * 2;
final fits = ((room + gap) / (shape + gap)).floor();
return fits.clamp(1, choices < 1 ? 1 : choices);
}
@@ -108,6 +110,9 @@ class _LayoutPaletteState extends State<_LayoutPalette> {
/// global binding, while the arrow keys did nothing at all, because those are
/// read HERE and nothing here was listening.
final FocusNode _keys = FocusNode(debugLabel: 'layout-palette');
+ final _shapeKeys = List.generate(6, (_) => GlobalKey());
+ int _perRow = 1;
+ bool _revealPending = false;
@override
void initState() {
@@ -129,12 +134,7 @@ class _LayoutPaletteState extends State<_LayoutPalette> {
super.dispose();
}
- /// One step along the strip — what a SECOND ⌘S does.
- ///
- /// Wraps, unlike the arrow keys, and the difference is deliberate. An arrow is
- /// a direction: running off the end of a strip you can see the ends of reads
- /// as a mis-key. A repeated chord is a CYCLE — nobody holding ⌘S means "stop
- /// at the last one", they mean "show me the next".
+ /// Advance one choice with the configured Layout key, without applying it.
bool _advance() {
if (!mounted || ModalRoute.isCurrentOf(context) == false) return false;
final count = widget.notifier.panes.length;
@@ -143,7 +143,7 @@ class _LayoutPaletteState extends State<_LayoutPalette> {
// presetFor is keyed on the PANE COUNT, not on how many shapes that count
// offers — the two are different numbers and only one of them is a key.
final at = _cursorIn(choices, widget.notifier.presetFor(count));
- setState(() => _cursor = (at + 1) % choices.length);
+ _select((at + 1) % choices.length);
return true;
}
@@ -152,6 +152,24 @@ class _LayoutPaletteState extends State<_LayoutPalette> {
/// still looking at the choices. Applying is Enter, a digit, or a click.
int? _cursor;
+ void _select(int index) {
+ if (_cursor == index) return;
+ setState(() => _cursor = index);
+ if (_revealPending) return;
+ _revealPending = true;
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ _revealPending = false;
+ if (!mounted || ModalRoute.isCurrentOf(context) == false) return;
+ final target = _shapeKeys[_cursor!].currentContext;
+ if (target != null) {
+ Scrollable.ensureVisible(
+ target,
+ alignmentPolicy: ScrollPositionAlignmentPolicy.keepVisibleAtEnd,
+ );
+ }
+ });
+ }
+
/// Where the cursor is, read from state rather than from a captured local.
///
/// Two keys can land inside one frame — an arrow and the Enter that takes it
@@ -175,135 +193,169 @@ class _LayoutPaletteState extends State<_LayoutPalette> {
final choices = PanePreset.forCount(count);
final current = notifier.presetFor(count);
final cursor = _cursorIn(choices, current);
-
- return Dialog(
- backgroundColor: grid.AppGlass.surfaceFill,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(13),
- side: BorderSide(color: grid.AppGlass.hair),
- ),
- child: Focus(
- focusNode: _keys,
- autofocus: true,
- onKeyEvent: (node, event) {
- // Repeats count: holding an arrow should walk the list, the way it
- // does in every other list on this OS.
- if (event is! KeyDownEvent && event is! KeyRepeatEvent) {
- return KeyEventResult.ignored;
- }
- if (choices.isEmpty) return KeyEventResult.ignored;
-
- void apply(PanePreset preset) {
- notifier.setPreset(count, preset);
- Navigator.of(context).pop();
- }
-
- final at = _cursorIn(choices, current);
- final direction = _direction(event.logicalKey);
- if (direction != null) {
- setState(
- () => _cursor = layoutPaletteMove(
- at,
- choices.length,
- direction.$1,
- direction.$2,
- _Strip.perRow(choices.length),
- ),
- );
- return KeyEventResult.handled;
- }
- if (_isCommit(event.logicalKey)) {
- apply(choices[at]);
- return KeyEventResult.handled;
- }
- final index = _digit(event.logicalKey);
- if (index == null || index > choices.length) {
- return KeyEventResult.ignored;
- }
- apply(choices[index - 1]);
- return KeyEventResult.handled;
+ final textScale = MediaQuery.textScalerOf(context).scale(11.5) / 11.5;
+ final shapeWidth = (_Strip.shape * textScale).clamp(_Strip.shape, 216.0);
+ final paletteWidth =
+ _Strip.width(choices.length) * textScale.clamp(1.0, 1.5);
+
+ return KeymapRegion(
+ contextKind: KeymapContext.workspace,
+ actions: {
+ 'pane.layout': () {
+ _advance();
},
- child: ConstrainedBox(
- // Wide enough that four shapes still get a diagram big enough to read
- // and a label that is not ellipsised into a guess.
- constraints: BoxConstraints(maxWidth: choices.length > 3 ? 500 : 420),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- Padding(
- padding: const EdgeInsets.fromLTRB(18, 16, 18, 12),
- child: Text(
- choices.isEmpty ? 'Layout' : 'Layout · $count tiles',
- style: TextStyle(
- color: grid.AppPalette.textSecondary,
- fontSize: 11.5,
- letterSpacing: 0.9,
- fontWeight: grid.AppFont.medium,
- ),
+ },
+ child: Dialog(
+ backgroundColor: grid.AppGlass.surfaceFill,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(13),
+ side: BorderSide(color: grid.AppGlass.hair),
+ ),
+ child: Focus(
+ focusNode: _keys,
+ autofocus: true,
+ onKeyEvent: (node, event) {
+ // Repeats count: holding an arrow should walk the list, the way it
+ // does in every other list on this OS.
+ if (event is! KeyDownEvent && event is! KeyRepeatEvent) {
+ return KeyEventResult.ignored;
+ }
+ // The keymap handles configured chords before this local handler.
+ // Modified digits/arrows must not fall through as a plain selection.
+ final keyboard = HardwareKeyboard.instance;
+ if (keyboard.isMetaPressed ||
+ keyboard.isControlPressed ||
+ keyboard.isAltPressed ||
+ keyboard.isShiftPressed) {
+ return KeyEventResult.ignored;
+ }
+ if (choices.isEmpty) return KeyEventResult.ignored;
+
+ void apply(PanePreset preset) {
+ notifier.setPreset(count, preset);
+ Navigator.of(context).pop();
+ }
+
+ final at = _cursorIn(choices, current);
+ final direction = _direction(event.logicalKey);
+ if (direction != null) {
+ _select(
+ layoutPaletteMove(
+ at,
+ choices.length,
+ direction.$1,
+ direction.$2,
+ _perRow,
),
- ),
- if (choices.isEmpty)
- Padding(
- padding: const EdgeInsets.fromLTRB(18, 0, 18, 20),
- child: Text(
- 'One tile has no layout to choose. Open another and the '
- 'shapes appear here.',
- style: TextStyle(
- color: grid.AppPalette.textFaint,
- fontSize: 12.5,
- height: 1.45,
- ),
- ),
- )
- else ...[
- Padding(
- padding: const EdgeInsets.fromLTRB(
- _Strip.sidePadding,
- 0,
- _Strip.sidePadding,
- 6,
- ),
- // Wrapped, not a Row: a big grid offers five column counts,
- // and five diagrams squeezed across one line are five things
- // nobody can tell apart. 108px keeps a shape readable.
- child: Wrap(
- spacing: _Strip.gap,
- runSpacing: _Strip.gap,
+ );
+ return KeyEventResult.handled;
+ }
+ if (_isCommit(event.logicalKey)) {
+ apply(choices[at]);
+ return KeyEventResult.handled;
+ }
+ final index = _digit(event.logicalKey);
+ if (index == null || index > choices.length) {
+ return KeyEventResult.ignored;
+ }
+ apply(choices[index - 1]);
+ return KeyEventResult.handled;
+ },
+ child: ConstrainedBox(
+ // Wide enough that four shapes still get a diagram big enough to read
+ // and a label that is not ellipsised into a guess.
+ constraints: BoxConstraints(maxWidth: paletteWidth),
+ child: LayoutBuilder(
+ builder: (context, constraints) {
+ // Read the same available width the Wrap uses, including text
+ // scaling and a window narrower than the preferred palette.
+ _perRow = _Strip.perRow(
+ choices.length,
+ constraints.maxWidth,
+ shapeWidth,
+ );
+ return SingleChildScrollView(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- for (var i = 0; i < choices.length; i++)
- SizedBox(
- width: _Strip.shape,
- child: _ShapeButton(
- preset: choices[i],
- count: count,
- index: i + 1,
- selected: choices[i] == current,
- cursor: i == cursor,
- onTap: () {
- notifier.setPreset(count, choices[i]);
- Navigator.of(context).pop();
- },
+ Padding(
+ padding: const EdgeInsets.fromLTRB(18, 16, 18, 12),
+ child: Text(
+ choices.isEmpty ? 'Layout' : 'Layout · $count tiles',
+ style: TextStyle(
+ color: grid.AppPalette.textSecondary,
+ fontSize: 11.5,
+ letterSpacing: 0.9,
+ fontWeight: grid.AppFont.medium,
+ ),
+ ),
+ ),
+ if (choices.isEmpty)
+ Padding(
+ padding: const EdgeInsets.fromLTRB(18, 0, 18, 20),
+ child: Text(
+ 'One tile has no layout to choose. Open another and the '
+ 'shapes appear here.',
+ style: TextStyle(
+ color: grid.AppPalette.textFaint,
+ fontSize: 12.5,
+ height: 1.45,
+ ),
+ ),
+ )
+ else ...[
+ Padding(
+ padding: const EdgeInsets.fromLTRB(
+ _Strip.sidePadding,
+ 0,
+ _Strip.sidePadding,
+ 6,
+ ),
+ // Wrapped, not a Row: a big grid offers five column counts,
+ // and five diagrams squeezed across one line are five things
+ // nobody can tell apart. 108px keeps a shape readable.
+ child: Wrap(
+ spacing: _Strip.gap,
+ runSpacing: _Strip.gap,
+ children: [
+ for (var i = 0; i < choices.length; i++)
+ SizedBox(
+ key: _shapeKeys[i],
+ width: shapeWidth,
+ child: _ShapeButton(
+ preset: choices[i],
+ count: count,
+ index: i + 1,
+ selected: choices[i] == current,
+ cursor: i == cursor,
+ onTap: () {
+ notifier.setPreset(count, choices[i]);
+ Navigator.of(context).pop();
+ },
+ ),
+ ),
+ ],
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.fromLTRB(18, 6, 18, 14),
+ child: Text(
+ 'Arrows to move · Enter or 1–${choices.length} to apply.\n'
+ 'Changing layout resets pane sizes.',
+ style: TextStyle(
+ color: grid.AppPalette.textSecondary,
+ fontSize: 11,
+ height: 1.4,
+ ),
),
),
+ ],
],
),
- ),
- Padding(
- padding: const EdgeInsets.fromLTRB(18, 6, 18, 14),
- child: Text(
- 'Arrows to move, Enter or a number to pick. Changing the '
- 'shape resets the dividers — they described boundaries the '
- 'old one had.',
- style: TextStyle(
- color: grid.AppPalette.textFaint,
- fontSize: 11,
- height: 1.4,
- ),
- ),
- ),
- ],
- ],
+ );
+ },
+ ),
),
),
),
@@ -311,12 +363,6 @@ class _LayoutPaletteState extends State<_LayoutPalette> {
}
/// Which way an arrow moves the cursor.
- ///
- /// Up and left both mean "back" and down and right both mean "forward",
- /// because the shapes WRAP onto more than one line when there are five of
- /// them: a vertical key that only moved between rows would do nothing on a
- /// single-row palette, and stepping by one is the only motion that means the
- /// same thing however the wrap happens to fall.
/// Which way a key points, as (dx, dy).
///
/// hjkl beside the arrows, unmodified, for the reason the window binds both: a
@@ -391,23 +437,29 @@ class _ShapeButton extends StatelessWidget {
: grid.AppSurface.hoverFill,
borderRadius: BorderRadius.circular(10),
border: Border.all(
- color: cursor
- ? AppColors.accent
- : (selected ? AppColors.accent : grid.AppGlass.hair),
- width: cursor ? 2 : 1,
+ color: selected ? AppColors.accent : grid.AppGlass.hair,
),
),
+ // Paint focus over the fixed border so moving the highlight does not
+ // change the diagram's bounds or the height of the wrapped row.
+ foregroundDecoration: cursor
+ ? BoxDecoration(
+ borderRadius: BorderRadius.circular(10),
+ border: Border.all(color: AppColors.accent, width: 2),
+ )
+ : null,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
- AspectRatio(
- aspectRatio: 4 / 3,
+ SizedBox(
+ width: _Strip.diagram,
+ height: _Strip.diagram * 3 / 4,
child: CustomPaint(painter: _ShapePainter(preset, count)),
),
const SizedBox(height: 8),
Text(
preset.label,
- maxLines: 1,
+ maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: selected
@@ -418,14 +470,11 @@ class _ShapeButton extends StatelessWidget {
),
const SizedBox(height: 2),
Text(
- switch (effectiveCommandHint(context, 'pane.layout')) {
- final String hint => '$hint then $index',
- null => '$index',
- },
+ '$index',
style: TextStyle(
fontFamily: grid.AppFont.mono,
fontSize: 9.5,
- color: grid.AppPalette.textFaint,
+ color: grid.AppPalette.textSecondary,
),
),
],
diff --git a/desktop/test/keymap_runtime_test.dart b/desktop/test/keymap_runtime_test.dart
index d9a320dd9..5b962cabe 100644
--- a/desktop/test/keymap_runtime_test.dart
+++ b/desktop/test/keymap_runtime_test.dart
@@ -10,6 +10,7 @@ import 'package:harness/shortcuts/app_keymap.dart';
import 'package:harness/shortcuts/keymap.dart';
import 'package:harness/shortcuts/shortcuts_list.dart';
import 'package:harness/state/app_state.dart';
+import 'package:harness/state/pane_preset.dart';
import 'package:harness/state/swarm_catalog.dart';
import 'package:harness/terminal/terminal_binary.dart';
import 'package:harness/widgets/swarm_switcher.dart';
@@ -70,6 +71,111 @@ Future<void> tabToResult(WidgetTester tester, {String? id}) async {
}
void main() {
+ for (final remapped in [false, true]) {
+ testWidgets(
+ 'the configured Layout key cycles choices and returns to latest output (remapped=$remapped)',
+ (tester) async {
+ final app = createApp();
+ final map = MemoryKeymap();
+ if (remapped) {
+ map.apply('''{"bindings":[
+ {"keys":"cmd+s","command":null},
+ {"keys":"cmd+y","command":"pane.layout"}
+ ]}''');
+ }
+ final firstInput = <TerminalBinaryFrame>[];
+ final secondInput = <TerminalBinaryFrame>[];
+ final first = terminal('a0', firstInput);
+ final second = terminal('a1', secondInput);
+ app.adoptSessionForTest(first);
+ final focused = app.adoptSessionForTest(second);
+ await mount(tester, app, map);
+ for (final session in [first, second]) {
+ session.terminal.write(
+ List.generate(200, (i) => 'Output $i\r\n').join(),
+ );
+ }
+ await tester.pump();
+ final views = tester
+ .widgetList<TerminalView>(find.byType(TerminalView))
+ .toList();
+ for (final view in views) {
+ expect(
+ view.scrollController!.position.maxScrollExtent,
+ greaterThan(0),
+ );
+ view.scrollController!.jumpTo(0);
+ }
+ await tester.pump();
+ final before = app.presetFor(2);
+ final shortcut = remapped
+ ? LogicalKeyboardKey.keyY
+ : LogicalKeyboardKey.keyS;
+ await key(tester, shortcut, cmd: true);
+ await tester.pumpAndSettle();
+ if (remapped) await key(tester, LogicalKeyboardKey.keyS, cmd: true);
+ // Fast repeated chords can arrive before the next rendered frame.
+ await tester.sendKeyDownEvent(LogicalKeyboardKey.metaLeft);
+ await tester.sendKeyEvent(shortcut);
+ await tester.sendKeyEvent(shortcut);
+ await tester.sendKeyUpEvent(LogicalKeyboardKey.metaLeft);
+ await tester.pump();
+ expect(find.byType(Dialog), findsOneWidget);
+ expect(app.presetFor(2), before);
+ expect(app.focusedPane, same(focused));
+ for (final view in views) {
+ expect(view.scrollController!.offset, 0);
+ }
+ await key(tester, LogicalKeyboardKey.enter);
+ await tester.pumpAndSettle();
+ expect(app.presetFor(2), PanePreset.rows);
+ expect(find.byType(Dialog), findsNothing);
+ for (final view in views) {
+ expect(
+ view.scrollController!.offset,
+ view.scrollController!.position.maxScrollExtent,
+ );
+ }
+ expect(firstInput, isEmpty);
+ expect(secondInput, isEmpty);
+ await key(tester, LogicalKeyboardKey.arrowLeft);
+ expect(firstInput, isEmpty);
+ expect(secondInput.single.bytes, [27, 91, 68]);
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ map.dispose();
+ },
+ );
+ }
+
+ testWidgets('modified layout digits do not confirm a shape', (tester) async {
+ final app = createApp();
+ final map = MemoryKeymap();
+ app.adoptSessionForTest(terminal('a0', []));
+ app.adoptSessionForTest(terminal('a1', []));
+ await mount(tester, app, map);
+ final before = app.presetFor(2);
+ await key(tester, LogicalKeyboardKey.keyS, cmd: true);
+ await tester.pumpAndSettle();
+ for (final modifier in ['cmd', 'ctrl', 'alt', 'shift']) {
+ await key(
+ tester,
+ LogicalKeyboardKey.digit3,
+ cmd: modifier == 'cmd',
+ ctrl: modifier == 'ctrl',
+ alt: modifier == 'alt',
+ shift: modifier == 'shift',
+ );
+ expect(find.byType(Dialog), findsOneWidget);
+ expect(app.presetFor(2), before);
+ }
+ await key(tester, LogicalKeyboardKey.escape);
+ await tester.pumpAndSettle();
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ map.dispose();
+ });
+
testWidgets('Command-T opens New Tab and Command-S opens Layout', (
tester,
) async {
diff --git a/desktop/test/layout_palette_render_test.dart b/desktop/test/layout_palette_render_test.dart
new file mode 100644
index 000000000..d31b1c9ee
--- /dev/null
+++ b/desktop/test/layout_palette_render_test.dart
@@ -0,0 +1,111 @@
+import 'dart:io';
+import 'dart:ui' as ui;
+
+import 'package:flutter/material.dart';
+import 'package:flutter/rendering.dart';
+import 'package:flutter/services.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/auth/auth_session.dart';
+import 'package:harness/core/config.dart';
+import 'package:harness/shared/theme/app_theme.dart' as grid;
+import 'package:harness/state/app_state.dart';
+import 'package:harness/state/pane_preset.dart';
+import 'package:harness/state/terminal_pane.dart';
+import 'package:harness/widgets/layout_palette.dart';
+
+import 'support/real_fonts.dart';
+
+void main() {
+ setUpAll(loadRealFonts);
+ for (final scale in [1.0, 2.0]) {
+ testWidgets('Layout choices fit the minimum window at text scale $scale', (
+ tester,
+ ) async {
+ tester.view.devicePixelRatio = 1;
+ tester.view.physicalSize = const Size(880, 560);
+ addTearDown(tester.view.reset);
+ final app = AppNotifier(
+ config: AppConfig.dev,
+ authSession: AuthSession(),
+ configStore: null,
+ );
+ for (var i = 0; i < 5; i++) {
+ app.panes.add(TerminalPane(id: i, machineId: 'm', agentId: 'a$i'));
+ }
+ final capture = GlobalKey();
+ await tester.pumpWidget(
+ RepaintBoundary(
+ key: capture,
+ child: MaterialApp(
+ debugShowCheckedModeBanner: false,
+ theme: grid.buildAppTheme(brightness: Brightness.dark),
+ builder: (context, child) => MediaQuery(
+ data: MediaQuery.of(context)
+ .copyWith(textScaler: TextScaler.linear(scale)),
+ child: child!,
+ ),
+ home: Scaffold(
+ backgroundColor: grid.AppPalette.swarmField,
+ body: Builder(
+ builder: (context) => TextButton(
+ onPressed: () => showLayoutPalette(context, app),
+ child: const Text('Layout'),
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ await tester.tap(find.text('Layout'));
+ await tester.pumpAndSettle();
+ final output = Platform.environment['HARNESS_LAYOUT_CAPTURE_DIR'];
+ if (output != null) {
+ final boundary =
+ capture.currentContext!.findRenderObject()!
+ as RenderRepaintBoundary;
+ await tester.runAsync(() async {
+ final image = await boundary.toImage(pixelRatio: 1);
+ final bytes = await image.toByteData(format: ui.ImageByteFormat.png);
+ await Directory(output).create(recursive: true);
+ await File('$output/layout-880-$scale.png')
+ .writeAsBytes(bytes!.buffer.asUint8List());
+ image.dispose();
+ });
+ }
+ expect(tester.takeException(), isNull);
+ final choices = PanePreset.forCount(5);
+ Rect card(PanePreset preset) => tester.getRect(
+ find.ancestor(
+ of: find.text(preset.label),
+ matching: find.byType(Container),
+ ),
+ );
+ for (final preset in choices) {
+ expect(find.text(preset.label).hitTestable(), findsOneWidget);
+ expect(
+ tester
+ .renderObject<RenderParagraph>(find.text(preset.label))
+ .didExceedMaxLines,
+ isFalse,
+ );
+ }
+ final first = card(choices.first);
+ final below = choices.firstWhere((preset) {
+ final rect = card(preset);
+ return rect.top > first.top && (rect.left - first.left).abs() < 1;
+ });
+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
+ await tester.sendKeyEvent(LogicalKeyboardKey.enter);
+ await tester.pumpAndSettle();
+ expect(
+ app.presetFor(5),
+ below,
+ reason: 'Down follows the row actually drawn below',
+ );
+ expect(find.byType(Dialog), findsNothing);
+ expect(tester.takeException(), isNull);
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ });
+ }
+}
diff --git a/desktop/test/layout_palette_test.dart b/desktop/test/layout_palette_test.dart
index 63896b780..59c0c8e3f 100644
--- a/desktop/test/layout_palette_test.dart
+++ b/desktop/test/layout_palette_test.dart
@@ -109,6 +109,28 @@ void main() {
expect(find.byType(Dialog), findsOneWidget, reason: 'still open');
});
+ testWidgets('moving the layout highlight keeps the diagrams in place', (
+ tester,
+ ) async {
+ final notifier = await _open(tester);
+ final choices = PanePreset.forCount(3);
+ List<Rect> rectangles() => [
+ for (final choice in choices)
+ tester.getRect(
+ find.ancestor(
+ of: find.text(choice.label),
+ matching: find.byType(Container),
+ ),
+ ),
+ ];
+ final before = rectangles();
+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight);
+ await tester.pump();
+ expect(rectangles(), before);
+ await tester.pumpWidget(const SizedBox());
+ notifier.dispose();
+ });
+
testWidgets('Enter takes the shape the arrows landed on', (tester) async {
final notifier = await _open(tester);
final choices = PanePreset.forCount(3);
diff --git a/docs/harness-agent-first-tabs.md b/docs/harness-agent-first-tabs.md
index ea00f7ead..c197667b6 100644
--- a/docs/harness-agent-first-tabs.md
+++ b/docs/harness-agent-first-tabs.md
@@ -80,6 +80,12 @@ name filled in; no agent is opened until the user chooses a result.
**Cmd-T** opens the start page, **Cmd-N** opens New Harness
directly, and **Cmd-O** finds an existing harness. **Cmd-S** opens Layout.
+Pressing the configured Layout key again cycles choices without applying them;
+Enter applies the highlighted choice and Escape cancels. Plain digits choose
+directly, while modified digits and arrows cannot accidentally apply a shape.
+Layout cards keep fixed diagram bounds as the highlight moves. Larger text gets
+wider cards and readable labels, with arrow navigation following the rendered
+rows and scrolling the selected choice into view when necessary.
**Cmd-H/J/K/L** and **Cmd-arrows** focus panes; **Shift-Cmd-arrows** move them.
**Cmd-1…Cmd-9** select tabs in their visible order; missing numbers do nothing.
Cmd-W closes the tab, Shift-Cmd-W closes the focused pane, and Shift-Cmd-T
diff --git a/docs/harness-v2-handoff.md b/docs/harness-v2-handoff.md
index 53011d3c9..b7bc2776e 100644
--- a/docs/harness-v2-handoff.md
+++ b/docs/harness-v2-handoff.md
@@ -1,5 +1,27 @@
# Harness v2: goal, plan, and continuation handoff
+**Layout keyboard and rendering correction:** The current workspace keymap blocked
+a second Layout chord once the dialog opened, and Cmd-number fell through as a
+plain layout choice. Layout now owns its configured cycling command while other
+workspace actions stay blocked; modified digits/arrows do not choose a shape.
+Fast repeated chords within a frame are covered. Confirmation retains the selected
+agent, reveals the latest output in both panes, and returns the next key to that
+agent without input leaking during selection.
+
+The highlight no longer changes card/diagram bounds. An 880×560 render with 2×
+text reproduced a 27-pixel overflow and truncated labels. Cards and the dialog
+now expand with text, arrow steps use the actual wrapped columns, and the selected
+choice stays scroll-reachable. Repeated shortcut text is replaced by readable
+choice numbers and shorter instructions. Normal and 2× current renders were
+inspected in `/private/tmp/harness-layout-captures-final/`; all **56 affected checks**
+pass in `/private/tmp/harness-layout-final-checks.log`. Analysis of all four changed
+source/test files is clean in `/private/tmp/harness-layout-final-analyze.log`.
+The full desktop suite passes **1,426 checks**, with one optional media placeholder
+skipped, in `/private/tmp/harness-layout-final-full.log`. These are headless renders
+with metric-compatible fonts, not native platform or latency qualification.
+The build refresh is pending; the prepared preview below predates this correction
+and the running preview is unchanged while the console is locked.
+
**Picker focus correction:** `0c240dd` is pushed. Tab could move from the search field into a result,
outside its shortcut scope. Both Cmd-N and the native New Harness action then
left the inline results underneath creation. The whole input/results surface now