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.

Keep resize controls focused during terminal relayout

dee332546f2621d
diff --git a/desktop/lib/widgets/terminal_panel.dart b/desktop/lib/widgets/terminal_panel.dart
index d965875f1..8279cfa3c 100644
--- a/desktop/lib/widgets/terminal_panel.dart
+++ b/desktop/lib/widgets/terminal_panel.dart
@@ -254,7 +254,9 @@ class _TerminalPanelState extends State<TerminalPanel>
_afterTerminalMounted(scrollToEnd: _followTail);
}
if (oldWidget.viewportSize != widget.viewportSize) {
- _afterTerminalMounted(scrollToEnd: _followTail);
+ // Geometry can change while a resize handle or another control owns
+ // the keyboard. Refresh the viewport without claiming input ownership.
+ _afterTerminalMounted(scrollToEnd: _followTail, claimFocus: false);
}
if (widget.focused &&
(!oldWidget.focused || oldWidget.focusRequest != widget.focusRequest)) {
@@ -565,6 +567,7 @@ class _TerminalPanelState extends State<TerminalPanel>
void _afterTerminalMounted({
bool clearSelection = false,
bool scrollToEnd = true,
+ bool claimFocus = true,
int retries = 2,
}) {
WidgetsBinding.instance.addPostFrameCallback((_) {
@@ -576,6 +579,7 @@ class _TerminalPanelState extends State<TerminalPanel>
_afterTerminalMounted(
clearSelection: clearSelection,
scrollToEnd: scrollToEnd,
+ claimFocus: claimFocus,
retries: retries - 1,
);
}
@@ -596,7 +600,7 @@ class _TerminalPanelState extends State<TerminalPanel>
}
// Never over the composer: a rebuild that re-focuses this tile while someone is typing into
// the box would pull the caret out from under them mid-sentence.
- _claimFocus(view);
+ if (claimFocus) _claimFocus(view);
if (_find != null) _onFindChanged();
if (_linkPointerPosition != null) _hoverLink(_linkPointerPosition);
});
diff --git a/desktop/test/swarm_resize_test.dart b/desktop/test/swarm_resize_test.dart
index 5c745e8f2..74cd574ea 100644
--- a/desktop/test/swarm_resize_test.dart
+++ b/desktop/test/swarm_resize_test.dart
@@ -136,6 +136,15 @@ void main() {
greaterThan(before),
);
expect(frames, isEmpty);
+ final resized = tester.getSize(find.byKey(left.cellKey)).width;
+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight);
+ await tester.pump();
+ expect(
+ tester.getSize(find.byKey(left.cellKey)).width,
+ greaterThan(resized),
+ reason: 'Relayout keeps subsequent arrow keys on the resize handle',
+ );
+ expect(frames, isEmpty);
await chord(tester, LogicalKeyboardKey.keyH);
await tester.pump();
expect(app.focusedPaneId, left.id);
diff --git a/desktop/test/terminal_initial_output_test.dart b/desktop/test/terminal_initial_output_test.dart
index 1b43e4990..86a642832 100644
--- a/desktop/test/terminal_initial_output_test.dart
+++ b/desktop/test/terminal_initial_output_test.dart
@@ -193,8 +193,14 @@ void main() {
).widget.scrollController!;
reading.jumpTo(100);
await tester.pump();
- app.setPreset(4, PanePreset.rows);
+ final before = terminalView(tester, sessions.first).renderTerminal.size;
+ app.setPreset(4, PanePreset.mainAndStack);
await tester.pump();
+ expect(app.presetFor(4), PanePreset.mainAndStack);
+ expect(
+ terminalView(tester, sessions.first).renderTerminal.size,
+ isNot(before),
+ );
expect(reading.offset, 100);
for (final session in sessions.skip(1)) {
final scroll = terminalView(tester, session).widget.scrollController!;