mirror of
https://github.com/stablyai/orca.git
synced 2026-10-24 00:04:01 +00:00
* fix(mobile): recover relay sessions on resume * fix(mobile): expedite relay retry on app resume * fix(mobile): keep relay reconnect controller under lint limit * fix(mobile): rebuild relay client after pairing rejection * refactor(mobile): keep relay reconnect policy under lint limit
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
import { View, StyleSheet } from 'react-native'
|
|
import { colors } from '../theme/mobile-theme'
|
|
import type { ConnectionState } from '../transport/types'
|
|
import type { ConnectionVerdict } from '../transport/connection-health'
|
|
|
|
const stateColors: Record<ConnectionState, string> = {
|
|
connected: colors.statusGreen,
|
|
connecting: colors.statusAmber,
|
|
handshaking: colors.statusAmber,
|
|
reconnecting: colors.statusAmber,
|
|
disconnected: colors.textMuted,
|
|
'auth-failed': colors.statusRed
|
|
}
|
|
|
|
export function statusDotColor(state: ConnectionState, verdict?: ConnectionVerdict): string {
|
|
if (verdict?.kind === 'unreachable' || verdict?.kind === 'auth-failed') {
|
|
return colors.statusRed
|
|
}
|
|
if (verdict?.kind === 'warning' || (verdict?.kind === 'normal' && verdict.label.endsWith('…'))) {
|
|
return colors.statusAmber
|
|
}
|
|
return stateColors[state] ?? colors.textMuted
|
|
}
|
|
|
|
// Why: when caller passes a verdict, the dot color reflects the verdict's
|
|
// severity instead of the raw transport state. This avoids the "amber dot
|
|
// next to red 'Can't reach desktop' label" mismatch — the underlying
|
|
// transport is still 'reconnecting' (amber) but the user-visible meaning
|
|
// has escalated to error (red).
|
|
export function StatusDot({
|
|
state,
|
|
verdict
|
|
}: {
|
|
state: ConnectionState
|
|
verdict?: ConnectionVerdict
|
|
}) {
|
|
const color = statusDotColor(state, verdict)
|
|
return <View style={[styles.dot, { backgroundColor: color }]} />
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
dot: {
|
|
width: 8,
|
|
height: 8,
|
|
borderRadius: 4,
|
|
marginRight: 8
|
|
}
|
|
})
|