Skip to content

Commit 3ac2f2f

Browse files
Programcodeclaude
andcommitted
Add Ask with streaming answers, reached from the Practice tab
Practice lists the website's practice tools; Ask opens full screen and the rest say they are on their way. Ask sends the website's request: plain questions stream from ai-stream through expo/fetch, and with Citations, Web search, Pros/Cons or Argument map on the whole answer comes from the ai function, because ai-stream refuses those options. The model, settings and Current Debate context are picked the way the website picks them, including pins. Finished exchanges are saved to chats and messages, past chats reopen from the history sheet, and leaving mid-answer cancels it without saving half a message. Answers render through a small Markdown reader with citation chips that open the Library source or the cited page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 1805083 commit 3ac2f2f

18 files changed

Lines changed: 1922 additions & 8 deletions

File tree

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,52 @@
1-
import { PlaceholderScreen } from '@/components/placeholder-screen';
1+
import { useRouter } from 'expo-router';
2+
import { useTranslation } from 'react-i18next';
3+
import { Pressable, StyleSheet, View } from 'react-native';
24

3-
export default function Screen() {
4-
return <PlaceholderScreen tab="practice" />;
5+
import { Card, IconTile } from '@/components/card';
6+
import { Icon } from '@/components/icon';
7+
import { PRACTICE_TOOLS } from '@/components/practice-tools';
8+
import { ScreenTitle } from '@/components/screen-title';
9+
import { Screen } from '@/components/screen';
10+
import { Text } from '@/components/text';
11+
import { useTheme } from '@/theme/use-theme';
12+
13+
/** The Practice tools. Ask opens full screen; the others say they are on their way. */
14+
export default function PracticeScreen() {
15+
const { t } = useTranslation();
16+
const router = useRouter();
17+
const { colors } = useTheme();
18+
return (
19+
<Screen>
20+
<ScreenTitle title={t('mobile.tabs.practice')} />
21+
<Card style={styles.list}>
22+
{PRACTICE_TOOLS.map((tool, index) => (
23+
<Pressable
24+
key={tool.key}
25+
accessibilityRole="button"
26+
onPress={() => (tool.key === 'ask' ? router.push('/ask') : router.push({ pathname: '/soon/[tool]', params: { tool: tool.key } }))}
27+
style={({ pressed }) => [styles.row, index > 0 && { borderTopWidth: 1, borderTopColor: colors.line }, pressed && styles.pressed]}>
28+
<IconTile name={tool.icon} size={42} />
29+
<View style={styles.rowText}>
30+
<Text weight="semibold" style={styles.rowTitle}>
31+
{t(`nav.${tool.key}`)}
32+
</Text>
33+
<Text tone="faint" style={styles.rowMeta} numberOfLines={1}>
34+
{t(`navDesc.${tool.key}`)}
35+
</Text>
36+
</View>
37+
<Icon name="chevronRight" color={colors.tabInactive} size={20} />
38+
</Pressable>
39+
))}
40+
</Card>
41+
</Screen>
42+
);
543
}
44+
45+
const styles = StyleSheet.create({
46+
list: { padding: 0, gap: 0 },
47+
row: { flexDirection: 'row', alignItems: 'center', gap: 13, paddingVertical: 12, paddingHorizontal: 14 },
48+
rowText: { flex: 1, gap: 2 },
49+
rowTitle: { fontSize: 16 },
50+
rowMeta: { fontSize: 14 },
51+
pressed: { opacity: 0.7 },
52+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { useLocalSearchParams } from 'expo-router';
2+
import { useTranslation } from 'react-i18next';
3+
4+
import { PlaceholderScreen } from '@/components/placeholder-screen';
5+
import { PRACTICE_TOOLS } from '@/components/practice-tools';
6+
7+
/** A Practice tool that is not in the app yet. */
8+
export default function PracticeToolScreen() {
9+
const { t } = useTranslation();
10+
const { tool } = useLocalSearchParams<{ tool: string }>();
11+
const entry = PRACTICE_TOOLS.find((item) => item.key === tool);
12+
return <PlaceholderScreen tab="practice" title={entry ? t(`nav.${entry.key}`) : undefined} icon={entry?.icon} />;
13+
}

‎apps/mobile/src/app/_layout.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ function Root() {
7979
<Stack.Screen name="add-link" options={sheet} />
8080
<Stack.Screen name="new-note" options={sheet} />
8181
<Stack.Screen name="source/[id]" options={sheet} />
82+
{/* Full screen above the tabs, as in mock 07. */}
83+
<Stack.Screen name="ask" />
8284
</Stack.Protected>
8385
<Stack.Protected guard={session === null}>
8486
<Stack.Screen name="sign-in" />

0 commit comments

Comments
 (0)