@gemies/sdk 2.0.0 → 2.0.1

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # @gemies/sdk
2
2
 
3
+ ## 2.0.1
4
+
5
+ - **`GemieAccounts` says when the API does not answer**, with a Retry (`gemie.accounts.retry`), and
6
+ offers nothing to link until it does. It used to show a line of text and no way to try again —
7
+ what a person saw while the API was rolling out a release that served the accounts routes.
8
+ - **A link that fails is said in the panel**, with the API's reason and a Retry, instead of a toast
9
+ that was gone before it could be read.
10
+
3
11
  ## 2.0.0
4
12
 
5
13
  - **Lighter chat on web: the chart cards come from their own Bloom entries.** `ChartRenderer` and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gemies/sdk",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "The Gemies SDK: the conversation runtime, chat UI, voice calls and dictation for Oxy apps that talk to a gemie",
5
5
  "main": "src/index.ts",
6
6
  "react-native": "src/index.ts",
@@ -330,12 +330,17 @@ export interface GemieAccountsProps {
330
330
  * its own turns can read or send through them. Only what this deployment can link is offered.
331
331
  */
332
332
  export function GemieAccounts({ gemieId, name, t = englishCopy }: GemieAccountsProps) {
333
- const { data, isPending, isError } = useGemieAccounts(gemieId);
333
+ const { data, isPending, isError, isFetching, refetch } = useGemieAccounts(gemieId);
334
334
  const { link, remove } = useGemieAccountMutations(gemieId);
335
335
  const [linking, setLinking] = useState<{
336
336
  platform: GemieAccountPlatform;
337
337
  link: GemieAccountLink;
338
338
  } | null>(null);
339
+ /** The last link that failed, said in the panel with a way to try again. */
340
+ const [linkFailure, setLinkFailure] = useState<{
341
+ platform: GemieAccountPlatform;
342
+ reason: string;
343
+ } | null>(null);
339
344
  const linked = useCallback(() => setLinking(null), []);
340
345
 
341
346
  if (isPending) {
@@ -350,15 +355,11 @@ export function GemieAccounts({ gemieId, name, t = englishCopy }: GemieAccountsP
350
355
  }
351
356
 
352
357
  const handleLink = async (platform: GemieAccountPlatform) => {
358
+ setLinkFailure(null);
353
359
  try {
354
360
  setLinking({ platform, link: await link.mutateAsync(platform) });
355
361
  } catch (error) {
356
- toast.error(
357
- t(`${K}.linkFailed`, {
358
- platform: PLATFORM_LABELS[platform],
359
- reason: errorMessage(error, t(`${K}.tryAgain`)),
360
- }),
361
- );
362
+ setLinkFailure({ platform, reason: errorMessage(error, t(`${K}.tryAgain`)) });
362
363
  }
363
364
  };
364
365
 
@@ -374,11 +375,39 @@ export function GemieAccounts({ gemieId, name, t = englishCopy }: GemieAccountsP
374
375
  );
375
376
  const platforms = data?.platforms ?? [];
376
377
 
378
+ /**
379
+ * Nothing could be read: the API did not answer (offline, or mid-rollout before it serves these
380
+ * routes). Said so, with a retry, and nothing else is offered until it answers. A later refresh
381
+ * that fails keeps what was already read.
382
+ */
383
+ if (isError && data === undefined) {
384
+ return (
385
+ <View>
386
+ <Row first>
387
+ <Text variant="body-2-regular" className="text-text-secondary">
388
+ {t(`${K}.loadFailed`)}
389
+ </Text>
390
+ <View className="flex-row">
391
+ <Button
392
+ size="sm"
393
+ appearance="outline"
394
+ tone="neutral"
395
+ loading={isFetching}
396
+ onPress={() => void refetch()}
397
+ >
398
+ {t(`${K}.retry`)}
399
+ </Button>
400
+ </View>
401
+ </Row>
402
+ </View>
403
+ );
404
+ }
405
+
377
406
  return (
378
407
  <View>
379
408
  <Row first>
380
409
  <Text variant="body-2-regular" className="text-text-secondary">
381
- {isError ? t(`${K}.loadFailed`) : t(`${K}.description`, { name })}
410
+ {t(`${K}.description`, { name })}
382
411
  </Text>
383
412
  </Row>
384
413
  {accounts.map((account) => (
@@ -401,7 +430,7 @@ export function GemieAccounts({ gemieId, name, t = englishCopy }: GemieAccountsP
401
430
  onDone={linked}
402
431
  onCancel={handleCancel}
403
432
  />
404
- ) : isError ? null : (
433
+ ) : (
405
434
  <Row>
406
435
  <Text variant="body-2-semibold">{t(`${K}.link`)}</Text>
407
436
  {platforms.length === 0 ? (
@@ -409,7 +438,7 @@ export function GemieAccounts({ gemieId, name, t = englishCopy }: GemieAccountsP
409
438
  {t(`${K}.unavailable`)}
410
439
  </Text>
411
440
  ) : (
412
- <View className="flex-row gap-2">
441
+ <View className="flex-row flex-wrap gap-2">
413
442
  {platforms.map((platform) => (
414
443
  <Button
415
444
  key={platform}
@@ -426,6 +455,31 @@ export function GemieAccounts({ gemieId, name, t = englishCopy }: GemieAccountsP
426
455
  ))}
427
456
  </View>
428
457
  )}
458
+ {linkFailure ? (
459
+ <View className="gap-2">
460
+ <Text
461
+ variant="body-2-regular"
462
+ className="text-error-primary"
463
+ accessibilityRole="alert"
464
+ >
465
+ {t(`${K}.linkFailed`, {
466
+ platform: PLATFORM_LABELS[linkFailure.platform],
467
+ reason: linkFailure.reason,
468
+ })}
469
+ </Text>
470
+ <View className="flex-row">
471
+ <Button
472
+ size="sm"
473
+ appearance="outline"
474
+ tone="neutral"
475
+ disabled={link.isPending}
476
+ onPress={() => handleLink(linkFailure.platform)}
477
+ >
478
+ {t(`${K}.retry`)}
479
+ </Button>
480
+ </View>
481
+ </View>
482
+ ) : null}
429
483
  </Row>
430
484
  )}
431
485
  </View>
@@ -179,6 +179,7 @@ export const COPY_EN: Readonly<Record<string, CopyEntry>> = {
179
179
  'gemie.accounts.replies.everyone': 'Everyone who writes',
180
180
  'gemie.accounts.replies.nobody': 'Nobody: {{name}} only reads and sends when you ask',
181
181
  'gemie.accounts.repliesLabel': 'Who {{name}} answers',
182
+ 'gemie.accounts.retry': 'Retry',
182
183
  'gemie.accounts.saveFailed': 'Could not save. Try again.',
183
184
  'gemie.accounts.scan.telegram':
184
185
  'Open Telegram on your phone, go to Settings > Devices > Link Desktop Device, and scan this code.',
@@ -175,6 +175,7 @@ export const COPY_ES: Readonly<Record<string, CopyEntry>> = {
175
175
  'gemie.accounts.replies.everyone': 'A todo el que escriba',
176
176
  'gemie.accounts.replies.nobody': 'A nadie: {{name}} solo lee y envía cuando se lo pides',
177
177
  'gemie.accounts.repliesLabel': 'A quién responde {{name}}',
178
+ 'gemie.accounts.retry': 'Reintentar',
178
179
  'gemie.accounts.saveFailed': 'No se ha podido guardar. Inténtalo de nuevo.',
179
180
  'gemie.accounts.scan.telegram':
180
181
  'Abre Telegram en tu teléfono, ve a Ajustes > Dispositivos > Vincular dispositivo de escritorio y escanea este código.',
@@ -8,6 +8,7 @@
8
8
  */
9
9
 
10
10
  export { API_ROUTES as GEMIES_API_ROUTES } from './routes';
11
+ export { ALIA_GEMIE_ID } from '../lib/alia-gemie';
11
12
  export * from './power-levels';
12
13
  export { englishCopy } from '../lib/copy';
13
14
  export type { Translate } from '../lib/copy';