Skip to content

Commit 5965c6c

Browse files
fix(mobile): the Android thread header keeps its height while typing
While the composer had the soft keyboard, the thread header dropped to a single row with the subtitle inline. It saved about 4 px and shifted everything below it each time the keyboard opened and closed. It only ever applied in Android split view. Remove the keyboard-compact header: the compact prop and its inline subtitle branch in the Android app bar, the single-line toolbar height, and the composer-editing flag that only existed to drive it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 54780ef commit 5965c6c

9 files changed

Lines changed: 8 additions & 73 deletions

‎apps/mobile/src/components/ui/AndroidScreenHeader.android.tsx‎

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { AppActivityIndicator } from "./AppActivityIndicator";
2-
import { Column, Row, Text as NativeText, RNHostView } from "@expo/ui/jetpack-compose";
3-
import { weight } from "@expo/ui/jetpack-compose/modifiers";
2+
import { Column, Text as NativeText, RNHostView } from "@expo/ui/jetpack-compose";
43
import { use, useState, type ReactNode } from "react";
54
import { View } from "react-native";
65

@@ -46,8 +45,6 @@ export function AndroidScreenHeader(props: {
4645
readonly onBack?: () => void;
4746
readonly embedded?: boolean;
4847
readonly hideBottomBorder?: boolean;
49-
/** One row with the subtitle after the title, for screens short on height. */
50-
readonly compact?: boolean;
5148
}) {
5249
const { colors } = useControlTheme();
5350
const titleTypography = useScaledTextRole("title");
@@ -77,7 +74,6 @@ export function AndroidScreenHeader(props: {
7774
/>
7875
) : null}
7976
<NativeAppBar
80-
singleLine={props.compact}
8177
navigationIcon={
8278
props.onBack || props.leading ? (
8379
<View collapsable={false} className="flex-row items-center">
@@ -108,26 +104,6 @@ export function AndroidScreenHeader(props: {
108104
>
109105
{props.title}
110106
</NativeText>
111-
) : props.compact ? (
112-
<Row verticalAlignment="center" horizontalArrangement={{ spacedBy: 8 }}>
113-
<NativeText
114-
color={colors["--color-header-foreground"]}
115-
maxLines={1}
116-
overflow="ellipsis"
117-
style={titleTypography}
118-
>
119-
{props.title}
120-
</NativeText>
121-
<NativeText
122-
color={colors["--color-foreground-muted"]}
123-
maxLines={1}
124-
overflow="ellipsis"
125-
style={subtitleTypography}
126-
modifiers={[weight(1)]}
127-
>
128-
{props.subtitle}
129-
</NativeText>
130-
</Row>
131107
) : (
132108
<Column>
133109
<NativeText

‎apps/mobile/src/components/ui/AppBar.android.tsx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ function AppBarView(props: AppBarProps & { readonly searchState?: SearchState })
204204
}
205205
embedded={props.sheet}
206206
hideBottomBorder={props.hideBottomBorder}
207-
compact={props.compact}
208207
actions={
209208
search && !inline
210209
? [

‎apps/mobile/src/components/ui/AppBar.types.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@ export interface AppBarProps {
120120
readonly onPress?: () => void;
121121
};
122122
readonly hideBottomBorder?: boolean;
123-
/** Android: one title row with the subtitle inline. iOS ignores it. */
124-
readonly compact?: boolean;
125123
readonly trailing?: ReactNode;
126124
readonly matchSearchSurface?: boolean;
127125
readonly optionsVersion?: unknown;

‎apps/mobile/src/components/ui/NativeAppBar.android.tsx‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ export function NativeAppBar(props: {
1212
readonly actions?: ReactElement;
1313
/** Compose nodes laid out by the bar itself, so they never wait on a React Native measure. */
1414
readonly nativeActions?: ReactElement;
15-
/** Shorter bar for a one-row title. */
16-
readonly singleLine?: boolean;
1715
}) {
1816
const { colors } = useControlTheme();
19-
const layout = useToolbarLayout(false, props.singleLine);
17+
const layout = useToolbarLayout();
2018
return (
2119
// The bar's height is fixed, so React Native lays out the screen below it from the first frame
2220
// instead of at zero height until Compose has measured and reported the bar.

‎apps/mobile/src/components/ui/useToolbarLayout.ts‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,16 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
44
import { useScaledTextRole } from "../../features/settings/appearance/useScaledTextRole";
55
import { useAndroidControlSizing } from "./useAndroidControlSizing";
66

7-
/**
8-
* Shared Android header geometry; class-based spacing uses the app's 14dp rem.
9-
* `singleLine` sizes the toolbar for a title row with the subtitle inline.
10-
*/
11-
export function useToolbarLayout(embedded = false, singleLine = false) {
7+
/** Shared Android header geometry; class-based spacing uses the app's 14dp rem. */
8+
export function useToolbarLayout(embedded = false) {
129
const insets = useSafeAreaInsets();
1310
const title = useScaledTextRole("title");
1411
const subtitle = useScaledTextRole("label");
1512
const { scale } = useAndroidControlSizing();
1613
const { fontScale } = useWindowDimensions();
1714
return {
1815
height: Math.ceil(
19-
singleLine
20-
? Math.max(48, 48 * scale, title.lineHeight * fontScale + 1)
21-
: Math.max(48, 56 * scale, (title.lineHeight + subtitle.lineHeight) * fontScale + 1),
16+
Math.max(48, 56 * scale, (title.lineHeight + subtitle.lineHeight) * fontScale + 1),
2217
),
2318
paddingTop: embedded ? 8 * scale : Math.max(insets.top, 12 * scale),
2419
paddingBottom: 7 * scale,

‎apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx‎

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
WorkspacePresentationHostContext,
44
} from "./workspace-presentation-context";
55
import { useAndroidFloatingTabs } from "../settings/appearance/AppearancePreferencesProvider";
6-
import { useSoftKeyboardShowing } from "../keyboard/useSoftKeyboardShowing";
76
import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area-context";
87
import {
98
AdaptiveWorkspaceContext,
@@ -215,7 +214,6 @@ function useStableActions(actions: Required<AdaptiveWorkspaceActions>): Adaptive
215214
openWorkspaceTab: (tab, options) => latest.current.openWorkspaceTab(tab, options),
216215
setAuxiliaryPaneWidth: (width) => latest.current.setAuxiliaryPaneWidth(width),
217216
setNativeInspectorWidth: (width) => latest.current.setNativeInspectorWidth(width),
218-
setComposerEditing: (editing) => latest.current.setComposerEditing(editing),
219217
}));
220218
return stable;
221219
}
@@ -321,12 +319,6 @@ function AdaptiveWorkspaceLayoutContent(
321319
nativeWorkspace,
322320
usesSplitView: baseLayout.usesSplitView,
323321
});
324-
const [composerEditing, setComposerEditing] = useState(false);
325-
const softKeyboardVisible = useSoftKeyboardShowing();
326-
// Keyed on the soft keyboard, not focus: Back closes the keyboard while the editor keeps focus.
327-
// It only compacts the thread header; the sidebar stays, so no pane changes width for typing.
328-
const composerKeyboardActive =
329-
Platform.OS === "android" && baseLayout.usesSplitView && composerEditing && softKeyboardVisible;
330322
const showPrimarySidebar = !workspacePage && (primarySidebarPinned || preferredSidebarVisible);
331323
// Medium windows float the sidebar over a page; beside a list it keeps its room.
332324
const sidebarFloats =
@@ -928,7 +920,6 @@ function AdaptiveWorkspaceLayoutContent(
928920
setAuxiliaryPaneWidth: setFileInspectorPreferredWidth,
929921
setNativeInspectorWidth: (width: number) =>
930922
setNativeInspectorWidthFraction(inspectorWidthFor(width / viewportWidth) / viewportWidth),
931-
setComposerEditing,
932923
});
933924
const contextValue = useMemo(
934925
() => ({ ...actions, layout, nativeInspectorWidth, workspacePageWidth }),
@@ -941,17 +932,9 @@ function AdaptiveWorkspaceLayoutContent(
941932
fileInspector,
942933
primarySidebarSearchQuery,
943934
sidebarToggleable,
944-
composerKeyboardActive,
945935
sidebarByOrientation,
946936
}),
947-
[
948-
panes,
949-
fileInspector,
950-
primarySidebarSearchQuery,
951-
sidebarToggleable,
952-
composerKeyboardActive,
953-
sidebarByOrientation,
954-
],
937+
[panes, fileInspector, primarySidebarSearchQuery, sidebarToggleable, sidebarByOrientation],
955938
);
956939

957940
const inspectorSheet = (

‎apps/mobile/src/features/layout/adaptive-workspace-context.ts‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ export interface AdaptiveWorkspaceActions {
3636
) => void;
3737
readonly setAuxiliaryPaneWidth: (width: number) => void;
3838
readonly setNativeInspectorWidth: (width: number) => void;
39-
/** The thread composer reports its focus so the layout can make room for typing. */
40-
readonly setComposerEditing: (editing: boolean) => void;
4139
}
4240

4341
/** Changes only with the window (size, fold, hinge), never with a pane toggle or the keyboard. */
@@ -58,11 +56,6 @@ interface WorkspacePaneStateValue {
5856
* its sidebar, and on a workspace page (Android Settings, Usage) that covers it.
5957
*/
6058
readonly sidebarToggleable: boolean;
61-
/**
62-
* Android split view while the thread composer has the soft keyboard: the
63-
* sidebar and rail step aside and the thread header drops to one line.
64-
*/
65-
readonly composerKeyboardActive: boolean;
6659
/**
6760
* Whether the sidebar shows in each orientation, where it floats over the content in portrait
6861
* (the unfolded Duo). The native split switches between them as a rotation starts.
@@ -95,14 +88,12 @@ export const AdaptiveWorkspaceContext = createContext<AdaptiveWorkspaceLayoutVal
9588
setAuxiliaryPaneWidth: () => undefined,
9689
nativeInspectorWidth: 0,
9790
setNativeInspectorWidth: () => undefined,
98-
setComposerEditing: () => undefined,
9991
});
10092
export const WorkspacePaneStateContext = createContext<WorkspacePaneStateValue>({
10193
panes: compactPanes,
10294
fileInspector: compactFileInspector,
10395
primarySidebarSearchQuery: "",
10496
sidebarToggleable: false,
105-
composerKeyboardActive: false,
10697
sidebarByOrientation: null,
10798
});
10899

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
588588
);
589589
const isVoiceInputPresented = voicePresentation.statusKind === "active";
590590
const isExpanded = isFocused || settingsSheetPresentation.keepsComposerExpanded;
591-
const { layout, setComposerEditing } = useAdaptiveWorkspaceLayout();
591+
const { layout } = useAdaptiveWorkspaceLayout();
592592
const floatingSidebarComposer = useAndroidFloatingTabs() && layout.usesSplitView;
593593
const sidebarWorkspaceTabs = useSidebarWorkspaceTabs();
594594
const deviceType = useDeviceType();
@@ -623,8 +623,6 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
623623
sendBlockedReason === null &&
624624
!modelUnavailable;
625625

626-
// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- clears the workspace layout's composer-editing flag when the composer unmounts
627-
useEffect(() => () => setComposerEditing(false), [setComposerEditing]);
628626
// A pending sheet presentation or focus restore has no composer left to act on.
629627
// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- disposes the pending settings sheet presentation and focus restore on unmount
630628
useEffect(() => () => disposeSettingsSheetPresentation(), []);
@@ -662,14 +660,12 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
662660
setIsFocused(true);
663661
settingsSheetPresentation.onEditorFocusChange(true);
664662
onEditorFocusChange?.(true);
665-
setComposerEditing(true);
666663
};
667664

668665
const handleBlur = () => {
669666
setIsFocused(false);
670667
settingsSheetPresentation.onEditorFocusChange(false);
671668
onEditorFocusChange?.(false);
672-
setComposerEditing(false);
673669
};
674670
const handleSend = async (followUp?: ActiveTurnComposerAction) => {
675671
if (

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function ThreadHeader(props: {
2424
}) {
2525
const goBack = useWorkspaceBackNavigation("threads");
2626
const { toggleAuxiliaryPane, startNewTask } = useAdaptiveWorkspaceLayout();
27-
const { panes, composerKeyboardActive } = useWorkspacePaneState();
27+
const { panes } = useWorkspacePaneState();
2828
const gitMenu = useThreadGitMenuDefinition(props.gitControls);
2929
const terminalMenu = threadTerminalMenu(props.gitControls);
3030
const filesVisible = props.inspectorMode === "files" && panes.auxiliaryPaneVisible;
@@ -60,7 +60,6 @@ export function ThreadHeader(props: {
6060
actions={actions}
6161
menus={menus}
6262
hideBottomBorder
63-
compact={composerKeyboardActive}
6463
/>
6564
);
6665
}

0 commit comments

Comments
 (0)