@apotech-os/support-kit 5.0.0 → 6.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/dist/ui/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { EVALUATION_VERDICTS, WHATSAPP_MODES, validateSettings, AGENT_GUARDRAILS, toCategory, toAgent, toGeneratedResponse, toResponseComparison, toTriageDecision, isGeneratedResponseStatus, toCategoryGroup, NODE_NAMES, settingsToProfile, hasNoDraftNode, DEFAULT_LLM_PROVIDER, computeWordDiff, isSendableVerdict, DEFAULT_MAX_TOOL_CALLS, DEFAULT_MIN_CONFIDENCE, DEFAULT_ESCALATION_ENABLED } from '../chunk-D5N3UEOG.js';
1
+ import { EVALUATION_VERDICTS, WHATSAPP_MODES, validateSettings, AGENT_GUARDRAILS, toCategory, toAgent, toGeneratedResponse, toResponseComparison, toTriageDecision, isGeneratedResponseStatus, isInvalidatableStatus, toCategoryGroup, NODE_NAMES, settingsToProfile, hasNoDraftNode, DEFAULT_LLM_PROVIDER, computeWordDiff, isSendableVerdict, DEFAULT_MAX_TOOL_CALLS, DEFAULT_MIN_CONFIDENCE, DEFAULT_ESCALATION_ENABLED } from '../chunk-CRFNVCS7.js';
2
2
  import { useState, useMemo, useEffect, useRef, useCallback, useId } from 'react';
3
3
  import { useAppContext, useAppSettings, DateRangeCompare, Link, Card, CardHeader, CardTitle, CardContent, AreaChart, StackedBarChart, Badge, useAppApi, useToast, Button, Select, DataTable, Spinner, Switch, Input, Checkbox, Textarea, comparisonRange, cn, SidePanel, Modal, Tooltip, buttonVariants, AppInvokeError, CopyButton, relativeDelta, Table, TableHeader, TableRow, TableHead, TableBody, TableCell, downloadBlob } from '@apotech-os/ui-sdk';
4
4
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
@@ -1231,10 +1231,14 @@ function noResponseCause(decision) {
1231
1231
  return "La cat\xE9gorie n'a pas la r\xE9ponse rapide activ\xE9e, ou n'a pas d'agent r\xE9dacteur.";
1232
1232
  }
1233
1233
  function TimelinePanel(props) {
1234
- const { decision, job, comparisons, conversation, conversationLoading, categoryName, onClose } = props;
1234
+ const { decision, job, comparisons, conversation, conversationLoading, categoryName, onClose, onInvalidate, isInvalidating } = props;
1235
1235
  const steps = buildTimeline({ decision, job, comparisons, conversation, conversationLoading });
1236
- return /* @__PURE__ */ jsx(SidePanel, { open: true, onClose, title: `Ticket ${decision.ticketId}`, description: categoryName, children: /* @__PURE__ */ jsxs("div", { className: "space-y-1 text-sm", children: [
1237
- /* @__PURE__ */ jsx("p", { className: "pb-3", children: /* @__PURE__ */ jsx(TicketLink, { ticketId: decision.ticketId, url: decision.ticketUrl, label: "Ouvrir le ticket dans Gorgias" }) }),
1236
+ const canInvalidate = job !== void 0 && isGeneratedResponseStatus(job.status) && isInvalidatableStatus(job.status);
1237
+ return /* @__PURE__ */ jsx(SidePanel, { open: true, onClose, title: `Ticket ${decision.ticketId}`, description: categoryName, children: /* @__PURE__ */ jsxs("div", { className: "min-h-0 flex-1 space-y-1 overflow-y-auto text-sm", children: [
1238
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3 pb-3", children: [
1239
+ /* @__PURE__ */ jsx(TicketLink, { ticketId: decision.ticketId, url: decision.ticketUrl, label: "Ouvrir le ticket dans Gorgias" }),
1240
+ onInvalidate && canInvalidate && /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: onInvalidate, disabled: isInvalidating, children: isInvalidating ? "Invalidation\u2026" : "Invalider la r\xE9ponse" })
1241
+ ] }),
1238
1242
  steps.map((step2, index) => /* @__PURE__ */ jsx(StepBlock, { step: step2, index, last: index === steps.length - 1, children: step2.reached ? renderStep(step2.key, props) : null }, step2.key))
1239
1243
  ] }) });
1240
1244
  }
@@ -1482,6 +1486,7 @@ function TicketsPage() {
1482
1486
  const [correctedFilter, setCorrectedFilter] = useState("");
1483
1487
  const [detailDecision, setDetailDecision] = useState(null);
1484
1488
  const [isTriaging, setIsTriaging] = useState(false);
1489
+ const [isInvalidating, setIsInvalidating] = useState(false);
1485
1490
  const [triageInFlight] = useState(() => ({ current: false }));
1486
1491
  const periodKey = JSON.stringify(period);
1487
1492
  const bounds = useMemo(() => periodBoundsOf(JSON.parse(periodKey)).current, [periodKey]);
@@ -1619,6 +1624,18 @@ function TicketsPage() {
1619
1624
  setIsTriaging(false);
1620
1625
  }
1621
1626
  }
1627
+ async function invalidateResponse(generatedResponseId) {
1628
+ setIsInvalidating(true);
1629
+ try {
1630
+ await api.invoke("invalidate-response", { generatedResponseId });
1631
+ toast({ title: "R\xE9ponse invalid\xE9e \u2014 le ticket pourra \xEAtre retrait\xE9 de z\xE9ro.", variant: "success" });
1632
+ await refreshAll();
1633
+ } catch (err) {
1634
+ toast({ title: "\xC9chec de l'invalidation", description: describeInvokeError(err), variant: "error" });
1635
+ } finally {
1636
+ setIsInvalidating(false);
1637
+ }
1638
+ }
1622
1639
  const columns = [
1623
1640
  { key: "ticketId", header: "Ticket", cell: ({ decision }) => /* @__PURE__ */ jsx(TicketLink, { ticketId: decision.ticketId, url: decision.ticketUrl }) },
1624
1641
  { key: "category", header: "Cat\xE9gorie", cell: ({ decision }) => decision.categoryId && categoryNames.get(decision.categoryId) || "\u2014" },
@@ -1755,7 +1772,9 @@ function TicketsPage() {
1755
1772
  categoryName: detailDecision.categoryId && categoryNames.get(detailDecision.categoryId) || "\u2014",
1756
1773
  agentName: detailRow?.job?.agentId && agentNames.get(detailRow.job.agentId) || "\u2014",
1757
1774
  langfuseConfig,
1758
- onClose: () => setDetailDecision(null)
1775
+ onClose: () => setDetailDecision(null),
1776
+ onInvalidate: canWrite && detailRow?.job ? () => void invalidateResponse(detailRow.job.id) : void 0,
1777
+ isInvalidating
1759
1778
  }
1760
1779
  )
1761
1780
  ] });