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
mobile: rename keeps the keyboard it raises, and one Paste row instead of two
bubu-dudu65cd83286850
diff --git a/mobile/lib/phone/terminal_page.dart b/mobile/lib/phone/terminal_page.dartindex c91073533..6f72a4faa 100644--- a/mobile/lib/phone/terminal_page.dart+++ b/mobile/lib/phone/terminal_page.dart@@ -337,6 +337,24 @@ class _TerminalPageState extends State<TerminalPage>/// — or [_searchHoldLimit], so a keyboard that never reports zero cannot hold/// the terminal still for good.bool _heldForSearch = false;++ /// The keyboard up belongs to a field OUTSIDE this page — the rename dialog+ /// over the `⋯` sheet, any dialog with a text field — so the terminal must+ /// not read it as its own. Held from the tick the keyboard rises until the+ /// inset reaches zero again.+ ///+ /// ⚠️ **Without it, what was typed into the dialog went to the shell.** The+ /// dialog focused its field and raised the keyboard; [_keyboardIsUp] went+ /// true from that inset; [_shouldFocus] followed it and the panel took focus+ /// — and the input connection — back from the dialog ~300ms after it opened.+ /// The same fault [_heldForSearch] fixes for search, which is inside this+ /// page; a dialog is not, so this one is decided by where the focus that+ /// raised the keyboard lives.+ ///+ /// ⚠️ Not [ModalRoute.isCurrent]: this page is a tab's root in `PhoneShell`'s+ /// nested Navigator, and sheets and dialogs are pushed on the ROOT one, so+ /// the page stays "current" under them.+ bool _heldForCover = false;Timer? _searchHoldTimer;static const _searchHoldLimit = Duration(milliseconds: 800);@@ -1253,6 +1271,25 @@ class _TerminalPageState extends State<TerminalPage>// shell at the half-risen height before the settle began — two SIGWINCHes// and two redraws for one keyboard. A page arriving under a keyboard already// up costs one needless 80ms hold, and nothing else.+ // The keyboard's first frame up says whose it is: the field that raised it+ // already holds the focus. One outside this page's route is a dialog's —+ // see [_heldForCover]. Zero ends the hold, covered or not.+ if (up && _lastInset <= 0) {+ final primary = FocusManager.instance.primaryFocus;+ final scope = FocusScope.of(context);+ // ⚠️ **A SCOPE holding the focus is nobody holding it.** With no field+ // focused anywhere, `primaryFocus` is a [FocusScopeNode] — the enclosing+ // scope, which by definition is not inside this page — and reading that+ // as "a dialog's keyboard" held the terminal off its own. A field in a+ // dialog is an ordinary [FocusNode]; only that is worth standing back for.+ _heldForCover =+ primary != null &&+ primary is! FocusScopeNode &&+ primary != scope &&+ !primary.ancestors.contains(scope);+ } else if (!up) {+ _heldForCover = false;+ }final previous = _lastInset;_lastInset = inset;// Search's keyboard has finished leaving: the terminal may read the@@ -1358,6 +1395,7 @@ class _TerminalPageState extends State<TerminalPage>bool get _shouldFocus =>widget.isActive &&!_heldForSearch &&+ !_heldForCover &&(_keyboardIsUp || _keyboardRequested);/// A tap on the terminal while no keyboard is up or coming: the keyboard.@@ -2347,7 +2385,11 @@ class _TerminalPageState extends State<TerminalPage>/// page hands it only what the page alone knows, whether this is still the terminal on screen.PhoneSheetAction _pasteAction(TerminalSession session) => PhoneSheetAction(icon: LucideIcons.clipboardPaste300,- label: 'Paste',+ // ⚠️ Named for WHERE it reads, not for the verb. The sheet's other rows act+ // on the agent and the machine; "Paste" alone left it open which clipboard+ // was meant — and the phone's is the surprising answer, since the agent runs+ // somewhere else. See [pasteClipboard], which says the same in its doc.+ label: 'Paste from clipboard',onTap: () {final messenger = ScaffoldMessenger.maybeOf(context);unawaited(@@ -2374,27 +2416,6 @@ class _TerminalPageState extends State<TerminalPage>);/// What acts on this agent and can be taken back — the first card of its sheet.- /// Pastes the phone's clipboard into the terminal, the way a desktop's ⌘V does — the pane's raw- /// paste where the computer takes one, bracketed paste where it does not.- Future<void> _pasteClipboard() async {- final session = widget.notifier- .paneOfAgent(widget.machineId, widget.agentId)- ?.session;- if (session == null || !session.acceptsInput) return;- final text = (await Clipboard.getData(Clipboard.kTextPlain))?.text;- if (!mounted) return;- if (text == null || text.isEmpty) {- _flash('the clipboard has no text', error: true);- return;- }- final machine = widget.notifier.stateOf(widget.machineId);- if (machine != null && machine.terminalPasteRawAvailable) {- await session.pasteText(text);- } else {- session.terminal.paste(text);- }- }-List<PhoneSheetAction> _agentActions(Agent agent) => [PhoneSheetAction(icon: LucideIcons.gitBranch300,@@ -2418,11 +2439,11 @@ class _TerminalPageState extends State<TerminalPage>),),),- PhoneSheetAction(- icon: LucideIcons.clipboardPaste300,- label: 'Paste from clipboard',- onTap: () => unawaited(_pasteClipboard()),- ),+ // ⚠️ **"Paste from clipboard" was here, and it was the SECOND paste row in+ // one sheet.** It did less than the one above ([_pasteAction]): text only,+ // no image; no `Clipboard.hasStrings` first, so iOS asked for permission+ // twice; and no check that the pane it was tapped on is still the pane the+ // text lands in. The capable one stays; this one goes.// Stop what it is doing — Esc, as in the terminal — only while it is doing something. First,// because when it is wanted it is wanted now.if (_agentWorking)diff --git a/mobile/lib/widgets/rename_agent_dialog.dart b/mobile/lib/widgets/rename_agent_dialog.dartindex 83a7ae972..de44537a4 100644--- a/mobile/lib/widgets/rename_agent_dialog.dart+++ b/mobile/lib/widgets/rename_agent_dialog.dart@@ -1,6 +1,7 @@import 'dart:async';import 'package:flutter/material.dart';+import 'package:flutter/services.dart';import 'package:lucide_icons_flutter/lucide_icons.dart';import '../core/models.dart' show Agent;@@ -115,8 +116,47 @@ class _RenameAgentDialogState extends State<_RenameAgentDialog> {_focus.addListener(_onFocus);}+ /// The route's entrance, watched once — see [_raiseKeyboard].+ Animation<double>? _entrance;++ @override+ void didChangeDependencies() {+ super.didChangeDependencies();+ if (_entrance != null) return;+ final entrance = ModalRoute.of(context)?.animation;+ if (entrance == null) return;+ _entrance = entrance;+ if (entrance.isCompleted) {+ WidgetsBinding.instance.addPostFrameCallback((_) => _raiseKeyboard());+ } else {+ entrance.addStatusListener(_onEntrance);+ }+ }++ void _onEntrance(AnimationStatus status) {+ if (!status.isCompleted) return;+ _entrance?.removeStatusListener(_onEntrance);+ _raiseKeyboard();+ }++ /// ⚠️ `autofocus` alone left the phone with no keyboard. The phone's `⋯` sheet+ /// pops and this dialog pushes in the same frame, and the autofocus landed+ /// while the sheet was still leaving — the field came up unfocused, or focused+ /// with the keyboard never shown. So once the dialog has finished arriving the+ /// focus is asked for again, and a field that already holds it asks for the+ /// keyboard outright (a no-op where there is no soft keyboard).+ void _raiseKeyboard() {+ if (!mounted || _busy) return;+ if (_focus.hasFocus) {+ unawaited(SystemChannels.textInput.invokeMethod<void>('TextInput.show'));+ } else {+ _focus.requestFocus();+ }+ }+@overridevoid dispose() {+ _entrance?.removeStatusListener(_onEntrance);_controller.dispose();_focus.dispose();super.dispose();diff --git a/mobile/test/phone_edge/focus_behavior_test.dart b/mobile/test/phone_edge/focus_behavior_test.dartindex d684482a1..d9bb2bb05 100644--- a/mobile/test/phone_edge/focus_behavior_test.dart+++ b/mobile/test/phone_edge/focus_behavior_test.dart@@ -34,14 +34,44 @@ void main() {TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (call) async {if (call.method == 'Clipboard.getData') return _clipboard;+ // ⚠️ Answered as well as `getData`, because the menu's Paste asks this+ // FIRST — it is how iOS is spared a second "Allow Paste" prompt (see+ // `phone/terminal_paste.dart`). Unanswered it reads as false, and the+ // paste walked straight past the text to look for an image.+ if (call.method == 'Clipboard.hasStrings') {+ final text = _clipboard?['text'];+ // ⚠️ Typed `<String, dynamic>`, not left to inference. Flutter reads+ // this reply as `Map<String, dynamic>?`, and a `Map<String, bool>`+ // fails that cast with a TypeError — which, thrown inside an+ // unawaited paste, is swallowed whole: no paste, no message, no+ // failure, just a Paste row that silently does nothing.+ return <String, dynamic>{+ 'value': text is String && text.isNotEmpty,+ };+ }return null;});+ // ⚠️ **Answered too, or Paste never finishes.** With no text on the+ // clipboard the paste goes looking for an IMAGE, over this channel — and an+ // unmocked channel in a widget test never replies at all. The await simply+ // hangs: no paste, no message, no error, and a test that reads as "the row+ // did nothing" when the row is in fact still waiting. Null is "no image".+ TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger+ .setMockMethodCallHandler(+ const MethodChannel('harness/clipboard_image'),+ (call) async => null,+ );});tearDown(() {_clipboard = null;TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, null);+ TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger+ .setMockMethodCallHandler(+ const MethodChannel('harness/clipboard_image'),+ null,+ );});testWidgets('a keyboard raised while the mic records puts the take away', (@@ -329,8 +359,13 @@ void main() {final focus = await openMenu(tester);_clipboard = null;await tester.tap(find.text('Paste from clipboard'));- await frames(tester, count: 1);- expect(find.text('the clipboard has no text'), findsOneWidget);+ await frames(tester);+ // No text AND no image: the sheet's Paste looks for both before it gives+ // up, so the sentence names the clipboard rather than the text on it.+ expect(+ find.text('There is nothing on the clipboard to paste.'),+ findsOneWidget,+ );await focus.close();});