@apotech-os/support-kit 3.0.2 → 3.1.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
@@ -60,6 +60,7 @@ function toTriageDecision(record) {
60
60
  return {
61
61
  id: record.id,
62
62
  ticketId: data.ticketId ?? "",
63
+ ticketUrl: data.ticketUrl ?? null,
63
64
  decidedAt: data.decidedAt ?? null,
64
65
  categoryId: data.categoryId ?? null,
65
66
  tag: data.tag ?? null,
@@ -504,6 +505,29 @@ function DashboardPage() {
504
505
  ] })
505
506
  ] });
506
507
  }
508
+ function isHttpUrl(url) {
509
+ try {
510
+ const { protocol } = new URL(url);
511
+ return protocol === "http:" || protocol === "https:";
512
+ } catch {
513
+ return false;
514
+ }
515
+ }
516
+ function TicketLink({ ticketId, url, label }) {
517
+ if (!url || !isHttpUrl(url)) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: label ?? ticketId });
518
+ return /* @__PURE__ */ jsxRuntime.jsx(
519
+ uiSdk.Link,
520
+ {
521
+ href: url,
522
+ target: "_blank",
523
+ rel: "noopener noreferrer",
524
+ className: "font-medium",
525
+ title: "Ouvrir le ticket dans Gorgias",
526
+ onClick: (event) => event.stopPropagation(),
527
+ children: label ?? ticketId
528
+ }
529
+ );
530
+ }
507
531
  var UNCONFIGURED = { baseUrl: null, projectId: null };
508
532
  function useLangfuseConfig() {
509
533
  const { appSlug } = uiSdk.useAppContext();
@@ -720,6 +744,7 @@ function DetailPanel({
720
744
  onClose
721
745
  }) {
722
746
  return /* @__PURE__ */ jsxRuntime.jsx(uiSdk.SidePanel, { open: true, onClose, title: `Ticket ${decision.ticketId}`, description: categoryName, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4 text-sm", children: [
747
+ decision.ticketUrl && /* @__PURE__ */ jsxRuntime.jsx("p", { children: /* @__PURE__ */ jsxRuntime.jsx(TicketLink, { ticketId: decision.ticketId, url: decision.ticketUrl, label: "Ouvrir le ticket dans Gorgias" }) }),
723
748
  decision.status === "error" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-md bg-destructive/10 p-3 text-destructive", children: [
724
749
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs font-semibold uppercase tracking-wider", children: TRIAGE_DECISION_STATUS_LABELS.error }),
725
750
  decision.error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-xs", children: decision.error })
@@ -872,7 +897,7 @@ function TicketsPage() {
872
897
  return withOutcome.filter((r) => r.job && responseOutcome(r.job).variant === outcomeFilter);
873
898
  }, [decisions, jobByDecisionId, outcomeFilter]);
874
899
  const columns = [
875
- { key: "ticketId", header: "Ticket", cell: ({ decision }) => decision.ticketId },
900
+ { key: "ticketId", header: "Ticket", cell: ({ decision }) => /* @__PURE__ */ jsxRuntime.jsx(TicketLink, { ticketId: decision.ticketId, url: decision.ticketUrl }) },
876
901
  {
877
902
  key: "category",
878
903
  header: "Cat\xE9gorie",
@@ -3156,6 +3181,7 @@ function StatusBadge({ status, error }) {
3156
3181
  }
3157
3182
  function DetailPanel3({ row, categoryName, onClose }) {
3158
3183
  return /* @__PURE__ */ jsxRuntime.jsx(uiSdk.SidePanel, { open: true, onClose, title: `Ticket ${row.ticketId}`, description: categoryName, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4 text-sm", children: [
3184
+ row.ticketUrl && /* @__PURE__ */ jsxRuntime.jsx("p", { children: /* @__PURE__ */ jsxRuntime.jsx(TicketLink, { ticketId: row.ticketId, url: row.ticketUrl, label: "Ouvrir le ticket dans Gorgias" }) }),
3159
3185
  row.reasoning && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3160
3186
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Raison du triage" }),
3161
3187
  /* @__PURE__ */ jsxRuntime.jsx("p", { children: row.reasoning })
@@ -3213,7 +3239,7 @@ function EscalationsPage() {
3213
3239
  const { rows: categories } = useRecordList("category", { limit: 500 }, toCategory);
3214
3240
  const categoryNames = react.useMemo(() => toNameMap(categories), [categories]);
3215
3241
  const columns = [
3216
- { key: "ticketId", header: "Ticket", cell: (row) => row.ticketId },
3242
+ { key: "ticketId", header: "Ticket", cell: (row) => /* @__PURE__ */ jsxRuntime.jsx(TicketLink, { ticketId: row.ticketId, url: row.ticketUrl }) },
3217
3243
  { key: "category", header: "Cat\xE9gorie", cell: (row) => row.categoryId && categoryNames.get(row.categoryId) || "\u2014" },
3218
3244
  { key: "tag", header: "Tag", cell: (row) => row.tag ? /* @__PURE__ */ jsxRuntime.jsx("code", { className: "text-xs", children: row.tag }) : "\u2014" },
3219
3245
  {
@@ -4821,6 +4847,31 @@ function SettingsPage() {
4821
4847
  ] })
4822
4848
  );
4823
4849
  }
4850
+ function readParam(name) {
4851
+ if (typeof window === "undefined") return null;
4852
+ return new URLSearchParams(window.location.search).get(name);
4853
+ }
4854
+ function useQueryParam(name) {
4855
+ const [value, setState] = react.useState(() => readParam(name));
4856
+ react.useEffect(() => {
4857
+ const sync = () => setState(readParam(name));
4858
+ sync();
4859
+ window.addEventListener("popstate", sync);
4860
+ return () => window.removeEventListener("popstate", sync);
4861
+ }, [name]);
4862
+ const setValue = react.useCallback(
4863
+ (next) => {
4864
+ const params = new URLSearchParams(window.location.search);
4865
+ if (next === null) params.delete(name);
4866
+ else params.set(name, next);
4867
+ const query = params.toString();
4868
+ window.history.pushState({}, "", `${window.location.pathname}${query ? `?${query}` : ""}`);
4869
+ setState(next);
4870
+ },
4871
+ [name]
4872
+ );
4873
+ return { value, setValue };
4874
+ }
4824
4875
 
4825
4876
  // src/graph/state.ts
4826
4877
  var NODE_NAMES = [
@@ -4841,14 +4892,32 @@ function hasNoDraftNode(profile) {
4841
4892
  }
4842
4893
 
4843
4894
  // src/ui/graph-canvas/reachability.ts
4895
+ var EXIT_TONES = {
4896
+ sent: "delivered",
4897
+ failed: "failure",
4898
+ ready: "held",
4899
+ needs_human: "held",
4900
+ guardrail_hold: "held",
4901
+ awaiting_approval: "held",
4902
+ escalated: "held",
4903
+ triaged_only: "held",
4904
+ no_reply_needed: "held"
4905
+ };
4844
4906
  function stubPrompts() {
4845
4907
  const ref = { name: "", label: "production" };
4846
4908
  return { triage: ref, escalate: ref, draft: ref, evaluate: ref };
4847
4909
  }
4848
4910
  var PROMPT_403_NODES = /* @__PURE__ */ new Set(["triage", "escalate", "draft", "evaluate", "revise"]);
4849
- var PROMPT_403_NOTE = "promptRef est transmis \xE0 ctx.api.llm.complete, qui r\xE9pond 403 en production tant que manifest.prompts[] reste vide (d\xE9faut D-LF connu, non corrig\xE9 \u2014 voir le journal T24/T25) : ce n\u0153ud peut renvoyer PROMPT_NOT_DECLARED sur un d\xE9ploiement r\xE9el malgr\xE9 un r\xE9glage \xAB Actif \xBB ici.";
4850
- function reason(kind, message) {
4851
- return { kind, message };
4911
+ var PROMPT_403_NOTE = {
4912
+ id: "prompt-403",
4913
+ message: "Ces \xE9tapes appellent un mod\xE8le via un prompt qui n'est pas d\xE9clar\xE9 : sur un d\xE9ploiement r\xE9el l'appel \xE9choue, m\xEAme l\xE0 o\xF9 cette page affiche \xAB Actif \xBB.",
4914
+ detail: "promptRef est transmis \xE0 ctx.api.llm.complete, qui r\xE9pond 403 PROMPT_NOT_DECLARED tant que manifest.prompts[] reste vide \u2014 d\xE9faut D-LF connu, non corrig\xE9 (journal T24/T25)."
4915
+ };
4916
+ function reason(kind, message, detail) {
4917
+ return detail === void 0 ? { kind, message } : { kind, message, detail };
4918
+ }
4919
+ function note(message, detail) {
4920
+ return detail === void 0 ? { message } : { message, detail };
4852
4921
  }
4853
4922
  function nodeModelOf(node, profile) {
4854
4923
  switch (node) {
@@ -4864,17 +4933,35 @@ function nodeModelOf(node, profile) {
4864
4933
  return null;
4865
4934
  }
4866
4935
  }
4867
- var READY_EXIT = { key: "evaluate-ready", condition: "envoi auto non \xE9ligible", outcome: "ready" };
4936
+ var READY_EXIT = {
4937
+ key: "evaluate-ready",
4938
+ condition: "envoi auto non \xE9ligible",
4939
+ outcome: "ready"
4940
+ };
4868
4941
  var NODE_EXITS = {
4869
- fetchContext: [{ key: "fetchContext-failed", condition: "lecture impossible", outcome: "failed" }],
4942
+ fetchContext: [
4943
+ { key: "fetchContext-failed", condition: "lecture impossible", outcome: "failed" }
4944
+ ],
4870
4945
  triage: [
4871
4946
  { key: "triage-fallback", condition: "classification de repli", outcome: "triaged_only" },
4872
- { key: "triage-closed", condition: "le dernier message client cl\xF4t la conversation", outcome: "no_reply_needed" },
4873
- { key: "triage-whatsapp-gate", condition: "r\xE8gle de canal WhatsApp (STOP ou pas notre tour)", outcome: "guardrail_hold" }
4947
+ {
4948
+ key: "triage-closed",
4949
+ condition: "le dernier message client cl\xF4t la conversation",
4950
+ outcome: "no_reply_needed"
4951
+ },
4952
+ {
4953
+ key: "triage-whatsapp-gate",
4954
+ condition: "r\xE8gle de canal WhatsApp (STOP ou pas notre tour)",
4955
+ outcome: "guardrail_hold"
4956
+ }
4874
4957
  ],
4875
4958
  escalate: [
4876
4959
  { key: "escalate-escalated", condition: "escalade demand\xE9e", outcome: "escalated" },
4877
- { key: "escalate-no-draft", condition: "profil sans n\u0153ud de r\xE9daction", outcome: "triaged_only" }
4960
+ {
4961
+ key: "escalate-no-draft",
4962
+ condition: "profil sans n\u0153ud de r\xE9daction",
4963
+ outcome: "triaged_only"
4964
+ }
4878
4965
  ],
4879
4966
  evaluate: [
4880
4967
  {
@@ -4884,8 +4971,16 @@ var NODE_EXITS = {
4884
4971
  },
4885
4972
  READY_EXIT
4886
4973
  ],
4887
- guardrails: [{ key: "guardrails-content", condition: "garde-fou de contenu", outcome: "guardrail_hold" }],
4888
- authorize: [{ key: "authorize-awaiting", condition: "une action n'est pas \xAB auto \xBB", outcome: "awaiting_approval" }],
4974
+ guardrails: [
4975
+ { key: "guardrails-content", condition: "garde-fou de contenu", outcome: "guardrail_hold" }
4976
+ ],
4977
+ authorize: [
4978
+ {
4979
+ key: "authorize-awaiting",
4980
+ condition: "une action n'est pas \xAB auto \xBB",
4981
+ outcome: "awaiting_approval"
4982
+ }
4983
+ ],
4889
4984
  act: [
4890
4985
  { key: "act-collision", condition: "contr\xF4le anti-collision", outcome: "guardrail_hold" },
4891
4986
  { key: "act-sent-email", condition: "r\xE9ponse email", outcome: "sent" },
@@ -4894,10 +4989,15 @@ var NODE_EXITS = {
4894
4989
  };
4895
4990
  function exitsFor(node, evaluateConfigured) {
4896
4991
  const raw = NODE_EXITS[node] ?? [];
4897
- if (evaluateConfigured) return raw;
4992
+ const withTone = (exits) => exits.map((exit) => ({ ...exit, tone: EXIT_TONES[exit.outcome] }));
4993
+ if (evaluateConfigured) return withTone(raw);
4898
4994
  if (node === "evaluate") return [];
4899
- if (node === "draft") return [READY_EXIT];
4900
- return raw;
4995
+ if (node === "draft") return withTone([READY_EXIT]);
4996
+ return withTone(raw);
4997
+ }
4998
+ function deriveCause(state, reasons) {
4999
+ if (state === "on") return null;
5000
+ return reasons.some((r) => r.kind !== "upstream-disabled") ? "root" : "consequence";
4901
5001
  }
4902
5002
  function deriveState(upstreamOk, blockingReasons, offReasons) {
4903
5003
  if (!upstreamOk) return "unreachable";
@@ -4915,11 +5015,17 @@ function computeGraphReachability(rawSettings, hasCategoryWithAutoReply) {
4915
5015
  nodes: NODE_NAMES.map((node) => ({
4916
5016
  node,
4917
5017
  state: "unreachable",
4918
- reasons: [reason("missing-setting", message)],
5018
+ // Every node reports the SAME single root cause here — none of them
5019
+ // is "blocked by the one before", they are all blocked by the same
5020
+ // absent setting, so none is a mere consequence of another.
5021
+ cause: "root",
5022
+ reasons: [reason("missing-setting", message, "validateSettings: nodes.triage est \xE0 null.")],
4919
5023
  notes: [],
4920
5024
  model: null,
4921
- exits: []
4922
- }))
5025
+ exits: [],
5026
+ promptWarning: false
5027
+ })),
5028
+ globalNotes: []
4923
5029
  };
4924
5030
  }
4925
5031
  const settings = rawSettings;
@@ -4927,20 +5033,23 @@ function computeGraphReachability(rawSettings, hasCategoryWithAutoReply) {
4927
5033
  const evaluateConfigured = profile.nodes.evaluate !== null;
4928
5034
  const byNode = /* @__PURE__ */ new Map();
4929
5035
  function set(node, state, reasons, notes = []) {
4930
- const promptNote = state === "on" && PROMPT_403_NODES.has(node) ? [PROMPT_403_NOTE] : [];
4931
5036
  byNode.set(node, {
4932
5037
  node,
4933
5038
  state,
5039
+ cause: deriveCause(state, reasons),
4934
5040
  reasons,
4935
- notes: [...notes, ...promptNote],
5041
+ notes,
4936
5042
  model: nodeModelOf(node, profile),
4937
- exits: exitsFor(node, evaluateConfigured)
5043
+ exits: exitsFor(node, evaluateConfigured),
5044
+ promptWarning: state === "on" && PROMPT_403_NODES.has(node)
4938
5045
  });
4939
5046
  }
4940
5047
  function getNode(node) {
4941
5048
  const found = byNode.get(node);
4942
5049
  if (!found) {
4943
- throw new Error(`computeGraphReachability: no reachability rule was set for node "${node}" \u2014 NODE_NAMES gained an entry this module does not know how to place.`);
5050
+ throw new Error(
5051
+ `computeGraphReachability: no reachability rule was set for node "${node}" \u2014 NODE_NAMES gained an entry this module does not know how to place.`
5052
+ );
4944
5053
  }
4945
5054
  return found;
4946
5055
  }
@@ -4949,121 +5058,329 @@ function computeGraphReachability(rawSettings, hasCategoryWithAutoReply) {
4949
5058
  const fetchBlockingReasons = [];
4950
5059
  const sourceViewIdIssue = issues.find((issue) => issue.key === "sourceViewId");
4951
5060
  if (sourceViewIdIssue) {
4952
- fetchBlockingReasons.push(reason("missing-setting", settingsIssueLabel("sourceViewId", sourceViewIdIssue.message)));
5061
+ fetchBlockingReasons.push(
5062
+ reason(
5063
+ "missing-setting",
5064
+ settingsIssueLabel("sourceViewId", sourceViewIdIssue.message),
5065
+ "validateSettings: sourceViewId est vide."
5066
+ )
5067
+ );
4953
5068
  }
4954
5069
  if (!settings.triageEnabled) {
4955
- fetchOffReasons.push(reason("missing-setting", "triageEnabled est d\xE9sactiv\xE9 \u2014 ce coupe-circuit emp\xEAche toute ex\xE9cution du pipeline."));
5070
+ fetchOffReasons.push(
5071
+ reason(
5072
+ "missing-setting",
5073
+ "Le pipeline est coup\xE9 : aucun ticket n'est lu, donc aucune \xE9tape ne s'ex\xE9cute.",
5074
+ "triageEnabled est d\xE9sactiv\xE9 \u2014 coupe-circuit global (\xA73.5)."
5075
+ )
5076
+ );
4956
5077
  }
4957
- set("fetchContext", deriveState(true, fetchBlockingReasons, fetchOffReasons), [...fetchBlockingReasons, ...fetchOffReasons]);
5078
+ set("fetchContext", deriveState(true, fetchBlockingReasons, fetchOffReasons), [
5079
+ ...fetchBlockingReasons,
5080
+ ...fetchOffReasons
5081
+ ]);
4958
5082
  const fetchNode = getNode("fetchContext");
4959
5083
  const fetchRuns = passesControlOn("fetchContext");
4960
5084
  set(
4961
5085
  "triage",
4962
5086
  fetchRuns ? "on" : "unreachable",
4963
5087
  fetchRuns ? [] : [
4964
- reason(
5088
+ fetchNode.state === "off" ? reason(
5089
+ "upstream-disabled",
5090
+ "La r\xE9cup\xE9ration du ticket est coup\xE9e \u2014 aucun ticket n'est jamais lu.",
5091
+ "fetchContext est d\xE9sactiv\xE9 (triageEnabled)."
5092
+ ) : reason(
4965
5093
  "upstream-disabled",
4966
- fetchNode.state === "off" ? "fetchContext est d\xE9sactiv\xE9 (triageEnabled) \u2014 aucun ticket n'est jamais lu." : "fetchContext est inatteignable \u2014 voir les raisons ci-dessus."
5094
+ "La r\xE9cup\xE9ration du ticket est bloqu\xE9e \u2014 voir sa carte.",
5095
+ "fetchContext est inatteignable (sourceViewId)."
4967
5096
  )
4968
5097
  ]
4969
5098
  );
4970
5099
  const triageRuns = passesControlOn("triage");
4971
5100
  const escalateDisabled = profile.nodes.escalate === null;
5101
+ const escalateOff = reason(
5102
+ "disabled-step",
5103
+ "\xC9tape coup\xE9e dans les r\xE9glages \u2014 aucune escalade automatique n'est d\xE9cid\xE9e.",
5104
+ "nodes.escalate est \xE0 null (\xA73.6)."
5105
+ );
4972
5106
  set(
4973
5107
  "escalate",
4974
- deriveState(triageRuns, [], escalateDisabled ? [reason("disabled-step", "nodes.escalate est \xE0 null dans les r\xE9glages \u2014 \xE9tape d\xE9sactiv\xE9e (\xA73.6).")] : []),
4975
- triageRuns ? escalateDisabled ? [reason("disabled-step", "nodes.escalate est \xE0 null dans les r\xE9glages \u2014 \xE9tape d\xE9sactiv\xE9e (\xA73.6).")] : [] : [reason("upstream-disabled", "triage est inatteignable.")]
5108
+ deriveState(triageRuns, [], escalateDisabled ? [escalateOff] : []),
5109
+ triageRuns ? escalateDisabled ? [escalateOff] : [] : [
5110
+ reason(
5111
+ "upstream-disabled",
5112
+ "Le triage n'est jamais atteint.",
5113
+ "triage est inatteignable."
5114
+ )
5115
+ ]
4976
5116
  );
4977
5117
  const draftDisabled = hasNoDraftNode(profile);
5118
+ const draftOff = reason(
5119
+ "disabled-step",
5120
+ "\xC9tape coup\xE9e dans les r\xE9glages \u2014 aucune r\xE9ponse n'est r\xE9dig\xE9e.",
5121
+ "nodes.draft est \xE0 null \u2014 sortie \xAB triaged_only \xBB (run-ticket.ts#hasNoDraftNode)."
5122
+ );
4978
5123
  set(
4979
5124
  "draft",
4980
- deriveState(triageRuns, [], draftDisabled ? [reason("disabled-step", 'nodes.draft est \xE0 null dans les r\xE9glages \u2014 aucune r\xE9ponse ne sera r\xE9dig\xE9e (sortie "triaged_only").')] : []),
4981
- triageRuns ? draftDisabled ? [reason("disabled-step", 'nodes.draft est \xE0 null dans les r\xE9glages \u2014 aucune r\xE9ponse ne sera r\xE9dig\xE9e (sortie "triaged_only").')] : [] : [reason("upstream-disabled", "triage est inatteignable.")]
5125
+ deriveState(triageRuns, [], draftDisabled ? [draftOff] : []),
5126
+ triageRuns ? draftDisabled ? [draftOff] : [] : [
5127
+ reason(
5128
+ "upstream-disabled",
5129
+ "Le triage n'est jamais atteint.",
5130
+ "triage est inatteignable."
5131
+ )
5132
+ ]
4982
5133
  );
4983
5134
  const draftRuns = passesControlOn("draft");
4984
5135
  const evaluateDisabled = !evaluateConfigured;
5136
+ const evaluateOff = reason(
5137
+ "disabled-step",
5138
+ "\xC9tape coup\xE9e dans les r\xE9glages \u2014 aucun verdict, la r\xE9ponse reste \xAB Disponible \xBB.",
5139
+ "nodes.evaluate est \xE0 null \u2014 la r\xE9ponse conserve l'issue \xAB ready \xBB."
5140
+ );
4985
5141
  set(
4986
5142
  "evaluate",
4987
- deriveState(draftRuns, [], evaluateDisabled ? [reason("disabled-step", `nodes.evaluate est \xE0 null dans les r\xE9glages \u2014 aucun verdict n'est jamais produit, la r\xE9ponse reste "ready".`)] : []),
4988
- draftRuns ? evaluateDisabled ? [reason("disabled-step", `nodes.evaluate est \xE0 null dans les r\xE9glages \u2014 aucun verdict n'est jamais produit, la r\xE9ponse reste "ready".`)] : [] : [reason("upstream-disabled", getNode("draft").state === "off" ? "draft est d\xE9sactiv\xE9 \u2014 aucun ticket n'atteint jamais \xE9valuate." : "draft est inatteignable.")]
5143
+ deriveState(draftRuns, [], evaluateDisabled ? [evaluateOff] : []),
5144
+ draftRuns ? evaluateDisabled ? [evaluateOff] : [] : [
5145
+ getNode("draft").state === "off" ? reason(
5146
+ "upstream-disabled",
5147
+ "La r\xE9daction est coup\xE9e \u2014 aucun ticket n'atteint l'\xE9valuation.",
5148
+ "draft est d\xE9sactiv\xE9."
5149
+ ) : reason(
5150
+ "upstream-disabled",
5151
+ "La r\xE9daction n'est jamais atteinte.",
5152
+ "draft est inatteignable."
5153
+ )
5154
+ ]
4989
5155
  );
4990
5156
  const evaluateRuns = passesControlOn("evaluate");
4991
5157
  const reviseDisabled = profile.nodes.revise === null;
5158
+ const reviseOff = reason(
5159
+ "disabled-step",
5160
+ "\xC9tape coup\xE9e dans les r\xE9glages \u2014 pas de passe de correction.",
5161
+ "nodes.revise est \xE0 null."
5162
+ );
4992
5163
  set(
4993
5164
  "revise",
4994
- deriveState(evaluateRuns, [], reviseDisabled ? [reason("disabled-step", "nodes.revise est \xE0 null dans les r\xE9glages \u2014 pas de passe de correction.")] : []),
4995
- evaluateRuns ? reviseDisabled ? [reason("disabled-step", "nodes.revise est \xE0 null dans les r\xE9glages \u2014 pas de passe de correction.")] : [] : [reason("upstream-disabled", getNode("evaluate").state === "off" ? "evaluate est d\xE9sactiv\xE9 \u2014 aucun ticket n'atteint jamais revise." : "evaluate est inatteignable.")],
4996
- evaluateRuns && !reviseDisabled ? ["Au plus une passe de r\xE9vision par ticket (\xA73.3)."] : []
5165
+ deriveState(evaluateRuns, [], reviseDisabled ? [reviseOff] : []),
5166
+ evaluateRuns ? reviseDisabled ? [reviseOff] : [] : [
5167
+ getNode("evaluate").state === "off" ? reason(
5168
+ "upstream-disabled",
5169
+ "L'\xE9valuation est coup\xE9e \u2014 aucun ticket n'atteint la r\xE9vision.",
5170
+ "evaluate est d\xE9sactiv\xE9."
5171
+ ) : reason(
5172
+ "upstream-disabled",
5173
+ "L'\xE9valuation n'est jamais atteinte.",
5174
+ "evaluate est inatteignable."
5175
+ )
5176
+ ],
5177
+ evaluateRuns && !reviseDisabled ? [note("Au plus une passe de r\xE9vision par ticket.", "\xA73.3.")] : []
4997
5178
  );
4998
5179
  const autoSendBlockingReasons = [];
4999
5180
  const autoSendOffReasons = [];
5000
5181
  if (!profile.autoSend.enabled) {
5001
- autoSendOffReasons.push(reason("missing-setting", "autoSendEnabled est d\xE9sactiv\xE9 \u2014 ce coupe-circuit emp\xEAche tout envoi automatique."));
5182
+ autoSendOffReasons.push(
5183
+ reason(
5184
+ "missing-setting",
5185
+ "L'envoi automatique est coup\xE9 \u2014 ce coupe-circuit emp\xEAche tout envoi.",
5186
+ "autoSendEnabled est d\xE9sactiv\xE9."
5187
+ )
5188
+ );
5002
5189
  }
5003
5190
  if (!hasCategoryWithAutoReply) {
5004
5191
  autoSendBlockingReasons.push(
5005
- reason("missing-setting", `Aucune cat\xE9gorie n'a "Envoi auto" activ\xE9 \u2014 isAutoSendEligible exige category.autoReplyEnabled, qu'aucune cat\xE9gorie ne porte aujourd'hui.`)
5192
+ reason(
5193
+ "missing-setting",
5194
+ "Aucune cat\xE9gorie n'a \xAB Envoi auto \xBB activ\xE9 \u2014 sans elle, aucune r\xE9ponse n'est \xE9ligible \xE0 un envoi automatique.",
5195
+ "isAutoSendEligible exige category.autoReplyEnabled ; aucune cat\xE9gorie ne le porte aujourd'hui."
5196
+ )
5006
5197
  );
5007
5198
  }
5008
5199
  const senderEmailIssue = issues.find((issue) => issue.key === "senderEmail");
5009
5200
  if (senderEmailIssue) {
5010
- autoSendBlockingReasons.push(reason("missing-setting", settingsIssueLabel("senderEmail", senderEmailIssue.message)));
5201
+ autoSendBlockingReasons.push(
5202
+ reason(
5203
+ "missing-setting",
5204
+ settingsIssueLabel("senderEmail", senderEmailIssue.message),
5205
+ "validateSettings: senderEmail est vide alors que autoSendEnabled est actif."
5206
+ )
5207
+ );
5011
5208
  }
5012
5209
  const guardrailNotes = [];
5013
5210
  if (!profile.autoSend.senderEmail && profile.guardrails.params.whatsappMode === "auto_reply") {
5014
5211
  guardrailNotes.push(
5015
- `senderEmail est vide : seuls les tickets WhatsApp en mode "auto_reply" peuvent atteindre ce n\u0153ud sans adresse d'envoi \u2014 un ticket email reste bloqu\xE9 \xE0 "ready", sans jamais atteindre guardrails/authorize/act.`
5212
+ note(
5213
+ "Sans adresse d'envoi, seuls les tickets WhatsApp en r\xE9ponse automatique passent ici : un ticket email reste bloqu\xE9 \xE0 \xAB Disponible \xBB.",
5214
+ `senderEmail est vide et whatsappMode="auto_reply" \u2014 hasSenderForMode n'est vrai que pour WhatsApp ; un ticket email n'atteint jamais guardrails/authorize/act.`
5215
+ )
5016
5216
  );
5017
5217
  }
5018
5218
  if (profile.guardrails.params.whatsappMode === "draft_only") {
5019
5219
  guardrailNotes.push(
5020
- 'whatsappMode="draft_only" : un ticket WhatsApp ne d\xE9passera jamais "ready" (isAutoSendEligible exclut ce mode) \u2014 seuls les tickets email atteignent r\xE9ellement ce n\u0153ud, et donc authorize/act ci-apr\xE8s.'
5220
+ note(
5221
+ "Les tickets WhatsApp ne d\xE9passent jamais \xAB Disponible \xBB (mode brouillon seul) : seuls les tickets email arrivent r\xE9ellement ici.",
5222
+ `whatsappMode="draft_only" \u2014 isAutoSendEligible exclut ce mode ; authorize/act ne s'ex\xE9cutent que pour le canal email.`
5223
+ )
5021
5224
  );
5022
5225
  }
5023
5226
  if (profile.guardrails.params.whatsappMode === "escalate_only") {
5024
5227
  guardrailNotes.push(
5025
- `whatsappMode="escalate_only" : un ticket WhatsApp qui atteint ce n\u0153ud sera syst\xE9matiquement bloqu\xE9 par le garde-fou "whatsapp" (\xA73.9) \u2014 la r\xE9ponse est retenue, pas envoy\xE9e, et authorize/act ci-apr\xE8s ne s'ex\xE9cutent jamais pour ce canal.`
5228
+ note(
5229
+ "Un ticket WhatsApp qui arrive ici est syst\xE9matiquement retenu : sur ce canal la r\xE9ponse est gard\xE9e, jamais envoy\xE9e.",
5230
+ `whatsappMode="escalate_only" \u2014 garde-fou \xAB whatsapp \xBB (\xA73.9) ; authorize/act ne s'ex\xE9cutent jamais pour ce canal.`
5231
+ )
5026
5232
  );
5027
5233
  }
5028
5234
  set(
5029
5235
  "guardrails",
5030
5236
  deriveState(evaluateRuns, autoSendBlockingReasons, autoSendOffReasons),
5031
- evaluateRuns ? [...autoSendBlockingReasons, ...autoSendOffReasons] : [reason("upstream-disabled", getNode("evaluate").state === "off" ? "evaluate est d\xE9sactiv\xE9 \u2014 sans verdict, aucun ticket n'atteint jamais ce n\u0153ud." : "evaluate est inatteignable \u2014 aucun verdict ne peut donc jamais \xEAtre produit.")],
5237
+ evaluateRuns ? [...autoSendBlockingReasons, ...autoSendOffReasons] : [
5238
+ getNode("evaluate").state === "off" ? reason(
5239
+ "upstream-disabled",
5240
+ "L'\xE9valuation est coup\xE9e \u2014 sans verdict, aucun ticket n'arrive ici.",
5241
+ "evaluate est d\xE9sactiv\xE9."
5242
+ ) : reason(
5243
+ "upstream-disabled",
5244
+ "L'\xE9valuation n'est jamais atteinte \u2014 aucun verdict ne peut donc \xEAtre produit.",
5245
+ "evaluate est inatteignable."
5246
+ )
5247
+ ],
5032
5248
  guardrailNotes
5033
5249
  );
5034
5250
  const guardrailsRuns = passesControlOn("guardrails");
5035
5251
  set(
5036
5252
  "authorize",
5037
5253
  guardrailsRuns ? "on" : "unreachable",
5038
- guardrailsRuns ? [] : [reason("upstream-disabled", getNode("guardrails").state === "off" ? "guardrails est d\xE9sactiv\xE9 (autoSendEnabled) \u2014 aucune action n'est jamais autoris\xE9e." : "guardrails est inatteignable \u2014 voir les raisons ci-dessus.")],
5254
+ guardrailsRuns ? [] : [
5255
+ getNode("guardrails").state === "off" ? reason(
5256
+ "upstream-disabled",
5257
+ "Les garde-fous sont coup\xE9s \u2014 aucune action n'est jamais autoris\xE9e.",
5258
+ "guardrails est d\xE9sactiv\xE9 (autoSendEnabled)."
5259
+ ) : reason(
5260
+ "upstream-disabled",
5261
+ "Les garde-fous ne sont jamais atteints \u2014 voir leur carte.",
5262
+ "guardrails est inatteignable."
5263
+ )
5264
+ ],
5039
5265
  guardrailsRuns ? guardrailNotes : []
5040
5266
  );
5041
5267
  const authorizeRuns = passesControlOn("authorize");
5042
- const approvalNote = `Le chemin d'approbation manuelle ("awaiting_approval") est inatteignable avec les r\xE9glages actuels : authorization.send_reply d\xE9rive du m\xEAme coupe-circuit autoSendEnabled qu'isAutoSendEligible, donc "act" est toujours atteint en direct, jamais via une approbation (limitation connue, voir le journal T22).`;
5268
+ const approvalNote = note(
5269
+ "Le chemin d'approbation manuelle est inatteignable avec les r\xE9glages actuels : une r\xE9ponse autoris\xE9e part directement, jamais apr\xE8s une approbation.",
5270
+ "authorization.send_reply d\xE9rive du m\xEAme coupe-circuit autoSendEnabled qu'isAutoSendEligible \u2014 l'issue \xAB awaiting_approval \xBB n'est jamais produite (limitation connue, journal T22)."
5271
+ );
5043
5272
  set(
5044
5273
  "act",
5045
5274
  authorizeRuns ? "on" : "unreachable",
5046
- authorizeRuns ? [] : [reason("upstream-disabled", "authorize est inatteignable.")],
5275
+ authorizeRuns ? [] : [
5276
+ reason(
5277
+ "upstream-disabled",
5278
+ "L'autorisation n'est jamais atteinte.",
5279
+ "authorize est inatteignable."
5280
+ )
5281
+ ],
5047
5282
  authorizeRuns ? [...guardrailNotes, approvalNote] : []
5048
5283
  );
5049
- return { blocked: false, nodes: NODE_NAMES.map((node) => getNode(node)) };
5284
+ const nodes = NODE_NAMES.map((node) => getNode(node));
5285
+ const promptWarningNodes = nodes.filter((n) => n.promptWarning).map((n) => n.node);
5286
+ return {
5287
+ blocked: false,
5288
+ nodes,
5289
+ globalNotes: promptWarningNodes.length > 0 ? [{ ...PROMPT_403_NOTE, nodes: promptWarningNodes }] : []
5290
+ };
5291
+ }
5292
+ function windowCutoffIso3(days, now = Date.now()) {
5293
+ return new Date(now - days * 24 * 60 * 60 * 1e3).toISOString();
5294
+ }
5295
+ function totalOf(rows) {
5296
+ if (!Array.isArray(rows)) return null;
5297
+ let total = 0;
5298
+ for (const row of rows) {
5299
+ const value = row?.count;
5300
+ if (typeof value !== "number") return null;
5301
+ total += value;
5302
+ }
5303
+ return total;
5304
+ }
5305
+ function useGraphTraffic(windowDays) {
5306
+ const cutoffIso = react.useMemo(() => windowCutoffIso3(windowDays), [windowDays]);
5307
+ const triaged = useAggregate("triage-decision", {
5308
+ filter: { decidedAt: { gte: cutoffIso } },
5309
+ metrics: [{ op: "count", as: "count" }]
5310
+ });
5311
+ const escalated = useAggregate("triage-decision", {
5312
+ filter: { decidedAt: { gte: cutoffIso }, escalated: { eq: true } },
5313
+ metrics: [{ op: "count", as: "count" }]
5314
+ });
5315
+ const drafted = useAggregate("generated-response", {
5316
+ filter: { generatedAt: { gte: cutoffIso } },
5317
+ metrics: [{ op: "count", as: "count" }]
5318
+ });
5319
+ const sent = useAggregate("generated-response", {
5320
+ filter: { generatedAt: { gte: cutoffIso }, status: { eq: "sent" } },
5321
+ metrics: [{ op: "count", as: "count" }]
5322
+ });
5323
+ const isLoading = triaged.isLoading || escalated.isLoading || drafted.isLoading || sent.isLoading;
5324
+ const failed = [triaged, escalated, drafted, sent].some((q) => q.error !== void 0);
5325
+ const triagedTotal = totalOf(triaged.rows);
5326
+ const escalatedTotal = totalOf(escalated.rows);
5327
+ const draftedTotal = totalOf(drafted.rows);
5328
+ const sentTotal = totalOf(sent.rows);
5329
+ return react.useMemo(() => {
5330
+ const byNode = {};
5331
+ if (triagedTotal !== null) {
5332
+ byNode.fetchContext = {
5333
+ count: triagedTotal,
5334
+ witness: "tickets triag\xE9s (un triage suppose une lecture r\xE9ussie)"
5335
+ };
5336
+ byNode.triage = { count: triagedTotal, witness: "tickets triag\xE9s" };
5337
+ }
5338
+ if (escalatedTotal !== null)
5339
+ byNode.escalate = { count: escalatedTotal, witness: "tickets escalad\xE9s" };
5340
+ if (draftedTotal !== null) byNode.draft = { count: draftedTotal, witness: "r\xE9ponses r\xE9dig\xE9es" };
5341
+ if (sentTotal !== null) byNode.act = { count: sentTotal, witness: "r\xE9ponses envoy\xE9es" };
5342
+ return {
5343
+ byNode: failed ? {} : byNode,
5344
+ isLoading,
5345
+ unavailable: failed
5346
+ };
5347
+ }, [triagedTotal, escalatedTotal, draftedTotal, sentTotal, failed, isLoading]);
5050
5348
  }
5051
5349
  var CATEGORY_PAGE_SIZE = 500;
5350
+ var TRAFFIC_WINDOW_DAYS = 7;
5052
5351
  var REASON_KIND_LABELS = {
5053
5352
  "disabled-step": "\xC9tape d\xE9sactiv\xE9e",
5054
5353
  "upstream-disabled": "Bloqu\xE9 en amont",
5055
5354
  "missing-setting": "R\xE9glage manquant",
5056
5355
  "channel-gate": "Restriction de canal"
5057
5356
  };
5058
- var ACTIVATION_LABELS = {
5357
+ var BADGE_LABELS = {
5059
5358
  on: "Actif",
5060
5359
  off: "D\xE9sactiv\xE9",
5061
- unreachable: "Inatteignable"
5360
+ root: "Bloqu\xE9",
5361
+ consequence: "Hors d\u2019atteinte"
5062
5362
  };
5063
- var ACTIVATION_BADGE_VARIANT = {
5363
+ var BADGE_VARIANTS = {
5064
5364
  on: "success",
5065
5365
  off: "neutral",
5066
- unreachable: "warning"
5366
+ root: "danger",
5367
+ consequence: "warning"
5368
+ };
5369
+ var BADGE_DEFINITIONS = {
5370
+ on: "Au moins un ticket peut atteindre ce n\u0153ud avec les r\xE9glages actuels.",
5371
+ off: "L\u2019op\xE9rateur a coup\xE9 ce n\u0153ud lui-m\xEAme \u2014 un choix, pas un incident.",
5372
+ root: "C\u2019est ici que le parcours s\u2019arr\xEAte : la cause est sur cette carte.",
5373
+ consequence: "Ce n\u0153ud n\u2019a rien de cass\xE9 \u2014 il est simplement priv\xE9 de tickets par un n\u0153ud en amont."
5374
+ };
5375
+ function badgeKindOf(node) {
5376
+ if (node.state === "on") return "on";
5377
+ if (node.state === "off") return "off";
5378
+ return node.cause === "consequence" ? "consequence" : "root";
5379
+ }
5380
+ var EXIT_TONE_CLASSES = {
5381
+ delivered: "border-status-success/30 bg-status-success/10 text-status-success",
5382
+ held: "border-border bg-muted text-muted-foreground",
5383
+ failure: "border-status-blocked/25 bg-status-blocked/10 text-status-blocked"
5067
5384
  };
5068
5385
  var NODE_SETTINGS_SECTION = {
5069
5386
  fetchContext: { id: "source", title: "Source" },
@@ -5075,60 +5392,395 @@ var NODE_SETTINGS_SECTION = {
5075
5392
  guardrails: { id: "guardrails", title: "Guardrails" },
5076
5393
  act: { id: "envoi", title: "Envoi" }
5077
5394
  };
5078
- function NodeCard({ node, appSlug }) {
5079
- const section = NODE_SETTINGS_SECTION[node.node];
5395
+ function settingsHref(appSlug, node) {
5396
+ const section = NODE_SETTINGS_SECTION[node];
5397
+ return section ? `/parametres/espaces/${appSlug}#${section.id}` : null;
5398
+ }
5399
+ function dedupeExits(exits) {
5400
+ const byOutcome = /* @__PURE__ */ new Map();
5401
+ for (const exit of exits) {
5402
+ const existing = byOutcome.get(exit.outcome);
5403
+ if (existing) existing.conditions.push(exit.condition);
5404
+ else
5405
+ byOutcome.set(exit.outcome, {
5406
+ outcome: exit.outcome,
5407
+ tone: exit.tone,
5408
+ conditions: [exit.condition]
5409
+ });
5410
+ }
5411
+ return [...byOutcome.values()];
5412
+ }
5413
+ function computeVerdict(result) {
5414
+ const causes = result.nodes.filter((node) => node.state !== "on" && node.cause === "root");
5415
+ if (result.blocked) {
5416
+ return {
5417
+ tone: "critical",
5418
+ headline: "Le pipeline ne peut pas d\xE9marrer : le triage n\u2019est pas configur\xE9.",
5419
+ causes: causes.slice(0, 1)
5420
+ };
5421
+ }
5422
+ const act = result.nodes.find((node) => node.node === "act");
5423
+ if (act && act.state !== "on") {
5424
+ return {
5425
+ tone: "critical",
5426
+ headline: "Aucune r\xE9ponse ne peut partir automatiquement aujourd\u2019hui.",
5427
+ causes
5428
+ };
5429
+ }
5430
+ return {
5431
+ tone: "ok",
5432
+ headline: "Le parcours va jusqu\u2019\xE0 l\u2019envoi : une r\xE9ponse peut partir automatiquement.",
5433
+ causes
5434
+ };
5435
+ }
5436
+ function VerdictBanner({ verdict, appSlug }) {
5437
+ const critical = verdict.tone === "critical";
5080
5438
  return /* @__PURE__ */ jsxRuntime.jsx(
5081
- uiSdk.Card,
5439
+ "section",
5082
5440
  {
5441
+ "data-testid": "graph-verdict",
5442
+ className: uiSdk.cn(
5443
+ "rounded-lg border p-4",
5444
+ critical ? "border-status-blocked/30 bg-status-blocked/5" : "border-status-success/30 bg-status-success/5"
5445
+ ),
5446
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-3", children: [
5447
+ /* @__PURE__ */ jsxRuntime.jsx(
5448
+ "span",
5449
+ {
5450
+ "aria-hidden": true,
5451
+ className: uiSdk.cn(
5452
+ "mt-0.5 text-lg leading-none",
5453
+ critical ? "text-status-blocked" : "text-status-success"
5454
+ ),
5455
+ children: critical ? "\u26D4" : "\u2713"
5456
+ }
5457
+ ),
5458
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
5459
+ /* @__PURE__ */ jsxRuntime.jsx(
5460
+ "p",
5461
+ {
5462
+ className: uiSdk.cn(
5463
+ "text-sm font-semibold",
5464
+ critical ? "text-status-blocked" : "text-status-success"
5465
+ ),
5466
+ children: verdict.headline
5467
+ }
5468
+ ),
5469
+ verdict.causes.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "space-y-2", children: verdict.causes.map((cause) => {
5470
+ const href = settingsHref(appSlug, cause.node);
5471
+ return /* @__PURE__ */ jsxRuntime.jsxs(
5472
+ "li",
5473
+ {
5474
+ className: "flex flex-wrap items-center gap-x-2 gap-y-1 text-sm",
5475
+ children: [
5476
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: NODE_LABELS[cause.node] }),
5477
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground", children: [
5478
+ "\u2014 ",
5479
+ cause.reasons[0]?.message ?? ""
5480
+ ] }),
5481
+ href && /* @__PURE__ */ jsxRuntime.jsx(
5482
+ uiSdk.Link,
5483
+ {
5484
+ href,
5485
+ className: uiSdk.cn(
5486
+ uiSdk.buttonVariants({ variant: "outline", size: "sm" }),
5487
+ "no-underline"
5488
+ ),
5489
+ children: "Corriger"
5490
+ }
5491
+ )
5492
+ ]
5493
+ },
5494
+ cause.node
5495
+ );
5496
+ }) })
5497
+ ] })
5498
+ ] })
5499
+ }
5500
+ );
5501
+ }
5502
+ function Legend() {
5503
+ return /* @__PURE__ */ jsxRuntime.jsx(
5504
+ "div",
5505
+ {
5506
+ className: "flex flex-wrap items-center gap-x-4 gap-y-2 text-xs text-muted-foreground",
5507
+ "data-testid": "graph-legend",
5508
+ children: Object.keys(BADGE_LABELS).map((kind) => /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-1.5", title: BADGE_DEFINITIONS[kind], children: [
5509
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: BADGE_VARIANTS[kind], children: BADGE_LABELS[kind] }),
5510
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "max-w-64", children: BADGE_DEFINITIONS[kind] })
5511
+ ] }, kind))
5512
+ }
5513
+ );
5514
+ }
5515
+ function trafficContradiction(node, traffic) {
5516
+ if (!traffic) return null;
5517
+ if (node.state === "on" && traffic.count === 0) {
5518
+ return `Aucun passage observ\xE9 sur ${TRAFFIC_WINDOW_DAYS} jours, alors que ce n\u0153ud est r\xE9put\xE9 atteignable.`;
5519
+ }
5520
+ if (node.state !== "on" && traffic.count > 0) {
5521
+ return `${traffic.count} passage(s) observ\xE9(s) sur ${TRAFFIC_WINDOW_DAYS} jours, alors que ce n\u0153ud est r\xE9put\xE9 injoignable \u2014 l\u2019analyse ou les r\xE9glages ont chang\xE9 depuis.`;
5522
+ }
5523
+ return null;
5524
+ }
5525
+ function TrafficPill({
5526
+ node,
5527
+ traffic
5528
+ }) {
5529
+ if (!traffic) {
5530
+ return /* @__PURE__ */ jsxRuntime.jsx(
5531
+ "span",
5532
+ {
5533
+ className: "text-xs text-muted-foreground",
5534
+ title: "Aucun enregistrement ne t\xE9moigne du passage par ce n\u0153ud \u2014 cette page pr\xE9f\xE8re ne rien afficher plut\xF4t qu\u2019un chiffre d\xE9duit.",
5535
+ children: "\u2014 trafic non mesur\xE9"
5536
+ }
5537
+ );
5538
+ }
5539
+ const contradiction = trafficContradiction(node, traffic);
5540
+ return /* @__PURE__ */ jsxRuntime.jsxs(
5541
+ "span",
5542
+ {
5543
+ className: uiSdk.cn(
5544
+ "text-xs",
5545
+ contradiction ? "font-medium text-status-blocked" : "text-muted-foreground"
5546
+ ),
5547
+ title: `${traffic.witness}, sur ${TRAFFIC_WINDOW_DAYS} jours.`,
5548
+ children: [
5549
+ traffic.count,
5550
+ " sur ",
5551
+ TRAFFIC_WINDOW_DAYS,
5552
+ " j",
5553
+ contradiction ? " \u26A0" : ""
5554
+ ]
5555
+ }
5556
+ );
5557
+ }
5558
+ function Connector({ into, isBreak }) {
5559
+ const dead = into.state !== "on";
5560
+ return /* @__PURE__ */ jsxRuntime.jsxs(
5561
+ "div",
5562
+ {
5563
+ className: "flex items-center gap-2 pl-[3px]",
5564
+ "data-testid": `graph-edge-${into.node}`,
5565
+ "data-edge-state": dead ? "dead" : "live",
5566
+ children: [
5567
+ /* @__PURE__ */ jsxRuntime.jsx(
5568
+ "span",
5569
+ {
5570
+ "aria-hidden": true,
5571
+ className: uiSdk.cn(
5572
+ "h-6 w-0 border-l-2",
5573
+ dead ? "border-dashed" : "border-solid",
5574
+ into.state === "on" ? "border-status-success/50" : into.cause === "root" ? "border-status-blocked/60" : "border-border"
5575
+ )
5576
+ }
5577
+ ),
5578
+ isBreak && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs font-medium text-status-blocked", children: [
5579
+ "\u26D4",
5580
+ " le parcours s",
5581
+ "\u2019",
5582
+ "arr\xEAte ici"
5583
+ ] })
5584
+ ]
5585
+ }
5586
+ );
5587
+ }
5588
+ function NodeRow({
5589
+ node,
5590
+ traffic,
5591
+ technical,
5592
+ globalNotes,
5593
+ onOpen
5594
+ }) {
5595
+ const kind = badgeKindOf(node);
5596
+ const exits = dedupeExits(node.exits);
5597
+ const contradiction = trafficContradiction(node, traffic);
5598
+ const headlineReason = node.reasons[0];
5599
+ const extraCount = Math.max(0, node.reasons.length - 1) + node.notes.length + globalNotes.length;
5600
+ return /* @__PURE__ */ jsxRuntime.jsxs(
5601
+ "div",
5602
+ {
5603
+ className: "flex items-start gap-3",
5083
5604
  "data-testid": "graph-node",
5084
5605
  "data-node": node.node,
5085
- className: uiSdk.cn("w-56 shrink-0", node.state !== "on" && "border-dashed opacity-90"),
5086
- children: /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.CardContent, { className: "space-y-2 p-3", "data-testid": `graph-node-${node.node}`, children: [
5087
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
5088
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium", children: NODE_LABELS[node.node] }),
5089
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: ACTIVATION_BADGE_VARIANT[node.state], children: ACTIVATION_LABELS[node.state] })
5090
- ] }),
5091
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs leading-snug text-muted-foreground", children: NODE_ROLE_LABELS[node.node] }),
5092
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-mono text-[10px] text-muted-foreground", children: node.node }),
5093
- node.model && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-muted-foreground", children: [
5094
- "Mod\xE8le : ",
5095
- /* @__PURE__ */ jsxRuntime.jsx("code", { className: "font-mono", children: node.model })
5096
- ] }),
5097
- node.exits.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "flex flex-wrap gap-1.5 border-t pt-2", children: node.exits.map((exit) => /* @__PURE__ */ jsxRuntime.jsx(
5098
- "li",
5606
+ "data-state": kind,
5607
+ children: [
5608
+ /* @__PURE__ */ jsxRuntime.jsx(
5609
+ "span",
5099
5610
  {
5100
- title: exit.condition,
5101
- className: "rounded-md border px-1.5 py-0.5 text-[11px] leading-tight text-muted-foreground",
5102
- children: outcomeLabel(exit.outcome)
5103
- },
5104
- exit.key
5105
- )) }),
5106
- node.reasons.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "space-y-1", children: node.reasons.map((r, i) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "text-xs text-muted-foreground", children: [
5107
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-medium text-foreground", children: [
5108
- REASON_KIND_LABELS[r.kind],
5109
- " \u2014 "
5110
- ] }),
5111
- r.message
5112
- ] }, i)) }),
5113
- node.notes.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "space-y-1 border-t pt-2", children: node.notes.map((note, i) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "text-xs text-muted-foreground", children: note }, i)) }),
5114
- section && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "border-t pt-2 text-xs", children: /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Link, { href: `/parametres/espaces/${appSlug}#${section.id}`, children: [
5115
- "Ouvrir \xAB ",
5116
- section.title,
5117
- " \xBB dans Param\xE8tres"
5118
- ] }) })
5119
- ] })
5611
+ "aria-hidden": true,
5612
+ className: uiSdk.cn(
5613
+ "mt-4 size-2 shrink-0 rounded-full",
5614
+ kind === "on" && "bg-status-success",
5615
+ kind === "off" && "bg-muted-foreground/50",
5616
+ kind === "root" && "bg-status-blocked",
5617
+ kind === "consequence" && "bg-status-pending"
5618
+ )
5619
+ }
5620
+ ),
5621
+ /* @__PURE__ */ jsxRuntime.jsx(
5622
+ uiSdk.Card,
5623
+ {
5624
+ className: uiSdk.cn(
5625
+ "w-full max-w-2xl",
5626
+ kind === "root" && "border-status-blocked/40",
5627
+ (kind === "off" || kind === "consequence") && "border-dashed opacity-80"
5628
+ ),
5629
+ children: /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.CardContent, { className: "space-y-2 p-3", "data-testid": `graph-node-${node.node}`, children: [
5630
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-x-2 gap-y-1", children: [
5631
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium", children: NODE_LABELS[node.node] }),
5632
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: BADGE_VARIANTS[kind], title: BADGE_DEFINITIONS[kind], children: BADGE_LABELS[kind] }),
5633
+ node.promptWarning && /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Badge, { variant: "warning", title: "Voir l\u2019avertissement au-dessus du graphe.", children: [
5634
+ "\u26A0",
5635
+ " prompt non d\xE9clar\xE9"
5636
+ ] }),
5637
+ technical && /* @__PURE__ */ jsxRuntime.jsx("code", { className: "font-mono text-[10px] text-muted-foreground", children: node.node }),
5638
+ technical && node.model && /* @__PURE__ */ jsxRuntime.jsx("code", { className: "font-mono text-[10px] text-muted-foreground", children: node.model }),
5639
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ml-auto flex items-center gap-3", children: [
5640
+ /* @__PURE__ */ jsxRuntime.jsx(TrafficPill, { node, traffic }),
5641
+ /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Button, { variant: "ghost", size: "sm", onClick: onOpen, children: [
5642
+ "D\xE9tails",
5643
+ extraCount > 0 ? ` (${extraCount})` : ""
5644
+ ] })
5645
+ ] })
5646
+ ] }),
5647
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs leading-snug text-muted-foreground", children: NODE_ROLE_LABELS[node.node] }),
5648
+ headlineReason && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs", children: [
5649
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-medium", children: [
5650
+ REASON_KIND_LABELS[headlineReason.kind],
5651
+ " \u2014 "
5652
+ ] }),
5653
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: headlineReason.message }),
5654
+ technical && headlineReason.detail && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-1 font-mono text-[10px] text-muted-foreground", children: headlineReason.detail })
5655
+ ] }),
5656
+ contradiction && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs font-medium text-status-blocked", children: contradiction }),
5657
+ exits.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-1.5 border-t pt-2", children: [
5658
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] text-muted-foreground", children: "Issues possibles :" }),
5659
+ exits.map((exit) => /* @__PURE__ */ jsxRuntime.jsx(
5660
+ "span",
5661
+ {
5662
+ title: exit.conditions.join(" \xB7 "),
5663
+ className: uiSdk.cn(
5664
+ "rounded-md border px-1.5 py-0.5 text-[11px] leading-tight",
5665
+ EXIT_TONE_CLASSES[exit.tone]
5666
+ ),
5667
+ children: outcomeLabel(exit.outcome)
5668
+ },
5669
+ exit.outcome
5670
+ ))
5671
+ ] })
5672
+ ] })
5673
+ }
5674
+ )
5675
+ ]
5676
+ }
5677
+ );
5678
+ }
5679
+ function NodeDetailPanel({
5680
+ node,
5681
+ traffic,
5682
+ technical,
5683
+ appSlug,
5684
+ globalNotes,
5685
+ onClose
5686
+ }) {
5687
+ const href = node ? settingsHref(appSlug, node.node) : null;
5688
+ return /* @__PURE__ */ jsxRuntime.jsx(
5689
+ uiSdk.SidePanel,
5690
+ {
5691
+ open: node !== null,
5692
+ onClose,
5693
+ title: node ? NODE_LABELS[node.node] : "",
5694
+ description: node ? NODE_ROLE_LABELS[node.node] : "",
5695
+ children: node && /* @__PURE__ */ jsxRuntime.jsxs(
5696
+ "div",
5697
+ {
5698
+ className: "min-h-0 flex-1 space-y-4 overflow-y-auto text-sm",
5699
+ "data-testid": "graph-node-detail",
5700
+ children: [
5701
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
5702
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: BADGE_VARIANTS[badgeKindOf(node)], children: BADGE_LABELS[badgeKindOf(node)] }),
5703
+ technical && /* @__PURE__ */ jsxRuntime.jsx("code", { className: "font-mono text-xs text-muted-foreground", children: node.node })
5704
+ ] }),
5705
+ node.model && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-muted-foreground", children: [
5706
+ "Mod\xE8le : ",
5707
+ /* @__PURE__ */ jsxRuntime.jsx("code", { className: "font-mono", children: node.model })
5708
+ ] }),
5709
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: traffic ? `${traffic.count} ${traffic.witness} sur ${TRAFFIC_WINDOW_DAYS} jours.` : "Aucun enregistrement ne t\xE9moigne du passage par ce n\u0153ud : cette page n\u2019en affiche donc aucun chiffre." }),
5710
+ node.reasons.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "space-y-2", children: [
5711
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: "Pourquoi" }),
5712
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "space-y-2", children: node.reasons.map((r, i) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "text-xs", children: [
5713
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-medium", children: [
5714
+ REASON_KIND_LABELS[r.kind],
5715
+ " \u2014 "
5716
+ ] }),
5717
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: r.message }),
5718
+ technical && r.detail && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-0.5 font-mono text-[10px] text-muted-foreground", children: r.detail })
5719
+ ] }, i)) })
5720
+ ] }),
5721
+ (node.notes.length > 0 || globalNotes.length > 0) && /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "space-y-2", children: [
5722
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: "\xC0 savoir" }),
5723
+ /* @__PURE__ */ jsxRuntime.jsxs("ul", { className: "space-y-2", children: [
5724
+ node.notes.map((note2, i) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "text-xs text-muted-foreground", children: [
5725
+ note2.message,
5726
+ technical && note2.detail && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-0.5 font-mono text-[10px]", children: note2.detail })
5727
+ ] }, `note-${i}`)),
5728
+ globalNotes.map((note2) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "text-xs text-muted-foreground", children: [
5729
+ note2.message,
5730
+ technical && note2.detail && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-0.5 font-mono text-[10px]", children: note2.detail })
5731
+ ] }, note2.id))
5732
+ ] })
5733
+ ] }),
5734
+ node.exits.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "space-y-2", children: [
5735
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: "Issues possibles" }),
5736
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "space-y-1", children: node.exits.map((exit) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "flex items-baseline gap-2 text-xs", children: [
5737
+ /* @__PURE__ */ jsxRuntime.jsx(
5738
+ "span",
5739
+ {
5740
+ className: uiSdk.cn(
5741
+ "rounded-md border px-1.5 py-0.5 leading-tight",
5742
+ EXIT_TONE_CLASSES[exit.tone]
5743
+ ),
5744
+ children: outcomeLabel(exit.outcome)
5745
+ }
5746
+ ),
5747
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: exit.condition })
5748
+ ] }, exit.key)) })
5749
+ ] }),
5750
+ href && /* @__PURE__ */ jsxRuntime.jsx(
5751
+ uiSdk.Link,
5752
+ {
5753
+ href,
5754
+ className: uiSdk.cn(uiSdk.buttonVariants({ variant: "default", size: "sm" }), "no-underline"),
5755
+ children: "Ouvrir le r\xE9glage"
5756
+ }
5757
+ )
5758
+ ]
5759
+ }
5760
+ )
5120
5761
  }
5121
5762
  );
5122
5763
  }
5123
5764
  function GraphCanvasPage() {
5124
5765
  const { appSlug } = uiSdk.useAppContext();
5125
- const { settings, isLoading: settingsLoading, error: settingsError } = uiSdk.useAppSettings();
5766
+ const { value: viewParam, setValue: setViewParam } = useQueryParam("vue");
5767
+ const technical = viewParam === "technique";
5768
+ const [openNode, setOpenNode] = react.useState(null);
5769
+ const {
5770
+ settings,
5771
+ isLoading: settingsLoading,
5772
+ error: settingsError
5773
+ } = uiSdk.useAppSettings();
5126
5774
  const {
5127
5775
  rows: categories,
5128
5776
  isLoading: categoriesLoading,
5129
5777
  error: categoriesError
5130
5778
  } = useRecordList("category", { limit: CATEGORY_PAGE_SIZE }, toCategory);
5131
- const hasCategoryWithAutoReply = react.useMemo(() => categories.some((c) => c.autoReplyEnabled), [categories]);
5779
+ const traffic = useGraphTraffic(TRAFFIC_WINDOW_DAYS);
5780
+ const hasCategoryWithAutoReply = react.useMemo(
5781
+ () => categories.some((c) => c.autoReplyEnabled),
5782
+ [categories]
5783
+ );
5132
5784
  const categoriesMayBeTruncated = categories.length >= CATEGORY_PAGE_SIZE;
5133
5785
  const result = react.useMemo(
5134
5786
  () => settings ? computeGraphReachability(settings, hasCategoryWithAutoReply) : null,
@@ -5136,41 +5788,134 @@ function GraphCanvasPage() {
5136
5788
  );
5137
5789
  const isLoading = settingsLoading || categoriesLoading;
5138
5790
  const isUnavailable = !isLoading && (settingsError !== void 0 || categoriesError !== void 0 || !result);
5791
+ const verdict = react.useMemo(() => result ? computeVerdict(result) : null, [result]);
5792
+ const selected = result?.nodes.find((node) => node.node === openNode) ?? null;
5793
+ const notesFor = (node) => result ? result.globalNotes.filter((note2) => note2.nodes.includes(node)) : [];
5794
+ const breakNode = result?.nodes.find((node) => node.state === "unreachable" && node.cause === "root")?.node ?? null;
5795
+ const rail = react.useMemo(() => {
5796
+ if (!result) return null;
5797
+ const rows = result.nodes.map((node, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
5798
+ i > 0 && /* @__PURE__ */ jsxRuntime.jsx(Connector, { into: node, isBreak: node.node === breakNode }),
5799
+ /* @__PURE__ */ jsxRuntime.jsx(
5800
+ NodeRow,
5801
+ {
5802
+ node,
5803
+ traffic: traffic.byNode[node.node],
5804
+ technical,
5805
+ globalNotes: result.globalNotes.filter((note2) => note2.nodes.includes(node.node)),
5806
+ onOpen: () => setOpenNode(node.node)
5807
+ }
5808
+ )
5809
+ ] }, node.node));
5810
+ const from = result.nodes.findIndex((node) => node.node === "evaluate");
5811
+ const to = result.nodes.findIndex((node) => node.node === "revise");
5812
+ if (from < 0 || to <= from) return rows;
5813
+ return [
5814
+ ...rows.slice(0, from),
5815
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
5816
+ /* @__PURE__ */ jsxRuntime.jsx(
5817
+ "div",
5818
+ {
5819
+ "aria-hidden": true,
5820
+ "data-testid": "graph-back-edge",
5821
+ className: "pointer-events-none absolute inset-y-6 -left-9 w-6 rounded-l-md border-y-2 border-l-2 border-dashed border-muted-foreground/40"
5822
+ }
5823
+ ),
5824
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pointer-events-none absolute -left-9 top-1/2 w-6 -translate-y-1/2 text-center text-[10px] leading-none text-muted-foreground", children: "\u21BA" }),
5825
+ rows.slice(from, to + 1)
5826
+ ] }, "back-edge"),
5827
+ ...rows.slice(to + 1)
5828
+ ];
5829
+ }, [result, breakNode, traffic.byNode, technical]);
5139
5830
  return /* @__PURE__ */ jsxRuntime.jsxs(PageShell, { children: [
5140
- /* @__PURE__ */ jsxRuntime.jsx(PageHeader, { title: "Graphe", description: "Le parcours d'un ticket \xE0 travers les 9 n\u0153uds du pipeline, et ce qui, dans les r\xE9glages actuels, rend chaque n\u0153ud atteignable ou non." }),
5831
+ /* @__PURE__ */ jsxRuntime.jsx(
5832
+ PageHeader,
5833
+ {
5834
+ title: "Graphe",
5835
+ description: "Le parcours d'un ticket \xE0 travers les 9 n\u0153uds du pipeline, et ce qui, dans les r\xE9glages actuels, rend chaque n\u0153ud atteignable ou non.",
5836
+ actions: /* @__PURE__ */ jsxRuntime.jsxs(
5837
+ "div",
5838
+ {
5839
+ className: "flex items-center rounded-md border p-0.5",
5840
+ role: "group",
5841
+ "aria-label": "Registre d'affichage",
5842
+ children: [
5843
+ /* @__PURE__ */ jsxRuntime.jsx(
5844
+ uiSdk.Button,
5845
+ {
5846
+ variant: technical ? "ghost" : "secondary",
5847
+ size: "sm",
5848
+ "aria-pressed": !technical,
5849
+ onClick: () => setViewParam(null),
5850
+ children: "Op\xE9rateur"
5851
+ }
5852
+ ),
5853
+ /* @__PURE__ */ jsxRuntime.jsx(
5854
+ uiSdk.Button,
5855
+ {
5856
+ variant: technical ? "secondary" : "ghost",
5857
+ size: "sm",
5858
+ "aria-pressed": technical,
5859
+ onClick: () => setViewParam("technique"),
5860
+ children: "Technique"
5861
+ }
5862
+ )
5863
+ ]
5864
+ }
5865
+ )
5866
+ }
5867
+ ),
5141
5868
  isLoading ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center py-12", children: [
5142
5869
  /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Spinner, {}),
5143
5870
  " ",
5144
5871
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-2 text-sm text-muted-foreground", children: "Chargement\u2026" })
5145
5872
  ] }) : isUnavailable ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive", children: "Impossible de calculer le graphe : les r\xE9glages ou les cat\xE9gories n'ont pas pu \xEAtre charg\xE9s." }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5146
- result.blocked && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-md border border-status-warning/40 bg-status-warning/10 p-3 text-sm text-status-warning", children: [
5147
- "Le graphe ne peut d\xE9marrer avec les r\xE9glages actuels : ",
5148
- result.nodes[0].reasons[0]?.message ?? ""
5149
- ] }),
5873
+ /* @__PURE__ */ jsxRuntime.jsx(VerdictBanner, { verdict, appSlug }),
5874
+ result.globalNotes.map((note2) => /* @__PURE__ */ jsxRuntime.jsxs(
5875
+ "div",
5876
+ {
5877
+ "data-testid": `graph-global-note-${note2.id}`,
5878
+ className: "rounded-md border border-status-warning/40 bg-status-warning/10 p-3 text-sm text-status-warning",
5879
+ children: [
5880
+ /* @__PURE__ */ jsxRuntime.jsx("p", { children: note2.message }),
5881
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "mt-1 text-xs", children: [
5882
+ "N\u0153uds concern\xE9s (",
5883
+ note2.nodes.length,
5884
+ ") :",
5885
+ " ",
5886
+ note2.nodes.map((n) => NODE_LABELS[n]).join(", "),
5887
+ "."
5888
+ ] }),
5889
+ technical && note2.detail && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 font-mono text-[10px]", children: note2.detail })
5890
+ ]
5891
+ },
5892
+ note2.id
5893
+ )),
5150
5894
  !hasCategoryWithAutoReply && categoriesMayBeTruncated && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-muted-foreground", children: [
5151
5895
  "La lecture des cat\xE9gories est born\xE9e aux ",
5152
5896
  CATEGORY_PAGE_SIZE,
5153
5897
  " premi\xE8res \u2014 au-del\xE0, l'absence de cat\xE9gorie avec \xAB Envoi auto \xBB activ\xE9 ci-dessous peut \xEAtre un simple effet de fen\xEAtre, pas un fait."
5154
5898
  ] }),
5155
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap items-center gap-2", children: result.nodes.map((node, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
5156
- /* @__PURE__ */ jsxRuntime.jsx(NodeCard, { node, appSlug }),
5157
- i < result.nodes.length - 1 && /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": true, className: "text-muted-foreground", children: "\u2192" })
5158
- ] }, node.node)) }),
5159
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: "\u21BA \xAB R\xE9vision \xBB rejoue \xAB \xC9valuation \xBB une fois avant de continuer (au plus une passe par ticket, \xA73.3) \u2014 la fl\xE8che lin\xE9aire ci-dessus ne montre pas ce retour en arri\xE8re pour garder la s\xE9quence lisible." }),
5160
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-4 text-xs text-muted-foreground", children: [
5161
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-1.5", children: [
5162
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: "success", children: "Actif" }),
5163
- " le n\u0153ud peut \xEAtre atteint par au moins un ticket avec les r\xE9glages actuels."
5164
- ] }),
5165
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-1.5", children: [
5166
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: "neutral", children: "D\xE9sactiv\xE9" }),
5167
- " l'op\xE9rateur a coup\xE9 ce n\u0153ud lui-m\xEAme \u2014 un choix, pas un incident."
5168
- ] }),
5169
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-1.5", children: [
5170
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: "warning", children: "Inatteignable" }),
5171
- " aucun ticket ne peut atteindre ce n\u0153ud aujourd'hui \u2014 voir les raisons sur sa carte."
5172
- ] })
5173
- ] })
5899
+ /* @__PURE__ */ jsxRuntime.jsx(Legend, {}),
5900
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: traffic.unavailable ? "Trafic observ\xE9 indisponible : le verdict ci-dessous reste calcul\xE9 sur les r\xE9glages seuls." : `Chiffres observ\xE9s sur les ${TRAFFIC_WINDOW_DAYS} derniers jours \u2014 seuls les n\u0153uds dont un enregistrement t\xE9moigne du passage en portent un.` }),
5901
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-0 pl-10", children: rail }),
5902
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-muted-foreground", children: [
5903
+ "\u21BA",
5904
+ " \xAB R\xE9vision \xBB rejoue \xAB \xC9valuation \xBB \u2014 au plus une passe par ticket",
5905
+ technical ? " (\xA73.3)" : "",
5906
+ "."
5907
+ ] }),
5908
+ /* @__PURE__ */ jsxRuntime.jsx(
5909
+ NodeDetailPanel,
5910
+ {
5911
+ node: selected,
5912
+ traffic: selected ? traffic.byNode[selected.node] : void 0,
5913
+ technical,
5914
+ appSlug,
5915
+ globalNotes: selected ? notesFor(selected.node) : [],
5916
+ onClose: () => setOpenNode(null)
5917
+ }
5918
+ )
5174
5919
  ] })
5175
5920
  ] });
5176
5921
  }
@@ -5886,31 +6631,6 @@ function TestPage() {
5886
6631
  !canRun ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Acc\xE8s en lecture seule \u2014 lancer un test n\xE9cessite le r\xF4le EDITOR (chaque ex\xE9cution consomme du budget LLM)." }) : /* @__PURE__ */ jsxRuntime.jsx(TestControls, {})
5887
6632
  ] });
5888
6633
  }
5889
- function readParam(name) {
5890
- if (typeof window === "undefined") return null;
5891
- return new URLSearchParams(window.location.search).get(name);
5892
- }
5893
- function useQueryParam(name) {
5894
- const [value, setState] = react.useState(() => readParam(name));
5895
- react.useEffect(() => {
5896
- const sync = () => setState(readParam(name));
5897
- sync();
5898
- window.addEventListener("popstate", sync);
5899
- return () => window.removeEventListener("popstate", sync);
5900
- }, [name]);
5901
- const setValue = react.useCallback(
5902
- (next) => {
5903
- const params = new URLSearchParams(window.location.search);
5904
- if (next === null) params.delete(name);
5905
- else params.set(name, next);
5906
- const query = params.toString();
5907
- window.history.pushState({}, "", `${window.location.pathname}${query ? `?${query}` : ""}`);
5908
- setState(next);
5909
- },
5910
- [name]
5911
- );
5912
- return { value, setValue };
5913
- }
5914
6634
  function ExperimentStatusBadge({ experiment }) {
5915
6635
  if (experiment.status === "done" && experiment.succeeded) {
5916
6636
  return /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: "success", children: "Termin\xE9" });