@apotech-os/support-kit 8.2.0 → 8.3.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
@@ -1525,7 +1525,8 @@ function toAuditTags(settings) {
1525
1525
  escalationTag: settings.escalationTag,
1526
1526
  sentTag: settings.autoRepliedTag,
1527
1527
  needsHumanTag: settings.needsReviewTag,
1528
- followupTag: settings.followupTag
1528
+ followupTag: settings.followupTag,
1529
+ appScopeTag: settings.appScopeTag
1529
1530
  };
1530
1531
  }
1531
1532
  var DEFAULT_MIN_CONFIDENCE = 0.8;
@@ -1938,16 +1939,16 @@ function dedupe(names) {
1938
1939
  const seen = /* @__PURE__ */ new Set();
1939
1940
  const out = [];
1940
1941
  for (const name of names) {
1941
- const trimmed = (name ?? "").trim();
1942
- if (!trimmed || seen.has(trimmed)) continue;
1943
- seen.add(trimmed);
1944
- out.push(trimmed);
1942
+ const trimmed2 = (name ?? "").trim();
1943
+ if (!trimmed2 || seen.has(trimmed2)) continue;
1944
+ seen.add(trimmed2);
1945
+ out.push(trimmed2);
1945
1946
  }
1946
1947
  return out;
1947
1948
  }
1948
1949
  function triageTagNames(input) {
1949
1950
  const { decision, category, policy } = input;
1950
- return [decision.tag, ...category?.extraTags ?? [], policy?.audit.handledTag];
1951
+ return [decision.tag, ...category?.extraTags ?? [], policy?.audit.handledTag, policy?.audit.appScopeTag];
1951
1952
  }
1952
1953
  function wasSimulated(job, policy) {
1953
1954
  if (!job) return false;
@@ -2263,6 +2264,10 @@ var ORIGIN_FILTER_OPTIONS = [
2263
2264
  { value: "followup", label: "Messages suivants" },
2264
2265
  { value: "test", label: "Brouillons d'essai" }
2265
2266
  ];
2267
+ var VIEW_MODE_OPTIONS = [
2268
+ { value: "byTicket", label: "Une ligne par ticket" },
2269
+ { value: "all", label: "Toutes les g\xE9n\xE9rations" }
2270
+ ];
2266
2271
  function OutcomeBadge({ outcome }) {
2267
2272
  return /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: OUTCOME_BADGE_VARIANT[outcome.variant], children: outcome.label });
2268
2273
  }
@@ -2282,6 +2287,7 @@ function TicketsPage() {
2282
2287
  const [promptVersionFilter, setPromptVersionFilter] = react.useState("");
2283
2288
  const [correctedFilter, setCorrectedFilter] = react.useState("");
2284
2289
  const [originFilter, setOriginFilter] = react.useState("");
2290
+ const [viewMode, setViewMode] = react.useState("byTicket");
2285
2291
  const [detailDecision, setDetailDecision] = react.useState(null);
2286
2292
  const [isTriaging, setIsTriaging] = react.useState(false);
2287
2293
  const [isInvalidating, setIsInvalidating] = react.useState(false);
@@ -2413,6 +2419,16 @@ function TicketsPage() {
2413
2419
  return true;
2414
2420
  });
2415
2421
  }, [decisions, jobByDecisionId, comparisonsByTicketId, outcomeFilter, verdictFilter, promptVersionFilter, correctedFilter, originFilter]);
2422
+ const listRows = react.useMemo(() => {
2423
+ if (viewMode === "all") return rows.map((row) => ({ ...row, turnCount: 1 }));
2424
+ const byTicket = /* @__PURE__ */ new Map();
2425
+ for (const row of rows) {
2426
+ const seen = byTicket.get(row.decision.ticketId);
2427
+ if (seen) seen.turnCount += 1;
2428
+ else byTicket.set(row.decision.ticketId, { ...row, turnCount: 1 });
2429
+ }
2430
+ return [...byTicket.values()];
2431
+ }, [rows, viewMode]);
2416
2432
  const deepLinkConsumed = react.useRef(false);
2417
2433
  react.useEffect(() => {
2418
2434
  if (deepLinkConsumed.current || !requestedTicket) return;
@@ -2460,6 +2476,16 @@ function TicketsPage() {
2460
2476
  }
2461
2477
  const columns = [
2462
2478
  { key: "ticketId", header: "Ticket", cell: ({ decision }) => /* @__PURE__ */ jsxRuntime.jsx(TicketLink, { ticketId: decision.ticketId, url: decision.ticketUrl }) },
2479
+ {
2480
+ key: "turns",
2481
+ header: "Tours",
2482
+ // Only a multi-turn ticket is worth marking: badging every row would
2483
+ // make the multi-turn ones invisible by saturation.
2484
+ cell: ({ turnCount }) => turnCount > 1 ? /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Badge, { variant: "neutral", children: [
2485
+ turnCount,
2486
+ " tours"
2487
+ ] }) : null
2488
+ },
2463
2489
  {
2464
2490
  key: "origin",
2465
2491
  header: "Origine",
@@ -2565,10 +2591,20 @@ function TicketsPage() {
2565
2591
  /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Select, { items: promptVersionOptions, value: promptVersionFilter, onValueChange: setPromptVersionFilter, placeholder: "Toutes versions de prompt", "aria-label": "Filtrer par version de prompt" }),
2566
2592
  /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Select, { items: CORRECTED_OPTIONS, value: correctedFilter, onValueChange: setCorrectedFilter, placeholder: "Corrig\xE9s ou non", "aria-label": "Filtrer par correction humaine" }),
2567
2593
  /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Select, { items: ORIGIN_FILTER_OPTIONS, value: originFilter, onValueChange: setOriginFilter, placeholder: "Toutes origines", "aria-label": "Filtrer par origine" }),
2568
- rows.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ml-auto text-sm text-muted-foreground", children: [
2569
- rows.length,
2594
+ /* @__PURE__ */ jsxRuntime.jsx(
2595
+ uiSdk.Select,
2596
+ {
2597
+ items: VIEW_MODE_OPTIONS,
2598
+ value: viewMode,
2599
+ onValueChange: (value) => setViewMode(value === "all" ? "all" : "byTicket"),
2600
+ placeholder: "Une ligne par ticket",
2601
+ "aria-label": "Filtrer par mode d'affichage"
2602
+ }
2603
+ ),
2604
+ listRows.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ml-auto text-sm text-muted-foreground", children: [
2605
+ listRows.length,
2570
2606
  " ticket",
2571
- rows.length > 1 ? "s" : "",
2607
+ listRows.length > 1 ? "s" : "",
2572
2608
  " sur cette page"
2573
2609
  ] })
2574
2610
  ] }),
@@ -2576,7 +2612,7 @@ function TicketsPage() {
2576
2612
  uiSdk.DataTable,
2577
2613
  {
2578
2614
  columns,
2579
- rows,
2615
+ rows: listRows,
2580
2616
  rowId: (row) => row.decision.id,
2581
2617
  manual: true,
2582
2618
  defaultState: { search: requestedTicket?.trim() ?? "" },
@@ -4296,6 +4332,37 @@ function isConfiguredNode(nodes) {
4296
4332
  const triage = nodes.triage;
4297
4333
  return typeof triage === "object" && triage !== null;
4298
4334
  }
4335
+
4336
+ // src/settings/warnings.ts
4337
+ var HUMAN_TAKEOVER_KEYS = ["escalationTag", "needsReviewTag", "followupTag"];
4338
+ var AUDIT_TAG_KEYS = ["unknownTag", "handledTag", "escalationTag", "autoRepliedTag", "needsReviewTag", "followupTag"];
4339
+ function settingsWarnings(settings) {
4340
+ const warnings = [];
4341
+ const appScopeTag = trimmed(settings.appScopeTag);
4342
+ const webhookScopeTag = trimmed(settings.webhookScopeTag);
4343
+ const collidesWith = (keys) => appScopeTag ? keys.filter((key) => trimmed(settings[key]) === appScopeTag) : [];
4344
+ if (collidesWith(HUMAN_TAKEOVER_KEYS).length > 0) {
4345
+ warnings.push({
4346
+ key: "appScopeTagVetoesFollowups",
4347
+ message: "Le tag d\u2019appartenance est l\u2019un des tags de reprise humaine (escalade, relecture, suivi) : le webhook de suivi consid\xE9rera que chaque ticket tri\xE9 a \xE9t\xE9 repris par un humain et ne r\xE9pondra plus \xE0 aucun message suivant."
4348
+ });
4349
+ } else if (collidesWith(AUDIT_TAG_KEYS).length > 0) {
4350
+ warnings.push({
4351
+ key: "appScopeTagCollision",
4352
+ message: "Le tag d\u2019appartenance est l\u2019un des autres tags d\u2019audit, que toutes les apps posent avec la m\xEAme valeur par d\xE9faut : il ne distingue donc pas cette app d\u2019une autre install\xE9e sur le m\xEAme compte Gorgias."
4353
+ });
4354
+ }
4355
+ if (appScopeTag && webhookScopeTag && appScopeTag !== webhookScopeTag) {
4356
+ warnings.push({
4357
+ key: "scopeTagMismatch",
4358
+ message: "Le tag de p\xE9rim\xE8tre du webhook de suivi n\u2019est pas celui que cette app pose sur ses tickets : le webhook ne r\xE9pondra sur aucun ticket tri\xE9 ici."
4359
+ });
4360
+ }
4361
+ return warnings;
4362
+ }
4363
+ function trimmed(value) {
4364
+ return typeof value === "string" ? value.trim() : "";
4365
+ }
4299
4366
  function NumberField({ id, label, value, onChange, disabled, min, max, integer, hint }) {
4300
4367
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4301
4368
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: id, className: "mb-1 block text-sm font-medium", children: label }),
@@ -4959,6 +5026,7 @@ function SettingsPage() {
4959
5026
  const claimedView = views.find((v) => v.id === sourceViewId);
4960
5027
  const claimUnverifiable = installedAppsUnavailable || uncheckedAppSlugs.length > 0;
4961
5028
  const issues = validateSettings(form);
5029
+ const warnings = settingsWarnings(form);
4962
5030
  const nodesIssue = issues.find((issue) => issue.key === "nodes");
4963
5031
  const summaryIssues = issues.filter((issue) => issue !== nodesIssue);
4964
5032
  const guardrailsActive = Array.isArray(form.guardrailsActive) ? form.guardrailsActive : [];
@@ -5133,11 +5201,14 @@ function SettingsPage() {
5133
5201
  ["escalationTag", "Tag d'escalade"],
5134
5202
  ["autoRepliedTag", "Tag r\xE9pondu automatiquement"],
5135
5203
  ["needsReviewTag", "Tag \xE0 revoir avant envoi"],
5136
- ["followupTag", "Tag suivi requis"]
5204
+ ["followupTag", "Tag suivi requis"],
5205
+ ["appScopeTag", "Tag d'appartenance"]
5137
5206
  ].map(([key, label]) => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
5138
5207
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: key, className: "mb-1 block text-sm font-medium", children: label }),
5139
5208
  /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Input, { id: key, value: field(form[key]), onChange: (e) => set(key, e.target.value), disabled: !canWrite })
5140
- ] }, key))
5209
+ ] }, key)),
5210
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: "Le tag d\u2019appartenance est pos\xE9 sur chaque ticket que le triage examine, dans le m\xEAme appel que les tags ci-dessus. Il doit \xEAtre propre \xE0 cette app : c\u2019est lui qui distingue ses tickets de ceux d\u2019une autre app install\xE9e sur le m\xEAme compte Gorgias." }),
5211
+ warnings.map((warning) => /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-status-pending", children: warning.message }, warning.key))
5141
5212
  ] }) }),
5142
5213
  /* @__PURE__ */ jsxRuntime.jsx(
5143
5214
  FollowupWebhookCard,
@@ -6677,6 +6748,7 @@ function tagOrigin(tag, settings) {
6677
6748
  if (tag === str(settings.followupTag)) return "tag de suivi";
6678
6749
  if (tag === str(settings.escalationTag)) return "tag d'escalade";
6679
6750
  if (tag === str(settings.handledTag)) return "tag de traitement";
6751
+ if (tag === str(settings.appScopeTag)) return "tag d'appartenance";
6680
6752
  if (tag === str(settings.unknownTag)) return "classification de repli";
6681
6753
  return "classification";
6682
6754
  }
@@ -7401,14 +7473,14 @@ function useExperiments(datasetName) {
7401
7473
  const api = uiSdk.useAppApi();
7402
7474
  const apiRef = react.useRef(api);
7403
7475
  apiRef.current = api;
7404
- const trimmed = datasetName.trim();
7476
+ const trimmed2 = datasetName.trim();
7405
7477
  const load = react.useCallback(async () => {
7406
- if (trimmed.length === 0) return [];
7407
- const params = new URLSearchParams({ datasetName: trimmed });
7478
+ if (trimmed2.length === 0) return [];
7479
+ const params = new URLSearchParams({ datasetName: trimmed2 });
7408
7480
  return apiRef.current.get(
7409
7481
  `/data/apps/${appSlug}/quality/experiments?${params.toString()}`
7410
7482
  );
7411
- }, [appSlug, trimmed]);
7483
+ }, [appSlug, trimmed2]);
7412
7484
  return useAsyncData(load, []);
7413
7485
  }
7414
7486
  function useReview(reviewId) {