Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
fix(web): optimize mobile keyboard handling and safe-area colors
Generdbff6c3ec290
diff --git a/src/web/src/app/globals.css b/src/web/src/app/globals.cssindex f6a6191de..f28c001e6 100644--- a/src/web/src/app/globals.css+++ b/src/web/src/app/globals.css@@ -954,13 +954,13 @@@apply border-border outline-ring/50;}body {- @apply bg-background text-foreground;+ @apply text-foreground;font-kerning: normal;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;}html {- @apply font-sans bg-background;+ @apply font-sans;font-size: 16px;line-height: 1.6;}@@ -1721,20 +1721,17 @@ html, body {touch-action: manipulation;}-html {+[data-keyboard-offset] {+ transition: transform 0.2s ease-out;+ will-change: transform;+}++html, body {background-color: oklch(0.93 0.015 80);min-height: 100dvh;}-.dark html,-html.dark {+html.dark,+.dark body {background-color: oklch(0.16 0.008 60);}--body {- min-height: 100dvh;- padding-top: env(safe-area-inset-top);- padding-bottom: env(safe-area-inset-bottom);- padding-left: env(safe-area-inset-left);- padding-right: env(safe-area-inset-right);-}diff --git a/src/web/src/app/layout.tsx b/src/web/src/app/layout.tsxindex 07a371654..76da708a4 100644--- a/src/web/src/app/layout.tsx+++ b/src/web/src/app/layout.tsx@@ -50,10 +50,12 @@ const OG_IMAGE_URL = "/og?title=Your Personal Company";export const viewport: Viewport = {width: "device-width",initialScale: 1,+ maximumScale: 1,+ userScalable: false,viewportFit: "cover",interactiveWidget: "resizes-visual",themeColor: [- { media: "(prefers-color-scheme: light)", color: "#f5f0e8" },+ { media: "(prefers-color-scheme: light)", color: "#ede7dd" },{ media: "(prefers-color-scheme: dark)", color: "#262320" },],};@@ -124,6 +126,9 @@ export default function RootLayout({<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /><link rel="preconnect" href="https://fonts.googleapis.com" /><link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="anonymous" />+ <script dangerouslySetInnerHTML={{ __html: `+ document.addEventListener('gesturestart', function(e) { e.preventDefault(); });+ `}} /></head><GoogleTagManager gtmId="GTM-56VHCCQZ" /><bodydiff --git a/src/web/src/hooks/__tests__/use-keyboard-scroll.test.ts b/src/web/src/hooks/__tests__/use-keyboard-scroll.test.tsindex 522d80635..960952105 100644--- a/src/web/src/hooks/__tests__/use-keyboard-scroll.test.ts+++ b/src/web/src/hooks/__tests__/use-keyboard-scroll.test.ts@@ -16,8 +16,11 @@ function createMockTarget(container?: HTMLElement | null) {return { target, scrollIntoView };}-function createMockContainer() {- return { style: { transform: "" } } as unknown as HTMLElement;+function createMockContainer(bottom = 800) {+ return {+ style: { transform: "" },+ getBoundingClientRect: () => ({ top: 0, left: 0, right: 0, bottom, width: 0, height: 0 }),+ } as unknown as HTMLElement;}describe("createKeyboardScrollController", () => {@@ -39,7 +42,7 @@ describe("createKeyboardScrollController", () => {const { handler } = createKeyboardScrollController(() => target, true);handler();- vi.advanceTimersByTime(100);+ vi.advanceTimersByTime(150);expect(scrollIntoView).toHaveBeenCalledWith({block: "end",@@ -67,7 +70,7 @@ describe("createKeyboardScrollController", () => {const { handler } = createKeyboardScrollController(() => target, true);handler();- vi.advanceTimersByTime(100);+ vi.advanceTimersByTime(150);expect(container.style.transform).toBe("translateY(-300px)");@@ -93,7 +96,7 @@ describe("createKeyboardScrollController", () => {const { handler } = createKeyboardScrollController(() => target, true);handler();- vi.advanceTimersByTime(100);+ vi.advanceTimersByTime(150);expect(container.style.transform).toBe("");@@ -118,7 +121,7 @@ describe("createKeyboardScrollController", () => {const { handler } = createKeyboardScrollController(() => target, false);handler();- vi.advanceTimersByTime(100);+ vi.advanceTimersByTime(150);expect(container.style.transform).toBe("");@@ -147,7 +150,7 @@ describe("createKeyboardScrollController", () => {handler();vi.advanceTimersByTime(50);handler();- vi.advanceTimersByTime(100);+ vi.advanceTimersByTime(150);expect(container.style.transform).toBe("translateY(-300px)");@@ -178,7 +181,7 @@ describe("createKeyboardScrollController", () => {handler();vi.advanceTimersByTime(50);cleanup();- vi.advanceTimersByTime(100);+ vi.advanceTimersByTime(150);expect(container.style.transform).toBe("");@@ -206,12 +209,12 @@ describe("createKeyboardScrollController", () => {const { handler } = createKeyboardScrollController(() => target, true);handler();- vi.advanceTimersByTime(100);+ vi.advanceTimersByTime(150);expect(container.style.transform).toBe("translateY(-300px)");viewportHeight = 600;handler();- vi.advanceTimersByTime(100);+ vi.advanceTimersByTime(150);expect(container.style.transform).toBe("translateY(-200px)");Object.defineProperty(globalThis, "window", {@@ -240,7 +243,7 @@ describe("createKeyboardScrollController", () => {const { handler } = createKeyboardScrollController(() => target, true);handler();- vi.advanceTimersByTime(100);+ vi.advanceTimersByTime(150);expect(scrollIntoView).toHaveBeenCalledWith({block: "end",@@ -315,7 +318,7 @@ describe("attachKeyboardScroll", () => {const handler = listeners.get("resize")!;handler(new Event("resize"));- vi.advanceTimersByTime(100);+ vi.advanceTimersByTime(150);expect(container.style.transform).toBe("translateY(-300px)");detach();diff --git a/src/web/src/hooks/use-keyboard-scroll.ts b/src/web/src/hooks/use-keyboard-scroll.tsindex 7354622c7..461ae496c 100644--- a/src/web/src/hooks/use-keyboard-scroll.ts+++ b/src/web/src/hooks/use-keyboard-scroll.ts@@ -7,10 +7,11 @@ export interface KeyboardScrollController {cleanup: () => void;}+const DEBOUNCE_MS = 150;+/*** Creates a resize handler that calculates the keyboard offset from the visual- * viewport and applies a CSS variable to the target element so its parent- * container can shift above the keyboard.+ * viewport and applies a translateY to shift the input container above the keyboard.* Exported for testability — the hook wraps this with lifecycle management.*/export function createKeyboardScrollController(@@ -29,17 +30,23 @@ export function createKeyboardScrollController(el.scrollIntoView({ block: "end", behavior: "smooth" });return;}- const offset = window.innerHeight - vv.height - vv.offsetTop;+ const keyboardHeight = window.innerHeight - vv.height;const inputContainer = el.closest("[data-keyboard-offset]",) as HTMLElement | null;- if (inputContainer) {+ if (inputContainer && keyboardHeight > 0) {+ // Calculate how much of the container is hidden behind the keyboard.+ // Only shift enough to keep it visible, not the full keyboard height.+ const rect = inputContainer.getBoundingClientRect();+ const overflow = rect.bottom - vv.height - vv.offsetTop;inputContainer.style.transform =- offset > 0 ? `translateY(-${offset}px)` : "";+ overflow > 0 ? `translateY(-${overflow}px)` : "";+ } else if (inputContainer) {+ inputContainer.style.transform = "";} else {el.scrollIntoView({ block: "end", behavior: "smooth" });}- }, 100);+ }, DEBOUNCE_MS);};const cleanup = () => {clearTimeout(timeoutId);@@ -84,12 +91,51 @@ export function attachKeyboardScroll(};}+/**+ * On Chromium (Android Chrome 94+), uses the VirtualKeyboard API with CSS+ * env(keyboard-inset-height) for a smoother native experience.+ * Falls back to visualViewport + translateY for iOS Safari/Chrome.+ */+function attachVirtualKeyboardAPI(+ getTarget: () => HTMLElement | null,+ isFocused: boolean,+): (() => void) | null {+ if (typeof window === "undefined") return null;+ const vk = (navigator as any).virtualKeyboard;+ if (!vk) return null;++ vk.overlaysContent = true;++ const inputContainer = getTarget()?.closest(+ "[data-keyboard-offset]",+ ) as HTMLElement | null;+ if (!inputContainer) return null;++ const onGeometryChange = () => {+ if (!isFocused) {+ inputContainer.style.transform = "";+ return;+ }+ const { height } = vk.boundingRect;+ inputContainer.style.transform =+ height > 0 ? `translateY(-${height}px)` : "";+ };++ vk.addEventListener("geometrychange", onGeometryChange);+ return () => {+ vk.removeEventListener("geometrychange", onGeometryChange);+ inputContainer.style.transform = "";+ vk.overlaysContent = false;+ };+}+/*** On iOS Safari, the virtual keyboard can push the focused input off-screen* because the layout viewport doesn't always resize in sync with the visual* viewport. This hook listens to `window.visualViewport` resize events and* applies a translateY offset to the nearest [data-keyboard-offset] ancestor.*+ * On Android Chrome 94+, uses VirtualKeyboard API for smoother handling.* No-op when `visualViewport` is unavailable or the editor isn't focused.*/export function useKeyboardScroll(@@ -97,6 +143,14 @@ export function useKeyboardScroll(isFocused: boolean,) {useEffect(() => {+ // Try VirtualKeyboard API first (Android Chrome 94+)+ const vkDetach = attachVirtualKeyboardAPI(+ () => targetRef.current,+ isFocused,+ );+ if (vkDetach) return vkDetach;++ // Fallback: visualViewport resize (iOS Safari/Chrome)const detach = attachKeyboardScroll(() => targetRef.current, isFocused);return detach ?? undefined;}, [targetRef, isFocused]);