@gemies/sdk 10.8.0 → 10.9.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.
- package/CHANGELOG.md +20 -0
- package/README.md +4 -0
- package/package.json +1 -1
- package/src/components/GemieChatContent.tsx +82 -3
- package/src/components/GemieComposer.tsx +4 -0
- package/src/components/thread/FollowUpStatus.tsx +35 -0
- package/src/components/thread/GemieThread.tsx +25 -1
- package/src/components/thread/ThreadFindBar.tsx +121 -0
- package/src/components/thread/ThreadPanel.tsx +34 -0
- package/src/components/thread/ThreadRow.tsx +44 -9
- package/src/components/thread/ThreadSearch.tsx +61 -78
- package/src/components/thread/ThreadTurns.tsx +94 -0
- package/src/hooks/useFindShortcut.ts +57 -0
- package/src/hooks/useRowJump.ts +79 -0
- package/src/hooks/useThreadNavigation.ts +134 -0
- package/src/hooks/useTimelineWindow.ts +18 -1
- package/src/lib/copy-en.ts +11 -0
- package/src/lib/copy-es.ts +11 -0
- package/src/runtime/thread/thread-find.ts +95 -0
- package/src/runtime/use-approval-actions.ts +7 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @gemies/sdk
|
|
2
2
|
|
|
3
|
+
## 10.9.0
|
|
4
|
+
|
|
5
|
+
### Find, jump to a turn, and where a follow-up is
|
|
6
|
+
|
|
7
|
+
- **Find in the conversation.** `GemieChatState.openFind` (⌘F on a Mac, Ctrl+F elsewhere on web)
|
|
8
|
+
opens a bar that searches the words the loaded messages show, whatever their case or accents,
|
|
9
|
+
starting on the newest match. Enter goes to the one above, Shift+Enter below, Escape closes. The
|
|
10
|
+
current match is outlined and scrolled to, above the mounted window too. History not paged in yet
|
|
11
|
+
is not searched, and the bar says so; `openSearch` still searches a whole thread on the server.
|
|
12
|
+
While a chat on screen offers find, the browser's own does not open (it cannot see unmounted rows).
|
|
13
|
+
- **Jump to a turn.** `GemieChatState.openTurns` lists the questions, newest first, and a thread of
|
|
14
|
+
six turns or more has a button for it at its edge.
|
|
15
|
+
- **Where a follow-up is.** A line over the composer says when a new conversation's first message is
|
|
16
|
+
waiting to be sent, and when a reply to a waiting agent is on its way. `GemieComposer` takes it as
|
|
17
|
+
`followUp`, and `ApprovalActions` gained `steering`.
|
|
18
|
+
- A shared (`readOnly`) conversation's replies can be copied.
|
|
19
|
+
- The thread's search and the new panels open under the floating header rather than behind it.
|
|
20
|
+
- New words: `chat.find.*`, `chat.followUp.*`, `chat.turns.*` (en, es). A host with its own `t`
|
|
21
|
+
adds them.
|
|
22
|
+
|
|
3
23
|
## 10.8.0
|
|
4
24
|
|
|
5
25
|
### A plan to keep, and a question answered by keyboard
|
package/README.md
CHANGED
|
@@ -304,6 +304,10 @@ history with the scroll that goes with it; and the card of an agent's run. What
|
|
|
304
304
|
around it, never in it (`tests/components/thread/one-thread.test.tsx` mounts it both ways and
|
|
305
305
|
holds the rows equal, and fails if anything else imports Bloom's thread).
|
|
306
306
|
|
|
307
|
+
Every chat can be moved around in: `state.openFind` finds words in the loaded messages (⌘F or
|
|
308
|
+
Ctrl+F on web, taken only while a chat offers it) and `state.openTurns` lists the turns to jump to.
|
|
309
|
+
A host draws the two where it draws its other chat actions.
|
|
310
|
+
|
|
307
311
|
An agent's permanent thread is `threadHandle`: the conversations behind the open one are paged in
|
|
308
312
|
above it, the thread can be searched (`state.openSearch`), and a hit opens the stretch around it.
|
|
309
313
|
Those routes (`/agents/thread/:handle/…`) answer Alia's own origins only, as `/conversations` did
|
package/package.json
CHANGED
|
@@ -48,9 +48,11 @@ import type { SharedValue } from 'react-native-reanimated';
|
|
|
48
48
|
import { useAmbientWave } from '../hooks/useAmbientWave';
|
|
49
49
|
import { useAtBottom } from '../hooks/useAtBottom';
|
|
50
50
|
import { type GemieTurn, useChatComposer } from '../hooks/useChatComposer';
|
|
51
|
+
import { useFindShortcut } from '../hooks/useFindShortcut';
|
|
51
52
|
import { type GemieVoiceOptions, useChatVoice } from '../hooks/useChatVoice';
|
|
52
53
|
import { useAttachMenu } from '../hooks/useAttachMenu';
|
|
53
54
|
import { usePendingQuestions } from '../hooks/usePendingQuestions';
|
|
55
|
+
import { useThreadNavigation } from '../hooks/useThreadNavigation';
|
|
54
56
|
import { useThreadView } from '../hooks/useThreadView';
|
|
55
57
|
import { useTTS } from '../hooks/useTTS';
|
|
56
58
|
import { BubblesProvider } from '../lib/bubbles';
|
|
@@ -72,6 +74,7 @@ import { type DeviceModel, buildPowerLevelOptions } from '../lib/power-level-opt
|
|
|
72
74
|
import { GEMIE_FEATURES, featureOffer, useAgentFeatures, useAgentProfile } from '../runtime/agents';
|
|
73
75
|
import { type GemieRuntimeHost, GemieRuntimeProvider, useGemieRuntime } from '../runtime/config';
|
|
74
76
|
import { type GemieHostTools, APP_SLUG } from '../runtime/host-tools';
|
|
77
|
+
import { useConversationStore } from '../runtime/conversation-store';
|
|
75
78
|
import { useCreateConversation } from '../runtime/conversations';
|
|
76
79
|
import { useRefreshGemieThread } from '../runtime/use-gemie-thread';
|
|
77
80
|
import type { GemieThreadAddress } from '../runtime/routes';
|
|
@@ -87,8 +90,11 @@ import { GemieWelcomeMessage } from './GemieWelcomeMessage';
|
|
|
87
90
|
import { AmbientField } from './AmbientField';
|
|
88
91
|
import { InertWhen } from './InertWhen';
|
|
89
92
|
import { GemieBetweenGemies } from './GemieBetweenGemies';
|
|
93
|
+
import { FollowUpStatus } from './thread/FollowUpStatus';
|
|
90
94
|
import { GemieThread } from './thread/GemieThread';
|
|
95
|
+
import { ThreadFindBar } from './thread/ThreadFindBar';
|
|
91
96
|
import { ThreadSearch } from './thread/ThreadSearch';
|
|
97
|
+
import { LONG_THREAD_TURNS, ThreadTurnList, ThreadTurnsButton } from './thread/ThreadTurns';
|
|
92
98
|
import { VoiceModeIcon } from './VoiceModeIcon';
|
|
93
99
|
import { VoiceCallContext } from './voice/VoiceCallContext';
|
|
94
100
|
import { createTokenStyles } from '@oxy.so/bloom/theme';
|
|
@@ -116,6 +122,10 @@ export interface GemieChatState {
|
|
|
116
122
|
participants: GemieChatParticipants;
|
|
117
123
|
/** Search what was said in the agent's thread. Present only on a thread (`threadHandle`, `gemieThread`). */
|
|
118
124
|
openSearch: (() => void) | undefined;
|
|
125
|
+
/** Find words in the conversation on screen (⌘F / Ctrl+F on web). Present once there is something to find. */
|
|
126
|
+
openFind: (() => void) | undefined;
|
|
127
|
+
/** The list of the conversation's turns, each a jump to it. Present once there is a turn. */
|
|
128
|
+
openTurns: (() => void) | undefined;
|
|
119
129
|
/** The conversation as it stands now, for an export. Read when called, not when rendered. */
|
|
120
130
|
getMessages: () => readonly Message[];
|
|
121
131
|
}
|
|
@@ -705,6 +715,49 @@ function GemieConversationView({
|
|
|
705
715
|
if (sent) composer.setText('');
|
|
706
716
|
}, [approvals, composer, decliningOption]);
|
|
707
717
|
|
|
718
|
+
// ── Moving around a long thread: find, and the list of turns ──
|
|
719
|
+
const showsPast = view.jumped;
|
|
720
|
+
const pastMessages = view.history?.messages;
|
|
721
|
+
/** What the thread draws, oldest first: the history behind it, then the conversation. */
|
|
722
|
+
const threadRows = useMemo<Message[]>(
|
|
723
|
+
() => [
|
|
724
|
+
...(pastMessages ?? []),
|
|
725
|
+
// Nothing live under a window: it is a view of the past.
|
|
726
|
+
...(showsPast ? [] : messages.filter((m) => m.role === 'user' || m.role === 'assistant')),
|
|
727
|
+
],
|
|
728
|
+
[pastMessages, showsPast, messages],
|
|
729
|
+
);
|
|
730
|
+
const navigation = useThreadNavigation(threadRows, conversationId);
|
|
731
|
+
const { openFind, openTurns, close: closeNavigation } = navigation;
|
|
732
|
+
const { closeSearch, openSearch: openThreadSearch } = view;
|
|
733
|
+
// One thing over the thread at a time.
|
|
734
|
+
const findInThread = useCallback(() => {
|
|
735
|
+
closeSearch();
|
|
736
|
+
openFind();
|
|
737
|
+
}, [closeSearch, openFind]);
|
|
738
|
+
const listTurns = useCallback(() => {
|
|
739
|
+
closeSearch();
|
|
740
|
+
openTurns();
|
|
741
|
+
}, [closeSearch, openTurns]);
|
|
742
|
+
const searchThread = useCallback(() => {
|
|
743
|
+
closeNavigation();
|
|
744
|
+
openThreadSearch();
|
|
745
|
+
}, [closeNavigation, openThreadSearch]);
|
|
746
|
+
const turnCount = useMemo(
|
|
747
|
+
() => threadRows.reduce((count, m) => (m.role === 'user' ? count + 1 : count), 0),
|
|
748
|
+
[threadRows],
|
|
749
|
+
);
|
|
750
|
+
const canFind = threadRows.length > 0;
|
|
751
|
+
const canList = turnCount > 0;
|
|
752
|
+
useFindShortcut(canFind && isFocused && betweenGemies === null ? findInThread : undefined);
|
|
753
|
+
|
|
754
|
+
// A message not yet in a turn being answered: said above the composer while that is so.
|
|
755
|
+
const queued = useConversationStore(
|
|
756
|
+
(s) =>
|
|
757
|
+
conversationId !== undefined && s.pendingInitialMessage?.conversationId === conversationId,
|
|
758
|
+
);
|
|
759
|
+
const followUp = approvals.steering.size > 0 ? 'steering' : queued ? 'queued' : undefined;
|
|
760
|
+
|
|
708
761
|
// ── The chrome ──
|
|
709
762
|
const latestMessages = useRef(messages);
|
|
710
763
|
latestMessages.current = messages;
|
|
@@ -717,7 +770,9 @@ function GemieConversationView({
|
|
|
717
770
|
clearMessages: clearConversation,
|
|
718
771
|
markState: voice.markState,
|
|
719
772
|
participants,
|
|
720
|
-
openSearch: threadAddress === undefined ? undefined :
|
|
773
|
+
openSearch: threadAddress === undefined ? undefined : searchThread,
|
|
774
|
+
openFind: canFind ? findInThread : undefined,
|
|
775
|
+
openTurns: canList ? listTurns : undefined,
|
|
721
776
|
getMessages: () => latestMessages.current,
|
|
722
777
|
}),
|
|
723
778
|
[
|
|
@@ -728,7 +783,11 @@ function GemieConversationView({
|
|
|
728
783
|
voice.markState,
|
|
729
784
|
participants,
|
|
730
785
|
threadAddress,
|
|
731
|
-
|
|
786
|
+
searchThread,
|
|
787
|
+
canFind,
|
|
788
|
+
findInThread,
|
|
789
|
+
canList,
|
|
790
|
+
listTurns,
|
|
732
791
|
],
|
|
733
792
|
);
|
|
734
793
|
const frame = useMemo(() => chrome?.(state) ?? {}, [chrome, state]);
|
|
@@ -790,6 +849,11 @@ function GemieConversationView({
|
|
|
790
849
|
onSubmit={() => void (replyDeclines ? submitReply() : composer.submit(composer.text))}
|
|
791
850
|
// Stop gives way to send while a reply would decline the question the agent waits on.
|
|
792
851
|
busy={isLoading && !replyDeclines}
|
|
852
|
+
followUp={
|
|
853
|
+
followUp === undefined ? undefined : (
|
|
854
|
+
<FollowUpStatus state={followUp} agent={lead.name} />
|
|
855
|
+
)
|
|
856
|
+
}
|
|
793
857
|
approval={
|
|
794
858
|
approvals.pending === undefined ? undefined : (
|
|
795
859
|
<ApprovalBar approvals={approvals} isFocused={isFocused} />
|
|
@@ -835,7 +899,6 @@ function GemieConversationView({
|
|
|
835
899
|
</>
|
|
836
900
|
);
|
|
837
901
|
|
|
838
|
-
const showsPast = view.jumped;
|
|
839
902
|
return (
|
|
840
903
|
<GemieFlightsProvider value={flights}>
|
|
841
904
|
<InertWhen inert={betweenGemies !== null}>
|
|
@@ -865,6 +928,8 @@ function GemieConversationView({
|
|
|
865
928
|
conversationLoading={conversationLoading || loading}
|
|
866
929
|
history={view.history}
|
|
867
930
|
focusCursor={view.focusCursor}
|
|
931
|
+
jumpTo={navigation.jump}
|
|
932
|
+
highlightedId={navigation.highlightedId}
|
|
868
933
|
failedTurn={failedTurn}
|
|
869
934
|
onRetryTurn={retryFailedTurn}
|
|
870
935
|
onRegenerate={composer.regenerate}
|
|
@@ -892,6 +957,20 @@ function GemieConversationView({
|
|
|
892
957
|
{!view.searchOpen || threadAddress === undefined ? null : (
|
|
893
958
|
<ThreadSearch thread={threadAddress} onJump={view.jump} onClose={view.closeSearch} />
|
|
894
959
|
)}
|
|
960
|
+
{navigation.panel === 'find' ? (
|
|
961
|
+
<ThreadFindBar find={navigation} partial={view.history?.loadMore !== undefined} />
|
|
962
|
+
) : null}
|
|
963
|
+
{navigation.panel === 'turns' ? (
|
|
964
|
+
<ThreadTurnList
|
|
965
|
+
turns={navigation.turns}
|
|
966
|
+
onJump={navigation.jumpToTurn}
|
|
967
|
+
onLoadEarlier={view.history?.loadMore}
|
|
968
|
+
onClose={navigation.close}
|
|
969
|
+
/>
|
|
970
|
+
) : null}
|
|
971
|
+
{navigation.panel === null && !view.searchOpen && turnCount >= LONG_THREAD_TURNS ? (
|
|
972
|
+
<ThreadTurnsButton onPress={listTurns} />
|
|
973
|
+
) : null}
|
|
895
974
|
</AiChatContainer>
|
|
896
975
|
</InertWhen>
|
|
897
976
|
{betweenGemies === null ? null : (
|
|
@@ -118,6 +118,8 @@ export interface GemieComposerProps<T extends GemieSuggestion = GemieSuggestion>
|
|
|
118
118
|
* questions: where the person is about to type the reply that declines it.
|
|
119
119
|
*/
|
|
120
120
|
approval?: ReactNode;
|
|
121
|
+
/** Where a message that is not in a running turn yet is (`FollowUpStatus`), over the field. */
|
|
122
|
+
followUp?: ReactNode;
|
|
121
123
|
/** The tab on the card's top edge (`ComposerPanelStatusTab`). */
|
|
122
124
|
status?: ReactNode;
|
|
123
125
|
/** Drawn where send would be while there is nothing to send (voice mode). */
|
|
@@ -164,6 +166,7 @@ function GemieComposerBody<T extends GemieSuggestion>({
|
|
|
164
166
|
suggestions,
|
|
165
167
|
questions,
|
|
166
168
|
approval,
|
|
169
|
+
followUp,
|
|
167
170
|
status,
|
|
168
171
|
emptyAction,
|
|
169
172
|
accessory,
|
|
@@ -342,6 +345,7 @@ function GemieComposerBody<T extends GemieSuggestion>({
|
|
|
342
345
|
onReturnFocus={returnToField}
|
|
343
346
|
/>
|
|
344
347
|
) : null}
|
|
348
|
+
{followUp}
|
|
345
349
|
<ComposerLoader phase={loaderPhase ?? (busy ? 'streaming' : 'idle')}>
|
|
346
350
|
<ComposerPill
|
|
347
351
|
value={value}
|
|
@@ -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
|
|
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
|
|
@@ -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';
|
|
@@ -44,6 +45,7 @@ import {
|
|
|
44
45
|
turnFileChanges,
|
|
45
46
|
} from '../../runtime/model';
|
|
46
47
|
import type { OpenThought } from '../../hooks/useOpenThought';
|
|
48
|
+
import type { RowView } from '../../hooks/useRowJump';
|
|
47
49
|
import { PlanPreviewCard } from '../PlanPreviewCard';
|
|
48
50
|
import { AskedQuestions } from '../QuestionCard';
|
|
49
51
|
import { CanvasComponent } from '../canvas/CanvasComponent';
|
|
@@ -100,6 +102,10 @@ export interface ThreadRowProps {
|
|
|
100
102
|
conversationId: string | undefined;
|
|
101
103
|
/** Where this row ended up, for the one row a jump is aimed at. */
|
|
102
104
|
onLayout?: (event: LayoutChangeEvent) => void;
|
|
105
|
+
/** Hands the thread the row's view, which a jump measures. Stable across renders. */
|
|
106
|
+
registerRow?: (messageId: string, view: RowView | null) => void;
|
|
107
|
+
/** The row is the find bar's current match. */
|
|
108
|
+
highlighted?: boolean;
|
|
103
109
|
actions: ThreadActions;
|
|
104
110
|
/** This reply's read-aloud, as a primitive so only its own row re-renders. */
|
|
105
111
|
readAloudState: ReadAloudState;
|
|
@@ -131,6 +137,8 @@ export const ThreadRow = memo(function ThreadRow({
|
|
|
131
137
|
isLoading,
|
|
132
138
|
conversationId,
|
|
133
139
|
onLayout,
|
|
140
|
+
registerRow,
|
|
141
|
+
highlighted = false,
|
|
134
142
|
actions,
|
|
135
143
|
readAloudState,
|
|
136
144
|
readAloudBlocked,
|
|
@@ -146,6 +154,11 @@ export const ThreadRow = memo(function ThreadRow({
|
|
|
146
154
|
const attached = !isReply && hasAttachments(message.content);
|
|
147
155
|
const storedIn = message.unsaved === true ? undefined : conversationId;
|
|
148
156
|
const hasText = text.length > 0;
|
|
157
|
+
const rowRef = useCallback(
|
|
158
|
+
(view: RowView | null) => registerRow?.(message.id, view),
|
|
159
|
+
[registerRow, message.id],
|
|
160
|
+
);
|
|
161
|
+
const rowStyle = highlighted ? styles.highlighted : undefined;
|
|
149
162
|
|
|
150
163
|
const copyAction: AiChatTurnAction | null = hasText
|
|
151
164
|
? {
|
|
@@ -175,7 +188,7 @@ export const ThreadRow = memo(function ThreadRow({
|
|
|
175
188
|
};
|
|
176
189
|
const questionActions = [copyAction, editAction].filter(isPresent);
|
|
177
190
|
return (
|
|
178
|
-
<Animated.View onLayout={onLayout}>
|
|
191
|
+
<Animated.View ref={rowRef} onLayout={onLayout} style={rowStyle}>
|
|
179
192
|
{text.length === 0 && !attached ? null : (
|
|
180
193
|
// Bloom's user turn, with the breathing room above it the thread has always had.
|
|
181
194
|
<View style={styles.question}>
|
|
@@ -214,7 +227,7 @@ export const ThreadRow = memo(function ThreadRow({
|
|
|
214
227
|
}
|
|
215
228
|
|
|
216
229
|
return (
|
|
217
|
-
<Animated.View onLayout={onLayout}>
|
|
230
|
+
<Animated.View ref={rowRef} onLayout={onLayout} style={rowStyle}>
|
|
218
231
|
<ReplyTurn
|
|
219
232
|
message={message}
|
|
220
233
|
text={text}
|
|
@@ -411,13 +424,12 @@ function ReplyTurn({
|
|
|
411
424
|
icon: RiThumbDownLine,
|
|
412
425
|
onPress: () => actions.vote(message.id, 'down', storedIn),
|
|
413
426
|
};
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
/** In a bubble: "react" is the emoji bar, "more" is the rest of what the turn offers, the votes included. */
|
|
427
|
+
/** A shared conversation is read, not judged: a finished reply still offers its words. */
|
|
428
|
+
const copyOnly = readOnly && !message.isStreaming ? copyAction : null;
|
|
429
|
+
/** The long-press menu, and a bubble's "more" (where "react" is the emoji bar beside it). */
|
|
418
430
|
const moreActions = hasFeedback
|
|
419
431
|
? [readAloudAction, copyAction, regenerateAction, likeAction, dislikeAction].filter(isPresent)
|
|
420
|
-
: [];
|
|
432
|
+
: [copyOnly].filter(isPresent);
|
|
421
433
|
const reactions = actions.reactionsOf(
|
|
422
434
|
message.id,
|
|
423
435
|
message.reactions,
|
|
@@ -509,7 +521,7 @@ function ReplyTurn({
|
|
|
509
521
|
) : null}
|
|
510
522
|
{/* Bloom's reply: its reveal and its own feedback row (like / dislike / copy), then read
|
|
511
523
|
aloud and regenerate. Copy confirms only what the clipboard did. */}
|
|
512
|
-
<TurnMenu actions={
|
|
524
|
+
<TurnMenu actions={moreActions} label={t('chat.turnActions')}>
|
|
513
525
|
<AiChatAssistantMessage
|
|
514
526
|
animate={isNew}
|
|
515
527
|
feedback={hasFeedback && !bubbled}
|
|
@@ -628,6 +640,20 @@ function ReplyTurn({
|
|
|
628
640
|
) : (
|
|
629
641
|
replyBody
|
|
630
642
|
)}
|
|
643
|
+
{/* Bloom's feedback row always votes, so a reader of a shared one gets copy alone. */}
|
|
644
|
+
{bubbled || copyOnly === null ? null : (
|
|
645
|
+
<View style={styles.copyOnly}>
|
|
646
|
+
<Button
|
|
647
|
+
iconOnly
|
|
648
|
+
size="sm"
|
|
649
|
+
appearance="plain"
|
|
650
|
+
tone="neutral"
|
|
651
|
+
leadingIcon={RiFileCopyLine}
|
|
652
|
+
accessibilityLabel={copyOnly.label}
|
|
653
|
+
onPress={copyOnly.onPress}
|
|
654
|
+
/>
|
|
655
|
+
</View>
|
|
656
|
+
)}
|
|
631
657
|
</AiChatAssistantMessage>
|
|
632
658
|
</TurnMenu>
|
|
633
659
|
</View>
|
|
@@ -637,8 +663,17 @@ function ReplyTurn({
|
|
|
637
663
|
}
|
|
638
664
|
|
|
639
665
|
const useStyles = createTokenStyles((t) => ({
|
|
666
|
+
// An outline takes no room, so marking a match moves nothing the reader is looking at.
|
|
667
|
+
highlighted: {
|
|
668
|
+
borderRadius: 16,
|
|
669
|
+
outlineWidth: 2,
|
|
670
|
+
outlineStyle: 'solid',
|
|
671
|
+
outlineColor: t.primary,
|
|
672
|
+
outlineOffset: 4,
|
|
673
|
+
},
|
|
640
674
|
question: { marginTop: 8, width: '100%', flexDirection: 'column', alignItems: 'flex-end' },
|
|
641
675
|
reply: { width: '100%', flexDirection: 'column' },
|
|
676
|
+
copyOnly: { alignSelf: 'flex-start' },
|
|
642
677
|
replyIdentity: { marginBottom: 2 },
|
|
643
678
|
canvas: { borderRadius: 16, borderWidth: 1, borderColor: t.border, padding: 16 },
|
|
644
679
|
muted: { fontSize: 14, color: t.mutedForeground, lineHeight: 20 },
|