Skip to content

Commit ee59ab2

Browse files
fix(mobile): the composer and search bars move with their iOS columns (#33543)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent dd0737d commit ee59ab2

3 files changed

Lines changed: 122 additions & 64 deletions

File tree

‎apps/mobile/src/features/layout/inspector-host.tsx‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@ const PANE_HEADER_OPTIONS = { ...GLASS_HEADER_OPTIONS, headerShown: false };
2323

2424
function PaneHeader(props: { readonly store: InspectorBarStore }) {
2525
const options = useSyncExternalStore(props.store.subscribe, props.store.getSnapshot);
26-
return <V5StackHeader options={{ ...PANE_HEADER_OPTIONS, ...options }} canGoBack={false} />;
26+
// Its own search identity, so opening the inspector doesn't morph the sidebar's search into it.
27+
return (
28+
<V5StackHeader
29+
options={{ ...PANE_HEADER_OPTIONS, ...options }}
30+
canGoBack={false}
31+
searchIdentifier="inspector-search"
32+
/>
33+
);
2734
}
2835

2936
function PaneScreenContent(props: {

‎apps/mobile/src/features/threads/ThreadDetailScreen.tsx‎

Lines changed: 98 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ import Animated, {
114114
} from "react-native-reanimated";
115115
import { useSafeAreaInsets } from "react-native-safe-area-context";
116116
import { useBarOverlap } from "../../components/ui/useBarInset";
117-
import { useWorkspaceContentWidth } from "../layout/workspace-content-width";
117+
import {
118+
useWorkspaceContentWidth,
119+
WorkspaceSettledContentWidthContext,
120+
} from "../layout/workspace-content-width";
118121
import { useAdaptiveWorkspaceLayout } from "../layout/adaptive-workspace-context";
119122
import { useNativeWorkspaceColumnsSupported } from "../../native/NativeWorkspaceColumns";
120123
import {
@@ -317,6 +320,17 @@ export interface ThreadDetailScreenProps {
317320

318321
// iOS questions overlay the controls; Android questions stack with child approvals.
319322
const ComposerPanels = Platform.OS === "android" ? Animated.ScrollView : Animated.View;
323+
324+
/** Hands the feed the screen width measured for a native column; elsewhere keeps the inherited one. */
325+
function ColumnWidth(props: { readonly width: number | null; readonly children: React.ReactNode }) {
326+
return props.width === null ? (
327+
props.children
328+
) : (
329+
<WorkspaceSettledContentWidthContext value={props.width}>
330+
{props.children}
331+
</WorkspaceSettledContentWidthContext>
332+
);
333+
}
320334
const USAGE_LIMITS_PANEL_GAP = 12;
321335
const USAGE_LIMITS_PANEL_MIN_HEIGHT = 44;
322336

@@ -1022,8 +1036,13 @@ function ThreadDetailBody(
10221036
// Android lays the screen out below its opaque header and reports a zero
10231037
// header height, so the window height overstates the room by the header.
10241038
const [screenHeight, setScreenHeight] = useState<number | null>(null);
1039+
const [screenWidth, setScreenWidth] = useState<number | null>(null);
10251040
const handleScreenLayout = (event: LayoutChangeEvent) => {
10261041
setScreenHeight(event.nativeEvent.layout.height);
1042+
const width = Math.round(event.nativeEvent.layout.width);
1043+
setScreenWidth((current) =>
1044+
current !== null && Math.abs(current - width) <= 1 ? current : width,
1045+
);
10271046
};
10281047
const screenAreaHeight = screenHeight ?? windowHeight;
10291048
const draftViewportHeight = screenAreaHeight - navigationHeaderHeight - liveKeyboardHeight;
@@ -1211,6 +1230,13 @@ function ThreadDetailBody(
12111230
}
12121231
: { width: "auto", right: controlInsets.right },
12131232
);
1233+
// A native column resizes the screen before JS hears of it. The feed and the composer take the
1234+
// measured width in one render, so they change size together rather than the composer first.
1235+
const columnWidth = usesNativeWorkspaceColumns && isSplitLayout ? screenWidth : null;
1236+
const columnComposerWidthStyle =
1237+
columnWidth === null
1238+
? null
1239+
: { width: Math.max(0, columnWidth - controlInsets.left - controlInsets.right) };
12141240
const selectedInstanceId = props.selectedThread.modelSelection.instanceId;
12151241
useAtomMount(threadStreamHaptics(props.selectedThreadDetailRef));
12161242
const selectedProviderSkills = (() => {
@@ -1436,54 +1462,58 @@ function ThreadDetailBody(
14361462
)}
14371463
>
14381464
<WorkspaceMutationIdProvider threadRef={props.selectedThreadDetailRef}>
1439-
<ThreadFeed
1440-
toolCallVisibility={toolCallVisibility}
1441-
environmentId={props.environmentId}
1442-
threadId={props.selectedThread.id}
1443-
detailRef={props.selectedThreadDetailRef}
1444-
workspaceRoot={props.threadCwd}
1445-
feed={props.selectedThreadFeed}
1446-
pendingHandoff={props.pendingHandoff}
1447-
worktreeSetup={props.worktreeSetup}
1448-
setupWorkingStartedAt={props.setupWorkingStartedAt}
1449-
queuedMessages={props.queuedMessages}
1450-
dispatchingMessageId={props.dispatchingMessageId}
1451-
// A native subagent has no composer to edit a pending message in;
1452-
// Cancel on the edit banner would discard it.
1453-
onEditPendingMessage={
1454-
isProviderSubagent || pendingMessageEditBlocked ? null : handleEditPendingMessage
1455-
}
1456-
contentPresentation={props.contentPresentation}
1457-
threadTitle={props.selectedThread.title}
1458-
latestRun={props.activityRun}
1459-
activeWorkStartedAt={props.activeWorkStartedAt}
1460-
runlessWorkActive={props.runlessWorkActive ?? false}
1461-
listRef={listRef}
1462-
freeze={freeze}
1463-
anchorMessageId={anchorMessageId}
1464-
jumpToMessageId={jumpMessageLoaded ? jumpMessageId : null}
1465-
onJumpedToMessage={() => finishThreadMessageJump(selectedThreadKey)}
1466-
contentInsetEndAdjustment={combinedContentInsetEndAdjustment}
1467-
keyboardOffset={composerKeyboardOffset}
1468-
sendingWithKeyboard={sendingWithKeyboard}
1469-
fitShortFeedToViewport={questionInFlow && !isKeyboardVisible}
1470-
contentTopInset={0}
1471-
contentBottomInset={
1472-
questionInFlow
1473-
? 0
1474-
: estimatedOverlayHeight +
1475-
(showFloatingStatus ? FLOATING_WORKING_CONTROL_COVERAGE : 0)
1476-
}
1477-
contentMaxWidth={contentMaxWidth}
1478-
historyControls={props.historyControls}
1479-
contentSideInsets={nativeMetrics?.safeArea}
1480-
layoutVariant={layoutVariant}
1481-
usesAutomaticContentInsets={props.usesAutomaticContentInsets}
1482-
onHeaderMaterialVisibilityChange={props.onHeaderMaterialVisibilityChange}
1483-
onIsAtEndChange={setIsAtEnd}
1484-
skills={selectedProviderSkills}
1485-
onUseArtifactTemplate={handleUseArtifactTemplate}
1486-
/>
1465+
<ColumnWidth width={columnWidth}>
1466+
<ThreadFeed
1467+
toolCallVisibility={toolCallVisibility}
1468+
environmentId={props.environmentId}
1469+
threadId={props.selectedThread.id}
1470+
detailRef={props.selectedThreadDetailRef}
1471+
workspaceRoot={props.threadCwd}
1472+
feed={props.selectedThreadFeed}
1473+
pendingHandoff={props.pendingHandoff}
1474+
worktreeSetup={props.worktreeSetup}
1475+
setupWorkingStartedAt={props.setupWorkingStartedAt}
1476+
queuedMessages={props.queuedMessages}
1477+
dispatchingMessageId={props.dispatchingMessageId}
1478+
// A native subagent has no composer to edit a pending message in;
1479+
// Cancel on the edit banner would discard it.
1480+
onEditPendingMessage={
1481+
isProviderSubagent || pendingMessageEditBlocked
1482+
? null
1483+
: handleEditPendingMessage
1484+
}
1485+
contentPresentation={props.contentPresentation}
1486+
threadTitle={props.selectedThread.title}
1487+
latestRun={props.activityRun}
1488+
activeWorkStartedAt={props.activeWorkStartedAt}
1489+
runlessWorkActive={props.runlessWorkActive ?? false}
1490+
listRef={listRef}
1491+
freeze={freeze}
1492+
anchorMessageId={anchorMessageId}
1493+
jumpToMessageId={jumpMessageLoaded ? jumpMessageId : null}
1494+
onJumpedToMessage={() => finishThreadMessageJump(selectedThreadKey)}
1495+
contentInsetEndAdjustment={combinedContentInsetEndAdjustment}
1496+
keyboardOffset={composerKeyboardOffset}
1497+
sendingWithKeyboard={sendingWithKeyboard}
1498+
fitShortFeedToViewport={questionInFlow && !isKeyboardVisible}
1499+
contentTopInset={0}
1500+
contentBottomInset={
1501+
questionInFlow
1502+
? 0
1503+
: estimatedOverlayHeight +
1504+
(showFloatingStatus ? FLOATING_WORKING_CONTROL_COVERAGE : 0)
1505+
}
1506+
contentMaxWidth={contentMaxWidth}
1507+
historyControls={props.historyControls}
1508+
contentSideInsets={nativeMetrics?.safeArea}
1509+
layoutVariant={layoutVariant}
1510+
usesAutomaticContentInsets={props.usesAutomaticContentInsets}
1511+
onHeaderMaterialVisibilityChange={props.onHeaderMaterialVisibilityChange}
1512+
onIsAtEndChange={setIsAtEnd}
1513+
skills={selectedProviderSkills}
1514+
onUseArtifactTemplate={handleUseArtifactTemplate}
1515+
/>
1516+
</ColumnWidth>
14871517
</WorkspaceMutationIdProvider>
14881518
</RenderErrorBoundary>
14891519
</View>
@@ -1533,18 +1563,25 @@ function ThreadDetailBody(
15331563
pointerEvents="box-none"
15341564
style={
15351565
questionInFlow
1536-
? isSplitLayout
1537-
? composerWidthStyle
1538-
: undefined
1539-
: [
1540-
{
1541-
position: "absolute",
1542-
bottom: controlInsets.bottom,
1543-
left: controlInsets.left,
1544-
right: controlInsets.right,
1545-
},
1546-
composerWidthStyle,
1547-
]
1566+
? (columnComposerWidthStyle ?? (isSplitLayout ? composerWidthStyle : undefined))
1567+
: columnComposerWidthStyle
1568+
? [
1569+
{
1570+
position: "absolute",
1571+
bottom: controlInsets.bottom,
1572+
left: controlInsets.left,
1573+
},
1574+
columnComposerWidthStyle,
1575+
]
1576+
: [
1577+
{
1578+
position: "absolute",
1579+
bottom: controlInsets.bottom,
1580+
left: controlInsets.left,
1581+
right: controlInsets.right,
1582+
},
1583+
composerWidthStyle,
1584+
]
15481585
}
15491586
>
15501587
{/* No paddingTop here: the overlay's measured height becomes the

‎apps/mobile/src/native/V5StackHeader.ios.tsx‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ export function V5StackHeader(props: {
156156
readonly column?: "primary" | "detail";
157157
/** The workspace's compose action, shown as its own group in this column's bar. */
158158
readonly onCompose?: () => void;
159+
/** UIKit morphs search items that share an identifier between bars as columns change. */
160+
readonly searchIdentifier?: string;
159161
}) {
160162
const { options } = props;
161163
const theme = useMobileNavigationTheme();
@@ -182,7 +184,14 @@ export function V5StackHeader(props: {
182184
const bottom = toolbar.flatMap<HeaderItem>((item, index) => {
183185
if (item.type === "mailSearchToolbar") return [];
184186
if (item.type === "searchBarPlacement")
185-
return [{ type: "item", id: `toolbar-search:${index}`, searchBarPlacement: true }];
187+
return [
188+
{
189+
type: "item",
190+
id: `toolbar-search:${index}`,
191+
searchBarPlacement: true,
192+
...(props.searchIdentifier ? { identifier: props.searchIdentifier } : {}),
193+
},
194+
];
186195
return convertItems([item], `toolbar:${index}`);
187196
});
188197
if (mailSearch) {
@@ -199,7 +208,12 @@ export function V5StackHeader(props: {
199208
if (bottomSearch) {
200209
if (spacesSearch && bottom.length)
201210
bottom.push({ type: "spacer", id: "before-search", sizing: "fixed", width: 8 });
202-
bottom.push({ type: "item", id: "home-search", searchBarPlacement: true });
211+
bottom.push({
212+
type: "item",
213+
id: "home-search",
214+
searchBarPlacement: true,
215+
...(props.searchIdentifier ? { identifier: props.searchIdentifier } : {}),
216+
});
203217
if (spacesSearch && mailSearch.onComposePress)
204218
bottom.push({ type: "spacer", id: "after-search", sizing: "fixed", width: 8 });
205219
}

0 commit comments

Comments
 (0)