@plaisolutions/react 0.20.0 → 0.21.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/dist/components/index.d.ts +80 -60
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +633 -34
- package/dist/components/index.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +633 -34
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +2 -2
package/dist/components/index.js
CHANGED
|
@@ -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, isHiddenMessage, toolConfirmationAt } from "@plaisolutions/client";
|
|
4
|
+
import { HttpStatusError, ToolDecisionRejectedError, isHiddenMessage, toolConfirmationAt } from "@plaisolutions/client";
|
|
5
5
|
|
|
6
6
|
//#region src/components/internal/join-classes.ts
|
|
7
7
|
function joinClasses(...classes) {
|
|
@@ -4167,7 +4167,25 @@ const ENGLISH = {
|
|
|
4167
4167
|
statusUnknown: "Outcome unknown: check before trying again",
|
|
4168
4168
|
statusNotFound: "Not available in this conversation",
|
|
4169
4169
|
toolUnavailable: "The tool for this action isn’t available right now",
|
|
4170
|
-
decisionError: "Your decision couldn’t be sent. Try again."
|
|
4170
|
+
decisionError: "Your decision couldn’t be sent. Try again.",
|
|
4171
|
+
edit: "Edit",
|
|
4172
|
+
saveAndSend: "Save and send",
|
|
4173
|
+
saveAndConfirm: "Save and confirm",
|
|
4174
|
+
discardEdit: "Discard changes",
|
|
4175
|
+
fieldBody: "Message",
|
|
4176
|
+
fieldStart: "Starts",
|
|
4177
|
+
fieldEnd: "Ends",
|
|
4178
|
+
addressesHint: "Separate addresses with commas",
|
|
4179
|
+
timeZoneNote: "Time zone: {{zone}}",
|
|
4180
|
+
errorRequired: "This field can’t be empty",
|
|
4181
|
+
errorNoRecipients: "Add at least one recipient",
|
|
4182
|
+
errorInvalidAddress: "Enter valid email addresses",
|
|
4183
|
+
errorInvalidDateTime: "Enter a valid date and time",
|
|
4184
|
+
errorAmbiguousTime: "This time doesn’t exist or happens twice in {{zone}}. Pick another time.",
|
|
4185
|
+
errorEndBeforeStart: "The end must be after the start",
|
|
4186
|
+
editNoLongerApplies: "Your changes no longer apply to this action. Review them and try again.",
|
|
4187
|
+
editedLabel: "Edited",
|
|
4188
|
+
seeNewerVersion: "See the newer version"
|
|
4171
4189
|
};
|
|
4172
4190
|
const COPY = {
|
|
4173
4191
|
en: {},
|
|
@@ -4241,7 +4259,25 @@ const COPY = {
|
|
|
4241
4259
|
statusUnknown: "Resultado desconocido: compruébalo antes de repetirlo",
|
|
4242
4260
|
statusNotFound: "No disponible en esta conversación",
|
|
4243
4261
|
toolUnavailable: "La herramienta de esta acción no está disponible ahora",
|
|
4244
|
-
decisionError: "No se pudo enviar tu decisión. Inténtalo de nuevo."
|
|
4262
|
+
decisionError: "No se pudo enviar tu decisión. Inténtalo de nuevo.",
|
|
4263
|
+
edit: "Editar",
|
|
4264
|
+
saveAndSend: "Guardar y enviar",
|
|
4265
|
+
saveAndConfirm: "Guardar y confirmar",
|
|
4266
|
+
discardEdit: "Descartar cambios",
|
|
4267
|
+
fieldBody: "Mensaje",
|
|
4268
|
+
fieldStart: "Empieza",
|
|
4269
|
+
fieldEnd: "Termina",
|
|
4270
|
+
addressesHint: "Separa las direcciones con comas",
|
|
4271
|
+
timeZoneNote: "Zona horaria: {{zone}}",
|
|
4272
|
+
errorRequired: "Este campo no puede estar vacío",
|
|
4273
|
+
errorNoRecipients: "Añade al menos un destinatario",
|
|
4274
|
+
errorInvalidAddress: "Introduce direcciones de correo válidas",
|
|
4275
|
+
errorInvalidDateTime: "Introduce una fecha y hora válidas",
|
|
4276
|
+
errorAmbiguousTime: "Esta hora no existe o se repite en {{zone}}. Elige otra hora.",
|
|
4277
|
+
errorEndBeforeStart: "El final debe ser posterior al inicio",
|
|
4278
|
+
editNoLongerApplies: "Tus cambios ya no se aplican a esta acción. Revísalos e inténtalo de nuevo.",
|
|
4279
|
+
editedLabel: "Editada",
|
|
4280
|
+
seeNewerVersion: "Ver la versión más reciente"
|
|
4245
4281
|
},
|
|
4246
4282
|
ca: {
|
|
4247
4283
|
searchingMail: "Cercant a {{service}}",
|
|
@@ -4313,7 +4349,25 @@ const COPY = {
|
|
|
4313
4349
|
statusUnknown: "Resultat desconegut: comprova-ho abans de repetir-ho",
|
|
4314
4350
|
statusNotFound: "No disponible en aquesta conversa",
|
|
4315
4351
|
toolUnavailable: "L’eina d’aquesta acció no està disponible ara",
|
|
4316
|
-
decisionError: "No s’ha pogut enviar la teva decisió. Torna-ho a provar."
|
|
4352
|
+
decisionError: "No s’ha pogut enviar la teva decisió. Torna-ho a provar.",
|
|
4353
|
+
edit: "Edita",
|
|
4354
|
+
saveAndSend: "Desa i envia",
|
|
4355
|
+
saveAndConfirm: "Desa i confirma",
|
|
4356
|
+
discardEdit: "Descarta els canvis",
|
|
4357
|
+
fieldBody: "Missatge",
|
|
4358
|
+
fieldStart: "Comença",
|
|
4359
|
+
fieldEnd: "Acaba",
|
|
4360
|
+
addressesHint: "Separa les adreces amb comes",
|
|
4361
|
+
timeZoneNote: "Zona horària: {{zone}}",
|
|
4362
|
+
errorRequired: "Aquest camp no pot estar buit",
|
|
4363
|
+
errorNoRecipients: "Afegeix com a mínim un destinatari",
|
|
4364
|
+
errorInvalidAddress: "Introdueix adreces de correu vàlides",
|
|
4365
|
+
errorInvalidDateTime: "Introdueix una data i hora vàlides",
|
|
4366
|
+
errorAmbiguousTime: "Aquesta hora no existeix o es repeteix a {{zone}}. Tria una altra hora.",
|
|
4367
|
+
errorEndBeforeStart: "El final ha de ser posterior a l’inici",
|
|
4368
|
+
editNoLongerApplies: "Els teus canvis ja no s’apliquen a aquesta acció. Revisa’ls i torna-ho a provar.",
|
|
4369
|
+
editedLabel: "Editada",
|
|
4370
|
+
seeNewerVersion: "Mostra la versió més recent"
|
|
4317
4371
|
},
|
|
4318
4372
|
fr: {
|
|
4319
4373
|
searchingMail: "Recherche dans {{service}}",
|
|
@@ -4385,7 +4439,25 @@ const COPY = {
|
|
|
4385
4439
|
statusUnknown: "Résultat inconnu : vérifiez avant de réessayer",
|
|
4386
4440
|
statusNotFound: "Indisponible dans cette conversation",
|
|
4387
4441
|
toolUnavailable: "L’outil de cette action n’est pas disponible pour le moment",
|
|
4388
|
-
decisionError: "Impossible d’envoyer votre décision. Réessayez."
|
|
4442
|
+
decisionError: "Impossible d’envoyer votre décision. Réessayez.",
|
|
4443
|
+
edit: "Modifier",
|
|
4444
|
+
saveAndSend: "Enregistrer et envoyer",
|
|
4445
|
+
saveAndConfirm: "Enregistrer et confirmer",
|
|
4446
|
+
discardEdit: "Annuler les modifications",
|
|
4447
|
+
fieldBody: "Message",
|
|
4448
|
+
fieldStart: "Début",
|
|
4449
|
+
fieldEnd: "Fin",
|
|
4450
|
+
addressesHint: "Séparez les adresses par des virgules",
|
|
4451
|
+
timeZoneNote: "Fuseau horaire : {{zone}}",
|
|
4452
|
+
errorRequired: "Ce champ ne peut pas être vide",
|
|
4453
|
+
errorNoRecipients: "Ajoutez au moins un destinataire",
|
|
4454
|
+
errorInvalidAddress: "Saisissez des adresses e-mail valides",
|
|
4455
|
+
errorInvalidDateTime: "Saisissez une date et une heure valides",
|
|
4456
|
+
errorAmbiguousTime: "Cette heure n’existe pas ou se répète en {{zone}}. Choisissez une autre heure.",
|
|
4457
|
+
errorEndBeforeStart: "La fin doit être postérieure au début",
|
|
4458
|
+
editNoLongerApplies: "Vos modifications ne s’appliquent plus à cette action. Vérifiez-les et réessayez.",
|
|
4459
|
+
editedLabel: "Modifiée",
|
|
4460
|
+
seeNewerVersion: "Voir la version la plus récente"
|
|
4389
4461
|
},
|
|
4390
4462
|
it: {
|
|
4391
4463
|
searchingMail: "Ricerca in {{service}}",
|
|
@@ -4457,7 +4529,25 @@ const COPY = {
|
|
|
4457
4529
|
statusUnknown: "Esito sconosciuto: verifica prima di riprovare",
|
|
4458
4530
|
statusNotFound: "Non disponibile in questa conversazione",
|
|
4459
4531
|
toolUnavailable: "Lo strumento di questa azione non è disponibile ora",
|
|
4460
|
-
decisionError: "Impossibile inviare la tua decisione. Riprova."
|
|
4532
|
+
decisionError: "Impossibile inviare la tua decisione. Riprova.",
|
|
4533
|
+
edit: "Modifica",
|
|
4534
|
+
saveAndSend: "Salva e invia",
|
|
4535
|
+
saveAndConfirm: "Salva e conferma",
|
|
4536
|
+
discardEdit: "Annulla le modifiche",
|
|
4537
|
+
fieldBody: "Messaggio",
|
|
4538
|
+
fieldStart: "Inizio",
|
|
4539
|
+
fieldEnd: "Fine",
|
|
4540
|
+
addressesHint: "Separa gli indirizzi con virgole",
|
|
4541
|
+
timeZoneNote: "Fuso orario: {{zone}}",
|
|
4542
|
+
errorRequired: "Questo campo non può essere vuoto",
|
|
4543
|
+
errorNoRecipients: "Aggiungi almeno un destinatario",
|
|
4544
|
+
errorInvalidAddress: "Inserisci indirizzi e-mail validi",
|
|
4545
|
+
errorInvalidDateTime: "Inserisci una data e un’ora valide",
|
|
4546
|
+
errorAmbiguousTime: "Questo orario non esiste o si ripete in {{zone}}. Scegli un altro orario.",
|
|
4547
|
+
errorEndBeforeStart: "La fine deve essere successiva all’inizio",
|
|
4548
|
+
editNoLongerApplies: "Le tue modifiche non si applicano più a questa azione. Controllale e riprova.",
|
|
4549
|
+
editedLabel: "Modificata",
|
|
4550
|
+
seeNewerVersion: "Vedi la versione più recente"
|
|
4461
4551
|
},
|
|
4462
4552
|
de: {
|
|
4463
4553
|
searchingMail: "Suche in {{service}}",
|
|
@@ -4529,7 +4619,25 @@ const COPY = {
|
|
|
4529
4619
|
statusUnknown: "Ergebnis unbekannt: vor dem Wiederholen prüfen",
|
|
4530
4620
|
statusNotFound: "In dieser Unterhaltung nicht verfügbar",
|
|
4531
4621
|
toolUnavailable: "Das Tool für diese Aktion ist gerade nicht verfügbar",
|
|
4532
|
-
decisionError: "Deine Entscheidung konnte nicht gesendet werden. Versuche es erneut."
|
|
4622
|
+
decisionError: "Deine Entscheidung konnte nicht gesendet werden. Versuche es erneut.",
|
|
4623
|
+
edit: "Bearbeiten",
|
|
4624
|
+
saveAndSend: "Speichern und senden",
|
|
4625
|
+
saveAndConfirm: "Speichern und bestätigen",
|
|
4626
|
+
discardEdit: "Änderungen verwerfen",
|
|
4627
|
+
fieldBody: "Nachricht",
|
|
4628
|
+
fieldStart: "Beginn",
|
|
4629
|
+
fieldEnd: "Ende",
|
|
4630
|
+
addressesHint: "Adressen durch Kommas trennen",
|
|
4631
|
+
timeZoneNote: "Zeitzone: {{zone}}",
|
|
4632
|
+
errorRequired: "Dieses Feld darf nicht leer sein",
|
|
4633
|
+
errorNoRecipients: "Füge mindestens einen Empfänger hinzu",
|
|
4634
|
+
errorInvalidAddress: "Gib gültige E-Mail-Adressen ein",
|
|
4635
|
+
errorInvalidDateTime: "Gib ein gültiges Datum und eine gültige Uhrzeit ein",
|
|
4636
|
+
errorAmbiguousTime: "Diese Uhrzeit existiert in {{zone}} nicht oder kommt doppelt vor. Wähle eine andere Uhrzeit.",
|
|
4637
|
+
errorEndBeforeStart: "Das Ende muss nach dem Beginn liegen",
|
|
4638
|
+
editNoLongerApplies: "Deine Änderungen gelten für diese Aktion nicht mehr. Prüfe sie und versuche es erneut.",
|
|
4639
|
+
editedLabel: "Bearbeitet",
|
|
4640
|
+
seeNewerVersion: "Neuere Version ansehen"
|
|
4533
4641
|
},
|
|
4534
4642
|
da: {
|
|
4535
4643
|
searchingMail: "Søger i {{service}}",
|
|
@@ -4601,7 +4709,25 @@ const COPY = {
|
|
|
4601
4709
|
statusUnknown: "Ukendt resultat: tjek før du prøver igen",
|
|
4602
4710
|
statusNotFound: "Ikke tilgængelig i denne samtale",
|
|
4603
4711
|
toolUnavailable: "Værktøjet til denne handling er ikke tilgængeligt lige nu",
|
|
4604
|
-
decisionError: "Din beslutning kunne ikke sendes. Prøv igen."
|
|
4712
|
+
decisionError: "Din beslutning kunne ikke sendes. Prøv igen.",
|
|
4713
|
+
edit: "Rediger",
|
|
4714
|
+
saveAndSend: "Gem og send",
|
|
4715
|
+
saveAndConfirm: "Gem og bekræft",
|
|
4716
|
+
discardEdit: "Kassér ændringer",
|
|
4717
|
+
fieldBody: "Besked",
|
|
4718
|
+
fieldStart: "Starter",
|
|
4719
|
+
fieldEnd: "Slutter",
|
|
4720
|
+
addressesHint: "Adskil adresser med komma",
|
|
4721
|
+
timeZoneNote: "Tidszone: {{zone}}",
|
|
4722
|
+
errorRequired: "Feltet må ikke være tomt",
|
|
4723
|
+
errorNoRecipients: "Tilføj mindst én modtager",
|
|
4724
|
+
errorInvalidAddress: "Angiv gyldige mailadresser",
|
|
4725
|
+
errorInvalidDateTime: "Angiv en gyldig dato og tid",
|
|
4726
|
+
errorAmbiguousTime: "Dette tidspunkt findes ikke eller forekommer to gange i {{zone}}. Vælg et andet tidspunkt.",
|
|
4727
|
+
errorEndBeforeStart: "Slutningen skal være efter starten",
|
|
4728
|
+
editNoLongerApplies: "Dine ændringer gælder ikke længere for denne handling. Gennemgå dem og prøv igen.",
|
|
4729
|
+
editedLabel: "Redigeret",
|
|
4730
|
+
seeNewerVersion: "Se den nyere version"
|
|
4605
4731
|
},
|
|
4606
4732
|
sv: {
|
|
4607
4733
|
searchingMail: "Söker i {{service}}",
|
|
@@ -4673,7 +4799,25 @@ const COPY = {
|
|
|
4673
4799
|
statusUnknown: "Okänt resultat: kontrollera innan du försöker igen",
|
|
4674
4800
|
statusNotFound: "Inte tillgänglig i den här konversationen",
|
|
4675
4801
|
toolUnavailable: "Verktyget för den här åtgärden är inte tillgängligt just nu",
|
|
4676
|
-
decisionError: "Ditt beslut kunde inte skickas. Försök igen."
|
|
4802
|
+
decisionError: "Ditt beslut kunde inte skickas. Försök igen.",
|
|
4803
|
+
edit: "Redigera",
|
|
4804
|
+
saveAndSend: "Spara och skicka",
|
|
4805
|
+
saveAndConfirm: "Spara och bekräfta",
|
|
4806
|
+
discardEdit: "Ignorera ändringar",
|
|
4807
|
+
fieldBody: "Meddelande",
|
|
4808
|
+
fieldStart: "Börjar",
|
|
4809
|
+
fieldEnd: "Slutar",
|
|
4810
|
+
addressesHint: "Separera adresser med kommatecken",
|
|
4811
|
+
timeZoneNote: "Tidszon: {{zone}}",
|
|
4812
|
+
errorRequired: "Fältet får inte vara tomt",
|
|
4813
|
+
errorNoRecipients: "Lägg till minst en mottagare",
|
|
4814
|
+
errorInvalidAddress: "Ange giltiga e-postadresser",
|
|
4815
|
+
errorInvalidDateTime: "Ange ett giltigt datum och en giltig tid",
|
|
4816
|
+
errorAmbiguousTime: "Den här tiden finns inte eller inträffar två gånger i {{zone}}. Välj en annan tid.",
|
|
4817
|
+
errorEndBeforeStart: "Slutet måste vara efter starten",
|
|
4818
|
+
editNoLongerApplies: "Dina ändringar gäller inte längre för den här åtgärden. Granska dem och försök igen.",
|
|
4819
|
+
editedLabel: "Redigerad",
|
|
4820
|
+
seeNewerVersion: "Se den nyare versionen"
|
|
4677
4821
|
},
|
|
4678
4822
|
no: {
|
|
4679
4823
|
searchingMail: "Søker i {{service}}",
|
|
@@ -4745,7 +4889,25 @@ const COPY = {
|
|
|
4745
4889
|
statusUnknown: "Ukjent resultat: sjekk før du prøver igjen",
|
|
4746
4890
|
statusNotFound: "Ikke tilgjengelig i denne samtalen",
|
|
4747
4891
|
toolUnavailable: "Verktøyet for denne handlingen er ikke tilgjengelig nå",
|
|
4748
|
-
decisionError: "Beslutningen din kunne ikke sendes. Prøv igjen."
|
|
4892
|
+
decisionError: "Beslutningen din kunne ikke sendes. Prøv igjen.",
|
|
4893
|
+
edit: "Rediger",
|
|
4894
|
+
saveAndSend: "Lagre og send",
|
|
4895
|
+
saveAndConfirm: "Lagre og bekreft",
|
|
4896
|
+
discardEdit: "Forkast endringer",
|
|
4897
|
+
fieldBody: "Melding",
|
|
4898
|
+
fieldStart: "Starter",
|
|
4899
|
+
fieldEnd: "Slutter",
|
|
4900
|
+
addressesHint: "Skill adresser med komma",
|
|
4901
|
+
timeZoneNote: "Tidssone: {{zone}}",
|
|
4902
|
+
errorRequired: "Feltet kan ikke være tomt",
|
|
4903
|
+
errorNoRecipients: "Legg til minst én mottaker",
|
|
4904
|
+
errorInvalidAddress: "Skriv inn gyldige e-postadresser",
|
|
4905
|
+
errorInvalidDateTime: "Skriv inn en gyldig dato og tid",
|
|
4906
|
+
errorAmbiguousTime: "Dette tidspunktet finnes ikke eller forekommer to ganger i {{zone}}. Velg et annet tidspunkt.",
|
|
4907
|
+
errorEndBeforeStart: "Slutten må være etter starten",
|
|
4908
|
+
editNoLongerApplies: "Endringene dine gjelder ikke lenger for denne handlingen. Gå gjennom dem og prøv igjen.",
|
|
4909
|
+
editedLabel: "Redigert",
|
|
4910
|
+
seeNewerVersion: "Se den nyere versjonen"
|
|
4749
4911
|
},
|
|
4750
4912
|
pt: {
|
|
4751
4913
|
searchingMail: "Pesquisando no {{service}}",
|
|
@@ -4817,7 +4979,25 @@ const COPY = {
|
|
|
4817
4979
|
statusUnknown: "Resultado desconhecido: verifique antes de tentar de novo",
|
|
4818
4980
|
statusNotFound: "Indisponível nesta conversa",
|
|
4819
4981
|
toolUnavailable: "A ferramenta desta ação não está disponível agora",
|
|
4820
|
-
decisionError: "Não foi possível enviar sua decisão. Tente novamente."
|
|
4982
|
+
decisionError: "Não foi possível enviar sua decisão. Tente novamente.",
|
|
4983
|
+
edit: "Editar",
|
|
4984
|
+
saveAndSend: "Salvar e enviar",
|
|
4985
|
+
saveAndConfirm: "Salvar e confirmar",
|
|
4986
|
+
discardEdit: "Descartar alterações",
|
|
4987
|
+
fieldBody: "Mensagem",
|
|
4988
|
+
fieldStart: "Início",
|
|
4989
|
+
fieldEnd: "Fim",
|
|
4990
|
+
addressesHint: "Separe os endereços com vírgulas",
|
|
4991
|
+
timeZoneNote: "Fuso horário: {{zone}}",
|
|
4992
|
+
errorRequired: "Este campo não pode ficar vazio",
|
|
4993
|
+
errorNoRecipients: "Adicione pelo menos um destinatário",
|
|
4994
|
+
errorInvalidAddress: "Informe endereços de e-mail válidos",
|
|
4995
|
+
errorInvalidDateTime: "Informe uma data e hora válidas",
|
|
4996
|
+
errorAmbiguousTime: "Este horário não existe ou se repete em {{zone}}. Escolha outro horário.",
|
|
4997
|
+
errorEndBeforeStart: "O fim deve ser posterior ao início",
|
|
4998
|
+
editNoLongerApplies: "Suas alterações não se aplicam mais a esta ação. Revise-as e tente novamente.",
|
|
4999
|
+
editedLabel: "Editada",
|
|
5000
|
+
seeNewerVersion: "Ver a versão mais recente"
|
|
4821
5001
|
}
|
|
4822
5002
|
};
|
|
4823
5003
|
function getPersonalConnectorCopy(locale) {
|
|
@@ -4830,6 +5010,325 @@ function fillCopy(template, values) {
|
|
|
4830
5010
|
return template.replace(/\{\{(\w+)\}\}/g, (match, key) => key in values ? String(values[key]) : match);
|
|
4831
5011
|
}
|
|
4832
5012
|
|
|
5013
|
+
//#endregion
|
|
5014
|
+
//#region src/components/internal/tool-confirmation-edit.ts
|
|
5015
|
+
const FIELD_KINDS = {
|
|
5016
|
+
to: "addresses",
|
|
5017
|
+
cc: "addresses",
|
|
5018
|
+
attendees: "addresses",
|
|
5019
|
+
subject: "text",
|
|
5020
|
+
title: "text",
|
|
5021
|
+
location: "text",
|
|
5022
|
+
body: "textarea",
|
|
5023
|
+
start: "datetime",
|
|
5024
|
+
end: "datetime"
|
|
5025
|
+
};
|
|
5026
|
+
/** Editable fields in the order the form shows them. */
|
|
5027
|
+
const FIELD_ORDER = [
|
|
5028
|
+
"to",
|
|
5029
|
+
"cc",
|
|
5030
|
+
"subject",
|
|
5031
|
+
"body",
|
|
5032
|
+
"title",
|
|
5033
|
+
"start",
|
|
5034
|
+
"end",
|
|
5035
|
+
"location",
|
|
5036
|
+
"attendees"
|
|
5037
|
+
];
|
|
5038
|
+
/** Fields of this action the card can show a control for. */
|
|
5039
|
+
function editableFields(pending) {
|
|
5040
|
+
const allowed = new Set(pending.editable ?? []);
|
|
5041
|
+
return FIELD_ORDER.filter((field) => allowed.has(field));
|
|
5042
|
+
}
|
|
5043
|
+
const OFFSET_SUFFIX = /(Z|[+-]\d{2}:?\d{2})$/i;
|
|
5044
|
+
function parseOffsetMinutes(value) {
|
|
5045
|
+
const match = OFFSET_SUFFIX.exec(value.trim());
|
|
5046
|
+
if (!match) return null;
|
|
5047
|
+
const text$2 = match[1].toUpperCase();
|
|
5048
|
+
if (text$2 === "Z") return 0;
|
|
5049
|
+
const sign = text$2[0] === "-" ? -1 : 1;
|
|
5050
|
+
const digits = text$2.slice(1).replace(":", "");
|
|
5051
|
+
return sign * (Number(digits.slice(0, 2)) * 60 + Number(digits.slice(2, 4)));
|
|
5052
|
+
}
|
|
5053
|
+
function formatOffset(minutes) {
|
|
5054
|
+
const sign = minutes < 0 ? "-" : "+";
|
|
5055
|
+
const abs = Math.abs(minutes);
|
|
5056
|
+
return `${sign}${String(Math.floor(abs / 60)).padStart(2, "0")}:${String(abs % 60).padStart(2, "0")}`;
|
|
5057
|
+
}
|
|
5058
|
+
function isValidZone(name) {
|
|
5059
|
+
try {
|
|
5060
|
+
new Intl.DateTimeFormat("en-US", { timeZone: name });
|
|
5061
|
+
return true;
|
|
5062
|
+
} catch {
|
|
5063
|
+
return false;
|
|
5064
|
+
}
|
|
5065
|
+
}
|
|
5066
|
+
/**
|
|
5067
|
+
* The zone of the action: its own `time_zone`, else the offset its dates were
|
|
5068
|
+
* prepared with, else UTC (how the server reads a date without offset).
|
|
5069
|
+
*/
|
|
5070
|
+
function actionZone(action) {
|
|
5071
|
+
const named = action.time_zone;
|
|
5072
|
+
if (typeof named === "string" && isValidZone(named)) return {
|
|
5073
|
+
kind: "iana",
|
|
5074
|
+
name: named
|
|
5075
|
+
};
|
|
5076
|
+
for (const field of ["start", "end"]) {
|
|
5077
|
+
const value = action[field];
|
|
5078
|
+
const minutes = typeof value === "string" ? parseOffsetMinutes(value) : null;
|
|
5079
|
+
if (minutes !== null) return {
|
|
5080
|
+
kind: "offset",
|
|
5081
|
+
minutes,
|
|
5082
|
+
label: `UTC${formatOffset(minutes)}`
|
|
5083
|
+
};
|
|
5084
|
+
}
|
|
5085
|
+
return {
|
|
5086
|
+
kind: "offset",
|
|
5087
|
+
minutes: 0,
|
|
5088
|
+
label: "UTC"
|
|
5089
|
+
};
|
|
5090
|
+
}
|
|
5091
|
+
function zoneLabel(zone) {
|
|
5092
|
+
return zone.kind === "iana" ? zone.name : zone.label;
|
|
5093
|
+
}
|
|
5094
|
+
const formatters = /* @__PURE__ */ new Map();
|
|
5095
|
+
/** Wall clock of an instant in `zone`, as if it were UTC (ms). */
|
|
5096
|
+
function wallClockMs(instant, name) {
|
|
5097
|
+
let formatter = formatters.get(name);
|
|
5098
|
+
if (!formatter) {
|
|
5099
|
+
formatter = new Intl.DateTimeFormat("en-US", {
|
|
5100
|
+
timeZone: name,
|
|
5101
|
+
hourCycle: "h23",
|
|
5102
|
+
year: "numeric",
|
|
5103
|
+
month: "2-digit",
|
|
5104
|
+
day: "2-digit",
|
|
5105
|
+
hour: "2-digit",
|
|
5106
|
+
minute: "2-digit",
|
|
5107
|
+
second: "2-digit"
|
|
5108
|
+
});
|
|
5109
|
+
formatters.set(name, formatter);
|
|
5110
|
+
}
|
|
5111
|
+
const parts = {};
|
|
5112
|
+
for (const part of formatter.formatToParts(new Date(instant))) if (part.type !== "literal") parts[part.type] = Number(part.value);
|
|
5113
|
+
return Date.UTC(parts.year, parts.month - 1, parts.day, parts.hour === 24 ? 0 : parts.hour, parts.minute, parts.second);
|
|
5114
|
+
}
|
|
5115
|
+
/** Offset of `name` at `instant`, in minutes east of UTC. */
|
|
5116
|
+
function offsetMinutesAt(instant, name) {
|
|
5117
|
+
return Math.round((wallClockMs(instant, name) - instant) / 6e4);
|
|
5118
|
+
}
|
|
5119
|
+
const LOCAL_INPUT = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})/;
|
|
5120
|
+
function pad(value) {
|
|
5121
|
+
return String(value).padStart(2, "0");
|
|
5122
|
+
}
|
|
5123
|
+
function toInputValue(wallMs) {
|
|
5124
|
+
const date = new Date(wallMs);
|
|
5125
|
+
return `${date.getUTCFullYear()}-${pad(date.getUTCMonth() + 1)}-${pad(date.getUTCDate())}T${pad(date.getUTCHours())}:${pad(date.getUTCMinutes())}`;
|
|
5126
|
+
}
|
|
5127
|
+
/** `YYYY-MM-DDTHH:mm` (a `datetime-local` value) of an ISO date, in `zone`. */
|
|
5128
|
+
function isoToLocalInput(iso, zone) {
|
|
5129
|
+
const text$2 = iso.trim();
|
|
5130
|
+
if (!OFFSET_SUFFIX.test(text$2)) {
|
|
5131
|
+
const naive = LOCAL_INPUT.exec(text$2);
|
|
5132
|
+
return naive ? `${naive[1]}-${naive[2]}-${naive[3]}T${naive[4]}:${naive[5]}` : null;
|
|
5133
|
+
}
|
|
5134
|
+
const instant = Date.parse(text$2);
|
|
5135
|
+
if (Number.isNaN(instant)) return null;
|
|
5136
|
+
return toInputValue(zone.kind === "iana" ? wallClockMs(instant, zone.name) : instant + zone.minutes * 6e4);
|
|
5137
|
+
}
|
|
5138
|
+
/**
|
|
5139
|
+
* ISO 8601 with the UTC offset `zone` has at that wall clock time. A time that
|
|
5140
|
+
* happens twice (clocks go back) or never (clocks go forward) has no single
|
|
5141
|
+
* valid offset: it is rejected so the user picks another one.
|
|
5142
|
+
*/
|
|
5143
|
+
function localInputToIso(local, zone) {
|
|
5144
|
+
const match = LOCAL_INPUT.exec(local.trim());
|
|
5145
|
+
if (!match) return { error: "invalid" };
|
|
5146
|
+
const [, year, month, day, hour, minute] = match;
|
|
5147
|
+
const wall = Date.UTC(Number(year), Number(month) - 1, Number(day), Number(hour), Number(minute));
|
|
5148
|
+
if (Number.isNaN(wall) || toInputValue(wall) !== local.trim().slice(0, 16)) return { error: "invalid" };
|
|
5149
|
+
const stamp = `${year}-${month}-${day}T${hour}:${minute}:00`;
|
|
5150
|
+
if (zone.kind === "offset") return { iso: `${stamp}${formatOffset(zone.minutes)}` };
|
|
5151
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
5152
|
+
for (const probe of [wall - 864e5, wall + 864e5]) {
|
|
5153
|
+
const offset$1 = offsetMinutesAt(probe, zone.name);
|
|
5154
|
+
if (wallClockMs(wall - offset$1 * 6e4, zone.name) === wall) candidates.add(offset$1);
|
|
5155
|
+
}
|
|
5156
|
+
if (candidates.size !== 1) return { error: "ambiguous" };
|
|
5157
|
+
const [offset] = candidates;
|
|
5158
|
+
return { iso: `${stamp}${formatOffset(offset)}` };
|
|
5159
|
+
}
|
|
5160
|
+
const EMAIL = /^[^@\s<>,;]+@[^@\s<>,;]+\.[^@\s<>,;]+$/;
|
|
5161
|
+
function asString(value) {
|
|
5162
|
+
return typeof value === "string" ? value : "";
|
|
5163
|
+
}
|
|
5164
|
+
/** What each field shows when the form opens: the prepared values. */
|
|
5165
|
+
function initialDraft(pending) {
|
|
5166
|
+
const action = pending.action;
|
|
5167
|
+
const zone = actionZone(action);
|
|
5168
|
+
const draft = {};
|
|
5169
|
+
for (const field of editableFields(pending)) {
|
|
5170
|
+
const value = action[field];
|
|
5171
|
+
switch (FIELD_KINDS[field]) {
|
|
5172
|
+
case "addresses":
|
|
5173
|
+
draft[field] = Array.isArray(value) ? value.filter((item) => typeof item === "string").join(", ") : "";
|
|
5174
|
+
break;
|
|
5175
|
+
case "datetime":
|
|
5176
|
+
draft[field] = typeof value === "string" ? isoToLocalInput(value, zone) ?? "" : "";
|
|
5177
|
+
break;
|
|
5178
|
+
default: draft[field] = asString(value);
|
|
5179
|
+
}
|
|
5180
|
+
}
|
|
5181
|
+
return draft;
|
|
5182
|
+
}
|
|
5183
|
+
function splitAddresses(text$2) {
|
|
5184
|
+
return text$2.split(/[,;\n]/).map((address) => address.trim()).filter(Boolean);
|
|
5185
|
+
}
|
|
5186
|
+
/**
|
|
5187
|
+
* The patch for `draft` against the prepared values, or the field errors that
|
|
5188
|
+
* stop it. Unchanged fields are left out so the server keeps their exact value.
|
|
5189
|
+
*/
|
|
5190
|
+
function buildPatch(pending, draft, initial = initialDraft(pending)) {
|
|
5191
|
+
const action = pending.action;
|
|
5192
|
+
const zone = actionZone(action);
|
|
5193
|
+
const zoneName = zoneLabel(zone);
|
|
5194
|
+
const patch = {};
|
|
5195
|
+
const errors = {};
|
|
5196
|
+
for (const field of editableFields(pending)) {
|
|
5197
|
+
const value = draft[field] ?? "";
|
|
5198
|
+
if (value === (initial[field] ?? "")) continue;
|
|
5199
|
+
switch (FIELD_KINDS[field]) {
|
|
5200
|
+
case "addresses": {
|
|
5201
|
+
const addresses = splitAddresses(value);
|
|
5202
|
+
if (addresses.some((address) => !EMAIL.test(address))) errors[field] = { key: "invalidAddress" };
|
|
5203
|
+
else if (field === "to" && addresses.length === 0) errors[field] = { key: "noRecipients" };
|
|
5204
|
+
else patch[field] = addresses;
|
|
5205
|
+
break;
|
|
5206
|
+
}
|
|
5207
|
+
case "datetime": {
|
|
5208
|
+
const converted = localInputToIso(value, zone);
|
|
5209
|
+
if (converted.error === "ambiguous") errors[field] = {
|
|
5210
|
+
key: "ambiguousTime",
|
|
5211
|
+
zone: zoneName
|
|
5212
|
+
};
|
|
5213
|
+
else if (converted.error) errors[field] = { key: "invalidDateTime" };
|
|
5214
|
+
else patch[field] = converted.iso;
|
|
5215
|
+
break;
|
|
5216
|
+
}
|
|
5217
|
+
case "text":
|
|
5218
|
+
if (value.trim() === "") if (field === "location") patch[field] = null;
|
|
5219
|
+
else errors[field] = { key: "required" };
|
|
5220
|
+
else patch[field] = value;
|
|
5221
|
+
break;
|
|
5222
|
+
default: patch[field] = value;
|
|
5223
|
+
}
|
|
5224
|
+
}
|
|
5225
|
+
const start = readInstant(patch.start, action.start);
|
|
5226
|
+
const end = readInstant(patch.end, action.end);
|
|
5227
|
+
if (!errors.end && !errors.start && (patch.start !== void 0 || patch.end !== void 0) && start !== null && end !== null && start >= end) errors.end = { key: "endBeforeStart" };
|
|
5228
|
+
return {
|
|
5229
|
+
patch,
|
|
5230
|
+
errors
|
|
5231
|
+
};
|
|
5232
|
+
}
|
|
5233
|
+
function readInstant(edited, original) {
|
|
5234
|
+
const value = typeof edited === "string" ? edited : original;
|
|
5235
|
+
if (typeof value !== "string") return null;
|
|
5236
|
+
const parsed = Date.parse(value);
|
|
5237
|
+
return Number.isNaN(parsed) ? null : parsed;
|
|
5238
|
+
}
|
|
5239
|
+
|
|
5240
|
+
//#endregion
|
|
5241
|
+
//#region src/components/tool-confirmation-edit-form.tsx
|
|
5242
|
+
const LABELS = {
|
|
5243
|
+
to: "to",
|
|
5244
|
+
cc: "cc",
|
|
5245
|
+
subject: "subject",
|
|
5246
|
+
body: "fieldBody",
|
|
5247
|
+
title: "title",
|
|
5248
|
+
start: "fieldStart",
|
|
5249
|
+
end: "fieldEnd",
|
|
5250
|
+
location: "location",
|
|
5251
|
+
attendees: "attendees"
|
|
5252
|
+
};
|
|
5253
|
+
const ERROR_COPY = {
|
|
5254
|
+
required: "errorRequired",
|
|
5255
|
+
noRecipients: "errorNoRecipients",
|
|
5256
|
+
invalidAddress: "errorInvalidAddress",
|
|
5257
|
+
invalidDateTime: "errorInvalidDateTime",
|
|
5258
|
+
ambiguousTime: "errorAmbiguousTime",
|
|
5259
|
+
endBeforeStart: "errorEndBeforeStart"
|
|
5260
|
+
};
|
|
5261
|
+
const INPUT_CLASS = "w-full rounded-md border border-border-strong bg-surface px-2 py-1.5 text-xs text-foreground disabled:opacity-50 aria-[invalid=true]:border-danger";
|
|
5262
|
+
/**
|
|
5263
|
+
* Inline form to change an action before confirming it. Only the fields the
|
|
5264
|
+
* server declared editable are shown. The draft lives in the parent, so it
|
|
5265
|
+
* survives validation errors and a busy thread.
|
|
5266
|
+
*/
|
|
5267
|
+
function ToolConfirmationEditForm({ pending, draft, onChange, errors, serverErrors, disabled, copy }) {
|
|
5268
|
+
const baseId = useId();
|
|
5269
|
+
const fields = editableFields(pending);
|
|
5270
|
+
const zone = zoneLabel(actionZone(pending.action));
|
|
5271
|
+
return /* @__PURE__ */ jsx("div", {
|
|
5272
|
+
className: "space-y-2 border-t border-border bg-surface px-3 py-3",
|
|
5273
|
+
"data-confirmation-edit": pending.action_id,
|
|
5274
|
+
children: fields.map((field) => {
|
|
5275
|
+
const kind = FIELD_KINDS[field];
|
|
5276
|
+
const id = `${baseId}-${field}`;
|
|
5277
|
+
const errorId = `${id}-error`;
|
|
5278
|
+
const clientError = errors[field];
|
|
5279
|
+
const message = clientError ? fillCopy(copy[ERROR_COPY[clientError.key]], { zone: clientError.zone ?? zone }) : serverErrors[field];
|
|
5280
|
+
const common = {
|
|
5281
|
+
id,
|
|
5282
|
+
name: field,
|
|
5283
|
+
value: draft[field] ?? "",
|
|
5284
|
+
disabled,
|
|
5285
|
+
"aria-invalid": message ? true : void 0,
|
|
5286
|
+
"aria-describedby": message ? errorId : void 0,
|
|
5287
|
+
className: INPUT_CLASS
|
|
5288
|
+
};
|
|
5289
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
5290
|
+
className: "space-y-1",
|
|
5291
|
+
children: [
|
|
5292
|
+
/* @__PURE__ */ jsx("label", {
|
|
5293
|
+
htmlFor: id,
|
|
5294
|
+
className: "block text-xs font-medium text-strong",
|
|
5295
|
+
children: copy[LABELS[field]]
|
|
5296
|
+
}),
|
|
5297
|
+
kind === "textarea" ? /* @__PURE__ */ jsx("textarea", {
|
|
5298
|
+
...common,
|
|
5299
|
+
rows: 5,
|
|
5300
|
+
onChange: (event) => onChange(field, event.target.value)
|
|
5301
|
+
}) : kind === "datetime" ? /* @__PURE__ */ jsx("input", {
|
|
5302
|
+
...common,
|
|
5303
|
+
type: "datetime-local",
|
|
5304
|
+
step: 60,
|
|
5305
|
+
onChange: (event) => onChange(field, event.target.value)
|
|
5306
|
+
}) : /* @__PURE__ */ jsx("input", {
|
|
5307
|
+
...common,
|
|
5308
|
+
type: "text",
|
|
5309
|
+
autoComplete: "off",
|
|
5310
|
+
onChange: (event) => onChange(field, event.target.value)
|
|
5311
|
+
}),
|
|
5312
|
+
kind === "addresses" ? /* @__PURE__ */ jsx("p", {
|
|
5313
|
+
className: "text-xs text-muted",
|
|
5314
|
+
children: copy.addressesHint
|
|
5315
|
+
}) : null,
|
|
5316
|
+
kind === "datetime" ? /* @__PURE__ */ jsx("p", {
|
|
5317
|
+
className: "text-xs text-muted",
|
|
5318
|
+
children: fillCopy(copy.timeZoneNote, { zone })
|
|
5319
|
+
}) : null,
|
|
5320
|
+
message ? /* @__PURE__ */ jsx("p", {
|
|
5321
|
+
id: errorId,
|
|
5322
|
+
role: "alert",
|
|
5323
|
+
className: joinClasses("text-xs text-danger-strong"),
|
|
5324
|
+
children: message
|
|
5325
|
+
}) : null
|
|
5326
|
+
]
|
|
5327
|
+
}, field);
|
|
5328
|
+
})
|
|
5329
|
+
});
|
|
5330
|
+
}
|
|
5331
|
+
|
|
4833
5332
|
//#endregion
|
|
4834
5333
|
//#region src/components/tool-confirmation-controls.tsx
|
|
4835
5334
|
const MINUTE = 6e4;
|
|
@@ -4900,15 +5399,36 @@ function expiryText(state, serverOffsetMs, now, copy) {
|
|
|
4900
5399
|
if (Number.isNaN(left) || left <= 0) return null;
|
|
4901
5400
|
return left < MINUTE ? copy.expiresSoon : fillCopy(copy.expiresIn, { minutes: Math.floor(left / MINUTE) });
|
|
4902
5401
|
}
|
|
5402
|
+
/** Label of the button that saves an edit and runs the action in one step. */
|
|
5403
|
+
function saveLabel(operation, copy) {
|
|
5404
|
+
return operation === "send" ? copy.saveAndSend : copy.saveAndConfirm;
|
|
5405
|
+
}
|
|
5406
|
+
/** Scrolls to the card of another version of the same action, if it is on screen. */
|
|
5407
|
+
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) {
|
|
5410
|
+
element.scrollIntoView?.({
|
|
5411
|
+
block: "center",
|
|
5412
|
+
behavior: "smooth"
|
|
5413
|
+
});
|
|
5414
|
+
return;
|
|
5415
|
+
}
|
|
5416
|
+
}
|
|
4903
5417
|
/**
|
|
4904
5418
|
* Footer of a held action. Without `toolConfirmation` it keeps the text hint
|
|
4905
|
-
* (reply "yes"); with it, buttons once the server state is known.
|
|
5419
|
+
* (reply "yes"); with it, buttons once the server state is known. When the
|
|
5420
|
+
* server lets the user edit the action, an inline form is offered and "Save
|
|
5421
|
+
* and send" confirms with the changes in a single step.
|
|
4906
5422
|
*/
|
|
4907
5423
|
function PendingConfirmationFooter({ pending, toolConfirmation, copy }) {
|
|
4908
5424
|
const state = useToolConfirmationState(pending, toolConfirmation);
|
|
4909
5425
|
const now = useNow(state?.status === "pending");
|
|
4910
5426
|
const [sending, setSending] = useState(null);
|
|
4911
5427
|
const [failed, setFailed] = useState(false);
|
|
5428
|
+
const [editing, setEditing] = useState(false);
|
|
5429
|
+
const [draft, setDraft] = useState({});
|
|
5430
|
+
const [fieldErrors, setFieldErrors] = useState({});
|
|
5431
|
+
const [serverErrors, setServerErrors] = useState({});
|
|
4912
5432
|
if (!toolConfirmation) return /* @__PURE__ */ jsx("p", {
|
|
4913
5433
|
className: "border-t border-border bg-warning-subtle/60 px-3 py-2 text-xs text-strong",
|
|
4914
5434
|
children: copy.confirmHint
|
|
@@ -4921,47 +5441,118 @@ function PendingConfirmationFooter({ pending, toolConfirmation, copy }) {
|
|
|
4921
5441
|
if (state.status !== "pending") {
|
|
4922
5442
|
const label = statusLabel(state.status, copy);
|
|
4923
5443
|
return label ? /* @__PURE__ */ jsxs("p", {
|
|
4924
|
-
className: "border-t border-divider bg-surface-muted px-3 py-2 text-xs text-strong",
|
|
5444
|
+
className: "flex flex-wrap items-center gap-2 border-t border-divider bg-surface-muted px-3 py-2 text-xs text-strong",
|
|
4925
5445
|
"aria-live": "polite",
|
|
4926
|
-
children: [
|
|
5446
|
+
children: [
|
|
5447
|
+
/* @__PURE__ */ jsxs("span", { children: [label, state.status === "failed" && state.error ? `: ${state.error}` : null] }),
|
|
5448
|
+
state.status === "superseded" && state.supersededBy ? /* @__PURE__ */ jsx("button", {
|
|
5449
|
+
type: "button",
|
|
5450
|
+
className: "underline underline-offset-2 hover:text-foreground",
|
|
5451
|
+
onClick: () => showAction(state.supersededBy),
|
|
5452
|
+
children: copy.seeNewerVersion
|
|
5453
|
+
}) : null,
|
|
5454
|
+
state.effectiveAction ? /* @__PURE__ */ jsx("span", {
|
|
5455
|
+
className: "rounded-full border border-border bg-surface px-2 py-0.5 text-muted",
|
|
5456
|
+
children: copy.editedLabel
|
|
5457
|
+
}) : null
|
|
5458
|
+
]
|
|
4927
5459
|
}) : null;
|
|
4928
5460
|
}
|
|
4929
|
-
const decide = async (
|
|
4930
|
-
setSending(decision);
|
|
5461
|
+
const decide = async (decisions) => {
|
|
4931
5462
|
setFailed(false);
|
|
4932
5463
|
try {
|
|
4933
|
-
await toolConfirmation.decide(
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
} catch {
|
|
4938
|
-
setFailed(true);
|
|
4939
|
-
} finally {
|
|
4940
|
-
setSending(null);
|
|
5464
|
+
await toolConfirmation.decide(decisions);
|
|
5465
|
+
} catch (error) {
|
|
5466
|
+
if (error instanceof ToolDecisionRejectedError && error.details.actionId === pending.action_id) setServerErrors(Object.fromEntries(error.details.errors.map(({ field, message }) => [field, message])));
|
|
5467
|
+
else setFailed(true);
|
|
4941
5468
|
}
|
|
4942
5469
|
};
|
|
5470
|
+
const send = async (decision) => {
|
|
5471
|
+
setSending(decision);
|
|
5472
|
+
await decide([{
|
|
5473
|
+
action_id: pending.action_id,
|
|
5474
|
+
decision
|
|
5475
|
+
}]);
|
|
5476
|
+
setSending(null);
|
|
5477
|
+
};
|
|
5478
|
+
const saveAndConfirm = async () => {
|
|
5479
|
+
const { patch, errors } = buildPatch(pending, draft);
|
|
5480
|
+
setFieldErrors(errors);
|
|
5481
|
+
setServerErrors({});
|
|
5482
|
+
if (Object.keys(errors).length > 0) return;
|
|
5483
|
+
setSending("confirm");
|
|
5484
|
+
await decide([{
|
|
5485
|
+
action_id: pending.action_id,
|
|
5486
|
+
decision: "confirm",
|
|
5487
|
+
...Object.keys(patch).length > 0 ? { arguments: patch } : {}
|
|
5488
|
+
}]);
|
|
5489
|
+
setSending(null);
|
|
5490
|
+
};
|
|
5491
|
+
const startEditing = () => {
|
|
5492
|
+
setDraft(initialDraft(pending));
|
|
5493
|
+
setFieldErrors({});
|
|
5494
|
+
setServerErrors({});
|
|
5495
|
+
setFailed(false);
|
|
5496
|
+
setEditing(true);
|
|
5497
|
+
};
|
|
5498
|
+
const stopEditing = () => {
|
|
5499
|
+
setEditing(false);
|
|
5500
|
+
setFieldErrors({});
|
|
5501
|
+
setServerErrors({});
|
|
5502
|
+
};
|
|
4943
5503
|
const disabled = Boolean(toolConfirmation.disabled) || sending !== null;
|
|
4944
5504
|
const destructive = pending.operation === "delete";
|
|
5505
|
+
const canEdit = state.canConfirm && editableFields(pending).length > 0;
|
|
4945
5506
|
const expiry = expiryText(state, toolConfirmation.states.serverOffsetMs, now, copy);
|
|
4946
5507
|
const unavailable = state.error === "tool_unavailable";
|
|
4947
|
-
|
|
5508
|
+
const editStale = state.error === "invalid_edit";
|
|
5509
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [editing && canEdit ? /* @__PURE__ */ jsx(ToolConfirmationEditForm, {
|
|
5510
|
+
pending,
|
|
5511
|
+
draft,
|
|
5512
|
+
onChange: (field, value) => {
|
|
5513
|
+
setDraft((current) => ({
|
|
5514
|
+
...current,
|
|
5515
|
+
[field]: value
|
|
5516
|
+
}));
|
|
5517
|
+
setFieldErrors(({ [field]: _removed,...rest }) => rest);
|
|
5518
|
+
setServerErrors(({ [field]: _removed,...rest }) => rest);
|
|
5519
|
+
},
|
|
5520
|
+
errors: fieldErrors,
|
|
5521
|
+
serverErrors,
|
|
5522
|
+
disabled,
|
|
5523
|
+
copy
|
|
5524
|
+
}) : null, /* @__PURE__ */ jsxs("div", {
|
|
4948
5525
|
className: "flex flex-wrap items-center gap-2 border-t border-border bg-warning-subtle/60 px-3 py-2",
|
|
4949
5526
|
"data-confirmation-actions": pending.action_id,
|
|
4950
5527
|
children: [
|
|
4951
5528
|
state.canConfirm ? /* @__PURE__ */ jsxs("button", {
|
|
4952
5529
|
type: "button",
|
|
4953
5530
|
disabled,
|
|
4954
|
-
onClick: () => void
|
|
5531
|
+
onClick: () => void (editing && canEdit ? saveAndConfirm() : send("confirm")),
|
|
4955
5532
|
className: joinClasses("inline-flex items-center rounded-md px-3 py-1.5 text-xs font-medium text-inverse-foreground disabled:opacity-50", destructive ? "bg-danger hover:bg-danger-strong" : "bg-inverse hover:bg-inverse-hover"),
|
|
4956
5533
|
children: [sending === "confirm" ? /* @__PURE__ */ jsx(LoaderCircle, {
|
|
4957
5534
|
className: "mr-2 size-3 animate-spin",
|
|
4958
5535
|
"aria-hidden": "true"
|
|
4959
|
-
}) : null, sending === "confirm" ? copy.confirming : verbFor(pending.operation, copy)]
|
|
5536
|
+
}) : null, sending === "confirm" ? copy.confirming : editing && canEdit ? saveLabel(pending.operation, copy) : verbFor(pending.operation, copy)]
|
|
5537
|
+
}) : null,
|
|
5538
|
+
canEdit && !editing ? /* @__PURE__ */ jsx("button", {
|
|
5539
|
+
type: "button",
|
|
5540
|
+
disabled,
|
|
5541
|
+
onClick: startEditing,
|
|
5542
|
+
className: "inline-flex items-center rounded-md border border-border-strong bg-surface px-3 py-1.5 text-xs font-medium text-strong hover:bg-surface-muted disabled:opacity-50",
|
|
5543
|
+
children: copy.edit
|
|
5544
|
+
}) : null,
|
|
5545
|
+
editing && canEdit ? /* @__PURE__ */ jsx("button", {
|
|
5546
|
+
type: "button",
|
|
5547
|
+
disabled,
|
|
5548
|
+
onClick: stopEditing,
|
|
5549
|
+
className: "inline-flex items-center rounded-md border border-border-strong bg-surface px-3 py-1.5 text-xs font-medium text-strong hover:bg-surface-muted disabled:opacity-50",
|
|
5550
|
+
children: copy.discardEdit
|
|
4960
5551
|
}) : null,
|
|
4961
5552
|
state.canReject ? /* @__PURE__ */ jsxs("button", {
|
|
4962
5553
|
type: "button",
|
|
4963
5554
|
disabled,
|
|
4964
|
-
onClick: () => void
|
|
5555
|
+
onClick: () => void send("reject"),
|
|
4965
5556
|
className: "inline-flex items-center rounded-md border border-border-strong bg-surface px-3 py-1.5 text-xs font-medium text-strong hover:bg-surface-muted disabled:opacity-50",
|
|
4966
5557
|
children: [sending === "reject" ? /* @__PURE__ */ jsx(LoaderCircle, {
|
|
4967
5558
|
className: "mr-2 size-3 animate-spin",
|
|
@@ -4971,10 +5562,10 @@ function PendingConfirmationFooter({ pending, toolConfirmation, copy }) {
|
|
|
4971
5562
|
/* @__PURE__ */ jsx("span", {
|
|
4972
5563
|
className: "ml-auto text-xs text-secondary",
|
|
4973
5564
|
"aria-live": "polite",
|
|
4974
|
-
children: failed ? copy.decisionError : unavailable ? copy.toolUnavailable : expiry
|
|
5565
|
+
children: failed ? copy.decisionError : unavailable ? copy.toolUnavailable : editStale ? copy.editNoLongerApplies : expiry
|
|
4975
5566
|
})
|
|
4976
5567
|
]
|
|
4977
|
-
});
|
|
5568
|
+
})] });
|
|
4978
5569
|
}
|
|
4979
5570
|
|
|
4980
5571
|
//#endregion
|
|
@@ -5581,20 +6172,28 @@ function headerCount(view, copy) {
|
|
|
5581
6172
|
return null;
|
|
5582
6173
|
}
|
|
5583
6174
|
function ToolResultPersonalConnectorCard({ part, locale, className, toolConfirmation }) {
|
|
5584
|
-
const
|
|
5585
|
-
const pending =
|
|
6175
|
+
const prepared = getView(part);
|
|
6176
|
+
const pending = prepared?.kind === "pending-mail" || prepared?.kind === "pending-event" ? prepared.pending : null;
|
|
5586
6177
|
const confirmationState = useToolConfirmationState(pending, toolConfirmation);
|
|
5587
|
-
if (!
|
|
6178
|
+
if (!prepared) return null;
|
|
6179
|
+
const view = (prepared.kind === "pending-mail" || prepared.kind === "pending-event") && confirmationState?.effectiveAction ? {
|
|
6180
|
+
...prepared,
|
|
6181
|
+
pending: {
|
|
6182
|
+
...prepared.pending,
|
|
6183
|
+
action: confirmationState.effectiveAction
|
|
6184
|
+
}
|
|
6185
|
+
} : prepared;
|
|
5588
6186
|
const copy = getPersonalConnectorCopy(locale);
|
|
5589
6187
|
const connector = getConnector(part);
|
|
5590
6188
|
const Icon = isCalendar(connector) ? CalendarDays : Mail;
|
|
5591
6189
|
const total = headerCount(view, copy);
|
|
5592
6190
|
const isPending = view.kind === "pending-mail" || view.kind === "pending-event";
|
|
5593
6191
|
return /* @__PURE__ */ jsxs("section", {
|
|
5594
|
-
className: joinClasses("plai-tool-result-personal-connector-card overflow-hidden rounded-lg border border-border bg-surface text-foreground", className),
|
|
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),
|
|
5595
6193
|
"data-tool-call-id": part.id,
|
|
5596
6194
|
"data-tool-call-state": part.state,
|
|
5597
6195
|
"data-connector-action": view.kind,
|
|
6196
|
+
"data-confirmation-action": pending?.action_id,
|
|
5598
6197
|
children: [
|
|
5599
6198
|
/* @__PURE__ */ jsxs("header", {
|
|
5600
6199
|
className: "flex items-center gap-2 border-b border-border px-3 py-2 text-xs text-secondary",
|