@gemies/sdk 9.1.0 → 10.0.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 +103 -0
- package/README.md +9 -6
- package/package.json +4 -11
- package/src/accounts.ts +7 -1
- package/src/ask-eager.ts +0 -2
- package/src/ask-text.ts +0 -1
- package/src/ask.ts +0 -1
- package/src/components/AmbientField.tsx +13 -2
- package/src/components/ComposerDropZone.tsx +20 -4
- package/src/components/ComposerSuggestions.tsx +9 -2
- package/src/components/GemieActivityLine.tsx +11 -5
- package/src/components/GemieBetweenGemies.tsx +23 -10
- package/src/components/GemieChatContent.tsx +65 -23
- package/src/components/GemieChatScreen.tsx +7 -4
- package/src/components/GemieChatSheet.tsx +6 -2
- package/src/components/GemieComposer.tsx +17 -7
- package/src/components/GemieGroupWelcome.tsx +16 -2
- package/src/components/GemieRecentConversations.tsx +13 -10
- package/src/components/GemieSharedConversation.tsx +38 -6
- package/src/components/GemieWelcomeMessage.tsx +23 -7
- package/src/components/IdentityMark.tsx +6 -12
- package/src/components/PlanPreviewCard.tsx +18 -7
- package/src/components/QuestionCard.tsx +6 -2
- package/src/components/ReplyMarkdown.tsx +32 -6
- package/src/components/RichBlocks.tsx +20 -15
- package/src/components/accounts/GemieAccountGrants.tsx +27 -10
- package/src/components/accounts/GemieConnectedAccounts.tsx +87 -51
- package/src/components/canvas/CanvasComponent.tsx +6 -2
- package/src/components/canvas/DashboardRenderer.tsx +25 -8
- package/src/components/canvas/DeckRenderer.tsx +23 -6
- package/src/components/canvas/FormRenderer.tsx +8 -3
- package/src/components/connectors/ConnectorLogo.tsx +15 -9
- package/src/components/connectors/GemieConnectedConnectors.tsx +51 -25
- package/src/components/connectors/GemieConnectorsStore.tsx +99 -41
- package/src/components/connectors/GrantSwitchRow.tsx +18 -5
- package/src/components/thought/ThoughtPanel.tsx +26 -12
- package/src/components/thought/ToolStep.tsx +14 -6
- package/src/components/thread/AgentResultCard.tsx +10 -4
- package/src/components/thread/AgentTaskCard.tsx +8 -3
- package/src/components/thread/ApprovalCard.tsx +118 -0
- package/src/components/thread/ChatBubble.tsx +66 -25
- package/src/components/thread/GemieThread.tsx +36 -8
- package/src/components/thread/ThreadRow.tsx +20 -15
- package/src/components/thread/ThreadSearch.tsx +27 -10
- package/src/components/thread/ThreadSkeleton.tsx +12 -6
- package/src/components/thread/ToolResultCard.tsx +10 -4
- package/src/components/thread/TurnAttachments.tsx +17 -8
- package/src/components/voice/VoiceControls.tsx +9 -6
- package/src/connectors.ts +15 -2
- package/src/hooks/useChatVoice.ts +2 -10
- package/src/hooks/useMessageReactions.ts +5 -5
- package/src/hooks/useThoughtScope.ts +9 -8
- package/src/index.ts +2 -3
- package/src/lib/copy-en.ts +7 -0
- package/src/lib/copy-es.ts +7 -0
- package/src/lib/tool-call-status.ts +1 -1
- package/src/lib/utils.ts +1 -8
- package/src/realtime/react.tsx +9 -9
- package/src/realtime/reread.ts +28 -0
- package/src/realtime/store.ts +123 -0
- package/src/runtime/agents.ts +46 -27
- package/src/runtime/approvals.ts +99 -0
- package/src/runtime/collections.ts +35 -136
- package/src/runtime/config.tsx +10 -0
- package/src/runtime/connected-accounts.ts +175 -88
- package/src/runtime/connectors.ts +244 -127
- package/src/runtime/conversations.ts +181 -607
- package/src/runtime/data/answer.ts +76 -0
- package/src/runtime/data/collections.ts +168 -0
- package/src/runtime/data/conversations.ts +626 -0
- package/src/runtime/data/reactions.ts +29 -0
- package/src/runtime/data/read.ts +37 -0
- package/src/runtime/data/threads.ts +149 -0
- package/src/runtime/index.ts +74 -8
- package/src/runtime/model.ts +0 -2
- package/src/runtime/routes.ts +2 -2
- package/src/runtime/sharing.ts +69 -56
- package/src/runtime/types.ts +8 -16
- package/src/runtime/use-bound-action.ts +27 -0
- package/src/runtime/use-conversation-stream.ts +47 -31
- package/src/runtime/use-conversation-thread.ts +44 -51
- package/src/runtime/use-gemie-thread.ts +32 -43
- package/src/runtime/use-start-conversation.ts +14 -15
- package/src/runtime/use-thread-history.ts +26 -36
- package/src/runtime/use-thread-search.ts +29 -76
- package/src/text.ts +0 -1
- package/src/voice.ts +0 -1
- package/src/components/Image.tsx +0 -12
- package/src/realtime/cache.ts +0 -257
- package/src/runtime/conversation-dates.ts +0 -31
- package/src/runtime/query-keys.ts +0 -66
- package/src/runtime/reaction-cache.ts +0 -45
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Questionnaire, type QuestionnaireAnswers } from '@oxy.so/bloom/questionnaire';
|
|
2
2
|
import { Muted } from '@oxy.so/bloom/typography';
|
|
3
|
-
import { View } from 'react-native';
|
|
3
|
+
import { View, StyleSheet } from 'react-native';
|
|
4
4
|
import { type AskedQuestion, formatAnswers } from '../lib/questions';
|
|
5
5
|
|
|
6
6
|
interface QuestionCardProps {
|
|
@@ -53,7 +53,7 @@ export function QuestionCard({ questions, onSubmit, onDismiss }: QuestionCardPro
|
|
|
53
53
|
/** The questions Alia asked, as plain lines: the thread's record of them once they are answered. */
|
|
54
54
|
export function AskedQuestions({ questions }: { questions: AskedQuestion[] }) {
|
|
55
55
|
return (
|
|
56
|
-
<View
|
|
56
|
+
<View style={styles.questions}>
|
|
57
57
|
{questions.map((q, i) => (
|
|
58
58
|
// The model's questions never reorder: the position is the identity.
|
|
59
59
|
// biome-ignore lint/suspicious/noArrayIndexKey: see above
|
|
@@ -62,3 +62,7 @@ export function AskedQuestions({ questions }: { questions: AskedQuestion[] }) {
|
|
|
62
62
|
</View>
|
|
63
63
|
);
|
|
64
64
|
}
|
|
65
|
+
|
|
66
|
+
const styles = StyleSheet.create({
|
|
67
|
+
questions: { marginVertical: 8, gap: 4 },
|
|
68
|
+
});
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
import { useLabels } from '../lib/labels';
|
|
15
15
|
import type { ToolInvocation } from '../runtime/types';
|
|
16
16
|
import { Banner, CompactList, Comparison, Credibility, RichImage, Timeline } from './RichBlocks';
|
|
17
|
+
import { createTokenStyles } from '@oxy.so/bloom/theme';
|
|
17
18
|
|
|
18
19
|
// Cheap pre-check: plain markdown (the overwhelmingly common case) skips the
|
|
19
20
|
// six per-pattern regex scans below with a single pass.
|
|
@@ -239,10 +240,11 @@ function ReferenceList({
|
|
|
239
240
|
entries: ReferenceEntry[];
|
|
240
241
|
onCitationPress?: (source: CitationSource) => void;
|
|
241
242
|
}) {
|
|
243
|
+
const styles = useStyles();
|
|
242
244
|
const { t } = useLabels();
|
|
243
245
|
return (
|
|
244
|
-
<View
|
|
245
|
-
<Text
|
|
246
|
+
<View style={styles.references} accessibilityRole="list">
|
|
247
|
+
<Text style={styles.referencesHeading}>{t('thought.references')}</Text>
|
|
246
248
|
{entries.map((entry) => {
|
|
247
249
|
const press = () => {
|
|
248
250
|
if (onCitationPress) onCitationPress(entry);
|
|
@@ -272,15 +274,15 @@ function ReferenceList({
|
|
|
272
274
|
key={entry.id}
|
|
273
275
|
accessibilityRole="link"
|
|
274
276
|
accessibilityLabel={t('thought.sourceLabel', { n: entry.id, title: entry.title })}
|
|
275
|
-
|
|
277
|
+
style={({ pressed }) => [styles.reference, pressed ? styles.referencePressed : null]}
|
|
276
278
|
onPress={onPress}
|
|
277
279
|
{...webAnchor}
|
|
278
280
|
>
|
|
279
|
-
<Text
|
|
280
|
-
<Text
|
|
281
|
+
<Text style={styles.referenceId}>[{entry.id}]</Text>
|
|
282
|
+
<Text style={styles.referenceTitle} numberOfLines={2}>
|
|
281
283
|
{entry.title}
|
|
282
284
|
</Text>
|
|
283
|
-
<Text
|
|
285
|
+
<Text style={styles.referenceDomain} numberOfLines={1}>
|
|
284
286
|
{entry.domain}
|
|
285
287
|
</Text>
|
|
286
288
|
</Pressable>
|
|
@@ -371,3 +373,27 @@ export function ReplyMarkdown({
|
|
|
371
373
|
</View>
|
|
372
374
|
);
|
|
373
375
|
}
|
|
376
|
+
|
|
377
|
+
const useStyles = createTokenStyles((t) => ({
|
|
378
|
+
references: { marginTop: 12, gap: 4, borderTopWidth: 1, borderColor: t.border, paddingTop: 12 },
|
|
379
|
+
referencesHeading: { fontSize: 12, fontWeight: 500, color: t.mutedForeground, lineHeight: 16 },
|
|
380
|
+
reference: {
|
|
381
|
+
flexDirection: 'row',
|
|
382
|
+
alignItems: 'flex-start',
|
|
383
|
+
gap: 8,
|
|
384
|
+
borderRadius: 6,
|
|
385
|
+
paddingVertical: 2,
|
|
386
|
+
},
|
|
387
|
+
referencePressed: { opacity: 0.7 },
|
|
388
|
+
referenceId: { fontSize: 14, color: t.mutedForeground, lineHeight: 20 },
|
|
389
|
+
referenceTitle: {
|
|
390
|
+
flexGrow: 1,
|
|
391
|
+
flexShrink: 1,
|
|
392
|
+
flexBasis: '0%',
|
|
393
|
+
fontSize: 14,
|
|
394
|
+
color: t.primary,
|
|
395
|
+
textDecorationLine: 'underline',
|
|
396
|
+
lineHeight: 20,
|
|
397
|
+
},
|
|
398
|
+
referenceDomain: { fontSize: 12, color: t.mutedForeground, lineHeight: 16 },
|
|
399
|
+
}));
|
|
@@ -12,8 +12,8 @@ import { RiExternalLinkLine } from '@oxy.so/bloom/icons/RiExternalLinkLine';
|
|
|
12
12
|
import { ListItem } from '@oxy.so/bloom/list';
|
|
13
13
|
import { Rating } from '@oxy.so/bloom/rating';
|
|
14
14
|
import { Muted, Text } from '@oxy.so/bloom/typography';
|
|
15
|
-
import { Image } from '
|
|
16
|
-
import { Linking, View } from 'react-native';
|
|
15
|
+
import { Image } from 'expo-image';
|
|
16
|
+
import { Linking, View, StyleSheet } from 'react-native';
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* The rich blocks a reply can carry (```compactlist, ```banner, …), drawn with
|
|
@@ -30,7 +30,7 @@ type CompactListItem = {
|
|
|
30
30
|
|
|
31
31
|
export function CompactList({ title, items }: { title: string; items: CompactListItem[] }) {
|
|
32
32
|
return (
|
|
33
|
-
<Card appearance="outline"
|
|
33
|
+
<Card appearance="outline" style={styles.block}>
|
|
34
34
|
<CardHeader>
|
|
35
35
|
<CardTitle>{title}</CardTitle>
|
|
36
36
|
</CardHeader>
|
|
@@ -44,11 +44,7 @@ export function CompactList({ title, items }: { title: string; items: CompactLis
|
|
|
44
44
|
supporting={item.meta}
|
|
45
45
|
leading={
|
|
46
46
|
item.image ? (
|
|
47
|
-
<Image
|
|
48
|
-
source={{ uri: item.image }}
|
|
49
|
-
className="h-10 w-10 rounded"
|
|
50
|
-
contentFit="cover"
|
|
51
|
-
/>
|
|
47
|
+
<Image source={{ uri: item.image }} style={styles.thumbnail} contentFit="cover" />
|
|
52
48
|
) : undefined
|
|
53
49
|
}
|
|
54
50
|
trailing={item.href ? <RiExternalLinkLine size="sm" /> : undefined}
|
|
@@ -76,7 +72,7 @@ export function Banner({
|
|
|
76
72
|
content: string;
|
|
77
73
|
}) {
|
|
78
74
|
return (
|
|
79
|
-
<View
|
|
75
|
+
<View style={styles.block}>
|
|
80
76
|
<AdmonitionRoot type={Object.hasOwn(ADMONITION, type) ? ADMONITION[type] : 'info'}>
|
|
81
77
|
<AdmonitionRow>
|
|
82
78
|
<AdmonitionIcon />
|
|
@@ -121,12 +117,12 @@ export function Comparison({
|
|
|
121
117
|
conclusion?: string;
|
|
122
118
|
}) {
|
|
123
119
|
return (
|
|
124
|
-
<Card appearance="outline"
|
|
120
|
+
<Card appearance="outline" style={styles.block}>
|
|
125
121
|
<CardHeader>
|
|
126
122
|
<CardTitle>{title}</CardTitle>
|
|
127
123
|
</CardHeader>
|
|
128
124
|
<CardBody>
|
|
129
|
-
<View
|
|
125
|
+
<View style={styles.sides}>
|
|
130
126
|
<ComparisonSideCard side={left} />
|
|
131
127
|
<ComparisonSideCard side={right} />
|
|
132
128
|
{conclusion ? <Admonition type="tip">{conclusion}</Admonition> : null}
|
|
@@ -144,7 +140,7 @@ type TimelineItem = {
|
|
|
144
140
|
|
|
145
141
|
export function Timeline({ title, items }: { title: string; items: TimelineItem[] }) {
|
|
146
142
|
return (
|
|
147
|
-
<Card appearance="outline"
|
|
143
|
+
<Card appearance="outline" style={styles.block}>
|
|
148
144
|
<CardHeader>
|
|
149
145
|
<CardTitle>{title}</CardTitle>
|
|
150
146
|
</CardHeader>
|
|
@@ -176,8 +172,8 @@ export function RichImage({
|
|
|
176
172
|
caption?: string;
|
|
177
173
|
}) {
|
|
178
174
|
return (
|
|
179
|
-
<View
|
|
180
|
-
<Image source={{ uri: url }}
|
|
175
|
+
<View style={styles.figure}>
|
|
176
|
+
<Image source={{ uri: url }} style={styles.figureImage} contentFit="cover" />
|
|
181
177
|
{title ? <Text variant="body-medium">{title}</Text> : null}
|
|
182
178
|
{caption ? <Muted>{caption}</Muted> : null}
|
|
183
179
|
</View>
|
|
@@ -188,9 +184,18 @@ export function RichImage({
|
|
|
188
184
|
export function Credibility({ level, source }: { level: number; source: string }) {
|
|
189
185
|
const { t } = useLabels();
|
|
190
186
|
return (
|
|
191
|
-
<View
|
|
187
|
+
<View style={styles.rating}>
|
|
192
188
|
<Rating value={Math.max(0, Math.min(5, level))} size="sm" />
|
|
193
189
|
<Muted>{t('chat.richBlocks.source', { source })}</Muted>
|
|
194
190
|
</View>
|
|
195
191
|
);
|
|
196
192
|
}
|
|
193
|
+
|
|
194
|
+
const styles = StyleSheet.create({
|
|
195
|
+
block: { marginVertical: 8 },
|
|
196
|
+
thumbnail: { height: 40, width: 40, borderRadius: 4 },
|
|
197
|
+
sides: { gap: 8 },
|
|
198
|
+
figure: { marginVertical: 8, gap: 4 },
|
|
199
|
+
figureImage: { aspectRatio: '16/9', width: '100%', borderRadius: 8 },
|
|
200
|
+
rating: { marginVertical: 8, flexDirection: 'row', alignItems: 'center', gap: 8 },
|
|
201
|
+
});
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from '../../runtime/connected-accounts';
|
|
11
11
|
import { GrantSwitchRow } from '../connectors/GrantSwitchRow';
|
|
12
12
|
import { K, PlatformMark, accountName, statusText } from './account-parts';
|
|
13
|
+
import { createTokenStyles } from '@oxy.so/bloom/theme';
|
|
13
14
|
|
|
14
15
|
export interface GemieAccountGrantsProps {
|
|
15
16
|
/** The gemie whose grants these are (Alia's id for her locked editor). */
|
|
@@ -34,13 +35,15 @@ export function GemieAccountGrants({
|
|
|
34
35
|
onManage,
|
|
35
36
|
t = englishCopy,
|
|
36
37
|
}: GemieAccountGrantsProps) {
|
|
37
|
-
const
|
|
38
|
+
const styles = useStyles();
|
|
39
|
+
const { value: data, isLoading, status, isFetching, refresh } = useConnectedAccounts();
|
|
40
|
+
const isError = status === 'error';
|
|
38
41
|
const { grant } = useConnectedAccountMutations();
|
|
39
42
|
|
|
40
|
-
if (
|
|
43
|
+
if (isLoading) {
|
|
41
44
|
return (
|
|
42
45
|
<Skeleton.Region>
|
|
43
|
-
<View
|
|
46
|
+
<View style={styles.loading}>
|
|
44
47
|
<Skeleton.Box width={220} height={14} />
|
|
45
48
|
<Skeleton.Box width={160} height={14} />
|
|
46
49
|
</View>
|
|
@@ -50,8 +53,8 @@ export function GemieAccountGrants({
|
|
|
50
53
|
|
|
51
54
|
if (isError && data === undefined) {
|
|
52
55
|
return (
|
|
53
|
-
<View
|
|
54
|
-
<Text variant="body-2-regular"
|
|
56
|
+
<View style={styles.failure}>
|
|
57
|
+
<Text variant="body-2-regular" style={styles.muted}>
|
|
55
58
|
{t(`${K}.loadFailed`)}
|
|
56
59
|
</Text>
|
|
57
60
|
<Button
|
|
@@ -59,7 +62,7 @@ export function GemieAccountGrants({
|
|
|
59
62
|
appearance="outline"
|
|
60
63
|
tone="neutral"
|
|
61
64
|
loading={isFetching}
|
|
62
|
-
onPress={() => void
|
|
65
|
+
onPress={() => void refresh()}
|
|
63
66
|
>
|
|
64
67
|
{t(`${K}.retry`)}
|
|
65
68
|
</Button>
|
|
@@ -72,7 +75,7 @@ export function GemieAccountGrants({
|
|
|
72
75
|
|
|
73
76
|
const setGranted = async (accountId: string, granted: boolean) => {
|
|
74
77
|
try {
|
|
75
|
-
await grant.
|
|
78
|
+
await grant.run(accountId, gemieId, granted);
|
|
76
79
|
} catch {
|
|
77
80
|
toast.error(t(`${K}.saveFailed`));
|
|
78
81
|
}
|
|
@@ -80,8 +83,8 @@ export function GemieAccountGrants({
|
|
|
80
83
|
|
|
81
84
|
return (
|
|
82
85
|
<View>
|
|
83
|
-
<View
|
|
84
|
-
<Text variant="body-2-regular"
|
|
86
|
+
<View style={styles.intro}>
|
|
87
|
+
<Text variant="body-2-regular" style={styles.muted}>
|
|
85
88
|
{accounts.length === 0 ? t(`${K}.grants.empty`) : t(`${K}.grants.description`, { name })}
|
|
86
89
|
</Text>
|
|
87
90
|
</View>
|
|
@@ -107,7 +110,7 @@ export function GemieAccountGrants({
|
|
|
107
110
|
/>
|
|
108
111
|
);
|
|
109
112
|
})}
|
|
110
|
-
<View
|
|
113
|
+
<View style={styles.manageRow}>
|
|
111
114
|
<Button size="sm" appearance="outline" tone="neutral" onPress={onManage}>
|
|
112
115
|
{t(`${K}.grants.manage`)}
|
|
113
116
|
</Button>
|
|
@@ -115,3 +118,17 @@ export function GemieAccountGrants({
|
|
|
115
118
|
</View>
|
|
116
119
|
);
|
|
117
120
|
}
|
|
121
|
+
|
|
122
|
+
const useStyles = createTokenStyles((t) => ({
|
|
123
|
+
loading: { gap: 12, paddingVertical: 10 },
|
|
124
|
+
failure: { alignItems: 'flex-start', gap: 8, paddingVertical: 10, paddingInlineEnd: 10 },
|
|
125
|
+
muted: { color: t.mutedForeground },
|
|
126
|
+
intro: { paddingVertical: 10, paddingInlineEnd: 10 },
|
|
127
|
+
manageRow: {
|
|
128
|
+
flexDirection: 'row',
|
|
129
|
+
borderTopWidth: 1,
|
|
130
|
+
borderColor: t.border,
|
|
131
|
+
paddingVertical: 10,
|
|
132
|
+
paddingInlineEnd: 10,
|
|
133
|
+
},
|
|
134
|
+
}));
|
|
@@ -31,17 +31,15 @@ import {
|
|
|
31
31
|
} from '../../runtime/connected-accounts';
|
|
32
32
|
import { GrantSwitchRow } from '../connectors/GrantSwitchRow';
|
|
33
33
|
import { K, PLATFORM_LABELS, PlatformMark, accountName, statusText } from './account-parts';
|
|
34
|
+
import { createTokenStyles } from '@oxy.so/bloom/theme';
|
|
34
35
|
|
|
35
36
|
/** The value the answering select gives "nobody answers on its own". */
|
|
36
37
|
const NOBODY = '';
|
|
37
38
|
|
|
38
39
|
/** One row of the list: the same rhythm as a settings row, a divider above all but the first. */
|
|
39
40
|
function Row({ children, first }: { children: React.ReactNode; first?: boolean }) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
{children}
|
|
43
|
-
</View>
|
|
44
|
-
);
|
|
41
|
+
const styles = useStyles();
|
|
42
|
+
return <View style={[styles.listRow, !first && styles.divider]}>{children}</View>;
|
|
45
43
|
}
|
|
46
44
|
|
|
47
45
|
function Choice<T extends string>({
|
|
@@ -57,9 +55,10 @@ function Choice<T extends string>({
|
|
|
57
55
|
disabled: boolean;
|
|
58
56
|
onChange: (value: T) => void;
|
|
59
57
|
}) {
|
|
58
|
+
const styles = useStyles();
|
|
60
59
|
return (
|
|
61
|
-
<View
|
|
62
|
-
<Text variant="body-2-regular"
|
|
60
|
+
<View style={styles.choice}>
|
|
61
|
+
<Text variant="body-2-regular" style={styles.muted}>
|
|
63
62
|
{label}
|
|
64
63
|
</Text>
|
|
65
64
|
<Select
|
|
@@ -107,16 +106,17 @@ function Code({ value }: { value: string | null | undefined }) {
|
|
|
107
106
|
* second step is left.
|
|
108
107
|
*/
|
|
109
108
|
function TelegramSteps({ link, t }: { link: string | null; t: Translate }) {
|
|
109
|
+
const styles = useStyles();
|
|
110
110
|
return (
|
|
111
|
-
<View
|
|
112
|
-
<Text variant="body-2-regular"
|
|
111
|
+
<View style={styles.steps}>
|
|
112
|
+
<Text variant="body-2-regular" style={styles.muted}>
|
|
113
113
|
{t(`${K}.telegram.note`)}
|
|
114
114
|
</Text>
|
|
115
115
|
{link ? (
|
|
116
116
|
<>
|
|
117
117
|
<Text variant="body-2-regular">{t(`${K}.telegram.step1`)}</Text>
|
|
118
118
|
<Text variant="body-2-regular">{t(`${K}.telegram.step2`)}</Text>
|
|
119
|
-
<View
|
|
119
|
+
<View style={styles.actions}>
|
|
120
120
|
<Button size="sm" onPress={() => void Linking.openURL(link)}>
|
|
121
121
|
{t(`${K}.telegram.open`)}
|
|
122
122
|
</Button>
|
|
@@ -147,7 +147,8 @@ function ConnectingAccount({
|
|
|
147
147
|
onDone: () => void;
|
|
148
148
|
onCancel: () => void;
|
|
149
149
|
}) {
|
|
150
|
-
const
|
|
150
|
+
const styles = useStyles();
|
|
151
|
+
const { value: data } = useConnectedAccountQr(link);
|
|
151
152
|
const status = data?.status ?? 'qr-pending';
|
|
152
153
|
const label = PLATFORM_LABELS[platform];
|
|
153
154
|
|
|
@@ -170,13 +171,13 @@ function ConnectingAccount({
|
|
|
170
171
|
) : (
|
|
171
172
|
<>
|
|
172
173
|
<Text variant="body-2-semibold">{t(`${K}.scanTitle`, { platform: label })}</Text>
|
|
173
|
-
<Text variant="body-2-regular"
|
|
174
|
+
<Text variant="body-2-regular" style={styles.muted}>
|
|
174
175
|
{t(`${K}.scan.${platform}`)}
|
|
175
176
|
</Text>
|
|
176
177
|
<Code value={data?.qr} />
|
|
177
178
|
</>
|
|
178
179
|
)}
|
|
179
|
-
<View
|
|
180
|
+
<View style={styles.actions}>
|
|
180
181
|
<Button size="sm" appearance="outline" tone="neutral" onPress={onCancel}>
|
|
181
182
|
{t(`${K}.cancel`)}
|
|
182
183
|
</Button>
|
|
@@ -187,7 +188,7 @@ function ConnectingAccount({
|
|
|
187
188
|
|
|
188
189
|
/** A Telegram account the person left before finishing: its steps, kept until it is connected. */
|
|
189
190
|
function PendingTelegram({ account, t }: { account: ConnectedAccount; t: Translate }) {
|
|
190
|
-
const { data } = useConnectedAccountQr({ accountId: account._id, qr: null });
|
|
191
|
+
const { value: data } = useConnectedAccountQr({ accountId: account._id, qr: null });
|
|
191
192
|
return <TelegramSteps link={data?.qr ?? null} t={t} />;
|
|
192
193
|
}
|
|
193
194
|
|
|
@@ -203,12 +204,13 @@ function ChosenChats({
|
|
|
203
204
|
saving: boolean;
|
|
204
205
|
t: Translate;
|
|
205
206
|
}) {
|
|
206
|
-
const
|
|
207
|
+
const styles = useStyles();
|
|
208
|
+
const { value: chats, isLoading } = useConnectedAccountChats(account._id);
|
|
207
209
|
|
|
208
|
-
if (
|
|
210
|
+
if (isLoading) {
|
|
209
211
|
return (
|
|
210
212
|
<Skeleton.Region>
|
|
211
|
-
<View
|
|
213
|
+
<View style={styles.steps}>
|
|
212
214
|
{[0, 1, 2].map((row) => (
|
|
213
215
|
<Skeleton.Box key={row} width={180} height={14} />
|
|
214
216
|
))}
|
|
@@ -218,16 +220,16 @@ function ChosenChats({
|
|
|
218
220
|
}
|
|
219
221
|
if (!chats?.length) {
|
|
220
222
|
return (
|
|
221
|
-
<Text variant="body-2-regular"
|
|
223
|
+
<Text variant="body-2-regular" style={styles.muted}>
|
|
222
224
|
{t(`${K}.noChats`)}
|
|
223
225
|
</Text>
|
|
224
226
|
);
|
|
225
227
|
}
|
|
226
228
|
return (
|
|
227
|
-
<View
|
|
229
|
+
<View style={styles.choice}>
|
|
228
230
|
{chats.map((chat) => (
|
|
229
|
-
<View key={chat.chatId}
|
|
230
|
-
<Text variant="body-2-regular" numberOfLines={1}
|
|
231
|
+
<View key={chat.chatId} style={styles.chat}>
|
|
232
|
+
<Text variant="body-2-regular" numberOfLines={1} style={styles.chatName}>
|
|
231
233
|
{chat.kind === 'group' ? t(`${K}.groupChat`, { name: chat.name }) : chat.name}
|
|
232
234
|
</Text>
|
|
233
235
|
<Switch
|
|
@@ -265,10 +267,11 @@ function Answering({
|
|
|
265
267
|
saving: boolean;
|
|
266
268
|
t: Translate;
|
|
267
269
|
}) {
|
|
270
|
+
const styles = useStyles();
|
|
268
271
|
const answering = gemies.find((gemie) => gemie.id === account.answeringGemieId) ?? null;
|
|
269
272
|
const telegram = account.platform === 'telegram';
|
|
270
273
|
return (
|
|
271
|
-
<View
|
|
274
|
+
<View style={styles.settings}>
|
|
272
275
|
<Choice
|
|
273
276
|
label={t(`${K}.answeringLabel`)}
|
|
274
277
|
value={answering?.id ?? NOBODY}
|
|
@@ -280,13 +283,13 @@ function Answering({
|
|
|
280
283
|
onChange={(id) => save({ answeringGemieId: id === NOBODY ? null : id })}
|
|
281
284
|
/>
|
|
282
285
|
{answering === null ? (
|
|
283
|
-
<Text variant="body-2-regular"
|
|
286
|
+
<Text variant="body-2-regular" style={styles.muted}>
|
|
284
287
|
{t(`${K}.answeringNone`)}
|
|
285
288
|
</Text>
|
|
286
289
|
) : (
|
|
287
290
|
<>
|
|
288
291
|
{telegram && account.status === 'connected' && account.canReply === false ? (
|
|
289
|
-
<Text variant="body-2-regular"
|
|
292
|
+
<Text variant="body-2-regular" style={styles.muted}>
|
|
290
293
|
{t(`${K}.telegram.cannotReply`, { name: answering.name })}
|
|
291
294
|
</Text>
|
|
292
295
|
) : null}
|
|
@@ -333,6 +336,7 @@ function AccountRow({
|
|
|
333
336
|
gemies: readonly GrantableGemie[];
|
|
334
337
|
t: Translate;
|
|
335
338
|
}) {
|
|
339
|
+
const styles = useStyles();
|
|
336
340
|
const { update, grant, remove } = useConnectedAccountMutations();
|
|
337
341
|
const platform = PLATFORM_LABELS[account.platform] ?? account.platform;
|
|
338
342
|
const name = accountName(account);
|
|
@@ -345,7 +349,7 @@ function AccountRow({
|
|
|
345
349
|
const save = useCallback(
|
|
346
350
|
async (patch: ConnectedAccountPatch) => {
|
|
347
351
|
try {
|
|
348
|
-
await update.
|
|
352
|
+
await update.run(account._id, patch);
|
|
349
353
|
} catch {
|
|
350
354
|
toast.error(t(`${K}.saveFailed`));
|
|
351
355
|
}
|
|
@@ -355,7 +359,7 @@ function AccountRow({
|
|
|
355
359
|
|
|
356
360
|
const setGranted = async (gemieId: string, granted: boolean) => {
|
|
357
361
|
try {
|
|
358
|
-
await grant.
|
|
362
|
+
await grant.run(account._id, gemieId, granted);
|
|
359
363
|
} catch {
|
|
360
364
|
toast.error(t(`${K}.saveFailed`));
|
|
361
365
|
}
|
|
@@ -373,7 +377,7 @@ function AccountRow({
|
|
|
373
377
|
});
|
|
374
378
|
if (!ok) return;
|
|
375
379
|
try {
|
|
376
|
-
await remove.
|
|
380
|
+
await remove.run(account._id);
|
|
377
381
|
toast.success(t(`${K}.removed`, { platform }));
|
|
378
382
|
} catch {
|
|
379
383
|
toast.error(t(`${K}.removeFailed`));
|
|
@@ -382,12 +386,12 @@ function AccountRow({
|
|
|
382
386
|
|
|
383
387
|
return (
|
|
384
388
|
<Row>
|
|
385
|
-
<View
|
|
389
|
+
<View style={styles.account}>
|
|
386
390
|
<PlatformMark platform={account.platform} size={28} />
|
|
387
|
-
<View
|
|
391
|
+
<View style={styles.accountText}>
|
|
388
392
|
<Text variant="body-2-semibold">{name}</Text>
|
|
389
393
|
<Text variant="body-2-regular">{statusText(account, t)}</Text>
|
|
390
|
-
<Text variant="body-2-regular"
|
|
394
|
+
<Text variant="body-2-regular" style={styles.muted}>
|
|
391
395
|
{account.lastActiveAt
|
|
392
396
|
? t(`${K}.lastMessage`, { when: new Date(account.lastActiveAt).toLocaleString() })
|
|
393
397
|
: t(`${K}.noMessagesYet`)}
|
|
@@ -411,7 +415,7 @@ function AccountRow({
|
|
|
411
415
|
<>
|
|
412
416
|
<View>
|
|
413
417
|
<Text variant="body-2-semibold">{t(`${K}.usedBy`)}</Text>
|
|
414
|
-
<Text variant="body-2-regular"
|
|
418
|
+
<Text variant="body-2-regular" style={styles.muted}>
|
|
415
419
|
{t(`${K}.usedByHint`)}
|
|
416
420
|
</Text>
|
|
417
421
|
{gemies.map((gemie, index) => (
|
|
@@ -454,7 +458,9 @@ export interface GemieConnectedAccountsProps {
|
|
|
454
458
|
* Alia apps draw this same panel. Only what this deployment can connect is offered.
|
|
455
459
|
*/
|
|
456
460
|
export function GemieConnectedAccounts({ t = englishCopy }: GemieConnectedAccountsProps) {
|
|
457
|
-
const
|
|
461
|
+
const styles = useStyles();
|
|
462
|
+
const { value: data, isLoading, status, isFetching, refresh } = useConnectedAccounts();
|
|
463
|
+
const isError = status === 'error';
|
|
458
464
|
const { connect, remove } = useConnectedAccountMutations();
|
|
459
465
|
const [connecting, setConnecting] = useState<{
|
|
460
466
|
platform: GemieAccountPlatform;
|
|
@@ -465,12 +471,14 @@ export function GemieConnectedAccounts({ t = englishCopy }: GemieConnectedAccoun
|
|
|
465
471
|
platform: GemieAccountPlatform;
|
|
466
472
|
reason: string;
|
|
467
473
|
} | null>(null);
|
|
474
|
+
/** The platform the last connection asked for, whose button spins while it runs. */
|
|
475
|
+
const [asked, setAsked] = useState<GemieAccountPlatform | null>(null);
|
|
468
476
|
const finished = useCallback(() => setConnecting(null), []);
|
|
469
477
|
|
|
470
|
-
if (
|
|
478
|
+
if (isLoading) {
|
|
471
479
|
return (
|
|
472
480
|
<Skeleton.Region>
|
|
473
|
-
<View
|
|
481
|
+
<View style={styles.loading}>
|
|
474
482
|
<Skeleton.Box width={260} height={14} />
|
|
475
483
|
<Skeleton.Box width={160} height={14} />
|
|
476
484
|
</View>
|
|
@@ -481,7 +489,9 @@ export function GemieConnectedAccounts({ t = englishCopy }: GemieConnectedAccoun
|
|
|
481
489
|
const handleConnect = async (platform: GemieAccountPlatform) => {
|
|
482
490
|
setConnectFailure(null);
|
|
483
491
|
try {
|
|
484
|
-
|
|
492
|
+
setAsked(platform);
|
|
493
|
+
const link = await connect.run(platform);
|
|
494
|
+
if (link) setConnecting({ platform, link });
|
|
485
495
|
} catch (error) {
|
|
486
496
|
setConnectFailure({ platform, reason: errorMessage(error, t(`${K}.tryAgain`)) });
|
|
487
497
|
}
|
|
@@ -490,7 +500,7 @@ export function GemieConnectedAccounts({ t = englishCopy }: GemieConnectedAccoun
|
|
|
490
500
|
const handleCancel = async () => {
|
|
491
501
|
const pending = connecting;
|
|
492
502
|
setConnecting(null);
|
|
493
|
-
if (pending) await remove.
|
|
503
|
+
if (pending) await remove.run(pending.link.accountId).catch(() => {});
|
|
494
504
|
};
|
|
495
505
|
|
|
496
506
|
/**
|
|
@@ -502,16 +512,16 @@ export function GemieConnectedAccounts({ t = englishCopy }: GemieConnectedAccoun
|
|
|
502
512
|
return (
|
|
503
513
|
<View>
|
|
504
514
|
<Row first>
|
|
505
|
-
<Text variant="body-2-regular"
|
|
515
|
+
<Text variant="body-2-regular" style={styles.muted}>
|
|
506
516
|
{t(`${K}.loadFailed`)}
|
|
507
517
|
</Text>
|
|
508
|
-
<View
|
|
518
|
+
<View style={styles.actions}>
|
|
509
519
|
<Button
|
|
510
520
|
size="sm"
|
|
511
521
|
appearance="outline"
|
|
512
522
|
tone="neutral"
|
|
513
523
|
loading={isFetching}
|
|
514
|
-
onPress={() => void
|
|
524
|
+
onPress={() => void refresh()}
|
|
515
525
|
>
|
|
516
526
|
{t(`${K}.retry`)}
|
|
517
527
|
</Button>
|
|
@@ -531,7 +541,7 @@ export function GemieConnectedAccounts({ t = englishCopy }: GemieConnectedAccoun
|
|
|
531
541
|
return (
|
|
532
542
|
<View>
|
|
533
543
|
<Row first>
|
|
534
|
-
<Text variant="body-2-regular"
|
|
544
|
+
<Text variant="body-2-regular" style={styles.muted}>
|
|
535
545
|
{t(`${K}.description`)}
|
|
536
546
|
</Text>
|
|
537
547
|
</Row>
|
|
@@ -550,17 +560,17 @@ export function GemieConnectedAccounts({ t = englishCopy }: GemieConnectedAccoun
|
|
|
550
560
|
<Row>
|
|
551
561
|
<Text variant="body-2-semibold">{t(`${K}.connect`)}</Text>
|
|
552
562
|
{platforms.length === 0 ? (
|
|
553
|
-
<Text variant="body-2-regular"
|
|
563
|
+
<Text variant="body-2-regular" style={styles.muted}>
|
|
554
564
|
{t(`${K}.unavailable`)}
|
|
555
565
|
</Text>
|
|
556
566
|
) : null}
|
|
557
567
|
{platforms.includes('telegram') ? (
|
|
558
|
-
<Text variant="body-2-regular"
|
|
568
|
+
<Text variant="body-2-regular" style={styles.muted}>
|
|
559
569
|
{t(`${K}.telegram.note`)}
|
|
560
570
|
</Text>
|
|
561
571
|
) : null}
|
|
562
572
|
{platforms.length === 0 ? null : (
|
|
563
|
-
<View
|
|
573
|
+
<View style={styles.platforms}>
|
|
564
574
|
{platforms.map((platform) => (
|
|
565
575
|
<Button
|
|
566
576
|
key={platform}
|
|
@@ -570,7 +580,7 @@ export function GemieConnectedAccounts({ t = englishCopy }: GemieConnectedAccoun
|
|
|
570
580
|
accessibilityLabel={t(`${K}.connectNamed`, {
|
|
571
581
|
platform: PLATFORM_LABELS[platform],
|
|
572
582
|
})}
|
|
573
|
-
loading={connect.isPending &&
|
|
583
|
+
loading={connect.isPending && asked === platform}
|
|
574
584
|
disabled={connect.isPending}
|
|
575
585
|
onPress={() => handleConnect(platform)}
|
|
576
586
|
>
|
|
@@ -580,18 +590,14 @@ export function GemieConnectedAccounts({ t = englishCopy }: GemieConnectedAccoun
|
|
|
580
590
|
</View>
|
|
581
591
|
)}
|
|
582
592
|
{connectFailure ? (
|
|
583
|
-
<View
|
|
584
|
-
<Text
|
|
585
|
-
variant="body-2-regular"
|
|
586
|
-
className="text-error-primary"
|
|
587
|
-
accessibilityRole="alert"
|
|
588
|
-
>
|
|
593
|
+
<View style={styles.steps}>
|
|
594
|
+
<Text variant="body-2-regular" accessibilityRole="alert" style={styles.failure}>
|
|
589
595
|
{t(`${K}.connectFailed`, {
|
|
590
596
|
platform: PLATFORM_LABELS[connectFailure.platform],
|
|
591
597
|
reason: connectFailure.reason,
|
|
592
598
|
})}
|
|
593
599
|
</Text>
|
|
594
|
-
<View
|
|
600
|
+
<View style={styles.actions}>
|
|
595
601
|
<Button
|
|
596
602
|
size="sm"
|
|
597
603
|
appearance="outline"
|
|
@@ -609,3 +615,33 @@ export function GemieConnectedAccounts({ t = englishCopy }: GemieConnectedAccoun
|
|
|
609
615
|
</View>
|
|
610
616
|
);
|
|
611
617
|
}
|
|
618
|
+
|
|
619
|
+
const useStyles = createTokenStyles((t) => ({
|
|
620
|
+
// A connect failure, in Bloom's error role.
|
|
621
|
+
failure: { color: t.destructive },
|
|
622
|
+
choice: { gap: 4 },
|
|
623
|
+
muted: { color: t.mutedForeground },
|
|
624
|
+
steps: { gap: 8 },
|
|
625
|
+
actions: { flexDirection: 'row' },
|
|
626
|
+
chat: {
|
|
627
|
+
flexDirection: 'row',
|
|
628
|
+
alignItems: 'center',
|
|
629
|
+
justifyContent: 'space-between',
|
|
630
|
+
gap: 12,
|
|
631
|
+
paddingVertical: 4,
|
|
632
|
+
},
|
|
633
|
+
chatName: { flexGrow: 1, flexShrink: 1, flexBasis: '0%' },
|
|
634
|
+
settings: { gap: 12 },
|
|
635
|
+
account: {
|
|
636
|
+
flexDirection: 'row',
|
|
637
|
+
flexWrap: 'wrap',
|
|
638
|
+
alignItems: 'center',
|
|
639
|
+
justifyContent: 'space-between',
|
|
640
|
+
gap: 12,
|
|
641
|
+
},
|
|
642
|
+
accountText: { flexGrow: 1, flexShrink: 1, flexBasis: '0%', gap: 2 },
|
|
643
|
+
loading: { gap: 12, paddingVertical: 10 },
|
|
644
|
+
platforms: { flexDirection: 'row', flexWrap: 'wrap', gap: 8 },
|
|
645
|
+
listRow: { gap: 12, paddingVertical: 10, paddingInlineEnd: 10 },
|
|
646
|
+
divider: { borderTopWidth: 1, borderColor: t.border },
|
|
647
|
+
}));
|