From ebd02c38b44527cc8bf83664e2183daef37890e5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 29 Oct 2026 16:56:46 +1100 Subject: [PATCH 1/2] fix(mobile): composer suggestions stay readable on short screens The skill and command list sat above the composer with a fixed 180pt cap, so on the iPhone Duo front screen with the keyboard up it ran off the top and under the header. Cap it to the room above the composer, and when that room is under about three rows, lay the list over the composer's top with frosted glass instead. iOS and Android share the placement rule. Co-Authored-By: Claude Opus 5.5 --- .../threads/ComposerCommandPopover.tsx | 15 +++-- .../threads/ComposerPopoverAnchor.android.tsx | 65 ++++++++++++++----- .../threads/ComposerPopoverAnchor.tsx | 27 ++++++-- .../features/threads/ComposerPopoverHost.tsx | 36 +++++++++- .../src/features/threads/ThreadComposer.tsx | 17 +++-- .../features/threads/ThreadDetailScreen.tsx | 16 ++++- 6 files changed, 140 insertions(+), 36 deletions(-) diff --git a/apps/mobile/src/features/threads/ComposerCommandPopover.tsx b/apps/mobile/src/features/threads/ComposerCommandPopover.tsx index cbe89f5fb8768..23bba7b9b03e3 100644 --- a/apps/mobile/src/features/threads/ComposerCommandPopover.tsx +++ b/apps/mobile/src/features/threads/ComposerCommandPopover.tsx @@ -78,19 +78,26 @@ interface ComposerCommandPopoverProps { readonly triggerKind: ComposerTriggerKind | null; readonly isLoading: boolean; readonly error?: string | null; + /** Clear glass reads over the feed; over the composer's own text it needs the frosted style. */ + readonly overlapsComposer?: boolean; readonly onSelect: (item: ComposerCommandItem) => void; } -function PopoverSurface(props: { readonly children: React.ReactNode; readonly style?: ViewStyle }) { +function PopoverSurface(props: { + readonly children: React.ReactNode; + readonly frosted: boolean; + readonly style?: ViewStyle; +}) { const baseStyle: ViewStyle = { borderRadius: 16, overflow: "hidden", + flexShrink: 1, ...props.style, }; return ( @@ -213,7 +220,7 @@ export const ComposerCommandPopover = memo(function ComposerCommandPopover( const label = groupLabel(props.triggerKind); return ( - + {label ? ( @@ -223,7 +230,7 @@ export const ComposerCommandPopover = memo(function ComposerCommandPopover( ) : null} {props.items.length > 0 ? ( diff --git a/apps/mobile/src/features/threads/ComposerPopoverAnchor.android.tsx b/apps/mobile/src/features/threads/ComposerPopoverAnchor.android.tsx index 54ccaec0d29e0..e0fa0909b001a 100644 --- a/apps/mobile/src/features/threads/ComposerPopoverAnchor.android.tsx +++ b/apps/mobile/src/features/threads/ComposerPopoverAnchor.android.tsx @@ -2,18 +2,26 @@ import type { ReactNode } from "react"; import { useEffect, useRef, useState } from "react"; import { View, type ViewInstance } from "react-native"; -import { useComposerPopoverHost } from "./ComposerPopoverHost"; - -const COMPOSER_GAP = 8; +import { + COMPOSER_POPOVER_GAP, + composerPopoverPlacement, + useComposerPopoverHost, +} from "./ComposerPopoverHost"; type Frame = { readonly x: number; readonly y: number; readonly width: number }; /** Android only delivers drags inside parent bounds; bottom-full popover lists cannot scroll. */ -export function ComposerPopoverAnchor(props: { readonly children: ReactNode }) { +export function ComposerPopoverAnchor(props: { + readonly children: (overlapsComposer: boolean) => ReactNode; +}) { const host = useComposerPopoverHost(); const anchorRef = useRef(null); const [frame, setFrame] = useState(null); const popoverHeight = host?.popoverHeight; + const placement = composerPopoverPlacement(host); + // A pinned popover's top sits `above` over the composer whatever its height. + const pinnedAbove = placement?.pinnedToTop ? placement.above : null; + const measuredHeightRef = useRef(0); const measure = () => { const hostView = host?.hostRef.current; @@ -31,25 +39,46 @@ export function ComposerPopoverAnchor(props: { readonly children: ReactNode }) { // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- measures the anchor view after every commit and hands its popover content to the composer popover host useEffect(() => { measure(); + if (frame === null) { + host?.setContent(null); + return; + } + // The host's top can sit above the screen while the keyboard lifts it, so the room + // estimate, not the anchor's offset, bounds the height. + const bottom = frame.y - COMPOSER_POPOVER_GAP; + const pinnedToTop = placement?.pinnedToTop === true; + const height = placement === null ? bottom : Math.min(bottom, placement.maxHeight); host?.setContent( - frame === null ? null : ( + { + measuredHeightRef.current = event.nativeEvent.layout.height; + popoverHeight?.set(pinnedAbove ?? measuredHeightRef.current); + }} > - { - popoverHeight?.set(event.nativeEvent.layout.height); - }} - > - {props.children} - + {props.children(pinnedToTop)} - ), + , ); }); + // New room can leave the popover's own size unchanged, so no layout event reports it. + // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- re-reports the popover's height above the composer when the room estimate changes + useEffect(() => { + if (measuredHeightRef.current === 0) return; + popoverHeight?.set(pinnedAbove ?? measuredHeightRef.current); + }, [pinnedAbove, popoverHeight]); + const setHostContent = host?.setContent; // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- clears the popover host's content and shared height value when the anchor unmounts useEffect( @@ -61,7 +90,9 @@ export function ComposerPopoverAnchor(props: { readonly children: ReactNode }) { ); if (host === null) { - return {props.children}; + return ( + {props.children(false)} + ); } return ( diff --git a/apps/mobile/src/features/threads/ComposerPopoverAnchor.tsx b/apps/mobile/src/features/threads/ComposerPopoverAnchor.tsx index b38bfc12eebfc..dbc63b5ac316a 100644 --- a/apps/mobile/src/features/threads/ComposerPopoverAnchor.tsx +++ b/apps/mobile/src/features/threads/ComposerPopoverAnchor.tsx @@ -2,10 +2,18 @@ import type { ReactNode } from "react"; import { useEffect } from "react"; import { View } from "react-native"; -import { useComposerPopoverHost } from "./ComposerPopoverHost"; +import { + COMPOSER_POPOVER_GAP, + composerPopoverPlacement, + useComposerPopoverHost, +} from "./ComposerPopoverHost"; -export function ComposerPopoverAnchor(props: { readonly children: ReactNode }) { - const popoverHeight = useComposerPopoverHost()?.popoverHeight; +export function ComposerPopoverAnchor(props: { + readonly children: (overlapsComposer: boolean) => ReactNode; +}) { + const host = useComposerPopoverHost(); + const popoverHeight = host?.popoverHeight; + const placement = composerPopoverPlacement(host); // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- resets the popover host's shared height value when the anchor unmounts useEffect( () => () => { @@ -15,12 +23,19 @@ export function ComposerPopoverAnchor(props: { readonly children: ReactNode }) { ); return ( { - popoverHeight?.set(event.nativeEvent.layout.height); + popoverHeight?.set( + placement?.pinnedToTop ? placement.above : event.nativeEvent.layout.height, + ); }} > - {props.children} + {props.children(placement?.pinnedToTop === true)} ); } diff --git a/apps/mobile/src/features/threads/ComposerPopoverHost.tsx b/apps/mobile/src/features/threads/ComposerPopoverHost.tsx index bba205270d396..c16212d759668 100644 --- a/apps/mobile/src/features/threads/ComposerPopoverHost.tsx +++ b/apps/mobile/src/features/threads/ComposerPopoverHost.tsx @@ -8,6 +8,9 @@ type ComposerPopoverHostValue = { readonly setContent: (content: ReactNode) => void; readonly layoutVersion: number; readonly popoverHeight: SharedValue; + /** Room between the header and the composer's top, or null when unknown. */ + readonly popoverRoom: number | null; + readonly composerHeight: number; }; const ComposerPopoverHostContext = createContext(null); @@ -16,16 +19,47 @@ export function useComposerPopoverHost() { return useContext(ComposerPopoverHostContext); } +export const COMPOSER_POPOVER_GAP = 8; +// The group label plus about three rows. +const COMPOSER_POPOVER_MIN_HEIGHT = 160; + +/** + * With too little room above the composer (the Duo's front screen, keyboard up), the popover pins + * below the header and grows down over the composer, stopping at its bottom edge so no row hides + * behind the keyboard. `above` is the height it can use above the composer. + */ +export function composerPopoverPlacement(host: ComposerPopoverHostValue | null) { + if (host?.popoverRoom == null) return null; + const above = Math.max(0, host.popoverRoom - COMPOSER_POPOVER_GAP * 2); + if (above >= COMPOSER_POPOVER_MIN_HEIGHT) { + return { above, maxHeight: above, pinnedToTop: false }; + } + const maxHeight = Math.min( + COMPOSER_POPOVER_MIN_HEIGHT, + above + host.composerHeight - COMPOSER_POPOVER_GAP, + ); + return { above, maxHeight, pinnedToTop: true }; +} + /** Mount inside KeyboardStickyView for Android gestures. Hide explicitly because portal content outlives its subtree. */ export function ComposerPopoverHost(props: { readonly hidden: boolean; readonly popoverHeight: SharedValue; + readonly popoverRoom: number | null; + readonly composerHeight: number; readonly children: ReactNode; }) { const hostRef = useRef(null); const [content, setContent] = useState(null); const [layoutVersion, setLayoutVersion] = useState(0); - const value = { hostRef, setContent, layoutVersion, popoverHeight: props.popoverHeight }; + const value = { + hostRef, + setContent, + layoutVersion, + popoverHeight: props.popoverHeight, + popoverRoom: props.popoverRoom, + composerHeight: props.composerHeight, + }; return ( diff --git a/apps/mobile/src/features/threads/ThreadComposer.tsx b/apps/mobile/src/features/threads/ThreadComposer.tsx index 024fc14179fd2..bf412426a0a1c 100644 --- a/apps/mobile/src/features/threads/ThreadComposer.tsx +++ b/apps/mobile/src/features/threads/ThreadComposer.tsx @@ -825,13 +825,16 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps composerMenu.trigger && (composerMenu.items.length > 0 || composerMenu.trigger.kind === "pull-request") ? ( - + {(overlapsComposer) => ( + + )} ) : null} diff --git a/apps/mobile/src/features/threads/ThreadDetailScreen.tsx b/apps/mobile/src/features/threads/ThreadDetailScreen.tsx index 27655f503bd65..a2494d3387408 100644 --- a/apps/mobile/src/features/threads/ThreadDetailScreen.tsx +++ b/apps/mobile/src/features/threads/ThreadDetailScreen.tsx @@ -872,6 +872,15 @@ function ThreadDetailBody(props: ThreadDetailScreenProps) { composerOverlapHeight: composerBottomInset, }), ); + // The sticky view lifts the composer by the keyboard less its opened offset, and the + // composer's measured height already includes its bottom inset. A measured Android screen + // already sits below its opaque header. + const composerPopoverRoom = + screenAreaHeight - + (Platform.OS === "android" && screenHeight !== null ? 0 : navigationHeaderHeight) - + controlInsets.bottom - + (keyboardStickyEnabled ? Math.max(0, liveKeyboardHeight - composerKeyboardOffset) : 0) - + composerOverlapHeight; // The usage panel stacks with the composer and any approval card, so it gets // whatever room they leave below the header. Measured only while it is open // so typing in the composer does not re-render the screen. @@ -1358,7 +1367,12 @@ function ThreadDetailBody(props: ThreadDetailScreenProps) { style={{ position: "absolute", bottom: 0, left: 0, right: 0, top: 0 }} offset={{ closed: 0, opened: composerKeyboardOffset }} > -