Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(ui): home agent-trigger width + mobile keyboard/Enter behavior (#413)

Call Whitec74c2a7feb72
diff --git a/ui/index.html b/ui/index.html
index d25a9ad46..3ac2518ff 100644
--- a/ui/index.html
+++ b/ui/index.html
@@ -5,10 +5,11 @@
<link rel="icon" type="image/png" href="/logo.png" />
<!-- maximum-scale=1 + user-scalable=no stops iOS Safari from auto-zooming when
a sub-16px input gains focus (app shell, not a content page).
- interactive-widget=resizes-content lets Android shrink the layout for the
- keyboard; iOS uses the visualViewport-driven --app-vvh instead (see
- useViewportHeightVar). -->
- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, interactive-widget=resizes-content" />
+ interactive-widget=resizes-content (added below for non-iOS) keeps Android
+ bottom sheets above the soft keyboard; on iOS it reflowed the centered home
+ when the keyboard opened, so iOS is handled in layout instead (top-aligned
+ home + visualViewport --app-vvh chat, see useViewportHeightVar). -->
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Vibe Remote</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
@@ -36,6 +37,25 @@
}
})();
</script>
+ <script>
+ // Enable interactive-widget=resizes-content on Android/desktop (keeps bottom
+ // sheets above the soft keyboard) but NOT on iOS, where it reflowed the
+ // layout badly when the keyboard opened. Placed AFTER the theme bootstrap so
+ // ui/scripts/validate-theme.mjs still treats the theme script as the first
+ // inline script. Browsers re-evaluate the viewport meta on content change.
+ (function () {
+ try {
+ var ua = navigator.userAgent || '';
+ var isIOS =
+ /iP(hone|ad|od)/.test(ua) ||
+ (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1);
+ if (!isIOS) {
+ var vp = document.querySelector('meta[name="viewport"]');
+ if (vp) vp.setAttribute('content', vp.getAttribute('content') + ', interactive-widget=resizes-content');
+ }
+ } catch (e) {}
+ })();
+ </script>
</head>
<body>
<div id="root"></div>
diff --git a/ui/src/components/Workbench.tsx b/ui/src/components/Workbench.tsx
index f8ed1fa17..678fa9f03 100644
--- a/ui/src/components/Workbench.tsx
+++ b/ui/src/components/Workbench.tsx
@@ -48,11 +48,12 @@ export const Workbench: React.FC = () => {
] as const;
return (
- // Center the hero + Composer as a group, leaving the AppShell's top/bottom
- // padding as margin (no negative-margin full-bleed). min-h fills the visible
- // area so justify-center actually centers; the responsive offset accounts
- // for the mobile header + bottom nav vs. the desktop sidebar layout.
- <div className="flex min-h-[calc(100dvh-13rem)] flex-col items-center justify-center gap-5 md:min-h-[calc(100dvh-7rem)]">
+ // Desktop centers the hero + Composer as a group (min-h + justify-center). On
+ // mobile we DON'T center or force a tall min-height: a tall centered container
+ // fights the iOS keyboard (focusing the composer leaves a big gap / pushes it
+ // off-screen). Top-aligned normal flow lets iOS scroll the focused composer
+ // into view above the keyboard the way it does for ordinary in-flow inputs.
+ <div className="flex flex-col items-center gap-5 md:min-h-[calc(100dvh-7rem)] md:justify-center">
{/* Hero panel — a centered card, not a full-bleed fill. */}
<div className="flex w-full max-w-[640px] flex-col items-center gap-6 rounded-2xl border border-border bg-surface-2 px-6 py-10">
<div className="flex size-14 items-center justify-center rounded-2xl border border-mint/40 bg-mint-soft text-mint shadow-[0_0_24px_-6px_rgba(91,255,160,0.6)]">
@@ -98,7 +99,7 @@ export const Workbench: React.FC = () => {
defaultLabel={ns.defaultAgentName ? t('newSession.defaultAgentNamed', { name: ns.defaultAgentName }) : t('newSession.defaultAgent')}
disabled={ns.sending}
align="start"
- triggerClassName="w-full max-w-full"
+ triggerClassName="max-w-full"
/>
</div>
<Composer
diff --git a/ui/src/components/workbench/Composer.tsx b/ui/src/components/workbench/Composer.tsx
index ef94598d0..0b677b63e 100644
--- a/ui/src/components/workbench/Composer.tsx
+++ b/ui/src/components/workbench/Composer.tsx
@@ -4,6 +4,7 @@ import { Loader2, Mic, Paperclip, Plus, Send, Square, Trash2, X } from 'lucide-r
import clsx from 'clsx';
import { apiFetch } from '../../lib/apiFetch';
+import { isSoftKeyboardOpen } from '../../lib/softKeyboard';
import { cn } from '../../lib/utils';
import { Button } from '../ui/button';
@@ -413,10 +414,11 @@ export const Composer: React.FC<ComposerProps> = ({
value={value}
onChange={(e) => update(e.target.value)}
onKeyDown={(e) => {
- // Enter sends; Shift+Enter inserts a newline. ``isComposing`` guards
- // against submitting mid-IME composition (CJK), where Enter commits
- // the candidate rather than the message.
- if (e.key === 'Enter' && !e.shiftKey && !e.nativeEvent.isComposing) {
+ // Enter sends, Shift+Enter newline — EXCEPT while the on-screen
+ // keyboard is open (mobile), where Enter inserts a newline and Send is
+ // the button. Hardware keyboards (no soft keyboard) keep Enter-to-send.
+ // ``isComposing`` guards against submitting mid-IME composition (CJK).
+ if (e.key === 'Enter' && !e.shiftKey && !e.nativeEvent.isComposing && !isSoftKeyboardOpen()) {
e.preventDefault();
submit();
}
diff --git a/ui/src/lib/softKeyboard.ts b/ui/src/lib/softKeyboard.ts
new file mode 100644
index 000000000..41ca50648
--- /dev/null
+++ b/ui/src/lib/softKeyboard.ts
@@ -0,0 +1,53 @@
+// Cross-platform "is the on-screen keyboard open?" check.
+//
+// It must work whether the keyboard OVERLAYS the viewport (iOS Safari: window
+// .innerHeight stays full, only visualViewport.height shrinks) OR RESIZES it
+// (Android Chrome with interactive-widget=resizes-content: innerHeight AND
+// visualViewport.height shrink together, so an innerHeight−visualViewport delta
+// reads ~0 — https://developer.chrome.com/blog/viewport-resize-behavior/). The
+// signal that survives both is the visual-viewport height vs the LARGEST height
+// seen while no keyboard was up (the "resting" height): the keyboard only ever
+// shrinks the visible viewport, and by far more than address-bar show/hide.
+
+let restingHeight = 0;
+
+// True when a text field is focused — i.e. the soft keyboard could be up — so the
+// resize handler knows whether a shrink is "keyboard" or just a window/orientation
+// change.
+function isEditableFocused(): boolean {
+ const el = typeof document !== 'undefined' ? (document.activeElement as HTMLElement | null) : null;
+ if (!el) return false;
+ const tag = el.tagName;
+ return tag === 'INPUT' || tag === 'TEXTAREA' || el.isContentEditable;
+}
+
+if (typeof window !== 'undefined' && window.visualViewport) {
+ const vv = window.visualViewport;
+ // Initialised at module load (app start, keyboard closed) → a keyboard-free baseline.
+ restingHeight = vv.height;
+ vv.addEventListener('resize', () => {
+ // While NO text field is focused the keyboard is closed, so the current height
+ // IS the resting baseline — this recomputes it on window resize / orientation
+ // change / address-bar show-hide (so a shrunk desktop window doesn't read as a
+ // keyboard). While a field is focused, only let the baseline grow (address bar
+ // hiding); never let the keyboard itself lower it.
+ if (!isEditableFocused() || vv.height > restingHeight) restingHeight = vv.height;
+ });
+}
+
+// ~250–300px keyboard vs ~60–100px address-bar variation → a 150px floor cleanly
+// separates "keyboard up" from address-bar collapse/expand.
+const KEYBOARD_MIN_DELTA = 150;
+
+// Only touch-capable devices have an on-screen keyboard. Gating on this keeps
+// isSoftKeyboardOpen() false on desktop regardless of window resizes (so Enter
+// always sends there — no false positives from a shorter window), while a
+// hardware keyboard on a touch device still reads false because it doesn't shrink
+// the viewport. So the resting-height heuristic only ever runs where a soft
+// keyboard can actually exist.
+const isTouchDevice = typeof navigator !== 'undefined' && navigator.maxTouchPoints > 0;
+
+export function isSoftKeyboardOpen(): boolean {
+ if (!isTouchDevice || typeof window === 'undefined' || !window.visualViewport) return false;
+ return restingHeight - window.visualViewport.height > KEYBOARD_MIN_DELTA;
+}