mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
* feat(mobile): polish press feedback, sheet motion, states, spacing and layout jumps Every control presses and disables the same way, with one haptic rule. Sheets follow the finger and settle without bounce, pickers stack instead of swapping, and screens slide over a dimmed, shifted parent. Loading, empty, error and offline states share one view with plain-language errors, rows and labels line up on one grid, and screens stop jumping as data arrives. * fix(mobile): settle voice, tasks and accounts states; keep host snapshot current Voice settings with no paired desktop shows the connect state instead of loading forever. A failed task settings read after a successful probe retries hydration. The shared host-list snapshot drops on invalidation and ignores stale passes. Accounts shows a re-pair state on auth failure, and busy action-sheet rows keep their disabled state for screen readers.
159 lines
7.0 KiB
TypeScript
159 lines
7.0 KiB
TypeScript
import { useCallback, useEffect, useState } from 'react'
|
|
import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
import { Text, View, type LayoutChangeEvent } from 'react-native'
|
|
import type { useMobileDiffReviewController } from '../session/use-mobile-diff-review-controller'
|
|
import { useResponsiveLayout } from '../layout/responsive-layout'
|
|
import { MobileDiffReviewBody } from './MobileDiffReviewBody'
|
|
import { MobileDiffReviewDrawers } from './MobileDiffReviewDrawers'
|
|
import { MobileDiffReviewFileSummary } from './MobileDiffReviewFileSummary'
|
|
import { MobileDiffReviewFooter } from './MobileDiffReviewFooter'
|
|
import { MobileDiffReviewHeader } from './MobileDiffReviewHeader'
|
|
import { useMobileDiffReviewOverflowActions } from './use-mobile-diff-review-overflow-actions'
|
|
import { MobilePRSidebar } from './MobilePRSidebar'
|
|
import { RightDrawer } from './RightDrawer'
|
|
import { mobilePrSidebarStyles, PR_SIDEBAR_DOCK_WIDTH } from './pr-sidebar/mobile-pr-sidebar-styles'
|
|
import { canDockPrSidebar, resolvePresentationMode } from './mobile-pr-sidebar-presentation'
|
|
import { mobileDiffReviewStyles as styles } from './mobile-diff-review-screen-styles'
|
|
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
|
|
|
|
type Props = {
|
|
controller: ReturnType<typeof useMobileDiffReviewController>
|
|
onBack: () => void
|
|
}
|
|
|
|
export function MobileDiffReviewScreenView({ controller, onBack }: Props) {
|
|
useMobileColorScheme()
|
|
const { isWideLayout } = useResponsiveLayout()
|
|
const insets = useSafeAreaInsets()
|
|
const [contentRowWidth, setContentRowWidth] = useState(0)
|
|
const overflowActions = useMobileDiffReviewOverflowActions(controller)
|
|
const canDockSidebar = canDockPrSidebar({
|
|
isWideLayout,
|
|
availableWidth: contentRowWidth,
|
|
dockWidth: PR_SIDEBAR_DOCK_WIDTH
|
|
})
|
|
const presentationMode = resolvePresentationMode(isWideLayout, canDockSidebar)
|
|
// Dock GitHub sidebar only when wide; otherwise showPRSidebar toggles RightDrawer overlay.
|
|
const showInlineDock = presentationMode === 'inline' && controller.prSidebarIsGithubRepo
|
|
const gitStatus = controller.screenState.kind === 'ready' ? controller.screenState.status : null
|
|
|
|
// Load docked PR data on visibility; overlay loads on trigger press.
|
|
const prSidebarKind = controller.prSidebarState.kind
|
|
const loadPRSidebar = controller.refetchPRSidebar
|
|
useEffect(() => {
|
|
if (showInlineDock && prSidebarKind === 'hidden') {
|
|
loadPRSidebar()
|
|
}
|
|
}, [showInlineDock, prSidebarKind, loadPRSidebar])
|
|
|
|
const handleContentRowLayout = useCallback((event: LayoutChangeEvent) => {
|
|
const width = Math.round(event.nativeEvent.layout.width)
|
|
setContentRowWidth((prev) => (prev === width ? prev : width))
|
|
}, [])
|
|
|
|
return (
|
|
<SafeAreaView style={styles.safeArea} edges={['top']}>
|
|
<MobileDiffReviewHeader
|
|
actions={overflowActions}
|
|
filter={controller.filter}
|
|
isWideLayout={isWideLayout}
|
|
prSidebarIsGithubRepo={controller.prSidebarIsGithubRepo}
|
|
prSidebarCanDock={presentationMode === 'inline'}
|
|
queueLength={controller.queue.length}
|
|
reviewedCount={controller.reviewedCount}
|
|
unsentCount={controller.unsentComments.length}
|
|
onBack={onBack}
|
|
onOpenPRSidebar={controller.openPRSidebar}
|
|
onSelectFilter={controller.selectFilter}
|
|
/>
|
|
<View style={{ flex: 1, flexDirection: 'row' }} onLayout={handleContentRowLayout}>
|
|
{/* Keep diff layout full; wide sidebar and diff scroll independently. */}
|
|
<View style={{ flex: 1, minWidth: 0 }}>
|
|
{controller.currentItem ? (
|
|
<MobileDiffReviewFileSummary
|
|
currentIndex={controller.currentIndex}
|
|
diffState={controller.diffState}
|
|
fileNotes={controller.fileNotes}
|
|
filteredCount={controller.filteredQueue.length}
|
|
item={controller.currentItem}
|
|
staleCommentIds={controller.staleCommentIds}
|
|
onEditNote={controller.openEditComposer}
|
|
onJumpHunk={controller.jumpHunk}
|
|
/>
|
|
) : null}
|
|
{controller.actionError ? (
|
|
<View style={styles.actionError}>
|
|
<Text style={styles.actionErrorText}>{controller.actionError}</Text>
|
|
</View>
|
|
) : null}
|
|
<MobileDiffReviewBody
|
|
activeHunkIndex={controller.activeHunkIndex}
|
|
commentsByLine={controller.commentsByLine}
|
|
currentItem={controller.currentItem}
|
|
diffState={controller.diffState}
|
|
filteredCount={controller.filteredQueue.length}
|
|
listRef={controller.listRef}
|
|
screenState={controller.screenState}
|
|
staleCommentIds={controller.staleCommentIds}
|
|
onAddNote={controller.openComposer}
|
|
onEditNote={controller.openEditComposer}
|
|
onRetry={controller.retryAction ?? undefined}
|
|
offline={controller.connState !== 'connected'}
|
|
onShowAll={
|
|
controller.filter === 'all' ? undefined : () => controller.selectFilter('all')
|
|
}
|
|
/>
|
|
{controller.currentItem ? (
|
|
<MobileDiffReviewFooter
|
|
busyAction={controller.busyAction}
|
|
item={controller.currentItem}
|
|
onAddFileNote={() => controller.openComposer(0)}
|
|
onDiscard={(target) => controller.openSheet({ kind: 'discard', target })}
|
|
onGitMutation={(method, item) => void controller.runGitMutation(method, item)}
|
|
onMarkReviewed={() => void controller.markReviewed()}
|
|
onMoveFile={controller.moveFile}
|
|
/>
|
|
) : null}
|
|
</View>
|
|
{showInlineDock ? (
|
|
<View style={mobilePrSidebarStyles.dockColumn}>
|
|
<MobilePRSidebar
|
|
state={controller.prSidebarState}
|
|
onRetry={controller.retryPRSidebar}
|
|
refetch={controller.refetchPRSidebar}
|
|
client={controller.client}
|
|
connState={controller.connState}
|
|
worktreeId={controller.worktreeId}
|
|
gitBranch={controller.prSidebarBranch}
|
|
gitStatus={gitStatus}
|
|
headSha={controller.prSidebarHeadSha}
|
|
bottomInset={insets.bottom}
|
|
workspaceLabel={controller.worktreeLabel}
|
|
/>
|
|
</View>
|
|
) : null}
|
|
</View>
|
|
<MobileDiffReviewDrawers controller={controller} />
|
|
{presentationMode === 'overlay' ? (
|
|
<RightDrawer
|
|
visible={controller.showPRSidebar}
|
|
onClose={() => controller.setShowPRSidebar(false)}
|
|
>
|
|
<MobilePRSidebar
|
|
state={controller.prSidebarState}
|
|
onRetry={controller.retryPRSidebar}
|
|
refetch={controller.refetchPRSidebar}
|
|
client={controller.client}
|
|
connState={controller.connState}
|
|
worktreeId={controller.worktreeId}
|
|
gitBranch={controller.prSidebarBranch}
|
|
gitStatus={gitStatus}
|
|
headSha={controller.prSidebarHeadSha}
|
|
workspaceLabel={controller.worktreeLabel}
|
|
/>
|
|
</RightDrawer>
|
|
) : null}
|
|
</SafeAreaView>
|
|
)
|
|
}
|