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(mobile): search opened from a keyboard reaches the bottom of the screen

bubu-dudueeca206ee654
diff --git a/mobile/lib/phone/terminal_page.dart b/mobile/lib/phone/terminal_page.dart
index e38922dd1..01811a6f6 100644
--- a/mobile/lib/phone/terminal_page.dart
+++ b/mobile/lib/phone/terminal_page.dart
@@ -1282,6 +1282,20 @@ class _TerminalPageState extends State<TerminalPage>
// turning it off.
body: Stack(
children: [
+ // ⚠️ **What gives this Stack the window's height instead of the
+ // page's.** A Stack is as tall as its tallest NON-POSITIONED child,
+ // and that child is the column below — whose terminal is frozen at
+ // the height it had when search opened (see [HeldHeight]). With a
+ // keyboard up at that moment the column is a keyboard shorter than
+ // the screen, so the search sheet, laid over this Stack, was clipped
+ // to a box that ended a keyboard's height above the bottom: it drew
+ // at the top of the screen with a band of empty page under it, long
+ // after the keyboard had gone.
+ //
+ // An empty box that asks for everything is enough. It paints nothing
+ // and takes no hits; it only stops the Stack from inheriting a height
+ // that belongs to something being deliberately held still.
+ const SizedBox.expand(),
MediaQuery.removePadding(
context: context,
removeBottom: true,
diff --git a/mobile/lib/phone/terminal_search.dart b/mobile/lib/phone/terminal_search.dart
index f214b2414..b3d77c0fe 100644
--- a/mobile/lib/phone/terminal_search.dart
+++ b/mobile/lib/phone/terminal_search.dart
@@ -433,9 +433,19 @@ class _TerminalSearchOverlayState extends State<TerminalSearchOverlay>
// A keyboard lifts the sheet whole, at the height it rests at. Only
// the ceiling stops it: a keyboard that leaves less room than that
// shortens the sheet instead.
+ //
+ // ⚠️ **Read from the view HERE, not from the notifier's last value.**
+ // [_keyboard] is written from metrics ticks and is what makes this
+ // rebuild, but the value it holds can be a frame behind the page: a
+ // tick that lands while the page has already grown back left the sheet
+ // lifted by a keyboard that was no longer there, floating at the top of
+ // the screen over a band of empty background — which is what opening
+ // search from a keyboard looked like.
+ final view = View.of(context);
+ final keyboard = view.viewInsets.bottom / view.devicePixelRatio;
final covered = math.min(
area.height,
- math.max(0.0, area.height - (screen - _keyboard.value)),
+ math.max(0.0, area.height - (screen - keyboard)),
);
final height = math.min(
resting,