@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.cjs CHANGED
@@ -1211,6 +1211,23 @@ var GENERATED_RESPONSE_STATUSES = [
1211
1211
  function isGeneratedResponseStatus(value) {
1212
1212
  return typeof value === "string" && GENERATED_RESPONSE_STATUSES.includes(value);
1213
1213
  }
1214
+ var ALLOWED_TRANSITIONS = {
1215
+ pending: ["ready", "failed", "no_reply_needed", "sending", "invalidated"],
1216
+ ready: ["sending", "invalidated", "expired"],
1217
+ sending: ["sent", "ready"],
1218
+ sent: [],
1219
+ failed: [],
1220
+ no_reply_needed: [],
1221
+ invalidated: [],
1222
+ expired: []
1223
+ };
1224
+ function canTransition(from, to) {
1225
+ if (!isGeneratedResponseStatus(from) || !isGeneratedResponseStatus(to)) return false;
1226
+ return ALLOWED_TRANSITIONS[from].includes(to);
1227
+ }
1228
+ function isInvalidatableStatus(status) {
1229
+ return canTransition(status, "invalidated");
1230
+ }
1214
1231
 
1215
1232
  // src/ui/tickets/ticket-outcome.ts
1216
1233
  var NO_JOB = { label: "Aucune r\xE9ponse g\xE9n\xE9r\xE9e", variant: "neutral" };
@@ -1411,10 +1428,14 @@ function noResponseCause(decision) {
1411
1428
  return "La cat\xE9gorie n'a pas la r\xE9ponse rapide activ\xE9e, ou n'a pas d'agent r\xE9dacteur.";
1412
1429
  }
1413
1430
  function TimelinePanel(props) {
1414
- const { decision, job, comparisons, conversation, conversationLoading, categoryName, onClose } = props;
1431
+ const { decision, job, comparisons, conversation, conversationLoading, categoryName, onClose, onInvalidate, isInvalidating } = props;
1415
1432
  const steps = buildTimeline({ decision, job, comparisons, conversation, conversationLoading });
1416
- return /* @__PURE__ */ jsxRuntime.jsx(uiSdk.SidePanel, { open: true, onClose, title: `Ticket ${decision.ticketId}`, description: categoryName, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1 text-sm", children: [
1417
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pb-3", children: /* @__PURE__ */ jsxRuntime.jsx(TicketLink, { ticketId: decision.ticketId, url: decision.ticketUrl, label: "Ouvrir le ticket dans Gorgias" }) }),
1433
+ const canInvalidate = job !== void 0 && isGeneratedResponseStatus(job.status) && isInvalidatableStatus(job.status);
1434
+ return /* @__PURE__ */ jsxRuntime.jsx(uiSdk.SidePanel, { open: true, onClose, title: `Ticket ${decision.ticketId}`, description: categoryName, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-h-0 flex-1 space-y-1 overflow-y-auto text-sm", children: [
1435
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-3 pb-3", children: [
1436
+ /* @__PURE__ */ jsxRuntime.jsx(TicketLink, { ticketId: decision.ticketId, url: decision.ticketUrl, label: "Ouvrir le ticket dans Gorgias" }),
1437
+ onInvalidate && canInvalidate && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", size: "sm", onClick: onInvalidate, disabled: isInvalidating, children: isInvalidating ? "Invalidation\u2026" : "Invalider la r\xE9ponse" })
1438
+ ] }),
1418
1439
  steps.map((step2, index) => /* @__PURE__ */ jsxRuntime.jsx(StepBlock, { step: step2, index, last: index === steps.length - 1, children: step2.reached ? renderStep(step2.key, props) : null }, step2.key))
1419
1440
  ] }) });
1420
1441
  }
@@ -1662,6 +1683,7 @@ function TicketsPage() {
1662
1683
  const [correctedFilter, setCorrectedFilter] = react.useState("");
1663
1684
  const [detailDecision, setDetailDecision] = react.useState(null);
1664
1685
  const [isTriaging, setIsTriaging] = react.useState(false);
1686
+ const [isInvalidating, setIsInvalidating] = react.useState(false);
1665
1687
  const [triageInFlight] = react.useState(() => ({ current: false }));
1666
1688
  const periodKey = JSON.stringify(period);
1667
1689
  const bounds = react.useMemo(() => periodBoundsOf(JSON.parse(periodKey)).current, [periodKey]);
@@ -1799,6 +1821,18 @@ function TicketsPage() {
1799
1821
  setIsTriaging(false);
1800
1822
  }
1801
1823
  }
1824
+ async function invalidateResponse(generatedResponseId) {
1825
+ setIsInvalidating(true);
1826
+ try {
1827
+ await api.invoke("invalidate-response", { generatedResponseId });
1828
+ toast({ title: "R\xE9ponse invalid\xE9e \u2014 le ticket pourra \xEAtre retrait\xE9 de z\xE9ro.", variant: "success" });
1829
+ await refreshAll();
1830
+ } catch (err) {
1831
+ toast({ title: "\xC9chec de l'invalidation", description: describeInvokeError(err), variant: "error" });
1832
+ } finally {
1833
+ setIsInvalidating(false);
1834
+ }
1835
+ }
1802
1836
  const columns = [
1803
1837
  { key: "ticketId", header: "Ticket", cell: ({ decision }) => /* @__PURE__ */ jsxRuntime.jsx(TicketLink, { ticketId: decision.ticketId, url: decision.ticketUrl }) },
1804
1838
  { key: "category", header: "Cat\xE9gorie", cell: ({ decision }) => decision.categoryId && categoryNames.get(decision.categoryId) || "\u2014" },
@@ -1935,7 +1969,9 @@ function TicketsPage() {
1935
1969
  categoryName: detailDecision.categoryId && categoryNames.get(detailDecision.categoryId) || "\u2014",
1936
1970
  agentName: detailRow?.job?.agentId && agentNames.get(detailRow.job.agentId) || "\u2014",
1937
1971
  langfuseConfig,
1938
- onClose: () => setDetailDecision(null)
1972
+ onClose: () => setDetailDecision(null),
1973
+ onInvalidate: canWrite && detailRow?.job ? () => void invalidateResponse(detailRow.job.id) : void 0,
1974
+ isInvalidating
1939
1975
  }
1940
1976
  )
1941
1977
  ] });