@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,57 @@
1
+ import { Chip } from '@oxy.so/bloom/chip';
2
+ import { RiChat3Line } from '@oxy.so/bloom/icons/RiChat3Line';
3
+ import { createTokenStyles } from '@oxy.so/bloom/theme';
4
+ import { View } from 'react-native';
5
+ import { useLabels } from '../../lib/labels';
6
+ import type { DiffComment } from '../../runtime/thread/diff-comments';
7
+ import { fileChangeName } from '../../runtime/thread/file-changes';
8
+ import { diffLinesLabel } from './diff-comments-context';
9
+
10
+ /** How much of a comment its chip shows. */
11
+ const PREVIEW_CHARS = 40;
12
+
13
+ const preview = (text: string) => {
14
+ const line = text.replace(/\s+/g, ' ').trim();
15
+ return line.length > PREVIEW_CHARS ? `${line.slice(0, PREVIEW_CHARS - 1)}…` : line;
16
+ };
17
+
18
+ /**
19
+ * The diff comments the next message carries, over the composer: the file and lines each is on and
20
+ * the start of what it says, with a way to take it out.
21
+ */
22
+ export function DiffCommentChips({
23
+ comments,
24
+ onRemove,
25
+ }: {
26
+ comments: readonly DiffComment[];
27
+ onRemove: (id: string) => void;
28
+ }) {
29
+ const { t } = useLabels();
30
+ const styles = useStyles();
31
+ if (comments.length === 0) return null;
32
+ return (
33
+ <View style={styles.chips}>
34
+ {comments.map((comment) => {
35
+ const where = {
36
+ file: fileChangeName(comment.path),
37
+ lines: diffLinesLabel(t, comment.lines),
38
+ };
39
+ return (
40
+ <Chip
41
+ key={comment.id}
42
+ size="sm"
43
+ leadingIcon={RiChat3Line}
44
+ onClose={() => onRemove(comment.id)}
45
+ closeLabel={t('chat.diffComments.removeFrom', where)}
46
+ >
47
+ {`${t('chat.diffComments.chip', where)} · ${preview(comment.text)}`}
48
+ </Chip>
49
+ );
50
+ })}
51
+ </View>
52
+ );
53
+ }
54
+
55
+ const useStyles = createTokenStyles(() => ({
56
+ chips: { flexDirection: 'row', flexWrap: 'wrap', gap: 6, paddingHorizontal: 8, paddingBottom: 8 },
57
+ }));
@@ -9,8 +9,9 @@ import { View } from 'react-native';
9
9
  import { copyText } from '../../lib/clipboard';
10
10
  import { useLabels } from '../../lib/labels';
11
11
  import { type CallFileChange, patchLines } from '../../runtime/thread/file-changes';
12
+ import { AnnotatedPatch } from './AnnotatedPatch';
13
+ import type { DiffCommentsDraft } from './diff-comments-context';
12
14
  import type { DiffLayout, GemieFileDiffRenderer } from './diff-renderer';
13
- import { PatchLines } from './PatchLines';
14
15
 
15
16
  const MARK = { add: 'A', update: 'M', delete: 'D', rename: 'R' } as const;
16
17
 
@@ -40,6 +41,8 @@ export interface FileChangeSectionProps {
40
41
  wrap: boolean;
41
42
  /** The host's drawing of a patch; the SDK's plain lines when it brought none. */
42
43
  renderer: GemieFileDiffRenderer | null;
44
+ /** The comments of the message being written; `null` where nothing takes them. */
45
+ draft: DiffCommentsDraft | null;
43
46
  }
44
47
 
45
48
  /**
@@ -54,6 +57,7 @@ export function FileChangeSection({
54
57
  layout,
55
58
  wrap,
56
59
  renderer,
60
+ draft,
57
61
  }: FileChangeSectionProps) {
58
62
  const { t } = useLabels();
59
63
  const { isDark, colors } = useTheme();
@@ -110,6 +114,7 @@ export function FileChangeSection({
110
114
  layout={layout}
111
115
  wrap={wrap}
112
116
  renderer={renderer}
117
+ draft={draft}
113
118
  appearance={isDark ? 'dark' : 'light'}
114
119
  />
115
120
  </View>
@@ -124,12 +129,14 @@ function ChangeBody({
124
129
  layout,
125
130
  wrap,
126
131
  renderer,
132
+ draft,
127
133
  appearance,
128
134
  }: {
129
135
  change: CallFileChange;
130
136
  layout: DiffLayout;
131
137
  wrap: boolean;
132
138
  renderer: GemieFileDiffRenderer | null;
139
+ draft: DiffCommentsDraft | null;
133
140
  appearance: 'light' | 'dark';
134
141
  }) {
135
142
  const { t } = useLabels();
@@ -147,15 +154,15 @@ function ChangeBody({
147
154
  if (change.additions === 0 && change.deletions === 0 && patchLines(change.patch).length === 0) {
148
155
  return say('chat.fileChanges.noContent');
149
156
  }
150
- if (renderer === null) return <PatchLines patch={change.patch} wrap={wrap} />;
151
- const { PatchView } = renderer;
152
157
  return (
153
- <PatchView
158
+ <AnnotatedPatch
154
159
  patch={change.patch}
155
160
  path={change.path}
156
- layout={renderer.layouts.includes(layout) ? layout : 'unified'}
161
+ layout={layout}
157
162
  wrap={wrap}
158
163
  appearance={appearance}
164
+ renderer={renderer}
165
+ draft={draft}
159
166
  />
160
167
  );
161
168
  }
@@ -9,10 +9,13 @@ import {
9
9
  SegmentedControlItemText,
10
10
  } from '@oxy.so/bloom/segmented-control';
11
11
  import { createTokenStyles } from '@oxy.so/bloom/theme';
12
+ import { Muted } from '@oxy.so/bloom/typography';
12
13
  import { useMemo, useState } from 'react';
13
14
  import { View } from 'react-native';
14
15
  import { useLabels } from '../../lib/labels';
16
+ import { type DiffComment, diffCommentsOn } from '../../runtime/thread/diff-comments';
15
17
  import { type CallFileChange, fileChangeTotals } from '../../runtime/thread/file-changes';
18
+ import { useDiffCommentsDraft } from './diff-comments-context';
16
19
  import { type DiffLayout, useFileDiffRenderer } from './diff-renderer';
17
20
  import { FileChangeSection } from './FileChangeSection';
18
21
 
@@ -23,13 +26,21 @@ import { FileChangeSection } from './FileChangeSection';
23
26
  */
24
27
  export const OPEN_LINE_BUDGET = 600;
25
28
 
26
- /** The sections that start open: in order, until the budget of lines is spent. */
27
- export function initiallyOpen(changes: readonly CallFileChange[]): Set<string> {
29
+ /**
30
+ * The sections that start open: in order, until the budget of lines is spent, and any holding a
31
+ * comment of the message being written.
32
+ */
33
+ export function initiallyOpen(
34
+ changes: readonly CallFileChange[],
35
+ comments: readonly DiffComment[] = [],
36
+ ): Set<string> {
28
37
  const open = new Set<string>();
29
38
  let spent = 0;
30
39
  for (const change of changes) {
40
+ if (change.patch === undefined || change.binary) continue;
41
+ if (diffCommentsOn(comments, change.path, change.patch).length > 0) open.add(change.key);
31
42
  const size = change.additions + change.deletions;
32
- if (change.patch === undefined || change.binary || spent + size > OPEN_LINE_BUDGET) continue;
43
+ if (spent + size > OPEN_LINE_BUDGET) continue;
33
44
  spent += size;
34
45
  open.add(change.key);
35
46
  }
@@ -45,14 +56,16 @@ export interface FileChangesViewerProps {
45
56
  /**
46
57
  * The files an agent changed, as a sheet (a panel on a wide screen): each file a section that folds,
47
58
  * with a unified/split choice where the host's renderer has both, line wrapping, and fold or open
48
- * every file at once.
59
+ * every file at once. Where a composer is listening (`DiffCommentsProvider`), the lines take
60
+ * comments that go with the next message.
49
61
  */
50
62
  export function FileChangesViewer({ changes, open, onClose }: FileChangesViewerProps) {
51
63
  const { t } = useLabels();
52
64
  const styles = useStyles();
53
65
  const renderer = useFileDiffRenderer();
66
+ const draft = useDiffCommentsDraft();
54
67
  const totals = useMemo(() => fileChangeTotals(changes), [changes]);
55
- const [opened, setOpened] = useState(() => initiallyOpen(changes));
68
+ const [opened, setOpened] = useState(() => initiallyOpen(changes, draft?.comments));
56
69
  const [layout, setLayout] = useState<DiffLayout>('unified');
57
70
  const [wrap, setWrap] = useState(false);
58
71
  const allOpen = changes.every((change) => opened.has(change.key));
@@ -107,6 +120,7 @@ export function FileChangesViewer({ changes, open, onClose }: FileChangesViewerP
107
120
  {allOpen ? t('chat.fileChanges.collapseAll') : t('chat.fileChanges.expandAll')}
108
121
  </Button>
109
122
  </View>
123
+ {draft === null ? null : <Muted style={styles.hint}>{t('chat.diffComments.hint')}</Muted>}
110
124
  <View>
111
125
  {changes.map((change) => (
112
126
  <FileChangeSection
@@ -117,6 +131,7 @@ export function FileChangesViewer({ changes, open, onClose }: FileChangesViewerP
117
131
  layout={layout}
118
132
  wrap={wrap}
119
133
  renderer={renderer}
134
+ draft={draft}
120
135
  />
121
136
  ))}
122
137
  </View>
@@ -132,4 +147,5 @@ const useStyles = createTokenStyles(() => ({
132
147
  gap: 8,
133
148
  paddingBottom: 12,
134
149
  },
150
+ hint: { fontSize: 12, paddingBottom: 8 },
135
151
  }));
@@ -1,9 +1,14 @@
1
1
  import { Button } from '@oxy.so/bloom/button';
2
2
  import { createTokenStyles } from '@oxy.so/bloom/theme';
3
3
  import { Text } from '@oxy.so/bloom/typography';
4
- import { useMemo, useState } from 'react';
5
- import { Platform, ScrollView, View } from 'react-native';
4
+ import { type ReactNode, useMemo, useState } from 'react';
5
+ import { Platform, Pressable, ScrollView, View } from 'react-native';
6
6
  import { useLabels } from '../../lib/labels';
7
+ import {
8
+ type DiffLinePoint,
9
+ diffLinePoint,
10
+ selectDiffLines,
11
+ } from '../../runtime/thread/diff-comments';
7
12
  import { type PatchLine, patchLines } from '../../runtime/thread/file-changes';
8
13
  import type { GemiePatchViewProps } from './diff-renderer';
9
14
 
@@ -28,25 +33,88 @@ function digitsOf(lines: readonly PatchLine[]): number {
28
33
 
29
34
  const SIGN = { add: '+', delete: '−', context: ' ' } as const;
30
35
 
36
+ const pointKey = ({ side, line }: DiffLinePoint) => `${side}:${line}`;
37
+
38
+ type PatchLinesProps = Pick<GemiePatchViewProps, 'patch' | 'wrap'> &
39
+ Partial<Pick<GemiePatchViewProps, 'annotations' | 'selection' | 'onSelectLines'>>;
40
+
41
+ /** The rows `selection` covers, as places in `lines`; none when it is not of this patch. */
42
+ function selectedRows(
43
+ patch: string,
44
+ lines: readonly PatchLine[],
45
+ selection: PatchLinesProps['selection'],
46
+ ): { first: number; last: number } | null {
47
+ const picked = selection ? selectDiffLines(patch, selection) : null;
48
+ if (picked === null) return null;
49
+ const at = (point: DiffLinePoint) =>
50
+ lines.findIndex(
51
+ (line) =>
52
+ line.kind !== 'hunk' &&
53
+ line.kind !== 'note' &&
54
+ pointKey(diffLinePoint(line)) === pointKey(point),
55
+ );
56
+ return { first: at(picked.range.from), last: at(picked.range.to) };
57
+ }
58
+
31
59
  /**
32
60
  * One file's patch as monospace lines, with its line numbers and the added and removed lines
33
61
  * tinted: the SDK's own drawing of a patch, which draws on every platform and needs nothing
34
62
  * installed. Drawn a page at a time, so a large patch costs what the person has read.
63
+ *
64
+ * Where it takes comments, a line number picks its line, and a second one picked while the first
65
+ * is marked extends the run to it.
35
66
  */
36
- export function PatchLines({ patch, wrap }: Pick<GemiePatchViewProps, 'patch' | 'wrap'>) {
67
+ export function PatchLines({
68
+ patch,
69
+ wrap,
70
+ annotations,
71
+ selection,
72
+ onSelectLines,
73
+ }: PatchLinesProps) {
37
74
  const { t } = useLabels();
38
75
  const styles = useStyles();
39
76
  const lines = useMemo(() => patchLines(patch), [patch]);
40
77
  const [shown, setShown] = useState(PATCH_LINES_PAGE);
41
- const rows = lines.slice(0, shown);
78
+ const under = useMemo(
79
+ () => new Map(annotations?.map(({ at, content }) => [pointKey(at), content])),
80
+ [annotations],
81
+ );
82
+ // An annotated line is drawn however far down the patch it is.
83
+ const annotatedThrough = lines.reduce(
84
+ (through, line, index) =>
85
+ line.kind !== 'hunk' && line.kind !== 'note' && under.has(pointKey(diffLinePoint(line)))
86
+ ? index + 1
87
+ : through,
88
+ 0,
89
+ );
90
+ const visible = Math.max(shown, annotatedThrough);
91
+ const rows = lines.slice(0, visible);
42
92
  const gutter = digitsOf(lines);
93
+ const marked = useMemo(() => selectedRows(patch, lines, selection), [patch, lines, selection]);
94
+ const pick =
95
+ onSelectLines === undefined
96
+ ? undefined
97
+ : (point: DiffLinePoint) =>
98
+ onSelectLines({ from: selection ? selection.from : point, to: point });
43
99
 
44
100
  const body = (
45
101
  <View style={wrap ? styles.wrapped : undefined}>
46
102
  {rows.map((line, index) => (
47
- // A patch's lines never reorder: their place in it is their identity.
48
- // biome-ignore lint/suspicious/noArrayIndexKey: see above
49
- <Row key={`${index}:${line.kind}`} line={line} gutter={gutter} wrap={wrap} />
103
+ <Row
104
+ // A patch's lines never reorder: their place in it is their identity.
105
+ // biome-ignore lint/suspicious/noArrayIndexKey: see above
106
+ key={`${index}:${line.kind}`}
107
+ line={line}
108
+ gutter={gutter}
109
+ wrap={wrap}
110
+ selected={marked !== null && index >= marked.first && index <= marked.last}
111
+ onPick={pick}
112
+ annotation={
113
+ line.kind === 'hunk' || line.kind === 'note'
114
+ ? undefined
115
+ : under.get(pointKey(diffLinePoint(line)))
116
+ }
117
+ />
50
118
  ))}
51
119
  </View>
52
120
  );
@@ -54,15 +122,15 @@ export function PatchLines({ patch, wrap }: Pick<GemiePatchViewProps, 'patch' |
54
122
  return (
55
123
  <View>
56
124
  {wrap ? body : <ScrollView horizontal>{body}</ScrollView>}
57
- {lines.length > shown ? (
125
+ {lines.length > visible ? (
58
126
  <View style={styles.more}>
59
127
  <Button
60
128
  size="sm"
61
129
  appearance="outline"
62
130
  tone="neutral"
63
- onPress={() => setShown((count) => count + PATCH_LINES_PAGE)}
131
+ onPress={() => setShown(visible + PATCH_LINES_PAGE)}
64
132
  >
65
- {t('chat.fileChanges.showMore', { count: lines.length - shown })}
133
+ {t('chat.fileChanges.showMore', { count: lines.length - visible })}
66
134
  </Button>
67
135
  </View>
68
136
  ) : null}
@@ -70,7 +138,22 @@ export function PatchLines({ patch, wrap }: Pick<GemiePatchViewProps, 'patch' |
70
138
  );
71
139
  }
72
140
 
73
- function Row({ line, gutter, wrap }: { line: PatchLine; gutter: number; wrap: boolean }) {
141
+ function Row({
142
+ line,
143
+ gutter,
144
+ wrap,
145
+ selected,
146
+ onPick,
147
+ annotation,
148
+ }: {
149
+ line: PatchLine;
150
+ gutter: number;
151
+ wrap: boolean;
152
+ selected: boolean;
153
+ onPick: ((point: DiffLinePoint) => void) | undefined;
154
+ annotation: ReactNode;
155
+ }) {
156
+ const { t } = useLabels();
74
157
  const styles = useStyles();
75
158
  if (line.kind === 'hunk' || line.kind === 'note') {
76
159
  return (
@@ -80,21 +163,46 @@ function Row({ line, gutter, wrap }: { line: PatchLine; gutter: number; wrap: bo
80
163
  );
81
164
  }
82
165
  const number = line.kind === 'delete' ? line.oldLine : line.newLine;
83
- return (
166
+ const numberText = (
167
+ <Text style={[styles.number, { minWidth: gutter * 9 + 12 }]}>{number ?? ''}</Text>
168
+ );
169
+ const row = (
84
170
  <View
85
171
  style={[
86
172
  styles.row,
87
173
  line.kind === 'add' ? styles.added : null,
88
174
  line.kind === 'delete' ? styles.removed : null,
175
+ selected ? styles.selected : null,
89
176
  ]}
90
177
  >
91
- <Text style={[styles.number, { minWidth: gutter * 9 + 12 }]}>{number ?? ''}</Text>
178
+ {onPick === undefined ? (
179
+ numberText
180
+ ) : (
181
+ <Pressable
182
+ onPress={() => onPick(diffLinePoint(line))}
183
+ accessibilityRole="button"
184
+ accessibilityLabel={t(
185
+ `chat.diffComments.comment.${line.kind === 'delete' ? 'removed' : 'current'}`,
186
+ { line: number },
187
+ )}
188
+ accessibilityState={{ selected }}
189
+ >
190
+ {numberText}
191
+ </Pressable>
192
+ )}
92
193
  <Text style={styles.sign}>{SIGN[line.kind]}</Text>
93
194
  <Text style={[styles.code, wrap ? styles.codeWrapped : null]} selectable>
94
195
  {line.text === '' ? ' ' : line.text}
95
196
  </Text>
96
197
  </View>
97
198
  );
199
+ if (annotation === undefined) return row;
200
+ return (
201
+ <View>
202
+ {row}
203
+ <View style={styles.annotation}>{annotation}</View>
204
+ </View>
205
+ );
98
206
  }
99
207
 
100
208
  const useStyles = createTokenStyles((t) => ({
@@ -116,4 +224,7 @@ const useStyles = createTokenStyles((t) => ({
116
224
  code: { fontFamily: MONO, fontSize: 12, lineHeight: 18, color: t.foreground },
117
225
  codeWrapped: { flexShrink: 1, flexGrow: 1, flexBasis: '0%' },
118
226
  more: { alignItems: 'center', paddingVertical: 8 },
227
+ selected: { backgroundColor: t.accent },
228
+ // Beside a patch that scrolls sideways there is no width to fill, so the note keeps its own.
229
+ annotation: { width: '100%', minWidth: 280, maxWidth: 560 },
119
230
  }));
@@ -0,0 +1,29 @@
1
+ import { createContext, useContext } from 'react';
2
+ import type { Translate } from '../../lib/copy';
3
+ import type { DiffComment, DiffLineSpan } from '../../runtime/thread/diff-comments';
4
+
5
+ /** The comments of the message being written, and how the diff viewer changes them. */
6
+ export interface DiffCommentsDraft {
7
+ comments: readonly DiffComment[];
8
+ add: (comment: DiffComment) => void;
9
+ remove: (id: string) => void;
10
+ }
11
+
12
+ const DiffCommentsContext = createContext<DiffCommentsDraft | null>(null);
13
+
14
+ /**
15
+ * Makes the diff viewers under it take comments, into this draft. A thread with no composer (a
16
+ * shared conversation, one between gemies) has no provider, and its viewers only show the changes.
17
+ */
18
+ export const DiffCommentsProvider = DiffCommentsContext.Provider;
19
+
20
+ export function useDiffCommentsDraft(): DiffCommentsDraft | null {
21
+ return useContext(DiffCommentsContext);
22
+ }
23
+
24
+ /** "Line 4", "Lines 3–5", or the same of removed lines. */
25
+ export function diffLinesLabel(t: Translate, { side, start, end }: DiffLineSpan): string {
26
+ const span = start === end ? 'line' : 'lines';
27
+ const kind = side === 'old' ? 'removed' : 'current';
28
+ return t(`chat.diffComments.${kind}.${span}`, { line: start, start, end });
29
+ }
@@ -1,8 +1,15 @@
1
- import { type ComponentType, createContext, useContext } from 'react';
1
+ import { type ComponentType, createContext, type ReactNode, useContext } from 'react';
2
+ import type { DiffLinePoint, DiffLineRange } from '../../runtime/thread/diff-comments';
2
3
 
3
4
  /** How a file's changes are laid out: one column of lines, or the old and new side by side. */
4
5
  export type DiffLayout = 'unified' | 'split';
5
6
 
7
+ /** Something drawn under one line of a patch: its comments, or the one being written. */
8
+ export interface GemieDiffAnnotation {
9
+ at: DiffLinePoint;
10
+ content: ReactNode;
11
+ }
12
+
6
13
  export interface GemiePatchViewProps {
7
14
  /** One file's unified patch (`diff --git` headers, then its hunks). */
8
15
  patch: string;
@@ -13,6 +20,15 @@ export interface GemiePatchViewProps {
13
20
  wrap: boolean;
14
21
  /** The theme the person reads in. */
15
22
  appearance: 'light' | 'dark';
23
+ /** What to draw under its lines; one entry a line. */
24
+ annotations: readonly GemieDiffAnnotation[];
25
+ /** The lines being commented on, to mark them. */
26
+ selection: DiffLineRange | null;
27
+ /**
28
+ * The person picked lines to comment on, in either order. Absent where nothing takes comments:
29
+ * the lines are then not selectable.
30
+ */
31
+ onSelectLines?: (range: DiffLineRange) => void;
16
32
  }
17
33
 
18
34
  /**
@@ -0,0 +1,35 @@
1
+ import { RiTimeLine } from '@oxy.so/bloom/icons/RiTimeLine';
2
+ import { Muted } from '@oxy.so/bloom/typography';
3
+ import { StyleSheet, View } from 'react-native';
4
+ import { useLabels } from '../../lib/labels';
5
+
6
+ /**
7
+ * Where something the person wrote is, when it is not in the thread being answered yet:
8
+ *
9
+ * - `queued`: the first message of a conversation just created, waiting for the thread to send it;
10
+ * - `steering`: a reply to the waiting agent on its way into the turn that is running.
11
+ */
12
+ export type FollowUpState = 'queued' | 'steering';
13
+
14
+ /** One line above the composer, said while it is true and gone with it. */
15
+ export function FollowUpStatus({ state, agent }: { state: FollowUpState; agent: string }) {
16
+ const { t } = useLabels();
17
+ return (
18
+ <View style={styles.row} accessibilityLiveRegion="polite" aria-live="polite">
19
+ <RiTimeLine size="sm" />
20
+ <Muted>
21
+ {state === 'queued' ? t('chat.followUp.queued') : t('chat.followUp.steering', { agent })}
22
+ </Muted>
23
+ </View>
24
+ );
25
+ }
26
+
27
+ const styles = StyleSheet.create({
28
+ row: {
29
+ flexDirection: 'row',
30
+ alignItems: 'center',
31
+ gap: 8,
32
+ paddingHorizontal: 16,
33
+ paddingBottom: 8,
34
+ },
35
+ });
@@ -19,7 +19,9 @@ import { useMessageVote } from '../../hooks/useMessageVote';
19
19
  import { useMessageReactions } from '../../hooks/useMessageReactions';
20
20
  import { useOpenThought } from '../../hooks/useOpenThought';
21
21
  import { useReadAloud } from '../../hooks/useReadAloud';
22
+ import { FIND_BAR_CLEARANCE, useRowJump } from '../../hooks/useRowJump';
22
23
  import { useThoughtScope } from '../../hooks/useThoughtScope';
24
+ import type { ThreadJumpTarget } from '../../hooks/useThreadNavigation';
23
25
  import { useThreadRows } from '../../hooks/useThreadRows';
24
26
  import { useTimelineWindow } from '../../hooks/useTimelineWindow';
25
27
  import { useAgentRunFailureToast } from '../../hooks/useAgentRunFailureToast';
@@ -73,6 +75,10 @@ export interface GemieThreadProps {
73
75
  * any list — leaves the reader twenty messages past the thing they searched for.
74
76
  */
75
77
  focusCursor?: string | null;
78
+ /** A row to bring into view: a match of the find bar, or a turn picked from the list. */
79
+ jumpTo?: ThreadJumpTarget | null;
80
+ /** The message marked as the find bar's current match. */
81
+ highlightedId?: string | null;
76
82
  /**
77
83
  * The turn that got no answer. It is told with a toast and a Retry, and the person's message
78
84
  * stays in the thread.
@@ -143,6 +149,8 @@ export const GemieThread = memo(function GemieThread({
143
149
  conversationLoading = false,
144
150
  history: historyProps,
145
151
  focusCursor,
152
+ jumpTo,
153
+ highlightedId,
146
154
  failedTurn = null,
147
155
  onRetryTurn,
148
156
  onRegenerate,
@@ -282,6 +290,16 @@ export const GemieThread = memo(function GemieThread({
282
290
  onLoadHistory: loadMore,
283
291
  onScroll,
284
292
  });
293
+ // While a match is marked the find bar floats over the top: the list holds that room open, so
294
+ // even the first row can be brought out from under it.
295
+ const clearance = highlightedId == null ? 0 : FIND_BAR_CLEARANCE;
296
+ const { listRef, registerRow } = useRowJump({
297
+ clearance,
298
+ target: jumpTo,
299
+ ids,
300
+ reveal: timeline.reveal,
301
+ threadRef,
302
+ });
285
303
 
286
304
  const nothingToShow =
287
305
  rows.length === 0 && !conversationLoading && !isLoading && !loadingHistory && !voiceThinking;
@@ -323,6 +341,8 @@ export const GemieThread = memo(function GemieThread({
323
341
  isLoading={isLastReply ? isLoading : false}
324
342
  conversationId={conversationOf(index)}
325
343
  onLayout={index === focusIndex ? handleFocusLayout : undefined}
344
+ registerRow={registerRow}
345
+ highlighted={message.id === highlightedId}
326
346
  actions={actions}
327
347
  readAloudState={readAloud.stateOf(message.id)}
328
348
  readAloudBlocked={readAloud.blocked}
@@ -373,7 +393,11 @@ export const GemieThread = memo(function GemieThread({
373
393
  <View style={styles.column}>
374
394
  {rows.length === 0 && conversationLoading ? <ThreadSkeleton /> : null}
375
395
 
376
- <View style={styles.list} onLayout={timeline.onListLayout}>
396
+ <View
397
+ ref={listRef}
398
+ style={clearance === 0 ? styles.list : [styles.list, { paddingTop: clearance }]}
399
+ onLayout={timeline.onListLayout}
400
+ >
377
401
  {/* The slot the history loader shows in, held open for as long as there is history to
378
402
  load. The thread anchors ONE growth per request — the first after
379
403
  `onStartReached` — so a loader that appeared on request would spend that anchor on