@gemies/sdk 10.8.0 → 10.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +4 -0
  3. package/package.json +1 -1
  4. package/src/components/GemieChatContent.tsx +117 -27
  5. package/src/components/GemieComposer.tsx +25 -4
  6. package/src/components/diff/AnnotatedPatch.tsx +125 -0
  7. package/src/components/diff/DiffCommentCards.tsx +132 -0
  8. package/src/components/diff/DiffCommentChips.tsx +57 -0
  9. package/src/components/diff/FileChangeSection.tsx +12 -5
  10. package/src/components/diff/FileChangesViewer.tsx +21 -5
  11. package/src/components/diff/PatchLines.tsx +124 -13
  12. package/src/components/diff/diff-comments-context.ts +29 -0
  13. package/src/components/diff/diff-renderer.ts +17 -1
  14. package/src/components/thread/FollowUpStatus.tsx +35 -0
  15. package/src/components/thread/GemieThread.tsx +25 -1
  16. package/src/components/thread/ThreadFindBar.tsx +121 -0
  17. package/src/components/thread/ThreadPanel.tsx +34 -0
  18. package/src/components/thread/ThreadRow.tsx +52 -12
  19. package/src/components/thread/ThreadSearch.tsx +61 -78
  20. package/src/components/thread/ThreadTurns.tsx +94 -0
  21. package/src/components/thread/TurnDiffComments.tsx +52 -0
  22. package/src/hooks/useChatComposer.ts +20 -3
  23. package/src/hooks/useFindShortcut.ts +57 -0
  24. package/src/hooks/useRowJump.ts +79 -0
  25. package/src/hooks/useThreadNavigation.ts +134 -0
  26. package/src/hooks/useTimelineWindow.ts +18 -1
  27. package/src/index.ts +8 -0
  28. package/src/lib/content-utils.ts +10 -0
  29. package/src/lib/copy-en.ts +26 -0
  30. package/src/lib/copy-es.ts +26 -0
  31. package/src/runtime/composer-draft-store.ts +43 -16
  32. package/src/runtime/model.ts +1 -0
  33. package/src/runtime/thread/diff-comments.ts +227 -0
  34. package/src/runtime/thread/message-processor.ts +58 -37
  35. package/src/runtime/thread/thread-find.ts +102 -0
  36. package/src/runtime/use-approval-actions.ts +7 -1
  37. package/src/runtime/use-conversation-thread.ts +10 -4
  38. package/src/runtime/use-start-conversation.ts +2 -1
  39. package/src/runtime/use-turn-edit.ts +5 -3
@@ -0,0 +1,121 @@
1
+ import { Button } from '@oxy.so/bloom/button';
2
+ import { RiArrowDownSLine } from '@oxy.so/bloom/icons/RiArrowDownSLine';
3
+ import { RiArrowUpSLine } from '@oxy.so/bloom/icons/RiArrowUpSLine';
4
+ import { RiCloseLine } from '@oxy.so/bloom/icons/RiCloseLine';
5
+ import { Search } from '@oxy.so/bloom/search';
6
+ import { Muted } from '@oxy.so/bloom/typography';
7
+ import { useEffect, useRef } from 'react';
8
+ import { StyleSheet, type TextInputKeyPressEvent, View } from 'react-native';
9
+ import type { ThreadNavigation } from '../../hooks/useThreadNavigation';
10
+ import { useLabels } from '../../lib/labels';
11
+ import type { TextInputHandle } from '../../lib/text-input';
12
+ import { ThreadPanel } from './ThreadPanel';
13
+
14
+ /**
15
+ * Find in the open conversation: the words, which match of how many, and the way to the others.
16
+ *
17
+ * Not `ThreadSearch`, which asks the server for sentences across every conversation of a gemie's
18
+ * thread: this marks the messages on screen and moves between them. Enter goes to the match
19
+ * above (older), Shift+Enter to the one below, Escape closes.
20
+ */
21
+ export function ThreadFindBar({
22
+ find,
23
+ partial,
24
+ }: {
25
+ find: ThreadNavigation;
26
+ /** There is history the thread has not loaded, which find cannot see. */
27
+ partial: boolean;
28
+ }) {
29
+ const { t } = useLabels();
30
+ const field = useRef<TextInputHandle>(null);
31
+ const { query, total, current, focusRequest, older, newer, close, setQuery } = find;
32
+
33
+ // Asked for again while open (the shortcut): the caret comes back to the words.
34
+ useEffect(() => {
35
+ if (focusRequest > 0) field.current?.focus();
36
+ }, [focusRequest]);
37
+
38
+ const onKeyPress = (event: TextInputKeyPressEvent) => {
39
+ const { key, shiftKey } = event.nativeEvent as { key: string; shiftKey?: boolean };
40
+ if (key === 'Escape') {
41
+ event.preventDefault();
42
+ close();
43
+ } else if (key === 'Enter' && shiftKey) {
44
+ event.preventDefault();
45
+ newer();
46
+ }
47
+ };
48
+
49
+ const asked = query.trim() !== '';
50
+ const none = total === 0;
51
+
52
+ return (
53
+ <ThreadPanel>
54
+ <View style={styles.row}>
55
+ <View style={styles.field}>
56
+ <Search
57
+ ref={field}
58
+ label={t('chat.find.placeholder')}
59
+ value={query}
60
+ onChangeText={setQuery}
61
+ onClearText={() => setQuery('')}
62
+ onKeyPress={onKeyPress}
63
+ onSubmitEditing={older}
64
+ // Enter steps through the matches, so the field keeps the caret.
65
+ submitBehavior="submit"
66
+ blurOnSubmit={false}
67
+ autoFocus
68
+ returnKeyType="search"
69
+ />
70
+ </View>
71
+ {asked ? (
72
+ <View accessibilityLiveRegion="polite" aria-live="polite">
73
+ <Muted>
74
+ {none ? t('chat.find.none') : t('chat.find.count', { current: current + 1, total })}
75
+ </Muted>
76
+ </View>
77
+ ) : null}
78
+ <Button
79
+ size="sm"
80
+ appearance="plain"
81
+ tone="neutral"
82
+ iconOnly
83
+ leadingIcon={RiArrowUpSLine}
84
+ accessibilityLabel={t('chat.find.older')}
85
+ disabled={none}
86
+ onPress={older}
87
+ />
88
+ <Button
89
+ size="sm"
90
+ appearance="plain"
91
+ tone="neutral"
92
+ iconOnly
93
+ leadingIcon={RiArrowDownSLine}
94
+ accessibilityLabel={t('chat.find.newer')}
95
+ disabled={none}
96
+ onPress={newer}
97
+ />
98
+ <Button
99
+ size="sm"
100
+ appearance="plain"
101
+ tone="neutral"
102
+ iconOnly
103
+ leadingIcon={RiCloseLine}
104
+ accessibilityLabel={t('common.close')}
105
+ onPress={close}
106
+ />
107
+ </View>
108
+ {partial ? (
109
+ <View style={styles.note}>
110
+ <Muted>{t('chat.find.loadedOnly')}</Muted>
111
+ </View>
112
+ ) : null}
113
+ </ThreadPanel>
114
+ );
115
+ }
116
+
117
+ const styles = StyleSheet.create({
118
+ row: { flexDirection: 'row', alignItems: 'center', gap: 8 },
119
+ field: { flexGrow: 1, flexShrink: 1, flexBasis: '0%' },
120
+ note: { paddingHorizontal: 4, paddingTop: 8 },
121
+ });
@@ -0,0 +1,34 @@
1
+ import { useAiChatChromeInsets } from '@oxy.so/bloom/ai-chat';
2
+ import { Card, CardBody } from '@oxy.so/bloom/card';
3
+ import type { ReactNode } from 'react';
4
+ import { StyleSheet, View } from 'react-native';
5
+
6
+ /**
7
+ * A card floating over the top of the thread, in its 768 column: what the thread's search, its
8
+ * find bar and its list of turns stand on. The card is the surface, so nothing on it paints one.
9
+ *
10
+ * It starts under the container's header, which floats over the content on a layer above it.
11
+ */
12
+ export function ThreadPanel({ children }: { children: ReactNode }) {
13
+ const insets = useAiChatChromeInsets();
14
+ return (
15
+ <View style={[styles.overlay, { top: insets?.top ?? 0 }]} pointerEvents="box-none">
16
+ <View style={styles.column}>
17
+ <Card elevation="m">
18
+ <CardBody>{children}</CardBody>
19
+ </Card>
20
+ </View>
21
+ </View>
22
+ );
23
+ }
24
+
25
+ const styles = StyleSheet.create({
26
+ overlay: {
27
+ position: 'absolute',
28
+ insetInline: 0,
29
+ zIndex: 20,
30
+ paddingHorizontal: 16,
31
+ paddingTop: 8,
32
+ },
33
+ column: { width: '100%', maxWidth: 768, alignSelf: 'center' },
34
+ });
@@ -6,6 +6,7 @@ import {
6
6
  AiChatUserMessage,
7
7
  type AiChatTurnAction,
8
8
  } from '@oxy.so/bloom/ai-chat';
9
+ import { Button } from '@oxy.so/bloom/button';
9
10
  import { RiEditLine } from '@oxy.so/bloom/icons/RiEditLine';
10
11
  import { RiFileCopyLine } from '@oxy.so/bloom/icons/RiFileCopyLine';
11
12
  import { RiRefreshLine } from '@oxy.so/bloom/icons/RiRefreshLine';
@@ -16,7 +17,7 @@ import { RiVolumeUpLine } from '@oxy.so/bloom/icons/RiVolumeUpLine';
16
17
  import { TaskList } from '@oxy.so/bloom/task-list';
17
18
  import { Text } from '@oxy.so/bloom/typography';
18
19
  import { WebSearch } from '@oxy.so/bloom/web-search';
19
- import { memo } from 'react';
20
+ import { memo, useCallback } from 'react';
20
21
  import { type LayoutChangeEvent, View } from 'react-native';
21
22
  import Animated from 'react-native-reanimated';
22
23
  import type { ReadAloudState } from '../../hooks/useReadAloud';
@@ -25,8 +26,9 @@ import { agentCharacterOf } from '../../lib/participants';
25
26
  import { gemieConversationOf } from '../../runtime/gemie-conversations';
26
27
  import { GemieConversationCard } from './GemieConversationCard';
27
28
  import { useBubbles } from '../../lib/bubbles';
28
- import { messageText } from '../../lib/content-utils';
29
+ import { messageText, questionParts } from '../../lib/content-utils';
29
30
  import { hasAttachments, TurnAttachments } from './TurnAttachments';
31
+ import { TurnDiffComments } from './TurnDiffComments';
30
32
  import { ANCHORS, useGemieFlights } from '../../lib/flights';
31
33
  import { useLabels } from '../../lib/labels';
32
34
  import { canvasResultOf } from '../../lib/canvas-result';
@@ -44,6 +46,7 @@ import {
44
46
  turnFileChanges,
45
47
  } from '../../runtime/model';
46
48
  import type { OpenThought } from '../../hooks/useOpenThought';
49
+ import type { RowView } from '../../hooks/useRowJump';
47
50
  import { PlanPreviewCard } from '../PlanPreviewCard';
48
51
  import { AskedQuestions } from '../QuestionCard';
49
52
  import { CanvasComponent } from '../canvas/CanvasComponent';
@@ -100,6 +103,10 @@ export interface ThreadRowProps {
100
103
  conversationId: string | undefined;
101
104
  /** Where this row ended up, for the one row a jump is aimed at. */
102
105
  onLayout?: (event: LayoutChangeEvent) => void;
106
+ /** Hands the thread the row's view, which a jump measures. Stable across renders. */
107
+ registerRow?: (messageId: string, view: RowView | null) => void;
108
+ /** The row is the find bar's current match. */
109
+ highlighted?: boolean;
103
110
  actions: ThreadActions;
104
111
  /** This reply's read-aloud, as a primitive so only its own row re-renders. */
105
112
  readAloudState: ReadAloudState;
@@ -131,6 +138,8 @@ export const ThreadRow = memo(function ThreadRow({
131
138
  isLoading,
132
139
  conversationId,
133
140
  onLayout,
141
+ registerRow,
142
+ highlighted = false,
134
143
  actions,
135
144
  readAloudState,
136
145
  readAloudBlocked,
@@ -141,11 +150,18 @@ export const ThreadRow = memo(function ThreadRow({
141
150
  }: ThreadRowProps) {
142
151
  const styles = useStyles();
143
152
  const { t } = useLabels();
144
- const text = messageText(message);
145
153
  const isReply = message.role === 'assistant';
154
+ const question = isReply ? null : questionParts(message);
155
+ const text = question === null ? messageText(message) : question.text;
156
+ const diffComments = question?.diffComments ?? [];
146
157
  const attached = !isReply && hasAttachments(message.content);
147
158
  const storedIn = message.unsaved === true ? undefined : conversationId;
148
159
  const hasText = text.length > 0;
160
+ const rowRef = useCallback(
161
+ (view: RowView | null) => registerRow?.(message.id, view),
162
+ [registerRow, message.id],
163
+ );
164
+ const rowStyle = highlighted ? styles.highlighted : undefined;
149
165
 
150
166
  const copyAction: AiChatTurnAction | null = hasText
151
167
  ? {
@@ -175,8 +191,8 @@ export const ThreadRow = memo(function ThreadRow({
175
191
  };
176
192
  const questionActions = [copyAction, editAction].filter(isPresent);
177
193
  return (
178
- <Animated.View onLayout={onLayout}>
179
- {text.length === 0 && !attached ? null : (
194
+ <Animated.View ref={rowRef} onLayout={onLayout} style={rowStyle}>
195
+ {text.length === 0 && !attached && diffComments.length === 0 ? null : (
180
196
  // Bloom's user turn, with the breathing room above it the thread has always had.
181
197
  <View style={styles.question}>
182
198
  <TurnMenu actions={questionActions} label={t('chat.turnActions')}>
@@ -191,6 +207,7 @@ export const ThreadRow = memo(function ThreadRow({
191
207
  tone="outgoing"
192
208
  onColor={foreground}
193
209
  />
210
+ <TurnDiffComments comments={diffComments} color={foreground} />
194
211
  {text.length > 0 ? (
195
212
  <Text variant="body-regular" selectable style={{ color: foreground }}>
196
213
  {text}
@@ -203,6 +220,7 @@ export const ThreadRow = memo(function ThreadRow({
203
220
  <AiChatUserMessage animate={isNew} actions={questionActions}>
204
221
  {/* Bloom's user turn sits on a neutral surface, not the accent. */}
205
222
  <TurnAttachments content={message.content} tone="incoming" />
223
+ {diffComments.length > 0 ? <TurnDiffComments comments={diffComments} /> : null}
206
224
  {text}
207
225
  </AiChatUserMessage>
208
226
  )}
@@ -214,7 +232,7 @@ export const ThreadRow = memo(function ThreadRow({
214
232
  }
215
233
 
216
234
  return (
217
- <Animated.View onLayout={onLayout}>
235
+ <Animated.View ref={rowRef} onLayout={onLayout} style={rowStyle}>
218
236
  <ReplyTurn
219
237
  message={message}
220
238
  text={text}
@@ -411,13 +429,12 @@ function ReplyTurn({
411
429
  icon: RiThumbDownLine,
412
430
  onPress: () => actions.vote(message.id, 'down', storedIn),
413
431
  };
414
- const menuActions: AiChatTurnAction[] = hasFeedback
415
- ? [readAloudAction, copyAction, regenerateAction, likeAction, dislikeAction].filter(isPresent)
416
- : [];
417
- /** In a bubble: "react" is the emoji bar, "more" is the rest of what the turn offers, the votes included. */
432
+ /** A shared conversation is read, not judged: a finished reply still offers its words. */
433
+ const copyOnly = readOnly && !message.isStreaming ? copyAction : null;
434
+ /** The long-press menu, and a bubble's "more" (where "react" is the emoji bar beside it). */
418
435
  const moreActions = hasFeedback
419
436
  ? [readAloudAction, copyAction, regenerateAction, likeAction, dislikeAction].filter(isPresent)
420
- : [];
437
+ : [copyOnly].filter(isPresent);
421
438
  const reactions = actions.reactionsOf(
422
439
  message.id,
423
440
  message.reactions,
@@ -509,7 +526,7 @@ function ReplyTurn({
509
526
  ) : null}
510
527
  {/* Bloom's reply: its reveal and its own feedback row (like / dislike / copy), then read
511
528
  aloud and regenerate. Copy confirms only what the clipboard did. */}
512
- <TurnMenu actions={menuActions} label={t('chat.turnActions')}>
529
+ <TurnMenu actions={moreActions} label={t('chat.turnActions')}>
513
530
  <AiChatAssistantMessage
514
531
  animate={isNew}
515
532
  feedback={hasFeedback && !bubbled}
@@ -628,6 +645,20 @@ function ReplyTurn({
628
645
  ) : (
629
646
  replyBody
630
647
  )}
648
+ {/* Bloom's feedback row always votes, so a reader of a shared one gets copy alone. */}
649
+ {bubbled || copyOnly === null ? null : (
650
+ <View style={styles.copyOnly}>
651
+ <Button
652
+ iconOnly
653
+ size="sm"
654
+ appearance="plain"
655
+ tone="neutral"
656
+ leadingIcon={RiFileCopyLine}
657
+ accessibilityLabel={copyOnly.label}
658
+ onPress={copyOnly.onPress}
659
+ />
660
+ </View>
661
+ )}
631
662
  </AiChatAssistantMessage>
632
663
  </TurnMenu>
633
664
  </View>
@@ -637,8 +668,17 @@ function ReplyTurn({
637
668
  }
638
669
 
639
670
  const useStyles = createTokenStyles((t) => ({
671
+ // An outline takes no room, so marking a match moves nothing the reader is looking at.
672
+ highlighted: {
673
+ borderRadius: 16,
674
+ outlineWidth: 2,
675
+ outlineStyle: 'solid',
676
+ outlineColor: t.primary,
677
+ outlineOffset: 4,
678
+ },
640
679
  question: { marginTop: 8, width: '100%', flexDirection: 'column', alignItems: 'flex-end' },
641
680
  reply: { width: '100%', flexDirection: 'column' },
681
+ copyOnly: { alignSelf: 'flex-start' },
642
682
  replyIdentity: { marginBottom: 2 },
643
683
  canvas: { borderRadius: 16, borderWidth: 1, borderColor: t.border, padding: 16 },
644
684
  muted: { fontSize: 14, color: t.mutedForeground, lineHeight: 20 },
@@ -3,13 +3,13 @@ import type { GemieThreadAddress } from '../../runtime/routes';
3
3
  import { useThreadSearch } from '../../runtime/use-thread-search';
4
4
  import { useLabels } from '../../lib/labels';
5
5
  import { Button } from '@oxy.so/bloom/button';
6
- import { Card, CardBody } from '@oxy.so/bloom/card';
7
6
  import { RiCloseLine } from '@oxy.so/bloom/icons/RiCloseLine';
8
7
  import { ListItem } from '@oxy.so/bloom/list';
9
8
  import { Search } from '@oxy.so/bloom/search';
10
9
  import { Muted } from '@oxy.so/bloom/typography';
11
10
  import { useState } from 'react';
12
11
  import { ScrollView, View, StyleSheet } from 'react-native';
12
+ import { ThreadPanel } from './ThreadPanel';
13
13
 
14
14
  /**
15
15
  * Searching what was said in this thread, across every conversation in it.
@@ -24,9 +24,7 @@ import { ScrollView, View, StyleSheet } from 'react-native';
24
24
  * can read and not reach is a wall, so `onJump` is not an extra: it is what the
25
25
  * hit is for.
26
26
  *
27
- * Bloom's `Search` for the field and a `ListItem` per hit, on a `Card` floating
28
- * over the top of the thread in its 768 column: the card is the surface, so
29
- * nothing here paints one of its own.
27
+ * Bloom's `Search` for the field and a `ListItem` per hit, on a `ThreadPanel`.
30
28
  */
31
29
 
32
30
  interface ThreadSearchProps {
@@ -61,85 +59,70 @@ export const ThreadSearch = ({ thread, onJump, onClose }: ThreadSearchProps) =>
61
59
  const found = hits ?? [];
62
60
 
63
61
  return (
64
- <View style={styles.overlay} pointerEvents="box-none">
65
- <View style={styles.column}>
66
- <Card elevation="m">
67
- <CardBody>
68
- <View style={styles.searchRow}>
69
- <View style={styles.search}>
70
- <Search
71
- label={t('chat.searchThreadPlaceholder')}
72
- value={query}
73
- onChangeText={setQuery}
74
- onClearText={() => setQuery('')}
75
- autoFocus
76
- returnKeyType="search"
77
- />
78
- </View>
79
- <Button
80
- size="md"
81
- appearance="plain"
82
- tone="neutral"
83
- iconOnly
84
- leadingIcon={RiCloseLine}
85
- accessibilityLabel={t('common.close')}
86
- onPress={onClose}
87
- />
88
- </View>
89
-
90
- {!asked ? (
91
- <View style={styles.hint}>
92
- <Muted>{t('chat.searchThreadHint')}</Muted>
93
- </View>
94
- ) : isError ? (
95
- <View style={styles.hint}>
96
- <Muted>{t('chat.searchThreadFailed')}</Muted>
97
- </View>
98
- ) : found.length === 0 ? (
99
- <View style={styles.hint}>
100
- <Muted>
101
- {isFetching ? t('chat.searchThreadSearching') : t('chat.searchThreadEmpty')}
102
- </Muted>
103
- </View>
104
- ) : (
105
- <ScrollView
106
- // A height in px, not a percentage of a parent that has none:
107
- // measured in Chromium, the list otherwise sized itself to its
108
- // content and spilled the results over the thread behind it.
109
- style={styles.results}
110
- keyboardShouldPersistTaps="handled"
111
- >
112
- {found.map((hit) => (
113
- <ListItem
114
- // The cursor, never `messageId`: a message the server wrote
115
- // has no client id, and `null` is not a key.
116
- key={hit.cursor}
117
- title={hit.snippet}
118
- supporting={`${t(
119
- hit.role === 'user' ? 'chat.searchThreadYou' : 'chat.searchThreadAgent',
120
- )} · ${hitDay(hit.createdAt, locale)}`}
121
- onPress={() => onJump(hit)}
122
- />
123
- ))}
124
- </ScrollView>
125
- )}
126
- </CardBody>
127
- </Card>
62
+ <ThreadPanel>
63
+ <View style={styles.searchRow}>
64
+ <View style={styles.search}>
65
+ <Search
66
+ label={t('chat.searchThreadPlaceholder')}
67
+ value={query}
68
+ onChangeText={setQuery}
69
+ onClearText={() => setQuery('')}
70
+ autoFocus
71
+ returnKeyType="search"
72
+ />
73
+ </View>
74
+ <Button
75
+ size="md"
76
+ appearance="plain"
77
+ tone="neutral"
78
+ iconOnly
79
+ leadingIcon={RiCloseLine}
80
+ accessibilityLabel={t('common.close')}
81
+ onPress={onClose}
82
+ />
128
83
  </View>
129
- </View>
84
+
85
+ {!asked ? (
86
+ <View style={styles.hint}>
87
+ <Muted>{t('chat.searchThreadHint')}</Muted>
88
+ </View>
89
+ ) : isError ? (
90
+ <View style={styles.hint}>
91
+ <Muted>{t('chat.searchThreadFailed')}</Muted>
92
+ </View>
93
+ ) : found.length === 0 ? (
94
+ <View style={styles.hint}>
95
+ <Muted>
96
+ {isFetching ? t('chat.searchThreadSearching') : t('chat.searchThreadEmpty')}
97
+ </Muted>
98
+ </View>
99
+ ) : (
100
+ <ScrollView
101
+ // A height in px, not a percentage of a parent that has none:
102
+ // measured in Chromium, the list otherwise sized itself to its
103
+ // content and spilled the results over the thread behind it.
104
+ style={styles.results}
105
+ keyboardShouldPersistTaps="handled"
106
+ >
107
+ {found.map((hit) => (
108
+ <ListItem
109
+ // The cursor, never `messageId`: a message the server wrote
110
+ // has no client id, and `null` is not a key.
111
+ key={hit.cursor}
112
+ title={hit.snippet}
113
+ supporting={`${t(
114
+ hit.role === 'user' ? 'chat.searchThreadYou' : 'chat.searchThreadAgent',
115
+ )} · ${hitDay(hit.createdAt, locale)}`}
116
+ onPress={() => onJump(hit)}
117
+ />
118
+ ))}
119
+ </ScrollView>
120
+ )}
121
+ </ThreadPanel>
130
122
  );
131
123
  };
132
124
 
133
125
  const styles = StyleSheet.create({
134
- overlay: {
135
- position: 'absolute',
136
- insetInline: 0,
137
- top: 0,
138
- zIndex: 20,
139
- paddingHorizontal: 16,
140
- paddingTop: 16,
141
- },
142
- column: { width: '100%', maxWidth: 768, alignSelf: 'center' },
143
126
  searchRow: { flexDirection: 'row', alignItems: 'center', gap: 8 },
144
127
  search: { flexGrow: 1, flexShrink: 1, flexBasis: '0%' },
145
128
  hint: { paddingHorizontal: 4, paddingVertical: 16 },
@@ -0,0 +1,94 @@
1
+ import { useAiChatChromeInsets } from '@oxy.so/bloom/ai-chat';
2
+ import { Button } from '@oxy.so/bloom/button';
3
+ import { RiCloseLine } from '@oxy.so/bloom/icons/RiCloseLine';
4
+ import { RiListUnordered } from '@oxy.so/bloom/icons/RiListUnordered';
5
+ import { ListItem } from '@oxy.so/bloom/list';
6
+ import { Muted } from '@oxy.so/bloom/typography';
7
+ import { ScrollView, StyleSheet, View } from 'react-native';
8
+ import { useLabels } from '../../lib/labels';
9
+ import type { ThreadTurn } from '../../runtime/thread/thread-find';
10
+ import { ThreadPanel } from './ThreadPanel';
11
+
12
+ /** From how many turns a thread offers its list of them without being asked for it. */
13
+ export const LONG_THREAD_TURNS = 6;
14
+
15
+ /**
16
+ * The thread's turns, newest first, each named by the question that opened it: a press lands there.
17
+ *
18
+ * A list rather than a drawn minimap: the thread mounts only a window of its rows, so there are no
19
+ * heights to draw the rest from, and a map built on guesses would land in the wrong place.
20
+ */
21
+ export function ThreadTurnList({
22
+ turns,
23
+ onJump,
24
+ onLoadEarlier,
25
+ onClose,
26
+ }: {
27
+ turns: readonly ThreadTurn[];
28
+ onJump: (messageId: string) => void;
29
+ /** Page in the history above, whose turns then join the list. Absent where there is none. */
30
+ onLoadEarlier?: () => void;
31
+ onClose: () => void;
32
+ }) {
33
+ const { t } = useLabels();
34
+ return (
35
+ <ThreadPanel>
36
+ <View style={styles.header}>
37
+ <View style={styles.title}>
38
+ <Muted>{t('chat.turns.title')}</Muted>
39
+ </View>
40
+ <Button
41
+ size="sm"
42
+ appearance="plain"
43
+ tone="neutral"
44
+ iconOnly
45
+ leadingIcon={RiCloseLine}
46
+ accessibilityLabel={t('common.close')}
47
+ onPress={onClose}
48
+ />
49
+ </View>
50
+ <ScrollView style={styles.turns} keyboardShouldPersistTaps="handled">
51
+ {[...turns].reverse().map((turn) => (
52
+ <ListItem
53
+ key={turn.id}
54
+ title={turn.preview || t('chat.turns.attachment')}
55
+ onPress={() => onJump(turn.id)}
56
+ />
57
+ ))}
58
+ {onLoadEarlier === undefined ? null : (
59
+ <Button appearance="plain" tone="neutral" size="sm" onPress={onLoadEarlier}>
60
+ {t('chat.turns.loadEarlier')}
61
+ </Button>
62
+ )}
63
+ </ScrollView>
64
+ </ThreadPanel>
65
+ );
66
+ }
67
+
68
+ /** The way to the list from a long thread: a button at its edge, under the header. */
69
+ export function ThreadTurnsButton({ onPress }: { onPress: () => void }) {
70
+ const { t } = useLabels();
71
+ // The header floats over the transcript, so the edge starts under it.
72
+ const insets = useAiChatChromeInsets();
73
+ return (
74
+ <View style={[styles.edge, { top: (insets?.top ?? 0) + 8 }]} pointerEvents="box-none">
75
+ <Button
76
+ size="sm"
77
+ appearance="outline"
78
+ tone="neutral"
79
+ iconOnly
80
+ leadingIcon={RiListUnordered}
81
+ accessibilityLabel={t('chat.turns.title')}
82
+ onPress={onPress}
83
+ />
84
+ </View>
85
+ );
86
+ }
87
+
88
+ const styles = StyleSheet.create({
89
+ header: { flexDirection: 'row', alignItems: 'center', gap: 8 },
90
+ title: { flexGrow: 1, flexShrink: 1, flexBasis: '0%', paddingHorizontal: 4 },
91
+ // A height in px, not a percentage of a parent that has none (see `ThreadSearch`).
92
+ turns: { marginTop: 8, maxHeight: 384 },
93
+ edge: { position: 'absolute', insetInlineEnd: 12, zIndex: 10 },
94
+ });
@@ -0,0 +1,52 @@
1
+ import { createTokenStyles } from '@oxy.so/bloom/theme';
2
+ import { Muted, Text } from '@oxy.so/bloom/typography';
3
+ import { View } from 'react-native';
4
+ import { useLabels } from '../../lib/labels';
5
+ import type { DiffComment } from '../../runtime/thread/diff-comments';
6
+ import { fileChangeName } from '../../runtime/thread/file-changes';
7
+ import { diffLinesLabel } from '../diff/diff-comments-context';
8
+
9
+ /**
10
+ * The diff comments a sent turn carried, drawn with it: where each one is and what it says. The
11
+ * excerpt the gemie reads is not repeated here, the diff is in the conversation above.
12
+ */
13
+ export function TurnDiffComments({
14
+ comments,
15
+ color,
16
+ }: {
17
+ comments: readonly DiffComment[];
18
+ /** The bubble's own foreground, where the turn is a painted bubble. */
19
+ color?: string;
20
+ }) {
21
+ const { t } = useLabels();
22
+ const styles = useStyles();
23
+ if (comments.length === 0) return null;
24
+ const painted = color === undefined ? null : { color };
25
+ return (
26
+ <View style={styles.comments}>
27
+ {comments.map((comment) => (
28
+ <View
29
+ key={comment.id}
30
+ style={[styles.comment, color === undefined ? null : { borderColor: color }]}
31
+ >
32
+ <Muted style={[styles.where, painted]} numberOfLines={1}>
33
+ {t('chat.diffComments.chip', {
34
+ file: fileChangeName(comment.path),
35
+ lines: diffLinesLabel(t, comment.lines),
36
+ })}
37
+ </Muted>
38
+ <Text style={[styles.text, painted]} selectable>
39
+ {comment.text}
40
+ </Text>
41
+ </View>
42
+ ))}
43
+ </View>
44
+ );
45
+ }
46
+
47
+ const useStyles = createTokenStyles((t) => ({
48
+ comments: { gap: 8, paddingBottom: 4 },
49
+ comment: { borderLeftWidth: 2, borderColor: t.border, paddingLeft: 8, gap: 2 },
50
+ where: { fontSize: 12 },
51
+ text: { fontSize: 14, lineHeight: 20 },
52
+ }));