@apotech-os/support-kit 3.0.2 → 3.2.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 +1259 -313
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +1260 -315
- 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.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,
|
|
@@ -282,33 +283,110 @@ function formatDate(iso) {
|
|
|
282
283
|
function toNameMap(rows) {
|
|
283
284
|
return new Map(rows.map((r) => [r.id, r.name]));
|
|
284
285
|
}
|
|
285
|
-
function windowCutoffIso(days) {
|
|
286
|
-
return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString();
|
|
287
|
-
}
|
|
288
286
|
|
|
289
287
|
// src/ui/dashboard/dashboard-stats.ts
|
|
290
|
-
function sumCounts(rows, countField = "count") {
|
|
291
|
-
return rows.reduce((sum, row) => sum + (Number(row[countField]) || 0), 0);
|
|
292
|
-
}
|
|
293
|
-
function countFor(rows, groupField, value, countField = "count") {
|
|
294
|
-
const row = rows.find((r) => r[groupField] === value);
|
|
295
|
-
return row ? Number(row[countField]) || 0 : 0;
|
|
296
|
-
}
|
|
297
288
|
function bucketDay(row) {
|
|
298
289
|
return String(row["bucket"]).slice(0, 10);
|
|
299
290
|
}
|
|
300
|
-
|
|
291
|
+
var EMPTY_TOTALS = {
|
|
292
|
+
auto: 0,
|
|
293
|
+
human: 0,
|
|
294
|
+
inProgress: 0,
|
|
295
|
+
noReplyNeeded: 0,
|
|
296
|
+
failed: 0
|
|
297
|
+
};
|
|
298
|
+
function outcomeOf(status, autoSendDecision) {
|
|
299
|
+
if (status === "sent") return "auto";
|
|
300
|
+
if (status === "no_reply_needed") return "noReplyNeeded";
|
|
301
|
+
if (status === "failed") return "failed";
|
|
302
|
+
if (status === "invalidated" || status === "expired") return "human";
|
|
303
|
+
return autoSendDecision === "hold" ? "human" : "inProgress";
|
|
304
|
+
}
|
|
305
|
+
function foldOutcomes(rows) {
|
|
306
|
+
const totals = { ...EMPTY_TOTALS };
|
|
307
|
+
for (const row of rows) {
|
|
308
|
+
totals[outcomeOf(row["status"], row["autoSendDecision"])] += Number(row["count"]) || 0;
|
|
309
|
+
}
|
|
310
|
+
return totals;
|
|
311
|
+
}
|
|
312
|
+
function settledCount(totals) {
|
|
313
|
+
return totals.auto + totals.human;
|
|
314
|
+
}
|
|
315
|
+
function autonomyRate(totals) {
|
|
316
|
+
const settled = settledCount(totals);
|
|
317
|
+
return settled > 0 ? totals.auto / settled : Number.NaN;
|
|
318
|
+
}
|
|
319
|
+
function foldDailyOutcomes(rows) {
|
|
301
320
|
const byDay = /* @__PURE__ */ new Map();
|
|
302
|
-
for (const row of
|
|
321
|
+
for (const row of rows) {
|
|
303
322
|
const day = bucketDay(row);
|
|
304
|
-
|
|
323
|
+
const totals = byDay.get(day) ?? { ...EMPTY_TOTALS };
|
|
324
|
+
totals[outcomeOf(row["status"], row["autoSendDecision"])] += Number(row["count"]) || 0;
|
|
325
|
+
byDay.set(day, totals);
|
|
305
326
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
327
|
+
return [...byDay.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([day, totals]) => ({
|
|
328
|
+
day,
|
|
329
|
+
auto: totals.auto,
|
|
330
|
+
human: totals.human,
|
|
331
|
+
rate: settledCount(totals) > 0 ? autonomyRate(totals) : null
|
|
332
|
+
}));
|
|
333
|
+
}
|
|
334
|
+
function fillMissingDays(series, fromIso, toIso) {
|
|
335
|
+
const from = Date.parse(fromIso.slice(0, 10));
|
|
336
|
+
const to = Date.parse(toIso.slice(0, 10));
|
|
337
|
+
if (Number.isNaN(from) || Number.isNaN(to) || to < from) return series;
|
|
338
|
+
const measured = new Map(series.map((point) => [point.day, point]));
|
|
339
|
+
const filled = [];
|
|
340
|
+
for (let t = from; t <= to; t += 864e5) {
|
|
341
|
+
const day = new Date(t).toISOString().slice(0, 10);
|
|
342
|
+
filled.push(measured.get(day) ?? { day, auto: 0, human: 0, rate: null });
|
|
343
|
+
}
|
|
344
|
+
return filled;
|
|
345
|
+
}
|
|
346
|
+
function ratePoints(rate, compareRate) {
|
|
347
|
+
return Number.isNaN(rate) || Number.isNaN(compareRate) ? null : (rate - compareRate) * 100;
|
|
348
|
+
}
|
|
349
|
+
var SIGNAL_MIN_VOLUME = 20;
|
|
350
|
+
var SIGNAL_MIN_POINTS = 3;
|
|
351
|
+
function dashboardSignals(totals, compare) {
|
|
352
|
+
const signals = [];
|
|
353
|
+
const settled = settledCount(totals);
|
|
354
|
+
const rate = autonomyRate(totals);
|
|
355
|
+
if (compare !== null && settled >= SIGNAL_MIN_VOLUME && settledCount(compare) >= SIGNAL_MIN_VOLUME) {
|
|
356
|
+
const points = ratePoints(rate, autonomyRate(compare));
|
|
357
|
+
if (points !== null && Math.abs(points) >= SIGNAL_MIN_POINTS) {
|
|
358
|
+
const move = points < 0 ? "recule" : "progresse";
|
|
359
|
+
signals.push({
|
|
360
|
+
level: points < 0 ? "creuser" : "info",
|
|
361
|
+
text: `Le taux d\u2019autonomie ${move} de ${Math.abs(Math.round(points))} points par rapport \xE0 la p\xE9riode pr\xE9c\xE9dente.`
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
if (totals.failed > 0) {
|
|
366
|
+
signals.push({
|
|
367
|
+
level: "creuser",
|
|
368
|
+
text: `${totals.failed} g\xE9n\xE9ration${totals.failed > 1 ? "s ont" : " a"} \xE9chou\xE9 techniquement : ${totals.failed > 1 ? "ces demandes n\u2019ont" : "cette demande n\u2019a"} jamais eu de brouillon.`
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
if (totals.inProgress > 0) {
|
|
372
|
+
signals.push({
|
|
373
|
+
level: "info",
|
|
374
|
+
text: `${totals.inProgress} r\xE9ponse${totals.inProgress > 1 ? "s sont" : " est"} encore en cours : ${totals.inProgress > 1 ? "elles ne comptent" : "elle ne compte"} dans aucun des deux camps.`
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
if (totals.noReplyNeeded > 0) {
|
|
378
|
+
signals.push({
|
|
379
|
+
level: "info",
|
|
380
|
+
text: `${totals.noReplyNeeded} demande${totals.noReplyNeeded > 1 ? "s" : ""} ne n\xE9cessitai${totals.noReplyNeeded > 1 ? "ent" : "t"} aucune r\xE9ponse : hors du taux d\u2019autonomie.`
|
|
381
|
+
});
|
|
310
382
|
}
|
|
311
|
-
|
|
383
|
+
if (compare !== null && settled > 0 && settledCount(compare) < SIGNAL_MIN_VOLUME) {
|
|
384
|
+
signals.push({
|
|
385
|
+
level: "info",
|
|
386
|
+
text: "La p\xE9riode pr\xE9c\xE9dente compte trop peu de demandes r\xE9gl\xE9es pour que la comparaison veuille dire quelque chose."
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
return signals;
|
|
312
390
|
}
|
|
313
391
|
var DEFAULT_TOP_N = 6;
|
|
314
392
|
function foldCategoryBreakdown(rows, categoryNames, topN = DEFAULT_TOP_N) {
|
|
@@ -321,189 +399,361 @@ function foldCategoryBreakdown(rows, categoryNames, topN = DEFAULT_TOP_N) {
|
|
|
321
399
|
const tail = measured.slice(topN).reduce((sum, bar) => sum + bar.value, 0);
|
|
322
400
|
return [...measured.slice(0, topN), { label: "Autres", value: tail }];
|
|
323
401
|
}
|
|
324
|
-
var
|
|
325
|
-
|
|
402
|
+
var POINTS_FORMAT = new Intl.NumberFormat("fr-FR", {
|
|
403
|
+
maximumFractionDigits: 1,
|
|
404
|
+
signDisplay: "exceptZero"
|
|
405
|
+
});
|
|
326
406
|
function formatRate(value) {
|
|
327
|
-
return Number.isNaN(value) ? "\u2014" : `${Math.round(value * 100)}%`;
|
|
407
|
+
return Number.isNaN(value) ? "\u2014" : `${Math.round(value * 100)} %`;
|
|
328
408
|
}
|
|
329
|
-
function
|
|
330
|
-
|
|
409
|
+
function AutonomyHero({
|
|
410
|
+
rate,
|
|
411
|
+
compareRate,
|
|
412
|
+
caption
|
|
413
|
+
}) {
|
|
414
|
+
const points = ratePoints(rate, compareRate);
|
|
415
|
+
return /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Card, { className: "border-primary/25 bg-gradient-to-br from-primary/10 via-card to-card", children: /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.CardContent, { className: "space-y-1 p-4", children: [
|
|
416
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "flex items-center gap-2 text-[11px] font-semibold uppercase tracking-[0.06em] text-muted-foreground", children: [
|
|
417
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": true, className: "inline-block size-2 rounded-full bg-primary" }),
|
|
418
|
+
"Taux d\u2019autonomie"
|
|
419
|
+
] }),
|
|
420
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-4xl font-semibold leading-tight tabular-nums text-foreground", children: formatRate(rate) }),
|
|
421
|
+
points !== null && // Direction is in the sign as well as the colour — `KpiCard`'s own
|
|
422
|
+
// rule, restated here because this card does not go through it.
|
|
423
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
424
|
+
"p",
|
|
425
|
+
{
|
|
426
|
+
className: `text-xs font-semibold tabular-nums ${points < 0 ? "text-status-blocked" : "text-status-success"}`,
|
|
427
|
+
children: [
|
|
428
|
+
POINTS_FORMAT.format(points),
|
|
429
|
+
" pts",
|
|
430
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ml-1 font-normal text-muted-foreground", children: [
|
|
431
|
+
"vs ",
|
|
432
|
+
formatRate(compareRate)
|
|
433
|
+
] })
|
|
434
|
+
]
|
|
435
|
+
}
|
|
436
|
+
),
|
|
437
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "pt-1 text-xs text-muted-foreground", children: caption })
|
|
438
|
+
] }) });
|
|
439
|
+
}
|
|
440
|
+
var DASHBOARD_PRESETS = [
|
|
441
|
+
{ key: "last7", label: "7 derniers jours" },
|
|
442
|
+
{ key: "last30", label: "30 derniers jours" }
|
|
443
|
+
];
|
|
444
|
+
var WEEKLY_BUCKET_FROM_DAYS = 46;
|
|
445
|
+
var DAY_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
|
|
446
|
+
var EPOCH_ISO = "1970-01-01T00:00:00.000Z";
|
|
447
|
+
function startOfDayIso(day) {
|
|
448
|
+
return day !== void 0 && DAY_PATTERN.test(day) ? `${day}T00:00:00.000Z` : EPOCH_ISO;
|
|
449
|
+
}
|
|
450
|
+
function endOfDayIso(day) {
|
|
451
|
+
return DAY_PATTERN.test(day) ? `${day}T23:59:59.999Z` : (/* @__PURE__ */ new Date()).toISOString();
|
|
452
|
+
}
|
|
453
|
+
function dayCount(bounds) {
|
|
454
|
+
const from = Date.parse(bounds.fromIso);
|
|
455
|
+
const to = Date.parse(bounds.toIso);
|
|
456
|
+
if (Number.isNaN(from) || Number.isNaN(to)) return 0;
|
|
457
|
+
return Math.max(1, Math.round((to - from) / 864e5));
|
|
458
|
+
}
|
|
459
|
+
function periodBoundsOf(value) {
|
|
460
|
+
const current = {
|
|
461
|
+
fromIso: startOfDayIso(value.range.from),
|
|
462
|
+
toIso: endOfDayIso(value.range.to)
|
|
463
|
+
};
|
|
464
|
+
const compare = value.compare === "none" ? void 0 : value.compareRange ?? uiSdk.comparisonRange(value.preset, value.range, value.compare);
|
|
465
|
+
const days = dayCount(current);
|
|
466
|
+
return {
|
|
467
|
+
current,
|
|
468
|
+
previous: compare === void 0 ? null : { fromIso: startOfDayIso(compare.from), toIso: endOfDayIso(compare.to) },
|
|
469
|
+
days,
|
|
470
|
+
interval: days >= WEEKLY_BUCKET_FROM_DAYS ? "week" : "day"
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
function defaultPeriod(today = /* @__PURE__ */ new Date()) {
|
|
474
|
+
const to = today.toISOString().slice(0, 10);
|
|
475
|
+
const start = new Date(today);
|
|
476
|
+
start.setUTCDate(start.getUTCDate() - 29);
|
|
477
|
+
const range = { from: start.toISOString().slice(0, 10), to };
|
|
478
|
+
const compareRange = uiSdk.comparisonRange("last30", range, "previous_period");
|
|
479
|
+
return {
|
|
480
|
+
preset: "last30",
|
|
481
|
+
range,
|
|
482
|
+
compare: "previous_period",
|
|
483
|
+
...compareRange === void 0 ? {} : { compareRange }
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
var OUTCOME_METRICS = [{ op: "count", as: "count" }];
|
|
487
|
+
var OUTCOME_GROUP_BY = ["status", "autoSendDecision"];
|
|
488
|
+
function formatCount(value) {
|
|
489
|
+
return Number.isNaN(value) ? "\u2026" : value.toLocaleString("fr-FR");
|
|
331
490
|
}
|
|
332
|
-
function
|
|
333
|
-
|
|
491
|
+
function dayLabel(day) {
|
|
492
|
+
const parsed = /* @__PURE__ */ new Date(`${day}T00:00:00.000Z`);
|
|
493
|
+
return Number.isNaN(parsed.getTime()) ? day : parsed.toLocaleDateString("fr-FR", { day: "2-digit", month: "2-digit", timeZone: "UTC" });
|
|
334
494
|
}
|
|
335
495
|
function DashboardPage() {
|
|
336
496
|
const { appSlug } = uiSdk.useAppContext();
|
|
337
|
-
const [
|
|
338
|
-
const { settings
|
|
497
|
+
const [period, setPeriod] = react.useState(() => defaultPeriod());
|
|
498
|
+
const { settings } = uiSdk.useAppSettings();
|
|
339
499
|
const timezone = settings?.statsTimezone ?? "UTC";
|
|
340
|
-
const
|
|
341
|
-
const
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
500
|
+
const periodKey = JSON.stringify(period);
|
|
501
|
+
const bounds = react.useMemo(() => periodBoundsOf(JSON.parse(periodKey)), [periodKey]);
|
|
502
|
+
const currentFilter = { generatedAt: { gte: bounds.current.fromIso, lte: bounds.current.toIso } };
|
|
503
|
+
const previousBounds = bounds.previous ?? bounds.current;
|
|
504
|
+
const {
|
|
505
|
+
rows: dailyRows,
|
|
506
|
+
isLoading: dailyLoading,
|
|
507
|
+
error: dailyError
|
|
508
|
+
} = useAggregate("generated-response", {
|
|
509
|
+
filter: currentFilter,
|
|
510
|
+
groupBy: OUTCOME_GROUP_BY,
|
|
511
|
+
bucket: { field: "generatedAt", interval: bounds.interval, tz: timezone },
|
|
512
|
+
metrics: OUTCOME_METRICS
|
|
350
513
|
});
|
|
351
|
-
const { rows:
|
|
352
|
-
filter: {
|
|
353
|
-
|
|
514
|
+
const { rows: previousRows, isLoading: previousLoading } = useAggregate("generated-response", {
|
|
515
|
+
filter: { generatedAt: { gte: previousBounds.fromIso, lte: previousBounds.toIso } },
|
|
516
|
+
groupBy: OUTCOME_GROUP_BY,
|
|
517
|
+
metrics: OUTCOME_METRICS
|
|
354
518
|
});
|
|
355
|
-
const {
|
|
356
|
-
|
|
519
|
+
const {
|
|
520
|
+
rows: categoryCounts,
|
|
521
|
+
isLoading: categoryLoading,
|
|
522
|
+
error: categoryError
|
|
523
|
+
} = useAggregate("triage-decision", {
|
|
524
|
+
filter: { decidedAt: { gte: bounds.current.fromIso, lte: bounds.current.toIso } },
|
|
357
525
|
groupBy: ["categoryId"],
|
|
358
|
-
metrics:
|
|
359
|
-
});
|
|
360
|
-
const { rows: dailySent, error: dailySentError } = useAggregate("generated-response", {
|
|
361
|
-
filter: { generatedAt: { gte: cutoffIso }, status: { eq: "sent" } },
|
|
362
|
-
bucket: { field: "generatedAt", interval: "day", tz: timezone },
|
|
363
|
-
metrics: [{ op: "count", as: "count" }]
|
|
364
|
-
});
|
|
365
|
-
const { rows: dailyHeld, error: dailyHeldError } = useAggregate("generated-response", {
|
|
366
|
-
filter: { generatedAt: { gte: cutoffIso }, autoSendDecision: { eq: "hold" } },
|
|
367
|
-
bucket: { field: "generatedAt", interval: "day", tz: timezone },
|
|
368
|
-
metrics: [{ op: "count", as: "count" }]
|
|
526
|
+
metrics: OUTCOME_METRICS
|
|
369
527
|
});
|
|
370
|
-
const dailySeriesError = dailySentError !== void 0 || dailyHeldError !== void 0;
|
|
371
528
|
const { rows: categories } = useRecordList("category", { limit: 500 }, toCategory);
|
|
372
529
|
const categoryNames = react.useMemo(() => toNameMap(categories), [categories]);
|
|
373
|
-
const
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
} = useRecordList(
|
|
378
|
-
"triage-decision",
|
|
379
|
-
{ sort: [{ field: "decidedAt", direction: "desc" }], limit: RECENT_ACTIVITY_LIMIT },
|
|
380
|
-
toTriageDecision
|
|
530
|
+
const totals = react.useMemo(() => foldOutcomes(dailyRows), [dailyRows]);
|
|
531
|
+
const compareTotals = react.useMemo(
|
|
532
|
+
() => bounds.previous === null ? null : foldOutcomes(previousRows),
|
|
533
|
+
[bounds.previous, previousRows]
|
|
381
534
|
);
|
|
382
|
-
const
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
535
|
+
const daily = react.useMemo(() => {
|
|
536
|
+
const folded = foldDailyOutcomes(dailyRows);
|
|
537
|
+
return bounds.interval === "day" ? fillMissingDays(folded, bounds.current.fromIso, bounds.current.toIso) : folded;
|
|
538
|
+
}, [dailyRows, bounds]);
|
|
539
|
+
const rate = autonomyRate(totals);
|
|
540
|
+
const compareRate = compareTotals === null ? Number.NaN : autonomyRate(compareTotals);
|
|
541
|
+
const settled = settledCount(totals);
|
|
542
|
+
const signals = react.useMemo(() => dashboardSignals(totals, compareTotals), [totals, compareTotals]);
|
|
386
543
|
const categoryBars = foldCategoryBreakdown(categoryCounts, categoryNames);
|
|
387
|
-
const
|
|
388
|
-
const
|
|
389
|
-
const
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Card, { children: /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.CardContent, { className: "space-y-1 p-4", children: [
|
|
401
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Escalades" }),
|
|
402
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium", children: escalatedLoading ? "\u2026" : escalatedError ? "Indisponible" : `${escalatedTotal} au total` })
|
|
403
|
-
] }) })
|
|
404
|
-
] }) })
|
|
405
|
-
] });
|
|
406
|
-
const columns = [
|
|
407
|
-
{ key: "ticketId", header: "Ticket", cell: (row) => row.ticketId },
|
|
408
|
-
{ key: "category", header: "Cat\xE9gorie", cell: (row) => row.categoryId && categoryNames.get(row.categoryId) || "\u2014" },
|
|
409
|
-
{
|
|
410
|
-
key: "escalated",
|
|
411
|
-
header: "Escalade",
|
|
412
|
-
cell: (row) => row.escalated ? /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: "warning", children: "Escalad\xE9" }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "Non escalad\xE9" })
|
|
413
|
-
},
|
|
414
|
-
{ key: "decidedAt", header: "Date", cell: (row) => formatDate(row.decidedAt) }
|
|
415
|
-
];
|
|
544
|
+
const loading = dailyLoading || previousLoading;
|
|
545
|
+
const chartData = daily.map((point) => ({ ...point, jour: dayLabel(point.day) }));
|
|
546
|
+
const bucketWord = bounds.interval === "day" ? "jour" : "semaine";
|
|
547
|
+
const aCreuser = signals.find((signal) => signal.level === "creuser");
|
|
548
|
+
const lead = loading ? null : settled === 0 ? {
|
|
549
|
+
alert: false,
|
|
550
|
+
title: "Aucune demande r\xE9gl\xE9e sur cette p\xE9riode",
|
|
551
|
+
detail: "Choisis une autre p\xE9riode, ou v\xE9rifie que le triage tourne (Param\xE8tres \u203A Triage)."
|
|
552
|
+
} : aCreuser !== void 0 ? { alert: true, title: "Un point m\xE9rite ton attention", detail: aCreuser.text } : {
|
|
553
|
+
alert: false,
|
|
554
|
+
title: `${formatRate(rate)} des demandes r\xE9gl\xE9es sans personne`,
|
|
555
|
+
detail: `${formatCount(totals.auto)} r\xE9ponses envoy\xE9es par l\u2019IA, ${formatCount(totals.human)} reprises par un humain, sur ${formatCount(settled)} demandes r\xE9gl\xE9es.`
|
|
556
|
+
};
|
|
416
557
|
return /* @__PURE__ */ jsxRuntime.jsxs(PageShell, { children: [
|
|
417
558
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
418
559
|
PageHeader,
|
|
419
560
|
{
|
|
420
561
|
title: "Tableau de bord",
|
|
421
|
-
description: "
|
|
422
|
-
actions: /* @__PURE__ */ jsxRuntime.
|
|
423
|
-
/* @__PURE__ */ jsxRuntime.
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
562
|
+
description: "Ce que l\u2019IA a r\xE9gl\xE9 seule sur la p\xE9riode, et ce qui est retomb\xE9 sur un humain.",
|
|
563
|
+
actions: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
564
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
565
|
+
uiSdk.DateRangeCompare,
|
|
566
|
+
{
|
|
567
|
+
value: period,
|
|
568
|
+
onChange: setPeriod,
|
|
569
|
+
comparable: true,
|
|
570
|
+
presets: DASHBOARD_PRESETS,
|
|
571
|
+
align: "end"
|
|
572
|
+
}
|
|
573
|
+
),
|
|
430
574
|
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Link, { href: `/espace/${appSlug}/pipeline`, children: "Voir le pipeline complet" })
|
|
431
|
-
] })
|
|
575
|
+
] })
|
|
432
576
|
}
|
|
433
577
|
),
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
437
|
-
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.KpiCard, { label: "G\xE9n\xE9r\xE9", value: statusLoading ? Number.NaN : totalGenerated, formatValue: (v) => Number.isNaN(v) ? "\u2026" : String(v) }),
|
|
438
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 px-1 text-xs text-muted-foreground", children: "R\xE9ponses g\xE9n\xE9r\xE9es sur la fen\xEAtre choisie, tous statuts confondus (en attente, envoy\xE9es, \xE9chou\xE9es\u2026)." })
|
|
439
|
-
] }),
|
|
440
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
441
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
442
|
-
uiSdk.KpiCard,
|
|
443
|
-
{
|
|
444
|
-
label: "Taux d'envoi auto",
|
|
445
|
-
value: statusLoading || autoSendLoading ? Number.NaN : rateOrNaN(sentCount, totalGenerated),
|
|
446
|
-
formatValue: formatRate
|
|
447
|
-
}
|
|
448
|
-
),
|
|
449
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 px-1 text-xs text-muted-foreground", children: "Part des r\xE9ponses g\xE9n\xE9r\xE9es sur la fen\xEAtre dont le statut est \xAB Envoy\xE9e \xBB." })
|
|
450
|
-
] }),
|
|
578
|
+
lead !== null && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Card, { children: /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.CardContent, { className: "flex items-start gap-3 p-4", children: [
|
|
579
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: lead.alert ? "warning" : "brand", children: lead.alert ? "\xC0 creuser" : "Cap" }),
|
|
451
580
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
452
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
453
|
-
|
|
454
|
-
{
|
|
455
|
-
label: "Taux de blocage",
|
|
456
|
-
value: statusLoading || autoSendLoading ? Number.NaN : rateOrNaN(heldCount, totalGenerated),
|
|
457
|
-
formatValue: formatRate,
|
|
458
|
-
lowerIsBetter: true
|
|
459
|
-
}
|
|
460
|
-
),
|
|
461
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 px-1 text-xs text-muted-foreground", children: "Part des r\xE9ponses g\xE9n\xE9r\xE9es sur la fen\xEAtre que la politique d'envoi a retenues (\xE9tat \xAB Bloqu\xE9 \xBB)." })
|
|
581
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-base font-semibold leading-snug", children: lead.title }),
|
|
582
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm leading-relaxed text-muted-foreground", children: lead.detail })
|
|
462
583
|
] })
|
|
463
|
-
] }),
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
584
|
+
] }) }),
|
|
585
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
586
|
+
"div",
|
|
587
|
+
{
|
|
588
|
+
"data-testid": "dashboard-kpis",
|
|
589
|
+
className: "grid grid-cols-1 gap-4 sm:grid-cols-[1.3fr_1fr_1fr]",
|
|
590
|
+
children: [
|
|
591
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
592
|
+
AutonomyHero,
|
|
593
|
+
{
|
|
594
|
+
rate: loading ? Number.NaN : rate,
|
|
595
|
+
compareRate,
|
|
596
|
+
caption: loading ? "Calcul en cours\u2026" : `${formatCount(totals.auto)} r\xE9gl\xE9es par l\u2019IA sur ${formatCount(settled)} demandes r\xE9gl\xE9es.`
|
|
597
|
+
}
|
|
598
|
+
),
|
|
599
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
600
|
+
uiSdk.KpiCard,
|
|
601
|
+
{
|
|
602
|
+
label: "R\xE9gl\xE9 par l\u2019IA",
|
|
603
|
+
value: loading ? Number.NaN : totals.auto,
|
|
604
|
+
...compareTotals === null ? {} : { compareValue: compareTotals.auto },
|
|
605
|
+
formatValue: formatCount
|
|
606
|
+
}
|
|
607
|
+
),
|
|
608
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
609
|
+
uiSdk.KpiCard,
|
|
610
|
+
{
|
|
611
|
+
label: "Repris par un humain",
|
|
612
|
+
value: loading ? Number.NaN : totals.human,
|
|
613
|
+
...compareTotals === null ? {} : { compareValue: compareTotals.human },
|
|
614
|
+
formatValue: formatCount,
|
|
615
|
+
lowerIsBetter: true
|
|
616
|
+
}
|
|
617
|
+
)
|
|
618
|
+
]
|
|
619
|
+
}
|
|
620
|
+
),
|
|
621
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-3", children: [
|
|
622
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
623
|
+
uiSdk.KpiCard,
|
|
624
|
+
{
|
|
625
|
+
label: "Encore en cours",
|
|
626
|
+
value: loading ? Number.NaN : totals.inProgress,
|
|
627
|
+
formatValue: formatCount
|
|
628
|
+
}
|
|
629
|
+
),
|
|
630
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
631
|
+
uiSdk.KpiCard,
|
|
632
|
+
{
|
|
633
|
+
label: "Sans r\xE9ponse n\xE9cessaire",
|
|
634
|
+
value: loading ? Number.NaN : totals.noReplyNeeded,
|
|
635
|
+
formatValue: formatCount
|
|
636
|
+
}
|
|
637
|
+
),
|
|
492
638
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
493
|
-
uiSdk.
|
|
639
|
+
uiSdk.KpiCard,
|
|
494
640
|
{
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
error: activityError ? "Erreur lors du chargement de l\u2019activit\xE9 r\xE9cente." : void 0,
|
|
501
|
-
empty: "Aucune d\xE9cision de triage enregistr\xE9e pour l\u2019instant."
|
|
641
|
+
label: "\xC9checs techniques",
|
|
642
|
+
value: loading ? Number.NaN : totals.failed,
|
|
643
|
+
...compareTotals === null ? {} : { compareValue: compareTotals.failed },
|
|
644
|
+
formatValue: formatCount,
|
|
645
|
+
lowerIsBetter: true
|
|
502
646
|
}
|
|
503
647
|
)
|
|
648
|
+
] }),
|
|
649
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs leading-relaxed text-muted-foreground", children: "Le taux d\u2019autonomie rapporte les r\xE9ponses envoy\xE9es par l\u2019IA \xE0 ces m\xEAmes r\xE9ponses plus celles qu\u2019un humain a reprises \u2014 bloqu\xE9es, escalad\xE9es, invalid\xE9es parce qu\u2019un agent avait d\xE9j\xE0 r\xE9pondu, ou expir\xE9es. \xB7 Une escalade est compt\xE9e UNE fois, du c\xF4t\xE9 humain : c\u2019est un motif de blocage, pas un camp de plus. \xB7 Les demandes encore en cours, celles sans r\xE9ponse n\xE9cessaire et les \xE9checs techniques sont hors du taux \u2014 les compter d\u2019un c\xF4t\xE9 ou de l\u2019autre le fausserait dans les deux sens. \xB7 Le d\xE9nominateur ne couvre que les demandes mises en file : un ticket escalad\xE9 avant toute g\xE9n\xE9ration n\u2019y figure pas." }),
|
|
650
|
+
dailyError !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive", children: "Erreur lors du calcul des chiffres cl\xE9s." }),
|
|
651
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-4 lg:grid-cols-2", children: [
|
|
652
|
+
/* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Card, { children: [
|
|
653
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.CardTitle, { className: "text-sm", children: [
|
|
654
|
+
"Automatique ou humain, ",
|
|
655
|
+
bucketWord,
|
|
656
|
+
" par ",
|
|
657
|
+
bucketWord
|
|
658
|
+
] }) }),
|
|
659
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardContent, { children: dailyError !== void 0 ? /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-destructive", children: [
|
|
660
|
+
"Impossible de calculer l\u2019\xE9volution par ",
|
|
661
|
+
bucketWord,
|
|
662
|
+
"."
|
|
663
|
+
] }) : chartData.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Aucune journ\xE9e mesur\xE9e sur cette p\xE9riode." }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
664
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-1 text-xs font-medium uppercase tracking-widest text-muted-foreground", children: "Part r\xE9gl\xE9e par l\u2019IA" }),
|
|
665
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
666
|
+
uiSdk.AreaChart,
|
|
667
|
+
{
|
|
668
|
+
data: chartData,
|
|
669
|
+
x: "jour",
|
|
670
|
+
series: [{ key: "rate", label: "Taux d\u2019autonomie" }],
|
|
671
|
+
formatValue: formatRate,
|
|
672
|
+
height: 150,
|
|
673
|
+
hideLegend: true
|
|
674
|
+
}
|
|
675
|
+
),
|
|
676
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-1 mt-4 text-xs font-medium uppercase tracking-widest text-muted-foreground", children: "Demandes r\xE9gl\xE9es, en volume" }),
|
|
677
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
678
|
+
uiSdk.StackedBarChart,
|
|
679
|
+
{
|
|
680
|
+
data: chartData,
|
|
681
|
+
x: "jour",
|
|
682
|
+
label: `Demandes r\xE9gl\xE9es par ${bucketWord}`,
|
|
683
|
+
series: [
|
|
684
|
+
{ key: "auto", label: "R\xE9gl\xE9 par l\u2019IA", colorIndex: 0 },
|
|
685
|
+
{ key: "human", label: "Repris par un humain", colorIndex: 1 }
|
|
686
|
+
],
|
|
687
|
+
formatValue: formatCount,
|
|
688
|
+
height: 150
|
|
689
|
+
}
|
|
690
|
+
),
|
|
691
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "mt-3 text-xs leading-relaxed text-muted-foreground", children: [
|
|
692
|
+
"La courbe est la ",
|
|
693
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: "part" }),
|
|
694
|
+
" r\xE9gl\xE9e sans personne ; les barres sont le",
|
|
695
|
+
" ",
|
|
696
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: "volume" }),
|
|
697
|
+
" qu\u2019elle recouvre. Un ",
|
|
698
|
+
bucketWord,
|
|
699
|
+
" \xE0 100 % sur deux demandes n\u2019est pas la m\xEAme nouvelle qu\u2019un ",
|
|
700
|
+
bucketWord,
|
|
701
|
+
" \xE0 80 % sur deux cents."
|
|
702
|
+
] }),
|
|
703
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "mt-1 text-xs leading-relaxed text-muted-foreground", children: [
|
|
704
|
+
"Un trou dans la courbe veut dire \xAB rien de r\xE9gl\xE9 ce ",
|
|
705
|
+
bucketWord,
|
|
706
|
+
"-l\xE0 \xBB, jamais \xAB 0 % \xBB : sans d\xE9nominateur, il n\u2019y a pas de taux \xE0 tracer."
|
|
707
|
+
] })
|
|
708
|
+
] }) })
|
|
709
|
+
] }),
|
|
710
|
+
/* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Card, { children: [
|
|
711
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardTitle, { className: "text-sm", children: "R\xE9partition par cat\xE9gorie" }) }),
|
|
712
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardContent, { children: categoryLoading ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Chargement\u2026" }) : categoryError !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive", children: "Impossible de calculer la r\xE9partition par cat\xE9gorie." }) : categoryBars.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Aucun volume calcul\xE9 pour l'instant sur cette p\xE9riode." }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
713
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
714
|
+
uiSdk.BarChart,
|
|
715
|
+
{
|
|
716
|
+
data: categoryBars,
|
|
717
|
+
x: "label",
|
|
718
|
+
series: [{ key: "value", label: "Volume", colorIndex: 0 }]
|
|
719
|
+
}
|
|
720
|
+
),
|
|
721
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-3 text-xs leading-relaxed text-muted-foreground", children: "Les d\xE9cisions de triage de la p\xE9riode, par cat\xE9gorie \u2014 le volume qui entre, avant toute id\xE9e de qui l\u2019a r\xE9gl\xE9." })
|
|
722
|
+
] }) })
|
|
723
|
+
] })
|
|
724
|
+
] }),
|
|
725
|
+
/* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Card, { children: [
|
|
726
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardTitle, { className: "text-sm", children: "Signaux \xE0 surveiller" }) }),
|
|
727
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardContent, { children: signals.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Rien de notable sur cette p\xE9riode \u2014 ou pas assez de demandes r\xE9gl\xE9es pour qu\u2019une comparaison veuille dire quelque chose." }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-3", children: signals.map((signal) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-3", children: [
|
|
728
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: signal.level === "creuser" ? "warning" : "neutral", children: signal.level === "creuser" ? "\xC0 creuser" : "Info" }),
|
|
729
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm leading-relaxed", children: signal.text })
|
|
730
|
+
] }, signal.text)) }) })
|
|
504
731
|
] })
|
|
505
732
|
] });
|
|
506
733
|
}
|
|
734
|
+
function isHttpUrl(url) {
|
|
735
|
+
try {
|
|
736
|
+
const { protocol } = new URL(url);
|
|
737
|
+
return protocol === "http:" || protocol === "https:";
|
|
738
|
+
} catch {
|
|
739
|
+
return false;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
function TicketLink({ ticketId, url, label }) {
|
|
743
|
+
if (!url || !isHttpUrl(url)) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: label ?? ticketId });
|
|
744
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
745
|
+
uiSdk.Link,
|
|
746
|
+
{
|
|
747
|
+
href: url,
|
|
748
|
+
target: "_blank",
|
|
749
|
+
rel: "noopener noreferrer",
|
|
750
|
+
className: "font-medium",
|
|
751
|
+
title: "Ouvrir le ticket dans Gorgias",
|
|
752
|
+
onClick: (event) => event.stopPropagation(),
|
|
753
|
+
children: label ?? ticketId
|
|
754
|
+
}
|
|
755
|
+
);
|
|
756
|
+
}
|
|
507
757
|
var UNCONFIGURED = { baseUrl: null, projectId: null };
|
|
508
758
|
function useLangfuseConfig() {
|
|
509
759
|
const { appSlug } = uiSdk.useAppContext();
|
|
@@ -720,6 +970,7 @@ function DetailPanel({
|
|
|
720
970
|
onClose
|
|
721
971
|
}) {
|
|
722
972
|
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: [
|
|
973
|
+
decision.ticketUrl && /* @__PURE__ */ jsxRuntime.jsx("p", { children: /* @__PURE__ */ jsxRuntime.jsx(TicketLink, { ticketId: decision.ticketId, url: decision.ticketUrl, label: "Ouvrir le ticket dans Gorgias" }) }),
|
|
723
974
|
decision.status === "error" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-md bg-destructive/10 p-3 text-destructive", children: [
|
|
724
975
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs font-semibold uppercase tracking-wider", children: TRIAGE_DECISION_STATUS_LABELS.error }),
|
|
725
976
|
decision.error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-xs", children: decision.error })
|
|
@@ -872,7 +1123,7 @@ function TicketsPage() {
|
|
|
872
1123
|
return withOutcome.filter((r) => r.job && responseOutcome(r.job).variant === outcomeFilter);
|
|
873
1124
|
}, [decisions, jobByDecisionId, outcomeFilter]);
|
|
874
1125
|
const columns = [
|
|
875
|
-
{ key: "ticketId", header: "Ticket", cell: ({ decision }) => decision.ticketId },
|
|
1126
|
+
{ key: "ticketId", header: "Ticket", cell: ({ decision }) => /* @__PURE__ */ jsxRuntime.jsx(TicketLink, { ticketId: decision.ticketId, url: decision.ticketUrl }) },
|
|
876
1127
|
{
|
|
877
1128
|
key: "category",
|
|
878
1129
|
header: "Cat\xE9gorie",
|
|
@@ -1192,7 +1443,7 @@ function computePipelineStats(rows, timezone = "UTC") {
|
|
|
1192
1443
|
}
|
|
1193
1444
|
var STATS_PAGE_SIZE = 200;
|
|
1194
1445
|
var TABLE_PAGE_SIZE = 200;
|
|
1195
|
-
var
|
|
1446
|
+
var WINDOW_OPTIONS = [7, 14, 30];
|
|
1196
1447
|
var DECISION_OPTIONS = [
|
|
1197
1448
|
{ value: "", label: "Tous" },
|
|
1198
1449
|
{ value: "sent", label: "Envoy\xE9s auto" },
|
|
@@ -1220,7 +1471,7 @@ function buildTableFilter(decision, status) {
|
|
|
1220
1471
|
function countOrEllipsis(value) {
|
|
1221
1472
|
return Number.isNaN(value) ? "\u2026" : String(value);
|
|
1222
1473
|
}
|
|
1223
|
-
function
|
|
1474
|
+
function windowCutoffIso(days) {
|
|
1224
1475
|
return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString();
|
|
1225
1476
|
}
|
|
1226
1477
|
function ConfidenceCell({ confidence }) {
|
|
@@ -1308,7 +1559,7 @@ function PipelinePage() {
|
|
|
1308
1559
|
const toast = uiSdk.useToast();
|
|
1309
1560
|
const [isTriaging, setIsTriaging] = react.useState(false);
|
|
1310
1561
|
const isTriagingRef = react.useRef(false);
|
|
1311
|
-
const [windowDays, setWindowDays] = react.useState(
|
|
1562
|
+
const [windowDays, setWindowDays] = react.useState(WINDOW_OPTIONS[0]);
|
|
1312
1563
|
const [decisionFilter, setDecisionFilter] = react.useState("");
|
|
1313
1564
|
const [statusFilter, setStatusFilter] = react.useState("");
|
|
1314
1565
|
const [verdictFilter, setVerdictFilter] = react.useState("");
|
|
@@ -1343,7 +1594,7 @@ function PipelinePage() {
|
|
|
1343
1594
|
const categoryNames = react.useMemo(() => toNameMap(categories), [categories]);
|
|
1344
1595
|
const agentNames = react.useMemo(() => toNameMap(agents), [agents]);
|
|
1345
1596
|
const windowedStatsRows = react.useMemo(() => {
|
|
1346
|
-
const cutoff =
|
|
1597
|
+
const cutoff = windowCutoffIso(windowDays);
|
|
1347
1598
|
return statsRows.filter((row) => row.generatedAt !== null && row.generatedAt >= cutoff);
|
|
1348
1599
|
}, [statsRows, windowDays]);
|
|
1349
1600
|
const stats = react.useMemo(
|
|
@@ -1438,7 +1689,7 @@ function PipelinePage() {
|
|
|
1438
1689
|
),
|
|
1439
1690
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1440
1691
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground", children: "Fen\xEAtre :" }),
|
|
1441
|
-
|
|
1692
|
+
WINDOW_OPTIONS.map((days) => /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Button, { size: "sm", variant: windowDays === days ? "default" : "outline", onClick: () => setWindowDays(days), children: [
|
|
1442
1693
|
days,
|
|
1443
1694
|
" j"
|
|
1444
1695
|
] }, days))
|
|
@@ -3156,6 +3407,7 @@ function StatusBadge({ status, error }) {
|
|
|
3156
3407
|
}
|
|
3157
3408
|
function DetailPanel3({ row, categoryName, onClose }) {
|
|
3158
3409
|
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: [
|
|
3410
|
+
row.ticketUrl && /* @__PURE__ */ jsxRuntime.jsx("p", { children: /* @__PURE__ */ jsxRuntime.jsx(TicketLink, { ticketId: row.ticketId, url: row.ticketUrl, label: "Ouvrir le ticket dans Gorgias" }) }),
|
|
3159
3411
|
row.reasoning && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
3160
3412
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Raison du triage" }),
|
|
3161
3413
|
/* @__PURE__ */ jsxRuntime.jsx("p", { children: row.reasoning })
|
|
@@ -3213,7 +3465,7 @@ function EscalationsPage() {
|
|
|
3213
3465
|
const { rows: categories } = useRecordList("category", { limit: 500 }, toCategory);
|
|
3214
3466
|
const categoryNames = react.useMemo(() => toNameMap(categories), [categories]);
|
|
3215
3467
|
const columns = [
|
|
3216
|
-
{ key: "ticketId", header: "Ticket", cell: (row) => row.ticketId },
|
|
3468
|
+
{ key: "ticketId", header: "Ticket", cell: (row) => /* @__PURE__ */ jsxRuntime.jsx(TicketLink, { ticketId: row.ticketId, url: row.ticketUrl }) },
|
|
3217
3469
|
{ key: "category", header: "Cat\xE9gorie", cell: (row) => row.categoryId && categoryNames.get(row.categoryId) || "\u2014" },
|
|
3218
3470
|
{ key: "tag", header: "Tag", cell: (row) => row.tag ? /* @__PURE__ */ jsxRuntime.jsx("code", { className: "text-xs", children: row.tag }) : "\u2014" },
|
|
3219
3471
|
{
|
|
@@ -4821,6 +5073,31 @@ function SettingsPage() {
|
|
|
4821
5073
|
] })
|
|
4822
5074
|
);
|
|
4823
5075
|
}
|
|
5076
|
+
function readParam(name) {
|
|
5077
|
+
if (typeof window === "undefined") return null;
|
|
5078
|
+
return new URLSearchParams(window.location.search).get(name);
|
|
5079
|
+
}
|
|
5080
|
+
function useQueryParam(name) {
|
|
5081
|
+
const [value, setState] = react.useState(() => readParam(name));
|
|
5082
|
+
react.useEffect(() => {
|
|
5083
|
+
const sync = () => setState(readParam(name));
|
|
5084
|
+
sync();
|
|
5085
|
+
window.addEventListener("popstate", sync);
|
|
5086
|
+
return () => window.removeEventListener("popstate", sync);
|
|
5087
|
+
}, [name]);
|
|
5088
|
+
const setValue = react.useCallback(
|
|
5089
|
+
(next) => {
|
|
5090
|
+
const params = new URLSearchParams(window.location.search);
|
|
5091
|
+
if (next === null) params.delete(name);
|
|
5092
|
+
else params.set(name, next);
|
|
5093
|
+
const query = params.toString();
|
|
5094
|
+
window.history.pushState({}, "", `${window.location.pathname}${query ? `?${query}` : ""}`);
|
|
5095
|
+
setState(next);
|
|
5096
|
+
},
|
|
5097
|
+
[name]
|
|
5098
|
+
);
|
|
5099
|
+
return { value, setValue };
|
|
5100
|
+
}
|
|
4824
5101
|
|
|
4825
5102
|
// src/graph/state.ts
|
|
4826
5103
|
var NODE_NAMES = [
|
|
@@ -4841,14 +5118,32 @@ function hasNoDraftNode(profile) {
|
|
|
4841
5118
|
}
|
|
4842
5119
|
|
|
4843
5120
|
// src/ui/graph-canvas/reachability.ts
|
|
5121
|
+
var EXIT_TONES = {
|
|
5122
|
+
sent: "delivered",
|
|
5123
|
+
failed: "failure",
|
|
5124
|
+
ready: "held",
|
|
5125
|
+
needs_human: "held",
|
|
5126
|
+
guardrail_hold: "held",
|
|
5127
|
+
awaiting_approval: "held",
|
|
5128
|
+
escalated: "held",
|
|
5129
|
+
triaged_only: "held",
|
|
5130
|
+
no_reply_needed: "held"
|
|
5131
|
+
};
|
|
4844
5132
|
function stubPrompts() {
|
|
4845
5133
|
const ref = { name: "", label: "production" };
|
|
4846
5134
|
return { triage: ref, escalate: ref, draft: ref, evaluate: ref };
|
|
4847
5135
|
}
|
|
4848
5136
|
var PROMPT_403_NODES = /* @__PURE__ */ new Set(["triage", "escalate", "draft", "evaluate", "revise"]);
|
|
4849
|
-
var PROMPT_403_NOTE =
|
|
4850
|
-
|
|
4851
|
-
|
|
5137
|
+
var PROMPT_403_NOTE = {
|
|
5138
|
+
id: "prompt-403",
|
|
5139
|
+
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.",
|
|
5140
|
+
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)."
|
|
5141
|
+
};
|
|
5142
|
+
function reason(kind, message, detail) {
|
|
5143
|
+
return detail === void 0 ? { kind, message } : { kind, message, detail };
|
|
5144
|
+
}
|
|
5145
|
+
function note(message, detail) {
|
|
5146
|
+
return detail === void 0 ? { message } : { message, detail };
|
|
4852
5147
|
}
|
|
4853
5148
|
function nodeModelOf(node, profile) {
|
|
4854
5149
|
switch (node) {
|
|
@@ -4864,17 +5159,35 @@ function nodeModelOf(node, profile) {
|
|
|
4864
5159
|
return null;
|
|
4865
5160
|
}
|
|
4866
5161
|
}
|
|
4867
|
-
var READY_EXIT = {
|
|
5162
|
+
var READY_EXIT = {
|
|
5163
|
+
key: "evaluate-ready",
|
|
5164
|
+
condition: "envoi auto non \xE9ligible",
|
|
5165
|
+
outcome: "ready"
|
|
5166
|
+
};
|
|
4868
5167
|
var NODE_EXITS = {
|
|
4869
|
-
fetchContext: [
|
|
5168
|
+
fetchContext: [
|
|
5169
|
+
{ key: "fetchContext-failed", condition: "lecture impossible", outcome: "failed" }
|
|
5170
|
+
],
|
|
4870
5171
|
triage: [
|
|
4871
5172
|
{ key: "triage-fallback", condition: "classification de repli", outcome: "triaged_only" },
|
|
4872
|
-
{
|
|
4873
|
-
|
|
5173
|
+
{
|
|
5174
|
+
key: "triage-closed",
|
|
5175
|
+
condition: "le dernier message client cl\xF4t la conversation",
|
|
5176
|
+
outcome: "no_reply_needed"
|
|
5177
|
+
},
|
|
5178
|
+
{
|
|
5179
|
+
key: "triage-whatsapp-gate",
|
|
5180
|
+
condition: "r\xE8gle de canal WhatsApp (STOP ou pas notre tour)",
|
|
5181
|
+
outcome: "guardrail_hold"
|
|
5182
|
+
}
|
|
4874
5183
|
],
|
|
4875
5184
|
escalate: [
|
|
4876
5185
|
{ key: "escalate-escalated", condition: "escalade demand\xE9e", outcome: "escalated" },
|
|
4877
|
-
{
|
|
5186
|
+
{
|
|
5187
|
+
key: "escalate-no-draft",
|
|
5188
|
+
condition: "profil sans n\u0153ud de r\xE9daction",
|
|
5189
|
+
outcome: "triaged_only"
|
|
5190
|
+
}
|
|
4878
5191
|
],
|
|
4879
5192
|
evaluate: [
|
|
4880
5193
|
{
|
|
@@ -4884,8 +5197,16 @@ var NODE_EXITS = {
|
|
|
4884
5197
|
},
|
|
4885
5198
|
READY_EXIT
|
|
4886
5199
|
],
|
|
4887
|
-
guardrails: [
|
|
4888
|
-
|
|
5200
|
+
guardrails: [
|
|
5201
|
+
{ key: "guardrails-content", condition: "garde-fou de contenu", outcome: "guardrail_hold" }
|
|
5202
|
+
],
|
|
5203
|
+
authorize: [
|
|
5204
|
+
{
|
|
5205
|
+
key: "authorize-awaiting",
|
|
5206
|
+
condition: "une action n'est pas \xAB auto \xBB",
|
|
5207
|
+
outcome: "awaiting_approval"
|
|
5208
|
+
}
|
|
5209
|
+
],
|
|
4889
5210
|
act: [
|
|
4890
5211
|
{ key: "act-collision", condition: "contr\xF4le anti-collision", outcome: "guardrail_hold" },
|
|
4891
5212
|
{ key: "act-sent-email", condition: "r\xE9ponse email", outcome: "sent" },
|
|
@@ -4894,10 +5215,15 @@ var NODE_EXITS = {
|
|
|
4894
5215
|
};
|
|
4895
5216
|
function exitsFor(node, evaluateConfigured) {
|
|
4896
5217
|
const raw = NODE_EXITS[node] ?? [];
|
|
4897
|
-
|
|
5218
|
+
const withTone = (exits) => exits.map((exit) => ({ ...exit, tone: EXIT_TONES[exit.outcome] }));
|
|
5219
|
+
if (evaluateConfigured) return withTone(raw);
|
|
4898
5220
|
if (node === "evaluate") return [];
|
|
4899
|
-
if (node === "draft") return [READY_EXIT];
|
|
4900
|
-
return raw;
|
|
5221
|
+
if (node === "draft") return withTone([READY_EXIT]);
|
|
5222
|
+
return withTone(raw);
|
|
5223
|
+
}
|
|
5224
|
+
function deriveCause(state, reasons) {
|
|
5225
|
+
if (state === "on") return null;
|
|
5226
|
+
return reasons.some((r) => r.kind !== "upstream-disabled") ? "root" : "consequence";
|
|
4901
5227
|
}
|
|
4902
5228
|
function deriveState(upstreamOk, blockingReasons, offReasons) {
|
|
4903
5229
|
if (!upstreamOk) return "unreachable";
|
|
@@ -4915,11 +5241,17 @@ function computeGraphReachability(rawSettings, hasCategoryWithAutoReply) {
|
|
|
4915
5241
|
nodes: NODE_NAMES.map((node) => ({
|
|
4916
5242
|
node,
|
|
4917
5243
|
state: "unreachable",
|
|
4918
|
-
|
|
5244
|
+
// Every node reports the SAME single root cause here — none of them
|
|
5245
|
+
// is "blocked by the one before", they are all blocked by the same
|
|
5246
|
+
// absent setting, so none is a mere consequence of another.
|
|
5247
|
+
cause: "root",
|
|
5248
|
+
reasons: [reason("missing-setting", message, "validateSettings: nodes.triage est \xE0 null.")],
|
|
4919
5249
|
notes: [],
|
|
4920
5250
|
model: null,
|
|
4921
|
-
exits: []
|
|
4922
|
-
|
|
5251
|
+
exits: [],
|
|
5252
|
+
promptWarning: false
|
|
5253
|
+
})),
|
|
5254
|
+
globalNotes: []
|
|
4923
5255
|
};
|
|
4924
5256
|
}
|
|
4925
5257
|
const settings = rawSettings;
|
|
@@ -4927,20 +5259,23 @@ function computeGraphReachability(rawSettings, hasCategoryWithAutoReply) {
|
|
|
4927
5259
|
const evaluateConfigured = profile.nodes.evaluate !== null;
|
|
4928
5260
|
const byNode = /* @__PURE__ */ new Map();
|
|
4929
5261
|
function set(node, state, reasons, notes = []) {
|
|
4930
|
-
const promptNote = state === "on" && PROMPT_403_NODES.has(node) ? [PROMPT_403_NOTE] : [];
|
|
4931
5262
|
byNode.set(node, {
|
|
4932
5263
|
node,
|
|
4933
5264
|
state,
|
|
5265
|
+
cause: deriveCause(state, reasons),
|
|
4934
5266
|
reasons,
|
|
4935
|
-
notes
|
|
5267
|
+
notes,
|
|
4936
5268
|
model: nodeModelOf(node, profile),
|
|
4937
|
-
exits: exitsFor(node, evaluateConfigured)
|
|
5269
|
+
exits: exitsFor(node, evaluateConfigured),
|
|
5270
|
+
promptWarning: state === "on" && PROMPT_403_NODES.has(node)
|
|
4938
5271
|
});
|
|
4939
5272
|
}
|
|
4940
5273
|
function getNode(node) {
|
|
4941
5274
|
const found = byNode.get(node);
|
|
4942
5275
|
if (!found) {
|
|
4943
|
-
throw new Error(
|
|
5276
|
+
throw new Error(
|
|
5277
|
+
`computeGraphReachability: no reachability rule was set for node "${node}" \u2014 NODE_NAMES gained an entry this module does not know how to place.`
|
|
5278
|
+
);
|
|
4944
5279
|
}
|
|
4945
5280
|
return found;
|
|
4946
5281
|
}
|
|
@@ -4949,121 +5284,329 @@ function computeGraphReachability(rawSettings, hasCategoryWithAutoReply) {
|
|
|
4949
5284
|
const fetchBlockingReasons = [];
|
|
4950
5285
|
const sourceViewIdIssue = issues.find((issue) => issue.key === "sourceViewId");
|
|
4951
5286
|
if (sourceViewIdIssue) {
|
|
4952
|
-
fetchBlockingReasons.push(
|
|
5287
|
+
fetchBlockingReasons.push(
|
|
5288
|
+
reason(
|
|
5289
|
+
"missing-setting",
|
|
5290
|
+
settingsIssueLabel("sourceViewId", sourceViewIdIssue.message),
|
|
5291
|
+
"validateSettings: sourceViewId est vide."
|
|
5292
|
+
)
|
|
5293
|
+
);
|
|
4953
5294
|
}
|
|
4954
5295
|
if (!settings.triageEnabled) {
|
|
4955
|
-
fetchOffReasons.push(
|
|
5296
|
+
fetchOffReasons.push(
|
|
5297
|
+
reason(
|
|
5298
|
+
"missing-setting",
|
|
5299
|
+
"Le pipeline est coup\xE9 : aucun ticket n'est lu, donc aucune \xE9tape ne s'ex\xE9cute.",
|
|
5300
|
+
"triageEnabled est d\xE9sactiv\xE9 \u2014 coupe-circuit global (\xA73.5)."
|
|
5301
|
+
)
|
|
5302
|
+
);
|
|
4956
5303
|
}
|
|
4957
|
-
set("fetchContext", deriveState(true, fetchBlockingReasons, fetchOffReasons), [
|
|
5304
|
+
set("fetchContext", deriveState(true, fetchBlockingReasons, fetchOffReasons), [
|
|
5305
|
+
...fetchBlockingReasons,
|
|
5306
|
+
...fetchOffReasons
|
|
5307
|
+
]);
|
|
4958
5308
|
const fetchNode = getNode("fetchContext");
|
|
4959
5309
|
const fetchRuns = passesControlOn("fetchContext");
|
|
4960
5310
|
set(
|
|
4961
5311
|
"triage",
|
|
4962
5312
|
fetchRuns ? "on" : "unreachable",
|
|
4963
5313
|
fetchRuns ? [] : [
|
|
4964
|
-
reason(
|
|
5314
|
+
fetchNode.state === "off" ? reason(
|
|
4965
5315
|
"upstream-disabled",
|
|
4966
|
-
|
|
5316
|
+
"La r\xE9cup\xE9ration du ticket est coup\xE9e \u2014 aucun ticket n'est jamais lu.",
|
|
5317
|
+
"fetchContext est d\xE9sactiv\xE9 (triageEnabled)."
|
|
5318
|
+
) : reason(
|
|
5319
|
+
"upstream-disabled",
|
|
5320
|
+
"La r\xE9cup\xE9ration du ticket est bloqu\xE9e \u2014 voir sa carte.",
|
|
5321
|
+
"fetchContext est inatteignable (sourceViewId)."
|
|
4967
5322
|
)
|
|
4968
5323
|
]
|
|
4969
5324
|
);
|
|
4970
5325
|
const triageRuns = passesControlOn("triage");
|
|
4971
5326
|
const escalateDisabled = profile.nodes.escalate === null;
|
|
5327
|
+
const escalateOff = reason(
|
|
5328
|
+
"disabled-step",
|
|
5329
|
+
"\xC9tape coup\xE9e dans les r\xE9glages \u2014 aucune escalade automatique n'est d\xE9cid\xE9e.",
|
|
5330
|
+
"nodes.escalate est \xE0 null (\xA73.6)."
|
|
5331
|
+
);
|
|
4972
5332
|
set(
|
|
4973
5333
|
"escalate",
|
|
4974
|
-
deriveState(triageRuns, [], escalateDisabled ? [
|
|
4975
|
-
triageRuns ? escalateDisabled ? [
|
|
5334
|
+
deriveState(triageRuns, [], escalateDisabled ? [escalateOff] : []),
|
|
5335
|
+
triageRuns ? escalateDisabled ? [escalateOff] : [] : [
|
|
5336
|
+
reason(
|
|
5337
|
+
"upstream-disabled",
|
|
5338
|
+
"Le triage n'est jamais atteint.",
|
|
5339
|
+
"triage est inatteignable."
|
|
5340
|
+
)
|
|
5341
|
+
]
|
|
4976
5342
|
);
|
|
4977
5343
|
const draftDisabled = hasNoDraftNode(profile);
|
|
5344
|
+
const draftOff = reason(
|
|
5345
|
+
"disabled-step",
|
|
5346
|
+
"\xC9tape coup\xE9e dans les r\xE9glages \u2014 aucune r\xE9ponse n'est r\xE9dig\xE9e.",
|
|
5347
|
+
"nodes.draft est \xE0 null \u2014 sortie \xAB triaged_only \xBB (run-ticket.ts#hasNoDraftNode)."
|
|
5348
|
+
);
|
|
4978
5349
|
set(
|
|
4979
5350
|
"draft",
|
|
4980
|
-
deriveState(triageRuns, [], draftDisabled ? [
|
|
4981
|
-
triageRuns ? draftDisabled ? [
|
|
5351
|
+
deriveState(triageRuns, [], draftDisabled ? [draftOff] : []),
|
|
5352
|
+
triageRuns ? draftDisabled ? [draftOff] : [] : [
|
|
5353
|
+
reason(
|
|
5354
|
+
"upstream-disabled",
|
|
5355
|
+
"Le triage n'est jamais atteint.",
|
|
5356
|
+
"triage est inatteignable."
|
|
5357
|
+
)
|
|
5358
|
+
]
|
|
4982
5359
|
);
|
|
4983
5360
|
const draftRuns = passesControlOn("draft");
|
|
4984
5361
|
const evaluateDisabled = !evaluateConfigured;
|
|
5362
|
+
const evaluateOff = reason(
|
|
5363
|
+
"disabled-step",
|
|
5364
|
+
"\xC9tape coup\xE9e dans les r\xE9glages \u2014 aucun verdict, la r\xE9ponse reste \xAB Disponible \xBB.",
|
|
5365
|
+
"nodes.evaluate est \xE0 null \u2014 la r\xE9ponse conserve l'issue \xAB ready \xBB."
|
|
5366
|
+
);
|
|
4985
5367
|
set(
|
|
4986
5368
|
"evaluate",
|
|
4987
|
-
deriveState(draftRuns, [], evaluateDisabled ? [
|
|
4988
|
-
draftRuns ? evaluateDisabled ? [
|
|
5369
|
+
deriveState(draftRuns, [], evaluateDisabled ? [evaluateOff] : []),
|
|
5370
|
+
draftRuns ? evaluateDisabled ? [evaluateOff] : [] : [
|
|
5371
|
+
getNode("draft").state === "off" ? reason(
|
|
5372
|
+
"upstream-disabled",
|
|
5373
|
+
"La r\xE9daction est coup\xE9e \u2014 aucun ticket n'atteint l'\xE9valuation.",
|
|
5374
|
+
"draft est d\xE9sactiv\xE9."
|
|
5375
|
+
) : reason(
|
|
5376
|
+
"upstream-disabled",
|
|
5377
|
+
"La r\xE9daction n'est jamais atteinte.",
|
|
5378
|
+
"draft est inatteignable."
|
|
5379
|
+
)
|
|
5380
|
+
]
|
|
4989
5381
|
);
|
|
4990
5382
|
const evaluateRuns = passesControlOn("evaluate");
|
|
4991
5383
|
const reviseDisabled = profile.nodes.revise === null;
|
|
5384
|
+
const reviseOff = reason(
|
|
5385
|
+
"disabled-step",
|
|
5386
|
+
"\xC9tape coup\xE9e dans les r\xE9glages \u2014 pas de passe de correction.",
|
|
5387
|
+
"nodes.revise est \xE0 null."
|
|
5388
|
+
);
|
|
4992
5389
|
set(
|
|
4993
5390
|
"revise",
|
|
4994
|
-
deriveState(evaluateRuns, [], reviseDisabled ? [
|
|
4995
|
-
evaluateRuns ? reviseDisabled ? [
|
|
4996
|
-
|
|
5391
|
+
deriveState(evaluateRuns, [], reviseDisabled ? [reviseOff] : []),
|
|
5392
|
+
evaluateRuns ? reviseDisabled ? [reviseOff] : [] : [
|
|
5393
|
+
getNode("evaluate").state === "off" ? reason(
|
|
5394
|
+
"upstream-disabled",
|
|
5395
|
+
"L'\xE9valuation est coup\xE9e \u2014 aucun ticket n'atteint la r\xE9vision.",
|
|
5396
|
+
"evaluate est d\xE9sactiv\xE9."
|
|
5397
|
+
) : reason(
|
|
5398
|
+
"upstream-disabled",
|
|
5399
|
+
"L'\xE9valuation n'est jamais atteinte.",
|
|
5400
|
+
"evaluate est inatteignable."
|
|
5401
|
+
)
|
|
5402
|
+
],
|
|
5403
|
+
evaluateRuns && !reviseDisabled ? [note("Au plus une passe de r\xE9vision par ticket.", "\xA73.3.")] : []
|
|
4997
5404
|
);
|
|
4998
5405
|
const autoSendBlockingReasons = [];
|
|
4999
5406
|
const autoSendOffReasons = [];
|
|
5000
5407
|
if (!profile.autoSend.enabled) {
|
|
5001
|
-
autoSendOffReasons.push(
|
|
5408
|
+
autoSendOffReasons.push(
|
|
5409
|
+
reason(
|
|
5410
|
+
"missing-setting",
|
|
5411
|
+
"L'envoi automatique est coup\xE9 \u2014 ce coupe-circuit emp\xEAche tout envoi.",
|
|
5412
|
+
"autoSendEnabled est d\xE9sactiv\xE9."
|
|
5413
|
+
)
|
|
5414
|
+
);
|
|
5002
5415
|
}
|
|
5003
5416
|
if (!hasCategoryWithAutoReply) {
|
|
5004
5417
|
autoSendBlockingReasons.push(
|
|
5005
|
-
reason(
|
|
5418
|
+
reason(
|
|
5419
|
+
"missing-setting",
|
|
5420
|
+
"Aucune cat\xE9gorie n'a \xAB Envoi auto \xBB activ\xE9 \u2014 sans elle, aucune r\xE9ponse n'est \xE9ligible \xE0 un envoi automatique.",
|
|
5421
|
+
"isAutoSendEligible exige category.autoReplyEnabled ; aucune cat\xE9gorie ne le porte aujourd'hui."
|
|
5422
|
+
)
|
|
5006
5423
|
);
|
|
5007
5424
|
}
|
|
5008
5425
|
const senderEmailIssue = issues.find((issue) => issue.key === "senderEmail");
|
|
5009
5426
|
if (senderEmailIssue) {
|
|
5010
|
-
autoSendBlockingReasons.push(
|
|
5427
|
+
autoSendBlockingReasons.push(
|
|
5428
|
+
reason(
|
|
5429
|
+
"missing-setting",
|
|
5430
|
+
settingsIssueLabel("senderEmail", senderEmailIssue.message),
|
|
5431
|
+
"validateSettings: senderEmail est vide alors que autoSendEnabled est actif."
|
|
5432
|
+
)
|
|
5433
|
+
);
|
|
5011
5434
|
}
|
|
5012
5435
|
const guardrailNotes = [];
|
|
5013
5436
|
if (!profile.autoSend.senderEmail && profile.guardrails.params.whatsappMode === "auto_reply") {
|
|
5014
5437
|
guardrailNotes.push(
|
|
5015
|
-
|
|
5438
|
+
note(
|
|
5439
|
+
"Sans adresse d'envoi, seuls les tickets WhatsApp en r\xE9ponse automatique passent ici : un ticket email reste bloqu\xE9 \xE0 \xAB Disponible \xBB.",
|
|
5440
|
+
`senderEmail est vide et whatsappMode="auto_reply" \u2014 hasSenderForMode n'est vrai que pour WhatsApp ; un ticket email n'atteint jamais guardrails/authorize/act.`
|
|
5441
|
+
)
|
|
5016
5442
|
);
|
|
5017
5443
|
}
|
|
5018
5444
|
if (profile.guardrails.params.whatsappMode === "draft_only") {
|
|
5019
5445
|
guardrailNotes.push(
|
|
5020
|
-
|
|
5446
|
+
note(
|
|
5447
|
+
"Les tickets WhatsApp ne d\xE9passent jamais \xAB Disponible \xBB (mode brouillon seul) : seuls les tickets email arrivent r\xE9ellement ici.",
|
|
5448
|
+
`whatsappMode="draft_only" \u2014 isAutoSendEligible exclut ce mode ; authorize/act ne s'ex\xE9cutent que pour le canal email.`
|
|
5449
|
+
)
|
|
5021
5450
|
);
|
|
5022
5451
|
}
|
|
5023
5452
|
if (profile.guardrails.params.whatsappMode === "escalate_only") {
|
|
5024
5453
|
guardrailNotes.push(
|
|
5025
|
-
|
|
5454
|
+
note(
|
|
5455
|
+
"Un ticket WhatsApp qui arrive ici est syst\xE9matiquement retenu : sur ce canal la r\xE9ponse est gard\xE9e, jamais envoy\xE9e.",
|
|
5456
|
+
`whatsappMode="escalate_only" \u2014 garde-fou \xAB whatsapp \xBB (\xA73.9) ; authorize/act ne s'ex\xE9cutent jamais pour ce canal.`
|
|
5457
|
+
)
|
|
5026
5458
|
);
|
|
5027
5459
|
}
|
|
5028
5460
|
set(
|
|
5029
5461
|
"guardrails",
|
|
5030
5462
|
deriveState(evaluateRuns, autoSendBlockingReasons, autoSendOffReasons),
|
|
5031
|
-
evaluateRuns ? [...autoSendBlockingReasons, ...autoSendOffReasons] : [
|
|
5463
|
+
evaluateRuns ? [...autoSendBlockingReasons, ...autoSendOffReasons] : [
|
|
5464
|
+
getNode("evaluate").state === "off" ? reason(
|
|
5465
|
+
"upstream-disabled",
|
|
5466
|
+
"L'\xE9valuation est coup\xE9e \u2014 sans verdict, aucun ticket n'arrive ici.",
|
|
5467
|
+
"evaluate est d\xE9sactiv\xE9."
|
|
5468
|
+
) : reason(
|
|
5469
|
+
"upstream-disabled",
|
|
5470
|
+
"L'\xE9valuation n'est jamais atteinte \u2014 aucun verdict ne peut donc \xEAtre produit.",
|
|
5471
|
+
"evaluate est inatteignable."
|
|
5472
|
+
)
|
|
5473
|
+
],
|
|
5032
5474
|
guardrailNotes
|
|
5033
5475
|
);
|
|
5034
5476
|
const guardrailsRuns = passesControlOn("guardrails");
|
|
5035
5477
|
set(
|
|
5036
5478
|
"authorize",
|
|
5037
5479
|
guardrailsRuns ? "on" : "unreachable",
|
|
5038
|
-
guardrailsRuns ? [] : [
|
|
5480
|
+
guardrailsRuns ? [] : [
|
|
5481
|
+
getNode("guardrails").state === "off" ? reason(
|
|
5482
|
+
"upstream-disabled",
|
|
5483
|
+
"Les garde-fous sont coup\xE9s \u2014 aucune action n'est jamais autoris\xE9e.",
|
|
5484
|
+
"guardrails est d\xE9sactiv\xE9 (autoSendEnabled)."
|
|
5485
|
+
) : reason(
|
|
5486
|
+
"upstream-disabled",
|
|
5487
|
+
"Les garde-fous ne sont jamais atteints \u2014 voir leur carte.",
|
|
5488
|
+
"guardrails est inatteignable."
|
|
5489
|
+
)
|
|
5490
|
+
],
|
|
5039
5491
|
guardrailsRuns ? guardrailNotes : []
|
|
5040
5492
|
);
|
|
5041
5493
|
const authorizeRuns = passesControlOn("authorize");
|
|
5042
|
-
const approvalNote =
|
|
5494
|
+
const approvalNote = note(
|
|
5495
|
+
"Le chemin d'approbation manuelle est inatteignable avec les r\xE9glages actuels : une r\xE9ponse autoris\xE9e part directement, jamais apr\xE8s une approbation.",
|
|
5496
|
+
"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)."
|
|
5497
|
+
);
|
|
5043
5498
|
set(
|
|
5044
5499
|
"act",
|
|
5045
5500
|
authorizeRuns ? "on" : "unreachable",
|
|
5046
|
-
authorizeRuns ? [] : [
|
|
5501
|
+
authorizeRuns ? [] : [
|
|
5502
|
+
reason(
|
|
5503
|
+
"upstream-disabled",
|
|
5504
|
+
"L'autorisation n'est jamais atteinte.",
|
|
5505
|
+
"authorize est inatteignable."
|
|
5506
|
+
)
|
|
5507
|
+
],
|
|
5047
5508
|
authorizeRuns ? [...guardrailNotes, approvalNote] : []
|
|
5048
5509
|
);
|
|
5049
|
-
|
|
5510
|
+
const nodes = NODE_NAMES.map((node) => getNode(node));
|
|
5511
|
+
const promptWarningNodes = nodes.filter((n) => n.promptWarning).map((n) => n.node);
|
|
5512
|
+
return {
|
|
5513
|
+
blocked: false,
|
|
5514
|
+
nodes,
|
|
5515
|
+
globalNotes: promptWarningNodes.length > 0 ? [{ ...PROMPT_403_NOTE, nodes: promptWarningNodes }] : []
|
|
5516
|
+
};
|
|
5517
|
+
}
|
|
5518
|
+
function windowCutoffIso2(days, now = Date.now()) {
|
|
5519
|
+
return new Date(now - days * 24 * 60 * 60 * 1e3).toISOString();
|
|
5520
|
+
}
|
|
5521
|
+
function totalOf(rows) {
|
|
5522
|
+
if (!Array.isArray(rows)) return null;
|
|
5523
|
+
let total = 0;
|
|
5524
|
+
for (const row of rows) {
|
|
5525
|
+
const value = row?.count;
|
|
5526
|
+
if (typeof value !== "number") return null;
|
|
5527
|
+
total += value;
|
|
5528
|
+
}
|
|
5529
|
+
return total;
|
|
5530
|
+
}
|
|
5531
|
+
function useGraphTraffic(windowDays) {
|
|
5532
|
+
const cutoffIso = react.useMemo(() => windowCutoffIso2(windowDays), [windowDays]);
|
|
5533
|
+
const triaged = useAggregate("triage-decision", {
|
|
5534
|
+
filter: { decidedAt: { gte: cutoffIso } },
|
|
5535
|
+
metrics: [{ op: "count", as: "count" }]
|
|
5536
|
+
});
|
|
5537
|
+
const escalated = useAggregate("triage-decision", {
|
|
5538
|
+
filter: { decidedAt: { gte: cutoffIso }, escalated: { eq: true } },
|
|
5539
|
+
metrics: [{ op: "count", as: "count" }]
|
|
5540
|
+
});
|
|
5541
|
+
const drafted = useAggregate("generated-response", {
|
|
5542
|
+
filter: { generatedAt: { gte: cutoffIso } },
|
|
5543
|
+
metrics: [{ op: "count", as: "count" }]
|
|
5544
|
+
});
|
|
5545
|
+
const sent = useAggregate("generated-response", {
|
|
5546
|
+
filter: { generatedAt: { gte: cutoffIso }, status: { eq: "sent" } },
|
|
5547
|
+
metrics: [{ op: "count", as: "count" }]
|
|
5548
|
+
});
|
|
5549
|
+
const isLoading = triaged.isLoading || escalated.isLoading || drafted.isLoading || sent.isLoading;
|
|
5550
|
+
const failed = [triaged, escalated, drafted, sent].some((q) => q.error !== void 0);
|
|
5551
|
+
const triagedTotal = totalOf(triaged.rows);
|
|
5552
|
+
const escalatedTotal = totalOf(escalated.rows);
|
|
5553
|
+
const draftedTotal = totalOf(drafted.rows);
|
|
5554
|
+
const sentTotal = totalOf(sent.rows);
|
|
5555
|
+
return react.useMemo(() => {
|
|
5556
|
+
const byNode = {};
|
|
5557
|
+
if (triagedTotal !== null) {
|
|
5558
|
+
byNode.fetchContext = {
|
|
5559
|
+
count: triagedTotal,
|
|
5560
|
+
witness: "tickets triag\xE9s (un triage suppose une lecture r\xE9ussie)"
|
|
5561
|
+
};
|
|
5562
|
+
byNode.triage = { count: triagedTotal, witness: "tickets triag\xE9s" };
|
|
5563
|
+
}
|
|
5564
|
+
if (escalatedTotal !== null)
|
|
5565
|
+
byNode.escalate = { count: escalatedTotal, witness: "tickets escalad\xE9s" };
|
|
5566
|
+
if (draftedTotal !== null) byNode.draft = { count: draftedTotal, witness: "r\xE9ponses r\xE9dig\xE9es" };
|
|
5567
|
+
if (sentTotal !== null) byNode.act = { count: sentTotal, witness: "r\xE9ponses envoy\xE9es" };
|
|
5568
|
+
return {
|
|
5569
|
+
byNode: failed ? {} : byNode,
|
|
5570
|
+
isLoading,
|
|
5571
|
+
unavailable: failed
|
|
5572
|
+
};
|
|
5573
|
+
}, [triagedTotal, escalatedTotal, draftedTotal, sentTotal, failed, isLoading]);
|
|
5050
5574
|
}
|
|
5051
5575
|
var CATEGORY_PAGE_SIZE = 500;
|
|
5576
|
+
var TRAFFIC_WINDOW_DAYS = 7;
|
|
5052
5577
|
var REASON_KIND_LABELS = {
|
|
5053
5578
|
"disabled-step": "\xC9tape d\xE9sactiv\xE9e",
|
|
5054
5579
|
"upstream-disabled": "Bloqu\xE9 en amont",
|
|
5055
5580
|
"missing-setting": "R\xE9glage manquant",
|
|
5056
5581
|
"channel-gate": "Restriction de canal"
|
|
5057
5582
|
};
|
|
5058
|
-
var
|
|
5583
|
+
var BADGE_LABELS = {
|
|
5059
5584
|
on: "Actif",
|
|
5060
5585
|
off: "D\xE9sactiv\xE9",
|
|
5061
|
-
|
|
5586
|
+
root: "Bloqu\xE9",
|
|
5587
|
+
consequence: "Hors d\u2019atteinte"
|
|
5062
5588
|
};
|
|
5063
|
-
var
|
|
5589
|
+
var BADGE_VARIANTS = {
|
|
5064
5590
|
on: "success",
|
|
5065
5591
|
off: "neutral",
|
|
5066
|
-
|
|
5592
|
+
root: "danger",
|
|
5593
|
+
consequence: "warning"
|
|
5594
|
+
};
|
|
5595
|
+
var BADGE_DEFINITIONS = {
|
|
5596
|
+
on: "Au moins un ticket peut atteindre ce n\u0153ud avec les r\xE9glages actuels.",
|
|
5597
|
+
off: "L\u2019op\xE9rateur a coup\xE9 ce n\u0153ud lui-m\xEAme \u2014 un choix, pas un incident.",
|
|
5598
|
+
root: "C\u2019est ici que le parcours s\u2019arr\xEAte : la cause est sur cette carte.",
|
|
5599
|
+
consequence: "Ce n\u0153ud n\u2019a rien de cass\xE9 \u2014 il est simplement priv\xE9 de tickets par un n\u0153ud en amont."
|
|
5600
|
+
};
|
|
5601
|
+
function badgeKindOf(node) {
|
|
5602
|
+
if (node.state === "on") return "on";
|
|
5603
|
+
if (node.state === "off") return "off";
|
|
5604
|
+
return node.cause === "consequence" ? "consequence" : "root";
|
|
5605
|
+
}
|
|
5606
|
+
var EXIT_TONE_CLASSES = {
|
|
5607
|
+
delivered: "border-status-success/30 bg-status-success/10 text-status-success",
|
|
5608
|
+
held: "border-border bg-muted text-muted-foreground",
|
|
5609
|
+
failure: "border-status-blocked/25 bg-status-blocked/10 text-status-blocked"
|
|
5067
5610
|
};
|
|
5068
5611
|
var NODE_SETTINGS_SECTION = {
|
|
5069
5612
|
fetchContext: { id: "source", title: "Source" },
|
|
@@ -5075,60 +5618,395 @@ var NODE_SETTINGS_SECTION = {
|
|
|
5075
5618
|
guardrails: { id: "guardrails", title: "Guardrails" },
|
|
5076
5619
|
act: { id: "envoi", title: "Envoi" }
|
|
5077
5620
|
};
|
|
5078
|
-
function
|
|
5079
|
-
const section = NODE_SETTINGS_SECTION[node
|
|
5621
|
+
function settingsHref(appSlug, node) {
|
|
5622
|
+
const section = NODE_SETTINGS_SECTION[node];
|
|
5623
|
+
return section ? `/parametres/espaces/${appSlug}#${section.id}` : null;
|
|
5624
|
+
}
|
|
5625
|
+
function dedupeExits(exits) {
|
|
5626
|
+
const byOutcome = /* @__PURE__ */ new Map();
|
|
5627
|
+
for (const exit of exits) {
|
|
5628
|
+
const existing = byOutcome.get(exit.outcome);
|
|
5629
|
+
if (existing) existing.conditions.push(exit.condition);
|
|
5630
|
+
else
|
|
5631
|
+
byOutcome.set(exit.outcome, {
|
|
5632
|
+
outcome: exit.outcome,
|
|
5633
|
+
tone: exit.tone,
|
|
5634
|
+
conditions: [exit.condition]
|
|
5635
|
+
});
|
|
5636
|
+
}
|
|
5637
|
+
return [...byOutcome.values()];
|
|
5638
|
+
}
|
|
5639
|
+
function computeVerdict(result) {
|
|
5640
|
+
const causes = result.nodes.filter((node) => node.state !== "on" && node.cause === "root");
|
|
5641
|
+
if (result.blocked) {
|
|
5642
|
+
return {
|
|
5643
|
+
tone: "critical",
|
|
5644
|
+
headline: "Le pipeline ne peut pas d\xE9marrer : le triage n\u2019est pas configur\xE9.",
|
|
5645
|
+
causes: causes.slice(0, 1)
|
|
5646
|
+
};
|
|
5647
|
+
}
|
|
5648
|
+
const act = result.nodes.find((node) => node.node === "act");
|
|
5649
|
+
if (act && act.state !== "on") {
|
|
5650
|
+
return {
|
|
5651
|
+
tone: "critical",
|
|
5652
|
+
headline: "Aucune r\xE9ponse ne peut partir automatiquement aujourd\u2019hui.",
|
|
5653
|
+
causes
|
|
5654
|
+
};
|
|
5655
|
+
}
|
|
5656
|
+
return {
|
|
5657
|
+
tone: "ok",
|
|
5658
|
+
headline: "Le parcours va jusqu\u2019\xE0 l\u2019envoi : une r\xE9ponse peut partir automatiquement.",
|
|
5659
|
+
causes
|
|
5660
|
+
};
|
|
5661
|
+
}
|
|
5662
|
+
function VerdictBanner({ verdict, appSlug }) {
|
|
5663
|
+
const critical = verdict.tone === "critical";
|
|
5080
5664
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5081
|
-
|
|
5665
|
+
"section",
|
|
5666
|
+
{
|
|
5667
|
+
"data-testid": "graph-verdict",
|
|
5668
|
+
className: uiSdk.cn(
|
|
5669
|
+
"rounded-lg border p-4",
|
|
5670
|
+
critical ? "border-status-blocked/30 bg-status-blocked/5" : "border-status-success/30 bg-status-success/5"
|
|
5671
|
+
),
|
|
5672
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-3", children: [
|
|
5673
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5674
|
+
"span",
|
|
5675
|
+
{
|
|
5676
|
+
"aria-hidden": true,
|
|
5677
|
+
className: uiSdk.cn(
|
|
5678
|
+
"mt-0.5 text-lg leading-none",
|
|
5679
|
+
critical ? "text-status-blocked" : "text-status-success"
|
|
5680
|
+
),
|
|
5681
|
+
children: critical ? "\u26D4" : "\u2713"
|
|
5682
|
+
}
|
|
5683
|
+
),
|
|
5684
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
|
|
5685
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5686
|
+
"p",
|
|
5687
|
+
{
|
|
5688
|
+
className: uiSdk.cn(
|
|
5689
|
+
"text-sm font-semibold",
|
|
5690
|
+
critical ? "text-status-blocked" : "text-status-success"
|
|
5691
|
+
),
|
|
5692
|
+
children: verdict.headline
|
|
5693
|
+
}
|
|
5694
|
+
),
|
|
5695
|
+
verdict.causes.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "space-y-2", children: verdict.causes.map((cause) => {
|
|
5696
|
+
const href = settingsHref(appSlug, cause.node);
|
|
5697
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5698
|
+
"li",
|
|
5699
|
+
{
|
|
5700
|
+
className: "flex flex-wrap items-center gap-x-2 gap-y-1 text-sm",
|
|
5701
|
+
children: [
|
|
5702
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: NODE_LABELS[cause.node] }),
|
|
5703
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-muted-foreground", children: [
|
|
5704
|
+
"\u2014 ",
|
|
5705
|
+
cause.reasons[0]?.message ?? ""
|
|
5706
|
+
] }),
|
|
5707
|
+
href && /* @__PURE__ */ jsxRuntime.jsx(
|
|
5708
|
+
uiSdk.Link,
|
|
5709
|
+
{
|
|
5710
|
+
href,
|
|
5711
|
+
className: uiSdk.cn(
|
|
5712
|
+
uiSdk.buttonVariants({ variant: "outline", size: "sm" }),
|
|
5713
|
+
"no-underline"
|
|
5714
|
+
),
|
|
5715
|
+
children: "Corriger"
|
|
5716
|
+
}
|
|
5717
|
+
)
|
|
5718
|
+
]
|
|
5719
|
+
},
|
|
5720
|
+
cause.node
|
|
5721
|
+
);
|
|
5722
|
+
}) })
|
|
5723
|
+
] })
|
|
5724
|
+
] })
|
|
5725
|
+
}
|
|
5726
|
+
);
|
|
5727
|
+
}
|
|
5728
|
+
function Legend() {
|
|
5729
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5730
|
+
"div",
|
|
5731
|
+
{
|
|
5732
|
+
className: "flex flex-wrap items-center gap-x-4 gap-y-2 text-xs text-muted-foreground",
|
|
5733
|
+
"data-testid": "graph-legend",
|
|
5734
|
+
children: Object.keys(BADGE_LABELS).map((kind) => /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-1.5", title: BADGE_DEFINITIONS[kind], children: [
|
|
5735
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: BADGE_VARIANTS[kind], children: BADGE_LABELS[kind] }),
|
|
5736
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "max-w-64", children: BADGE_DEFINITIONS[kind] })
|
|
5737
|
+
] }, kind))
|
|
5738
|
+
}
|
|
5739
|
+
);
|
|
5740
|
+
}
|
|
5741
|
+
function trafficContradiction(node, traffic) {
|
|
5742
|
+
if (!traffic) return null;
|
|
5743
|
+
if (node.state === "on" && traffic.count === 0) {
|
|
5744
|
+
return `Aucun passage observ\xE9 sur ${TRAFFIC_WINDOW_DAYS} jours, alors que ce n\u0153ud est r\xE9put\xE9 atteignable.`;
|
|
5745
|
+
}
|
|
5746
|
+
if (node.state !== "on" && traffic.count > 0) {
|
|
5747
|
+
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.`;
|
|
5748
|
+
}
|
|
5749
|
+
return null;
|
|
5750
|
+
}
|
|
5751
|
+
function TrafficPill({
|
|
5752
|
+
node,
|
|
5753
|
+
traffic
|
|
5754
|
+
}) {
|
|
5755
|
+
if (!traffic) {
|
|
5756
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5757
|
+
"span",
|
|
5758
|
+
{
|
|
5759
|
+
className: "text-xs text-muted-foreground",
|
|
5760
|
+
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.",
|
|
5761
|
+
children: "\u2014 trafic non mesur\xE9"
|
|
5762
|
+
}
|
|
5763
|
+
);
|
|
5764
|
+
}
|
|
5765
|
+
const contradiction = trafficContradiction(node, traffic);
|
|
5766
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5767
|
+
"span",
|
|
5768
|
+
{
|
|
5769
|
+
className: uiSdk.cn(
|
|
5770
|
+
"text-xs",
|
|
5771
|
+
contradiction ? "font-medium text-status-blocked" : "text-muted-foreground"
|
|
5772
|
+
),
|
|
5773
|
+
title: `${traffic.witness}, sur ${TRAFFIC_WINDOW_DAYS} jours.`,
|
|
5774
|
+
children: [
|
|
5775
|
+
traffic.count,
|
|
5776
|
+
" sur ",
|
|
5777
|
+
TRAFFIC_WINDOW_DAYS,
|
|
5778
|
+
" j",
|
|
5779
|
+
contradiction ? " \u26A0" : ""
|
|
5780
|
+
]
|
|
5781
|
+
}
|
|
5782
|
+
);
|
|
5783
|
+
}
|
|
5784
|
+
function Connector({ into, isBreak }) {
|
|
5785
|
+
const dead = into.state !== "on";
|
|
5786
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5787
|
+
"div",
|
|
5788
|
+
{
|
|
5789
|
+
className: "flex items-center gap-2 pl-[3px]",
|
|
5790
|
+
"data-testid": `graph-edge-${into.node}`,
|
|
5791
|
+
"data-edge-state": dead ? "dead" : "live",
|
|
5792
|
+
children: [
|
|
5793
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5794
|
+
"span",
|
|
5795
|
+
{
|
|
5796
|
+
"aria-hidden": true,
|
|
5797
|
+
className: uiSdk.cn(
|
|
5798
|
+
"h-6 w-0 border-l-2",
|
|
5799
|
+
dead ? "border-dashed" : "border-solid",
|
|
5800
|
+
into.state === "on" ? "border-status-success/50" : into.cause === "root" ? "border-status-blocked/60" : "border-border"
|
|
5801
|
+
)
|
|
5802
|
+
}
|
|
5803
|
+
),
|
|
5804
|
+
isBreak && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs font-medium text-status-blocked", children: [
|
|
5805
|
+
"\u26D4",
|
|
5806
|
+
" le parcours s",
|
|
5807
|
+
"\u2019",
|
|
5808
|
+
"arr\xEAte ici"
|
|
5809
|
+
] })
|
|
5810
|
+
]
|
|
5811
|
+
}
|
|
5812
|
+
);
|
|
5813
|
+
}
|
|
5814
|
+
function NodeRow({
|
|
5815
|
+
node,
|
|
5816
|
+
traffic,
|
|
5817
|
+
technical,
|
|
5818
|
+
globalNotes,
|
|
5819
|
+
onOpen
|
|
5820
|
+
}) {
|
|
5821
|
+
const kind = badgeKindOf(node);
|
|
5822
|
+
const exits = dedupeExits(node.exits);
|
|
5823
|
+
const contradiction = trafficContradiction(node, traffic);
|
|
5824
|
+
const headlineReason = node.reasons[0];
|
|
5825
|
+
const extraCount = Math.max(0, node.reasons.length - 1) + node.notes.length + globalNotes.length;
|
|
5826
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5827
|
+
"div",
|
|
5082
5828
|
{
|
|
5829
|
+
className: "flex items-start gap-3",
|
|
5083
5830
|
"data-testid": "graph-node",
|
|
5084
5831
|
"data-node": node.node,
|
|
5085
|
-
|
|
5086
|
-
children:
|
|
5087
|
-
/* @__PURE__ */ jsxRuntime.
|
|
5088
|
-
|
|
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",
|
|
5832
|
+
"data-state": kind,
|
|
5833
|
+
children: [
|
|
5834
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5835
|
+
"span",
|
|
5099
5836
|
{
|
|
5100
|
-
|
|
5101
|
-
className:
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5837
|
+
"aria-hidden": true,
|
|
5838
|
+
className: uiSdk.cn(
|
|
5839
|
+
"mt-4 size-2 shrink-0 rounded-full",
|
|
5840
|
+
kind === "on" && "bg-status-success",
|
|
5841
|
+
kind === "off" && "bg-muted-foreground/50",
|
|
5842
|
+
kind === "root" && "bg-status-blocked",
|
|
5843
|
+
kind === "consequence" && "bg-status-pending"
|
|
5844
|
+
)
|
|
5845
|
+
}
|
|
5846
|
+
),
|
|
5847
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5848
|
+
uiSdk.Card,
|
|
5849
|
+
{
|
|
5850
|
+
className: uiSdk.cn(
|
|
5851
|
+
"w-full max-w-2xl",
|
|
5852
|
+
kind === "root" && "border-status-blocked/40",
|
|
5853
|
+
(kind === "off" || kind === "consequence") && "border-dashed opacity-80"
|
|
5854
|
+
),
|
|
5855
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.CardContent, { className: "space-y-2 p-3", "data-testid": `graph-node-${node.node}`, children: [
|
|
5856
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-x-2 gap-y-1", children: [
|
|
5857
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium", children: NODE_LABELS[node.node] }),
|
|
5858
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: BADGE_VARIANTS[kind], title: BADGE_DEFINITIONS[kind], children: BADGE_LABELS[kind] }),
|
|
5859
|
+
node.promptWarning && /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Badge, { variant: "warning", title: "Voir l\u2019avertissement au-dessus du graphe.", children: [
|
|
5860
|
+
"\u26A0",
|
|
5861
|
+
" prompt non d\xE9clar\xE9"
|
|
5862
|
+
] }),
|
|
5863
|
+
technical && /* @__PURE__ */ jsxRuntime.jsx("code", { className: "font-mono text-[10px] text-muted-foreground", children: node.node }),
|
|
5864
|
+
technical && node.model && /* @__PURE__ */ jsxRuntime.jsx("code", { className: "font-mono text-[10px] text-muted-foreground", children: node.model }),
|
|
5865
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ml-auto flex items-center gap-3", children: [
|
|
5866
|
+
/* @__PURE__ */ jsxRuntime.jsx(TrafficPill, { node, traffic }),
|
|
5867
|
+
/* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Button, { variant: "ghost", size: "sm", onClick: onOpen, children: [
|
|
5868
|
+
"D\xE9tails",
|
|
5869
|
+
extraCount > 0 ? ` (${extraCount})` : ""
|
|
5870
|
+
] })
|
|
5871
|
+
] })
|
|
5872
|
+
] }),
|
|
5873
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs leading-snug text-muted-foreground", children: NODE_ROLE_LABELS[node.node] }),
|
|
5874
|
+
headlineReason && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs", children: [
|
|
5875
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-medium", children: [
|
|
5876
|
+
REASON_KIND_LABELS[headlineReason.kind],
|
|
5877
|
+
" \u2014 "
|
|
5878
|
+
] }),
|
|
5879
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: headlineReason.message }),
|
|
5880
|
+
technical && headlineReason.detail && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-1 font-mono text-[10px] text-muted-foreground", children: headlineReason.detail })
|
|
5881
|
+
] }),
|
|
5882
|
+
contradiction && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs font-medium text-status-blocked", children: contradiction }),
|
|
5883
|
+
exits.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-1.5 border-t pt-2", children: [
|
|
5884
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] text-muted-foreground", children: "Issues possibles :" }),
|
|
5885
|
+
exits.map((exit) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5886
|
+
"span",
|
|
5887
|
+
{
|
|
5888
|
+
title: exit.conditions.join(" \xB7 "),
|
|
5889
|
+
className: uiSdk.cn(
|
|
5890
|
+
"rounded-md border px-1.5 py-0.5 text-[11px] leading-tight",
|
|
5891
|
+
EXIT_TONE_CLASSES[exit.tone]
|
|
5892
|
+
),
|
|
5893
|
+
children: outcomeLabel(exit.outcome)
|
|
5894
|
+
},
|
|
5895
|
+
exit.outcome
|
|
5896
|
+
))
|
|
5897
|
+
] })
|
|
5898
|
+
] })
|
|
5899
|
+
}
|
|
5900
|
+
)
|
|
5901
|
+
]
|
|
5902
|
+
}
|
|
5903
|
+
);
|
|
5904
|
+
}
|
|
5905
|
+
function NodeDetailPanel({
|
|
5906
|
+
node,
|
|
5907
|
+
traffic,
|
|
5908
|
+
technical,
|
|
5909
|
+
appSlug,
|
|
5910
|
+
globalNotes,
|
|
5911
|
+
onClose
|
|
5912
|
+
}) {
|
|
5913
|
+
const href = node ? settingsHref(appSlug, node.node) : null;
|
|
5914
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5915
|
+
uiSdk.SidePanel,
|
|
5916
|
+
{
|
|
5917
|
+
open: node !== null,
|
|
5918
|
+
onClose,
|
|
5919
|
+
title: node ? NODE_LABELS[node.node] : "",
|
|
5920
|
+
description: node ? NODE_ROLE_LABELS[node.node] : "",
|
|
5921
|
+
children: node && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5922
|
+
"div",
|
|
5923
|
+
{
|
|
5924
|
+
className: "min-h-0 flex-1 space-y-4 overflow-y-auto text-sm",
|
|
5925
|
+
"data-testid": "graph-node-detail",
|
|
5926
|
+
children: [
|
|
5927
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
5928
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: BADGE_VARIANTS[badgeKindOf(node)], children: BADGE_LABELS[badgeKindOf(node)] }),
|
|
5929
|
+
technical && /* @__PURE__ */ jsxRuntime.jsx("code", { className: "font-mono text-xs text-muted-foreground", children: node.node })
|
|
5930
|
+
] }),
|
|
5931
|
+
node.model && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
5932
|
+
"Mod\xE8le : ",
|
|
5933
|
+
/* @__PURE__ */ jsxRuntime.jsx("code", { className: "font-mono", children: node.model })
|
|
5934
|
+
] }),
|
|
5935
|
+
/* @__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." }),
|
|
5936
|
+
node.reasons.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "space-y-2", children: [
|
|
5937
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: "Pourquoi" }),
|
|
5938
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "space-y-2", children: node.reasons.map((r, i) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "text-xs", children: [
|
|
5939
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-medium", children: [
|
|
5940
|
+
REASON_KIND_LABELS[r.kind],
|
|
5941
|
+
" \u2014 "
|
|
5942
|
+
] }),
|
|
5943
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: r.message }),
|
|
5944
|
+
technical && r.detail && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-0.5 font-mono text-[10px] text-muted-foreground", children: r.detail })
|
|
5945
|
+
] }, i)) })
|
|
5946
|
+
] }),
|
|
5947
|
+
(node.notes.length > 0 || globalNotes.length > 0) && /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "space-y-2", children: [
|
|
5948
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: "\xC0 savoir" }),
|
|
5949
|
+
/* @__PURE__ */ jsxRuntime.jsxs("ul", { className: "space-y-2", children: [
|
|
5950
|
+
node.notes.map((note2, i) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "text-xs text-muted-foreground", children: [
|
|
5951
|
+
note2.message,
|
|
5952
|
+
technical && note2.detail && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-0.5 font-mono text-[10px]", children: note2.detail })
|
|
5953
|
+
] }, `note-${i}`)),
|
|
5954
|
+
globalNotes.map((note2) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "text-xs text-muted-foreground", children: [
|
|
5955
|
+
note2.message,
|
|
5956
|
+
technical && note2.detail && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-0.5 font-mono text-[10px]", children: note2.detail })
|
|
5957
|
+
] }, note2.id))
|
|
5958
|
+
] })
|
|
5959
|
+
] }),
|
|
5960
|
+
node.exits.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "space-y-2", children: [
|
|
5961
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: "Issues possibles" }),
|
|
5962
|
+
/* @__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: [
|
|
5963
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5964
|
+
"span",
|
|
5965
|
+
{
|
|
5966
|
+
className: uiSdk.cn(
|
|
5967
|
+
"rounded-md border px-1.5 py-0.5 leading-tight",
|
|
5968
|
+
EXIT_TONE_CLASSES[exit.tone]
|
|
5969
|
+
),
|
|
5970
|
+
children: outcomeLabel(exit.outcome)
|
|
5971
|
+
}
|
|
5972
|
+
),
|
|
5973
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: exit.condition })
|
|
5974
|
+
] }, exit.key)) })
|
|
5975
|
+
] }),
|
|
5976
|
+
href && /* @__PURE__ */ jsxRuntime.jsx(
|
|
5977
|
+
uiSdk.Link,
|
|
5978
|
+
{
|
|
5979
|
+
href,
|
|
5980
|
+
className: uiSdk.cn(uiSdk.buttonVariants({ variant: "default", size: "sm" }), "no-underline"),
|
|
5981
|
+
children: "Ouvrir le r\xE9glage"
|
|
5982
|
+
}
|
|
5983
|
+
)
|
|
5984
|
+
]
|
|
5985
|
+
}
|
|
5986
|
+
)
|
|
5120
5987
|
}
|
|
5121
5988
|
);
|
|
5122
5989
|
}
|
|
5123
5990
|
function GraphCanvasPage() {
|
|
5124
5991
|
const { appSlug } = uiSdk.useAppContext();
|
|
5125
|
-
const {
|
|
5992
|
+
const { value: viewParam, setValue: setViewParam } = useQueryParam("vue");
|
|
5993
|
+
const technical = viewParam === "technique";
|
|
5994
|
+
const [openNode, setOpenNode] = react.useState(null);
|
|
5995
|
+
const {
|
|
5996
|
+
settings,
|
|
5997
|
+
isLoading: settingsLoading,
|
|
5998
|
+
error: settingsError
|
|
5999
|
+
} = uiSdk.useAppSettings();
|
|
5126
6000
|
const {
|
|
5127
6001
|
rows: categories,
|
|
5128
6002
|
isLoading: categoriesLoading,
|
|
5129
6003
|
error: categoriesError
|
|
5130
6004
|
} = useRecordList("category", { limit: CATEGORY_PAGE_SIZE }, toCategory);
|
|
5131
|
-
const
|
|
6005
|
+
const traffic = useGraphTraffic(TRAFFIC_WINDOW_DAYS);
|
|
6006
|
+
const hasCategoryWithAutoReply = react.useMemo(
|
|
6007
|
+
() => categories.some((c) => c.autoReplyEnabled),
|
|
6008
|
+
[categories]
|
|
6009
|
+
);
|
|
5132
6010
|
const categoriesMayBeTruncated = categories.length >= CATEGORY_PAGE_SIZE;
|
|
5133
6011
|
const result = react.useMemo(
|
|
5134
6012
|
() => settings ? computeGraphReachability(settings, hasCategoryWithAutoReply) : null,
|
|
@@ -5136,41 +6014,134 @@ function GraphCanvasPage() {
|
|
|
5136
6014
|
);
|
|
5137
6015
|
const isLoading = settingsLoading || categoriesLoading;
|
|
5138
6016
|
const isUnavailable = !isLoading && (settingsError !== void 0 || categoriesError !== void 0 || !result);
|
|
6017
|
+
const verdict = react.useMemo(() => result ? computeVerdict(result) : null, [result]);
|
|
6018
|
+
const selected = result?.nodes.find((node) => node.node === openNode) ?? null;
|
|
6019
|
+
const notesFor = (node) => result ? result.globalNotes.filter((note2) => note2.nodes.includes(node)) : [];
|
|
6020
|
+
const breakNode = result?.nodes.find((node) => node.state === "unreachable" && node.cause === "root")?.node ?? null;
|
|
6021
|
+
const rail = react.useMemo(() => {
|
|
6022
|
+
if (!result) return null;
|
|
6023
|
+
const rows = result.nodes.map((node, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
6024
|
+
i > 0 && /* @__PURE__ */ jsxRuntime.jsx(Connector, { into: node, isBreak: node.node === breakNode }),
|
|
6025
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6026
|
+
NodeRow,
|
|
6027
|
+
{
|
|
6028
|
+
node,
|
|
6029
|
+
traffic: traffic.byNode[node.node],
|
|
6030
|
+
technical,
|
|
6031
|
+
globalNotes: result.globalNotes.filter((note2) => note2.nodes.includes(node.node)),
|
|
6032
|
+
onOpen: () => setOpenNode(node.node)
|
|
6033
|
+
}
|
|
6034
|
+
)
|
|
6035
|
+
] }, node.node));
|
|
6036
|
+
const from = result.nodes.findIndex((node) => node.node === "evaluate");
|
|
6037
|
+
const to = result.nodes.findIndex((node) => node.node === "revise");
|
|
6038
|
+
if (from < 0 || to <= from) return rows;
|
|
6039
|
+
return [
|
|
6040
|
+
...rows.slice(0, from),
|
|
6041
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
|
|
6042
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6043
|
+
"div",
|
|
6044
|
+
{
|
|
6045
|
+
"aria-hidden": true,
|
|
6046
|
+
"data-testid": "graph-back-edge",
|
|
6047
|
+
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"
|
|
6048
|
+
}
|
|
6049
|
+
),
|
|
6050
|
+
/* @__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" }),
|
|
6051
|
+
rows.slice(from, to + 1)
|
|
6052
|
+
] }, "back-edge"),
|
|
6053
|
+
...rows.slice(to + 1)
|
|
6054
|
+
];
|
|
6055
|
+
}, [result, breakNode, traffic.byNode, technical]);
|
|
5139
6056
|
return /* @__PURE__ */ jsxRuntime.jsxs(PageShell, { children: [
|
|
5140
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6057
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6058
|
+
PageHeader,
|
|
6059
|
+
{
|
|
6060
|
+
title: "Graphe",
|
|
6061
|
+
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.",
|
|
6062
|
+
actions: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6063
|
+
"div",
|
|
6064
|
+
{
|
|
6065
|
+
className: "flex items-center rounded-md border p-0.5",
|
|
6066
|
+
role: "group",
|
|
6067
|
+
"aria-label": "Registre d'affichage",
|
|
6068
|
+
children: [
|
|
6069
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6070
|
+
uiSdk.Button,
|
|
6071
|
+
{
|
|
6072
|
+
variant: technical ? "ghost" : "secondary",
|
|
6073
|
+
size: "sm",
|
|
6074
|
+
"aria-pressed": !technical,
|
|
6075
|
+
onClick: () => setViewParam(null),
|
|
6076
|
+
children: "Op\xE9rateur"
|
|
6077
|
+
}
|
|
6078
|
+
),
|
|
6079
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6080
|
+
uiSdk.Button,
|
|
6081
|
+
{
|
|
6082
|
+
variant: technical ? "secondary" : "ghost",
|
|
6083
|
+
size: "sm",
|
|
6084
|
+
"aria-pressed": technical,
|
|
6085
|
+
onClick: () => setViewParam("technique"),
|
|
6086
|
+
children: "Technique"
|
|
6087
|
+
}
|
|
6088
|
+
)
|
|
6089
|
+
]
|
|
6090
|
+
}
|
|
6091
|
+
)
|
|
6092
|
+
}
|
|
6093
|
+
),
|
|
5141
6094
|
isLoading ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center py-12", children: [
|
|
5142
6095
|
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Spinner, {}),
|
|
5143
6096
|
" ",
|
|
5144
6097
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-2 text-sm text-muted-foreground", children: "Chargement\u2026" })
|
|
5145
6098
|
] }) : 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
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
6099
|
+
/* @__PURE__ */ jsxRuntime.jsx(VerdictBanner, { verdict, appSlug }),
|
|
6100
|
+
result.globalNotes.map((note2) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6101
|
+
"div",
|
|
6102
|
+
{
|
|
6103
|
+
"data-testid": `graph-global-note-${note2.id}`,
|
|
6104
|
+
className: "rounded-md border border-status-warning/40 bg-status-warning/10 p-3 text-sm text-status-warning",
|
|
6105
|
+
children: [
|
|
6106
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { children: note2.message }),
|
|
6107
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "mt-1 text-xs", children: [
|
|
6108
|
+
"N\u0153uds concern\xE9s (",
|
|
6109
|
+
note2.nodes.length,
|
|
6110
|
+
") :",
|
|
6111
|
+
" ",
|
|
6112
|
+
note2.nodes.map((n) => NODE_LABELS[n]).join(", "),
|
|
6113
|
+
"."
|
|
6114
|
+
] }),
|
|
6115
|
+
technical && note2.detail && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 font-mono text-[10px]", children: note2.detail })
|
|
6116
|
+
]
|
|
6117
|
+
},
|
|
6118
|
+
note2.id
|
|
6119
|
+
)),
|
|
5150
6120
|
!hasCategoryWithAutoReply && categoriesMayBeTruncated && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
5151
6121
|
"La lecture des cat\xE9gories est born\xE9e aux ",
|
|
5152
6122
|
CATEGORY_PAGE_SIZE,
|
|
5153
6123
|
" 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
6124
|
] }),
|
|
5155
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
|
|
6125
|
+
/* @__PURE__ */ jsxRuntime.jsx(Legend, {}),
|
|
6126
|
+
/* @__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.` }),
|
|
6127
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-0 pl-10", children: rail }),
|
|
6128
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
6129
|
+
"\u21BA",
|
|
6130
|
+
" \xAB R\xE9vision \xBB rejoue \xAB \xC9valuation \xBB \u2014 au plus une passe par ticket",
|
|
6131
|
+
technical ? " (\xA73.3)" : "",
|
|
6132
|
+
"."
|
|
6133
|
+
] }),
|
|
6134
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6135
|
+
NodeDetailPanel,
|
|
6136
|
+
{
|
|
6137
|
+
node: selected,
|
|
6138
|
+
traffic: selected ? traffic.byNode[selected.node] : void 0,
|
|
6139
|
+
technical,
|
|
6140
|
+
appSlug,
|
|
6141
|
+
globalNotes: selected ? notesFor(selected.node) : [],
|
|
6142
|
+
onClose: () => setOpenNode(null)
|
|
6143
|
+
}
|
|
6144
|
+
)
|
|
5174
6145
|
] })
|
|
5175
6146
|
] });
|
|
5176
6147
|
}
|
|
@@ -5886,31 +6857,6 @@ function TestPage() {
|
|
|
5886
6857
|
!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
6858
|
] });
|
|
5888
6859
|
}
|
|
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
6860
|
function ExperimentStatusBadge({ experiment }) {
|
|
5915
6861
|
if (experiment.status === "done" && experiment.succeeded) {
|
|
5916
6862
|
return /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: "success", children: "Termin\xE9" });
|