Files
orca/mobile/src/session/MobileNativeChatSessionOptionSegments.tsx
T
Kelvin Amoaba cf7423c8f4 feat(mobile): redesign the chat composer with file attachments and inline skills (#30359)
* refactor(native-chat): move the slash picker builder and upload chunking to shared

Mobile builds the same skill and command list as desktop.

* feat(mobile): redesign the chat composer with file attachments and inline skills

* fix(mobile): the composer field owns its input style

The page's font-size census cannot follow a style passed in as a prop.
2026-10-18 20:03:26 +00:00

67 lines
2.1 KiB
TypeScript

import { StyleSheet, Text, View } from 'react-native'
import { MobileSegmentedControl } from '../components/MobileSegmentedControl'
import { colors, spacing, typography } from '../theme/mobile-theme'
import {
sessionOptionDispatchUnconfirmed,
type SessionOptionDescriptor,
type SessionOptionValue
} from '../../../src/shared/native-chat-session-options'
import { SessionOptionCaption } from './MobileNativeChatSessionOptionRows'
// Five fit across a phone's sheet; more read better as a list on their own page.
const MAX_SEGMENTS = 5
/** An effort-like choice the model page can show in place, as one segmented control. */
export function showsSessionOptionAsSegments(descriptor: SessionOptionDescriptor): boolean {
return (
descriptor.category === 'thought_level' &&
descriptor.kind.type === 'select' &&
!descriptor.action &&
descriptor.kind.choices.length > 1 &&
descriptor.kind.choices.length <= MAX_SEGMENTS
)
}
export function SessionOptionSegments({
descriptor,
disabled,
onSetOption
}: {
descriptor: SessionOptionDescriptor
disabled: boolean
onSetOption: (value: SessionOptionValue) => void
}): React.JSX.Element | null {
if (descriptor.kind.type !== 'select') {
return null
}
const { choices, currentValue } = descriptor.kind
return (
<View style={styles.block}>
<Text style={styles.label}>{descriptor.label}</Text>
<MobileSegmentedControl
segments={choices}
// An unknown value marks nothing, rather than reading as a confirmed choice.
selected={descriptor.valueSource === 'unknown' ? undefined : currentValue}
onSelect={onSetOption}
fill
disabled={disabled || !descriptor.settable}
/>
{sessionOptionDispatchUnconfirmed(descriptor) ? (
<SessionOptionCaption>Sent to the agent — not confirmed</SessionOptionCaption>
) : null}
</View>
)
}
const styles = StyleSheet.create({
block: {
marginTop: spacing.md
},
label: {
color: colors.textMuted,
fontSize: typography.metaSize,
paddingHorizontal: spacing.xs,
paddingBottom: 6
}
})