feat(mobile): press feedback everywhere, smoother motion, and Reduce Motion for sheets (#36885)

* fix(mobile): stop page bounce and input zoom; URL keyboard for new browser tabs

* feat(mobile): smoother motion, press feedback everywhere, reduced motion for sheets

Working rings and the tool-run pulse run as compositor animations on the
page. Sheets, the right panel, the page stack and the pager cross-fade under
Reduce Motion. The right panel shares the sheet's drag physics. The composer
cross-fades Send/Stop/Save and the mic, jump-to-latest and prompt cards ease
in, banners ease their height, and every Pressable shows a pressed state.
Pairing gets a success beat, and the clean state fades in after a commit.
This commit is contained in:
Kelvin Amoaba
2026-11-01 04:29:28 +00:00
committed by GitHub
parent fbb3381dfe
commit 6aa71261b9
165 changed files with 1954 additions and 710 deletions
@@ -102,8 +102,10 @@ export const MOBILE_WEB_APP_ROOT_RESET =
// Use zero-specificity native parity: remove text-field focus rings only; keyboard buttons keep browser rings.
// Disable body text selection/callout to prevent WebKit/Android long-press interference, including portaled modals; fields opt back in.
// Stop the WebView rubber-banding the whole page (headers included) when an inner list hits its end; inner scrollers keep their bounce.
export const MOBILE_WEB_APP_NATIVE_PARITY_STYLE =
'<style id="orca-native-parity">:where(input:focus,textarea:focus){outline:none}' +
':where(html){overscroll-behavior:none}' +
':where(body){-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}' +
':where(input,textarea,[contenteditable]){-webkit-user-select:text;user-select:text;' +
'-webkit-touch-callout:default}</style>'
@@ -18,6 +18,7 @@ const describeClosure = mobileWebAppDependenciesPresent() ? describe : describe.
const HUB = 'app/h/[hostId]/source-control/[worktreeId].tsx'
const REVIEW = 'app/h/[hostId]/review/[worktreeId].tsx'
const FILE_PREVIEW = 'app/h/[hostId]/files/preview/[worktreeId].tsx'
// The pages' inputs take their size from the chat composer's shared styles.
const COMPOSER_INPUT_STYLES = 'src/components/composer-input/composer-input-styles.ts'
@@ -424,14 +425,17 @@ describe('a style module with a platform sibling', () => {
})
describeClosure(
'the text inputs the source-control and review pages reach',
'the text inputs the source-control, review and file preview pages reach',
() => {
it.each([HUB, REVIEW])('takes every input size through the seam: %s', async (route) => {
const closure = await mobileWebAppRouteClosure(route)
expect(textInputFontSizeOffenders(mobileDir, closure)).toEqual([])
})
it.each([HUB, REVIEW, FILE_PREVIEW])(
'takes every input size through the seam: %s',
async (route) => {
const closure = await mobileWebAppRouteClosure(route)
expect(textInputFontSizeOffenders(mobileDir, closure)).toEqual([])
}
)
it.each([HUB, REVIEW])(
it.each([HUB, REVIEW, FILE_PREVIEW])(
'reads every input it found, so the list above is complete: %s',
async (route) => {
const closure = await mobileWebAppRouteClosure(route)
@@ -353,7 +353,7 @@ describeRender('the host stack transition on the page', () => {
await page.close()
}, 120_000)
it('swaps instantly in the tablet split view and under reduced motion', async () => {
it('swaps without sliding in the tablet split view and under reduced motion', async () => {
for (const options of [{ animation: 'none' }, { reducedMotion: 'reduce' }]) {
const { errors, page } = await open(options)
const pushed = await sampleFrames(page, 'push')
@@ -111,13 +111,15 @@ async function openProbe() {
return { errors, page }
}
// The rings turn with Web Animations, which never write inline style, so read the computed rotation.
const readRotations = (page) =>
page.evaluate(() =>
['working-spinner', 'working-dot'].map(
(id) =>
[...document.querySelectorAll(`#${id} *`)].find((node) => node.style.transform)?.style
.transform ?? null
)
['working-spinner', 'working-dot'].map((id) => {
const ring = [...document.querySelectorAll(`#${id} *`)].find(
(node) => node.getAnimations().length > 0
)
return ring ? getComputedStyle(ring).transform : null
})
)
describeRender('working rings on the page', () => {
+6 -1
View File
@@ -22,6 +22,7 @@ import { connectionDiagnosticsScreenStyles as styles } from '../src/diagnostics/
import { useMobileColorScheme } from '../src/theme/use-mobile-color-scheme'
import { NATIVE_APP_LOG_ID } from '../src/diagnostics/native-render-log'
import type { ConnectionLogEntry, HostProfile } from '../src/transport/types'
import { pressedStyle } from '../src/theme/mobile-theme'
// Keep empty snapshot identity stable or useSyncExternalStore rerenders forever.
const EMPTY_ENTRIES: readonly ConnectionLogEntry[] = []
@@ -111,7 +112,11 @@ export default function NativeConnectionLogRoute() {
{hosts.map((host) => (
<Pressable
key={host.id}
style={[styles.hostChip, host.id === selectedId && styles.hostChipActive]}
style={({ pressed }) => [
styles.hostChip,
host.id === selectedId && styles.hostChipActive,
pressed && pressedStyle
]}
onPress={() =>
setManualSelection({ hostId: host.id, requestedHostId: params.hostId, routeKey })
}
+6 -3
View File
@@ -11,7 +11,7 @@ import {
import { useSafeAreaInsets } from 'react-native-safe-area-context'
import { useLocalSearchParams, useRouter } from 'expo-router'
import { ChevronLeft } from 'lucide-react-native'
import { colors, radii, spacing, typography } from '../../../src/theme/mobile-theme'
import { colors, radii, spacing, typography, pressedStyle } from '../../../src/theme/mobile-theme'
import { themedStyleSheet } from '../../../src/theme/themed-styles'
import { useMobileColorScheme } from '../../../src/theme/use-mobile-color-scheme'
import { loadHosts, updateHostNameAndEndpoint } from '../../../src/transport/host-store'
@@ -173,7 +173,7 @@ export default function EditHostScreen() {
<View style={[styles.container, { paddingTop: insets.top + spacing.sm }]}>
<View style={styles.topRow}>
<Pressable
style={styles.backButton}
style={({ pressed }) => [styles.backButton, pressed && pressedStyle]}
onPress={leave}
accessibilityRole="button"
accessibilityLabel={t('common.back', 'Back')}
@@ -202,7 +202,10 @@ export default function EditHostScreen() {
{loadError ? (
<View style={styles.errorState}>
<Text style={styles.errorText}>{loadError}</Text>
<Pressable style={styles.secondaryButton} onPress={leave}>
<Pressable
style={({ pressed }) => [styles.secondaryButton, pressed && pressedStyle]}
onPress={leave}
>
<Text style={styles.secondaryButtonText}>{t('host.edit.goBack', 'Go back')}</Text>
</Pressable>
</View>
+4 -4
View File
@@ -1,5 +1,5 @@
import { useCallback, useMemo, useRef, useState } from 'react'
import { Animated, BackHandler, Text, View, type LayoutChangeEvent } from 'react-native'
import { Animated, BackHandler, Easing, Text, View, type LayoutChangeEvent } from 'react-native'
import { useFocusEffect, useLocalSearchParams, useRouter } from 'expo-router'
import { SafeAreaView } from 'react-native-safe-area-context'
import { OrcaLogo } from '../src/components/OrcaLogo'
@@ -10,6 +10,7 @@ import {
type NotificationOnboardingChoice
} from '../src/onboarding/MobileOnboardingPage'
import { parseMobileOnboardingSteps } from '../src/onboarding/mobile-onboarding-plan'
import { PUSH_CURVE, PUSH_SLIDE_MS } from '../src/navigation/push-motion'
import { useReducedMotionEnabled } from '../src/platform/use-reduced-motion'
import { useMobileColorScheme } from '../src/theme/use-mobile-color-scheme'
import { mobileOnboardingStyles as styles } from '../src/onboarding/mobile-onboarding-styles'
@@ -20,8 +21,6 @@ import {
import { setRemotePushEnabled } from '../src/notifications/push-registration'
import { useMobileTranslation } from '../src/i18n/use-mobile-translation'
const SLIDE_DURATION_MS = 280
export default function MobileOnboardingScreen() {
const params = useLocalSearchParams<{
hostId?: string | string[]
@@ -82,7 +81,8 @@ function MobileOnboardingFlow({
Animated.timing(slideProgress, {
toValue: nextIndex,
// Preserve carousel continuity while honoring reduced motion.
duration: reducedMotionEnabled === true ? 0 : SLIDE_DURATION_MS,
duration: reducedMotionEnabled === true ? 0 : PUSH_SLIDE_MS,
easing: Easing.bezier(...PUSH_CURVE),
useNativeDriver: true
}).start(() => {
// Cancelled cosmetic animation must not block the next choice after previous choice persisted.
+33 -11
View File
@@ -1,5 +1,5 @@
import { useCallback, useRef, useState } from 'react'
import { View, Text, Pressable, ActivityIndicator, BackHandler } from 'react-native'
import { View, Text, Pressable, BackHandler } from 'react-native'
import { useSafeAreaInsets } from 'react-native-safe-area-context'
import { useFocusEffect, useLocalSearchParams, useRouter } from 'expo-router'
import { ChevronLeft } from 'lucide-react-native'
@@ -13,7 +13,7 @@ import {
} from '../src/transport/pre-profile-pairing-coordinator'
import type { ConnectionLogEntry } from '../src/transport/types'
import { useRefreshHostClient } from '../src/transport/host-client-hooks'
import { colors, spacing, radii, typography } from '../src/theme/mobile-theme'
import { colors, spacing, radii, typography, pressedStyle } from '../src/theme/mobile-theme'
import { themedStyleSheet } from '../src/theme/themed-styles'
import { useMobileColorScheme } from '../src/theme/use-mobile-color-scheme'
import { useMobileTranslation } from '../src/i18n/use-mobile-translation'
@@ -22,6 +22,12 @@ import {
loadMobileOnboardingSteps,
mobileOnboardingDestination
} from '../src/onboarding/mobile-onboarding-plan'
import {
PAIRING_SUCCESS_HOLD_MS,
PairingProgress,
waitForBeat
} from '../src/pairing/pairing-visuals'
import { triggerSuccess } from '../src/platform/haptics'
type Status = 'awaiting-confirm' | 'connecting' | 'error'
@@ -46,6 +52,7 @@ function PairConfirmContent({ routeState }: { routeState: PairConfirmRouteState
const refreshHostClient = useRefreshHostClient()
const insets = useSafeAreaInsets()
const [status, setStatus] = useState<Status>('awaiting-confirm')
const [paired, setPaired] = useState(false)
const [errorMessage, setErrorMessage] = useState('')
const [logs, setLogs] = useState<ConnectionLogEntry[]>([])
// Ref keeps RPC callback logs current and batches bursty state updates.
@@ -124,7 +131,12 @@ function PairConfirmContent({ routeState }: { routeState: PairConfirmRouteState
}
// Re-pair reuses host id; close cached client so it reloads the persisted endpoint/relay (STA-1840).
refreshHostClient(hostId)
const onboardingSteps = await loadMobileOnboardingSteps()
setPaired(true)
triggerSuccess()
const [onboardingSteps] = await Promise.all([
loadMobileOnboardingSteps(),
waitForBeat(PAIRING_SUCCESS_HOLD_MS)
])
if (!mountedRef.current) {
return
}
@@ -160,7 +172,7 @@ function PairConfirmContent({ routeState }: { routeState: PairConfirmRouteState
return (
<View ref={setPairConfirmRootRef} style={[styles.container, containerPadding]}>
<Pressable
style={styles.backButton}
style={({ pressed }) => [styles.backButton, pressed && pressedStyle]}
onPress={cancel}
hitSlop={8}
accessibilityRole="button"
@@ -182,12 +194,18 @@ function PairConfirmContent({ routeState }: { routeState: PairConfirmRouteState
)}
</Text>
<View style={styles.actionStack}>
<Pressable style={styles.primaryButton} onPress={() => void confirm()}>
<Pressable
style={({ pressed }) => [styles.primaryButton, pressed && pressedStyle]}
onPress={() => void confirm()}
>
<Text style={styles.primaryButtonText}>
{t('app.pairConfirm.pairButton', 'Pair')}
</Text>
</Pressable>
<Pressable style={styles.secondaryButton} onPress={cancel}>
<Pressable
style={({ pressed }) => [styles.secondaryButton, pressed && pressedStyle]}
onPress={cancel}
>
<Text style={styles.secondaryButtonText}>{t('common.cancel', 'Cancel')}</Text>
</Pressable>
</View>
@@ -196,10 +214,11 @@ function PairConfirmContent({ routeState }: { routeState: PairConfirmRouteState
{resolvedStatus === 'connecting' && (
<>
<ActivityIndicator size="large" color={colors.textSecondary} />
<Text style={styles.connectingText}>
{t('app.pairConfirm.connecting', 'Connecting…')}
</Text>
<PairingProgress
succeeded={paired}
connectingLabel={t('app.pairConfirm.connecting', 'Connecting…')}
labelStyle={styles.connectingText}
/>
<View style={styles.logSlot}>
<ConnectionLog
entries={logs}
@@ -221,7 +240,10 @@ function PairConfirmContent({ routeState }: { routeState: PairConfirmRouteState
</View>
)}
<View style={styles.actionStack}>
<Pressable style={styles.primaryButton} onPress={cancel}>
<Pressable
style={({ pressed }) => [styles.primaryButton, pressed && pressedStyle]}
onPress={cancel}
>
<Text style={styles.primaryButtonText}>
{t('app.pairConfirm.backToHome', 'Back to home')}
</Text>
+38 -29
View File
@@ -20,7 +20,7 @@ import {
} from '../src/transport/pre-profile-pairing-coordinator'
import type { ConnectionLogEntry, PairingOffer } from '../src/transport/types'
import { useRefreshHostClient } from '../src/transport/host-client-hooks'
import { colors, spacing } from '../src/theme/mobile-theme'
import { colors, spacing, pressedStyle } from '../src/theme/mobile-theme'
import { useMobileColorScheme } from '../src/theme/use-mobile-color-scheme'
import { useMobileTranslation } from '../src/i18n/use-mobile-translation'
import { TextInputModal } from '../src/components/TextInputModal'
@@ -30,24 +30,21 @@ import {
mobileOnboardingDestination
} from '../src/onboarding/mobile-onboarding-plan'
import { pairScanStyles as styles } from '../src/pair-scan-styles'
import {
PAIRING_SUCCESS_HOLD_MS,
PairingProgress,
SCAN_DECODE_BEAT_MS,
ScanReticle,
Step,
waitForBeat
} from '../src/pairing/pairing-visuals'
import { triggerSuccess } from '../src/platform/haptics'
// Bound initial pairing at ~25s (one connect timeout plus retry) so broken routes show an actionable error/log; live RPC retries indefinitely.
const PAIRING_OVERALL_TIMEOUT_MS = 25_000
const SCAN_RETICLE_SCALE = 0.62
const SCAN_RETICLE_MAX_SIZE = 360
function Step({ number, text }: { number: number; text: string }) {
useMobileColorScheme()
return (
<View style={styles.step}>
<View style={styles.stepBadge}>
<Text style={styles.stepNumber}>{number}</Text>
</View>
<Text style={styles.stepText}>{text}</Text>
</View>
)
}
export default function PairScanScreen() {
useMobileColorScheme()
const t = useMobileTranslation()
@@ -56,6 +53,8 @@ export default function PairScanScreen() {
const insets = useSafeAreaInsets()
const [permission, requestPermission, getPermission] = useCameraPermissions()
const [status, setStatus] = useState<'scanning' | 'connecting' | 'error'>('scanning')
const [decoded, setDecoded] = useState(false)
const [paired, setPaired] = useState(false)
const [errorMessage, setErrorMessage] = useState('')
const [pasteVisible, setPasteVisible] = useState(false)
const [cameraBounds, setCameraBounds] = useState({ width: 0, height: 0 })
@@ -100,7 +99,8 @@ export default function PairScanScreen() {
return
}
void testAndSave(offer)
setDecoded(true)
void waitForBeat(SCAN_DECODE_BEAT_MS).then(() => testAndSave(offer))
},
[router, t]
)
@@ -145,6 +145,10 @@ export default function PairScanScreen() {
}, [])
async function testAndSave(offer: PairingOffer) {
// A decoded QR waits out the reticle beat; the screen may have left meanwhile.
if (!mountedRef.current) {
return
}
setStatus('connecting')
logsRef.current = []
setLogs([])
@@ -176,7 +180,12 @@ export default function PairScanScreen() {
}
// Re-pair reuses host id; close cached client so it reloads the persisted endpoint/relay (STA-1840).
refreshHostClient(hostId)
const onboardingSteps = await loadMobileOnboardingSteps()
setPaired(true)
triggerSuccess()
const [onboardingSteps] = await Promise.all([
loadMobileOnboardingSteps(),
waitForBeat(PAIRING_SUCCESS_HOLD_MS)
])
if (!mountedRef.current) {
return
}
@@ -210,6 +219,7 @@ export default function PairScanScreen() {
function retry() {
setStatus('scanning')
setDecoded(false)
setErrorMessage('')
logsRef.current = []
setLogs([])
@@ -240,7 +250,7 @@ export default function PairScanScreen() {
return (
<View ref={setPairScanRootRef} style={[styles.container, containerPadding]}>
<Pressable
style={styles.backButton}
style={({ pressed }) => [styles.backButton, pressed && pressedStyle]}
onPress={() => router.back()}
hitSlop={8}
accessibilityRole="button"
@@ -266,7 +276,7 @@ export default function PairScanScreen() {
)}
</Text>
<Pressable
style={styles.primaryButton}
style={({ pressed }) => [styles.primaryButton, pressed && pressedStyle]}
onPress={canAskAgain ? requestPermission : () => void Linking.openSettings()}
>
{canAskAgain && <QrCode size={16} color={colors.bgBase} />}
@@ -307,7 +317,7 @@ export default function PairScanScreen() {
return (
<View ref={setPairScanRootRef} style={[styles.container, containerPadding]}>
<Pressable
style={styles.backButton}
style={({ pressed }) => [styles.backButton, pressed && pressedStyle]}
onPress={() => router.back()}
hitSlop={8}
accessibilityRole="button"
@@ -336,14 +346,7 @@ export default function PairScanScreen() {
barcodeScannerSettings={{ barcodeTypes: ['qr'] }}
onBarcodeScanned={handleBarCodeScanned}
/>
<View style={styles.reticle} pointerEvents="none">
<View style={[styles.reticleFrame, { width: reticleSize, height: reticleSize }]}>
<View style={[styles.corner, styles.cornerTL]} />
<View style={[styles.corner, styles.cornerTR]} />
<View style={[styles.corner, styles.cornerBL]} />
<View style={[styles.corner, styles.cornerBR]} />
</View>
</View>
<ScanReticle size={reticleSize} decoded={decoded} />
</View>
)}
{pasteVisible && <View style={styles.cameraPlaceholder} />}
@@ -361,8 +364,11 @@ export default function PairScanScreen() {
{status === 'connecting' && (
<View style={styles.centered}>
<ActivityIndicator size="large" color={colors.textSecondary} />
<Text style={styles.connectingText}>{t('app.pairScan.connecting', 'Connecting…')}</Text>
<PairingProgress
succeeded={paired}
connectingLabel={t('app.pairScan.connecting', 'Connecting…')}
labelStyle={styles.connectingText}
/>
<View style={styles.logSlot}>
<ConnectionLog entries={logs} title={t('app.pairScan.pairingLog', 'Pairing log')} />
</View>
@@ -378,7 +384,10 @@ export default function PairScanScreen() {
</View>
)}
<View style={styles.errorActions}>
<Pressable style={styles.primaryButton} onPress={retry}>
<Pressable
style={({ pressed }) => [styles.primaryButton, pressed && pressedStyle]}
onPress={retry}
>
<Text style={styles.primaryButtonText}>
{t('app.pairScan.tryAgain', 'Try Again')}
</Text>
+5 -2
View File
@@ -1,7 +1,7 @@
import { useCallback, useEffect, useState } from 'react'
import { ActivityIndicator, Linking, Pressable, Text, View } from 'react-native'
import { useLocalSearchParams, useRouter } from 'expo-router'
import { colors, radii, spacing, typography } from '../src/theme/mobile-theme'
import { colors, radii, spacing, typography, pressedStyle } from '../src/theme/mobile-theme'
import { themedStyleSheet } from '../src/theme/themed-styles'
import { useMobileColorScheme } from '../src/theme/use-mobile-color-scheme'
import { useMobileTranslation } from '../src/i18n/use-mobile-translation'
@@ -51,7 +51,10 @@ export default function PairRedirectScreen() {
{missingCode ? (
<>
<Text style={styles.errorText}>{t('app.pair.missingCode', 'Missing pairing code')}</Text>
<Pressable style={styles.primaryButton} onPress={goHome}>
<Pressable
style={({ pressed }) => [styles.primaryButton, pressed && pressedStyle]}
onPress={goHome}
>
<Text style={styles.primaryButtonText}>{t('app.pair.backToHome', 'Back to home')}</Text>
</Pressable>
</>
@@ -1,7 +1,7 @@
import { useState } from 'react'
import { Pressable, ScrollView, Text, View } from 'react-native'
import { TriangleAlert, X } from 'lucide-react-native'
import { colors, radii, spacing, typography } from '../theme/mobile-theme'
import { colors, radii, spacing, typography, pressedStyle } from '../theme/mobile-theme'
import { themedStyleSheet } from '../theme/themed-styles'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
@@ -28,6 +28,7 @@ export function AgentHistorySkippedNotice({ issues }: { issues: readonly Transcr
: t('agentHistory.panel.skipped_other', '{{count}} transcripts skipped', { count })}
</Text>
<Pressable
style={({ pressed }) => pressed && pressedStyle}
onPress={() => setShown((value) => !value)}
hitSlop={10}
accessibilityRole="button"
@@ -71,6 +72,7 @@ export function AgentHistoryResumeNotice({
<View style={[styles.notice, styles.noticeRow]}>
<Text style={styles.noticeText}>{message}</Text>
<Pressable
style={({ pressed }) => pressed && pressedStyle}
onPress={onDismiss}
hitSlop={12}
accessibilityRole="button"
@@ -3,7 +3,7 @@ import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { useState } from 'react'
import { Pressable, Text, TextInput, View } from 'react-native'
import { PickerModal, type PickerOption } from '../components/PickerModal'
import { colors } from '../theme/mobile-theme'
import { colors, pressedStyle } from '../theme/mobile-theme'
import { automationStyles as styles } from './automation-styles'
export function AutomationButton(props: {
@@ -20,10 +20,11 @@ export function AutomationButton(props: {
accessibilityState={{ disabled: props.disabled }}
disabled={props.disabled}
onPress={props.onPress}
style={[
style={({ pressed }) => [
styles.button,
props.primary && styles.primaryButton,
props.disabled && styles.disabled
props.disabled && styles.disabled,
pressed && pressedStyle
]}
>
<Text
+2 -2
View File
@@ -4,7 +4,7 @@ import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { CalendarClock, ChevronRight } from 'lucide-react-native'
import { Pressable, Switch, Text, View } from 'react-native'
import { formatAutomationSchedule } from './automation-schedule-label'
import { colors } from '../theme/mobile-theme'
import { colors, pressedStyle } from '../theme/mobile-theme'
import { AutomationButton } from './AutomationControls'
import type { MobileAutomationRow } from './automation-reply-schema'
import { automationDate, automationRunStatusLabel } from './automation-run-presentation'
@@ -58,7 +58,7 @@ export function AutomationList(props: {
<Pressable
accessibilityRole="button"
onPress={() => props.onOpen(row)}
style={styles.grow}
style={({ pressed }) => [styles.grow, pressed && pressedStyle]}
>
<View style={styles.row}>
<Text style={[styles.heading, styles.grow]}>{automation.name}</Text>
+2 -2
View File
@@ -2,7 +2,7 @@ import { useMobileTranslation } from '../i18n/use-mobile-translation'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { Pressable, Text, View } from 'react-native'
import { ChevronRight } from 'lucide-react-native'
import { colors } from '../theme/mobile-theme'
import { colors, pressedStyle } from '../theme/mobile-theme'
import type { MobileAutomationRun } from './automation-reply-schema'
import { AutomationButton } from './AutomationControls'
import type { AutomationRunObservation } from './use-automation-runs'
@@ -66,7 +66,7 @@ export function AutomationRunList(props: {
}
)}
onPress={() => props.onSelect(run)}
style={styles.card}
style={({ pressed }) => [styles.card, pressed && pressedStyle]}
>
<View style={styles.row}>
<Text style={[styles.heading, styles.grow]}>{run.title}</Text>
@@ -11,7 +11,7 @@ import { useRouteHandoff } from '../navigation/route-handoff'
import { useHostClient } from '../transport/host-client-hooks'
import { useHostProtocolGates } from '../components/host-protocol-gates-context'
import { useReachableServerClients } from '../worktree/use-reachable-server-clients'
import { colors } from '../theme/mobile-theme'
import { colors, pressedStyle } from '../theme/mobile-theme'
import { AutomationChoice } from './AutomationControls'
import { AutomationManager } from './AutomationManager'
import { automationStyles as styles } from './automation-styles'
@@ -34,6 +34,7 @@ export function MobileAutomationsScreen() {
<View style={[styles.screen, { paddingTop: insets.top, paddingBottom: insets.bottom }]}>
<View style={styles.header}>
<Pressable
style={({ pressed }) => pressed && pressedStyle}
accessibilityRole="button"
accessibilityLabel={t('automations.mobile.back', 'Back')}
onPress={() => router.back()}
+6 -2
View File
@@ -12,7 +12,7 @@ import {
} from 'react-native'
import { ArrowUp, ChevronLeft, ChevronRight, RefreshCw } from 'lucide-react-native'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import { colors } from '../theme/mobile-theme'
import { colors, pressedStyle } from '../theme/mobile-theme'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { MobileBrowserAddressField } from './MobileBrowserAddressField'
import { MobileBrowserKeyRow } from './MobileBrowserKeyRow'
@@ -326,7 +326,11 @@ export function MobileBrowserPaneView(props: MobileBrowserPaneViewProps) {
onSubmitEditing={() => void sendKeyboardText()}
/>
<Pressable
style={[styles.sendButton, (controlsDisabled || !keyboardValue) && styles.disabled]}
style={({ pressed }) => [
styles.sendButton,
(controlsDisabled || !keyboardValue) && styles.disabled,
pressed && pressedStyle
]}
disabled={controlsDisabled || !keyboardValue}
onPress={() => void sendKeyboardText()}
accessibilityLabel={t('browser.paneView.sendText', 'Send text to browser')}
+2 -1
View File
@@ -3,7 +3,7 @@ import { Pressable, Text, View, type StyleProp, type TextStyle } from 'react-nat
import { useClipboardWriter } from '../platform/clipboard'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import type { MobileAgentLaunchAvailability } from '../session/mobile-agent-launch-availability'
import { colors, spacing, typography } from '../theme/mobile-theme'
import { colors, spacing, typography, pressedStyle } from '../theme/mobile-theme'
import { themedStyleSheet } from '../theme/themed-styles'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
@@ -66,6 +66,7 @@ export function AgentLaunchNotice({
{note ? <Text style={styles.warningText}>{note}</Text> : null}
{undeliveredPrompt ? (
<Pressable
style={({ pressed }) => pressed && pressedStyle}
onPress={() => {
clipboard.writeText(undeliveredPrompt).then(
() => setCopyState({ prompt: undeliveredPrompt, status: 'copied' }),
+3 -4
View File
@@ -1,12 +1,12 @@
import { Activity } from 'lucide-react-native'
import { Animated, View } from 'react-native'
import { View } from 'react-native'
import type { AgentWorkingMode } from '../../../src/shared/agent-status-types'
import type { WorktreeStatus } from '../../../src/shared/worktree-status-rollup'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import { colors, radii } from '../theme/mobile-theme'
import { themedStyleSheet } from '../theme/themed-styles'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { useWorkingRingRotation } from './use-working-ring-rotation'
import { WorkingRing } from './AgentStateDot'
// Match desktop sidebar StatusIndicator colors/sizes for the worktree rollup; palette distinguishes moving/alive/completed states.
export const agentStatusColors = (): Record<WorktreeStatus, string> => ({
@@ -32,7 +32,6 @@ export function AgentSpinner({
useMobileColorScheme()
const monitoring =
status === 'monitoring' || (status === 'working' && workingMode === 'monitoring')
const rotate = useWorkingRingRotation(status === 'working' && !monitoring)
const palette = agentStatusColors()
const color = palette[status] ?? palette.inactive
@@ -62,7 +61,7 @@ export function AgentSpinner({
if (status === 'working') {
return (
<View style={styles.wrapper}>
<Animated.View style={[styles.spinner, { borderColor: color, transform: [{ rotate }] }]} />
<WorkingRing color={color} style={styles.spinner} />
</View>
)
}
+17 -5
View File
@@ -1,11 +1,12 @@
import { Activity } from 'lucide-react-native'
import { Animated, View } from 'react-native'
import { Animated, View, type ViewStyle } from 'react-native'
import type { AgentDotState } from '../worktree/agent-row-display'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import { colors, radii } from '../theme/mobile-theme'
import { themedStyleSheet } from '../theme/themed-styles'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { useWorkingRingRotation } from './use-working-ring-rotation'
import { useReducedMotionEnabled } from '../platform/use-reduced-motion'
import { useWorkingRingRotation } from './use-working-motion'
// Match desktop per-agent vocabulary: working yellow spinner, done emerald, attention red, interrupted muted, unconfirmed amber, idle neutral.
// Separate from AgentSpinner’s five-state worktree rollup.
@@ -23,17 +24,29 @@ const dotColors = (): Record<
})
export const AGENT_WORKING_COLOR = '#eab308'
/** Spins only while mounted, so idle rows hold no loop; Reduce Motion closes the gap, as desktop does. */
export function WorkingRing({ color, style }: { color: string; style: ViewStyle }) {
// Unknown counts as reduced, the same as LoadingSpinner.
const still = useReducedMotionEnabled() !== false
const ring = useWorkingRingRotation(!still)
return (
<Animated.View
ref={ring.ref}
style={[style, { borderColor: color }, still ? { borderTopColor: color } : ring.style]}
/>
)
}
/** `unverifiable` is a child row's lost contact: desktop's dashed amber ring, a missing-evidence
* mark rather than a state claim. */
export function AgentStateDot({ state }: { state: AgentDotState | 'unverifiable' }) {
const t = useMobileTranslation()
useMobileColorScheme()
const rotate = useWorkingRingRotation(state === 'working')
if (state === 'working') {
return (
<View style={styles.wrapper}>
<Animated.View style={[styles.spinner, { transform: [{ rotate }] }]} />
<WorkingRing color={AGENT_WORKING_COLOR} style={styles.spinner} />
</View>
)
}
@@ -83,7 +96,6 @@ const styles = themedStyleSheet(() => ({
height: 6,
borderRadius: radii.pill,
borderWidth: 1.5,
borderColor: AGENT_WORKING_COLOR,
borderTopColor: 'transparent'
}
}))
@@ -1,6 +1,6 @@
import { Pressable, Text } from 'react-native'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import { colors } from '../theme/mobile-theme'
import { colors, pressedStyle } from '../theme/mobile-theme'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { authFailedBannerStyles as styles } from './auth-failed-banner-styles'
@@ -21,16 +21,25 @@ export function AuthFailedBannerActions({
return (
<>
{canRetry && (
<Pressable style={styles.action} onPress={onRetry}>
<Pressable
style={({ pressed }) => [styles.action, pressed && pressedStyle]}
onPress={onRetry}
>
<Text style={styles.actionText}>{t('common.retry', 'Retry')}</Text>
</Pressable>
)}
<Pressable style={styles.action} onPress={onRepair}>
<Pressable
style={({ pressed }) => [styles.action, pressed && pressedStyle]}
onPress={onRepair}
>
<Text style={styles.actionText}>
{t('components.authFailedBannerActions.repair', 'Re-pair')}
</Text>
</Pressable>
<Pressable style={styles.action} onPress={onRemove}>
<Pressable
style={({ pressed }) => [styles.action, pressed && pressedStyle]}
onPress={onRemove}
>
<Text style={[styles.actionText, { color: colors.statusRed }]}>
{t('common.remove', 'Remove')}
</Text>
@@ -2,6 +2,7 @@ import { Pressable, Text } from 'react-native'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import { authFailedBannerStyles as styles } from './auth-failed-banner-styles'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { pressedStyle } from '../theme/mobile-theme'
// Offer shell-routed /pair-scan only; web forceReconnect is null and page-host-removal-refusal rejects Remove, so direct users to app for both.
export function AuthFailedBannerActions({
@@ -16,7 +17,10 @@ export function AuthFailedBannerActions({
useMobileColorScheme()
return (
<>
<Pressable style={styles.action} onPress={onRepair}>
<Pressable
style={({ pressed }) => [styles.action, pressed && pressedStyle]}
onPress={onRepair}
>
<Text style={styles.actionText}>
{t('components.authFailedBannerActions.repair', 'Re-pair')}
</Text>
+41
View File
@@ -9,6 +9,8 @@ import Animated, {
} from 'react-native-reanimated'
import { useReducedMotionEnabled } from '../platform/use-reduced-motion'
import { BOTTOM_DRAWER_EASING, BOTTOM_DRAWER_HEIGHT_DURATION_MS } from './bottom-drawer-constants'
// The same 200 ms as Reduce Motion's cross-fade: content fades while its box eases.
import { REDUCED_MOTION_FADE_MS as CONTENT_FADE_MS } from './sheet-motion-values'
const HEIGHT_TIMING = { duration: BOTTOM_DRAWER_HEIGHT_DURATION_MS, easing: BOTTOM_DRAWER_EASING }
@@ -80,6 +82,45 @@ export function AutoHeight({ children, maxHeight, open = true }: AutoHeightProps
)
}
/**
* A banner that comes and goes: pass it as the child, or nothing to hide it. Its box eases open
* and closed while the content fades, and the last banner stays drawn while it leaves.
* `animateHeight={false}` resizes once instead, for content above a terminal or page whose every
* resize refits it.
*/
export function Presence({
children,
animateHeight = true
}: {
children: ReactNode
animateHeight?: boolean
}) {
const shown = children !== null && children !== undefined && children !== false
const [last, setLast] = useState<ReactNode>(shown ? children : null)
if (shown && last !== children) {
setLast(children)
}
const [present, setPresent] = useState(shown)
if (shown && !present) {
setPresent(true)
}
const opacity = useSharedValue(shown ? 1 : 0)
useEffect(() => {
opacity.value = withTiming(shown ? 1 : 0, { duration: CONTENT_FADE_MS }, (finished) => {
if (finished && !shown) {
runOnJS(setPresent)(false)
}
})
}, [opacity, shown])
// The page bundle has no worklet plugin, so web mappers read only the dependency list.
const fadeStyle = useAnimatedStyle(() => ({ opacity: opacity.value }), [opacity])
const content = <Animated.View style={fadeStyle}>{shown ? children : last}</Animated.View>
if (animateHeight) {
return <AutoHeight open={shown}>{content}</AutoHeight>
}
return present ? content : null
}
function easeHeight(
height: SharedValue<number>,
next: number,
+11 -3
View File
@@ -1,7 +1,7 @@
import { useCallback, useMemo, useState } from 'react'
import { View, Text, Pressable, TextInput } from 'react-native'
import { ChevronLeft } from 'lucide-react-native'
import { colors } from '../theme/mobile-theme'
import { colors, pressedStyle } from '../theme/mobile-theme'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { BottomDrawer } from './BottomDrawer'
import { TextField } from './composer-input/TextField'
@@ -310,7 +310,11 @@ export function CustomKeyModal({ visible, onClose, onKeysChanged, onManageShortc
</View>
<Pressable
style={[styles.saveButton, !shortcutPreview && styles.saveButtonDisabled]}
style={({ pressed }) => [
styles.saveButton,
!shortcutPreview && styles.saveButtonDisabled,
pressed && pressedStyle
]}
disabled={!shortcutPreview}
onPress={handleShortcutSave}
>
@@ -394,7 +398,11 @@ export function CustomKeyModal({ visible, onClose, onKeysChanged, onManageShortc
/>
</View>
<Pressable
style={[styles.saveButton, !macroText.trim() && styles.saveButtonDisabled]}
style={({ pressed }) => [
styles.saveButton,
!macroText.trim() && styles.saveButtonDisabled,
pressed && pressedStyle
]}
disabled={!macroText.trim()}
onPress={handleMacroSave}
>
@@ -24,6 +24,9 @@ it('places a coherent measured append directly, but springs a dragged row back i
root!.root.findAll((node) => node.type === Animated.View && node.props.onLayout)
const measureRow = (at: number) =>
rows()[at]!.props.onLayout({ nativeEvent: { layout: { height: 44 } } })
// Rows move by their first transform, not by top.
const y = ({ transform }: Record<string, unknown>) =>
Array.isArray(transform) ? transform[0]?.translateY : undefined
const frame = () => {
probe.reactions.forEach((react) => react())
return [...probe.styles.values()].map((read) => read())
@@ -33,10 +36,10 @@ it('places a coherent measured append directly, but springs a dragged row back i
measureRow(1)
})
await publishLayout()
expect(frame().map((style) => style.top)).toEqual([0, 44])
expect(frame().map(y)).toEqual([0, 44])
expect(probe.spring).not.toHaveBeenCalled()
await act(async () => root!.update(createElement(Harness, { ids: ['a', 'b', 'c'] })))
expect(frame().map((style) => [style.position, style.top])).toEqual([
expect(frame().map((style) => [style.position, y(style)])).toEqual([
['relative', 0],
['relative', 0],
['relative', 0]
@@ -50,9 +53,9 @@ it('places a coherent measured append directly, but springs a dragged row back i
const coherent = measurement.value
// React is ready, but the UI thread still has the previous measurement publication.
measurement.value = earlier
expect(frame().every((style) => style.position === 'relative' && style.top === 0)).toBe(true)
expect(frame().every((style) => style.position === 'relative' && y(style) === 0)).toBe(true)
measurement.value = coherent
expect(frame().map((style) => [style.position, style.top])).toEqual([
expect(frame().map((style) => [style.position, y(style)])).toEqual([
['absolute', 0],
['absolute', 44],
['absolute', 88]
@@ -63,9 +66,9 @@ it('places a coherent measured append directly, but springs a dragged row back i
gesture.start!({ absoluteY: 60, translationY: 0 }, true)
gesture.update!({ absoluteY: 70, translationY: 10 }, true)
})
expect(frame()[1]!.top).toBe(54)
expect(y(frame()[1]!)).toBe(54)
await act(async () => gesture.finalize!({ absoluteY: 70, translationY: 10 }, true))
expect(frame()[1]!.top).toBe(44)
expect(y(frame()[1]!)).toBe(44)
expect(probe.spring).toHaveBeenCalledExactlyOnceWith(44, expect.any(Object))
await act(async () => root!.unmount())
})
+30 -19
View File
@@ -3,11 +3,14 @@ import { StyleSheet, View } from 'react-native'
import { Gesture, GestureDetector } from 'react-native-gesture-handler'
import { GripVertical } from 'lucide-react-native'
import Animated, {
Easing,
interpolateColor,
runOnJS,
useAnimatedStyle,
useAnimatedReaction,
useSharedValue,
withSpring,
withTiming,
type DerivedValue,
type SharedValue
} from 'react-native-reanimated'
@@ -24,6 +27,13 @@ import {
// Critically damped: Reanimated 4's default mass of 4 made the old damping/stiffness pair wobble.
const ROW_SPRING = { dampingRatio: 1, duration: 250 } as const
const LONG_PRESS_ACTIVATION_MS = 200
const LIFT_MS = 150
// Built per call: a module-level easing would run before a test's Reanimated mock can serve it.
function liftTo(value: 0 | 1) {
'worklet'
return withTiming(value, { duration: LIFT_MS, easing: Easing.out(Easing.cubic) })
}
export type DragSharedState = {
layout: DerivedValue<DragReorderLayout & { measurementKey: string; ready: boolean }>
@@ -88,6 +98,8 @@ export function DragReorderRow({
// Settings rows rest on their ListGroup's surface.
const restingBackground = colors.sheetGroup
// 0 rests, 1 is picked up: the lift eases in and out instead of snapping.
const lift = useSharedValue(0)
const pan = Gesture.Pan()
.enabled(ready && movable && !disabled)
.activateAfterLongPress(LONG_PRESS_ACTIVATION_MS)
@@ -100,6 +112,7 @@ export function DragReorderRow({
dragPointerAbsY.value = event.absoluteY
activeTop.value = dragStartTop.value
activeKey.value = rowKey
lift.value = liftTo(1)
runOnJS(onDragActiveChange)(true)
runOnJS(triggerMediumImpact)()
})
@@ -116,6 +129,7 @@ export function DragReorderRow({
return
}
activeKey.value = null
lift.value = liftTo(0)
if (success) {
const orderedKeys = orderedKeysFromDragReorderPositions(positions.value)
runOnJS(onCommit)(orderedKeys, rowKey, true)
@@ -144,28 +158,24 @@ export function DragReorderRow({
},
[ready, layout, measurementKey, activeKey, rowKey, activeTop, rowTop]
)
// Rows sit at the top and move by transform, so a drag never lays the list out per frame.
const rowStyle = useAnimatedStyle(() => {
const placed = ready && layout.value.ready && layout.value.measurementKey === measurementKey
const placement = { position: placed ? ('absolute' as const) : ('relative' as const) }
if (activeKey.value === rowKey) {
return {
...placement,
top: placed ? activeTop.value : 0,
zIndex: 2,
elevation: presentation === 'settings' ? 4 : 0,
shadowOpacity: presentation === 'settings' ? 0.3 : 0,
backgroundColor: presentation === 'settings' ? activeBackground : undefined,
transform: [{ scale: presentation === 'settings' ? 1.02 : 1 }]
}
}
const active = activeKey.value === rowKey
const raised = presentation === 'settings' ? lift.value : 0
const y = !placed ? 0 : active ? activeTop.value : rowTop.value
return {
...placement,
top: placed ? rowTop.value : 0,
zIndex: 0,
elevation: 0,
shadowOpacity: 0,
backgroundColor: presentation === 'settings' ? restingBackground : undefined,
transform: [{ scale: 1 }]
position: placed ? ('absolute' as const) : ('relative' as const),
top: 0,
// Stay above neighbours while the lift eases off.
zIndex: active || lift.value > 0 ? 2 : 0,
elevation: 4 * raised,
shadowOpacity: 0.3 * raised,
backgroundColor:
presentation === 'settings'
? interpolateColor(lift.value, [0, 1], [restingBackground, activeBackground])
: undefined,
transform: [{ translateY: y }, { scale: 1 + 0.02 * raised }]
}
}, [
layout,
@@ -176,6 +186,7 @@ export function DragReorderRow({
measurementKey,
presentation,
rowTop,
lift,
activeBackground,
restingBackground
])
@@ -1,6 +1,6 @@
import { ChevronRight } from 'lucide-react-native'
import { Pressable, Text } from 'react-native'
import { colors, radii, spacing, typography } from '../theme/mobile-theme'
import { colors, radii, spacing, typography, pressedStyle } from '../theme/mobile-theme'
import { themedStyleSheet } from '../theme/themed-styles'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
@@ -10,7 +10,7 @@ export function HostDiagnosticsLink({ onPress }: { onPress: () => void }): React
const t = useMobileTranslation()
return (
<Pressable
style={styles.link}
style={({ pressed }) => [styles.link, pressed && pressedStyle]}
onPress={onPress}
accessibilityRole="button"
accessibilityLabel={t(
@@ -1,6 +1,6 @@
import { Pressable, Text, View } from 'react-native'
import { X } from 'lucide-react-native'
import { colors, spacing } from '../theme/mobile-theme'
import { colors, spacing, pressedStyle } from '../theme/mobile-theme'
import { themedStyleSheet } from '../theme/themed-styles'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
@@ -28,7 +28,12 @@ export function HostRouteNoticeBanner({
>
<Text style={styles.text}>{message}</Text>
{action ? (
<Pressable onPress={action.onPress} accessibilityRole="button" hitSlop={spacing.sm}>
<Pressable
style={({ pressed }) => pressed && pressedStyle}
onPress={action.onPress}
accessibilityRole="button"
hitSlop={spacing.sm}
>
<Text style={styles.action}>{action.label}</Text>
</Pressable>
) : null}
@@ -38,7 +43,7 @@ export function HostRouteNoticeBanner({
accessibilityRole="button"
accessibilityLabel={t('components.hostRouteNoticeBanner.dismissNotice', 'Dismiss notice')}
hitSlop={spacing.sm}
style={styles.dismiss}
style={({ pressed }) => [styles.dismiss, pressed && pressedStyle]}
>
<X size={16} color={colors.textMuted} />
</Pressable>
+3 -3
View File
@@ -1,7 +1,7 @@
import { Animated } from 'react-native'
import { Hourglass, LoaderCircle } from 'lucide-react-native'
import { useReducedMotionEnabled } from '../platform/use-reduced-motion'
import { useWorkingRingRotation } from './use-working-ring-rotation'
import { useWorkingRingRotation } from './use-working-motion'
// Match desktop one-second spinner; reduced motion uses distinct working icon so frozen circle does not look stuck.
export function LoadingSpinner({
@@ -12,12 +12,12 @@ export function LoadingSpinner({
color: string
}): React.JSX.Element {
const reducedMotion = useReducedMotionEnabled()
const rotate = useWorkingRingRotation(reducedMotion === false)
const ring = useWorkingRingRotation(reducedMotion === false)
if (reducedMotion) {
return <Hourglass size={size} color={color} strokeWidth={2} />
}
return (
<Animated.View style={{ transform: [{ rotate }] }}>
<Animated.View ref={ring.ref} style={ring.style}>
<LoaderCircle size={size} color={color} strokeWidth={2} />
</Animated.View>
)
@@ -1,7 +1,7 @@
import { Pressable, Text, View } from 'react-native'
import { Code, Eye } from 'lucide-react-native'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import { colors, radii, spacing, typography } from '../theme/mobile-theme'
import { colors, radii, spacing, typography, pressedStyle } from '../theme/mobile-theme'
import { themedStyleSheet } from '../theme/themed-styles'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
@@ -21,7 +21,11 @@ export function MobilePreviewSourceTabs({ mode, onModeChange, previewLabel, sour
// Expose selected tab to assistive readers; active styling alone is silent.
<View style={styles.toolbar} accessibilityRole="tablist">
<Pressable
style={[styles.toggle, mode === 'preview' && styles.toggleActive]}
style={({ pressed }) => [
styles.toggle,
mode === 'preview' && styles.toggleActive,
pressed && pressedStyle
]}
onPress={() => onModeChange('preview')}
accessibilityRole="tab"
// Set both native accessibilityState and web aria-selected: RN Web drops former without emitting latter.
@@ -33,7 +37,11 @@ export function MobilePreviewSourceTabs({ mode, onModeChange, previewLabel, sour
<Text style={styles.toggleText}>{t('components.htmlPreview.preview', 'Preview')}</Text>
</Pressable>
<Pressable
style={[styles.toggle, mode === 'source' && styles.toggleActive]}
style={({ pressed }) => [
styles.toggle,
mode === 'source' && styles.toggleActive,
pressed && pressedStyle
]}
onPress={() => onModeChange('source')}
accessibilityRole="tab"
accessibilityState={{ selected: mode === 'source' }}
+2 -1
View File
@@ -2,7 +2,7 @@ import { useState, type ReactNode } from 'react'
import { ActivityIndicator, Pressable, StyleSheet, Text, View } from 'react-native'
import { CircleAlert, SearchX, WifiOff, type LucideIcon } from 'lucide-react-native'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import { colors, feedback, radii, spacing, typography } from '../theme/mobile-theme'
import { colors, feedback, radii, spacing, typography, pressedStyle } from '../theme/mobile-theme'
import { themedStyleSheet } from '../theme/themed-styles'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { describeLoadError } from './load-error-description'
@@ -74,6 +74,7 @@ function MobileStateDetails({ details }: { details: string }) {
return (
<>
<Pressable
style={({ pressed }) => pressed && pressedStyle}
onPress={() => setOpen(!open)}
hitSlop={8}
accessibilityRole="button"
@@ -4,7 +4,7 @@ import { useRouter, useSegments, type ErrorBoundaryProps } from 'expo-router'
import { discardInitialLaunchIntent } from '../navigation/initial-launch-intent'
import { recordNativeRenderError } from '../diagnostics/native-render-log'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import { colors, radii, spacing, typography } from '../theme/mobile-theme'
import { colors, radii, spacing, typography, pressedStyle } from '../theme/mobile-theme'
import { themedStyleSheet } from '../theme/themed-styles'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
@@ -23,14 +23,18 @@ export function NativeScreenRecovery({ error, retry }: ErrorBoundaryProps) {
<Text style={styles.title}>
{t('components.nativeScreenRecovery.title', 'Something went wrong')}
</Text>
<Pressable accessibilityRole="button" style={styles.retryButton} onPress={() => void retry()}>
<Pressable
accessibilityRole="button"
style={({ pressed }) => [styles.retryButton, pressed && pressedStyle]}
onPress={() => void retry()}
>
<Text style={styles.retryText}>
{t('components.nativeScreenRecovery.tryAgain', 'Try again')}
</Text>
</Pressable>
<Pressable
accessibilityRole="button"
style={styles.homeButton}
style={({ pressed }) => [styles.homeButton, pressed && pressedStyle]}
onPress={() => {
discardInitialLaunchIntent()
router.replace('/')
@@ -4,6 +4,7 @@ import type { WorkspaceSshGate } from '../tasks/workspace-ssh-gate'
import { workspaceSshStatusLabel } from '../tasks/workspace-ssh-gate'
import { newWorktreeFormStyles as styles } from './new-worktree-form-styles'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { pressedStyle } from '../theme/mobile-theme'
export function NewWorkspaceSshConnectionField({
repoName,
@@ -41,7 +42,11 @@ export function NewWorkspaceSshConnectionField({
</View>
{sshGate.status === 'connected' ? null : (
<Pressable
style={[styles.sshConnectButton, sshGate.connectInProgress && styles.disabled]}
style={({ pressed }) => [
styles.sshConnectButton,
sshGate.connectInProgress && styles.disabled,
pressed && pressedStyle
]}
disabled={sshGate.connectInProgress}
onPress={onConnect}
>
+35 -65
View File
@@ -1,16 +1,8 @@
import { type ReactNode, useCallback, useEffect, useState } from 'react'
import { type ReactNode, useEffect, useMemo, useState } from 'react'
import { View, Pressable, StyleSheet, Platform, Keyboard } from 'react-native'
import { useSafeAreaFrame, useSafeAreaInsets } from 'react-native-safe-area-context'
import { Gesture, GestureDetector, GestureHandlerRootView } from 'react-native-gesture-handler'
import Animated, {
useSharedValue,
useAnimatedStyle,
withSpring,
withTiming,
runOnJS,
interpolate,
Extrapolation
} from 'react-native-reanimated'
import Animated, { useSharedValue, useAnimatedStyle } from 'react-native-reanimated'
import { useBackClaim } from '../navigation/use-back-claim'
import { colors, radii, spacing } from '../theme/mobile-theme'
import { themedStyleSheet } from '../theme/themed-styles'
@@ -18,15 +10,15 @@ import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
// Reuse BottomDrawer’s anchor-independent mount-before-commit gate.
import { resolveBottomDrawerMounted } from './bottom-drawer-mount-state'
import { resolveRightDrawerPanelWidth } from './right-drawer-panel-width'
import { SETTLE_SPRING } from './sheet-motion-values'
import {
bottomDrawerOffset,
bottomDrawerScrim,
bottomDrawerTravel
} from './bottom-drawer-drag-motion'
import { hideDrawer, showDrawer, useDrawerDrag } from './use-bottom-drawer-drag'
import { useDrawerReducedMotion } from './bottom-drawer-constants'
import { useResponsiveLayout } from '../layout/responsive-layout'
const DISMISS_THRESHOLD = 80
// Damp negative translateX so panel resists pulling inward past docked edge.
const RUBBER_BAND_FACTOR = 0.25
const SHOW_DURATION = 180
const HIDE_DURATION = 150
type Props = {
visible: boolean
onClose: () => void
@@ -75,24 +67,26 @@ function MountedRightDrawer({
widthPx
}: MountedRightDrawerProps) {
useMobileColorScheme()
const translateX = useSharedValue(0)
const progress = useSharedValue(0)
const fade = useSharedValue(0)
const reducedMotion = useDrawerReducedMotion()
const motion = useMemo(() => ({ progress, fade, reducedMotion }), [progress, fade, reducedMotion])
const { width: screenWidth } = useSafeAreaFrame()
const insets = useSafeAreaInsets()
const { isWideLayout } = useResponsiveLayout()
const panelWidth = resolveRightDrawerPanelWidth(screenWidth, isWideLayout, widthPx)
const extent = useSharedValue(panelWidth)
useEffect(() => {
extent.value = panelWidth
}, [extent, panelWidth])
// The panel moves like the bottom sheet, on its own axis: one value, the same curve and release.
useEffect(() => {
if (visible) {
translateX.value = 0
progress.value = withTiming(1, { duration: SHOW_DURATION })
showDrawer(motion)
} else {
Keyboard.dismiss()
progress.value = withTiming(0, { duration: HIDE_DURATION }, (finished) => {
if (finished) {
runOnJS(onHidden)()
}
})
hideDrawer(motion, onHidden)
}
}, [onHidden, visible])
@@ -106,53 +100,29 @@ function MountedRightDrawer({
: null
)
const dismiss = useCallback(() => {
onClose()
}, [onClose])
const drag = useDrawerDrag({ ...motion, extent, screenExtent: screenWidth, onDismiss: onClose })
const scrollGesture = Gesture.Native()
// Positive horizontal swipe dismisses; activeOffset leaves vertical ScrollView gestures intact.
const panGesture = Gesture.Pan()
.activeOffsetX([-8, 8])
.simultaneousWithExternalGesture(scrollGesture)
.onUpdate((e) => {
if (e.translationX > 0) {
translateX.value = e.translationX
} else {
translateX.value = e.translationX * RUBBER_BAND_FACTOR
}
})
.onEnd((e) => {
if (e.translationX > DISMISS_THRESHOLD || e.velocityX > 500) {
const velocity = Math.max(e.velocityX, 800)
const remaining = panelWidth - e.translationX
const duration = Math.min(Math.max((remaining / velocity) * 1000, 120), 300)
translateX.value = withTiming(panelWidth, { duration })
progress.value = withTiming(0, { duration }, () => {
runOnJS(dismiss)()
})
} else {
translateX.value = withSpring(0, { ...SETTLE_SPRING, velocity: e.velocityX })
}
})
.onBegin(() => drag.begin())
.onUpdate((e) => drag.follow(e.translationX))
.onEnd((e) => drag.release(e.velocityX))
const drawerStyle = useAnimatedStyle(
() => ({
transform: [
{
translateX:
interpolate(progress.value, [0, 1], [panelWidth, 0], Extrapolation.CLAMP) +
translateX.value
}
]
}),
[progress, translateX, panelWidth]
)
// Web has no worklet plugin; mapper hooks need this explicit dependency list.
const drawerStyle = useAnimatedStyle(() => {
const travel = bottomDrawerTravel(extent.value, screenWidth)
return {
opacity: fade.value,
transform: [{ translateX: bottomDrawerOffset(progress.value, travel) }]
}
}, [progress, fade, extent, screenWidth])
const backdropStyle = useAnimatedStyle(() => {
const dragFade = interpolate(translateX.value, [0, panelWidth], [1, 0], Extrapolation.CLAMP)
return { opacity: progress.value * dragFade }
}, [progress, translateX, panelWidth])
const travel = bottomDrawerTravel(extent.value, screenWidth)
return { opacity: fade.value * bottomDrawerScrim(progress.value, travel, extent.value) }
}, [progress, fade, extent, screenWidth])
return (
<Animated.View
@@ -163,7 +133,7 @@ function MountedRightDrawer({
>
<GestureHandlerRootView style={styles.root}>
<Animated.View style={[styles.backdrop, backdropStyle]}>
<Pressable style={StyleSheet.absoluteFill} onPress={dismiss} />
<Pressable style={StyleSheet.absoluteFill} onPress={onClose} />
</Animated.View>
<View style={styles.anchor} pointerEvents="box-none">
+24 -3
View File
@@ -76,7 +76,14 @@ export function SetupHookTrustDrawer({
</View>
<View style={styles.trustActionGroup}>
<Pressable style={styles.trustActionRow} disabled={busy} onPress={onRunOnce}>
<Pressable
style={({ pressed }) => [
styles.trustActionRow,
pressed && { backgroundColor: colors.translucentFill }
]}
disabled={busy}
onPress={onRunOnce}
>
<Check size={16} color={colors.textPrimary} />
<Text style={styles.trustActionText}>
{t('components.setupHookTrustDrawer.runHooks', 'Run hooks')}
@@ -85,7 +92,14 @@ export function SetupHookTrustDrawer({
<View style={styles.trustActionSeparator} />
{allowAlwaysTrust ? (
<>
<Pressable style={styles.trustActionRow} disabled={busy} onPress={onAlwaysTrust}>
<Pressable
style={({ pressed }) => [
styles.trustActionRow,
pressed && { backgroundColor: colors.translucentFill }
]}
disabled={busy}
onPress={onAlwaysTrust}
>
<Check size={16} color={colors.textPrimary} />
<Text style={styles.trustActionText}>
{t('components.setupHookTrustDrawer.alwaysTrustAndRun', 'Always trust and run')}
@@ -94,7 +108,14 @@ export function SetupHookTrustDrawer({
<View style={styles.trustActionSeparator} />
</>
) : null}
<Pressable style={styles.trustActionRow} disabled={busy} onPress={onDontRun}>
<Pressable
style={({ pressed }) => [
styles.trustActionRow,
pressed && { backgroundColor: colors.translucentFill }
]}
disabled={busy}
onPress={onDontRun}
>
<Text style={styles.trustActionText}>
{t('components.setupHookTrustDrawer.dontRun', "Don't run")}
</Text>
@@ -27,7 +27,7 @@ import {
} from '../tasks/smart-source-paste-intent'
import { useSmartWorkspaceSource } from '../tasks/use-smart-workspace-source'
import type { MobileComposerSource } from '../tasks/use-mobile-composer-source'
import { colors } from '../theme/mobile-theme'
import { colors, pressedStyle } from '../theme/mobile-theme'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import { BottomDrawer } from './BottomDrawer'
@@ -234,11 +234,14 @@ export function SmartWorkspaceSourceDrawer({
)}
</Text>
<View style={styles.crossRepoActions}>
<Pressable style={styles.crossRepoDismiss} onPress={dismissCrossRepoPrompt}>
<Pressable
style={({ pressed }) => [styles.crossRepoDismiss, pressed && pressedStyle]}
onPress={dismissCrossRepoPrompt}
>
<Text style={styles.crossRepoDismissText}>{t('common.cancel', 'Cancel')}</Text>
</Pressable>
<Pressable
style={styles.crossRepoSwitch}
style={({ pressed }) => [styles.crossRepoSwitch, pressed && pressedStyle]}
onPress={() => void handleAcceptCrossRepo()}
>
<Text style={styles.crossRepoSwitchText}>
@@ -319,7 +322,11 @@ export function SmartWorkspaceSourceDrawer({
return (
<Pressable
key={option.id}
style={[styles.chip, selected && styles.chipSelected]}
style={({ pressed }) => [
styles.chip,
selected && styles.chipSelected,
pressed && pressedStyle
]}
onPress={() => setMrStateFilter(option.id)}
>
<Text style={[styles.chipText, selected && styles.chipTextSelected]}>
@@ -338,7 +345,11 @@ export function SmartWorkspaceSourceDrawer({
return (
<Pressable
key={option.id}
style={[styles.tab, selected && styles.tabSelected]}
style={({ pressed }) => [
styles.tab,
selected && styles.tabSelected,
pressed && pressedStyle
]}
onPress={() => setMode(option.id)}
>
<SmartSourceModeIcon icon={option.icon} color={tint} />
@@ -9,7 +9,7 @@ import {
} from 'lucide-react-native'
import type { SmartNameSelection } from '../tasks/mobile-composer-source-types'
import type { MobileComposerSource } from '../tasks/use-mobile-composer-source'
import { colors, spacing } from '../theme/mobile-theme'
import { colors, spacing, pressedStyle } from '../theme/mobile-theme'
import { themedStyleSheet } from '../theme/themed-styles'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
@@ -83,7 +83,7 @@ export function SmartWorkspaceSourceField({
<View style={styles.actions}>
{selection.url ? (
<Pressable
style={styles.action}
style={({ pressed }) => [styles.action, pressed && pressedStyle]}
accessibilityRole="link"
accessibilityLabel={t(
'components.smartWorkspaceSourceField.openSelectedSource',
@@ -100,7 +100,7 @@ export function SmartWorkspaceSourceField({
</Pressable>
) : null}
<Pressable
style={styles.action}
style={({ pressed }) => [styles.action, pressed && pressedStyle]}
accessibilityRole="button"
accessibilityLabel={t(
'components.smartWorkspaceSourceField.clearSelectedSource',
+2 -1
View File
@@ -3,7 +3,7 @@ import { memo } from 'react'
import { Pressable, Text, View } from 'react-native'
import type { RuntimeWorktreeAgentRow } from '../../../src/shared/runtime-types'
import { withoutNativeChatVisualDirectiveLines } from '../../../src/shared/native-chat/native-chat-visual-directive'
import { colors, spacing } from '../theme/mobile-theme'
import { colors, spacing, pressedStyle } from '../theme/mobile-theme'
import { themedStyleSheet } from '../theme/themed-styles'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import {
@@ -82,6 +82,7 @@ function WorktreeAgentRowComponent({
)
return childRow ? (
<Pressable
style={({ pressed }) => pressed && pressedStyle}
disabled={isReadOnly || !onPress}
accessibilityRole="button"
onPress={(event) => {
@@ -19,14 +19,19 @@ async function mount(element: ReactElement): Promise<ReactTestRenderer> {
return mounted.renderer
}
const { animationLoop, animationTiming, setValue } = vi.hoisted(() => ({
const { animationLoop, animationTiming, setValue, motion } = vi.hoisted(() => ({
animationLoop: vi.fn(() => ({ start: vi.fn(), stop: vi.fn() })),
animationTiming: vi.fn(() => ({})),
setValue: vi.fn()
setValue: vi.fn(),
motion: { reduced: false }
}))
vi.mock('lucide-react-native', () => ({ Activity: 'Activity' }))
vi.mock('react-native', () => ({
AccessibilityInfo: {
isReduceMotionEnabled: () => Promise.resolve(motion.reduced),
addEventListener: () => ({ remove: () => {} })
},
Animated: {
Value: function Value() {
return { interpolate: vi.fn(() => 'rotation'), setValue }
@@ -48,6 +53,7 @@ describe('mobile monitoring indicators', () => {
animationLoop.mockClear()
animationTiming.mockClear()
setValue.mockClear()
motion.reduced = false
})
afterEach(() => {
@@ -103,6 +109,23 @@ describe('mobile monitoring indicators', () => {
}
})
it('holds both working rings still and closed under Reduce Motion, like desktop', async () => {
motion.reduced = true
renderer = await mount(
createElement('View', null, [
createElement(AgentSpinner, { key: 'spinner', status: 'working' }),
createElement(AgentStateDot, { key: 'dot', state: 'working' })
])
)
expect(animationLoop).not.toHaveBeenCalled()
const rings = findAllByHostType(renderer.root, 'AnimatedView')
expect(rings).toHaveLength(2)
for (const ring of rings) {
expect(ring.props.style).toContainEqual({ borderTopColor: DESKTOP_WORKING_COLOR })
}
})
it.each([
// A user's Stop is not news: muted, never the fault red a failure draws.
['interrupted', colors.textMuted],
@@ -42,11 +42,14 @@ vi.mock('react-native-gesture-handler', () => {
}
})
vi.mock('./AutoHeight', () => ({ AutoHeight: ({ children }: { children: unknown }) => children }))
// The OS motion setting is read through AccessibilityInfo, which the react-native mock leaves out.
vi.mock('../platform/use-reduced-motion', () => ({ useReducedMotionEnabled: () => false }))
vi.mock('react-native-reanimated', () => {
function isTiming(value: unknown): value is Timing {
return typeof value === 'object' && value !== null && 'to' in value
}
return {
useReducedMotion: () => false,
Easing: { bezier: () => (t: number) => t },
default: { View: 'AnimatedView', ScrollView: 'AnimatedScrollView' },
useSharedValue: (initial: number) => {
@@ -1,7 +1,17 @@
import { Easing } from 'react-native-reanimated'
import { Easing, useReducedMotion } from 'react-native-reanimated'
import { useReducedMotionEnabled } from '../platform/use-reduced-motion'
import { SHEET_CURVE, SHEET_HEIGHT_DURATION_MS } from './sheet-motion-values'
export const BOTTOM_DRAWER_EASING = Easing.bezier(...SHEET_CURVE)
export const BOTTOM_DRAWER_SHOW_DURATION_MS = 480
export const BOTTOM_DRAWER_HIDE_DURATION_MS = 300
export const BOTTOM_DRAWER_HEIGHT_DURATION_MS = SHEET_HEIGHT_DURATION_MS
/**
* Reduce Motion as soon as it is known: the live accessibility value once read, Reanimated's
* launch-time value before that, so a drawer opened on mount never slides under Reduce Motion.
*/
export function useDrawerReducedMotion(): boolean {
const launchValue = useReducedMotion()
return useReducedMotionEnabled() ?? launchValue
}
@@ -42,7 +42,10 @@ vi.mock('react-native-gesture-handler', () => {
}
})
vi.mock('./AutoHeight', () => ({ AutoHeight: ({ children }: { children: unknown }) => children }))
// The OS motion setting is read through AccessibilityInfo, which the react-native mock leaves out.
vi.mock('../platform/use-reduced-motion', () => ({ useReducedMotionEnabled: () => false }))
vi.mock('react-native-reanimated', () => ({
useReducedMotion: () => false,
Easing: { bezier: () => (t: number) => t },
default: { View: 'AnimatedView', ScrollView: 'AnimatedScrollView' },
useSharedValue: (initial: number) => ({ value: initial }),
@@ -44,6 +44,8 @@ vi.mock('react-native-gesture-handler', () => {
}
})
vi.mock('./AutoHeight', () => ({ AutoHeight: ({ children }: { children: unknown }) => children }))
// The OS motion setting is read through AccessibilityInfo, which the react-native mock leaves out.
vi.mock('../platform/use-reduced-motion', () => ({ useReducedMotionEnabled: () => false }))
vi.mock('react-native-reanimated', () => {
function makeShared(key: string, initial: number) {
let value = initial
@@ -60,6 +62,7 @@ vi.mock('react-native-reanimated', () => {
let sharedIndex = 0
return {
Easing: { bezier: () => (t: number) => t },
useReducedMotion: () => false,
default: { View: 'AnimatedView', ScrollView: 'AnimatedScrollView' },
useSharedValue: (initial: number) => makeShared(`shared-${sharedIndex++}`, initial),
useAnimatedStyle: () => ({}),
@@ -203,6 +203,10 @@ vi.mock('react-native-reanimated', async () => {
return { setActive: probe.frameActive }
},
withSpring: probe.spring,
withTiming: (value: number) => value,
interpolateColor: (value: number, _input: number[], output: string[]) =>
value >= 1 ? output[1] : output[0],
Easing: { out: (easing: unknown) => easing, cubic: 'cubic' },
runOnJS:
(fn: (...args: unknown[]) => unknown) =>
(...args: unknown[]) => {
@@ -23,6 +23,7 @@ import { codeFenceClosed, plainText } from './mobile-markdown-tree'
import { MermaidDiagram } from './pr-sidebar/MermaidDiagram'
import { MobileMarkdownCodeBlock } from './MobileMarkdownCodeBlock'
import { translate } from '../i18n/mobile-i18n'
import { pressedStyle } from '../theme/mobile-theme'
/** Prose base size — passed to MermaidDiagram fallback mono text. */
const MERMAID_BASE = 13
@@ -165,7 +166,7 @@ function renderBlock(
return (
<Pressable
key={key}
style={styles.imageFrame}
style={({ pressed }) => [styles.imageFrame, pressed && pressedStyle]}
onPress={() => openMarkdownHref(only.url, ctx.onOpenFile)}
onLongPress={ctx.rowLongPress}
>
@@ -64,7 +64,10 @@ vi.mock('react-native-gesture-handler', () => {
}
})
vi.mock('./AutoHeight', () => ({ AutoHeight: ({ children }: { children: unknown }) => children }))
// The OS motion setting is read through AccessibilityInfo, which the react-native mock leaves out.
vi.mock('../platform/use-reduced-motion', () => ({ useReducedMotionEnabled: () => false }))
vi.mock('react-native-reanimated', () => ({
useReducedMotion: () => false,
Easing: { bezier: () => (t: number) => t },
default: { View: 'AnimatedView', ScrollView: 'AnimatedScrollView' },
useSharedValue: (initial: number) => {
@@ -56,9 +56,12 @@ vi.mock('react-native-gesture-handler', () => {
}
})
vi.mock('./AutoHeight', () => ({ AutoHeight: ({ children }: { children: unknown }) => children }))
// The OS motion setting is read through AccessibilityInfo, which the react-native mock leaves out.
vi.mock('../platform/use-reduced-motion', () => ({ useReducedMotionEnabled: () => false }))
vi.mock('react-native-reanimated', async () => {
const React = await import('react')
return {
useReducedMotion: () => false,
Easing: { bezier: () => (t: number) => t },
default: { View: 'AnimatedView', ScrollView: 'AnimatedScrollView' },
useSharedValue: (initial: number) => React.useRef({ value: initial }).current,
+17 -32
View File
@@ -1,4 +1,4 @@
import { type ReactNode, useCallback, useEffect, useRef, useState } from 'react'
import { type ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react'
import {
View,
Pressable,
@@ -9,22 +9,12 @@ import {
Platform
} from 'react-native'
import { GestureDetector, GestureHandlerRootView } from 'react-native-gesture-handler'
import Animated, {
useSharedValue,
useAnimatedStyle,
withTiming,
runOnJS
} from 'react-native-reanimated'
import Animated, { useSharedValue, useAnimatedStyle, withTiming } from 'react-native-reanimated'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import { spacing } from '../theme/mobile-theme'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { resolveBottomDrawerFillHeight } from './bottom-drawer-fill-height'
import { resolveBottomDrawerKeyboardInset } from './bottom-drawer-keyboard-inset'
import {
BOTTOM_DRAWER_EASING,
BOTTOM_DRAWER_HIDE_DURATION_MS,
BOTTOM_DRAWER_SHOW_DURATION_MS
} from './bottom-drawer-constants'
import { AutoHeight } from './AutoHeight'
import {
bottomDrawerOffset,
@@ -41,10 +31,9 @@ import { useWindowSafeAreaInsets } from '../layout/side-safe-area'
import { useBackClaim } from '../navigation/use-back-claim'
import { currentSoftKeyboardHeight, subscribeSoftKeyboard } from '../platform/keyboard-occlusion'
import { hostOs } from '../platform/host-os'
import { useBottomDrawerDrag } from './use-bottom-drawer-drag'
import { hideDrawer, showDrawer, useBottomDrawerDrag } from './use-bottom-drawer-drag'
import { useDrawerReducedMotion } from './bottom-drawer-constants'
const SHOW_TIMING = { duration: BOTTOM_DRAWER_SHOW_DURATION_MS, easing: BOTTOM_DRAWER_EASING }
const HIDE_TIMING = { duration: BOTTOM_DRAWER_HIDE_DURATION_MS, easing: BOTTOM_DRAWER_EASING }
// The grabber row above the content: its padding plus the 5 pt bar.
const HANDLE_AREA_HEIGHT = spacing.sm + 5 + spacing.md
@@ -78,6 +67,9 @@ export function MountedBottomDrawer({
useMobileColorScheme()
const t = useMobileTranslation()
const progress = useSharedValue(0)
const fade = useSharedValue(0)
const reducedMotion = useDrawerReducedMotion()
const motion = useMemo(() => ({ progress, fade, reducedMotion }), [progress, fade, reducedMotion])
const keyboardOffset = useSharedValue(0)
const scrollOffsetY = useSharedValue(0)
const scrollRef = useRef<ScrollView>(null)
@@ -114,7 +106,7 @@ export function MountedBottomDrawer({
if (!tookWindowBack) {
return
}
progress.value = withTiming(1, SHOW_TIMING)
showDrawer(motion)
// Pages have no native binding to heal, and a remount there paints one empty frame of the sheet.
if (Platform.OS !== 'web') {
setWindowEpoch((epoch) => epoch + 1)
@@ -125,15 +117,11 @@ export function MountedBottomDrawer({
// Both directions run from wherever the sheet is, so a reopen mid-close never jumps.
if (visible) {
scrollOffsetY.value = 0
progress.value = withTiming(1, SHOW_TIMING)
showDrawer(motion)
} else {
Keyboard.dismiss()
setKeyboardInset(0)
progress.value = withTiming(0, HIDE_TIMING, (finished) => {
if (finished) {
runOnJS(onHidden)()
}
})
hideDrawer(motion, onHidden)
}
}, [onHidden, visible])
@@ -192,12 +180,8 @@ export function MountedBottomDrawer({
return
}
Keyboard.dismiss()
progress.value = withTiming(0, HIDE_TIMING, (finished) => {
if (finished) {
runOnJS(onClose)()
}
})
}, [onClose, progress, visible])
hideDrawer(motion, onClose)
}, [onClose, motion, visible])
// Top interactive sheet claims native/shell Back so Android closes drawer rather than screen; pinned-under sheet never owns key.
useBackClaim(
@@ -211,7 +195,7 @@ export function MountedBottomDrawer({
useBottomDrawerModalHostBackClaim(visible && interactive ? dismiss : null)
const { scrollHandler, scrollGesture, handlePanGesture, contentPanGesture } = useBottomDrawerDrag(
{ progress, sheetHeight, screenHeight, scrollOffsetY, onDismiss: onClose }
{ ...motion, sheetHeight, screenHeight, scrollOffsetY, onDismiss: onClose }
)
const drawerStyle = useAnimatedStyle(() => {
@@ -219,14 +203,15 @@ export function MountedBottomDrawer({
const keyboardShift = fillAvailable ? 0 : keyboardOffset.value
const travel = bottomDrawerTravel(sheetHeight.value, screenHeight)
return {
opacity: fade.value,
transform: [{ translateY: bottomDrawerOffset(progress.value, travel) - keyboardShift }]
}
}, [progress, keyboardOffset, screenHeight, fillAvailable, sheetHeight])
}, [progress, fade, keyboardOffset, screenHeight, fillAvailable, sheetHeight])
const backdropStyle = useAnimatedStyle(() => {
const travel = bottomDrawerTravel(sheetHeight.value, screenHeight)
return { opacity: bottomDrawerScrim(progress.value, travel, sheetHeight.value) }
}, [progress, sheetHeight, screenHeight])
return { opacity: fade.value * bottomDrawerScrim(progress.value, travel, sheetHeight.value) }
}, [progress, fade, sheetHeight, screenHeight])
// Use full-screen native Modal (own/shared) to escape nested ScrollView clipping; progress drives animationType:none so exit finishes before unmount.
const handle = (
@@ -2,7 +2,7 @@ import { useMemo, useState } from 'react'
import { Pressable, ScrollView, StyleSheet, Text, View } from 'react-native'
import { openExternalLink } from '../../platform/external-link'
import { ChevronDown, ChevronRight } from 'lucide-react-native'
import { colors, radii, spacing, typography } from '../../theme/mobile-theme'
import { colors, radii, spacing, typography, pressedStyle } from '../../theme/mobile-theme'
import { themedStyleSheet } from '../../theme/themed-styles'
import { useMobileColorScheme } from '../../theme/use-mobile-color-scheme'
import { MermaidDiagram } from './MermaidDiagram'
@@ -63,7 +63,7 @@ function DetailsBlock({
return (
<View style={styles.details}>
<Pressable
style={styles.detailsSummary}
style={({ pressed }) => [styles.detailsSummary, pressed && pressedStyle]}
onPress={() => setOpen((v) => !v)}
accessibilityRole="button"
>
@@ -1,7 +1,7 @@
import { memo, useEffect, useId, useMemo, useRef, useState, type ReactNode } from 'react'
import { Pressable, ScrollView, StyleSheet, Text, View } from 'react-native'
import { Maximize2 } from 'lucide-react-native'
import { colors, radii, spacing, typography } from '../../theme/mobile-theme'
import { colors, radii, spacing, typography, pressedStyle } from '../../theme/mobile-theme'
import { useMobileColorScheme } from '../../theme/use-mobile-color-scheme'
import { themedStyleSheet } from '../../theme/themed-styles'
import { readableMermaidFlowchartSvg } from '../../../../src/shared/mermaid-flowchart-contrast'
@@ -88,7 +88,12 @@ export const MermaidDiagram = memo(function MermaidDiagram({ source, base }: Mer
return (
<MermaidFrame onExpand={drawnSvg ? () => setExpanded(true) : undefined}>
{/* The header button is the accessible control; the drawing is a tap shortcut. */}
<Pressable accessible={false} disabled={!drawnSvg} onPress={() => setExpanded(true)}>
<Pressable
style={({ pressed }) => pressed && pressedStyle}
accessible={false}
disabled={!drawnSvg}
onPress={() => setExpanded(true)}
>
<View ref={hostRef} style={styles.host} />
</Pressable>
{expanded && drawnSvg ? (
@@ -125,6 +130,7 @@ function MermaidFrame({ children, onExpand }: { children: ReactNode; onExpand?:
<Text style={styles.labelText}>mermaid</Text>
{onExpand ? (
<Pressable
style={({ pressed }) => pressed && pressedStyle}
onPress={onExpand}
hitSlop={8}
accessibilityRole="button"
@@ -1,6 +1,6 @@
import { useCallback, useState } from 'react'
import { ActivityIndicator, Pressable, Text, View } from 'react-native'
import { colors, radii, spacing, typography } from '../../theme/mobile-theme'
import { colors, radii, spacing, typography, pressedStyle } from '../../theme/mobile-theme'
import { themedStyleSheet } from '../../theme/themed-styles'
import { useMobileColorScheme } from '../../theme/use-mobile-color-scheme'
import type { RpcClient } from '../../transport/rpc-client'
@@ -66,6 +66,7 @@ export function MobileLinkPrForm({ client, worktreeId, onCancel, onLinked }: Pro
{t('pullRequest.linkPrForm.title', 'Link existing pull request')}
</Text>
<Pressable
style={({ pressed }) => pressed && pressedStyle}
onPress={onCancel}
disabled={submitting}
accessibilityRole="button"
@@ -1,7 +1,7 @@
import { useCallback, useState } from 'react'
import { ActivityIndicator, Pressable, Text, View } from 'react-native'
import { GitMerge, Link2Off } from 'lucide-react-native'
import { colors } from '../../theme/mobile-theme'
import { colors, pressedStyle } from '../../theme/mobile-theme'
import { useMobileColorScheme } from '../../theme/use-mobile-color-scheme'
import type { GitHubPRMergeMethod, PRInfo } from '../../../../src/shared/github/pull-request-types'
import type { RpcClient } from '../../transport/rpc-client'
@@ -143,10 +143,11 @@ export function PRActionsSection({
<View style={styles.actionsBlock}>
{avail.canMerge ? (
<Pressable
style={[
style={({ pressed }) => [
styles.actionButton,
styles.actionButtonMerge,
(mergeBusy || !merge.enabled) && styles.actionButtonDisabled
(mergeBusy || !merge.enabled) && styles.actionButtonDisabled,
pressed && pressedStyle
]}
onPress={() => {
setUnlinkError(null)
@@ -173,6 +174,7 @@ export function PRActionsSection({
<Text style={styles.actionHint}>{merge.hint}</Text>
{/* No mobile surface polls PR state, so a blocked Merge needs its own recheck. */}
<Pressable
style={({ pressed }) => pressed && pressedStyle}
onPress={() => onRecheck()}
hitSlop={8}
accessibilityRole="button"
@@ -190,10 +192,11 @@ export function PRActionsSection({
{showMarkReady ? (
<Pressable
style={[
style={({ pressed }) => [
styles.actionButton,
styles.secondaryButton,
stateBusy && styles.actionButtonDisabled
stateBusy && styles.actionButtonDisabled,
pressed && pressedStyle
]}
onPress={() => {
setUnlinkError(null)
@@ -219,7 +222,11 @@ export function PRActionsSection({
{t('pullRequest.prActionsSection.autoMergeLabel', 'Auto-merge when ready')}
</Text>
<Pressable
style={[styles.togglePill, autoMerge && styles.togglePillOn]}
style={({ pressed }) => [
styles.togglePill,
autoMerge && styles.togglePillOn,
pressed && pressedStyle
]}
onPress={() => {
setUnlinkError(null)
actions.setAutoMerge(!autoMerge, effectiveMethod)
@@ -249,10 +256,11 @@ export function PRActionsSection({
<View style={styles.secondaryRow}>
{avail.canClose || avail.canReopen ? (
<Pressable
style={[
style={({ pressed }) => [
styles.actionButton,
styles.secondaryButton,
stateBusy && styles.actionButtonDisabled
stateBusy && styles.actionButtonDisabled,
pressed && pressedStyle
]}
onPress={() => {
setUnlinkError(null)
@@ -284,10 +292,11 @@ export function PRActionsSection({
) : null}
{avail.canUnlink ? (
<Pressable
style={[
style={({ pressed }) => [
styles.actionButton,
styles.secondaryButton,
unlinkBusy && styles.actionButtonDisabled
unlinkBusy && styles.actionButtonDisabled,
pressed && pressedStyle
]}
onPress={() => void unlink()}
disabled={unlinkBusy}
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef, useState } from 'react'
import { ActivityIndicator, Pressable, Text, View } from 'react-native'
import { openExternalLink } from '../../platform/external-link'
import { ChevronDown, ChevronRight, ExternalLink, RotateCw, Sparkles } from 'lucide-react-native'
import { colors } from '../../theme/mobile-theme'
import { colors, pressedStyle } from '../../theme/mobile-theme'
import { useMobileColorScheme } from '../../theme/use-mobile-color-scheme'
import { translate } from '../../i18n/mobile-i18n'
import type { Translate } from '../../i18n/mobile-i18n'
@@ -230,7 +230,7 @@ export function PRChecksSection({
{/* Rerun is offered only when something failed; spinner-in-place while in-flight. */}
{actions && count > 0 ? (
<Pressable
style={styles.iconButton}
style={({ pressed }) => [styles.iconButton, pressed && pressedStyle]}
onPress={() => actions.rerunFailingChecks()}
disabled={rerunBusy}
accessibilityRole="button"
@@ -310,7 +310,10 @@ export function PRChecksSection({
return (
<View key={key}>
<Pressable
style={styles.row}
style={({ pressed }) => [
styles.row,
pressed && { backgroundColor: colors.translucentFill }
]}
onPress={() => toggle(check)}
accessibilityRole="button"
accessibilityLabel={t(
@@ -332,7 +335,7 @@ export function PRChecksSection({
</Text>
{url ? (
<Pressable
style={styles.rowTrailing}
style={({ pressed }) => [styles.rowTrailing, pressed && pressedStyle]}
onPress={() => openExternalLink(url)}
hitSlop={6}
accessibilityRole="button"
@@ -7,7 +7,7 @@ import type {
GitHubReactionContent,
PRComment
} from '../../../../src/shared/github/comment-types'
import { colors } from '../../theme/mobile-theme'
import { colors, pressedStyle } from '../../theme/mobile-theme'
import { useMobileColorScheme } from '../../theme/use-mobile-color-scheme'
import type { Translate } from '../../i18n/mobile-i18n'
import { useMobileTranslation } from '../../i18n/use-mobile-translation'
@@ -186,7 +186,7 @@ export const PRCommentCard = memo(function PRCommentCard({
) : null}
{comment.url ? (
<Pressable
style={styles.openButton}
style={({ pressed }) => [styles.openButton, pressed && pressedStyle]}
onPress={() => openExternalLink(comment.url)}
hitSlop={8}
accessibilityRole="button"
@@ -4,7 +4,7 @@ import { ChevronDown, ChevronRight } from 'lucide-react-native'
import type { PRState } from '../../../../src/shared/github/pull-request-types'
import type { GitHubWorkItemDetails } from '../../../../src/shared/github/work-item-types'
import type { GitHubPrRepoSlug } from '../../session/github-pr-rpc'
import { colors } from '../../theme/mobile-theme'
import { colors, pressedStyle } from '../../theme/mobile-theme'
import { useMobileColorScheme } from '../../theme/use-mobile-color-scheme'
import type { Translate } from '../../i18n/mobile-i18n'
import { useMobileTranslation } from '../../i18n/use-mobile-translation'
@@ -186,7 +186,11 @@ export function PRCommentsSection({
return (
<Pressable
key={tab.value}
style={[styles.audienceTab, active && styles.audienceTabActive]}
style={({ pressed }) => [
styles.audienceTab,
active && styles.audienceTabActive,
pressed && pressedStyle
]}
onPress={() => selectFilter(tab.value)}
accessibilityRole="button"
accessibilityState={{ selected: active }}
@@ -220,7 +224,7 @@ export function PRCommentsSection({
))}
{remaining > 0 ? (
<Pressable
style={styles.showMore}
style={({ pressed }) => [styles.showMore, pressed && pressedStyle]}
onPress={() => setLimit((l) => l + COMMENT_PAGE)}
accessibilityRole="button"
>
@@ -302,7 +306,10 @@ function CommentGroupView({
return (
<View style={styles.group}>
<Pressable
style={styles.resolvedHeader}
style={({ pressed }) => [
styles.resolvedHeader,
pressed && { backgroundColor: colors.translucentFill }
]}
onPress={() => setExpanded((v) => !v)}
accessibilityRole="button"
>
@@ -1,7 +1,7 @@
import { useMemo, useState } from 'react'
import { ActivityIndicator, Pressable, Text, View } from 'react-native'
import { UserPlus, X } from 'lucide-react-native'
import { colors } from '../../theme/mobile-theme'
import { colors, pressedStyle } from '../../theme/mobile-theme'
import { useMobileColorScheme } from '../../theme/use-mobile-color-scheme'
import type { Translate } from '../../i18n/mobile-i18n'
import { useMobileTranslation } from '../../i18n/use-mobile-translation'
@@ -89,7 +89,7 @@ export function PRReviewersSection({ details, actions, client, worktreeId }: Pro
const addButton = (
<Pressable
style={styles.iconButton}
style={({ pressed }) => [styles.iconButton, pressed && pressedStyle]}
onPress={() => setPickerOpen(true)}
accessibilityRole="button"
accessibilityLabel={t('pullRequest.reviewersSection.addOrRemove', 'Add or remove reviewers')}
@@ -133,7 +133,7 @@ export function PRReviewersSection({ details, actions, client, worktreeId }: Pro
{row.stateLabel}
</Text>
<Pressable
style={styles.rowTrailing}
style={({ pressed }) => [styles.rowTrailing, pressed && pressedStyle]}
onPress={() => actions.removeReviewer(row.login)}
disabled={busy}
accessibilityRole="button"
@@ -1,7 +1,7 @@
import { useState } from 'react'
import { ActivityIndicator, Pressable, Text, View } from 'react-native'
import { ArrowRight, ExternalLink, Pencil } from 'lucide-react-native'
import { colors } from '../../theme/mobile-theme'
import { colors, pressedStyle } from '../../theme/mobile-theme'
import { useMobileColorScheme } from '../../theme/use-mobile-color-scheme'
import { useMobileTranslation } from '../../i18n/use-mobile-translation'
import type { PRInfo } from '../../../../src/shared/github/pull-request-types'
@@ -191,7 +191,7 @@ function PRTitle({
return (
<Pressable
style={styles.titleRow}
style={({ pressed }) => [styles.titleRow, pressed && pressedStyle]}
onPress={editable ? startEdit : undefined}
disabled={!editable}
accessibilityRole={editable ? 'button' : undefined}
@@ -1,7 +1,7 @@
import { useEffect, useState } from 'react'
import { ActivityIndicator, Pressable, Text, View } from 'react-native'
import { GitPullRequestArrow, Link2, RefreshCw } from 'lucide-react-native'
import { colors } from '../../theme/mobile-theme'
import { colors, pressedStyle } from '../../theme/mobile-theme'
import { useMobileColorScheme } from '../../theme/use-mobile-color-scheme'
import { useMobileTranslation } from '../../i18n/use-mobile-translation'
import type { RpcClient } from '../../transport/rpc-client'
@@ -194,7 +194,11 @@ export function PrSidebarCreateEmptyState({
<RefreshCw size={16} color={colors.textSecondary} strokeWidth={2.2} />
</Pressable>
<Pressable
style={[styles.createButton, (!canCreate || loading) && styles.createButtonDisabled]}
style={({ pressed }) => [
styles.createButton,
(!canCreate || loading) && styles.createButtonDisabled,
pressed && pressedStyle
]}
onPress={() => void openComposer()}
disabled={!canCreate || loading}
accessibilityRole="button"
@@ -128,7 +128,10 @@ export function ReviewerPickerDrawer({
return (
<Pressable
key={item.login}
style={styles.pickerRow}
style={({ pressed }) => [
styles.pickerRow,
pressed && { backgroundColor: colors.translucentFill }
]}
onPress={() => onToggle(item.login)}
accessibilityRole="button"
accessibilityState={{ selected: requested }}
@@ -36,7 +36,13 @@ vi.mock('react-native-safe-area-context', () => ({
}))
vi.mock('react-native-gesture-handler', () => {
const chain: Record<string, unknown> = {}
for (const method of ['activeOffsetX', 'simultaneousWithExternalGesture', 'onUpdate', 'onEnd']) {
for (const method of [
'activeOffsetX',
'simultaneousWithExternalGesture',
'onBegin',
'onUpdate',
'onEnd'
]) {
chain[method] = () => chain
}
return {
@@ -45,7 +51,11 @@ vi.mock('react-native-gesture-handler', () => {
GestureHandlerRootView: 'GestureHandlerRootView'
}
})
// The OS motion setting is read through AccessibilityInfo, which the react-native mock leaves out.
vi.mock('../platform/use-reduced-motion', () => ({ useReducedMotionEnabled: () => false }))
vi.mock('react-native-reanimated', () => ({
useReducedMotion: () => false,
Easing: { bezier: () => (t: number) => t },
default: { View: 'AnimatedView', ScrollView: 'AnimatedScrollView' },
useSharedValue: (initial: number) => ({ value: initial }),
useAnimatedStyle: () => ({}),
@@ -10,3 +10,9 @@ export const SHEET_HEIGHT_DURATION_MS = 320
* mass to 4, which turned the old `{ damping, stiffness }` pair into a wobble.
*/
export const SETTLE_SPRING = { dampingRatio: 1, duration: 350 } as const
/**
* Reduce Motion swaps every slide (sheets, the side panel, page pushes, in-sheet pages) for a
* cross-fade in place, like iOS; a swipe-away still follows the finger and then fades.
*/
export const REDUCED_MOTION_FADE_MS = 200
export const REDUCED_MOTION_DISMISS_FADE_MS = 150
@@ -0,0 +1,45 @@
import { describe, expect, it, vi } from 'vitest'
const timings = vi.hoisted((): { to: number; config: Record<string, unknown> }[] => [])
vi.mock('react-native-gesture-handler', () => ({ Gesture: {} }))
vi.mock('react-native-reanimated', () => ({
Easing: { bezier: () => (t: number) => t },
ReduceMotion: { Never: 'never' },
runOnJS: (fn: () => void) => fn,
withTiming: (to: number, config: Record<string, unknown>, done?: (finished: boolean) => void) => {
timings.push({ to, config })
done?.(true)
return to
}
}))
vi.mock('../platform/use-reduced-motion', () => ({ useReducedMotionEnabled: () => false }))
import { hideDrawer, showDrawer } from './use-bottom-drawer-drag'
const drawer = (reducedMotion: boolean) => ({
progress: { value: 0 },
fade: { value: 0 },
reducedMotion
})
describe('drawer motion under Reduce Motion', () => {
it('opens in place with a 200 ms fade that Reduce Motion cannot skip', () => {
timings.length = 0
const motion = drawer(true)
showDrawer(motion)
expect(motion.progress.value).toBe(1)
expect(timings).toEqual([{ to: 1, config: { duration: 200, reduceMotion: 'never' } }])
})
it('closes with the same fade and reports the drawer gone', () => {
timings.length = 0
const motion = drawer(true)
motion.progress.value = 1
const onDone = vi.fn()
hideDrawer(motion, onDone)
expect(motion.progress.value).toBe(1)
expect(timings[0]).toMatchObject({ to: 0, config: { duration: 200 } })
expect(onDone).toHaveBeenCalledOnce()
})
})
+140 -42
View File
@@ -1,6 +1,7 @@
import { Gesture } from 'react-native-gesture-handler'
import {
Easing,
ReduceMotion,
cancelAnimation,
runOnJS,
useAnimatedScrollHandler,
@@ -9,8 +10,16 @@ import {
withTiming,
type SharedValue
} from 'react-native-reanimated'
import { BOTTOM_DRAWER_HIDE_DURATION_MS } from './bottom-drawer-constants'
import { SETTLE_SPRING } from './sheet-motion-values'
import {
BOTTOM_DRAWER_EASING,
BOTTOM_DRAWER_HIDE_DURATION_MS,
BOTTOM_DRAWER_SHOW_DURATION_MS
} from './bottom-drawer-constants'
import {
REDUCED_MOTION_DISMISS_FADE_MS,
REDUCED_MOTION_FADE_MS,
SETTLE_SPRING
} from './sheet-motion-values'
import {
bottomDrawerDismissMotion,
bottomDrawerDragProgress,
@@ -21,56 +30,131 @@ import {
const TOP_SCROLL_EPSILON = 1
/**
* The sheet's drag: the finger moves the same progress value that opens and closes it, so a grab
* mid-open or mid-close takes the sheet where it is, and release carries the finger's speed.
*/
export function useBottomDrawerDrag(args: {
/** The drawer's motion state: `progress` is its position (1 open), `fade` its opacity. */
export type DrawerMotion = {
progress: SharedValue<number>
sheetHeight: SharedValue<number>
screenHeight: number
scrollOffsetY: SharedValue<number>
onDismiss: () => void
}) {
const { progress, sheetHeight, screenHeight, scrollOffsetY, onDismiss } = args
fade: SharedValue<number>
reducedMotion: boolean
}
/** What opening and closing touch: the two values, read and written whole. */
type DrawerValues = {
progress: { value: number }
fade: { value: number }
reducedMotion: boolean
}
function fadeTo(fade: { value: number }, to: number, duration: number, onDone?: () => void) {
'worklet'
// Never: this fade is what replaces the slide under Reduce Motion, so it must not be skipped too.
fade.value = withTiming(to, { duration, reduceMotion: ReduceMotion.Never }, (finished) => {
if (finished && onDone) {
runOnJS(onDone)()
}
})
}
/** Opens from wherever the drawer is: a slide, or a fade in place under Reduce Motion. */
export function showDrawer({ progress, fade, reducedMotion }: DrawerValues): void {
'worklet'
if (reducedMotion) {
progress.value = 1
fadeTo(fade, 1, REDUCED_MOTION_FADE_MS)
return
}
fade.value = 1
progress.value = withTiming(1, {
duration: BOTTOM_DRAWER_SHOW_DURATION_MS,
easing: BOTTOM_DRAWER_EASING
})
}
/** Closes from wherever the drawer is, then reports it gone. */
export function hideDrawer(
{ progress, fade, reducedMotion }: DrawerValues,
onDone: () => void
): void {
'worklet'
if (reducedMotion) {
fadeTo(fade, 0, REDUCED_MOTION_FADE_MS, onDone)
return
}
progress.value = withTiming(
0,
{ duration: BOTTOM_DRAWER_HIDE_DURATION_MS, easing: BOTTOM_DRAWER_EASING },
(finished) => {
if (finished) {
runOnJS(onDone)()
}
}
)
}
/**
* A drawer's drag along one axis: the finger moves the same progress value that opens and closes
* it, so a grab mid-open or mid-close takes it where it is, and release carries the finger's speed.
* `extent` is the drawer's size along the axis and `screenExtent` the screen's.
*/
export function useDrawerDrag(
args: DrawerMotion & {
extent: SharedValue<number>
screenExtent: number
onDismiss: () => void
}
) {
const { progress, extent, screenExtent, reducedMotion, onDismiss } = args
const dragging = useSharedValue(false)
const dragStartOffset = useSharedValue(0)
const follow = (translationY: number) => {
const begin = () => {
'worklet'
const travel = bottomDrawerTravel(sheetHeight.value, screenHeight)
if (!dragging.value) {
cancelAnimation(progress)
dragStartOffset.value = bottomDrawerOffset(progress.value, travel) - translationY
dragging.value = true
}
progress.value = bottomDrawerDragProgress(dragStartOffset.value + translationY, travel)
dragging.value = false
}
const settle = (velocityY: number) => {
const follow = (translation: number) => {
'worklet'
const travel = bottomDrawerTravel(sheetHeight.value, screenHeight)
const travel = bottomDrawerTravel(extent.value, screenExtent)
if (!dragging.value) {
cancelAnimation(progress)
dragStartOffset.value = bottomDrawerOffset(progress.value, travel) - translation
dragging.value = true
}
progress.value = bottomDrawerDragProgress(dragStartOffset.value + translation, travel)
}
const settle = (velocity: number) => {
'worklet'
dragging.value = false
if (reducedMotion) {
progress.value = 1
return
}
const travel = bottomDrawerTravel(extent.value, screenExtent)
progress.value = withSpring(1, {
...SETTLE_SPRING,
velocity: travel > 0 ? -velocityY / travel : 0
velocity: travel > 0 ? -velocity / travel : 0
})
}
const release = (velocityY: number) => {
const release = (velocity: number) => {
'worklet'
if (!dragging.value) {
return
}
dragging.value = false
const travel = bottomDrawerTravel(sheetHeight.value, screenHeight)
const travel = bottomDrawerTravel(extent.value, screenExtent)
const offset = bottomDrawerOffset(progress.value, travel)
if (!shouldDismissBottomDrawer(offset, velocityY, sheetHeight.value)) {
settle(velocityY)
if (!shouldDismissBottomDrawer(offset, velocity, extent.value)) {
settle(velocity)
return
}
if (reducedMotion) {
fadeTo(args.fade, 0, REDUCED_MOTION_DISMISS_FADE_MS, onDismiss)
return
}
const motion = bottomDrawerDismissMotion(
offset,
velocityY,
velocity,
travel,
BOTTOM_DRAWER_HIDE_DURATION_MS
)
@@ -85,6 +169,25 @@ export function useBottomDrawerDrag(args: {
)
}
return { begin, follow, settle, release, dragging }
}
/** The bottom sheet's grabber and content drags, over its scrollable content. */
export function useBottomDrawerDrag(
args: DrawerMotion & {
sheetHeight: SharedValue<number>
screenHeight: number
scrollOffsetY: SharedValue<number>
onDismiss: () => void
}
) {
const { scrollOffsetY } = args
const drag = useDrawerDrag({
...args,
extent: args.sheetHeight,
screenExtent: args.screenHeight
})
const scrollHandler = useAnimatedScrollHandler((event) => {
scrollOffsetY.value = Math.max(event.contentOffset.y, 0)
})
@@ -93,29 +196,24 @@ export function useBottomDrawerDrag(args: {
const handlePanGesture = Gesture.Pan()
.activeOffsetY([-8, 8])
.simultaneousWithExternalGesture(scrollGesture)
.onBegin(() => {
dragging.value = false
})
.onUpdate((e) => follow(e.translationY))
.onEnd((e) => release(e.velocityY))
.onBegin(() => drag.begin())
.onUpdate((e) => drag.follow(e.translationY))
.onEnd((e) => drag.release(e.velocityY))
const contentPanGesture = Gesture.Pan()
.activeOffsetY([-8, 8])
.simultaneousWithExternalGesture(scrollGesture)
.onBegin(() => {
dragging.value = false
})
.onBegin(() => drag.begin())
.onUpdate((e) => {
// Tall content scrolls back to its top before a downward drag takes the sheet.
if (scrollOffsetY.value > TOP_SCROLL_EPSILON) {
if (dragging.value) {
dragging.value = false
settle(0)
if (drag.dragging.value) {
drag.settle(0)
}
return
}
follow(e.translationY)
drag.follow(e.translationY)
})
.onEnd((e) => release(e.velocityY))
.onEnd((e) => drag.release(e.velocityY))
return { scrollHandler, scrollGesture, handlePanGesture, contentPanGesture }
}
@@ -0,0 +1,56 @@
import { useEffect, useRef } from 'react'
import { Animated, Easing } from 'react-native'
// The page runs these as compositor animations instead (use-working-motion.web.ts).
export type WorkingMotion<Style> = { ref: (node: unknown) => void; style: Style | undefined }
function noRef(): void {}
export function useWorkingRingRotation(
active: boolean
): WorkingMotion<{ transform: { rotate: Animated.AnimatedInterpolation<string> }[] }> {
const spin = useRef(new Animated.Value(0)).current
useEffect(() => {
if (!active) {
spin.setValue(0)
return undefined
}
const animation = Animated.loop(
Animated.timing(spin, {
toValue: 1,
duration: 1000,
easing: Easing.linear,
// Decorative loops must not hold up interaction-scheduled list rendering.
isInteraction: false,
useNativeDriver: true
})
)
animation.start()
return () => animation.stop()
}, [active, spin])
const rotate = spin.interpolate({ inputRange: [0, 1], outputRange: ['0deg', '360deg'] })
return { ref: noRef, style: { transform: [{ rotate }] } }
}
/** Live-work text breathing between full and half opacity on desktop's animate-pulse curve. */
export function useWorkingPulse(active: boolean): WorkingMotion<{ opacity: Animated.Value }> {
const opacity = useRef(new Animated.Value(1)).current
useEffect(() => {
if (!active) {
opacity.setValue(1)
return undefined
}
const to = (toValue: number) =>
Animated.timing(opacity, {
toValue,
duration: 1000,
easing: Easing.bezier(0.4, 0, 0.6, 1),
isInteraction: false,
useNativeDriver: true
})
const animation = Animated.loop(Animated.sequence([to(0.5), to(1)]))
animation.start()
return () => animation.stop()
}, [active, opacity])
return { ref: noRef, style: { opacity } }
}
@@ -0,0 +1,44 @@
import { useCallback, useEffect, useState } from 'react'
import type { WorkingMotion } from './use-working-motion'
// Web Animations on the element run on the compositor, so a busy page cannot stall them the way
// a JS-driven Animated loop is stalled; every ring shares one phase, like desktop's spinner.
function useElementLoop(
active: boolean,
keyframes: Keyframe[],
options: KeyframeAnimationOptions
): (node: unknown) => void {
const [element, setElement] = useState<HTMLElement | null>(null)
const ref = useCallback(
(node: unknown) => setElement(node instanceof HTMLElement ? node : null),
[]
)
useEffect(() => {
if (!active || element === null || typeof element.animate !== 'function') {
return undefined
}
const animation = element.animate(keyframes, { ...options, iterations: Infinity })
animation.startTime = 0
return () => animation.cancel()
}, [active, element, keyframes, options])
return ref
}
const SPIN: Keyframe[] = [{ transform: 'rotate(0deg)' }, { transform: 'rotate(360deg)' }]
const SPIN_TIMING: KeyframeAnimationOptions = { duration: 1000, easing: 'linear' }
// Desktop's animate-pulse: the curve eases each half of the 2s breath.
const PULSE_CURVE = 'cubic-bezier(0.4, 0, 0.6, 1)'
const PULSE: Keyframe[] = [
{ opacity: 1, easing: PULSE_CURVE },
{ opacity: 0.5, easing: PULSE_CURVE },
{ opacity: 1 }
]
const PULSE_TIMING: KeyframeAnimationOptions = { duration: 2000 }
export function useWorkingRingRotation(active: boolean): WorkingMotion<never> {
return { ref: useElementLoop(active, SPIN, SPIN_TIMING), style: undefined }
}
export function useWorkingPulse(active: boolean): WorkingMotion<never> {
return { ref: useElementLoop(active, PULSE, PULSE_TIMING), style: undefined }
}
@@ -1,28 +0,0 @@
import { useEffect, useRef } from 'react'
import { Animated, Easing, Platform } from 'react-native'
export function useWorkingRingRotation(active: boolean): Animated.AnimatedInterpolation<string> {
const spinValue = useRef(new Animated.Value(0)).current
useEffect(() => {
if (active) {
const animation = Animated.loop(
Animated.timing(spinValue, {
toValue: 1,
duration: 1000,
easing: Easing.linear,
// Decorative loops must not hold up interaction-scheduled list rendering.
isInteraction: false,
// Web has no native driver; looping native-driver timing would play only once.
useNativeDriver: Platform.OS !== 'web'
})
)
animation.start()
return () => animation.stop()
}
spinValue.setValue(0)
return undefined
}, [active, spinValue])
return spinValue.interpolate({ inputRange: [0, 1], outputRange: ['0deg', '360deg'] })
}
@@ -2,7 +2,7 @@ import type { ReactNode } from 'react'
import { View, Text, Pressable } from 'react-native'
import { useSafeAreaInsets } from 'react-native-safe-area-context'
import { ChevronLeft, Copy, Check, Send } from 'lucide-react-native'
import { colors, spacing } from '../theme/mobile-theme'
import { colors, spacing, pressedStyle } from '../theme/mobile-theme'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { ConnectionLog } from '../components/ConnectionLog'
import { connectionDiagnosticsScreenStyles as styles } from './connection-diagnostics-screen-styles'
@@ -55,7 +55,7 @@ export function ConnectionDiagnosticsView({
<Pressable
accessibilityRole="button"
accessibilityLabel={t('common.back', 'Back')}
style={styles.backButton}
style={({ pressed }) => [styles.backButton, pressed && pressedStyle]}
onPress={onBack}
>
<ChevronLeft size={22} color={colors.textSecondary} />
@@ -80,7 +80,10 @@ export function ConnectionDiagnosticsView({
)
: stateLabels[state]}
</Text>
<Pressable style={styles.copyButton} onPress={() => void copyDiagnostics()}>
<Pressable
style={({ pressed }) => [styles.copyButton, pressed && pressedStyle]}
onPress={() => void copyDiagnostics()}
>
{copied ? (
<Check size={14} color={colors.statusGreen} />
) : (
@@ -109,7 +112,7 @@ export function ConnectionDiagnosticsView({
)}
</Text>
<Pressable
style={styles.sendButton}
style={({ pressed }) => [styles.sendButton, pressed && pressedStyle]}
onPress={() => void sendDiagnostics()}
disabled={submissionState === 'sending'}
>
+2 -2
View File
@@ -11,7 +11,7 @@ import {
XCircle,
AlertTriangle
} from 'lucide-react-native'
import { colors, spacing } from '../theme/mobile-theme'
import { colors, spacing, pressedStyle } from '../theme/mobile-theme'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { troubleshootCommonIssues } from './troubleshoot-common-issues'
import { troubleshootScreenStyles as styles } from './troubleshoot-screen-styles'
@@ -71,7 +71,7 @@ export function TroubleshootView({
<Pressable
accessibilityRole="button"
accessibilityLabel={t('common.back', 'Back')}
style={styles.backButton}
style={({ pressed }) => [styles.backButton, pressed && pressedStyle]}
onPress={onBack}
>
<ChevronLeft size={22} color={colors.textSecondary} />
@@ -1,6 +1,6 @@
import { useEffect, useState } from 'react'
import { ActivityIndicator, Image, Pressable, Text, View } from 'react-native'
import { colors, spacing, typography } from '../theme/mobile-theme'
import { colors, spacing, typography, pressedStyle } from '../theme/mobile-theme'
import { themedStyleSheet } from '../theme/themed-styles'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { MobileLoadErrorState } from '../components/MobileStateView'
@@ -70,6 +70,7 @@ export function MobileMarkdownPreviewImage({ client, worktreeId, documentPath, h
/>
) : load.uri ? (
<Pressable
style={({ pressed }) => pressed && pressedStyle}
onPress={() => setExpanded(true)}
accessibilityRole="button"
accessibilityLabel={
@@ -84,8 +84,9 @@ export const filePreviewStyles = themedStyleSheet(() => ({
flex: 1,
color: colors.textPrimary,
fontFamily: typography.monoFamily,
fontSize: 13,
lineHeight: 19,
// iOS zooms the page when a field under 16px takes focus; a literal, not the seam, avoids an extra shared chunk.
fontSize: 16,
lineHeight: 22,
padding: 0
}
}))
@@ -1,7 +1,7 @@
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import { CalendarClock, ChevronRight } from 'lucide-react-native'
import { Pressable, Text, View } from 'react-native'
import { colors } from '../theme/mobile-theme'
import { colors, pressedStyle } from '../theme/mobile-theme'
import { automationStyles as styles } from '../automations/automation-styles'
export function MobileHomeAutomationsCard({
@@ -18,7 +18,7 @@ export function MobileHomeAutomationsCard({
accessibilityLabel={t('automations.mobile.automations', 'Automations')}
disabled={!enabled}
onPress={onOpen}
style={[styles.card, !enabled && styles.disabled]}
style={({ pressed }) => [styles.card, !enabled && styles.disabled, pressed && pressedStyle]}
>
<View style={styles.row}>
<CalendarClock size={22} color={colors.textSecondary} />
@@ -16,7 +16,7 @@ import { NavBarButton } from '../components/nav-bar/NavBarButton'
import { PullDownMenu } from '../components/nav-bar/PullDownMenu'
import { StatusDot } from '../components/StatusDot'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import { colors } from '../theme/mobile-theme'
import { colors, pressedStyle } from '../theme/mobile-theme'
import { themedStyleSheet } from '../theme/themed-styles'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { useCalmConnectionState } from '../transport/calm-connection-state'
@@ -56,6 +56,7 @@ export function HostConnectionStatus({ controller }: { controller: HostScreenCon
{/* auth-failed has its own banner; the page cannot re-dial the connection the shell owns. */}
{isConnectionOutage(connectionVerdict) && hostId && forceReconnectHost !== null ? (
<Pressable
style={({ pressed }) => pressed && pressedStyle}
onPress={() => void forceReconnectHost(hostId)}
accessibilityRole="button"
accessibilityLabel={t('hostScreen.hostScreenHeader.reconnect', 'Reconnect')}
@@ -8,6 +8,14 @@ import {
import { afterEach, describe, expect, it, vi } from 'vitest'
// Banner and chevron motion run on Reanimated and Animated, which these mocks leave out.
vi.mock('../components/AutoHeight', () => ({
Presence: ({ children }: { children: unknown }) => children || null,
AutoHeight: ({ children }: { children: unknown }) => children
}))
vi.mock('../components/DisclosureChevron', () => ({
DisclosureChevron: ({ children }: { children: unknown }) => children
}))
vi.mock('react-native', () => ({
Platform: { OS: 'ios' },
Pressable: 'Pressable',
@@ -3,6 +3,14 @@ import { act, create as createRenderer, type ReactTestRenderer } from 'react-tes
import { afterEach, describe, expect, it, vi } from 'vitest'
// Banner and chevron motion run on Reanimated and Animated, which these mocks leave out.
vi.mock('../components/AutoHeight', () => ({
Presence: ({ children }: { children: unknown }) => children || null,
AutoHeight: ({ children }: { children: unknown }) => children
}))
vi.mock('../components/DisclosureChevron', () => ({
DisclosureChevron: ({ children }: { children: unknown }) => children
}))
vi.mock('react-native', () => ({
ActivityIndicator: 'ActivityIndicator',
Platform: { OS: 'ios' },
@@ -9,6 +9,14 @@ const { rowRenders, agentRenders } = vi.hoisted(() => ({
agentRenders: vi.fn()
}))
// Banner and chevron motion run on Reanimated and Animated, which these mocks leave out.
vi.mock('../components/AutoHeight', () => ({
Presence: ({ children }: { children: unknown }) => children || null,
AutoHeight: ({ children }: { children: unknown }) => children
}))
vi.mock('../components/DisclosureChevron', () => ({
DisclosureChevron: ({ children }: { children: unknown }) => children
}))
vi.mock('react-native', () => ({
Platform: { OS: 'ios' },
Pressable: 'Pressable',
+44 -34
View File
@@ -8,8 +8,10 @@ import {
Text,
View
} from 'react-native'
import { ChevronDown, ChevronRight, FolderTree, Pin } from 'lucide-react-native'
import { ChevronRight, FolderTree, Pin } from 'lucide-react-native'
import { AuthFailedBanner } from '../components/AuthFailedBanner'
import { Presence } from '../components/AutoHeight'
import { DisclosureChevron } from '../components/DisclosureChevron'
import { HostDiagnosticsLink } from '../components/HostDiagnosticsLink'
import { HostRouteNoticeBanner } from '../components/HostRouteNoticeBanner'
import { MobileRepoIcon } from '../components/MobileRepoIcon'
@@ -114,14 +116,17 @@ export function HostWorkspaceList({
return (
<>
{(connState === 'auth-failed' || relayRecovery.pairingRejected) && (
<AuthFailedBanner
canRetry={!!hostId && forceReconnectHost !== null}
onRetry={() => hostId && forceReconnectHost && void forceReconnectHost(hostId)}
onRepair={() => router.push('/pair-scan')}
onRemove={() => state.setConfirmRemoveHost(true)}
/>
)}
{/* Banners ease in and out; a dismissed one keeps its message while it leaves. */}
<Presence>
{(connState === 'auth-failed' || relayRecovery.pairingRejected) && (
<AuthFailedBanner
canRetry={!!hostId && forceReconnectHost !== null}
onRetry={() => hostId && forceReconnectHost && void forceReconnectHost(hostId)}
onRepair={() => router.push('/pair-scan')}
onRemove={() => state.setConfirmRemoveHost(true)}
/>
)}
</Presence>
{connState !== 'connected' &&
!relayRecovery.pairingRejected &&
@@ -134,27 +139,33 @@ export function HostWorkspaceList({
/>
) : null}
{routeNotice && (
<HostRouteNoticeBanner
message={routeNotice}
onDismiss={() => setDismissedNotice(noticeParam ?? null)}
/>
)}
{state.serverNotice ? (
<HostRouteNoticeBanner
message={state.serverNotice}
onDismiss={() => state.setServerNotice(null)}
/>
) : null}
<Presence>
{routeNotice && (
<HostRouteNoticeBanner
message={routeNotice}
onDismiss={() => setDismissedNotice(noticeParam ?? null)}
/>
)}
</Presence>
<Presence>
{state.serverNotice ? (
<HostRouteNoticeBanner
message={state.serverNotice}
onDismiss={() => state.setServerNotice(null)}
/>
) : null}
</Presence>
{/* Keep action errors above the list so the header and reopened confirm remain usable. */}
{state.actionError !== '' && (
<HostRouteNoticeBanner
message={state.actionError}
tone="failure"
onDismiss={() => state.setActionError('')}
/>
)}
<Presence>
{state.actionError !== '' && (
<HostRouteNoticeBanner
message={state.actionError}
tone="failure"
onDismiss={() => state.setActionError('')}
/>
)}
</Presence>
{hasRows ? null : pageTitle?.element}
@@ -208,7 +219,7 @@ export function HostWorkspaceList({
return (
<>
<Pressable
style={[
style={({ pressed }) => [
styles.sectionHeader,
section.projectGroupDepth
? {
@@ -216,16 +227,15 @@ export function HostWorkspaceList({
WORKTREE_ROW_LAYOUT.indicatorInset +
projectGroupHeaderIndent(section.projectGroupDepth)
}
: null
: null,
pressed && { backgroundColor: colors.translucentFill }
]}
onPress={() => settings.toggleCollapsed(collapseKey)}
>
<View style={styles.sectionChevron}>
{isCollapsed ? (
<DisclosureChevron expanded={!isCollapsed} collapsedDeg={0} expandedDeg={90}>
<ChevronRight size={12} color={colors.textMuted} />
) : (
<ChevronDown size={12} color={colors.textMuted} />
)}
</DisclosureChevron>
</View>
{section.icon === 'pin' && (
<Pin size={12} color={colors.textMuted} style={styles.sectionIcon} />
@@ -2,6 +2,7 @@ import { useCallback, useState, type ReactNode } from 'react'
import { StyleSheet, View } from 'react-native'
import Animated, {
Easing,
ReduceMotion,
runOnJS,
useAnimatedStyle,
useSharedValue,
@@ -14,19 +15,22 @@ import {
PUSH_UNDER_DIM,
PUSH_UNDER_SHIFT
} from '../navigation/push-motion'
import { useReducedMotionEnabled } from '../platform/use-reduced-motion'
import { useDrawerReducedMotion } from '../components/bottom-drawer-constants'
import { REDUCED_MOTION_FADE_MS } from '../components/sheet-motion-values'
import { colors } from '../theme/mobile-theme'
import { themedStyleSheet } from '../theme/themed-styles'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
// Built per call: a module-level easing would run before a test's Reanimated mock can serve it.
function slideTiming(duration: number) {
return { duration, easing: Easing.bezier(...PUSH_CURVE) }
function pageTiming(reducedMotion: boolean) {
// Under Reduce Motion the page cross-fades instead of sliding, and that fade must still run.
return reducedMotion
? { duration: REDUCED_MOTION_FADE_MS, reduceMotion: ReduceMotion.Never }
: { duration: PUSH_SLIDE_MS, easing: Easing.bezier(...PUSH_CURVE) }
}
export function useOptionPager<Key extends string>() {
const reduceMotion = useReducedMotionEnabled()
const duration = reduceMotion ? 0 : PUSH_SLIDE_MS
const reducedMotion = useDrawerReducedMotion()
const [page, setPage] = useState<Key | null>(null)
// 0 shows the page; 1 parks it one width to the right.
const slide = useSharedValue(1)
@@ -35,52 +39,54 @@ export function useOptionPager<Key extends string>() {
(key: Key) => {
slide.value = 1
setPage(key)
slide.value = withTiming(0, slideTiming(duration))
slide.value = withTiming(0, pageTiming(reducedMotion))
},
[duration, slide]
[reducedMotion, slide]
)
const close = useCallback(() => {
if (duration === 0) {
setPage(null)
return
}
slide.value = withTiming(1, slideTiming(duration), (finished) => {
slide.value = withTiming(1, pageTiming(reducedMotion), (finished) => {
if (finished) {
runOnJS(setPage)(null)
}
})
}, [duration, slide])
}, [reducedMotion, slide])
const forget = useCallback(() => setPage(null), [])
return { page, open, close, forget, slide }
return { page, open, close, forget, slide, reducedMotion }
}
export type OptionPagerControls<Key extends string> = ReturnType<typeof useOptionPager<Key>>
// Keep the main sheet laid out under its page so opening or closing it cannot change drawer height.
export function OptionPager(props: {
pager: { slide: SharedValue<number> }
pager: { slide: SharedValue<number>; reducedMotion: boolean }
main: ReactNode
page: ReactNode | null
}) {
useMobileColorScheme()
const [width, setWidth] = useState(0)
const [mainHeight, setMainHeight] = useState<number | null>(null)
const { slide } = props.pager
const { slide, reducedMotion } = props.pager
// Web has no worklet plugin; mapper hooks need this explicit dependency list.
const pageStyle = useAnimatedStyle(
() => ({ transform: [{ translateX: slide.value * width }] }),
[slide, width]
() =>
reducedMotion
? { opacity: 1 - slide.value, transform: [{ translateX: 0 }] }
: { opacity: 1, transform: [{ translateX: slide.value * width }] },
[slide, width, reducedMotion]
)
// The main list drifts left and dims under the page, like the screen under an iOS push.
const under = reducedMotion ? 0 : 1
const mainStyle = useAnimatedStyle(
() => ({ transform: [{ translateX: -(1 - slide.value) * PUSH_UNDER_SHIFT * width }] }),
[slide, width]
() => ({
transform: [{ translateX: -(1 - slide.value) * PUSH_UNDER_SHIFT * width * under }]
}),
[slide, width, under]
)
const dimStyle = useAnimatedStyle(
() => ({ opacity: (1 - slide.value) * PUSH_UNDER_DIM }),
[slide]
() => ({ opacity: (1 - slide.value) * PUSH_UNDER_DIM * under }),
[slide, under]
)
const pageOpen = props.page !== null
return (
@@ -24,6 +24,7 @@ vi.mock('../platform/use-reduced-motion', () => ({ useReducedMotionEnabled: () =
vi.mock('react-native-reanimated', () => ({
default: { View: 'AnimatedView' },
Easing: { bezier: () => (t: number) => t },
useReducedMotion: () => false,
runOnJS:
<Args extends unknown[]>(fn: (...args: Args) => void) =>
(...args: Args) =>
+23 -11
View File
@@ -1,23 +1,27 @@
import { REDUCED_MOTION_FADE_MS } from '../components/sheet-motion-values'
import { PUSH_EASING_CSS, PUSH_SLIDE_MS, PUSH_UNDER_DIM, PUSH_UNDER_SHIFT } from './push-motion'
// Bound suspended-screen waits so a route with no content can still arrive.
const CONTENT_WAIT_CAP_MS = 1000
const UNDER_SHIFT = `translateX(${-PUSH_UNDER_SHIFT * 100}%)`
/** Where an interrupted slide stopped, so the reverse starts there instead of jumping. */
/** Where an interrupted move stopped (a transform, or an opacity under Reduce Motion). */
const stoppedAt = new WeakMap<HTMLElement, string>()
/**
* Slides a pushed screen in over the one under it (or a popped one off it). Compositor animations,
* so an expensive screen mount cannot stall them. Returns the cancel for an interrupting move.
* Slides a pushed screen in over the one under it (or a popped one off it); under Reduce Motion it
* cross-fades in place instead. Compositor animations, so an expensive screen mount cannot stall
* them. Returns the cancel for an interrupting move.
*/
export function runStackMotion(args: {
kind: 'push' | 'pop'
moving: HTMLElement | null
under: HTMLElement | null
reducedMotion: boolean
onSettled: () => void
}): () => void {
const { kind, moving, under, onSettled } = args
const { kind, moving, reducedMotion, onSettled } = args
const under = reducedMotion ? null : args.under
if (moving === null) {
return () => {}
}
@@ -28,12 +32,19 @@ export function runStackMotion(args: {
fill: 'both'
}
const from = (node: HTMLElement, rest: string) => stoppedAt.get(node) ?? rest
const slide = moving.animate(
push
? [{ transform: from(moving, 'translateX(100%)') }, { transform: 'translateX(0)' }]
: [{ transform: from(moving, 'translateX(0)') }, { transform: 'translateX(100%)' }],
options
)
const slide = reducedMotion
? moving.animate(
push
? [{ opacity: from(moving, '0') }, { opacity: 1 }]
: [{ opacity: from(moving, '1') }, { opacity: 0 }],
{ duration: REDUCED_MOTION_FADE_MS, easing: 'ease-out', fill: 'both' }
)
: moving.animate(
push
? [{ transform: from(moving, 'translateX(100%)') }, { transform: 'translateX(0)' }]
: [{ transform: from(moving, 'translateX(0)') }, { transform: 'translateX(100%)' }],
options
)
slide.onfinish = onSettled
const dim = under === null ? null : appendDim(under)
const underSlide =
@@ -88,7 +99,8 @@ export function runStackMotion(args: {
}
// Only an interrupted move hands its position on; a finished one rests where it should.
if (slide.playState !== 'finished') {
stoppedAt.set(moving, getComputedStyle(moving).transform)
const style = getComputedStyle(moving)
stoppedAt.set(moving, reducedMotion ? style.opacity : style.transform)
if (under !== null) {
stoppedAt.set(under, getComputedStyle(under).transform)
}
+2 -1
View File
@@ -66,7 +66,7 @@ function HostStackView({ animation }: { animation: HostStackAnimation }) {
// Derive during render so a pop’s first frame still contains its outgoing screen.
if (shown.routes !== routes) {
const moved = shown.routes.at(-1)?.key !== routes.at(-1)?.key
const slides = moved && animation !== 'none' && !prefersReducedMotion()
const slides = moved && animation !== 'none'
setShown({
routes,
descriptors,
@@ -91,6 +91,7 @@ function HostStackView({ animation }: { animation: HostStackAnimation }) {
kind: transition.kind,
moving: nodes.current.get(push ? transition.enteringKey : transition.leaving.key) ?? null,
under: nodes.current.get((push ? transition.underKey : topKey) ?? '') ?? null,
reducedMotion: prefersReducedMotion(),
onSettled: settle
})
}, [transition, topKey, settle])
@@ -29,6 +29,7 @@ vi.mock('react-native', () => ({
multiply: (value: { current: number }, factor: number) => ({ value, factor }),
timing: mocks.animatedTiming
},
Easing: { bezier: () => 'push-easing' },
BackHandler: {
addEventListener: vi.fn(() => ({ remove: vi.fn() }))
},
+18
View File
@@ -22,6 +22,24 @@ const mocks = vi.hoisted(() => {
parse: vi.fn()
}
})
vi.mock('./pairing/pairing-visuals', async () => {
const { createElement } = await import('react')
return {
SCAN_DECODE_BEAT_MS: 0,
PAIRING_SUCCESS_HOLD_MS: 0,
waitForBeat: () => Promise.resolve(),
ScanReticle: () => null,
Step: ({ text }: { text: string }) => createElement('Text', null, text),
PairingProgress: ({
succeeded,
connectingLabel
}: {
succeeded: boolean
connectingLabel: string
}) => createElement('Text', null, succeeded ? 'Connected' : connectingLabel)
}
})
vi.mock('./platform/haptics', () => ({ triggerSuccess: () => {} }))
vi.mock('react-native', () => ({
View: 'View',
Text: 'Text',
+127
View File
@@ -0,0 +1,127 @@
import { useEffect } from 'react'
import { ActivityIndicator, Text, View, type StyleProp, type TextStyle } from 'react-native'
import Animated, {
Easing,
useAnimatedStyle,
useSharedValue,
withSpring,
withTiming
} from 'react-native-reanimated'
import { Check } from 'lucide-react-native'
import { SHEET_CURVE } from '../components/sheet-motion-values'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import { useReducedMotionEnabled } from '../platform/use-reduced-motion'
import { pairScanStyles as scanStyles } from '../pair-scan-styles'
import { colors, radii } from '../theme/mobile-theme'
import { themedStyleSheet } from '../theme/themed-styles'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
/** The reticle's squeeze on a decoded QR, before the screen turns to Connecting. */
export const SCAN_DECODE_BEAT_MS = 160
/** How long the check stays up before pairing moves on, so the success registers. */
export const PAIRING_SUCCESS_HOLD_MS = 450
const REDUCED_MOTION_MS = 150
const SHEET_EASING = Easing.bezier(...SHEET_CURVE)
export function waitForBeat(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms))
}
/** One numbered instruction above the scanner. */
export function Step({ number, text }: { number: number; text: string }) {
useMobileColorScheme()
return (
<View style={scanStyles.step}>
<View style={scanStyles.stepBadge}>
<Text style={scanStyles.stepNumber}>{number}</Text>
</View>
<Text style={scanStyles.stepText}>{text}</Text>
</View>
)
}
/** The QR guide's four corners; they squeeze in once a code decodes, or dim under Reduce Motion. */
export function ScanReticle({ size, decoded }: { size: number; decoded: boolean }) {
useMobileColorScheme()
const reducedMotion = useReducedMotionEnabled() === true
const progress = useSharedValue(0)
useEffect(() => {
progress.value = withTiming(decoded ? 1 : 0, {
duration: reducedMotion ? REDUCED_MOTION_MS : SCAN_DECODE_BEAT_MS,
easing: SHEET_EASING
})
}, [decoded, progress, reducedMotion])
const frameStyle = useAnimatedStyle(
() =>
reducedMotion
? { opacity: 1 - progress.value * 0.5 }
: { transform: [{ scale: 1 - progress.value * 0.06 }] },
[progress, reducedMotion]
)
return (
<View style={scanStyles.reticle} pointerEvents="none">
<Animated.View style={[scanStyles.reticleFrame, { width: size, height: size }, frameStyle]}>
<View style={[scanStyles.corner, scanStyles.cornerTL]} />
<View style={[scanStyles.corner, scanStyles.cornerTR]} />
<View style={[scanStyles.corner, scanStyles.cornerBL]} />
<View style={[scanStyles.corner, scanStyles.cornerBR]} />
</Animated.View>
</View>
)
}
/** The spinner and its label while pairing connects; both turn to Connected, with a check, once the desktop accepts. */
export function PairingProgress({
succeeded,
connectingLabel,
labelStyle
}: {
succeeded: boolean
connectingLabel: string
labelStyle: StyleProp<TextStyle>
}) {
useMobileColorScheme()
const t = useMobileTranslation()
const reducedMotion = useReducedMotionEnabled() === true
const shown = useSharedValue(0)
useEffect(() => {
if (!succeeded) {
return
}
shown.value = reducedMotion
? withTiming(1, { duration: REDUCED_MOTION_MS })
: withSpring(1, { duration: 400, dampingRatio: 0.8 })
}, [reducedMotion, shown, succeeded])
const checkStyle = useAnimatedStyle(
() => ({
opacity: shown.value,
transform: [{ scale: reducedMotion ? 1 : 0.5 + shown.value * 0.5 }]
}),
[reducedMotion, shown]
)
return (
<>
{succeeded ? (
<Animated.View style={[styles.check, checkStyle]}>
<Check size={22} color={colors.bgBase} strokeWidth={3} />
</Animated.View>
) : (
<ActivityIndicator size="large" color={colors.textSecondary} />
)}
<Text style={labelStyle}>
{succeeded ? t('connection.connectionHealth.connected', 'Connected') : connectingLabel}
</Text>
</>
)
}
const styles = themedStyleSheet(() => ({
check: {
width: 36,
height: 36,
borderRadius: radii.pill,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: colors.statusGreen
}
}))
+21 -7
View File
@@ -5,7 +5,7 @@ import {
MobileRichMarkdownEditor,
type MobileRichMarkdownEditorHandle
} from '../components/MobileRichMarkdownEditor'
import { colors, spacing } from '../theme/mobile-theme'
import { colors, spacing, pressedStyle } from '../theme/mobile-theme'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import {
resolveMarkdownFloatingActionsBottom,
@@ -108,7 +108,11 @@ export function MobileMarkdownReader({
<View style={styles.markdownFloatingActions}>
{keyboardOpen ? (
<Pressable
style={[styles.markdownFloatingButton, styles.markdownKeyboardDismissButton]}
style={({ pressed }) => [
styles.markdownFloatingButton,
styles.markdownKeyboardDismissButton,
pressed && pressedStyle
]}
onPress={() => editorRef.current?.dismissKeyboard()}
hitSlop={8}
accessibilityRole="button"
@@ -130,12 +134,18 @@ export function MobileMarkdownReader({
</Pressable>
) : null}
{showCopy ? (
<Pressable style={styles.markdownFloatingButton} onPress={onCopy}>
<Pressable
style={({ pressed }) => [styles.markdownFloatingButton, pressed && pressedStyle]}
onPress={onCopy}
>
<Text style={styles.markdownFloatingButtonText}>{t('common.copy', 'Copy')}</Text>
</Pressable>
) : null}
{showRefresh ? (
<Pressable style={styles.markdownFloatingButton} onPress={onRefresh}>
<Pressable
style={({ pressed }) => [styles.markdownFloatingButton, pressed && pressedStyle]}
onPress={onRefresh}
>
<RefreshCw size={13} color={colors.textPrimary} />
<Text style={styles.markdownFloatingButtonText}>
{t('common.refresh', 'Refresh')}
@@ -143,7 +153,10 @@ export function MobileMarkdownReader({
</Pressable>
) : null}
{doc.isDirty ? (
<Pressable style={styles.markdownFloatingButton} onPress={onDiscard}>
<Pressable
style={({ pressed }) => [styles.markdownFloatingButton, pressed && pressedStyle]}
onPress={onDiscard}
>
<Text style={styles.markdownFloatingButtonText}>
{t('session.markdownReader.discard', 'Discard')}
</Text>
@@ -151,10 +164,11 @@ export function MobileMarkdownReader({
) : null}
{showSave ? (
<Pressable
style={[
style={({ pressed }) => [
styles.markdownFloatingButton,
styles.markdownSaveButton,
(!doc.editable || !doc.isDirty || doc.saving) && styles.markdownButtonDisabled
(!doc.editable || !doc.isDirty || doc.saving) && styles.markdownButtonDisabled,
pressed && pressedStyle
]}
disabled={!doc.editable || !doc.isDirty || doc.saving}
onPress={onSave}
@@ -1,6 +1,6 @@
import { Keyboard, Pressable, StyleSheet } from 'react-native'
import { ChevronDown, X } from 'lucide-react-native'
import { colors } from '../theme/mobile-theme'
import { colors, pressedStyle } from '../theme/mobile-theme'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
@@ -30,7 +30,7 @@ export function MobileNativeChatCardHeaderAction<Prompt>({
}
accessibilityState={onCancel ? undefined : { expanded: true }}
hitSlop={8}
style={styles.action}
style={({ pressed }) => [styles.action, pressed && pressedStyle]}
onPress={() => {
if (onCancel) {
void onCancel(prompt)
@@ -14,7 +14,7 @@ import { nativeChatToolRowVerbCopy } from './native-chat/transcript/native-chat-
import { nativeChatDiffCardCopy } from './native-chat-diff-card-copy'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import { MobileSourceCopyButton } from '../components/MobileSourceCopyButton'
import { colors } from '../theme/mobile-theme'
import { colors, pressedStyle } from '../theme/mobile-theme'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { useMobileNativeChatOpenedDetail } from './native-chat/visual/mobile-native-chat-opened-detail'
import { useMobileNativeChatDisclosure } from './native-chat/transcript/mobile-native-chat-disclosure-store'
@@ -155,7 +155,7 @@ export function MobileNativeChatDiffCard({
<View>
<View style={styles.cardHeader}>
<Pressable
style={[styles.line, styles.cardToggle]}
style={({ pressed }) => [styles.line, styles.cardToggle, pressed && pressedStyle]}
onPress={() => hasBody && setExpanded(!expanded)}
disabled={!hasBody}
accessibilityRole="button"
@@ -1,10 +1,15 @@
import { Pressable, View } from 'react-native'
import { useEffect, useRef } from 'react'
import { Animated, Easing, Platform, Pressable, View } from 'react-native'
import { ArrowDown } from 'lucide-react-native'
import { colors } from '../theme/mobile-theme'
import { SHEET_CURVE } from '../components/sheet-motion-values'
import { useReducedMotionEnabled } from '../platform/use-reduced-motion'
import { colors, feedback } from '../theme/mobile-theme'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { styles } from './mobile-native-chat-view-styles'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
const JUMP_EASING = Easing.bezier(...SHEET_CURVE)
export function MobileNativeChatFloatingControls({
showJumpToTail,
onJumpToTail
@@ -14,20 +19,42 @@ export function MobileNativeChatFloatingControls({
}): React.JSX.Element {
useMobileColorScheme()
const t = useMobileTranslation()
const reducedMotion = useReducedMotionEnabled() === true
const shown = useRef(new Animated.Value(showJumpToTail ? 1 : 0)).current
// Stays mounted so a scroll that flips it mid-fade turns the fade around instead of popping.
useEffect(() => {
const animation = Animated.timing(shown, {
toValue: showJumpToTail ? 1 : 0,
duration: showJumpToTail ? 160 : 120,
easing: JUMP_EASING,
useNativeDriver: Platform.OS !== 'web'
})
animation.start()
return () => animation.stop()
}, [showJumpToTail, shown])
const scale = reducedMotion ? 1 : shown.interpolate({ inputRange: [0, 1], outputRange: [0.9, 1] })
return (
<View pointerEvents="box-none" style={styles.floatingControls}>
{showJumpToTail ? (
<Animated.View
pointerEvents={showJumpToTail ? 'box-none' : 'none'}
accessibilityElementsHidden={!showJumpToTail}
importantForAccessibility={showJumpToTail ? 'auto' : 'no-hide-descendants'}
style={{ opacity: shown, transform: [{ scale }] }}
>
<Pressable
accessibilityLabel={t(
'session.nativeChatFloatingControls.scrollToLatest',
'Scroll to latest'
)}
style={styles.fab}
accessibilityLabel={
showJumpToTail
? t('session.nativeChatFloatingControls.scrollToLatest', 'Scroll to latest')
: undefined
}
disabled={!showJumpToTail}
focusable={showJumpToTail}
style={({ pressed }) => [styles.fab, pressed && { opacity: feedback.pressedOpacity }]}
onPress={onJumpToTail}
>
<ArrowDown size={18} color={colors.textPrimary} strokeWidth={2.2} />
</Pressable>
) : null}
</Animated.View>
</View>
)
}
@@ -21,6 +21,7 @@ import {
MobileNativeChatItemSourceContext,
readMobileNativeChatItem
} from './mobile-native-chat-item-read'
import { pressedStyle } from '../theme/mobile-theme'
// Keep full-content state per row so live transcript revisions cannot overwrite the reader’s requested expansion.
@@ -40,7 +41,7 @@ function ShowFull({
useMobileColorScheme()
return (
<Pressable
style={styles.showFull}
style={({ pressed }) => [styles.showFull, pressed && pressedStyle]}
onPress={onPress}
disabled={load === 'loading'}
hitSlop={8}
@@ -11,6 +11,7 @@ import { setMobileNativeChatDraftText } from './native-chat/composer/mobile-nati
vi.mock('react-native', async () => {
const React = await import('react')
return {
...(await import('../test-support/react-native-motion-stub')).reactNativeMotionStub(),
ActivityIndicator: 'ActivityIndicator',
Image: 'Image',
Platform: { OS: 'ios' },
@@ -18,15 +18,10 @@ const pageScroller = vi.hoisted(() => ({
export async function reactNativeStub() {
const React = await import('react')
const { reactNativeMotionStub } = await import('../test-support/react-native-motion-stub')
return {
...reactNativeMotionStub(),
ActivityIndicator: 'ActivityIndicator',
Animated: {
Value: class {
constructor(readonly value: number) {}
},
timing: () => ({ start: () => {}, stop: () => {} }),
View: 'Animated.View'
},
FlatList: React.forwardRef((props, ref) => {
const handle = { scrollToEnd, scrollToOffset, getScrollableNode: () => pageScroller }
React.useImperativeHandle(ref, () => handle, [])
@@ -22,6 +22,7 @@ import { MobileNativeChatView } from './MobileNativeChatView'
import { MobileNativeChatRowContent } from './native-chat/transcript/MobileNativeChatRowItemSource'
vi.mock('react-native', async () => ({
...(await import('../test-support/react-native-motion-stub')).reactNativeMotionStub(),
ActivityIndicator: 'ActivityIndicator',
ScrollView: 'ScrollView',
Platform: { OS: 'web' },
@@ -11,6 +11,7 @@ const scrollToOffset = vi.hoisted(() => vi.fn())
vi.mock('react-native', async () => {
const React = await import('react')
return {
...(await import('../test-support/react-native-motion-stub')).reactNativeMotionStub(),
ActivityIndicator: 'ActivityIndicator',
FlatList: React.forwardRef<
unknown,
@@ -9,6 +9,7 @@ import { MobileNativeChatView } from './MobileNativeChatView'
vi.mock('react-native', async () => {
const React = await import('react')
return {
...(await import('../test-support/react-native-motion-stub')).reactNativeMotionStub(),
ActivityIndicator: 'ActivityIndicator',
FlatList: React.forwardRef((props, ref) => {
React.useImperativeHandle(ref, () => ({ scrollToEnd: vi.fn(), scrollToOffset: vi.fn() }), [])
+2 -1
View File
@@ -1,6 +1,6 @@
import { useState } from 'react'
import { Pressable, Text, View } from 'react-native'
import { colors, typography } from '../theme/mobile-theme'
import { colors, typography, pressedStyle } from '../theme/mobile-theme'
import { themedStyleSheet } from '../theme/themed-styles'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { queuedMessageStyles } from './native-chat/input/mobile-native-chat-queued-message-styles'
@@ -42,6 +42,7 @@ export function MobileQueuedCardText({
}
const toggle = (
<Pressable
style={({ pressed }) => pressed && pressedStyle}
testID="queued-card-text"
accessibilityRole="button"
accessibilityState={{ expanded }}
@@ -10,7 +10,7 @@ import {
Send,
Trash2
} from 'lucide-react-native'
import { colors } from '../theme/mobile-theme'
import { colors, pressedStyle } from '../theme/mobile-theme'
import { queuedMessageCardSteers } from '../../../src/shared/structured-agent-session-queued-cards'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import type { MobileQueuedMessageCard } from './mobile-structured-queued-message-cards'
@@ -189,6 +189,7 @@ function QueuedMessageCardContents({
<View style={styles.expandedBody}>
{expanded ? (
<Pressable
style={({ pressed }) => pressed && pressedStyle}
accessibilityRole="button"
accessibilityState={{ expanded: true }}
accessibilityHint={t(
@@ -2,7 +2,7 @@ import { View, Text, Pressable } from 'react-native'
import { AlertTriangle, X } from 'lucide-react-native'
import { SessionDockColumn } from './SessionDockColumn'
import { dismissMobileSessionCreateWarningState } from './mobile-session-create-warning-state'
import { colors } from '../theme/mobile-theme'
import { colors, pressedStyle } from '../theme/mobile-theme'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import { styles } from './mobile-session-styles'
@@ -37,7 +37,7 @@ export function MobileSessionContentRow({ controller }: { controller: MobileSess
<AlertTriangle size={16} color={colors.statusAmber} strokeWidth={2.2} />
<Text style={styles.createWarningText}>{createWarning}</Text>
<Pressable
style={styles.createWarningDismiss}
style={({ pressed }) => [styles.createWarningDismiss, pressed && pressedStyle]}
onPress={() => setCreateWarningState(dismissMobileSessionCreateWarningState)}
accessibilityLabel={t(
'session.contentRow.dismissCreationWarning',
@@ -3,7 +3,7 @@ import { MessageSquare, Plus, X } from 'lucide-react-native'
import { MobileSyntaxSegments } from '../components/MobileSyntaxSegments'
import { MessageBox } from '../components/composer-input/MessageBox'
import { composerInputStyles } from '../components/composer-input/composer-input-styles'
import { colors } from '../theme/mobile-theme'
import { colors, pressedStyle } from '../theme/mobile-theme'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import { styles } from './mobile-session-styles'
@@ -110,7 +110,7 @@ export function DiffLineRow({
})}
</Text>
<Pressable
style={styles.diffCommentDeleteButton}
style={({ pressed }) => [styles.diffCommentDeleteButton, pressed && pressedStyle]}
disabled={commentsBusy}
onPress={() => onDeleteComment(comment.id)}
accessibilityLabel={t(
@@ -21,7 +21,7 @@ import {
import { MobileHtmlPreview } from '../components/MobileHtmlPreview'
import { MobilePanZoomImage } from '../components/MobilePanZoomImage'
import { MobileSvgPreview } from '../components/MobileSvgPreview'
import { colors } from '../theme/mobile-theme'
import { colors, pressedStyle } from '../theme/mobile-theme'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import { styles } from './mobile-session-styles'
@@ -223,9 +223,10 @@ function FileReaderDocument({
</View>
<View style={styles.diffNotesActions}>
<Pressable
style={[
style={({ pressed }) => [
styles.diffNotesActionButton,
!canCopyNotes && styles.diffCommentButtonDisabled
!canCopyNotes && styles.diffCommentButtonDisabled,
pressed && pressedStyle
]}
disabled={!canCopyNotes}
onPress={() => void diffCommentActions.onCopyAll()}
@@ -235,9 +236,10 @@ function FileReaderDocument({
<Text style={styles.diffNotesActionText}>{t('common.copy', 'Copy')}</Text>
</Pressable>
<Pressable
style={[
style={({ pressed }) => [
styles.diffNotesActionButton,
!canSendNotes && styles.diffCommentButtonDisabled
!canSendNotes && styles.diffCommentButtonDisabled,
pressed && pressedStyle
]}
disabled={!canSendNotes}
onPress={diffCommentActions.onSendAll}
@@ -4,7 +4,7 @@ import { RefreshCw } from 'lucide-react-native'
import { MobileRichMarkdownEditor } from '../components/MobileRichMarkdownEditor'
import { resolveMarkdownFloatingActionsBottom } from './markdown-floating-actions-layout'
import { markdownReaderStatusText } from './mobile-markdown-reader-status'
import { colors, spacing } from '../theme/mobile-theme'
import { colors, spacing, pressedStyle } from '../theme/mobile-theme'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import { styles } from './mobile-session-styles'
@@ -83,7 +83,11 @@ export function MarkdownReader({
) : null}
<View style={styles.markdownFloatingActions}>
<Pressable
style={[styles.markdownFloatingButton, styles.markdownCopyButton]}
style={({ pressed }) => [
styles.markdownFloatingButton,
styles.markdownCopyButton,
pressed && pressedStyle
]}
onPress={onCopy}
accessibilityRole="button"
accessibilityLabel={
@@ -99,7 +103,11 @@ export function MarkdownReader({
</Text>
</Pressable>
<Pressable
style={[styles.markdownFloatingButton, styles.markdownCopyButton]}
style={({ pressed }) => [
styles.markdownFloatingButton,
styles.markdownCopyButton,
pressed && pressedStyle
]}
onPress={onCopyPath}
accessibilityRole="button"
accessibilityLabel={t('session.markdownReader.copyPathLabel', 'Copy Markdown path')}
@@ -109,7 +117,10 @@ export function MarkdownReader({
</Text>
</Pressable>
{showRefresh ? (
<Pressable style={styles.markdownFloatingButton} onPress={onRefresh}>
<Pressable
style={({ pressed }) => [styles.markdownFloatingButton, pressed && pressedStyle]}
onPress={onRefresh}
>
<RefreshCw size={13} color={colors.textPrimary} />
<Text style={styles.markdownFloatingButtonText}>
{t('common.refresh', 'Refresh')}
@@ -117,7 +128,10 @@ export function MarkdownReader({
</Pressable>
) : null}
{doc.isDirty ? (
<Pressable style={styles.markdownFloatingButton} onPress={onDiscard}>
<Pressable
style={({ pressed }) => [styles.markdownFloatingButton, pressed && pressedStyle]}
onPress={onDiscard}
>
<Text style={styles.markdownFloatingButtonText}>
{t('session.markdownReader.discard', 'Discard')}
</Text>
@@ -125,10 +139,11 @@ export function MarkdownReader({
) : null}
{showSave ? (
<Pressable
style={[
style={({ pressed }) => [
styles.markdownFloatingButton,
styles.markdownSaveButton,
(!doc.editable || !doc.isDirty || doc.saving) && styles.markdownButtonDisabled
(!doc.editable || !doc.isDirty || doc.saving) && styles.markdownButtonDisabled,
pressed && pressedStyle
]}
disabled={!doc.editable || !doc.isDirty || doc.saving}
onPress={onSave}
+2 -1
View File
@@ -347,7 +347,8 @@ export function MobileSessionSheets({ controller }: { controller: MobileSessionC
submitLabel={t('common.open', 'Open')}
allowEmpty
selectTextOnFocus
keyboardType={Platform.OS === 'ios' ? 'url' : 'default'}
// The session page reports 'web', where RN Web maps 'url' to the URL keyboard.
keyboardType={Platform.OS === 'android' ? 'default' : 'url'}
onSubmit={(value) => {
void handleCreateBrowser(value).then((created) => {
if (created) {
@@ -6,6 +6,7 @@ import { StatusDot } from '../components/StatusDot'
import type { ConnectionState } from '../transport/types'
import { styles } from './mobile-session-styles'
import { useMobileTranslation } from '../i18n/use-mobile-translation'
import { pressedStyle } from '../theme/mobile-theme'
/** The session's title and status line. A tap opens a card with the full name, where it lives
* and its host, as desktop's tab card does, because a sideways phone cuts the title short. */
@@ -33,11 +34,15 @@ export function MobileSessionTitleBlock({
<DetailCardFocusBoundary refs={details.boundaryRefs} index={0} active={details.titleActive} />
<Fragment key="title">
<Pressable
style={
style={({ pressed }) => [
centered
? centeredStyles.block
: [styles.sessionTitleBlock, details.besideTabs && styles.sessionTitleBlockBesideTabs]
}
: [
styles.sessionTitleBlock,
details.besideTabs && styles.sessionTitleBlockBesideTabs
],
pressed && pressedStyle
]}
ref={details.openerRef}
onLayout={details.onAnchorLayout}
onPress={details.toggle}
@@ -58,7 +63,7 @@ export function MobileSessionTitleBlock({
{title}
</Text>
<Pressable
style={styles.sessionMetaRow}
style={({ pressed }) => [styles.sessionMetaRow, pressed && pressedStyle]}
disabled={!showConnectionRetry}
onPress={onRetry}
accessibilityRole={showConnectionRetry ? 'button' : undefined}

Some files were not shown because too many files have changed in this diff Show More