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): static locked mobile shell for the iOS keyboard (#420)

Call White6c37ae854fc0
diff --git a/ui/src/components/AppShell.tsx b/ui/src/components/AppShell.tsx
index c05b025c9..42507a7f5 100644
--- a/ui/src/components/AppShell.tsx
+++ b/ui/src/components/AppShell.tsx
@@ -128,7 +128,11 @@ export const AppShell: React.FC = () => {
const [enabledPlatforms, setEnabledPlatforms] = useState<string[]>([]);
const [config, setConfig] = useState<any>(null);
const [newSessionOpen, setNewSessionOpen] = useState(false);
- // Track the visual viewport so the chat composer stays flush above the iOS keyboard.
+ // Mirror the iOS visual-viewport height into --app-vvh. The MOBILE shell is a
+ // static locked column that does NOT read it (resizing the shell mid-focus
+ // fought iOS's scroll-into-view and flung the input off-screen); only the md+
+ // chat (iPad / phone-landscape — desktop layout, so it can't use the mobile
+ // body-lock) sizes to it, keeping its composer above the soft keyboard.
useViewportHeightVar();
useEffect(() => {
@@ -189,10 +193,15 @@ export const AppShell: React.FC = () => {
const showBottomNav = !location.pathname.startsWith('/chat/') && location.pathname !== '/setup';
return (
- // Mobile: a LOCKED, --app-vvh-sized flex column (overflow-hidden) so the
+ // Mobile: a LOCKED, full-viewport flex column (overflow-hidden) so the
// document never scrolls — iOS can't then fling a focused input off the top —
- // and <main> scrolls internally. Desktop: normal document flow.
- <div className="flex h-[var(--app-vvh)] flex-col overflow-hidden bg-background text-foreground md:block md:h-auto md:min-h-screen md:overflow-visible">
+ // and <main> scrolls internally. The height is the STATIC --app-shell-h (dvh,
+ // with a 100vh fallback for older iOS): we deliberately do NOT resize the shell
+ // to the visual viewport in JS, because mutating the shell height mid-focus
+ // fought iOS's own scroll-into-view and threw the input off-screen. iOS instead
+ // pans the locked page to lift the focused composer above the keyboard.
+ // Desktop: normal document flow.
+ <div className="flex h-[var(--app-shell-h)] flex-col overflow-hidden bg-background text-foreground md:block md:h-auto md:min-h-screen md:overflow-visible">
<aside className="fixed inset-y-0 left-0 z-30 hidden w-[240px] flex-col border-r border-border bg-surface md:flex">
<div className="flex h-full flex-col justify-between gap-6 px-4 py-5">
{/* Top: Brand + Workspace label + Nav list */}
diff --git a/ui/src/components/workbench/ChatPage.tsx b/ui/src/components/workbench/ChatPage.tsx
index 11a03498e..c524447f5 100644
--- a/ui/src/components/workbench/ChatPage.tsx
+++ b/ui/src/components/workbench/ChatPage.tsx
@@ -707,11 +707,13 @@ export const ChatPage: React.FC = () => {
// and left a 4rem dead gap below the compose bar. On mobile the sticky
// ``h-16`` header occupies 4rem at the top, so subtract that instead.
<ImageViewerProvider images={sessionImages}>
- {/* Mobile: fill <main> exactly. <main> is app-vvh minus the header, and the
- header is 4rem + the top safe-area, so subtract BOTH — otherwise the chat
- is taller than main and main double-scrolls, hiding the compose bar on
- notched iPhones. Desktop has no mobile header → full app-vvh. */}
- <div className="-mx-4 -my-5 flex h-[calc(var(--app-vvh)_-_4rem_-_env(safe-area-inset-top))] flex-col md:-mx-10 md:-my-8 md:h-[var(--app-vvh)]">
+ {/* Mobile: fill <main> exactly — --app-shell-h minus the header (4rem + top
+ safe-area), statically (dvh, 100vh fallback for old iOS): the mobile
+ body-lock makes iOS pan the locked page to lift the composer above the
+ keyboard, so no JS sizing is needed. md+ (iPad / phone-landscape) uses the
+ desktop layout (no body-lock), so size to the visual-viewport height
+ (--app-vvh) to keep the composer above the soft keyboard there. */}
+ <div className="-mx-4 -my-5 flex h-[calc(var(--app-shell-h)_-_4rem_-_env(safe-area-inset-top))] flex-col md:-mx-10 md:-my-8 md:h-[var(--app-vvh)]">
<ChatHeaderBar session={session} agents={agents} onPatch={patch} onBack={goBack} />
{error && (
diff --git a/ui/src/index.css b/ui/src/index.css
index 88c32bbcb..d1ed2934a 100644
--- a/ui/src/index.css
+++ b/ui/src/index.css
@@ -1,13 +1,30 @@
@import "tailwindcss";
@import "tw-animate-css";
-/* Visual-viewport height (px), kept in sync by useViewportHeightVar so full-height
- surfaces (chat) stay flush above the iOS keyboard. Defaults to the dynamic
- viewport height before/without JS. */
+/* iOS visual-viewport height (px), kept in sync by useViewportHeightVar. Consumed
+ ONLY by the md+ chat (iPad / landscape), whose desktop layout can't use the
+ mobile body-lock; the mobile shell + chat use the static --app-shell-h instead.
+ Defaults to 100dvh before/without JS. */
:root {
--app-vvh: 100dvh;
}
+/* Static full-viewport height for the LOCKED mobile shell + mobile chat. NEVER
+ JS-resized to the visual viewport (that mid-focus resize flung the input off the
+ top); the locked page just pans under iOS to lift the composer. Uses dvh where
+ supported (tracks the URL bar, not the keyboard), with a 100vh fallback for older
+ iOS Safari that exposes visualViewport but not dvh — without it h-[…dvh] would be
+ ignored, leaving the locked shell unbounded and clipping <main> instead of
+ scrolling it. */
+:root {
+ --app-shell-h: 100vh;
+}
+@supports (height: 100dvh) {
+ :root {
+ --app-shell-h: 100dvh;
+ }
+}
+
@theme inline {
--color-background: var(--background);
--color-foreground: var(--foreground);
@@ -353,8 +370,8 @@ body {
/* iOS Safari keyboard fix: on mobile, lock the document so it can't scroll.
Otherwise focusing an input makes Safari scroll the (slightly-taller-than-
viewport) page to "reveal" it and overshoots, flinging the input off the top
- of the screen. The AppShell instead is a fixed, --app-vvh-sized flex column
- whose <main> scrolls internally. Desktop keeps normal document scrolling. */
+ of the screen. The AppShell instead is a static h-dvh flex column whose
+ <main> scrolls internally. Desktop keeps normal document scrolling. */
@media (max-width: 767px) {
html,
body {
diff --git a/ui/src/lib/useViewportHeightVar.ts b/ui/src/lib/useViewportHeightVar.ts
index 3c4677cd0..d11b24f11 100644
--- a/ui/src/lib/useViewportHeightVar.ts
+++ b/ui/src/lib/useViewportHeightVar.ts
@@ -5,8 +5,14 @@ import { useEffect } from 'react';
// chat composer ends up stranded with a large gap above the keyboard (dvh alone
// doesn't fix it on iOS, and interactive-widget=resizes-content isn't supported
// there). Mirror window.visualViewport.height into the --app-vvh CSS var
-// (rAF-throttled) so full-height surfaces can size to the actually-visible area
-// and keep the input flush above the keyboard. Refs:
+// (rAF-throttled).
+//
+// NB: the MOBILE shell deliberately does NOT consume this — sizing the shell to
+// it mid-focus fought iOS's own scroll-into-view and flung the input off the top
+// (the mobile shell is a static locked column instead, see AppShell/index.css).
+// The ONLY consumer is the md+ chat (iPad / phone-landscape), which uses the
+// desktop layout and so cannot use the mobile body-lock; sizing that chat to the
+// visual viewport keeps its composer above the soft keyboard. Refs:
// https://www.bram.us/2021/09/13/prevent-items-from-being-hidden-underneath-the-virtual-keyboard-by-means-of-the-virtualkeyboard-api/
// https://dev.to/franciscomoretti/fix-mobile-keyboard-overlap-with-visualviewport-3a4a
export function useViewportHeightVar(): void {