From dfcbd0f0c309be2965675ccff80b050a35792842 Mon Sep 17 00:00:00 2001 From: Kelvin Amoaba <97001695+AmoabaKelvin@users.noreply.github.com> Date: Tue, 10 Nov 2026 04:48:50 +0000 Subject: [PATCH] feat(mobile): draw the tab bar as the strip's square cells The rounded pill and round buttons read as a different control from the strip people know. The open tab is now the strip's raised, underlined cell from the screen edge, with the count and + as square cells in the same row, which also gives them 46x44 pt targets. --- .../src/components/nav-bar/NavBarButton.tsx | 19 +- mobile/src/i18n/locales/en.json | 18 +- mobile/src/session/MobileSessionHeader.tsx | 6 +- ...ionTabPill.tsx => MobileSessionTabBar.tsx} | 214 ++++++++++-------- .../session/tabs/MobileSessionTabsSheet.tsx | 4 +- .../use-mobile-session-presentation.ts | 2 +- 6 files changed, 140 insertions(+), 123 deletions(-) rename mobile/src/session/tabs/{MobileSessionTabPill.tsx => MobileSessionTabBar.tsx} (62%) diff --git a/mobile/src/components/nav-bar/NavBarButton.tsx b/mobile/src/components/nav-bar/NavBarButton.tsx index ec901f9ab0f..697704fa9e4 100644 --- a/mobile/src/components/nav-bar/NavBarButton.tsx +++ b/mobile/src/components/nav-bar/NavBarButton.tsx @@ -1,4 +1,4 @@ -import type { ComponentType, ReactNode, Ref } from 'react' +import type { ComponentType, Ref } from 'react' import { Pressable, type View } from 'react-native' import { colors, feedback, radii } from '../../theme/mobile-theme' import { themedStyleSheet } from '../../theme/themed-styles' @@ -10,25 +10,19 @@ type IconProps = { size?: number; color?: string; strokeWidth?: number } type NavBarButtonProps = { ref?: Ref + icon: ComponentType accessibilityLabel: string - accessibilityHint?: string onPress: () => void /** The screen or panel this button opens is showing. */ active?: boolean disabled?: boolean -} & ( - | { icon: ComponentType; children?: never } - /** Drawn in place of an icon, e.g. a tab count. */ - | { icon?: never; children: ReactNode } -) +} // A round top-bar button; the bar floats over content like the composer, so its buttons are round too. export function NavBarButton({ ref, icon: Icon, - children, accessibilityLabel, - accessibilityHint, onPress, active = false, disabled = false @@ -48,14 +42,9 @@ export function NavBarButton({ hitSlop={4} accessibilityRole="button" accessibilityLabel={accessibilityLabel} - accessibilityHint={accessibilityHint} accessibilityState={{ disabled, selected: active }} > - {Icon ? ( - - ) : ( - children - )} + ) } diff --git a/mobile/src/i18n/locales/en.json b/mobile/src/i18n/locales/en.json index 43dc83faaf1..dfc87cd1a81 100644 --- a/mobile/src/i18n/locales/en.json +++ b/mobile/src/i18n/locales/en.json @@ -2925,15 +2925,6 @@ "stop": "Stop", "yes": "Yes" }, - "tabPill": { - "oneTab": "1 tab", - "tabCount": "{{count}} tabs", - "anotherNeedsYou": "another tab needs you", - "hint": "Shows all tabs", - "next": "Next tab", - "previous": "Previous tab", - "actionsHint": "Shows actions for this tab" - }, "tabsSheet": { "needsYou": "Needs you", "working": "Working", @@ -2947,6 +2938,15 @@ "file": "File", "chat": "Chat", "terminal": "Terminal" + }, + "tabBar": { + "oneTab": "1 tab", + "tabCount": "{{count}} tabs", + "anotherNeedsYou": "another tab needs you", + "actionsHint": "Shows actions for this tab", + "next": "Next tab", + "previous": "Previous tab", + "hint": "Shows all tabs" } }, "chat": { diff --git a/mobile/src/session/MobileSessionHeader.tsx b/mobile/src/session/MobileSessionHeader.tsx index ec819c15d28..9020e7d7486 100644 --- a/mobile/src/session/MobileSessionHeader.tsx +++ b/mobile/src/session/MobileSessionHeader.tsx @@ -6,7 +6,7 @@ import { NavBar, NavBarRefreshLine } from '../components/nav-bar/NavBar' import { useRefreshHint } from '../query/refresh-hint' import { NavBarButton } from '../components/nav-bar/NavBarButton' import { MobileSessionHeaderMoreMenu } from './MobileSessionHeaderMoreMenu' -import { MobileSessionTabPill } from './tabs/MobileSessionTabPill' +import { MobileSessionTabBar } from './tabs/MobileSessionTabBar' import { MobileSessionTitleBlock } from './MobileSessionTitleBlock' import type { SessionTitleCard } from './tabs/use-session-title-card' import { styles } from './mobile-session-styles' @@ -58,11 +58,11 @@ export function MobileSessionHeader({ // Why: a sideways phone is ~390pt tall, so the tabs share the top bar instead of taking a second row. const hasTabs = visibleTabs.length > 0 const tabsInTopBar = (layout.isLandscapePhone || sideRail) && hasTabs - // Bar buttons otherwise leave the tab pill too narrow to read on a narrow header. + // Bar buttons otherwise leave the tab bar too narrow to read on a narrow header. const actionsCollapsed = tabsInTopBar && (headerWidth ?? layout.width) < 600 const sourceControlInBar = !isFloatingWorkspaceRoute && !actionsCollapsed const tabStrip = hasTabs ? ( - + return } return state && state !== 'idle' ? : null } // Mounted with the bare tab, so the motion preference is read before the dot arrives. -function ArrivingTabPillDot({ state }: { state: AgentDotState | undefined }) { +function ArrivingTabBarDot({ state }: { state: AgentDotState | undefined }) { const reducedMotion = useReducedMotionEnabled() if (!state || state === 'idle') { return null @@ -60,8 +58,8 @@ function ArrivingTabPillDot({ state }: { state: AgentDotState | undefined }) { ) } -/** The tab you're in as one pill: tap for every tab, swipe for the next one, + for a new one. */ -export function MobileSessionTabPill({ +/** The tab you're in as one cell: tap for its actions, swipe for the next one; the count shows every tab, + adds one. */ +export function MobileSessionTabBar({ controller, inTopBar, actionsCollapsed = false @@ -82,7 +80,7 @@ export function MobileSessionTabPill({ visibleTabs, terminals } = controller - // Why: the first tap must reach the pill with the keyboard open instead of only dismissing it (#5106). + // Why: the first tap must reach the bar with the keyboard open instead of only dismissing it (#5106). const keepsKeyboard = useKeyboardPersistingTaps('handled') const now = useNow(60_000) const rows = useMemo( @@ -101,7 +99,7 @@ export function MobileSessionTabPill({ const reducedMotion = useDrawerReducedMotion() const offset = useSharedValue(0) const width = useSharedValue(0) - // On the web, releasing a mouse drag also clicks the pill. + // On the web, releasing a mouse drag also clicks the tab. const dragEndedAtRef = useRef(0) const settle = (to: number) => withTiming( @@ -145,7 +143,7 @@ export function MobileSessionTabPill({ offset.value = settle(0) }) // Web has no worklet plugin; mapper hooks need this explicit dependency list. - const pillStyle = useAnimatedStyle( + const contentStyle = useAnimatedStyle( () => ({ transform: [{ translateX: offset.value }], opacity: 1 - Math.min(Math.abs(offset.value) / Math.max(width.value, 1), 1) * 0.6 @@ -156,14 +154,14 @@ export function MobileSessionTabPill({ const status = active?.dotState && active.dotState !== 'idle' ? active.dotState : undefined const countLabel = rows.length === 1 - ? t('session.tabPill.oneTab', '1 tab') - : t('session.tabPill.tabCount', '{{count}} tabs', { count: rows.length }) - const pillLabel = [active?.title, status ? agentStateLabel(status) : null] + ? t('session.tabBar.oneTab', '1 tab') + : t('session.tabBar.tabCount', '{{count}} tabs', { count: rows.length }) + const tabLabel = [active?.title, status ? agentStateLabel(status) : null] .filter(Boolean) .join(', ') const countAccessibilityLabel = [ countLabel, - othersNeedYou ? t('session.tabPill.anotherNeedsYou', 'another tab needs you') : null + othersNeedYou ? t('session.tabBar.anotherNeedsYou', 'another tab needs you') : null ] .filter(Boolean) .join(', ') @@ -178,77 +176,91 @@ export function MobileSessionTabPill({ return ( - { - width.value = event.nativeEvent.layout.width - }} - > - {/* pan-y keeps vertical touches with the page on the web. */} - - - [styles.pill, pressed && styles.pillPressed]} - onPress={openTabActions} - onLongPress={() => { - triggerMediumImpact() - openTabActions() - }} - delayLongPress={400} - disabled={!active} - accessibilityRole="button" - accessibilityLabel={pillLabel || countLabel} - accessibilityHint={t('session.tabPill.actionsHint', 'Shows actions for this tab')} - accessibilityActions={[ - ...(next - ? [{ name: 'nextTab', label: t('session.tabPill.next', 'Next tab') }] - : []), - ...(previous - ? [{ name: 'previousTab', label: t('session.tabPill.previous', 'Previous tab') }] - : []) - ]} - onAccessibilityAction={(event) => { - const name = event.nativeEvent.actionName - if (name === 'nextTab') { - step(next, -1) - } else if (name === 'previousTab') { - step(previous, 1) - } - }} - > + {/* pan-y keeps vertical touches with the page on the web. */} + + { + width.value = event.nativeEvent.layout.width + }} + > + [styles.tabPress, pressed && styles.cellPressed]} + onPress={openTabActions} + onLongPress={() => { + triggerMediumImpact() + openTabActions() + }} + delayLongPress={400} + disabled={!active} + accessibilityRole="button" + accessibilityLabel={tabLabel || countLabel} + accessibilityHint={t('session.tabBar.actionsHint', 'Shows actions for this tab')} + accessibilityActions={[ + ...(next ? [{ name: 'nextTab', label: t('session.tabBar.next', 'Next tab') }] : []), + ...(previous + ? [{ name: 'previousTab', label: t('session.tabBar.previous', 'Previous tab') }] + : []) + ]} + onAccessibilityAction={(event) => { + const name = event.nativeEvent.actionName + if (name === 'nextTab') { + step(next, -1) + } else if (name === 'previousTab') { + step(previous, 1) + } + }} + > + {/* Only the contents slide, so the cell stays flush with the screen edge. */} + {active ? ( <> - + - + ) : null} {active?.title ?? countLabel} - - - - - {/* Lined up under the header's buttons; a collapsed bar's + lives in the header's ⋯ menu. */} - + + + + [ + styles.sideCell, + actionsCollapsed && styles.lastCell, + pressed && styles.cellPressed + ]} onPress={() => setSheetOpen(true)} + accessibilityRole="button" accessibilityLabel={countAccessibilityLabel} - accessibilityHint={t('session.tabPill.hint', 'Shows all tabs')} + accessibilityHint={t('session.tabBar.hint', 'Shows all tabs')} > {rows.length} {othersNeedYou ? : null} - + + {/* A collapsed bar's + lives in the header's ⋯ menu. */} {!actionsCollapsed ? ( - [ + styles.sideCell, + styles.lastCell, + pressed && styles.cellPressed, + createDisabled && styles.cellDisabled + ]} disabled={createDisabled} onPress={handleOpenNewTab} + accessibilityRole="button" accessibilityLabel={t('session.tabStrip.newTab', 'New tab')} - icon={Plus} - /> + accessibilityState={{ disabled: createDisabled }} + > + + ) : null} ({ - // The right inset matches the nav bar's, so the + lines up with the ⋯ above it. bar: { height: 44, flexDirection: 'row', - alignItems: 'center', - gap: spacing.sm, - paddingHorizontal: spacing.md, + alignItems: 'stretch', borderTopWidth: 1, borderTopColor: colors.borderSubtle }, + // Cancels the top bar's vertical padding so the cells run the bar's full height. barInTopBar: { flex: 1, minWidth: 0, flexDirection: 'row', - alignItems: 'center', - gap: spacing.sm, - marginLeft: spacing.sm + alignItems: 'stretch', + alignSelf: 'stretch', + marginVertical: -spacing.xs, + marginLeft: spacing.md, + borderLeftWidth: 1, + borderLeftColor: colors.borderSubtle }, - track: { flex: 1, minWidth: 0 }, - pillFrame: { width: '100%' }, - pill: { - height: PILL_HEIGHT, - flexDirection: 'row', - alignItems: 'center', - gap: 7, - paddingLeft: 11, - paddingRight: spacing.md, - borderRadius: radii.control, - backgroundColor: colors.bgRaised + // The open tab, drawn like the strip's active tab: raised, with a line under it. + tabCell: { + flex: 1, + minWidth: 0, + backgroundColor: colors.bgRaised, + borderBottomWidth: 2, + borderBottomColor: colors.textSecondary, + borderRightWidth: 1, + borderRightColor: colors.borderSubtle, + overflow: 'hidden' }, - pillPressed: { backgroundColor: colors.translucentFill }, + tabPress: { + flex: 1, + justifyContent: 'center', + paddingLeft: spacing.lg, + paddingRight: spacing.sm + }, + tabContent: { flexDirection: 'row', alignItems: 'center', gap: 6 }, // Keeps web SVGs from shrinking before the title ellipsizes. mark: { flexShrink: 0 }, title: { - flex: 1, + flexShrink: 1, minWidth: 0, - fontSize: 15, + fontSize: 14, fontWeight: '600', color: colors.textPrimary }, + sideCell: { + width: 46, + alignItems: 'center', + justifyContent: 'center', + borderRightWidth: 1, + borderRightColor: colors.borderSubtle + }, + lastCell: { borderRightWidth: 0 }, + cellPressed: { backgroundColor: colors.translucentFill }, + cellDisabled: { opacity: feedback.disabledOpacity }, countBox: { minWidth: 19, height: 19, @@ -317,16 +345,16 @@ const styles = themedStyleSheet(() => ({ color: colors.textPrimary, fontVariant: ['tabular-nums'] }, - // Another tab needs you: a red dot on the button's corner, ringed in its colour. + // Another tab needs you: a red dot on the count's corner, ringed in the bar's colour. alert: { position: 'absolute', - top: 5, - right: 6, + top: 8, + right: 9, width: 9, height: 9, borderRadius: radii.pill, backgroundColor: colors.statusRed, borderWidth: 2, - borderColor: colors.bgRaised + borderColor: colors.bgPanel } })) diff --git a/mobile/src/session/tabs/MobileSessionTabsSheet.tsx b/mobile/src/session/tabs/MobileSessionTabsSheet.tsx index b1e6abc83d6..f8cd5cd1981 100644 --- a/mobile/src/session/tabs/MobileSessionTabsSheet.tsx +++ b/mobile/src/session/tabs/MobileSessionTabsSheet.tsx @@ -62,8 +62,8 @@ export function MobileSessionTabsSheet({ } const title = rows.length === 1 - ? t('session.tabPill.oneTab', '1 tab') - : t('session.tabPill.tabCount', '{{count}} tabs', { count: rows.length }) + ? t('session.tabBar.oneTab', '1 tab') + : t('session.tabBar.tabCount', '{{count}} tabs', { count: rows.length }) const renderRow = (row: MobileSessionTabRow) => { const current = row.tab.id === activeSessionTabId diff --git a/mobile/src/session/use-mobile-session-presentation.ts b/mobile/src/session/use-mobile-session-presentation.ts index dfd4896e63e..8f4b3c23331 100644 --- a/mobile/src/session/use-mobile-session-presentation.ts +++ b/mobile/src/session/use-mobile-session-presentation.ts @@ -76,7 +76,7 @@ export function useMobileSessionPresentation(scope: MobileSessionBulkCloseModel) presentedConnState === 'connected' ? showLoadingState && visibleTabs.length === 0 ? t('session.presentation.loadingTabs', 'Loading tabs') - : // The tab count lives on the tab pill, so the header names the branch instead. + : // The tab count lives in the tab bar, so the header names the branch instead. (scope.worktreeBranch ?? MOBILE_SESSION_STATUS_LABELS.connected) : showConnectionRetry ? t('session.presentation.tapToRetry', '{{status}} — tap to retry', {