Repository navigation
Phone Sessions: search, sort and source filters #4975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| import { FlatList, Pressable } from 'react-native'; | ||
| import { Sheet } from '../chat/sheet'; | ||
| import { segmentCorners } from '../design/segment-corners'; | ||
| import { useDesignTheme } from '../design/theme'; | ||
| import { androidSettings, space } from '../design/tokens'; | ||
| import { RadioMark } from '../primitives/radio-mark'; | ||
| import { Text } from '../primitives/text'; | ||
| import { useStrings } from '../strings'; | ||
| import { HeaderAction } from './header-action'; | ||
|
|
||
| type Choice = { id: string; label: string; select(): void }; | ||
| export type SessionOptionGroup = { | ||
| id: string; | ||
| label: string; | ||
| selected: string; | ||
| choices: Choice[]; | ||
| }; | ||
|
|
||
| export function HostSessionOptionsButton({ active, onOpen }: { active: boolean; onOpen(): void }) { | ||
| const t = useStrings().hostSessions; | ||
| return ( | ||
| <HeaderAction | ||
| icon="filter" | ||
| label={t.options} | ||
| testID="host-sessions-options" | ||
| active={active} | ||
| onPress={onOpen} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| type HostSessionOptionsSheetProps = { | ||
| open: boolean; | ||
| groups: readonly SessionOptionGroup[]; | ||
| onClose(): void; | ||
| }; | ||
|
|
||
| type Row = | ||
| | { kind: 'heading'; key: string; label: string } | ||
| | { | ||
| kind: 'choice'; | ||
| key: string; | ||
| choice: Choice; | ||
| selected: boolean; | ||
| first: boolean; | ||
| last: boolean; | ||
| }; | ||
|
|
||
| export function HostSessionOptionsSheet({ open, groups, onClose }: HostSessionOptionsSheetProps) { | ||
| const t = useStrings().hostSessions; | ||
| const theme = useDesignTheme(); | ||
| if (!open) return null; | ||
| const rows = groups.flatMap((group): Row[] => [ | ||
| { kind: 'heading', key: group.id, label: group.label }, | ||
| ...group.choices.map((choice, index): Row => ({ | ||
| kind: 'choice', | ||
| key: `${group.id}:${choice.id}`, | ||
| choice, | ||
| selected: group.selected === choice.id, | ||
| first: index === 0, | ||
| last: index === group.choices.length - 1, | ||
| })), | ||
| ]); | ||
| return ( | ||
| <Sheet visible label={t.options} title={t.options} onClose={onClose}> | ||
| <FlatList | ||
| nestedScrollEnabled | ||
| data={rows} | ||
| keyExtractor={(row) => row.key} | ||
| contentContainerStyle={{ paddingHorizontal: space.x5, paddingBottom: space.x5 }} | ||
| renderItem={({ item }) => { | ||
| if (item.kind === 'heading') | ||
| return ( | ||
| <Text | ||
| variant="meta" | ||
| tone="muted" | ||
| accessibilityRole="header" | ||
| style={{ paddingVertical: space.x3 }} | ||
| > | ||
| {item.label} | ||
| </Text> | ||
| ); | ||
| return ( | ||
| <Pressable | ||
| accessibilityRole="radio" | ||
| accessibilityLabel={item.choice.label} | ||
| accessibilityState={{ checked: item.selected }} | ||
|
Comment on lines
+84
to
+87
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add stable testIDs to the Android source and sort choices. Each choice in the Android selection sheet has a translated accessibility label but no As per coding guidelines, “A new interactive control that a flow or agent will drive gets a kebab-case
|
||
| onPress={item.choice.select} | ||
| style={({ pressed }) => ({ | ||
| minHeight: theme.touch, | ||
| flexDirection: 'row', | ||
| alignItems: 'center', | ||
| gap: space.x4, | ||
| paddingHorizontal: space.x5, | ||
| paddingVertical: space.x3, | ||
| ...segmentCorners(item.first, item.last), | ||
| marginTop: item.first ? 0 : androidSettings.segmentGap, | ||
| backgroundColor: pressed ? theme.layer.raised.pressed : theme.layer.raised.fill, | ||
| })} | ||
| > | ||
| <RadioMark selected={item.selected} /> | ||
| <Text style={{ flex: 1 }}>{item.choice.label}</Text> | ||
| </Pressable> | ||
| ); | ||
| }} | ||
| /> | ||
| </Sheet> | ||
| ); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep untouched saved preferences when another preference changes during restore.
If a preference setter runs before
restore()finishes reading, the singletouchedflag blocks every saved field. The savedsessionSortis then dropped, and the restore persists the default'last-human-turn'. This affectslanguageandappearancein the same way. The window is narrow because only a user action can start it, but it still overwrites a saved preference.Restore each saved field that the user has not changed, including
sessionSort. An explicit startup change must still win for the field it changed.