mirror of
https://github.com/stablyai/orca.git
synced 2026-10-20 00:03:45 +00:00
fix(mobile): preserve host card accessibility details
This commit is contained in:
@@ -99,6 +99,7 @@ describe('MobileHostCard', () => {
|
||||
state: 'connected',
|
||||
verdict: { kind: 'normal', label: 'Connected' },
|
||||
path: 'tailscale',
|
||||
worktreeCounts: { total: 3, active: 2 },
|
||||
onPress: vi.fn(),
|
||||
onLongPress: vi.fn(),
|
||||
onOpenActions: vi.fn()
|
||||
@@ -109,7 +110,41 @@ describe('MobileHostCard', () => {
|
||||
|
||||
const navigationButton = renderer.root.findAllByType('Pressable')[0]
|
||||
expect(navigationButton.props.accessibilityLabel).toBe(
|
||||
'Open Desk, Connected, Direct via Tailscale'
|
||||
'Open Desk, Connected, Direct via Tailscale, 3 worktrees, 2 active'
|
||||
)
|
||||
})
|
||||
|
||||
it('includes visible offline recovery guidance in the navigation label', async () => {
|
||||
const consoleError = suppressRendererDeprecation()
|
||||
await act(async () => {
|
||||
renderer = create(
|
||||
createElement(MobileHostCard, {
|
||||
host: {
|
||||
id: 'desk',
|
||||
name: 'Desk',
|
||||
endpoint: 'ws://192.168.1.2:6768',
|
||||
deviceToken: 'token',
|
||||
publicKeyB64: 'key',
|
||||
lastConnected: 1
|
||||
},
|
||||
state: 'reconnecting',
|
||||
verdict: {
|
||||
kind: 'unreachable',
|
||||
label: "Can't reach desktop",
|
||||
reason: 'never-connected'
|
||||
},
|
||||
path: 'lan',
|
||||
onPress: vi.fn(),
|
||||
onLongPress: vi.fn(),
|
||||
onOpenActions: vi.fn()
|
||||
})
|
||||
)
|
||||
})
|
||||
consoleError.mockRestore()
|
||||
|
||||
const navigationButton = renderer.root.findAllByType('Pressable')[0]
|
||||
expect(navigationButton.props.accessibilityLabel).toBe(
|
||||
"Open Desk, Can't reach desktop, Update desktop Orca and sign in to connect from anywhere"
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -26,11 +26,25 @@ export function MobileHostCard(props: {
|
||||
const worktreeSummary = props.worktreeCounts
|
||||
? `${props.worktreeCounts.total} worktree${props.worktreeCounts.total === 1 ? '' : 's'}${props.worktreeCounts.active > 0 ? ` · ${props.worktreeCounts.active} active` : ''}`
|
||||
: null
|
||||
const accessibleWorktreeSummary = connected ? worktreeSummary?.replace(' · ', ', ') : null
|
||||
const discoveryHint =
|
||||
props.verdict.kind === 'unreachable' && !props.host.relay
|
||||
? 'Update desktop Orca and sign in to connect from anywhere'
|
||||
: null
|
||||
const accessibilityLabel = [
|
||||
`Open ${props.host.name}`,
|
||||
statusLabel,
|
||||
accessibleConnectionPathLabel,
|
||||
accessibleWorktreeSummary,
|
||||
discoveryHint
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(', ')
|
||||
return (
|
||||
<View style={styles.card}>
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={`Open ${props.host.name}, ${statusLabel}${accessibleConnectionPathLabel ? `, ${accessibleConnectionPathLabel}` : ''}`}
|
||||
accessibilityLabel={accessibilityLabel}
|
||||
style={({ pressed }) => [styles.cardMain, pressed && styles.cardPressed]}
|
||||
onPress={props.onPress}
|
||||
onLongPress={props.onLongPress}
|
||||
@@ -61,9 +75,9 @@ export function MobileHostCard(props: {
|
||||
{worktreeSummary}
|
||||
</Text>
|
||||
) : null}
|
||||
{props.verdict.kind === 'unreachable' && !props.host.relay ? (
|
||||
{discoveryHint ? (
|
||||
<Text style={styles.discoveryHint} numberOfLines={2}>
|
||||
Update desktop Orca and sign in to connect from anywhere
|
||||
{discoveryHint}
|
||||
</Text>
|
||||
) : null}
|
||||
</View>
|
||||
|
||||
Reference in New Issue
Block a user