mirror of
https://github.com/stablyai/orca.git
synced 2026-11-15 18:37:24 +00:00
* feat(mobile): create a worktree per repository from an empty folder workspace A folder workspace with no attached worktrees lists one card per repository in its project group, as desktop's empty state does. Tapping one creates a worktree named after the folder, attached to it, in place; a taken name or a setup choice opens the new-workspace composer with the repo, the name and the folder parent filled in. Shown only when the host creating it supports exact-name creation. * chore(mobile): merge the folder repo read's execution-host imports * fix(mobile): folder creates keep their repository until the folder shows them Every create from a folder's empty state, direct or through the composer, holds its repository from admission until the folder lists the new worktree, so a lost reply, a remount or a reopened form can't start a second one. The composer and toasts belong to the folder screen, stay on the folder's host, and say nothing once it's left. A relayed server's repository read holds no desktop event stream, and a failed read can be retried. * test(mobile): a folder create resent after a lost reply carries the same mutation id * fix(mobile): folder creates keep their name, and a left or replaced form shows and holds nothing * fix(mobile): pause folder rows under the create form; a lost folder create is checked, never resent as another * fix(mobile): a folder card never resends a form's create, and one form owns the folder screen at a time * fix(mobile): a folder setup choice resends only its own unconfirmed create, and the newest form silences older ones * test(mobile): declare the submit hook's folder launch in its recording fixture * fix(mobile): a create refused on a resend after a lost reply tries no other name and stays unconfirmed * fix(mobile): a replayed refusal after an agent-launch fallback stops the retry, and the composer says it may have been created * test(mobile): type the replayed refusal reply in the retry test * ci: retrigger checks * fix(mobile): localize the folder and uncertain-create messages in the workspace composer
250 lines
6.8 KiB
TypeScript
250 lines
6.8 KiB
TypeScript
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, 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'
|
|
|
|
export type MobileStateAction = { label: string; onPress: () => void }
|
|
|
|
type MobileStateViewProps = {
|
|
/** Omitted while loading, which shows a spinner instead. */
|
|
icon?: LucideIcon
|
|
/** A non-Lucide mark, such as a provider logo, drawn where the icon goes. */
|
|
iconElement?: ReactNode
|
|
title: string
|
|
message?: string | null
|
|
/** Raw text a person can open for support, never shown by default. */
|
|
details?: string | null
|
|
action?: MobileStateAction | null
|
|
loading?: boolean
|
|
/** Keeps the content centred above a floating bottom bar. */
|
|
bottomInset?: number
|
|
/** Full-width content under the message, such as a list of choices. */
|
|
children?: ReactNode
|
|
}
|
|
|
|
/** Every screen's loading, empty, no-match, error and offline state: icon, title, one sentence, one action. */
|
|
export function MobileStateView({
|
|
icon: Icon,
|
|
iconElement,
|
|
title,
|
|
message,
|
|
details,
|
|
action,
|
|
loading = false,
|
|
bottomInset = 0,
|
|
children
|
|
}: MobileStateViewProps) {
|
|
useMobileColorScheme()
|
|
return (
|
|
<View style={[styles.state, { paddingBottom: spacing.xl + bottomInset }]}>
|
|
{loading ? (
|
|
<ActivityIndicator size="small" color={colors.textSecondary} />
|
|
) : Icon ? (
|
|
<Icon size={24} color={colors.textMuted} strokeWidth={1.75} />
|
|
) : (
|
|
iconElement
|
|
)}
|
|
<Text style={loading ? styles.message : styles.title}>{title}</Text>
|
|
{message ? <Text style={styles.message}>{message}</Text> : null}
|
|
{details ? <MobileStateDetails details={details} /> : null}
|
|
{action ? <MobileStateButton label={action.label} onPress={action.onPress} /> : null}
|
|
{children ? <View style={styles.children}>{children}</View> : null}
|
|
</View>
|
|
)
|
|
}
|
|
|
|
/** The one action a centred state offers, such as Retry. */
|
|
export function MobileStateButton({ label, onPress }: MobileStateAction) {
|
|
useMobileColorScheme()
|
|
return (
|
|
<Pressable
|
|
style={({ pressed }) => [styles.action, pressed && styles.actionPressed]}
|
|
onPress={onPress}
|
|
hitSlop={8}
|
|
accessibilityRole="button"
|
|
>
|
|
<Text style={styles.actionText}>{label}</Text>
|
|
</Pressable>
|
|
)
|
|
}
|
|
|
|
function MobileStateDetails({ details }: { details: string }) {
|
|
const t = useMobileTranslation()
|
|
const [open, setOpen] = useState(false)
|
|
return (
|
|
<>
|
|
<Pressable
|
|
style={({ pressed }) => pressed && pressedStyle}
|
|
onPress={() => setOpen(!open)}
|
|
hitSlop={8}
|
|
accessibilityRole="button"
|
|
accessibilityState={{ expanded: open }}
|
|
>
|
|
<Text style={styles.detailsToggle}>
|
|
{open ? t('common.hideDetails', 'Hide details') : t('common.details', 'Details')}
|
|
</Text>
|
|
</Pressable>
|
|
{open ? (
|
|
<Text style={styles.details} selectable>
|
|
{details}
|
|
</Text>
|
|
) : null}
|
|
</>
|
|
)
|
|
}
|
|
|
|
/** A failed load: the translated reason, raw text behind Details, and Retry when it can help. */
|
|
export function MobileLoadErrorState({
|
|
error,
|
|
title,
|
|
onRetry,
|
|
bottomInset
|
|
}: {
|
|
error: unknown
|
|
title?: string
|
|
onRetry?: (() => void) | null
|
|
bottomInset?: number
|
|
}) {
|
|
const t = useMobileTranslation()
|
|
const { message, details } = describeLoadError(error, t)
|
|
return (
|
|
<MobileStateView
|
|
icon={CircleAlert}
|
|
title={title ?? t('common.loadError.title', 'Unable to Load')}
|
|
message={message}
|
|
details={details}
|
|
action={onRetry ? { label: t('common.retry', 'Retry'), onPress: onRetry } : null}
|
|
bottomInset={bottomInset}
|
|
/>
|
|
)
|
|
}
|
|
|
|
/** The host is unreachable and the screen has nothing to show: say so and offer a reconnect. */
|
|
export function MobileOfflineState({
|
|
hostName,
|
|
message,
|
|
onReconnect,
|
|
bottomInset
|
|
}: {
|
|
hostName?: string | null
|
|
/** Replaces the default advice, e.g. with when the stored data around this state was read. */
|
|
message?: string
|
|
onReconnect?: (() => void) | null
|
|
bottomInset?: number
|
|
}) {
|
|
const t = useMobileTranslation()
|
|
return (
|
|
<MobileStateView
|
|
icon={WifiOff}
|
|
title={
|
|
hostName
|
|
? t('common.offline.waitingFor', 'Waiting for {{host}}', { host: hostName })
|
|
: t('common.offline.waiting', 'Waiting for desktop')
|
|
}
|
|
message={
|
|
message ??
|
|
t('common.offline.message', 'Check that your computer is awake and Orca is running.')
|
|
}
|
|
action={
|
|
onReconnect
|
|
? { label: t('common.offline.reconnect', 'Reconnect'), onPress: onReconnect }
|
|
: null
|
|
}
|
|
bottomInset={bottomInset}
|
|
/>
|
|
)
|
|
}
|
|
|
|
/** A search or filter that matched nothing, with the way back out. */
|
|
export function MobileNoMatchState({
|
|
message,
|
|
onClear,
|
|
clearLabel,
|
|
bottomInset
|
|
}: {
|
|
message?: string
|
|
onClear?: (() => void) | null
|
|
clearLabel?: string
|
|
bottomInset?: number
|
|
}) {
|
|
const t = useMobileTranslation()
|
|
return (
|
|
<MobileStateView
|
|
icon={SearchX}
|
|
title={t('common.noMatch.title', 'No matches')}
|
|
message={message}
|
|
action={
|
|
onClear
|
|
? {
|
|
label: clearLabel ?? t('common.noMatch.clearSearch', 'Clear search'),
|
|
onPress: onClear
|
|
}
|
|
: null
|
|
}
|
|
bottomInset={bottomInset}
|
|
/>
|
|
)
|
|
}
|
|
|
|
const styles = themedStyleSheet(() => ({
|
|
children: {
|
|
alignSelf: 'stretch',
|
|
marginTop: spacing.md
|
|
},
|
|
state: {
|
|
flex: 1,
|
|
alignItems: 'center',
|
|
justifyContent: 'center',
|
|
padding: spacing.xl,
|
|
gap: 6
|
|
},
|
|
title: {
|
|
marginTop: spacing.xs,
|
|
color: colors.textPrimary,
|
|
fontSize: 15,
|
|
fontWeight: '600',
|
|
textAlign: 'center'
|
|
},
|
|
message: {
|
|
maxWidth: 280,
|
|
color: colors.textSecondary,
|
|
fontSize: 13,
|
|
lineHeight: 17,
|
|
textAlign: 'center'
|
|
},
|
|
detailsToggle: {
|
|
color: colors.textMuted,
|
|
fontSize: typography.metaSize,
|
|
fontWeight: '600',
|
|
paddingVertical: 2
|
|
},
|
|
details: {
|
|
maxWidth: 300,
|
|
color: colors.textMuted,
|
|
fontSize: 11,
|
|
lineHeight: 15,
|
|
fontFamily: typography.monoFamily,
|
|
textAlign: 'center'
|
|
},
|
|
action: {
|
|
marginTop: spacing.sm,
|
|
minHeight: 32,
|
|
justifyContent: 'center',
|
|
paddingHorizontal: 14,
|
|
borderRadius: radii.control,
|
|
borderWidth: StyleSheet.hairlineWidth,
|
|
borderColor: colors.borderSubtle,
|
|
backgroundColor: colors.bgRaised
|
|
},
|
|
actionPressed: { opacity: feedback.pressedOpacity },
|
|
actionText: {
|
|
color: colors.textPrimary,
|
|
fontSize: 13,
|
|
fontWeight: '600'
|
|
}
|
|
}))
|