fix(mobile): preserve host card accessibility details

This commit is contained in:
Brennan Benson
2026-07-31 00:57:41 -07:00
parent 440748d0e7
commit 6b3b64089b
2 changed files with 53 additions and 4 deletions
+36 -1
View File
@@ -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"
)
})
})
+17 -3
View File
@@ -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>