@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/{chunk-AFOXQT22.js → chunk-SFOPXCD4.js} +5 -3
- package/dist/chunk-SFOPXCD4.js.map +1 -0
- package/dist/index.cjs +38 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +39 -4
- package/dist/index.js.map +1 -1
- package/dist/ui/index.cjs +859 -139
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +860 -141
- package/dist/ui/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-AFOXQT22.js.map +0 -1
package/dist/ui/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { GENERATED_RESPONSE_STATUSES, EVALUATION_VERDICTS, WHATSAPP_MODES, validateSettings, AGENT_GUARDRAILS, toCategory, toTriageDecision, toAgent, toGeneratedResponse, isGeneratedResponseStatus, toCategoryGroup, toResponseComparison, toDiffAnalysis, NODE_NAMES, settingsToProfile, hasNoDraftNode, guardrailBucket, DEFAULT_LLM_PROVIDER, computeWordDiff, isSendableVerdict, DEFAULT_MAX_TOOL_CALLS, DEFAULT_MIN_CONFIDENCE, DEFAULT_ESCALATION_ENABLED } from '../chunk-
|
|
1
|
+
import { GENERATED_RESPONSE_STATUSES, EVALUATION_VERDICTS, WHATSAPP_MODES, validateSettings, AGENT_GUARDRAILS, toCategory, toTriageDecision, toAgent, toGeneratedResponse, isGeneratedResponseStatus, toCategoryGroup, toResponseComparison, toDiffAnalysis, NODE_NAMES, settingsToProfile, hasNoDraftNode, guardrailBucket, DEFAULT_LLM_PROVIDER, computeWordDiff, isSendableVerdict, DEFAULT_MAX_TOOL_CALLS, DEFAULT_MIN_CONFIDENCE, DEFAULT_ESCALATION_ENABLED } from '../chunk-SFOPXCD4.js';
|
|
2
2
|
import { useState, useMemo, useRef, useEffect, useCallback, useId } from 'react';
|
|
3
|
-
import { useAppContext, useAppSettings, Card, CardContent, Button, Link, KpiCard, BarChart, StackedBarChart, DataTable, Select, useAppApi, useToast, Badge, FunnelChart, Spinner, LineChart, Switch, Input, Checkbox, Textarea, cn, SidePanel, CopyButton, Modal, Tooltip, CardHeader, CardTitle, AppInvokeError, Table, TableHeader, TableRow, TableHead, TableBody, TableCell, downloadBlob } from '@apotech-os/ui-sdk';
|
|
3
|
+
import { useAppContext, useAppSettings, Card, CardContent, Button, Link, KpiCard, BarChart, StackedBarChart, DataTable, Select, useAppApi, useToast, Badge, FunnelChart, Spinner, LineChart, Switch, Input, Checkbox, Textarea, cn, SidePanel, CopyButton, Modal, Tooltip, buttonVariants, CardHeader, CardTitle, AppInvokeError, Table, TableHeader, TableRow, TableHead, TableBody, TableCell, downloadBlob } from '@apotech-os/ui-sdk';
|
|
4
4
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
|
|
6
6
|
function useRecordList(objectKey, query, mapper) {
|
|
@@ -365,6 +365,29 @@ function DashboardPage() {
|
|
|
365
365
|
] })
|
|
366
366
|
] });
|
|
367
367
|
}
|
|
368
|
+
function isHttpUrl(url) {
|
|
369
|
+
try {
|
|
370
|
+
const { protocol } = new URL(url);
|
|
371
|
+
return protocol === "http:" || protocol === "https:";
|
|
372
|
+
} catch {
|
|
373
|
+
return false;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
function TicketLink({ ticketId, url, label }) {
|
|
377
|
+
if (!url || !isHttpUrl(url)) return /* @__PURE__ */ jsx(Fragment, { children: label ?? ticketId });
|
|
378
|
+
return /* @__PURE__ */ jsx(
|
|
379
|
+
Link,
|
|
380
|
+
{
|
|
381
|
+
href: url,
|
|
382
|
+
target: "_blank",
|
|
383
|
+
rel: "noopener noreferrer",
|
|
384
|
+
className: "font-medium",
|
|
385
|
+
title: "Ouvrir le ticket dans Gorgias",
|
|
386
|
+
onClick: (event) => event.stopPropagation(),
|
|
387
|
+
children: label ?? ticketId
|
|
388
|
+
}
|
|
389
|
+
);
|
|
390
|
+
}
|
|
368
391
|
var UNCONFIGURED = { baseUrl: null, projectId: null };
|
|
369
392
|
function useLangfuseConfig() {
|
|
370
393
|
const { appSlug } = useAppContext();
|
|
@@ -566,6 +589,7 @@ function DetailPanel({
|
|
|
566
589
|
onClose
|
|
567
590
|
}) {
|
|
568
591
|
return /* @__PURE__ */ jsx(SidePanel, { open: true, onClose, title: `Ticket ${decision.ticketId}`, description: categoryName, children: /* @__PURE__ */ jsxs("div", { className: "space-y-4 text-sm", children: [
|
|
592
|
+
decision.ticketUrl && /* @__PURE__ */ jsx("p", { children: /* @__PURE__ */ jsx(TicketLink, { ticketId: decision.ticketId, url: decision.ticketUrl, label: "Ouvrir le ticket dans Gorgias" }) }),
|
|
569
593
|
decision.status === "error" && /* @__PURE__ */ jsxs("div", { className: "rounded-md bg-destructive/10 p-3 text-destructive", children: [
|
|
570
594
|
/* @__PURE__ */ jsx("p", { className: "text-xs font-semibold uppercase tracking-wider", children: TRIAGE_DECISION_STATUS_LABELS.error }),
|
|
571
595
|
decision.error && /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs", children: decision.error })
|
|
@@ -718,7 +742,7 @@ function TicketsPage() {
|
|
|
718
742
|
return withOutcome.filter((r) => r.job && responseOutcome(r.job).variant === outcomeFilter);
|
|
719
743
|
}, [decisions, jobByDecisionId, outcomeFilter]);
|
|
720
744
|
const columns = [
|
|
721
|
-
{ key: "ticketId", header: "Ticket", cell: ({ decision }) => decision.ticketId },
|
|
745
|
+
{ key: "ticketId", header: "Ticket", cell: ({ decision }) => /* @__PURE__ */ jsx(TicketLink, { ticketId: decision.ticketId, url: decision.ticketUrl }) },
|
|
722
746
|
{
|
|
723
747
|
key: "category",
|
|
724
748
|
header: "Cat\xE9gorie",
|
|
@@ -2840,6 +2864,7 @@ function StatusBadge({ status, error }) {
|
|
|
2840
2864
|
}
|
|
2841
2865
|
function DetailPanel3({ row, categoryName, onClose }) {
|
|
2842
2866
|
return /* @__PURE__ */ jsx(SidePanel, { open: true, onClose, title: `Ticket ${row.ticketId}`, description: categoryName, children: /* @__PURE__ */ jsxs("div", { className: "space-y-4 text-sm", children: [
|
|
2867
|
+
row.ticketUrl && /* @__PURE__ */ jsx("p", { children: /* @__PURE__ */ jsx(TicketLink, { ticketId: row.ticketId, url: row.ticketUrl, label: "Ouvrir le ticket dans Gorgias" }) }),
|
|
2843
2868
|
row.reasoning && /* @__PURE__ */ jsxs("div", { children: [
|
|
2844
2869
|
/* @__PURE__ */ jsx("p", { className: "mb-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Raison du triage" }),
|
|
2845
2870
|
/* @__PURE__ */ jsx("p", { children: row.reasoning })
|
|
@@ -2897,7 +2922,7 @@ function EscalationsPage() {
|
|
|
2897
2922
|
const { rows: categories } = useRecordList("category", { limit: 500 }, toCategory);
|
|
2898
2923
|
const categoryNames = useMemo(() => toNameMap(categories), [categories]);
|
|
2899
2924
|
const columns = [
|
|
2900
|
-
{ key: "ticketId", header: "Ticket", cell: (row) => row.ticketId },
|
|
2925
|
+
{ key: "ticketId", header: "Ticket", cell: (row) => /* @__PURE__ */ jsx(TicketLink, { ticketId: row.ticketId, url: row.ticketUrl }) },
|
|
2901
2926
|
{ key: "category", header: "Cat\xE9gorie", cell: (row) => row.categoryId && categoryNames.get(row.categoryId) || "\u2014" },
|
|
2902
2927
|
{ key: "tag", header: "Tag", cell: (row) => row.tag ? /* @__PURE__ */ jsx("code", { className: "text-xs", children: row.tag }) : "\u2014" },
|
|
2903
2928
|
{
|
|
@@ -4345,16 +4370,59 @@ function SettingsPage() {
|
|
|
4345
4370
|
] })
|
|
4346
4371
|
);
|
|
4347
4372
|
}
|
|
4373
|
+
function readParam(name) {
|
|
4374
|
+
if (typeof window === "undefined") return null;
|
|
4375
|
+
return new URLSearchParams(window.location.search).get(name);
|
|
4376
|
+
}
|
|
4377
|
+
function useQueryParam(name) {
|
|
4378
|
+
const [value, setState] = useState(() => readParam(name));
|
|
4379
|
+
useEffect(() => {
|
|
4380
|
+
const sync = () => setState(readParam(name));
|
|
4381
|
+
sync();
|
|
4382
|
+
window.addEventListener("popstate", sync);
|
|
4383
|
+
return () => window.removeEventListener("popstate", sync);
|
|
4384
|
+
}, [name]);
|
|
4385
|
+
const setValue = useCallback(
|
|
4386
|
+
(next) => {
|
|
4387
|
+
const params = new URLSearchParams(window.location.search);
|
|
4388
|
+
if (next === null) params.delete(name);
|
|
4389
|
+
else params.set(name, next);
|
|
4390
|
+
const query = params.toString();
|
|
4391
|
+
window.history.pushState({}, "", `${window.location.pathname}${query ? `?${query}` : ""}`);
|
|
4392
|
+
setState(next);
|
|
4393
|
+
},
|
|
4394
|
+
[name]
|
|
4395
|
+
);
|
|
4396
|
+
return { value, setValue };
|
|
4397
|
+
}
|
|
4348
4398
|
|
|
4349
4399
|
// src/ui/graph-canvas/reachability.ts
|
|
4400
|
+
var EXIT_TONES = {
|
|
4401
|
+
sent: "delivered",
|
|
4402
|
+
failed: "failure",
|
|
4403
|
+
ready: "held",
|
|
4404
|
+
needs_human: "held",
|
|
4405
|
+
guardrail_hold: "held",
|
|
4406
|
+
awaiting_approval: "held",
|
|
4407
|
+
escalated: "held",
|
|
4408
|
+
triaged_only: "held",
|
|
4409
|
+
no_reply_needed: "held"
|
|
4410
|
+
};
|
|
4350
4411
|
function stubPrompts() {
|
|
4351
4412
|
const ref = { name: "", label: "production" };
|
|
4352
4413
|
return { triage: ref, escalate: ref, draft: ref, evaluate: ref };
|
|
4353
4414
|
}
|
|
4354
4415
|
var PROMPT_403_NODES = /* @__PURE__ */ new Set(["triage", "escalate", "draft", "evaluate", "revise"]);
|
|
4355
|
-
var PROMPT_403_NOTE =
|
|
4356
|
-
|
|
4357
|
-
|
|
4416
|
+
var PROMPT_403_NOTE = {
|
|
4417
|
+
id: "prompt-403",
|
|
4418
|
+
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.",
|
|
4419
|
+
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)."
|
|
4420
|
+
};
|
|
4421
|
+
function reason(kind, message, detail) {
|
|
4422
|
+
return detail === void 0 ? { kind, message } : { kind, message, detail };
|
|
4423
|
+
}
|
|
4424
|
+
function note(message, detail) {
|
|
4425
|
+
return detail === void 0 ? { message } : { message, detail };
|
|
4358
4426
|
}
|
|
4359
4427
|
function nodeModelOf(node, profile) {
|
|
4360
4428
|
switch (node) {
|
|
@@ -4370,17 +4438,35 @@ function nodeModelOf(node, profile) {
|
|
|
4370
4438
|
return null;
|
|
4371
4439
|
}
|
|
4372
4440
|
}
|
|
4373
|
-
var READY_EXIT = {
|
|
4441
|
+
var READY_EXIT = {
|
|
4442
|
+
key: "evaluate-ready",
|
|
4443
|
+
condition: "envoi auto non \xE9ligible",
|
|
4444
|
+
outcome: "ready"
|
|
4445
|
+
};
|
|
4374
4446
|
var NODE_EXITS = {
|
|
4375
|
-
fetchContext: [
|
|
4447
|
+
fetchContext: [
|
|
4448
|
+
{ key: "fetchContext-failed", condition: "lecture impossible", outcome: "failed" }
|
|
4449
|
+
],
|
|
4376
4450
|
triage: [
|
|
4377
4451
|
{ key: "triage-fallback", condition: "classification de repli", outcome: "triaged_only" },
|
|
4378
|
-
{
|
|
4379
|
-
|
|
4452
|
+
{
|
|
4453
|
+
key: "triage-closed",
|
|
4454
|
+
condition: "le dernier message client cl\xF4t la conversation",
|
|
4455
|
+
outcome: "no_reply_needed"
|
|
4456
|
+
},
|
|
4457
|
+
{
|
|
4458
|
+
key: "triage-whatsapp-gate",
|
|
4459
|
+
condition: "r\xE8gle de canal WhatsApp (STOP ou pas notre tour)",
|
|
4460
|
+
outcome: "guardrail_hold"
|
|
4461
|
+
}
|
|
4380
4462
|
],
|
|
4381
4463
|
escalate: [
|
|
4382
4464
|
{ key: "escalate-escalated", condition: "escalade demand\xE9e", outcome: "escalated" },
|
|
4383
|
-
{
|
|
4465
|
+
{
|
|
4466
|
+
key: "escalate-no-draft",
|
|
4467
|
+
condition: "profil sans n\u0153ud de r\xE9daction",
|
|
4468
|
+
outcome: "triaged_only"
|
|
4469
|
+
}
|
|
4384
4470
|
],
|
|
4385
4471
|
evaluate: [
|
|
4386
4472
|
{
|
|
@@ -4390,8 +4476,16 @@ var NODE_EXITS = {
|
|
|
4390
4476
|
},
|
|
4391
4477
|
READY_EXIT
|
|
4392
4478
|
],
|
|
4393
|
-
guardrails: [
|
|
4394
|
-
|
|
4479
|
+
guardrails: [
|
|
4480
|
+
{ key: "guardrails-content", condition: "garde-fou de contenu", outcome: "guardrail_hold" }
|
|
4481
|
+
],
|
|
4482
|
+
authorize: [
|
|
4483
|
+
{
|
|
4484
|
+
key: "authorize-awaiting",
|
|
4485
|
+
condition: "une action n'est pas \xAB auto \xBB",
|
|
4486
|
+
outcome: "awaiting_approval"
|
|
4487
|
+
}
|
|
4488
|
+
],
|
|
4395
4489
|
act: [
|
|
4396
4490
|
{ key: "act-collision", condition: "contr\xF4le anti-collision", outcome: "guardrail_hold" },
|
|
4397
4491
|
{ key: "act-sent-email", condition: "r\xE9ponse email", outcome: "sent" },
|
|
@@ -4400,10 +4494,15 @@ var NODE_EXITS = {
|
|
|
4400
4494
|
};
|
|
4401
4495
|
function exitsFor(node, evaluateConfigured) {
|
|
4402
4496
|
const raw = NODE_EXITS[node] ?? [];
|
|
4403
|
-
|
|
4497
|
+
const withTone = (exits) => exits.map((exit) => ({ ...exit, tone: EXIT_TONES[exit.outcome] }));
|
|
4498
|
+
if (evaluateConfigured) return withTone(raw);
|
|
4404
4499
|
if (node === "evaluate") return [];
|
|
4405
|
-
if (node === "draft") return [READY_EXIT];
|
|
4406
|
-
return raw;
|
|
4500
|
+
if (node === "draft") return withTone([READY_EXIT]);
|
|
4501
|
+
return withTone(raw);
|
|
4502
|
+
}
|
|
4503
|
+
function deriveCause(state, reasons) {
|
|
4504
|
+
if (state === "on") return null;
|
|
4505
|
+
return reasons.some((r) => r.kind !== "upstream-disabled") ? "root" : "consequence";
|
|
4407
4506
|
}
|
|
4408
4507
|
function deriveState(upstreamOk, blockingReasons, offReasons) {
|
|
4409
4508
|
if (!upstreamOk) return "unreachable";
|
|
@@ -4421,11 +4520,17 @@ function computeGraphReachability(rawSettings, hasCategoryWithAutoReply) {
|
|
|
4421
4520
|
nodes: NODE_NAMES.map((node) => ({
|
|
4422
4521
|
node,
|
|
4423
4522
|
state: "unreachable",
|
|
4424
|
-
|
|
4523
|
+
// Every node reports the SAME single root cause here — none of them
|
|
4524
|
+
// is "blocked by the one before", they are all blocked by the same
|
|
4525
|
+
// absent setting, so none is a mere consequence of another.
|
|
4526
|
+
cause: "root",
|
|
4527
|
+
reasons: [reason("missing-setting", message, "validateSettings: nodes.triage est \xE0 null.")],
|
|
4425
4528
|
notes: [],
|
|
4426
4529
|
model: null,
|
|
4427
|
-
exits: []
|
|
4428
|
-
|
|
4530
|
+
exits: [],
|
|
4531
|
+
promptWarning: false
|
|
4532
|
+
})),
|
|
4533
|
+
globalNotes: []
|
|
4429
4534
|
};
|
|
4430
4535
|
}
|
|
4431
4536
|
const settings = rawSettings;
|
|
@@ -4433,20 +4538,23 @@ function computeGraphReachability(rawSettings, hasCategoryWithAutoReply) {
|
|
|
4433
4538
|
const evaluateConfigured = profile.nodes.evaluate !== null;
|
|
4434
4539
|
const byNode = /* @__PURE__ */ new Map();
|
|
4435
4540
|
function set(node, state, reasons, notes = []) {
|
|
4436
|
-
const promptNote = state === "on" && PROMPT_403_NODES.has(node) ? [PROMPT_403_NOTE] : [];
|
|
4437
4541
|
byNode.set(node, {
|
|
4438
4542
|
node,
|
|
4439
4543
|
state,
|
|
4544
|
+
cause: deriveCause(state, reasons),
|
|
4440
4545
|
reasons,
|
|
4441
|
-
notes
|
|
4546
|
+
notes,
|
|
4442
4547
|
model: nodeModelOf(node, profile),
|
|
4443
|
-
exits: exitsFor(node, evaluateConfigured)
|
|
4548
|
+
exits: exitsFor(node, evaluateConfigured),
|
|
4549
|
+
promptWarning: state === "on" && PROMPT_403_NODES.has(node)
|
|
4444
4550
|
});
|
|
4445
4551
|
}
|
|
4446
4552
|
function getNode(node) {
|
|
4447
4553
|
const found = byNode.get(node);
|
|
4448
4554
|
if (!found) {
|
|
4449
|
-
throw new Error(
|
|
4555
|
+
throw new Error(
|
|
4556
|
+
`computeGraphReachability: no reachability rule was set for node "${node}" \u2014 NODE_NAMES gained an entry this module does not know how to place.`
|
|
4557
|
+
);
|
|
4450
4558
|
}
|
|
4451
4559
|
return found;
|
|
4452
4560
|
}
|
|
@@ -4455,121 +4563,329 @@ function computeGraphReachability(rawSettings, hasCategoryWithAutoReply) {
|
|
|
4455
4563
|
const fetchBlockingReasons = [];
|
|
4456
4564
|
const sourceViewIdIssue = issues.find((issue) => issue.key === "sourceViewId");
|
|
4457
4565
|
if (sourceViewIdIssue) {
|
|
4458
|
-
fetchBlockingReasons.push(
|
|
4566
|
+
fetchBlockingReasons.push(
|
|
4567
|
+
reason(
|
|
4568
|
+
"missing-setting",
|
|
4569
|
+
settingsIssueLabel("sourceViewId", sourceViewIdIssue.message),
|
|
4570
|
+
"validateSettings: sourceViewId est vide."
|
|
4571
|
+
)
|
|
4572
|
+
);
|
|
4459
4573
|
}
|
|
4460
4574
|
if (!settings.triageEnabled) {
|
|
4461
|
-
fetchOffReasons.push(
|
|
4575
|
+
fetchOffReasons.push(
|
|
4576
|
+
reason(
|
|
4577
|
+
"missing-setting",
|
|
4578
|
+
"Le pipeline est coup\xE9 : aucun ticket n'est lu, donc aucune \xE9tape ne s'ex\xE9cute.",
|
|
4579
|
+
"triageEnabled est d\xE9sactiv\xE9 \u2014 coupe-circuit global (\xA73.5)."
|
|
4580
|
+
)
|
|
4581
|
+
);
|
|
4462
4582
|
}
|
|
4463
|
-
set("fetchContext", deriveState(true, fetchBlockingReasons, fetchOffReasons), [
|
|
4583
|
+
set("fetchContext", deriveState(true, fetchBlockingReasons, fetchOffReasons), [
|
|
4584
|
+
...fetchBlockingReasons,
|
|
4585
|
+
...fetchOffReasons
|
|
4586
|
+
]);
|
|
4464
4587
|
const fetchNode = getNode("fetchContext");
|
|
4465
4588
|
const fetchRuns = passesControlOn("fetchContext");
|
|
4466
4589
|
set(
|
|
4467
4590
|
"triage",
|
|
4468
4591
|
fetchRuns ? "on" : "unreachable",
|
|
4469
4592
|
fetchRuns ? [] : [
|
|
4470
|
-
reason(
|
|
4593
|
+
fetchNode.state === "off" ? reason(
|
|
4594
|
+
"upstream-disabled",
|
|
4595
|
+
"La r\xE9cup\xE9ration du ticket est coup\xE9e \u2014 aucun ticket n'est jamais lu.",
|
|
4596
|
+
"fetchContext est d\xE9sactiv\xE9 (triageEnabled)."
|
|
4597
|
+
) : reason(
|
|
4471
4598
|
"upstream-disabled",
|
|
4472
|
-
|
|
4599
|
+
"La r\xE9cup\xE9ration du ticket est bloqu\xE9e \u2014 voir sa carte.",
|
|
4600
|
+
"fetchContext est inatteignable (sourceViewId)."
|
|
4473
4601
|
)
|
|
4474
4602
|
]
|
|
4475
4603
|
);
|
|
4476
4604
|
const triageRuns = passesControlOn("triage");
|
|
4477
4605
|
const escalateDisabled = profile.nodes.escalate === null;
|
|
4606
|
+
const escalateOff = reason(
|
|
4607
|
+
"disabled-step",
|
|
4608
|
+
"\xC9tape coup\xE9e dans les r\xE9glages \u2014 aucune escalade automatique n'est d\xE9cid\xE9e.",
|
|
4609
|
+
"nodes.escalate est \xE0 null (\xA73.6)."
|
|
4610
|
+
);
|
|
4478
4611
|
set(
|
|
4479
4612
|
"escalate",
|
|
4480
|
-
deriveState(triageRuns, [], escalateDisabled ? [
|
|
4481
|
-
triageRuns ? escalateDisabled ? [
|
|
4613
|
+
deriveState(triageRuns, [], escalateDisabled ? [escalateOff] : []),
|
|
4614
|
+
triageRuns ? escalateDisabled ? [escalateOff] : [] : [
|
|
4615
|
+
reason(
|
|
4616
|
+
"upstream-disabled",
|
|
4617
|
+
"Le triage n'est jamais atteint.",
|
|
4618
|
+
"triage est inatteignable."
|
|
4619
|
+
)
|
|
4620
|
+
]
|
|
4482
4621
|
);
|
|
4483
4622
|
const draftDisabled = hasNoDraftNode(profile);
|
|
4623
|
+
const draftOff = reason(
|
|
4624
|
+
"disabled-step",
|
|
4625
|
+
"\xC9tape coup\xE9e dans les r\xE9glages \u2014 aucune r\xE9ponse n'est r\xE9dig\xE9e.",
|
|
4626
|
+
"nodes.draft est \xE0 null \u2014 sortie \xAB triaged_only \xBB (run-ticket.ts#hasNoDraftNode)."
|
|
4627
|
+
);
|
|
4484
4628
|
set(
|
|
4485
4629
|
"draft",
|
|
4486
|
-
deriveState(triageRuns, [], draftDisabled ? [
|
|
4487
|
-
triageRuns ? draftDisabled ? [
|
|
4630
|
+
deriveState(triageRuns, [], draftDisabled ? [draftOff] : []),
|
|
4631
|
+
triageRuns ? draftDisabled ? [draftOff] : [] : [
|
|
4632
|
+
reason(
|
|
4633
|
+
"upstream-disabled",
|
|
4634
|
+
"Le triage n'est jamais atteint.",
|
|
4635
|
+
"triage est inatteignable."
|
|
4636
|
+
)
|
|
4637
|
+
]
|
|
4488
4638
|
);
|
|
4489
4639
|
const draftRuns = passesControlOn("draft");
|
|
4490
4640
|
const evaluateDisabled = !evaluateConfigured;
|
|
4641
|
+
const evaluateOff = reason(
|
|
4642
|
+
"disabled-step",
|
|
4643
|
+
"\xC9tape coup\xE9e dans les r\xE9glages \u2014 aucun verdict, la r\xE9ponse reste \xAB Disponible \xBB.",
|
|
4644
|
+
"nodes.evaluate est \xE0 null \u2014 la r\xE9ponse conserve l'issue \xAB ready \xBB."
|
|
4645
|
+
);
|
|
4491
4646
|
set(
|
|
4492
4647
|
"evaluate",
|
|
4493
|
-
deriveState(draftRuns, [], evaluateDisabled ? [
|
|
4494
|
-
draftRuns ? evaluateDisabled ? [
|
|
4648
|
+
deriveState(draftRuns, [], evaluateDisabled ? [evaluateOff] : []),
|
|
4649
|
+
draftRuns ? evaluateDisabled ? [evaluateOff] : [] : [
|
|
4650
|
+
getNode("draft").state === "off" ? reason(
|
|
4651
|
+
"upstream-disabled",
|
|
4652
|
+
"La r\xE9daction est coup\xE9e \u2014 aucun ticket n'atteint l'\xE9valuation.",
|
|
4653
|
+
"draft est d\xE9sactiv\xE9."
|
|
4654
|
+
) : reason(
|
|
4655
|
+
"upstream-disabled",
|
|
4656
|
+
"La r\xE9daction n'est jamais atteinte.",
|
|
4657
|
+
"draft est inatteignable."
|
|
4658
|
+
)
|
|
4659
|
+
]
|
|
4495
4660
|
);
|
|
4496
4661
|
const evaluateRuns = passesControlOn("evaluate");
|
|
4497
4662
|
const reviseDisabled = profile.nodes.revise === null;
|
|
4663
|
+
const reviseOff = reason(
|
|
4664
|
+
"disabled-step",
|
|
4665
|
+
"\xC9tape coup\xE9e dans les r\xE9glages \u2014 pas de passe de correction.",
|
|
4666
|
+
"nodes.revise est \xE0 null."
|
|
4667
|
+
);
|
|
4498
4668
|
set(
|
|
4499
4669
|
"revise",
|
|
4500
|
-
deriveState(evaluateRuns, [], reviseDisabled ? [
|
|
4501
|
-
evaluateRuns ? reviseDisabled ? [
|
|
4502
|
-
|
|
4670
|
+
deriveState(evaluateRuns, [], reviseDisabled ? [reviseOff] : []),
|
|
4671
|
+
evaluateRuns ? reviseDisabled ? [reviseOff] : [] : [
|
|
4672
|
+
getNode("evaluate").state === "off" ? reason(
|
|
4673
|
+
"upstream-disabled",
|
|
4674
|
+
"L'\xE9valuation est coup\xE9e \u2014 aucun ticket n'atteint la r\xE9vision.",
|
|
4675
|
+
"evaluate est d\xE9sactiv\xE9."
|
|
4676
|
+
) : reason(
|
|
4677
|
+
"upstream-disabled",
|
|
4678
|
+
"L'\xE9valuation n'est jamais atteinte.",
|
|
4679
|
+
"evaluate est inatteignable."
|
|
4680
|
+
)
|
|
4681
|
+
],
|
|
4682
|
+
evaluateRuns && !reviseDisabled ? [note("Au plus une passe de r\xE9vision par ticket.", "\xA73.3.")] : []
|
|
4503
4683
|
);
|
|
4504
4684
|
const autoSendBlockingReasons = [];
|
|
4505
4685
|
const autoSendOffReasons = [];
|
|
4506
4686
|
if (!profile.autoSend.enabled) {
|
|
4507
|
-
autoSendOffReasons.push(
|
|
4687
|
+
autoSendOffReasons.push(
|
|
4688
|
+
reason(
|
|
4689
|
+
"missing-setting",
|
|
4690
|
+
"L'envoi automatique est coup\xE9 \u2014 ce coupe-circuit emp\xEAche tout envoi.",
|
|
4691
|
+
"autoSendEnabled est d\xE9sactiv\xE9."
|
|
4692
|
+
)
|
|
4693
|
+
);
|
|
4508
4694
|
}
|
|
4509
4695
|
if (!hasCategoryWithAutoReply) {
|
|
4510
4696
|
autoSendBlockingReasons.push(
|
|
4511
|
-
reason(
|
|
4697
|
+
reason(
|
|
4698
|
+
"missing-setting",
|
|
4699
|
+
"Aucune cat\xE9gorie n'a \xAB Envoi auto \xBB activ\xE9 \u2014 sans elle, aucune r\xE9ponse n'est \xE9ligible \xE0 un envoi automatique.",
|
|
4700
|
+
"isAutoSendEligible exige category.autoReplyEnabled ; aucune cat\xE9gorie ne le porte aujourd'hui."
|
|
4701
|
+
)
|
|
4512
4702
|
);
|
|
4513
4703
|
}
|
|
4514
4704
|
const senderEmailIssue = issues.find((issue) => issue.key === "senderEmail");
|
|
4515
4705
|
if (senderEmailIssue) {
|
|
4516
|
-
autoSendBlockingReasons.push(
|
|
4706
|
+
autoSendBlockingReasons.push(
|
|
4707
|
+
reason(
|
|
4708
|
+
"missing-setting",
|
|
4709
|
+
settingsIssueLabel("senderEmail", senderEmailIssue.message),
|
|
4710
|
+
"validateSettings: senderEmail est vide alors que autoSendEnabled est actif."
|
|
4711
|
+
)
|
|
4712
|
+
);
|
|
4517
4713
|
}
|
|
4518
4714
|
const guardrailNotes = [];
|
|
4519
4715
|
if (!profile.autoSend.senderEmail && profile.guardrails.params.whatsappMode === "auto_reply") {
|
|
4520
4716
|
guardrailNotes.push(
|
|
4521
|
-
|
|
4717
|
+
note(
|
|
4718
|
+
"Sans adresse d'envoi, seuls les tickets WhatsApp en r\xE9ponse automatique passent ici : un ticket email reste bloqu\xE9 \xE0 \xAB Disponible \xBB.",
|
|
4719
|
+
`senderEmail est vide et whatsappMode="auto_reply" \u2014 hasSenderForMode n'est vrai que pour WhatsApp ; un ticket email n'atteint jamais guardrails/authorize/act.`
|
|
4720
|
+
)
|
|
4522
4721
|
);
|
|
4523
4722
|
}
|
|
4524
4723
|
if (profile.guardrails.params.whatsappMode === "draft_only") {
|
|
4525
4724
|
guardrailNotes.push(
|
|
4526
|
-
|
|
4725
|
+
note(
|
|
4726
|
+
"Les tickets WhatsApp ne d\xE9passent jamais \xAB Disponible \xBB (mode brouillon seul) : seuls les tickets email arrivent r\xE9ellement ici.",
|
|
4727
|
+
`whatsappMode="draft_only" \u2014 isAutoSendEligible exclut ce mode ; authorize/act ne s'ex\xE9cutent que pour le canal email.`
|
|
4728
|
+
)
|
|
4527
4729
|
);
|
|
4528
4730
|
}
|
|
4529
4731
|
if (profile.guardrails.params.whatsappMode === "escalate_only") {
|
|
4530
4732
|
guardrailNotes.push(
|
|
4531
|
-
|
|
4733
|
+
note(
|
|
4734
|
+
"Un ticket WhatsApp qui arrive ici est syst\xE9matiquement retenu : sur ce canal la r\xE9ponse est gard\xE9e, jamais envoy\xE9e.",
|
|
4735
|
+
`whatsappMode="escalate_only" \u2014 garde-fou \xAB whatsapp \xBB (\xA73.9) ; authorize/act ne s'ex\xE9cutent jamais pour ce canal.`
|
|
4736
|
+
)
|
|
4532
4737
|
);
|
|
4533
4738
|
}
|
|
4534
4739
|
set(
|
|
4535
4740
|
"guardrails",
|
|
4536
4741
|
deriveState(evaluateRuns, autoSendBlockingReasons, autoSendOffReasons),
|
|
4537
|
-
evaluateRuns ? [...autoSendBlockingReasons, ...autoSendOffReasons] : [
|
|
4742
|
+
evaluateRuns ? [...autoSendBlockingReasons, ...autoSendOffReasons] : [
|
|
4743
|
+
getNode("evaluate").state === "off" ? reason(
|
|
4744
|
+
"upstream-disabled",
|
|
4745
|
+
"L'\xE9valuation est coup\xE9e \u2014 sans verdict, aucun ticket n'arrive ici.",
|
|
4746
|
+
"evaluate est d\xE9sactiv\xE9."
|
|
4747
|
+
) : reason(
|
|
4748
|
+
"upstream-disabled",
|
|
4749
|
+
"L'\xE9valuation n'est jamais atteinte \u2014 aucun verdict ne peut donc \xEAtre produit.",
|
|
4750
|
+
"evaluate est inatteignable."
|
|
4751
|
+
)
|
|
4752
|
+
],
|
|
4538
4753
|
guardrailNotes
|
|
4539
4754
|
);
|
|
4540
4755
|
const guardrailsRuns = passesControlOn("guardrails");
|
|
4541
4756
|
set(
|
|
4542
4757
|
"authorize",
|
|
4543
4758
|
guardrailsRuns ? "on" : "unreachable",
|
|
4544
|
-
guardrailsRuns ? [] : [
|
|
4759
|
+
guardrailsRuns ? [] : [
|
|
4760
|
+
getNode("guardrails").state === "off" ? reason(
|
|
4761
|
+
"upstream-disabled",
|
|
4762
|
+
"Les garde-fous sont coup\xE9s \u2014 aucune action n'est jamais autoris\xE9e.",
|
|
4763
|
+
"guardrails est d\xE9sactiv\xE9 (autoSendEnabled)."
|
|
4764
|
+
) : reason(
|
|
4765
|
+
"upstream-disabled",
|
|
4766
|
+
"Les garde-fous ne sont jamais atteints \u2014 voir leur carte.",
|
|
4767
|
+
"guardrails est inatteignable."
|
|
4768
|
+
)
|
|
4769
|
+
],
|
|
4545
4770
|
guardrailsRuns ? guardrailNotes : []
|
|
4546
4771
|
);
|
|
4547
4772
|
const authorizeRuns = passesControlOn("authorize");
|
|
4548
|
-
const approvalNote =
|
|
4773
|
+
const approvalNote = note(
|
|
4774
|
+
"Le chemin d'approbation manuelle est inatteignable avec les r\xE9glages actuels : une r\xE9ponse autoris\xE9e part directement, jamais apr\xE8s une approbation.",
|
|
4775
|
+
"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)."
|
|
4776
|
+
);
|
|
4549
4777
|
set(
|
|
4550
4778
|
"act",
|
|
4551
4779
|
authorizeRuns ? "on" : "unreachable",
|
|
4552
|
-
authorizeRuns ? [] : [
|
|
4780
|
+
authorizeRuns ? [] : [
|
|
4781
|
+
reason(
|
|
4782
|
+
"upstream-disabled",
|
|
4783
|
+
"L'autorisation n'est jamais atteinte.",
|
|
4784
|
+
"authorize est inatteignable."
|
|
4785
|
+
)
|
|
4786
|
+
],
|
|
4553
4787
|
authorizeRuns ? [...guardrailNotes, approvalNote] : []
|
|
4554
4788
|
);
|
|
4555
|
-
|
|
4789
|
+
const nodes = NODE_NAMES.map((node) => getNode(node));
|
|
4790
|
+
const promptWarningNodes = nodes.filter((n) => n.promptWarning).map((n) => n.node);
|
|
4791
|
+
return {
|
|
4792
|
+
blocked: false,
|
|
4793
|
+
nodes,
|
|
4794
|
+
globalNotes: promptWarningNodes.length > 0 ? [{ ...PROMPT_403_NOTE, nodes: promptWarningNodes }] : []
|
|
4795
|
+
};
|
|
4796
|
+
}
|
|
4797
|
+
function windowCutoffIso3(days, now = Date.now()) {
|
|
4798
|
+
return new Date(now - days * 24 * 60 * 60 * 1e3).toISOString();
|
|
4799
|
+
}
|
|
4800
|
+
function totalOf(rows) {
|
|
4801
|
+
if (!Array.isArray(rows)) return null;
|
|
4802
|
+
let total = 0;
|
|
4803
|
+
for (const row of rows) {
|
|
4804
|
+
const value = row?.count;
|
|
4805
|
+
if (typeof value !== "number") return null;
|
|
4806
|
+
total += value;
|
|
4807
|
+
}
|
|
4808
|
+
return total;
|
|
4809
|
+
}
|
|
4810
|
+
function useGraphTraffic(windowDays) {
|
|
4811
|
+
const cutoffIso = useMemo(() => windowCutoffIso3(windowDays), [windowDays]);
|
|
4812
|
+
const triaged = useAggregate("triage-decision", {
|
|
4813
|
+
filter: { decidedAt: { gte: cutoffIso } },
|
|
4814
|
+
metrics: [{ op: "count", as: "count" }]
|
|
4815
|
+
});
|
|
4816
|
+
const escalated = useAggregate("triage-decision", {
|
|
4817
|
+
filter: { decidedAt: { gte: cutoffIso }, escalated: { eq: true } },
|
|
4818
|
+
metrics: [{ op: "count", as: "count" }]
|
|
4819
|
+
});
|
|
4820
|
+
const drafted = useAggregate("generated-response", {
|
|
4821
|
+
filter: { generatedAt: { gte: cutoffIso } },
|
|
4822
|
+
metrics: [{ op: "count", as: "count" }]
|
|
4823
|
+
});
|
|
4824
|
+
const sent = useAggregate("generated-response", {
|
|
4825
|
+
filter: { generatedAt: { gte: cutoffIso }, status: { eq: "sent" } },
|
|
4826
|
+
metrics: [{ op: "count", as: "count" }]
|
|
4827
|
+
});
|
|
4828
|
+
const isLoading = triaged.isLoading || escalated.isLoading || drafted.isLoading || sent.isLoading;
|
|
4829
|
+
const failed = [triaged, escalated, drafted, sent].some((q) => q.error !== void 0);
|
|
4830
|
+
const triagedTotal = totalOf(triaged.rows);
|
|
4831
|
+
const escalatedTotal = totalOf(escalated.rows);
|
|
4832
|
+
const draftedTotal = totalOf(drafted.rows);
|
|
4833
|
+
const sentTotal = totalOf(sent.rows);
|
|
4834
|
+
return useMemo(() => {
|
|
4835
|
+
const byNode = {};
|
|
4836
|
+
if (triagedTotal !== null) {
|
|
4837
|
+
byNode.fetchContext = {
|
|
4838
|
+
count: triagedTotal,
|
|
4839
|
+
witness: "tickets triag\xE9s (un triage suppose une lecture r\xE9ussie)"
|
|
4840
|
+
};
|
|
4841
|
+
byNode.triage = { count: triagedTotal, witness: "tickets triag\xE9s" };
|
|
4842
|
+
}
|
|
4843
|
+
if (escalatedTotal !== null)
|
|
4844
|
+
byNode.escalate = { count: escalatedTotal, witness: "tickets escalad\xE9s" };
|
|
4845
|
+
if (draftedTotal !== null) byNode.draft = { count: draftedTotal, witness: "r\xE9ponses r\xE9dig\xE9es" };
|
|
4846
|
+
if (sentTotal !== null) byNode.act = { count: sentTotal, witness: "r\xE9ponses envoy\xE9es" };
|
|
4847
|
+
return {
|
|
4848
|
+
byNode: failed ? {} : byNode,
|
|
4849
|
+
isLoading,
|
|
4850
|
+
unavailable: failed
|
|
4851
|
+
};
|
|
4852
|
+
}, [triagedTotal, escalatedTotal, draftedTotal, sentTotal, failed, isLoading]);
|
|
4556
4853
|
}
|
|
4557
4854
|
var CATEGORY_PAGE_SIZE = 500;
|
|
4855
|
+
var TRAFFIC_WINDOW_DAYS = 7;
|
|
4558
4856
|
var REASON_KIND_LABELS = {
|
|
4559
4857
|
"disabled-step": "\xC9tape d\xE9sactiv\xE9e",
|
|
4560
4858
|
"upstream-disabled": "Bloqu\xE9 en amont",
|
|
4561
4859
|
"missing-setting": "R\xE9glage manquant",
|
|
4562
4860
|
"channel-gate": "Restriction de canal"
|
|
4563
4861
|
};
|
|
4564
|
-
var
|
|
4862
|
+
var BADGE_LABELS = {
|
|
4565
4863
|
on: "Actif",
|
|
4566
4864
|
off: "D\xE9sactiv\xE9",
|
|
4567
|
-
|
|
4865
|
+
root: "Bloqu\xE9",
|
|
4866
|
+
consequence: "Hors d\u2019atteinte"
|
|
4568
4867
|
};
|
|
4569
|
-
var
|
|
4868
|
+
var BADGE_VARIANTS = {
|
|
4570
4869
|
on: "success",
|
|
4571
4870
|
off: "neutral",
|
|
4572
|
-
|
|
4871
|
+
root: "danger",
|
|
4872
|
+
consequence: "warning"
|
|
4873
|
+
};
|
|
4874
|
+
var BADGE_DEFINITIONS = {
|
|
4875
|
+
on: "Au moins un ticket peut atteindre ce n\u0153ud avec les r\xE9glages actuels.",
|
|
4876
|
+
off: "L\u2019op\xE9rateur a coup\xE9 ce n\u0153ud lui-m\xEAme \u2014 un choix, pas un incident.",
|
|
4877
|
+
root: "C\u2019est ici que le parcours s\u2019arr\xEAte : la cause est sur cette carte.",
|
|
4878
|
+
consequence: "Ce n\u0153ud n\u2019a rien de cass\xE9 \u2014 il est simplement priv\xE9 de tickets par un n\u0153ud en amont."
|
|
4879
|
+
};
|
|
4880
|
+
function badgeKindOf(node) {
|
|
4881
|
+
if (node.state === "on") return "on";
|
|
4882
|
+
if (node.state === "off") return "off";
|
|
4883
|
+
return node.cause === "consequence" ? "consequence" : "root";
|
|
4884
|
+
}
|
|
4885
|
+
var EXIT_TONE_CLASSES = {
|
|
4886
|
+
delivered: "border-status-success/30 bg-status-success/10 text-status-success",
|
|
4887
|
+
held: "border-border bg-muted text-muted-foreground",
|
|
4888
|
+
failure: "border-status-blocked/25 bg-status-blocked/10 text-status-blocked"
|
|
4573
4889
|
};
|
|
4574
4890
|
var NODE_SETTINGS_SECTION = {
|
|
4575
4891
|
fetchContext: { id: "source", title: "Source" },
|
|
@@ -4581,60 +4897,395 @@ var NODE_SETTINGS_SECTION = {
|
|
|
4581
4897
|
guardrails: { id: "guardrails", title: "Guardrails" },
|
|
4582
4898
|
act: { id: "envoi", title: "Envoi" }
|
|
4583
4899
|
};
|
|
4584
|
-
function
|
|
4585
|
-
const section = NODE_SETTINGS_SECTION[node
|
|
4900
|
+
function settingsHref(appSlug, node) {
|
|
4901
|
+
const section = NODE_SETTINGS_SECTION[node];
|
|
4902
|
+
return section ? `/parametres/espaces/${appSlug}#${section.id}` : null;
|
|
4903
|
+
}
|
|
4904
|
+
function dedupeExits(exits) {
|
|
4905
|
+
const byOutcome = /* @__PURE__ */ new Map();
|
|
4906
|
+
for (const exit of exits) {
|
|
4907
|
+
const existing = byOutcome.get(exit.outcome);
|
|
4908
|
+
if (existing) existing.conditions.push(exit.condition);
|
|
4909
|
+
else
|
|
4910
|
+
byOutcome.set(exit.outcome, {
|
|
4911
|
+
outcome: exit.outcome,
|
|
4912
|
+
tone: exit.tone,
|
|
4913
|
+
conditions: [exit.condition]
|
|
4914
|
+
});
|
|
4915
|
+
}
|
|
4916
|
+
return [...byOutcome.values()];
|
|
4917
|
+
}
|
|
4918
|
+
function computeVerdict(result) {
|
|
4919
|
+
const causes = result.nodes.filter((node) => node.state !== "on" && node.cause === "root");
|
|
4920
|
+
if (result.blocked) {
|
|
4921
|
+
return {
|
|
4922
|
+
tone: "critical",
|
|
4923
|
+
headline: "Le pipeline ne peut pas d\xE9marrer : le triage n\u2019est pas configur\xE9.",
|
|
4924
|
+
causes: causes.slice(0, 1)
|
|
4925
|
+
};
|
|
4926
|
+
}
|
|
4927
|
+
const act = result.nodes.find((node) => node.node === "act");
|
|
4928
|
+
if (act && act.state !== "on") {
|
|
4929
|
+
return {
|
|
4930
|
+
tone: "critical",
|
|
4931
|
+
headline: "Aucune r\xE9ponse ne peut partir automatiquement aujourd\u2019hui.",
|
|
4932
|
+
causes
|
|
4933
|
+
};
|
|
4934
|
+
}
|
|
4935
|
+
return {
|
|
4936
|
+
tone: "ok",
|
|
4937
|
+
headline: "Le parcours va jusqu\u2019\xE0 l\u2019envoi : une r\xE9ponse peut partir automatiquement.",
|
|
4938
|
+
causes
|
|
4939
|
+
};
|
|
4940
|
+
}
|
|
4941
|
+
function VerdictBanner({ verdict, appSlug }) {
|
|
4942
|
+
const critical = verdict.tone === "critical";
|
|
4586
4943
|
return /* @__PURE__ */ jsx(
|
|
4587
|
-
|
|
4944
|
+
"section",
|
|
4588
4945
|
{
|
|
4946
|
+
"data-testid": "graph-verdict",
|
|
4947
|
+
className: cn(
|
|
4948
|
+
"rounded-lg border p-4",
|
|
4949
|
+
critical ? "border-status-blocked/30 bg-status-blocked/5" : "border-status-success/30 bg-status-success/5"
|
|
4950
|
+
),
|
|
4951
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
|
|
4952
|
+
/* @__PURE__ */ jsx(
|
|
4953
|
+
"span",
|
|
4954
|
+
{
|
|
4955
|
+
"aria-hidden": true,
|
|
4956
|
+
className: cn(
|
|
4957
|
+
"mt-0.5 text-lg leading-none",
|
|
4958
|
+
critical ? "text-status-blocked" : "text-status-success"
|
|
4959
|
+
),
|
|
4960
|
+
children: critical ? "\u26D4" : "\u2713"
|
|
4961
|
+
}
|
|
4962
|
+
),
|
|
4963
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
4964
|
+
/* @__PURE__ */ jsx(
|
|
4965
|
+
"p",
|
|
4966
|
+
{
|
|
4967
|
+
className: cn(
|
|
4968
|
+
"text-sm font-semibold",
|
|
4969
|
+
critical ? "text-status-blocked" : "text-status-success"
|
|
4970
|
+
),
|
|
4971
|
+
children: verdict.headline
|
|
4972
|
+
}
|
|
4973
|
+
),
|
|
4974
|
+
verdict.causes.length > 0 && /* @__PURE__ */ jsx("ul", { className: "space-y-2", children: verdict.causes.map((cause) => {
|
|
4975
|
+
const href = settingsHref(appSlug, cause.node);
|
|
4976
|
+
return /* @__PURE__ */ jsxs(
|
|
4977
|
+
"li",
|
|
4978
|
+
{
|
|
4979
|
+
className: "flex flex-wrap items-center gap-x-2 gap-y-1 text-sm",
|
|
4980
|
+
children: [
|
|
4981
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: NODE_LABELS[cause.node] }),
|
|
4982
|
+
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
|
|
4983
|
+
"\u2014 ",
|
|
4984
|
+
cause.reasons[0]?.message ?? ""
|
|
4985
|
+
] }),
|
|
4986
|
+
href && /* @__PURE__ */ jsx(
|
|
4987
|
+
Link,
|
|
4988
|
+
{
|
|
4989
|
+
href,
|
|
4990
|
+
className: cn(
|
|
4991
|
+
buttonVariants({ variant: "outline", size: "sm" }),
|
|
4992
|
+
"no-underline"
|
|
4993
|
+
),
|
|
4994
|
+
children: "Corriger"
|
|
4995
|
+
}
|
|
4996
|
+
)
|
|
4997
|
+
]
|
|
4998
|
+
},
|
|
4999
|
+
cause.node
|
|
5000
|
+
);
|
|
5001
|
+
}) })
|
|
5002
|
+
] })
|
|
5003
|
+
] })
|
|
5004
|
+
}
|
|
5005
|
+
);
|
|
5006
|
+
}
|
|
5007
|
+
function Legend() {
|
|
5008
|
+
return /* @__PURE__ */ jsx(
|
|
5009
|
+
"div",
|
|
5010
|
+
{
|
|
5011
|
+
className: "flex flex-wrap items-center gap-x-4 gap-y-2 text-xs text-muted-foreground",
|
|
5012
|
+
"data-testid": "graph-legend",
|
|
5013
|
+
children: Object.keys(BADGE_LABELS).map((kind) => /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5", title: BADGE_DEFINITIONS[kind], children: [
|
|
5014
|
+
/* @__PURE__ */ jsx(Badge, { variant: BADGE_VARIANTS[kind], children: BADGE_LABELS[kind] }),
|
|
5015
|
+
/* @__PURE__ */ jsx("span", { className: "max-w-64", children: BADGE_DEFINITIONS[kind] })
|
|
5016
|
+
] }, kind))
|
|
5017
|
+
}
|
|
5018
|
+
);
|
|
5019
|
+
}
|
|
5020
|
+
function trafficContradiction(node, traffic) {
|
|
5021
|
+
if (!traffic) return null;
|
|
5022
|
+
if (node.state === "on" && traffic.count === 0) {
|
|
5023
|
+
return `Aucun passage observ\xE9 sur ${TRAFFIC_WINDOW_DAYS} jours, alors que ce n\u0153ud est r\xE9put\xE9 atteignable.`;
|
|
5024
|
+
}
|
|
5025
|
+
if (node.state !== "on" && traffic.count > 0) {
|
|
5026
|
+
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.`;
|
|
5027
|
+
}
|
|
5028
|
+
return null;
|
|
5029
|
+
}
|
|
5030
|
+
function TrafficPill({
|
|
5031
|
+
node,
|
|
5032
|
+
traffic
|
|
5033
|
+
}) {
|
|
5034
|
+
if (!traffic) {
|
|
5035
|
+
return /* @__PURE__ */ jsx(
|
|
5036
|
+
"span",
|
|
5037
|
+
{
|
|
5038
|
+
className: "text-xs text-muted-foreground",
|
|
5039
|
+
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.",
|
|
5040
|
+
children: "\u2014 trafic non mesur\xE9"
|
|
5041
|
+
}
|
|
5042
|
+
);
|
|
5043
|
+
}
|
|
5044
|
+
const contradiction = trafficContradiction(node, traffic);
|
|
5045
|
+
return /* @__PURE__ */ jsxs(
|
|
5046
|
+
"span",
|
|
5047
|
+
{
|
|
5048
|
+
className: cn(
|
|
5049
|
+
"text-xs",
|
|
5050
|
+
contradiction ? "font-medium text-status-blocked" : "text-muted-foreground"
|
|
5051
|
+
),
|
|
5052
|
+
title: `${traffic.witness}, sur ${TRAFFIC_WINDOW_DAYS} jours.`,
|
|
5053
|
+
children: [
|
|
5054
|
+
traffic.count,
|
|
5055
|
+
" sur ",
|
|
5056
|
+
TRAFFIC_WINDOW_DAYS,
|
|
5057
|
+
" j",
|
|
5058
|
+
contradiction ? " \u26A0" : ""
|
|
5059
|
+
]
|
|
5060
|
+
}
|
|
5061
|
+
);
|
|
5062
|
+
}
|
|
5063
|
+
function Connector({ into, isBreak }) {
|
|
5064
|
+
const dead = into.state !== "on";
|
|
5065
|
+
return /* @__PURE__ */ jsxs(
|
|
5066
|
+
"div",
|
|
5067
|
+
{
|
|
5068
|
+
className: "flex items-center gap-2 pl-[3px]",
|
|
5069
|
+
"data-testid": `graph-edge-${into.node}`,
|
|
5070
|
+
"data-edge-state": dead ? "dead" : "live",
|
|
5071
|
+
children: [
|
|
5072
|
+
/* @__PURE__ */ jsx(
|
|
5073
|
+
"span",
|
|
5074
|
+
{
|
|
5075
|
+
"aria-hidden": true,
|
|
5076
|
+
className: cn(
|
|
5077
|
+
"h-6 w-0 border-l-2",
|
|
5078
|
+
dead ? "border-dashed" : "border-solid",
|
|
5079
|
+
into.state === "on" ? "border-status-success/50" : into.cause === "root" ? "border-status-blocked/60" : "border-border"
|
|
5080
|
+
)
|
|
5081
|
+
}
|
|
5082
|
+
),
|
|
5083
|
+
isBreak && /* @__PURE__ */ jsxs("span", { className: "text-xs font-medium text-status-blocked", children: [
|
|
5084
|
+
"\u26D4",
|
|
5085
|
+
" le parcours s",
|
|
5086
|
+
"\u2019",
|
|
5087
|
+
"arr\xEAte ici"
|
|
5088
|
+
] })
|
|
5089
|
+
]
|
|
5090
|
+
}
|
|
5091
|
+
);
|
|
5092
|
+
}
|
|
5093
|
+
function NodeRow({
|
|
5094
|
+
node,
|
|
5095
|
+
traffic,
|
|
5096
|
+
technical,
|
|
5097
|
+
globalNotes,
|
|
5098
|
+
onOpen
|
|
5099
|
+
}) {
|
|
5100
|
+
const kind = badgeKindOf(node);
|
|
5101
|
+
const exits = dedupeExits(node.exits);
|
|
5102
|
+
const contradiction = trafficContradiction(node, traffic);
|
|
5103
|
+
const headlineReason = node.reasons[0];
|
|
5104
|
+
const extraCount = Math.max(0, node.reasons.length - 1) + node.notes.length + globalNotes.length;
|
|
5105
|
+
return /* @__PURE__ */ jsxs(
|
|
5106
|
+
"div",
|
|
5107
|
+
{
|
|
5108
|
+
className: "flex items-start gap-3",
|
|
4589
5109
|
"data-testid": "graph-node",
|
|
4590
5110
|
"data-node": node.node,
|
|
4591
|
-
|
|
4592
|
-
children:
|
|
4593
|
-
/* @__PURE__ */
|
|
4594
|
-
|
|
4595
|
-
/* @__PURE__ */ jsx(Badge, { variant: ACTIVATION_BADGE_VARIANT[node.state], children: ACTIVATION_LABELS[node.state] })
|
|
4596
|
-
] }),
|
|
4597
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs leading-snug text-muted-foreground", children: NODE_ROLE_LABELS[node.node] }),
|
|
4598
|
-
/* @__PURE__ */ jsx("p", { className: "font-mono text-[10px] text-muted-foreground", children: node.node }),
|
|
4599
|
-
node.model && /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
4600
|
-
"Mod\xE8le : ",
|
|
4601
|
-
/* @__PURE__ */ jsx("code", { className: "font-mono", children: node.model })
|
|
4602
|
-
] }),
|
|
4603
|
-
node.exits.length > 0 && /* @__PURE__ */ jsx("ul", { className: "flex flex-wrap gap-1.5 border-t pt-2", children: node.exits.map((exit) => /* @__PURE__ */ jsx(
|
|
4604
|
-
"li",
|
|
5111
|
+
"data-state": kind,
|
|
5112
|
+
children: [
|
|
5113
|
+
/* @__PURE__ */ jsx(
|
|
5114
|
+
"span",
|
|
4605
5115
|
{
|
|
4606
|
-
|
|
4607
|
-
className:
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
5116
|
+
"aria-hidden": true,
|
|
5117
|
+
className: cn(
|
|
5118
|
+
"mt-4 size-2 shrink-0 rounded-full",
|
|
5119
|
+
kind === "on" && "bg-status-success",
|
|
5120
|
+
kind === "off" && "bg-muted-foreground/50",
|
|
5121
|
+
kind === "root" && "bg-status-blocked",
|
|
5122
|
+
kind === "consequence" && "bg-status-pending"
|
|
5123
|
+
)
|
|
5124
|
+
}
|
|
5125
|
+
),
|
|
5126
|
+
/* @__PURE__ */ jsx(
|
|
5127
|
+
Card,
|
|
5128
|
+
{
|
|
5129
|
+
className: cn(
|
|
5130
|
+
"w-full max-w-2xl",
|
|
5131
|
+
kind === "root" && "border-status-blocked/40",
|
|
5132
|
+
(kind === "off" || kind === "consequence") && "border-dashed opacity-80"
|
|
5133
|
+
),
|
|
5134
|
+
children: /* @__PURE__ */ jsxs(CardContent, { className: "space-y-2 p-3", "data-testid": `graph-node-${node.node}`, children: [
|
|
5135
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-x-2 gap-y-1", children: [
|
|
5136
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: NODE_LABELS[node.node] }),
|
|
5137
|
+
/* @__PURE__ */ jsx(Badge, { variant: BADGE_VARIANTS[kind], title: BADGE_DEFINITIONS[kind], children: BADGE_LABELS[kind] }),
|
|
5138
|
+
node.promptWarning && /* @__PURE__ */ jsxs(Badge, { variant: "warning", title: "Voir l\u2019avertissement au-dessus du graphe.", children: [
|
|
5139
|
+
"\u26A0",
|
|
5140
|
+
" prompt non d\xE9clar\xE9"
|
|
5141
|
+
] }),
|
|
5142
|
+
technical && /* @__PURE__ */ jsx("code", { className: "font-mono text-[10px] text-muted-foreground", children: node.node }),
|
|
5143
|
+
technical && node.model && /* @__PURE__ */ jsx("code", { className: "font-mono text-[10px] text-muted-foreground", children: node.model }),
|
|
5144
|
+
/* @__PURE__ */ jsxs("span", { className: "ml-auto flex items-center gap-3", children: [
|
|
5145
|
+
/* @__PURE__ */ jsx(TrafficPill, { node, traffic }),
|
|
5146
|
+
/* @__PURE__ */ jsxs(Button, { variant: "ghost", size: "sm", onClick: onOpen, children: [
|
|
5147
|
+
"D\xE9tails",
|
|
5148
|
+
extraCount > 0 ? ` (${extraCount})` : ""
|
|
5149
|
+
] })
|
|
5150
|
+
] })
|
|
5151
|
+
] }),
|
|
5152
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs leading-snug text-muted-foreground", children: NODE_ROLE_LABELS[node.node] }),
|
|
5153
|
+
headlineReason && /* @__PURE__ */ jsxs("p", { className: "text-xs", children: [
|
|
5154
|
+
/* @__PURE__ */ jsxs("span", { className: "font-medium", children: [
|
|
5155
|
+
REASON_KIND_LABELS[headlineReason.kind],
|
|
5156
|
+
" \u2014 "
|
|
5157
|
+
] }),
|
|
5158
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: headlineReason.message }),
|
|
5159
|
+
technical && headlineReason.detail && /* @__PURE__ */ jsx("span", { className: "ml-1 font-mono text-[10px] text-muted-foreground", children: headlineReason.detail })
|
|
5160
|
+
] }),
|
|
5161
|
+
contradiction && /* @__PURE__ */ jsx("p", { className: "text-xs font-medium text-status-blocked", children: contradiction }),
|
|
5162
|
+
exits.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-1.5 border-t pt-2", children: [
|
|
5163
|
+
/* @__PURE__ */ jsx("span", { className: "text-[11px] text-muted-foreground", children: "Issues possibles :" }),
|
|
5164
|
+
exits.map((exit) => /* @__PURE__ */ jsx(
|
|
5165
|
+
"span",
|
|
5166
|
+
{
|
|
5167
|
+
title: exit.conditions.join(" \xB7 "),
|
|
5168
|
+
className: cn(
|
|
5169
|
+
"rounded-md border px-1.5 py-0.5 text-[11px] leading-tight",
|
|
5170
|
+
EXIT_TONE_CLASSES[exit.tone]
|
|
5171
|
+
),
|
|
5172
|
+
children: outcomeLabel(exit.outcome)
|
|
5173
|
+
},
|
|
5174
|
+
exit.outcome
|
|
5175
|
+
))
|
|
5176
|
+
] })
|
|
5177
|
+
] })
|
|
5178
|
+
}
|
|
5179
|
+
)
|
|
5180
|
+
]
|
|
5181
|
+
}
|
|
5182
|
+
);
|
|
5183
|
+
}
|
|
5184
|
+
function NodeDetailPanel({
|
|
5185
|
+
node,
|
|
5186
|
+
traffic,
|
|
5187
|
+
technical,
|
|
5188
|
+
appSlug,
|
|
5189
|
+
globalNotes,
|
|
5190
|
+
onClose
|
|
5191
|
+
}) {
|
|
5192
|
+
const href = node ? settingsHref(appSlug, node.node) : null;
|
|
5193
|
+
return /* @__PURE__ */ jsx(
|
|
5194
|
+
SidePanel,
|
|
5195
|
+
{
|
|
5196
|
+
open: node !== null,
|
|
5197
|
+
onClose,
|
|
5198
|
+
title: node ? NODE_LABELS[node.node] : "",
|
|
5199
|
+
description: node ? NODE_ROLE_LABELS[node.node] : "",
|
|
5200
|
+
children: node && /* @__PURE__ */ jsxs(
|
|
5201
|
+
"div",
|
|
5202
|
+
{
|
|
5203
|
+
className: "min-h-0 flex-1 space-y-4 overflow-y-auto text-sm",
|
|
5204
|
+
"data-testid": "graph-node-detail",
|
|
5205
|
+
children: [
|
|
5206
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
5207
|
+
/* @__PURE__ */ jsx(Badge, { variant: BADGE_VARIANTS[badgeKindOf(node)], children: BADGE_LABELS[badgeKindOf(node)] }),
|
|
5208
|
+
technical && /* @__PURE__ */ jsx("code", { className: "font-mono text-xs text-muted-foreground", children: node.node })
|
|
5209
|
+
] }),
|
|
5210
|
+
node.model && /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
5211
|
+
"Mod\xE8le : ",
|
|
5212
|
+
/* @__PURE__ */ jsx("code", { className: "font-mono", children: node.model })
|
|
5213
|
+
] }),
|
|
5214
|
+
/* @__PURE__ */ 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." }),
|
|
5215
|
+
node.reasons.length > 0 && /* @__PURE__ */ jsxs("section", { className: "space-y-2", children: [
|
|
5216
|
+
/* @__PURE__ */ jsx("h3", { className: "text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: "Pourquoi" }),
|
|
5217
|
+
/* @__PURE__ */ jsx("ul", { className: "space-y-2", children: node.reasons.map((r, i) => /* @__PURE__ */ jsxs("li", { className: "text-xs", children: [
|
|
5218
|
+
/* @__PURE__ */ jsxs("span", { className: "font-medium", children: [
|
|
5219
|
+
REASON_KIND_LABELS[r.kind],
|
|
5220
|
+
" \u2014 "
|
|
5221
|
+
] }),
|
|
5222
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: r.message }),
|
|
5223
|
+
technical && r.detail && /* @__PURE__ */ jsx("p", { className: "mt-0.5 font-mono text-[10px] text-muted-foreground", children: r.detail })
|
|
5224
|
+
] }, i)) })
|
|
5225
|
+
] }),
|
|
5226
|
+
(node.notes.length > 0 || globalNotes.length > 0) && /* @__PURE__ */ jsxs("section", { className: "space-y-2", children: [
|
|
5227
|
+
/* @__PURE__ */ jsx("h3", { className: "text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: "\xC0 savoir" }),
|
|
5228
|
+
/* @__PURE__ */ jsxs("ul", { className: "space-y-2", children: [
|
|
5229
|
+
node.notes.map((note2, i) => /* @__PURE__ */ jsxs("li", { className: "text-xs text-muted-foreground", children: [
|
|
5230
|
+
note2.message,
|
|
5231
|
+
technical && note2.detail && /* @__PURE__ */ jsx("p", { className: "mt-0.5 font-mono text-[10px]", children: note2.detail })
|
|
5232
|
+
] }, `note-${i}`)),
|
|
5233
|
+
globalNotes.map((note2) => /* @__PURE__ */ jsxs("li", { className: "text-xs text-muted-foreground", children: [
|
|
5234
|
+
note2.message,
|
|
5235
|
+
technical && note2.detail && /* @__PURE__ */ jsx("p", { className: "mt-0.5 font-mono text-[10px]", children: note2.detail })
|
|
5236
|
+
] }, note2.id))
|
|
5237
|
+
] })
|
|
5238
|
+
] }),
|
|
5239
|
+
node.exits.length > 0 && /* @__PURE__ */ jsxs("section", { className: "space-y-2", children: [
|
|
5240
|
+
/* @__PURE__ */ jsx("h3", { className: "text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: "Issues possibles" }),
|
|
5241
|
+
/* @__PURE__ */ jsx("ul", { className: "space-y-1", children: node.exits.map((exit) => /* @__PURE__ */ jsxs("li", { className: "flex items-baseline gap-2 text-xs", children: [
|
|
5242
|
+
/* @__PURE__ */ jsx(
|
|
5243
|
+
"span",
|
|
5244
|
+
{
|
|
5245
|
+
className: cn(
|
|
5246
|
+
"rounded-md border px-1.5 py-0.5 leading-tight",
|
|
5247
|
+
EXIT_TONE_CLASSES[exit.tone]
|
|
5248
|
+
),
|
|
5249
|
+
children: outcomeLabel(exit.outcome)
|
|
5250
|
+
}
|
|
5251
|
+
),
|
|
5252
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: exit.condition })
|
|
5253
|
+
] }, exit.key)) })
|
|
5254
|
+
] }),
|
|
5255
|
+
href && /* @__PURE__ */ jsx(
|
|
5256
|
+
Link,
|
|
5257
|
+
{
|
|
5258
|
+
href,
|
|
5259
|
+
className: cn(buttonVariants({ variant: "default", size: "sm" }), "no-underline"),
|
|
5260
|
+
children: "Ouvrir le r\xE9glage"
|
|
5261
|
+
}
|
|
5262
|
+
)
|
|
5263
|
+
]
|
|
5264
|
+
}
|
|
5265
|
+
)
|
|
4626
5266
|
}
|
|
4627
5267
|
);
|
|
4628
5268
|
}
|
|
4629
5269
|
function GraphCanvasPage() {
|
|
4630
5270
|
const { appSlug } = useAppContext();
|
|
4631
|
-
const {
|
|
5271
|
+
const { value: viewParam, setValue: setViewParam } = useQueryParam("vue");
|
|
5272
|
+
const technical = viewParam === "technique";
|
|
5273
|
+
const [openNode, setOpenNode] = useState(null);
|
|
5274
|
+
const {
|
|
5275
|
+
settings,
|
|
5276
|
+
isLoading: settingsLoading,
|
|
5277
|
+
error: settingsError
|
|
5278
|
+
} = useAppSettings();
|
|
4632
5279
|
const {
|
|
4633
5280
|
rows: categories,
|
|
4634
5281
|
isLoading: categoriesLoading,
|
|
4635
5282
|
error: categoriesError
|
|
4636
5283
|
} = useRecordList("category", { limit: CATEGORY_PAGE_SIZE }, toCategory);
|
|
4637
|
-
const
|
|
5284
|
+
const traffic = useGraphTraffic(TRAFFIC_WINDOW_DAYS);
|
|
5285
|
+
const hasCategoryWithAutoReply = useMemo(
|
|
5286
|
+
() => categories.some((c) => c.autoReplyEnabled),
|
|
5287
|
+
[categories]
|
|
5288
|
+
);
|
|
4638
5289
|
const categoriesMayBeTruncated = categories.length >= CATEGORY_PAGE_SIZE;
|
|
4639
5290
|
const result = useMemo(
|
|
4640
5291
|
() => settings ? computeGraphReachability(settings, hasCategoryWithAutoReply) : null,
|
|
@@ -4642,41 +5293,134 @@ function GraphCanvasPage() {
|
|
|
4642
5293
|
);
|
|
4643
5294
|
const isLoading = settingsLoading || categoriesLoading;
|
|
4644
5295
|
const isUnavailable = !isLoading && (settingsError !== void 0 || categoriesError !== void 0 || !result);
|
|
5296
|
+
const verdict = useMemo(() => result ? computeVerdict(result) : null, [result]);
|
|
5297
|
+
const selected = result?.nodes.find((node) => node.node === openNode) ?? null;
|
|
5298
|
+
const notesFor = (node) => result ? result.globalNotes.filter((note2) => note2.nodes.includes(node)) : [];
|
|
5299
|
+
const breakNode = result?.nodes.find((node) => node.state === "unreachable" && node.cause === "root")?.node ?? null;
|
|
5300
|
+
const rail = useMemo(() => {
|
|
5301
|
+
if (!result) return null;
|
|
5302
|
+
const rows = result.nodes.map((node, i) => /* @__PURE__ */ jsxs("div", { children: [
|
|
5303
|
+
i > 0 && /* @__PURE__ */ jsx(Connector, { into: node, isBreak: node.node === breakNode }),
|
|
5304
|
+
/* @__PURE__ */ jsx(
|
|
5305
|
+
NodeRow,
|
|
5306
|
+
{
|
|
5307
|
+
node,
|
|
5308
|
+
traffic: traffic.byNode[node.node],
|
|
5309
|
+
technical,
|
|
5310
|
+
globalNotes: result.globalNotes.filter((note2) => note2.nodes.includes(node.node)),
|
|
5311
|
+
onOpen: () => setOpenNode(node.node)
|
|
5312
|
+
}
|
|
5313
|
+
)
|
|
5314
|
+
] }, node.node));
|
|
5315
|
+
const from = result.nodes.findIndex((node) => node.node === "evaluate");
|
|
5316
|
+
const to = result.nodes.findIndex((node) => node.node === "revise");
|
|
5317
|
+
if (from < 0 || to <= from) return rows;
|
|
5318
|
+
return [
|
|
5319
|
+
...rows.slice(0, from),
|
|
5320
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
5321
|
+
/* @__PURE__ */ jsx(
|
|
5322
|
+
"div",
|
|
5323
|
+
{
|
|
5324
|
+
"aria-hidden": true,
|
|
5325
|
+
"data-testid": "graph-back-edge",
|
|
5326
|
+
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"
|
|
5327
|
+
}
|
|
5328
|
+
),
|
|
5329
|
+
/* @__PURE__ */ 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" }),
|
|
5330
|
+
rows.slice(from, to + 1)
|
|
5331
|
+
] }, "back-edge"),
|
|
5332
|
+
...rows.slice(to + 1)
|
|
5333
|
+
];
|
|
5334
|
+
}, [result, breakNode, traffic.byNode, technical]);
|
|
4645
5335
|
return /* @__PURE__ */ jsxs(PageShell, { children: [
|
|
4646
|
-
/* @__PURE__ */ jsx(
|
|
5336
|
+
/* @__PURE__ */ jsx(
|
|
5337
|
+
PageHeader,
|
|
5338
|
+
{
|
|
5339
|
+
title: "Graphe",
|
|
5340
|
+
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.",
|
|
5341
|
+
actions: /* @__PURE__ */ jsxs(
|
|
5342
|
+
"div",
|
|
5343
|
+
{
|
|
5344
|
+
className: "flex items-center rounded-md border p-0.5",
|
|
5345
|
+
role: "group",
|
|
5346
|
+
"aria-label": "Registre d'affichage",
|
|
5347
|
+
children: [
|
|
5348
|
+
/* @__PURE__ */ jsx(
|
|
5349
|
+
Button,
|
|
5350
|
+
{
|
|
5351
|
+
variant: technical ? "ghost" : "secondary",
|
|
5352
|
+
size: "sm",
|
|
5353
|
+
"aria-pressed": !technical,
|
|
5354
|
+
onClick: () => setViewParam(null),
|
|
5355
|
+
children: "Op\xE9rateur"
|
|
5356
|
+
}
|
|
5357
|
+
),
|
|
5358
|
+
/* @__PURE__ */ jsx(
|
|
5359
|
+
Button,
|
|
5360
|
+
{
|
|
5361
|
+
variant: technical ? "secondary" : "ghost",
|
|
5362
|
+
size: "sm",
|
|
5363
|
+
"aria-pressed": technical,
|
|
5364
|
+
onClick: () => setViewParam("technique"),
|
|
5365
|
+
children: "Technique"
|
|
5366
|
+
}
|
|
5367
|
+
)
|
|
5368
|
+
]
|
|
5369
|
+
}
|
|
5370
|
+
)
|
|
5371
|
+
}
|
|
5372
|
+
),
|
|
4647
5373
|
isLoading ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center py-12", children: [
|
|
4648
5374
|
/* @__PURE__ */ jsx(Spinner, {}),
|
|
4649
5375
|
" ",
|
|
4650
5376
|
/* @__PURE__ */ jsx("span", { className: "ml-2 text-sm text-muted-foreground", children: "Chargement\u2026" })
|
|
4651
5377
|
] }) : isUnavailable ? /* @__PURE__ */ 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__ */ jsxs(Fragment, { children: [
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
5378
|
+
/* @__PURE__ */ jsx(VerdictBanner, { verdict, appSlug }),
|
|
5379
|
+
result.globalNotes.map((note2) => /* @__PURE__ */ jsxs(
|
|
5380
|
+
"div",
|
|
5381
|
+
{
|
|
5382
|
+
"data-testid": `graph-global-note-${note2.id}`,
|
|
5383
|
+
className: "rounded-md border border-status-warning/40 bg-status-warning/10 p-3 text-sm text-status-warning",
|
|
5384
|
+
children: [
|
|
5385
|
+
/* @__PURE__ */ jsx("p", { children: note2.message }),
|
|
5386
|
+
/* @__PURE__ */ jsxs("p", { className: "mt-1 text-xs", children: [
|
|
5387
|
+
"N\u0153uds concern\xE9s (",
|
|
5388
|
+
note2.nodes.length,
|
|
5389
|
+
") :",
|
|
5390
|
+
" ",
|
|
5391
|
+
note2.nodes.map((n) => NODE_LABELS[n]).join(", "),
|
|
5392
|
+
"."
|
|
5393
|
+
] }),
|
|
5394
|
+
technical && note2.detail && /* @__PURE__ */ jsx("p", { className: "mt-1 font-mono text-[10px]", children: note2.detail })
|
|
5395
|
+
]
|
|
5396
|
+
},
|
|
5397
|
+
note2.id
|
|
5398
|
+
)),
|
|
4656
5399
|
!hasCategoryWithAutoReply && categoriesMayBeTruncated && /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
4657
5400
|
"La lecture des cat\xE9gories est born\xE9e aux ",
|
|
4658
5401
|
CATEGORY_PAGE_SIZE,
|
|
4659
5402
|
" 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."
|
|
4660
5403
|
] }),
|
|
4661
|
-
/* @__PURE__ */ jsx(
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
5404
|
+
/* @__PURE__ */ jsx(Legend, {}),
|
|
5405
|
+
/* @__PURE__ */ 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.` }),
|
|
5406
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-0 pl-10", children: rail }),
|
|
5407
|
+
/* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
5408
|
+
"\u21BA",
|
|
5409
|
+
" \xAB R\xE9vision \xBB rejoue \xAB \xC9valuation \xBB \u2014 au plus une passe par ticket",
|
|
5410
|
+
technical ? " (\xA73.3)" : "",
|
|
5411
|
+
"."
|
|
5412
|
+
] }),
|
|
5413
|
+
/* @__PURE__ */ jsx(
|
|
5414
|
+
NodeDetailPanel,
|
|
5415
|
+
{
|
|
5416
|
+
node: selected,
|
|
5417
|
+
traffic: selected ? traffic.byNode[selected.node] : void 0,
|
|
5418
|
+
technical,
|
|
5419
|
+
appSlug,
|
|
5420
|
+
globalNotes: selected ? notesFor(selected.node) : [],
|
|
5421
|
+
onClose: () => setOpenNode(null)
|
|
5422
|
+
}
|
|
5423
|
+
)
|
|
4680
5424
|
] })
|
|
4681
5425
|
] });
|
|
4682
5426
|
}
|
|
@@ -5392,31 +6136,6 @@ function TestPage() {
|
|
|
5392
6136
|
!canRun ? /* @__PURE__ */ 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__ */ jsx(TestControls, {})
|
|
5393
6137
|
] });
|
|
5394
6138
|
}
|
|
5395
|
-
function readParam(name) {
|
|
5396
|
-
if (typeof window === "undefined") return null;
|
|
5397
|
-
return new URLSearchParams(window.location.search).get(name);
|
|
5398
|
-
}
|
|
5399
|
-
function useQueryParam(name) {
|
|
5400
|
-
const [value, setState] = useState(() => readParam(name));
|
|
5401
|
-
useEffect(() => {
|
|
5402
|
-
const sync = () => setState(readParam(name));
|
|
5403
|
-
sync();
|
|
5404
|
-
window.addEventListener("popstate", sync);
|
|
5405
|
-
return () => window.removeEventListener("popstate", sync);
|
|
5406
|
-
}, [name]);
|
|
5407
|
-
const setValue = useCallback(
|
|
5408
|
-
(next) => {
|
|
5409
|
-
const params = new URLSearchParams(window.location.search);
|
|
5410
|
-
if (next === null) params.delete(name);
|
|
5411
|
-
else params.set(name, next);
|
|
5412
|
-
const query = params.toString();
|
|
5413
|
-
window.history.pushState({}, "", `${window.location.pathname}${query ? `?${query}` : ""}`);
|
|
5414
|
-
setState(next);
|
|
5415
|
-
},
|
|
5416
|
-
[name]
|
|
5417
|
-
);
|
|
5418
|
-
return { value, setValue };
|
|
5419
|
-
}
|
|
5420
6139
|
function ExperimentStatusBadge({ experiment }) {
|
|
5421
6140
|
if (experiment.status === "done" && experiment.succeeded) {
|
|
5422
6141
|
return /* @__PURE__ */ jsx(Badge, { variant: "success", children: "Termin\xE9" });
|