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.

Give terminal Find input before its first frame

deedff8dfb1123b
diff --git a/desktop/lib/widgets/terminal_find_bar.dart b/desktop/lib/widgets/terminal_find_bar.dart
index e7a03d0a1..c155dbde3 100644
--- a/desktop/lib/widgets/terminal_find_bar.dart
+++ b/desktop/lib/widgets/terminal_find_bar.dart
@@ -11,9 +11,15 @@ class TerminalFindBar extends StatefulWidget {
required this.onStep,
required this.onClose,
required this.onFocus,
+ this.initialQuery = '',
+ this.initialCaseSensitive = false,
this.readOnly = false,
});
- final TerminalSearch search;
+
+ /// Null while the focused pane keeps its input ready without a search index.
+ final TerminalSearch? search;
+ final String initialQuery;
+ final bool initialCaseSensitive;
final void Function(String query, bool caseSensitive) onQuery;
final ValueChanged<int> onStep;
final VoidCallback onClose;
@@ -25,23 +31,54 @@ class TerminalFindBar extends StatefulWidget {
}
class TerminalFindBarState extends State<TerminalFindBar> {
+ static final _idle = Listenable.merge(const []);
+ final _scope = FocusScopeNode(debugLabel: 'Terminal Find');
final _focus = FocusNode(debugLabel: 'Find in terminal');
- late final _text = TextEditingController(text: widget.search.query);
+ late final _text = TextEditingController(
+ text: widget.search?.query ?? widget.initialQuery,
+ );
+ // Keys can arrive before the widget receives the newly opened search.
+ TerminalSearch? _activeSearch;
@override
void initState() {
super.initState();
+ _activeSearch = widget.search;
+ _setActive(widget.search != null);
_focus.addListener(_onFocus);
WidgetsBinding.instance.addPostFrameCallback((_) {
- if (mounted) focusSearch();
+ if (mounted && widget.search != null) focusSearch();
});
}
+ @override
+ void didUpdateWidget(TerminalFindBar oldWidget) {
+ super.didUpdateWidget(oldWidget);
+ _activeSearch = widget.search;
+ _setActive(widget.search != null);
+ if (widget.search == null && _text.text != widget.initialQuery) {
+ _text.text = widget.initialQuery;
+ }
+ }
+
+ void _setActive(bool active) {
+ _scope.canRequestFocus = active;
+ _scope.descendantsAreFocusable = active;
+ _scope.descendantsAreTraversable = active;
+ }
+
+ void releaseSearchFocus() {
+ _activeSearch = null;
+ _setActive(false);
+ }
+
void _onFocus() {
if (_focus.hasFocus) widget.onFocus();
}
- void focusSearch({bool selectAll = true}) {
+ void focusSearch({bool selectAll = true, TerminalSearch? search}) {
+ _activeSearch = search ?? widget.search ?? _activeSearch;
+ _setActive(true);
_focus.requestFocus();
if (selectAll) {
_text.selection = TextSelection(
@@ -86,13 +123,14 @@ class TerminalFindBarState extends State<TerminalFindBar> {
void dispose() {
_focus.removeListener(_onFocus);
_focus.dispose();
+ _scope.dispose();
_text.dispose();
super.dispose();
}
@override
- Widget build(BuildContext context) => Focus(
- canRequestFocus: false,
+ Widget build(BuildContext context) => FocusScope(
+ node: _scope,
onKeyEvent: _onKeyEvent,
child: Material(
color: const Color(0xff272727),
@@ -103,14 +141,15 @@ class TerminalFindBarState extends State<TerminalFindBar> {
child: Padding(
padding: const EdgeInsets.only(left: 10, right: 4, top: 2, bottom: 2),
child: ListenableBuilder(
- listenable: widget.search,
+ listenable: widget.search ?? _idle,
// Live output and result navigation update the controls, not the
// editor. Keep its widget stable while the search index refreshes.
child: Expanded(
+ key: const ValueKey('terminal-find-editor'),
child: TextField(
controller: _text,
focusNode: _focus,
- autofocus: true,
+ autofocus: widget.search != null,
textAlignVertical: TextAlignVertical.center,
style: const TextStyle(
fontSize: 13,
@@ -129,17 +168,26 @@ class TerminalFindBarState extends State<TerminalFindBar> {
filled: false,
contentPadding: EdgeInsets.zero,
),
- onChanged: (value) =>
- widget.onQuery(value, widget.search.caseSensitive),
+ onChanged: (value) => widget.onQuery(
+ value,
+ _activeSearch?.caseSensitive ?? widget.initialCaseSensitive,
+ ),
),
),
builder: (context, editor) {
final search = widget.search;
- final status = search.query.isEmpty
+ final query = search?.query ?? '';
+ final searching = search?.searching ?? false;
+ final hasSnapshot = search?.hasSnapshot ?? false;
+ final count = search?.count ?? 0;
+ final selected = (search?.selected ?? -1) + 1;
+ final sensitive =
+ search?.caseSensitive ?? widget.initialCaseSensitive;
+ final status = query.isEmpty
? ''
- : search.searching && !search.hasSnapshot
+ : searching && !hasSnapshot
? '…'
- : '${search.selected + 1}/${search.count}';
+ : '$selected/$count';
Widget button(
String label,
Widget icon,
@@ -180,13 +228,13 @@ class TerminalFindBarState extends State<TerminalFindBar> {
const SizedBox(width: 6),
Semantics(
liveRegion: true,
- label: search.searching && !search.hasSnapshot
+ label: searching && !hasSnapshot
? 'Searching terminal'
- : search.query.isEmpty
+ : query.isEmpty
? 'Find in terminal'
- : search.count == 0
+ : count == 0
? 'No matches'
- : 'Match ${search.selected + 1} of ${search.count}',
+ : 'Match $selected of $count',
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 56),
child: ExcludeSemantics(
@@ -197,10 +245,7 @@ class TerminalFindBarState extends State<TerminalFindBar> {
style: TextStyle(
fontSize: 11,
height: 1,
- color:
- search.count == 0 &&
- search.query.isNotEmpty &&
- !search.searching
+ color: count == 0 && query.isNotEmpty && !searching
? const Color(0xffffb4a9)
: Colors.white54,
),
@@ -216,24 +261,26 @@ class TerminalFindBarState extends State<TerminalFindBar> {
style: TextStyle(
fontSize: 12,
height: 1,
- color: search.caseSensitive
- ? Colors.white
- : Colors.white54,
- fontWeight: search.caseSensitive
+ color: sensitive ? Colors.white : Colors.white54,
+ fontWeight: sensitive
? FontWeight.w700
: FontWeight.normal,
),
),
() {
- widget.onQuery(_text.text, !search.caseSensitive);
+ widget.onQuery(
+ _text.text,
+ !(_activeSearch?.caseSensitive ??
+ widget.initialCaseSensitive),
+ );
_focus.requestFocus();
},
- selected: search.caseSensitive,
+ selected: sensitive,
),
button(
'Previous match (⇧⌘G)',
const Icon(Icons.keyboard_arrow_up),
- search.count > 0
+ count > 0
? () {
widget.onStep(-1);
_focus.requestFocus();
@@ -243,7 +290,7 @@ class TerminalFindBarState extends State<TerminalFindBar> {
button(
'Next match (⌘G)',
const Icon(Icons.keyboard_arrow_down),
- search.count > 0
+ count > 0
? () {
widget.onStep(1);
_focus.requestFocus();
diff --git a/desktop/lib/widgets/terminal_panel.dart b/desktop/lib/widgets/terminal_panel.dart
index cd7a27732..f92251b8d 100644
--- a/desktop/lib/widgets/terminal_panel.dart
+++ b/desktop/lib/widgets/terminal_panel.dart
@@ -652,6 +652,7 @@ class _TerminalPanelState extends State<TerminalPanel>
..addListener(_onFindChanged);
_findRevealPending = true;
_find!.setQuery(_lastFindQuery, caseSensitive: _lastFindCaseSensitive);
+ _findBarKey.currentState?.focusSearch(search: _find);
setState(() {});
} else if (action == TerminalFindAction.open) {
_findBarKey.currentState?.focusSearch();
@@ -746,6 +747,7 @@ class _TerminalPanelState extends State<TerminalPanel>
_lastFindBuffer = _viewTerminal.buffer;
}
_find = null;
+ _findBarKey.currentState?.releaseSearchFocus();
search.removeListener(_onFindChanged);
search.dispose();
_clearFindHighlight();
@@ -1112,50 +1114,57 @@ class _TerminalPanelState extends State<TerminalPanel>
maintainState: true,
child: _buildHeader(context),
),
- if (_find != null)
+ // Attach the focused pane's input before Find is requested.
+ // Hidden/unfocused panes need no dormant editor or index.
+ if (_find != null || (widget.visible && widget.focused))
Positioned.fill(
- child: LayoutBuilder(
- builder: (context, constraints) => Row(
- children: [
- if (constraints.maxWidth > 520)
- Expanded(
+ child: Offstage(
+ offstage: _find == null,
+ child: LayoutBuilder(
+ builder: (context, constraints) => Row(
+ children: [
+ if (constraints.maxWidth > 520)
+ Expanded(
+ child: Padding(
+ padding: const EdgeInsets.symmetric(
+ horizontal: _stripPadding,
+ ),
+ child: Text(
+ session.agentName,
+ maxLines: 1,
+ overflow: TextOverflow.ellipsis,
+ style: const TextStyle(
+ fontSize: 13,
+ color: Colors.white70,
+ ),
+ ),
+ ),
+ )
+ else
+ const Spacer(),
+ SizedBox(
+ width: math.min(constraints.maxWidth, 380),
child: Padding(
padding: const EdgeInsets.symmetric(
- horizontal: _stripPadding,
+ horizontal: 6,
+ vertical: 4,
),
- child: Text(
- session.agentName,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: const TextStyle(
- fontSize: 13,
- color: Colors.white70,
- ),
+ child: TerminalFindBar(
+ key: _findBarKey,
+ search: _find,
+ initialQuery: _lastFindQuery,
+ initialCaseSensitive: _lastFindCaseSensitive,
+ readOnly:
+ widget.readOnly || !session.acceptsInput,
+ onQuery: _queryFind,
+ onStep: _stepFind,
+ onClose: _closeFind,
+ onFocus: () => widget.onRendererFocus?.call(),
),
),
- )
- else
- const Spacer(),
- SizedBox(
- width: math.min(constraints.maxWidth, 380),
- child: Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: 6,
- vertical: 4,
- ),
- child: TerminalFindBar(
- key: _findBarKey,
- search: _find!,
- readOnly:
- widget.readOnly || !session.acceptsInput,
- onQuery: _queryFind,
- onStep: _stepFind,
- onClose: _closeFind,
- onFocus: () => widget.onRendererFocus?.call(),
- ),
),
- ),
- ],
+ ],
+ ),
),
),
),
diff --git a/desktop/test/swarm_interactions_test.dart b/desktop/test/swarm_interactions_test.dart
index a8809cd00..60ab24b64 100644
--- a/desktop/test/swarm_interactions_test.dart
+++ b/desktop/test/swarm_interactions_test.dart
@@ -406,7 +406,7 @@ void main() {
await tester.pump(const Duration(milliseconds: 10));
final search = tester
.widget<TerminalFindBar>(find.byType(TerminalFindBar))
- .search;
+ .search!;
expect(search.count, 2);
await native('findNext');
await tester.pump();
diff --git a/desktop/test/terminal_find_test.dart b/desktop/test/terminal_find_test.dart
index 9784b91b0..4ceb12927 100644
--- a/desktop/test/terminal_find_test.dart
+++ b/desktop/test/terminal_find_test.dart
@@ -11,6 +11,7 @@ import 'package:harness/widgets/terminal_find_bar.dart';
import 'package:xterm/xterm.dart';
import 'swarm_interactions_test.dart' show chord;
+import 'keymap_runtime_test.dart' show native;
import 'swarm_screen_test.dart' show mount, terminal;
import 'swarm_state_test.dart' show createApp;
@@ -24,7 +25,7 @@ Future<void> finishFind(WidgetTester tester) async {
await tester.pump(const Duration(milliseconds: 1));
if (!tester
.widget<TerminalFindBar>(find.byType(TerminalFindBar))
- .search
+ .search!
.searching) {
return;
}
@@ -58,6 +59,177 @@ Future<void> output(
);
void main() {
+ for (final nativeEntry in [false, true]) {
+ testWidgets(
+ 'opening Find owns input before its first frame (native=$nativeEntry)',
+ (tester) async {
+ final app = createApp();
+ app.machineStates['m']!.nodeOnline = true;
+ final input = <TerminalBinaryFrame>[];
+ final session = terminal('a0', input);
+ await output(session, 0, 'first marker\r\n', keyframe: true);
+ app.adoptSessionForTest(session);
+ try {
+ await mount(tester, app, nativeTabs: nativeEntry);
+ if (nativeEntry) {
+ await native(tester, 'findTerminal');
+ } else {
+ await tester.sendKeyDownEvent(LogicalKeyboardKey.meta);
+ await tester.sendKeyEvent(LogicalKeyboardKey.keyF);
+ await tester.sendKeyUpEvent(LogicalKeyboardKey.meta);
+ }
+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowLeft);
+ tester.testTextInput.enterText('marker');
+ await tester.pump();
+ await finishFind(tester);
+ expect(input, isEmpty);
+ expect(
+ tester.widget<TextField>(findField).controller!.text,
+ 'marker',
+ );
+ expect(
+ tester.widget<TextField>(findField).focusNode!.hasFocus,
+ isTrue,
+ );
+ expect(
+ tester
+ .widget<TerminalFindBar>(find.byType(TerminalFindBar))
+ .search!
+ .count,
+ 1,
+ );
+ } finally {
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ }
+ },
+ );
+ }
+
+ testWidgets('Find can close before its first frame without sending Escape', (
+ tester,
+ ) async {
+ final app = createApp();
+ app.machineStates['m']!.nodeOnline = true;
+ final input = <TerminalBinaryFrame>[];
+ final session = terminal('a0', input);
+ await output(session, 0, 'first marker\r\n', keyframe: true);
+ app.adoptSessionForTest(session);
+ try {
+ await mount(tester, app);
+ await tester.sendKeyDownEvent(LogicalKeyboardKey.meta);
+ await tester.sendKeyEvent(LogicalKeyboardKey.keyF);
+ await tester.sendKeyUpEvent(LogicalKeyboardKey.meta);
+ await tester.sendKeyEvent(LogicalKeyboardKey.escape);
+ await tester.pump();
+ expect(input, isEmpty);
+ expect(findField, findsNothing);
+ await tester.sendKeyEvent(LogicalKeyboardKey.arrowLeft);
+ await tester.pump(const Duration(milliseconds: 10));
+ expect(input.single.bytes, [27, 91, 68]);
+ } finally {
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ }
+ });
+
+ testWidgets('Find preserves composition started before its first frame', (
+ tester,
+ ) async {
+ final app = createApp();
+ app.machineStates['m']!.nodeOnline = true;
+ final input = <TerminalBinaryFrame>[];
+ final session = terminal('a0', input);
+ await output(session, 0, '日本語\r\n', keyframe: true);
+ app.adoptSessionForTest(session);
+ try {
+ await mount(tester, app);
+ await tester.sendKeyDownEvent(LogicalKeyboardKey.meta);
+ await tester.sendKeyEvent(LogicalKeyboardKey.keyF);
+ await tester.sendKeyUpEvent(LogicalKeyboardKey.meta);
+ const editing = TextEditingValue(
+ text: '日本',
+ selection: TextSelection.collapsed(offset: 2),
+ composing: TextRange(start: 0, end: 2),
+ );
+ tester.testTextInput.updateEditingValue(editing);
+ expect(await tester.sendKeyEvent(LogicalKeyboardKey.escape), isFalse);
+ await tester.pump();
+ await finishFind(tester);
+ expect(input, isEmpty);
+ expect(tester.widget<TextField>(findField).controller!.value, editing);
+ expect(tester.widget<TextField>(findField).focusNode!.hasFocus, isTrue);
+ } finally {
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ }
+ });
+
+ testWidgets('only the focused pane prepares an idle Find editor', (
+ tester,
+ ) async {
+ final app = createApp();
+ app.machineStates['m']!.nodeOnline = true;
+ final sessions = <TerminalSession>[];
+ final input = <TerminalBinaryFrame>[];
+ for (var workspace = 0; workspace < 4; workspace++) {
+ if (workspace > 0) app.newSwarm();
+ for (var pane = 0; pane < 4; pane++) {
+ final session = terminal('a${workspace * 4 + pane}', input);
+ await output(session, 0, 'first marker\r\n', keyframe: true);
+ sessions.add(session);
+ app.adoptSessionForTest(session);
+ }
+ }
+ final previousObserver = debugOnRebuildDirtyWidget;
+ try {
+ await mount(tester, app);
+ for (final workspace in app.swarms) {
+ app.selectSwarm(workspace.id);
+ await tester.pump();
+ }
+ await tester.pump();
+ expect(find.byType(TerminalView, skipOffstage: false), findsNWidgets(16));
+ final bars = find.byType(TerminalFindBar, skipOffstage: false);
+ expect(bars, findsOneWidget);
+ expect(tester.widget<TerminalFindBar>(bars).search, isNull);
+ final editor = find.descendant(
+ of: bars,
+ matching: find.byType(TextField, skipOffstage: false),
+ skipOffstage: false,
+ );
+ expect(
+ tester.widget<TextField>(editor).focusNode!.canRequestFocus,
+ isFalse,
+ );
+ final focus = FocusManager.instance.primaryFocus;
+ var builds = 0;
+ debugOnRebuildDirtyWidget = (element, _) {
+ if (element.widget is TextField || element.widget is TerminalFindBar) {
+ builds++;
+ }
+ };
+ for (final session in sessions) {
+ await output(session, 1, 'later marker\r\n');
+ await tester.pump();
+ }
+ debugOnRebuildDirtyWidget = previousObserver;
+ expect(builds, 0);
+ expect(FocusManager.instance.primaryFocus, same(focus));
+ expect(input, isEmpty);
+ expect(tester.widget<TerminalFindBar>(bars).search, isNull);
+ app.focusPane(app.panes.first.id);
+ await tester.pump();
+ await tester.pump();
+ expect(bars, findsOneWidget);
+ expect(tester.widget<TerminalFindBar>(bars).search, isNull);
+ } finally {
+ debugOnRebuildDirtyWidget = previousObserver;
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ }
+ });
+
for (final closeWithEscape in [true, false]) {
testWidgets(
'closing Find returns the next key before a frame (Escape=$closeWithEscape)',
@@ -87,12 +259,17 @@ void main() {
await tester.pump(const Duration(milliseconds: 10));
expect(findField, findsNothing);
expect(view.renderTerminal, same(renderer));
+ expect(input.expand((frame) => frame.bytes).toList(), [
+ 27,
+ 91,
+ 68,
+ ...utf8.encode('resume'),
+ ]);
+ await chord(tester, LogicalKeyboardKey.keyF);
expect(
- input.expand((frame) => frame.bytes).toList(),
- [27, 91, 68, ...utf8.encode('resume')],
+ tester.widget<TextField>(findField).controller!.text,
+ 'marker',
);
- await chord(tester, LogicalKeyboardKey.keyF);
- expect(tester.widget<TextField>(findField).controller!.text, 'marker');
} finally {
await tester.pumpWidget(const SizedBox());
app.dispose();
@@ -162,7 +339,7 @@ void main() {
final field = tester.widget<TextField>(findField);
final search = tester
.widget<TerminalFindBar>(find.byType(TerminalFindBar))
- .search;
+ .search!;
final selected = search.match;
final view = terminalView(tester, session);
final renderer = view.renderTerminal;
@@ -221,7 +398,7 @@ void main() {
await finishFind(tester);
final search = tester
.widget<TerminalFindBar>(find.byType(TerminalFindBar))
- .search;
+ .search!;
final controller = tester.widget<TextField>(findField).controller!;
final selected = search.selected;
controller.value = controller.value.copyWith(
@@ -369,7 +546,7 @@ void main() {
await finishFind(tester);
final search = tester
.widget<TerminalFindBar>(find.byType(TerminalFindBar))
- .search;
+ .search!;
expect(search.count, 4);
expect(search.selected, 1);
expect(controller.highlights, hasLength(1));
@@ -398,7 +575,7 @@ void main() {
expect(
tester
.widget<TerminalFindBar>(find.byType(TerminalFindBar))
- .search
+ .search!
.selected,
3,
);
@@ -436,7 +613,7 @@ void main() {
await finishFind(tester);
final search = tester
.widget<TerminalFindBar>(find.byType(TerminalFindBar))
- .search;
+ .search!;
expect(search.count, 1);
app.newSwarm();
app.adoptSessionForTest(b);
@@ -472,7 +649,12 @@ void main() {
await finishFind(tester);
final old = session.terminal;
final text = tester.widget<TextField>(findField).controller!;
- text.selection = const TextSelection.collapsed(offset: 3);
+ text.value = text.value.copyWith(
+ selection: const TextSelection.collapsed(offset: 3),
+ composing: const TextRange(start: 0, end: 6),
+ );
+ await tester.pump();
+ final editing = text.value;
await output(
session,
10,
@@ -483,12 +665,12 @@ void main() {
await finishFind(tester);
expect(session.terminal, isNot(same(old)));
expect(tester.widget<TextField>(findField).controller, same(text));
- expect(text.selection, const TextSelection.collapsed(offset: 3));
+ expect(text.value, editing);
expect(tester.widget<TextField>(findField).focusNode!.hasFocus, isTrue);
expect(
tester
.widget<TerminalFindBar>(find.byType(TerminalFindBar))
- .search
+ .search!
.count,
2,
);
@@ -497,7 +679,7 @@ void main() {
expect(
tester
.widget<TerminalFindBar>(find.byType(TerminalFindBar))
- .search
+ .search!
.count,
1,
);
@@ -526,7 +708,7 @@ void main() {
await finishFind(tester);
final search = tester
.widget<TerminalFindBar>(find.byType(TerminalFindBar))
- .search;
+ .search!;
expect(search.count, 1);
await tester.tap(find.byTooltip('Match case'));
await finishFind(tester);
diff --git a/desktop/test/terminal_offline_view_test.dart b/desktop/test/terminal_offline_view_test.dart
index 398993c1b..a546386b6 100644
--- a/desktop/test/terminal_offline_view_test.dart
+++ b/desktop/test/terminal_offline_view_test.dart
@@ -50,7 +50,7 @@ void main() {
expect(
tester
.widget<TerminalFindBar>(find.byType(TerminalFindBar))
- .search
+ .search!
.count,
180,
);
diff --git a/desktop/test/terminal_reconnect_view_test.dart b/desktop/test/terminal_reconnect_view_test.dart
index c899a8cb8..d41021c45 100644
--- a/desktop/test/terminal_reconnect_view_test.dart
+++ b/desktop/test/terminal_reconnect_view_test.dart
@@ -194,7 +194,7 @@ void main() {
field.selection = const TextSelection.collapsed(offset: 3);
final search = tester
.widget<TerminalFindBar>(find.byType(TerminalFindBar))
- .search;
+ .search!;
final matchedRow = search.match!.begin.y;
final matchedText = session.terminal.buffer.lines[matchedRow].getText();
final before = session.terminal;
@@ -234,7 +234,7 @@ void main() {
expect(terminalView(tester, session), same(renderer));
final restored = tester
.widget<TerminalFindBar>(find.byType(TerminalFindBar))
- .search;
+ .search!;
expect(
session.terminal.buffer.lines[restored.match!.begin.y].getText(),
matchedText,
diff --git a/docs/harness-agent-first-tabs.md b/docs/harness-agent-first-tabs.md
index 39cc87de2..953a4ee34 100644
--- a/docs/harness-agent-first-tabs.md
+++ b/docs/harness-agent-first-tabs.md
@@ -129,6 +129,10 @@ output without scheduling paints. Regression fixtures cover delayed history and
reconnects for local and remote sessions, multi-pane resize, retained-pane reuse,
hidden output, and input arriving between output and the next layout.
+Find takes keyboard and text input as soon as its shortcut or native action is
+invoked, including before its first frame. Only a focused, visible pane prepares
+a dormant editor; it stays hidden and unfocusable, with no search index, until
+requested. Immediate text, composition and Escape belong to Find, not the agent.
Closing Find returns keyboard and text input to the retained terminal or visible
message composer immediately, without waiting for another frame. The next key
cannot be lost in the closing search field or replace its remembered query.
diff --git a/docs/harness-v2-performance.md b/docs/harness-v2-performance.md
index 238b86bff..6f7c3c863 100644
--- a/docs/harness-v2-performance.md
+++ b/docs/harness-v2-performance.md
@@ -12,6 +12,29 @@ It prints `SWARM_BENCH` JSON records. Its filename deliberately does not end in
## Current continuation benchmark (2026-09-14)
+### Find takes input before its first frame
+
+The first-frame opening checks reproduced text and Escape reaching the agent
+after Find had been requested but before its editor mounted. The focused visible
+pane now prepares its input field without a search index. Opening activates its
+focus scope and text-input client immediately; the first paint uses that same
+editor, preserving already-entered text and composition. Closing before that
+paint consumes Escape and returns the next key to the terminal.
+
+In the current 16-terminal/four-workspace fixture, exactly one dormant editor is
+mounted. It cannot take focus while inactive, has no search model, and output
+updates across all 16 sessions cause zero Find/editor rebuilds. Existing active
+Find output checks still show zero editor rebuilds. Snapshot replacement retains
+the editor's full editing value, including composition. These are input-ownership
+and deterministic-work checks, not native latency or live IME measurements.
+
+The before-fix cases are in `/private/tmp/harness-find-opening-before.log`.
+All **1,443 desktop checks** pass, with one optional CLI-media placeholder
+skipped, in `/private/tmp/harness-find-opening-full.log`. Analysis of all six
+changed source/test files is clean in
+`/private/tmp/harness-find-opening-analyze.log`. The native-entry case uses the
+actual incoming Dart method handler with an isolated platform channel.
+
### Immediate input after closing terminal Find
Find previously waited for the next frame to return focus to the retained