mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
* feat(mobile): give every corner one of three shapes Corners had drifted to 17 different radii, so a screen mixed 6 pt buttons, 14 pt cards, 12 pt groups and 4 pt badges. Every corner now comes from the shape of what it is: - control (12): anything you tap — buttons, icon buttons, fields, pickers, segmented controls, key caps. - surface (16): anything that holds content — cards, groups, sheets, banners, code boxes. Dialogs and the composer box use floating (24). - pill: badges, chips, status pills, dots, avatars and the composer's own round buttons. - tile (10) for icon squares and mark (4) for inline code and check squares; nested shapes take the parent's radius minus the gap. Every rounded style also asks for the continuous (squircle) corner curve; iOS draws it, Android and the web ignore it. * fix(mobile): keep circles and pills on the circular corner curve The continuous curve squares off a corner radius that reaches half the element's size, so the FAB, dots, avatars and the composer's round buttons stopped being round on iOS. * fix(mobile): put the anchored detail card on the surface radius * fix(mobile): keep the circular curve on unclipped bordered styles React Native strokes an unclipped visible border on a circular path while it fills the background with the continuous curve, so the two edges drifted apart at the corners.
163 lines
4.3 KiB
TypeScript
163 lines
4.3 KiB
TypeScript
import { useRef } from 'react'
|
|
import { ScrollView, StyleSheet, Text, View } from 'react-native'
|
|
import type { ConnectionLogEntry } from '../transport/types'
|
|
import { colors, radii, spacing, typography } from '../theme/mobile-theme'
|
|
import { themedStyleSheet } from '../theme/themed-styles'
|
|
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
|
|
|
|
type Props = {
|
|
entries: ConnectionLogEntry[]
|
|
// Label log scope before first entry (Pairing vs Reconnect).
|
|
title?: string
|
|
fillAvailableHeight?: boolean
|
|
}
|
|
|
|
const levelColor = (): Record<ConnectionLogEntry['level'], string> => ({
|
|
info: colors.textSecondary,
|
|
success: colors.statusGreen,
|
|
warn: colors.statusAmber,
|
|
error: colors.statusRed
|
|
})
|
|
|
|
const LEVEL_GLYPH: Record<ConnectionLogEntry['level'], string> = {
|
|
info: '•',
|
|
success: '✓',
|
|
warn: '!',
|
|
error: '✕'
|
|
}
|
|
|
|
function formatTime(ts: number, baseTs: number): string {
|
|
// Elapsed seconds expose connection stalls better than wall-clock time.
|
|
const elapsed = Math.max(0, ts - baseTs) / 1000
|
|
if (elapsed < 10) {
|
|
return `+${elapsed.toFixed(2)}s`
|
|
}
|
|
if (elapsed < 100) {
|
|
return `+${elapsed.toFixed(1)}s`
|
|
}
|
|
return `+${Math.round(elapsed)}s`
|
|
}
|
|
|
|
export function ConnectionLog({ entries, title, fillAvailableHeight = false }: Props) {
|
|
useMobileColorScheme()
|
|
const scrollRef = useRef<ScrollView | null>(null)
|
|
|
|
if (entries.length === 0) {
|
|
return null
|
|
}
|
|
const baseTs = entries[0]!.ts
|
|
const keyOccurrences = new Map<string, number>()
|
|
const levelColors = levelColor()
|
|
|
|
return (
|
|
<View
|
|
style={[
|
|
styles.container,
|
|
fillAvailableHeight ? styles.fillContainer : styles.boundedContainer
|
|
]}
|
|
>
|
|
{title && <Text style={styles.title}>{title}</Text>}
|
|
<ScrollView
|
|
ref={scrollRef}
|
|
style={fillAvailableHeight ? styles.fillScroll : styles.boundedScroll}
|
|
contentContainerStyle={styles.scrollContent}
|
|
showsVerticalScrollIndicator={false}
|
|
onContentSizeChange={() => scrollRef.current?.scrollToEnd({ animated: true })}
|
|
>
|
|
{entries.map((entry) => {
|
|
const occurrence = keyOccurrences.get(entry.id) ?? 0
|
|
keyOccurrences.set(entry.id, occurrence + 1)
|
|
const renderKey = occurrence === 0 ? entry.id : `${entry.id}:${occurrence}`
|
|
return (
|
|
<View key={renderKey} style={styles.row}>
|
|
<Text style={styles.timestamp}>{formatTime(entry.ts, baseTs)}</Text>
|
|
<Text style={[styles.glyph, { color: levelColors[entry.level] }]}>
|
|
{LEVEL_GLYPH[entry.level]}
|
|
</Text>
|
|
<View style={styles.rowText}>
|
|
<Text style={[styles.message, { color: levelColors[entry.level] }]}>
|
|
{entry.message}
|
|
</Text>
|
|
{entry.detail && (
|
|
<Text style={styles.detail} numberOfLines={2}>
|
|
{entry.detail}
|
|
</Text>
|
|
)}
|
|
</View>
|
|
</View>
|
|
)
|
|
})}
|
|
</ScrollView>
|
|
</View>
|
|
)
|
|
}
|
|
|
|
const styles = themedStyleSheet(() => ({
|
|
container: {
|
|
width: '100%',
|
|
backgroundColor: colors.bgPanel,
|
|
borderRadius: radii.surface,
|
|
borderWidth: StyleSheet.hairlineWidth,
|
|
borderColor: colors.borderSubtle,
|
|
paddingVertical: spacing.sm,
|
|
paddingHorizontal: spacing.md
|
|
},
|
|
boundedContainer: {
|
|
maxHeight: 240
|
|
},
|
|
fillContainer: {
|
|
flex: 1
|
|
},
|
|
title: {
|
|
fontSize: typography.metaSize,
|
|
fontFamily: typography.monoFamily,
|
|
color: colors.textMuted,
|
|
textTransform: 'uppercase',
|
|
letterSpacing: 1,
|
|
marginBottom: spacing.xs
|
|
},
|
|
boundedScroll: {
|
|
maxHeight: 200
|
|
},
|
|
fillScroll: {
|
|
flex: 1
|
|
},
|
|
scrollContent: {
|
|
gap: 6
|
|
},
|
|
row: {
|
|
flexDirection: 'row',
|
|
alignItems: 'flex-start',
|
|
gap: spacing.sm
|
|
},
|
|
timestamp: {
|
|
fontFamily: typography.monoFamily,
|
|
fontSize: typography.metaSize,
|
|
color: colors.textMuted,
|
|
width: 52,
|
|
paddingTop: 1
|
|
},
|
|
glyph: {
|
|
fontFamily: typography.monoFamily,
|
|
fontSize: typography.metaSize,
|
|
width: 12,
|
|
textAlign: 'center',
|
|
paddingTop: 1
|
|
},
|
|
rowText: {
|
|
flex: 1
|
|
},
|
|
message: {
|
|
fontFamily: typography.monoFamily,
|
|
fontSize: typography.metaSize,
|
|
lineHeight: 16
|
|
},
|
|
detail: {
|
|
fontFamily: typography.monoFamily,
|
|
fontSize: 11,
|
|
color: colors.textMuted,
|
|
lineHeight: 14,
|
|
marginTop: 1
|
|
}
|
|
}))
|