@plaisolutions/react 0.21.0 → 0.22.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.
@@ -1,7 +1,7 @@
1
1
  import { ArrowUpRight, Bot, Brain, CalendarDays, Check, CheckCircle2, ChevronDown, ChevronUp, CircleAlert, CircleX, Clock, Copy, Database, Download, File, FileText, Globe, LoaderCircle, Mail, MessageSquare, Paperclip as Paperclip$1, Plug, RotateCcw, ThumbsDown, ThumbsUp, Video, Workflow, X as X$1, XCircle } from "lucide-react";
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  import { createContext, forwardRef, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
4
- import { HttpStatusError, ToolDecisionRejectedError, isHiddenMessage, toolConfirmationAt } from "@plaisolutions/client";
4
+ import { HttpStatusError, ToolDecisionRejectedError, ToolSubmissionConflictError, isHiddenMessage, toolConfirmationAt } from "@plaisolutions/client";
5
5
 
6
6
  //#region src/components/internal/join-classes.ts
7
7
  function joinClasses(...classes) {
@@ -4185,7 +4185,17 @@ const ENGLISH = {
4185
4185
  errorEndBeforeStart: "The end must be after the start",
4186
4186
  editNoLongerApplies: "Your changes no longer apply to this action. Review them and try again.",
4187
4187
  editedLabel: "Edited",
4188
- seeNewerVersion: "See the newer version"
4188
+ seeNewerVersion: "See the newer version",
4189
+ invalidatedConfigurationChanged: "The tool, account or its settings changed after this was prepared. Ask again in the chat.",
4190
+ invalidatedNoSnapshot: "This action was prepared by an older version and can’t run. Ask again in the chat.",
4191
+ invalidatedResourceChanged: "The event changed after this was prepared, so nothing was modified. Ask again in the chat.",
4192
+ unknownOutcome: "The provider didn’t confirm whether it happened. Check your sent mail or calendar before trying again.",
4193
+ unknownInterrupted: "The action was interrupted and it isn’t known whether it happened. Check your account before trying again.",
4194
+ applyingNow: "This is already being applied…",
4195
+ errorPlainText: "Use plain text, without HTML",
4196
+ errorOffsetMismatch: "The UTC offset doesn’t match the time zone of the event",
4197
+ errorNotEditable: "This field can’t be edited",
4198
+ errorInvalidValue: "This value isn’t valid"
4189
4199
  };
4190
4200
  const COPY = {
4191
4201
  en: {},
@@ -4277,7 +4287,17 @@ const COPY = {
4277
4287
  errorEndBeforeStart: "El final debe ser posterior al inicio",
4278
4288
  editNoLongerApplies: "Tus cambios ya no se aplican a esta acción. Revísalos e inténtalo de nuevo.",
4279
4289
  editedLabel: "Editada",
4280
- seeNewerVersion: "Ver la versión más reciente"
4290
+ seeNewerVersion: "Ver la versión más reciente",
4291
+ invalidatedConfigurationChanged: "La herramienta, la cuenta o su configuración cambiaron después de preparar esto. Pídelo de nuevo en el chat.",
4292
+ invalidatedNoSnapshot: "Esta acción la preparó una versión anterior y no se puede ejecutar. Pídelo de nuevo en el chat.",
4293
+ invalidatedResourceChanged: "El evento cambió después de preparar esto, así que no se modificó nada. Pídelo de nuevo en el chat.",
4294
+ unknownOutcome: "El proveedor no confirmó si llegó a ocurrir. Comprueba tus enviados o tu calendario antes de intentarlo de nuevo.",
4295
+ unknownInterrupted: "La acción se interrumpió y no se sabe si llegó a ocurrir. Comprueba tu cuenta antes de intentarlo de nuevo.",
4296
+ applyingNow: "Ya se está aplicando…",
4297
+ errorPlainText: "Usa texto sin formato, sin HTML",
4298
+ errorOffsetMismatch: "El desfase UTC no coincide con la zona horaria del evento",
4299
+ errorNotEditable: "Este campo no se puede editar",
4300
+ errorInvalidValue: "Este valor no es válido"
4281
4301
  },
4282
4302
  ca: {
4283
4303
  searchingMail: "Cercant a {{service}}",
@@ -4367,7 +4387,17 @@ const COPY = {
4367
4387
  errorEndBeforeStart: "El final ha de ser posterior a l’inici",
4368
4388
  editNoLongerApplies: "Els teus canvis ja no s’apliquen a aquesta acció. Revisa’ls i torna-ho a provar.",
4369
4389
  editedLabel: "Editada",
4370
- seeNewerVersion: "Mostra la versió més recent"
4390
+ seeNewerVersion: "Mostra la versió més recent",
4391
+ invalidatedConfigurationChanged: "L’eina, el compte o la seva configuració han canviat després de preparar això. Torna-ho a demanar al xat.",
4392
+ invalidatedNoSnapshot: "Aquesta acció la va preparar una versió anterior i no es pot executar. Torna-ho a demanar al xat.",
4393
+ invalidatedResourceChanged: "L’esdeveniment ha canviat després de preparar això, així que no s’ha modificat res. Torna-ho a demanar al xat.",
4394
+ unknownOutcome: "El proveïdor no ha confirmat si va arribar a passar. Comprova els enviats o el calendari abans de tornar-ho a provar.",
4395
+ unknownInterrupted: "L’acció s’ha interromput i no se sap si va arribar a passar. Comprova el teu compte abans de tornar-ho a provar.",
4396
+ applyingNow: "Ja s’està aplicant…",
4397
+ errorPlainText: "Utilitza text sense format, sense HTML",
4398
+ errorOffsetMismatch: "El desfasament UTC no coincideix amb la zona horària de l’esdeveniment",
4399
+ errorNotEditable: "Aquest camp no es pot editar",
4400
+ errorInvalidValue: "Aquest valor no és vàlid"
4371
4401
  },
4372
4402
  fr: {
4373
4403
  searchingMail: "Recherche dans {{service}}",
@@ -4457,7 +4487,17 @@ const COPY = {
4457
4487
  errorEndBeforeStart: "La fin doit être postérieure au début",
4458
4488
  editNoLongerApplies: "Vos modifications ne s’appliquent plus à cette action. Vérifiez-les et réessayez.",
4459
4489
  editedLabel: "Modifiée",
4460
- seeNewerVersion: "Voir la version la plus récente"
4490
+ seeNewerVersion: "Voir la version la plus récente",
4491
+ invalidatedConfigurationChanged: "L’outil, le compte ou sa configuration ont changé après la préparation. Redemandez-le dans le chat.",
4492
+ invalidatedNoSnapshot: "Cette action a été préparée par une version antérieure et ne peut pas s’exécuter. Redemandez-la dans le chat.",
4493
+ invalidatedResourceChanged: "L’événement a changé après la préparation, donc rien n’a été modifié. Redemandez-le dans le chat.",
4494
+ unknownOutcome: "Le fournisseur n’a pas confirmé si cela a eu lieu. Vérifiez vos envois ou votre agenda avant de réessayer.",
4495
+ unknownInterrupted: "L’action a été interrompue et on ne sait pas si elle a eu lieu. Vérifiez votre compte avant de réessayer.",
4496
+ applyingNow: "Déjà en cours d’application…",
4497
+ errorPlainText: "Utilisez du texte brut, sans HTML",
4498
+ errorOffsetMismatch: "Le décalage UTC ne correspond pas au fuseau horaire de l’événement",
4499
+ errorNotEditable: "Ce champ ne peut pas être modifié",
4500
+ errorInvalidValue: "Cette valeur n’est pas valide"
4461
4501
  },
4462
4502
  it: {
4463
4503
  searchingMail: "Ricerca in {{service}}",
@@ -4547,7 +4587,17 @@ const COPY = {
4547
4587
  errorEndBeforeStart: "La fine deve essere successiva all’inizio",
4548
4588
  editNoLongerApplies: "Le tue modifiche non si applicano più a questa azione. Controllale e riprova.",
4549
4589
  editedLabel: "Modificata",
4550
- seeNewerVersion: "Vedi la versione più recente"
4590
+ seeNewerVersion: "Vedi la versione più recente",
4591
+ invalidatedConfigurationChanged: "Lo strumento, l’account o la sua configurazione sono cambiati dopo la preparazione. Chiedilo di nuovo nella chat.",
4592
+ invalidatedNoSnapshot: "Questa azione è stata preparata da una versione precedente e non può essere eseguita. Chiedilo di nuovo nella chat.",
4593
+ invalidatedResourceChanged: "L’evento è cambiato dopo la preparazione, quindi non è stato modificato nulla. Chiedilo di nuovo nella chat.",
4594
+ unknownOutcome: "Il provider non ha confermato se sia avvenuto. Controlla la posta inviata o il calendario prima di riprovare.",
4595
+ unknownInterrupted: "L’azione è stata interrotta e non si sa se sia avvenuta. Controlla il tuo account prima di riprovare.",
4596
+ applyingNow: "È già in corso di applicazione…",
4597
+ errorPlainText: "Usa testo semplice, senza HTML",
4598
+ errorOffsetMismatch: "Lo scostamento UTC non corrisponde al fuso orario dell’evento",
4599
+ errorNotEditable: "Questo campo non può essere modificato",
4600
+ errorInvalidValue: "Questo valore non è valido"
4551
4601
  },
4552
4602
  de: {
4553
4603
  searchingMail: "Suche in {{service}}",
@@ -4637,7 +4687,17 @@ const COPY = {
4637
4687
  errorEndBeforeStart: "Das Ende muss nach dem Beginn liegen",
4638
4688
  editNoLongerApplies: "Deine Änderungen gelten für diese Aktion nicht mehr. Prüfe sie und versuche es erneut.",
4639
4689
  editedLabel: "Bearbeitet",
4640
- seeNewerVersion: "Neuere Version ansehen"
4690
+ seeNewerVersion: "Neuere Version ansehen",
4691
+ invalidatedConfigurationChanged: "Das Tool, das Konto oder dessen Konfiguration haben sich nach der Vorbereitung geändert. Frag im Chat erneut an.",
4692
+ invalidatedNoSnapshot: "Diese Aktion wurde von einer älteren Version vorbereitet und kann nicht ausgeführt werden. Frag im Chat erneut an.",
4693
+ invalidatedResourceChanged: "Der Termin hat sich nach der Vorbereitung geändert, daher wurde nichts verändert. Frag im Chat erneut an.",
4694
+ unknownOutcome: "Der Anbieter hat nicht bestätigt, ob es passiert ist. Prüfe deine gesendeten Mails oder deinen Kalender, bevor du es erneut versuchst.",
4695
+ unknownInterrupted: "Die Aktion wurde unterbrochen und es ist nicht bekannt, ob sie ausgeführt wurde. Prüfe dein Konto, bevor du es erneut versuchst.",
4696
+ applyingNow: "Wird bereits angewendet…",
4697
+ errorPlainText: "Verwende reinen Text, ohne HTML",
4698
+ errorOffsetMismatch: "Der UTC-Versatz passt nicht zur Zeitzone des Termins",
4699
+ errorNotEditable: "Dieses Feld kann nicht bearbeitet werden",
4700
+ errorInvalidValue: "Dieser Wert ist ungültig"
4641
4701
  },
4642
4702
  da: {
4643
4703
  searchingMail: "Søger i {{service}}",
@@ -4727,7 +4787,17 @@ const COPY = {
4727
4787
  errorEndBeforeStart: "Slutningen skal være efter starten",
4728
4788
  editNoLongerApplies: "Dine ændringer gælder ikke længere for denne handling. Gennemgå dem og prøv igen.",
4729
4789
  editedLabel: "Redigeret",
4730
- seeNewerVersion: "Se den nyere version"
4790
+ seeNewerVersion: "Se den nyere version",
4791
+ invalidatedConfigurationChanged: "Værktøjet, kontoen eller dens konfiguration er ændret, efter at dette blev forberedt. Spørg igen i chatten.",
4792
+ invalidatedNoSnapshot: "Denne handling blev forberedt af en ældre version og kan ikke udføres. Spørg igen i chatten.",
4793
+ invalidatedResourceChanged: "Begivenheden er ændret, efter at dette blev forberedt, så intet blev ændret. Spørg igen i chatten.",
4794
+ unknownOutcome: "Udbyderen bekræftede ikke, om det skete. Tjek dine sendte mails eller din kalender, før du prøver igen.",
4795
+ unknownInterrupted: "Handlingen blev afbrudt, og det vides ikke, om den skete. Tjek din konto, før du prøver igen.",
4796
+ applyingNow: "Bliver allerede anvendt…",
4797
+ errorPlainText: "Brug almindelig tekst uden HTML",
4798
+ errorOffsetMismatch: "UTC-forskydningen passer ikke til begivenhedens tidszone",
4799
+ errorNotEditable: "Dette felt kan ikke redigeres",
4800
+ errorInvalidValue: "Denne værdi er ugyldig"
4731
4801
  },
4732
4802
  sv: {
4733
4803
  searchingMail: "Söker i {{service}}",
@@ -4817,7 +4887,17 @@ const COPY = {
4817
4887
  errorEndBeforeStart: "Slutet måste vara efter starten",
4818
4888
  editNoLongerApplies: "Dina ändringar gäller inte längre för den här åtgärden. Granska dem och försök igen.",
4819
4889
  editedLabel: "Redigerad",
4820
- seeNewerVersion: "Se den nyare versionen"
4890
+ seeNewerVersion: "Se den nyare versionen",
4891
+ invalidatedConfigurationChanged: "Verktyget, kontot eller dess inställningar ändrades efter att detta förbereddes. Fråga igen i chatten.",
4892
+ invalidatedNoSnapshot: "Den här åtgärden förbereddes av en äldre version och kan inte köras. Fråga igen i chatten.",
4893
+ invalidatedResourceChanged: "Händelsen ändrades efter att detta förbereddes, så inget ändrades. Fråga igen i chatten.",
4894
+ unknownOutcome: "Leverantören bekräftade inte om det hände. Kontrollera dina skickade mejl eller din kalender innan du försöker igen.",
4895
+ unknownInterrupted: "Åtgärden avbröts och det är inte känt om den hände. Kontrollera ditt konto innan du försöker igen.",
4896
+ applyingNow: "Tillämpas redan…",
4897
+ errorPlainText: "Använd vanlig text, utan HTML",
4898
+ errorOffsetMismatch: "UTC-förskjutningen stämmer inte med händelsens tidszon",
4899
+ errorNotEditable: "Det här fältet kan inte redigeras",
4900
+ errorInvalidValue: "Det här värdet är ogiltigt"
4821
4901
  },
4822
4902
  no: {
4823
4903
  searchingMail: "Søker i {{service}}",
@@ -4907,7 +4987,17 @@ const COPY = {
4907
4987
  errorEndBeforeStart: "Slutten må være etter starten",
4908
4988
  editNoLongerApplies: "Endringene dine gjelder ikke lenger for denne handlingen. Gå gjennom dem og prøv igjen.",
4909
4989
  editedLabel: "Redigert",
4910
- seeNewerVersion: "Se den nyere versjonen"
4990
+ seeNewerVersion: "Se den nyere versjonen",
4991
+ invalidatedConfigurationChanged: "Verktøyet, kontoen eller konfigurasjonen ble endret etter at dette ble forberedt. Spør igjen i chatten.",
4992
+ invalidatedNoSnapshot: "Denne handlingen ble forberedt av en eldre versjon og kan ikke kjøres. Spør igjen i chatten.",
4993
+ invalidatedResourceChanged: "Hendelsen ble endret etter at dette ble forberedt, så ingenting ble endret. Spør igjen i chatten.",
4994
+ unknownOutcome: "Leverandøren bekreftet ikke om det skjedde. Sjekk sendte e-poster eller kalenderen før du prøver igjen.",
4995
+ unknownInterrupted: "Handlingen ble avbrutt, og det er ikke kjent om den skjedde. Sjekk kontoen din før du prøver igjen.",
4996
+ applyingNow: "Blir allerede brukt…",
4997
+ errorPlainText: "Bruk vanlig tekst, uten HTML",
4998
+ errorOffsetMismatch: "UTC-forskyvningen stemmer ikke med hendelsens tidssone",
4999
+ errorNotEditable: "Dette feltet kan ikke redigeres",
5000
+ errorInvalidValue: "Denne verdien er ugyldig"
4911
5001
  },
4912
5002
  pt: {
4913
5003
  searchingMail: "Pesquisando no {{service}}",
@@ -4997,7 +5087,17 @@ const COPY = {
4997
5087
  errorEndBeforeStart: "O fim deve ser posterior ao início",
4998
5088
  editNoLongerApplies: "Suas alterações não se aplicam mais a esta ação. Revise-as e tente novamente.",
4999
5089
  editedLabel: "Editada",
5000
- seeNewerVersion: "Ver a versão mais recente"
5090
+ seeNewerVersion: "Ver a versão mais recente",
5091
+ invalidatedConfigurationChanged: "A ferramenta, a conta ou a configuração mudaram depois de preparar isto. Peça de novo no chat.",
5092
+ invalidatedNoSnapshot: "Esta ação foi preparada por uma versão anterior e não pode ser executada. Peça de novo no chat.",
5093
+ invalidatedResourceChanged: "O evento mudou depois de preparar isto, então nada foi modificado. Peça de novo no chat.",
5094
+ unknownOutcome: "O provedor não confirmou se aconteceu. Verifique seus enviados ou sua agenda antes de tentar de novo.",
5095
+ unknownInterrupted: "A ação foi interrompida e não se sabe se aconteceu. Verifique sua conta antes de tentar de novo.",
5096
+ applyingNow: "Já está sendo aplicado…",
5097
+ errorPlainText: "Use texto simples, sem HTML",
5098
+ errorOffsetMismatch: "O deslocamento UTC não corresponde ao fuso horário do evento",
5099
+ errorNotEditable: "Este campo não pode ser editado",
5100
+ errorInvalidValue: "Este valor não é válido"
5001
5101
  }
5002
5102
  };
5003
5103
  function getPersonalConnectorCopy(locale) {
@@ -5040,6 +5140,28 @@ function editableFields(pending) {
5040
5140
  const allowed = new Set(pending.editable ?? []);
5041
5141
  return FIELD_ORDER.filter((field) => allowed.has(field));
5042
5142
  }
5143
+ /**
5144
+ * Copy of each stable code the server sends for a rejected edit. A code this client does
5145
+ * not know falls back to the server's English message instead of hiding the problem.
5146
+ */
5147
+ const SERVER_ERROR_COPY = {
5148
+ needs_recipient: "errorNoRecipients",
5149
+ invalid_address: "errorInvalidAddress",
5150
+ must_be_address_list: "errorInvalidAddress",
5151
+ too_many_addresses: "errorInvalidAddress",
5152
+ cannot_be_empty: "errorRequired",
5153
+ cannot_be_null: "errorRequired",
5154
+ plain_text_only: "errorPlainText",
5155
+ invalid_datetime: "errorInvalidDateTime",
5156
+ ambiguous_time: "errorAmbiguousTime",
5157
+ end_before_start: "errorEndBeforeStart",
5158
+ offset_mismatch: "errorOffsetMismatch",
5159
+ not_editable: "errorNotEditable",
5160
+ cannot_change: "errorNotEditable",
5161
+ not_replaceable: "errorNotEditable",
5162
+ must_be_text: "errorInvalidValue",
5163
+ too_long: "errorInvalidValue"
5164
+ };
5043
5165
  const OFFSET_SUFFIX = /(Z|[+-]\d{2}:?\d{2})$/i;
5044
5166
  function parseOffsetMinutes(value) {
5045
5167
  const match = OFFSET_SUFFIX.exec(value.trim());
@@ -5276,7 +5398,9 @@ function ToolConfirmationEditForm({ pending, draft, onChange, errors, serverErro
5276
5398
  const id = `${baseId}-${field}`;
5277
5399
  const errorId = `${id}-error`;
5278
5400
  const clientError = errors[field];
5279
- const message = clientError ? fillCopy(copy[ERROR_COPY[clientError.key]], { zone: clientError.zone ?? zone }) : serverErrors[field];
5401
+ const serverError = serverErrors[field];
5402
+ const serverKey = serverError?.code ? SERVER_ERROR_COPY[serverError.code] : void 0;
5403
+ const message = clientError ? fillCopy(copy[ERROR_COPY[clientError.key]], { zone: clientError.zone ?? zone }) : serverKey ? fillCopy(copy[serverKey], { zone }) : serverError?.message;
5280
5404
  const common = {
5281
5405
  id,
5282
5406
  name: field,
@@ -5372,6 +5496,26 @@ function statusLabel(status, copy) {
5372
5496
  const key = STATUS_COPY[status];
5373
5497
  return key ? copy[key] : null;
5374
5498
  }
5499
+ const REASON_COPY = {
5500
+ invalidated: {
5501
+ configuration_changed: "invalidatedConfigurationChanged",
5502
+ no_snapshot: "invalidatedNoSnapshot",
5503
+ resource_changed: "invalidatedResourceChanged"
5504
+ },
5505
+ unknown: {
5506
+ outcome_unknown: "unknownOutcome",
5507
+ interrupted: "unknownInterrupted"
5508
+ }
5509
+ };
5510
+ /**
5511
+ * Why an action ended as `invalidated` or `unknown`, from the safe reason code the
5512
+ * server stores. A code this client does not know shows nothing extra: the status
5513
+ * label still says what happened.
5514
+ */
5515
+ function reasonLabel(status, reason, copy) {
5516
+ const key = reason ? REASON_COPY[status]?.[reason] : void 0;
5517
+ return key ? copy[key] : null;
5518
+ }
5375
5519
  const BADGE_TONE = {
5376
5520
  pending: "border-warning-border bg-warning-subtle text-warning-strong",
5377
5521
  executing: "border-sky-200 bg-sky-50 text-sky-800",
@@ -5403,16 +5547,28 @@ function expiryText(state, serverOffsetMs, now, copy) {
5403
5547
  function saveLabel(operation, copy) {
5404
5548
  return operation === "send" ? copy.saveAndSend : copy.saveAndConfirm;
5405
5549
  }
5406
- /** Scrolls to the card of another version of the same action, if it is on screen. */
5550
+ const HIGHLIGHT = [
5551
+ "ring-2",
5552
+ "ring-border-strong",
5553
+ "transition-shadow"
5554
+ ];
5555
+ /**
5556
+ * Scrolls to the card of another version of the same action and flashes it, so the eye finds
5557
+ * it. Returns whether that card is on screen (it may not be, e.g. older history not loaded).
5558
+ */
5407
5559
  function showAction(actionId) {
5408
- if (typeof document === "undefined") return;
5409
- for (const element of document.querySelectorAll("[data-confirmation-action]")) if (element.getAttribute("data-confirmation-action") === actionId) {
5560
+ if (typeof document === "undefined") return false;
5561
+ for (const element of document.querySelectorAll("[data-confirmation-action]")) {
5562
+ if (element.getAttribute("data-confirmation-action") !== actionId) continue;
5410
5563
  element.scrollIntoView?.({
5411
5564
  block: "center",
5412
5565
  behavior: "smooth"
5413
5566
  });
5414
- return;
5567
+ element.classList.add(...HIGHLIGHT);
5568
+ setTimeout(() => element.classList.remove(...HIGHLIGHT), 1600);
5569
+ return true;
5415
5570
  }
5571
+ return false;
5416
5572
  }
5417
5573
  /**
5418
5574
  * Footer of a held action. Without `toolConfirmation` it keeps the text hint
@@ -5429,6 +5585,7 @@ function PendingConfirmationFooter({ pending, toolConfirmation, copy }) {
5429
5585
  const [draft, setDraft] = useState({});
5430
5586
  const [fieldErrors, setFieldErrors] = useState({});
5431
5587
  const [serverErrors, setServerErrors] = useState({});
5588
+ const [applying, setApplying] = useState(false);
5432
5589
  if (!toolConfirmation) return /* @__PURE__ */ jsx("p", {
5433
5590
  className: "border-t border-border bg-warning-subtle/60 px-3 py-2 text-xs text-strong",
5434
5591
  children: copy.confirmHint
@@ -5440,11 +5597,17 @@ function PendingConfirmationFooter({ pending, toolConfirmation, copy }) {
5440
5597
  });
5441
5598
  if (state.status !== "pending") {
5442
5599
  const label = statusLabel(state.status, copy);
5600
+ const reason = reasonLabel(state.status, state.error, copy);
5443
5601
  return label ? /* @__PURE__ */ jsxs("p", {
5444
5602
  className: "flex flex-wrap items-center gap-2 border-t border-divider bg-surface-muted px-3 py-2 text-xs text-strong",
5445
5603
  "aria-live": "polite",
5446
5604
  children: [
5447
5605
  /* @__PURE__ */ jsxs("span", { children: [label, state.status === "failed" && state.error ? `: ${state.error}` : null] }),
5606
+ reason ? /* @__PURE__ */ jsx("span", {
5607
+ className: "basis-full text-muted",
5608
+ "data-confirmation-reason": true,
5609
+ children: reason
5610
+ }) : null,
5448
5611
  state.status === "superseded" && state.supersededBy ? /* @__PURE__ */ jsx("button", {
5449
5612
  type: "button",
5450
5613
  className: "underline underline-offset-2 hover:text-foreground",
@@ -5460,10 +5623,15 @@ function PendingConfirmationFooter({ pending, toolConfirmation, copy }) {
5460
5623
  }
5461
5624
  const decide = async (decisions) => {
5462
5625
  setFailed(false);
5626
+ setApplying(false);
5463
5627
  try {
5464
5628
  await toolConfirmation.decide(decisions);
5465
5629
  } catch (error) {
5466
- if (error instanceof ToolDecisionRejectedError && error.details.actionId === pending.action_id) setServerErrors(Object.fromEntries(error.details.errors.map(({ field, message }) => [field, message])));
5630
+ if (error instanceof ToolDecisionRejectedError && error.details.actionId === pending.action_id) setServerErrors(Object.fromEntries(error.details.errors.map(({ field, message, code }) => [field, {
5631
+ message,
5632
+ ...code ? { code } : {}
5633
+ }])));
5634
+ else if (error instanceof ToolSubmissionConflictError && error.details.code === "decision_in_progress") setApplying(true);
5467
5635
  else setFailed(true);
5468
5636
  }
5469
5637
  };
@@ -5562,7 +5730,7 @@ function PendingConfirmationFooter({ pending, toolConfirmation, copy }) {
5562
5730
  /* @__PURE__ */ jsx("span", {
5563
5731
  className: "ml-auto text-xs text-secondary",
5564
5732
  "aria-live": "polite",
5565
- children: failed ? copy.decisionError : unavailable ? copy.toolUnavailable : editStale ? copy.editNoLongerApplies : expiry
5733
+ children: failed ? copy.decisionError : applying ? copy.applyingNow : unavailable ? copy.toolUnavailable : editStale ? copy.editNoLongerApplies : expiry
5566
5734
  })
5567
5735
  ]
5568
5736
  })] });
@@ -6188,8 +6356,46 @@ function ToolResultPersonalConnectorCard({ part, locale, className, toolConfirma
6188
6356
  const Icon = isCalendar(connector) ? CalendarDays : Mail;
6189
6357
  const total = headerCount(view, copy);
6190
6358
  const isPending = view.kind === "pending-mail" || view.kind === "pending-event";
6359
+ if (pending && confirmationState?.status === "superseded") {
6360
+ const summary = text(pending.action.subject) ?? text(pending.action.title) ?? copy.noSubject;
6361
+ return /* @__PURE__ */ jsx("section", {
6362
+ className: joinClasses("plai-tool-result-personal-connector-card plai-superseded overflow-hidden rounded-lg border border-border bg-surface text-foreground", className),
6363
+ "data-tool-call-id": part.id,
6364
+ "data-tool-call-state": part.state,
6365
+ "data-connector-action": view.kind,
6366
+ "data-confirmation-action": pending.action_id,
6367
+ "data-confirmation-status": "superseded",
6368
+ children: /* @__PURE__ */ jsxs("div", {
6369
+ className: "flex flex-wrap items-center gap-x-2 gap-y-1 px-3 py-2 text-xs text-secondary",
6370
+ children: [
6371
+ /* @__PURE__ */ jsx(Icon, {
6372
+ className: "h-4 w-4 shrink-0 text-muted",
6373
+ "aria-hidden": "true"
6374
+ }),
6375
+ /* @__PURE__ */ jsx("span", {
6376
+ className: "shrink-0 font-medium text-muted",
6377
+ children: connector?.label
6378
+ }),
6379
+ /* @__PURE__ */ jsx("span", {
6380
+ className: "min-w-0 flex-1 truncate text-muted",
6381
+ children: summary
6382
+ }),
6383
+ /* @__PURE__ */ jsx("span", {
6384
+ className: "shrink-0 text-muted",
6385
+ children: copy.statusSuperseded
6386
+ }),
6387
+ confirmationState.supersededBy ? /* @__PURE__ */ jsx("button", {
6388
+ type: "button",
6389
+ className: "shrink-0 underline underline-offset-2 hover:text-foreground",
6390
+ onClick: () => showAction(confirmationState.supersededBy),
6391
+ children: copy.seeNewerVersion
6392
+ }) : null
6393
+ ]
6394
+ })
6395
+ });
6396
+ }
6191
6397
  return /* @__PURE__ */ jsxs("section", {
6192
- className: joinClasses("plai-tool-result-personal-connector-card overflow-hidden rounded-lg border border-border bg-surface text-foreground", confirmationState?.status === "superseded" ? "opacity-60" : void 0, className),
6398
+ className: joinClasses("plai-tool-result-personal-connector-card overflow-hidden rounded-lg border border-border bg-surface text-foreground", className),
6193
6399
  "data-tool-call-id": part.id,
6194
6400
  "data-tool-call-state": part.state,
6195
6401
  "data-connector-action": view.kind,
@@ -6355,6 +6561,7 @@ function ToolResultPendingConfirmationCard({ part, locale, className, toolConfir
6355
6561
  className: joinClasses("plai-tool-result-pending-confirmation-card overflow-hidden rounded-lg border border-border bg-surface text-foreground", className),
6356
6562
  "data-tool-call-id": part.id,
6357
6563
  "data-tool-call-state": part.state,
6564
+ "data-confirmation-action": pending.action_id,
6358
6565
  children: [
6359
6566
  /* @__PURE__ */ jsxs("header", {
6360
6567
  className: "flex items-center gap-2 border-b border-border px-3 py-2 text-xs text-secondary",
@@ -6713,6 +6920,15 @@ function getDatasourceResourceLinks(part) {
6713
6920
  const links = part.metadata.resource_links;
6714
6921
  return Array.isArray(links) ? links.filter(isResourceLink) : [];
6715
6922
  }
6923
+ /**
6924
+ * A held mail or calendar action, whichever tool reported it. The result of
6925
+ * `replace_pending_action` is a `tool_confirmation` result that carries the new version
6926
+ * with the connector's metadata: it must look exactly as preparing it did (the mail or
6927
+ * event card), not like an anonymous tool with its arguments as JSON.
6928
+ */
6929
+ function isConnectorPending(part) {
6930
+ return part.metadata?.type === "personal_connector" && !!getPendingConfirmation(part);
6931
+ }
6716
6932
  function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAgentThread, getResourceDownloadUrl, memoryProposal, toolConfirmation }) {
6717
6933
  const copy = getUiCopy(locale);
6718
6934
  if (part.toolType === "memory_proposal") {
@@ -6741,7 +6957,7 @@ function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAge
6741
6957
  locale,
6742
6958
  className
6743
6959
  });
6744
- if (part.toolType !== "personal_connector" && getPendingConfirmation(part)) return /* @__PURE__ */ jsx(ToolResultPendingConfirmationCard, {
6960
+ if (part.toolType !== "personal_connector" && !isConnectorPending(part) && getPendingConfirmation(part)) return /* @__PURE__ */ jsx(ToolResultPendingConfirmationCard, {
6745
6961
  part,
6746
6962
  locale,
6747
6963
  className,
@@ -6786,7 +7002,7 @@ function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAge
6786
7002
  locale,
6787
7003
  className
6788
7004
  });
6789
- if (part.toolType === "personal_connector" && hasPersonalConnectorView(part)) return /* @__PURE__ */ jsx(ToolResultPersonalConnectorCard, {
7005
+ if ((part.toolType === "personal_connector" || isConnectorPending(part)) && hasPersonalConnectorView(part)) return /* @__PURE__ */ jsx(ToolResultPersonalConnectorCard, {
6790
7006
  part,
6791
7007
  locale,
6792
7008
  className,
@@ -8059,5 +8275,5 @@ function ConversationFilesSheet({ messages, locale, className, open, onOpenChang
8059
8275
  }
8060
8276
 
8061
8277
  //#endregion
8062
- export { AggregatedSourceResults, ArrowUp, AssistantMessage, ChatError, Clipboard, ConfirmationBadge, ConversationFilesList, ConversationFilesSheet, DatasourceFolderCard, DatasourceToolResources, DatasourceToolResultCard, Loader, MemoryProposalCard, Message, MessageAvatar, MessageContent, MessageFooter, MessageHeader, MessageParts, MessageRoot, Microphone, PROMPT_FORM_FILE_ACCEPT, Paperclip, PendingConfirmationFooter, PromptForm, PromptFormAttachButton, PromptFormIconButton, Reload, ResourceCard, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, SpeechToTextToggle, Stop, Thinking, ThumbDown, ThumbUp, ToolError, ToolResultAgentInvocationCard, ToolResultBrowserCard, ToolResultCard, ToolResultExternalDatasourceCard, ToolResultHttpRequestCard, ToolResultMcpCard, ToolResultOfficeDocumentsCard, ToolResultPendingConfirmationCard, ToolResultPersonalConnectorCard, ToolResultToolConfirmationCard, ToolResultWebSearchCard, ToolResultWorkflowDispatchCard, ToolUseIndicator, UserMessage, X, dummyTranscribeAudio, getConversationFiles, getLocalizedOpenGraphValue, getPendingConfirmation, getResourceDescription, getResourceIcon, getResourceOpenGraphImage, getResourceOpenGraphType, getResourceTitle, getResourceType, getResourceUrl, getToolUseLabel, hasPersonalConnectorView, hasToolConfirmationView, isAllowedPromptFormFile, partitionPromptFormFiles, useSpeechToText };
8278
+ export { AggregatedSourceResults, ArrowUp, AssistantMessage, ChatError, Clipboard, ConfirmationBadge, ConversationFilesList, ConversationFilesSheet, DatasourceFolderCard, DatasourceToolResources, DatasourceToolResultCard, Loader, MemoryProposalCard, Message, MessageAvatar, MessageContent, MessageFooter, MessageHeader, MessageParts, MessageRoot, Microphone, PROMPT_FORM_FILE_ACCEPT, Paperclip, PendingConfirmationFooter, PromptForm, PromptFormAttachButton, PromptFormIconButton, Reload, ResourceCard, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, SpeechToTextToggle, Stop, Thinking, ThumbDown, ThumbUp, ToolError, ToolResultAgentInvocationCard, ToolResultBrowserCard, ToolResultCard, ToolResultExternalDatasourceCard, ToolResultHttpRequestCard, ToolResultMcpCard, ToolResultOfficeDocumentsCard, ToolResultPendingConfirmationCard, ToolResultPersonalConnectorCard, ToolResultToolConfirmationCard, ToolResultWebSearchCard, ToolResultWorkflowDispatchCard, ToolUseIndicator, UserMessage, X, dummyTranscribeAudio, getConversationFiles, getLocalizedOpenGraphValue, getPendingConfirmation, getResourceDescription, getResourceIcon, getResourceOpenGraphImage, getResourceOpenGraphType, getResourceTitle, getResourceType, getResourceUrl, getToolUseLabel, hasPersonalConnectorView, hasToolConfirmationView, isAllowedPromptFormFile, partitionPromptFormFiles, reasonLabel, useSpeechToText };
8063
8279
  //# sourceMappingURL=index.js.map