[Bug] Android: hardcoded 25px switcher height (#58) - #69
Conversation
The chat scroll-fade used a hardcoded 25px pill height that drifted at non-default font scales because the pill text is sp-sized. Keep 25px as the CSS default for older shells and have MainActivity push the measured height into --omnigent-android-switcher-height after layout. Closes #58 Co-authored-by: Deepak Sekar <deepaksekaranz@users.noreply.github.com>
| switchButton.getHitRect(hitRect) | ||
| if (hitRect.height() < minHeight) hitRect.bottom = hitRect.top + minHeight | ||
| container.touchDelegate = TouchDelegate(hitRect, switchButton) | ||
| emitSwitcherHeight() |
There was a problem hiding this comment.
🟡 Measured server-switcher height never reaches the loaded page, so the old fixed height stays in effect
The measured pill height is pushed to the web layer (emitSwitcherHeight() at web/android/app/src/main/java/ai/omnigent/android/MainActivity.kt:586) only while the native pill is being laid out, which happens before the page finishes loading and is never repeated afterward, so the loaded page keeps using the hardcoded 25px default the change was meant to replace.
Impact: The Android scroll-fade gradient still positions itself using the old fixed height instead of the pill's real size on normal cold starts and after any page reload or server switch, so the visual bug the change targets is not actually fixed.
Layout-driven emit fires before page load and is not re-run in onPageReady
emitSwitcherHeight() sets the inline CSS custom property --omnigent-android-switcher-height on document.documentElement. It is invoked only from the pill's addOnLayoutChangeListener callback (MainActivity.kt:581-586), which runs during the activity's initial native layout pass — before webView.loadUrl(...)'s SPA has finished loading. Any inline style set against the pre-load / about:blank document is discarded when the real document loads.
Unlike the safe-area insets, which are cached in lastInsets and re-emitted from onPageReady on every pinned-origin page load (MainActivity.kt:660 calls emitInsets()), onPageReady never calls emitSwitcherHeight() (see MainActivity.kt:642-661). No native re-layout of switchButton occurs on a WebView reload or server switch (reloadWithNewServer → loadUrl), so the layout listener does not fire again and the measured height is never delivered to the freshly loaded document. The CSS in web/src/index.css:167 therefore falls back to --omnigent-android-switcher-height: 25px.
Fix: cache the last measured height and also emit it from onPageReady (mirroring emitInsets), so the loaded page reliably receives the real pill height.
Prompt for agents
emitSwitcherHeight() is only called from the pill's addOnLayoutChangeListener in expandSwitchButtonTouchTarget (MainActivity.kt:586). That listener fires during the initial native layout pass, which happens before the WebView's SPA finishes loading, and it does not fire again on a page reload or server switch (reloadWithNewServer -> webView.loadUrl) because switchButton does not re-layout. As a result the inline CSS var --omnigent-android-switcher-height set on document.documentElement is lost when the real document loads, and the web layer keeps using the 25px default in web/src/index.css. Compare with emitInsets, which caches its value in lastInsets and is re-emitted from onPageReady on every pinned-origin page load so it survives reloads. Fix emitSwitcherHeight the same way: remember the last measured pill height and also emit it from onPageReady (after the origin check) so the loaded page reliably receives the measured height on cold start and after every reload/server switch.
Was this helpful? React with 👍 or 👎 to provide feedback.
|
bugbot run |
Bugbot couldn't run — GitHub account mismatchThe GitHub account linked to your Cursor account does not match the PR author. Please ensure you're using the correct GitHub account, or run Bugbot from a team that covers this repository. |
Opened by Cursor Forge after Cloud Agent pushed the branch but could not create the PR (GitHub App collaborator permissions).
Fixes #58.