@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.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { GENERATED_RESPONSE_STATUSES, EVALUATION_VERDICTS, WHATSAPP_MODES, validateSettings, AGENT_GUARDRAILS, toCategory,
|
|
1
|
+
import { GENERATED_RESPONSE_STATUSES, EVALUATION_VERDICTS, WHATSAPP_MODES, validateSettings, AGENT_GUARDRAILS, toCategory, toAgent, toGeneratedResponse, toTriageDecision, isGeneratedResponseStatus, toCategoryGroup, toResponseComparison, toDiffAnalysis, NODE_NAMES, settingsToProfile, hasNoDraftNode, guardrailBucket, DEFAULT_LLM_PROVIDER, computeWordDiff, isSendableVerdict, DEFAULT_MAX_TOOL_CALLS, DEFAULT_MIN_CONFIDENCE, DEFAULT_ESCALATION_ENABLED } from '../chunk-SFOPXCD4.js';
|
|
2
2
|
import { useState, useMemo, useRef, useEffect, useCallback, useId } from 'react';
|
|
3
|
-
import { useAppContext, useAppSettings, Card, CardContent,
|
|
3
|
+
import { useAppContext, useAppSettings, DateRangeCompare, Link, Card, CardContent, Badge, KpiCard, CardHeader, CardTitle, AreaChart, StackedBarChart, BarChart, Button, Select, DataTable, useAppApi, useToast, FunnelChart, Spinner, LineChart, Switch, Input, Checkbox, Textarea, comparisonRange, cn, SidePanel, CopyButton, Modal, Tooltip, buttonVariants, AppInvokeError, Table, TableHeader, TableRow, TableHead, TableBody, TableCell, downloadBlob } from '@apotech-os/ui-sdk';
|
|
4
4
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
|
|
6
6
|
function useRecordList(objectKey, query, mapper) {
|
|
@@ -143,33 +143,110 @@ function formatDate(iso) {
|
|
|
143
143
|
function toNameMap(rows) {
|
|
144
144
|
return new Map(rows.map((r) => [r.id, r.name]));
|
|
145
145
|
}
|
|
146
|
-
function windowCutoffIso(days) {
|
|
147
|
-
return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString();
|
|
148
|
-
}
|
|
149
146
|
|
|
150
147
|
// src/ui/dashboard/dashboard-stats.ts
|
|
151
|
-
function sumCounts(rows, countField = "count") {
|
|
152
|
-
return rows.reduce((sum, row) => sum + (Number(row[countField]) || 0), 0);
|
|
153
|
-
}
|
|
154
|
-
function countFor(rows, groupField, value, countField = "count") {
|
|
155
|
-
const row = rows.find((r) => r[groupField] === value);
|
|
156
|
-
return row ? Number(row[countField]) || 0 : 0;
|
|
157
|
-
}
|
|
158
148
|
function bucketDay(row) {
|
|
159
149
|
return String(row["bucket"]).slice(0, 10);
|
|
160
150
|
}
|
|
161
|
-
|
|
151
|
+
var EMPTY_TOTALS = {
|
|
152
|
+
auto: 0,
|
|
153
|
+
human: 0,
|
|
154
|
+
inProgress: 0,
|
|
155
|
+
noReplyNeeded: 0,
|
|
156
|
+
failed: 0
|
|
157
|
+
};
|
|
158
|
+
function outcomeOf(status, autoSendDecision) {
|
|
159
|
+
if (status === "sent") return "auto";
|
|
160
|
+
if (status === "no_reply_needed") return "noReplyNeeded";
|
|
161
|
+
if (status === "failed") return "failed";
|
|
162
|
+
if (status === "invalidated" || status === "expired") return "human";
|
|
163
|
+
return autoSendDecision === "hold" ? "human" : "inProgress";
|
|
164
|
+
}
|
|
165
|
+
function foldOutcomes(rows) {
|
|
166
|
+
const totals = { ...EMPTY_TOTALS };
|
|
167
|
+
for (const row of rows) {
|
|
168
|
+
totals[outcomeOf(row["status"], row["autoSendDecision"])] += Number(row["count"]) || 0;
|
|
169
|
+
}
|
|
170
|
+
return totals;
|
|
171
|
+
}
|
|
172
|
+
function settledCount(totals) {
|
|
173
|
+
return totals.auto + totals.human;
|
|
174
|
+
}
|
|
175
|
+
function autonomyRate(totals) {
|
|
176
|
+
const settled = settledCount(totals);
|
|
177
|
+
return settled > 0 ? totals.auto / settled : Number.NaN;
|
|
178
|
+
}
|
|
179
|
+
function foldDailyOutcomes(rows) {
|
|
162
180
|
const byDay = /* @__PURE__ */ new Map();
|
|
163
|
-
for (const row of
|
|
181
|
+
for (const row of rows) {
|
|
164
182
|
const day = bucketDay(row);
|
|
165
|
-
|
|
183
|
+
const totals = byDay.get(day) ?? { ...EMPTY_TOTALS };
|
|
184
|
+
totals[outcomeOf(row["status"], row["autoSendDecision"])] += Number(row["count"]) || 0;
|
|
185
|
+
byDay.set(day, totals);
|
|
166
186
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
187
|
+
return [...byDay.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([day, totals]) => ({
|
|
188
|
+
day,
|
|
189
|
+
auto: totals.auto,
|
|
190
|
+
human: totals.human,
|
|
191
|
+
rate: settledCount(totals) > 0 ? autonomyRate(totals) : null
|
|
192
|
+
}));
|
|
193
|
+
}
|
|
194
|
+
function fillMissingDays(series, fromIso, toIso) {
|
|
195
|
+
const from = Date.parse(fromIso.slice(0, 10));
|
|
196
|
+
const to = Date.parse(toIso.slice(0, 10));
|
|
197
|
+
if (Number.isNaN(from) || Number.isNaN(to) || to < from) return series;
|
|
198
|
+
const measured = new Map(series.map((point) => [point.day, point]));
|
|
199
|
+
const filled = [];
|
|
200
|
+
for (let t = from; t <= to; t += 864e5) {
|
|
201
|
+
const day = new Date(t).toISOString().slice(0, 10);
|
|
202
|
+
filled.push(measured.get(day) ?? { day, auto: 0, human: 0, rate: null });
|
|
203
|
+
}
|
|
204
|
+
return filled;
|
|
205
|
+
}
|
|
206
|
+
function ratePoints(rate, compareRate) {
|
|
207
|
+
return Number.isNaN(rate) || Number.isNaN(compareRate) ? null : (rate - compareRate) * 100;
|
|
208
|
+
}
|
|
209
|
+
var SIGNAL_MIN_VOLUME = 20;
|
|
210
|
+
var SIGNAL_MIN_POINTS = 3;
|
|
211
|
+
function dashboardSignals(totals, compare) {
|
|
212
|
+
const signals = [];
|
|
213
|
+
const settled = settledCount(totals);
|
|
214
|
+
const rate = autonomyRate(totals);
|
|
215
|
+
if (compare !== null && settled >= SIGNAL_MIN_VOLUME && settledCount(compare) >= SIGNAL_MIN_VOLUME) {
|
|
216
|
+
const points = ratePoints(rate, autonomyRate(compare));
|
|
217
|
+
if (points !== null && Math.abs(points) >= SIGNAL_MIN_POINTS) {
|
|
218
|
+
const move = points < 0 ? "recule" : "progresse";
|
|
219
|
+
signals.push({
|
|
220
|
+
level: points < 0 ? "creuser" : "info",
|
|
221
|
+
text: `Le taux d\u2019autonomie ${move} de ${Math.abs(Math.round(points))} points par rapport \xE0 la p\xE9riode pr\xE9c\xE9dente.`
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
if (totals.failed > 0) {
|
|
226
|
+
signals.push({
|
|
227
|
+
level: "creuser",
|
|
228
|
+
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.`
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
if (totals.inProgress > 0) {
|
|
232
|
+
signals.push({
|
|
233
|
+
level: "info",
|
|
234
|
+
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.`
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
if (totals.noReplyNeeded > 0) {
|
|
238
|
+
signals.push({
|
|
239
|
+
level: "info",
|
|
240
|
+
text: `${totals.noReplyNeeded} demande${totals.noReplyNeeded > 1 ? "s" : ""} ne n\xE9cessitai${totals.noReplyNeeded > 1 ? "ent" : "t"} aucune r\xE9ponse : hors du taux d\u2019autonomie.`
|
|
241
|
+
});
|
|
171
242
|
}
|
|
172
|
-
|
|
243
|
+
if (compare !== null && settled > 0 && settledCount(compare) < SIGNAL_MIN_VOLUME) {
|
|
244
|
+
signals.push({
|
|
245
|
+
level: "info",
|
|
246
|
+
text: "La p\xE9riode pr\xE9c\xE9dente compte trop peu de demandes r\xE9gl\xE9es pour que la comparaison veuille dire quelque chose."
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
return signals;
|
|
173
250
|
}
|
|
174
251
|
var DEFAULT_TOP_N = 6;
|
|
175
252
|
function foldCategoryBreakdown(rows, categoryNames, topN = DEFAULT_TOP_N) {
|
|
@@ -182,189 +259,361 @@ function foldCategoryBreakdown(rows, categoryNames, topN = DEFAULT_TOP_N) {
|
|
|
182
259
|
const tail = measured.slice(topN).reduce((sum, bar) => sum + bar.value, 0);
|
|
183
260
|
return [...measured.slice(0, topN), { label: "Autres", value: tail }];
|
|
184
261
|
}
|
|
185
|
-
var
|
|
186
|
-
|
|
262
|
+
var POINTS_FORMAT = new Intl.NumberFormat("fr-FR", {
|
|
263
|
+
maximumFractionDigits: 1,
|
|
264
|
+
signDisplay: "exceptZero"
|
|
265
|
+
});
|
|
187
266
|
function formatRate(value) {
|
|
188
|
-
return Number.isNaN(value) ? "\u2014" : `${Math.round(value * 100)}%`;
|
|
267
|
+
return Number.isNaN(value) ? "\u2014" : `${Math.round(value * 100)} %`;
|
|
189
268
|
}
|
|
190
|
-
function
|
|
191
|
-
|
|
269
|
+
function AutonomyHero({
|
|
270
|
+
rate,
|
|
271
|
+
compareRate,
|
|
272
|
+
caption
|
|
273
|
+
}) {
|
|
274
|
+
const points = ratePoints(rate, compareRate);
|
|
275
|
+
return /* @__PURE__ */ jsx(Card, { className: "border-primary/25 bg-gradient-to-br from-primary/10 via-card to-card", children: /* @__PURE__ */ jsxs(CardContent, { className: "space-y-1 p-4", children: [
|
|
276
|
+
/* @__PURE__ */ jsxs("p", { className: "flex items-center gap-2 text-[11px] font-semibold uppercase tracking-[0.06em] text-muted-foreground", children: [
|
|
277
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "inline-block size-2 rounded-full bg-primary" }),
|
|
278
|
+
"Taux d\u2019autonomie"
|
|
279
|
+
] }),
|
|
280
|
+
/* @__PURE__ */ jsx("p", { className: "text-4xl font-semibold leading-tight tabular-nums text-foreground", children: formatRate(rate) }),
|
|
281
|
+
points !== null && // Direction is in the sign as well as the colour — `KpiCard`'s own
|
|
282
|
+
// rule, restated here because this card does not go through it.
|
|
283
|
+
/* @__PURE__ */ jsxs(
|
|
284
|
+
"p",
|
|
285
|
+
{
|
|
286
|
+
className: `text-xs font-semibold tabular-nums ${points < 0 ? "text-status-blocked" : "text-status-success"}`,
|
|
287
|
+
children: [
|
|
288
|
+
POINTS_FORMAT.format(points),
|
|
289
|
+
" pts",
|
|
290
|
+
/* @__PURE__ */ jsxs("span", { className: "ml-1 font-normal text-muted-foreground", children: [
|
|
291
|
+
"vs ",
|
|
292
|
+
formatRate(compareRate)
|
|
293
|
+
] })
|
|
294
|
+
]
|
|
295
|
+
}
|
|
296
|
+
),
|
|
297
|
+
/* @__PURE__ */ jsx("p", { className: "pt-1 text-xs text-muted-foreground", children: caption })
|
|
298
|
+
] }) });
|
|
299
|
+
}
|
|
300
|
+
var DASHBOARD_PRESETS = [
|
|
301
|
+
{ key: "last7", label: "7 derniers jours" },
|
|
302
|
+
{ key: "last30", label: "30 derniers jours" }
|
|
303
|
+
];
|
|
304
|
+
var WEEKLY_BUCKET_FROM_DAYS = 46;
|
|
305
|
+
var DAY_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
|
|
306
|
+
var EPOCH_ISO = "1970-01-01T00:00:00.000Z";
|
|
307
|
+
function startOfDayIso(day) {
|
|
308
|
+
return day !== void 0 && DAY_PATTERN.test(day) ? `${day}T00:00:00.000Z` : EPOCH_ISO;
|
|
309
|
+
}
|
|
310
|
+
function endOfDayIso(day) {
|
|
311
|
+
return DAY_PATTERN.test(day) ? `${day}T23:59:59.999Z` : (/* @__PURE__ */ new Date()).toISOString();
|
|
312
|
+
}
|
|
313
|
+
function dayCount(bounds) {
|
|
314
|
+
const from = Date.parse(bounds.fromIso);
|
|
315
|
+
const to = Date.parse(bounds.toIso);
|
|
316
|
+
if (Number.isNaN(from) || Number.isNaN(to)) return 0;
|
|
317
|
+
return Math.max(1, Math.round((to - from) / 864e5));
|
|
318
|
+
}
|
|
319
|
+
function periodBoundsOf(value) {
|
|
320
|
+
const current = {
|
|
321
|
+
fromIso: startOfDayIso(value.range.from),
|
|
322
|
+
toIso: endOfDayIso(value.range.to)
|
|
323
|
+
};
|
|
324
|
+
const compare = value.compare === "none" ? void 0 : value.compareRange ?? comparisonRange(value.preset, value.range, value.compare);
|
|
325
|
+
const days = dayCount(current);
|
|
326
|
+
return {
|
|
327
|
+
current,
|
|
328
|
+
previous: compare === void 0 ? null : { fromIso: startOfDayIso(compare.from), toIso: endOfDayIso(compare.to) },
|
|
329
|
+
days,
|
|
330
|
+
interval: days >= WEEKLY_BUCKET_FROM_DAYS ? "week" : "day"
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
function defaultPeriod(today = /* @__PURE__ */ new Date()) {
|
|
334
|
+
const to = today.toISOString().slice(0, 10);
|
|
335
|
+
const start = new Date(today);
|
|
336
|
+
start.setUTCDate(start.getUTCDate() - 29);
|
|
337
|
+
const range = { from: start.toISOString().slice(0, 10), to };
|
|
338
|
+
const compareRange = comparisonRange("last30", range, "previous_period");
|
|
339
|
+
return {
|
|
340
|
+
preset: "last30",
|
|
341
|
+
range,
|
|
342
|
+
compare: "previous_period",
|
|
343
|
+
...compareRange === void 0 ? {} : { compareRange }
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
var OUTCOME_METRICS = [{ op: "count", as: "count" }];
|
|
347
|
+
var OUTCOME_GROUP_BY = ["status", "autoSendDecision"];
|
|
348
|
+
function formatCount(value) {
|
|
349
|
+
return Number.isNaN(value) ? "\u2026" : value.toLocaleString("fr-FR");
|
|
192
350
|
}
|
|
193
|
-
function
|
|
194
|
-
|
|
351
|
+
function dayLabel(day) {
|
|
352
|
+
const parsed = /* @__PURE__ */ new Date(`${day}T00:00:00.000Z`);
|
|
353
|
+
return Number.isNaN(parsed.getTime()) ? day : parsed.toLocaleDateString("fr-FR", { day: "2-digit", month: "2-digit", timeZone: "UTC" });
|
|
195
354
|
}
|
|
196
355
|
function DashboardPage() {
|
|
197
356
|
const { appSlug } = useAppContext();
|
|
198
|
-
const [
|
|
199
|
-
const { settings
|
|
357
|
+
const [period, setPeriod] = useState(() => defaultPeriod());
|
|
358
|
+
const { settings } = useAppSettings();
|
|
200
359
|
const timezone = settings?.statsTimezone ?? "UTC";
|
|
201
|
-
const
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
360
|
+
const periodKey = JSON.stringify(period);
|
|
361
|
+
const bounds = useMemo(() => periodBoundsOf(JSON.parse(periodKey)), [periodKey]);
|
|
362
|
+
const currentFilter = { generatedAt: { gte: bounds.current.fromIso, lte: bounds.current.toIso } };
|
|
363
|
+
const previousBounds = bounds.previous ?? bounds.current;
|
|
364
|
+
const {
|
|
365
|
+
rows: dailyRows,
|
|
366
|
+
isLoading: dailyLoading,
|
|
367
|
+
error: dailyError
|
|
368
|
+
} = useAggregate("generated-response", {
|
|
369
|
+
filter: currentFilter,
|
|
370
|
+
groupBy: OUTCOME_GROUP_BY,
|
|
371
|
+
bucket: { field: "generatedAt", interval: bounds.interval, tz: timezone },
|
|
372
|
+
metrics: OUTCOME_METRICS
|
|
211
373
|
});
|
|
212
|
-
const { rows:
|
|
213
|
-
filter: {
|
|
214
|
-
|
|
374
|
+
const { rows: previousRows, isLoading: previousLoading } = useAggregate("generated-response", {
|
|
375
|
+
filter: { generatedAt: { gte: previousBounds.fromIso, lte: previousBounds.toIso } },
|
|
376
|
+
groupBy: OUTCOME_GROUP_BY,
|
|
377
|
+
metrics: OUTCOME_METRICS
|
|
215
378
|
});
|
|
216
|
-
const {
|
|
217
|
-
|
|
379
|
+
const {
|
|
380
|
+
rows: categoryCounts,
|
|
381
|
+
isLoading: categoryLoading,
|
|
382
|
+
error: categoryError
|
|
383
|
+
} = useAggregate("triage-decision", {
|
|
384
|
+
filter: { decidedAt: { gte: bounds.current.fromIso, lte: bounds.current.toIso } },
|
|
218
385
|
groupBy: ["categoryId"],
|
|
219
|
-
metrics:
|
|
220
|
-
});
|
|
221
|
-
const { rows: dailySent, error: dailySentError } = useAggregate("generated-response", {
|
|
222
|
-
filter: { generatedAt: { gte: cutoffIso }, status: { eq: "sent" } },
|
|
223
|
-
bucket: { field: "generatedAt", interval: "day", tz: timezone },
|
|
224
|
-
metrics: [{ op: "count", as: "count" }]
|
|
225
|
-
});
|
|
226
|
-
const { rows: dailyHeld, error: dailyHeldError } = useAggregate("generated-response", {
|
|
227
|
-
filter: { generatedAt: { gte: cutoffIso }, autoSendDecision: { eq: "hold" } },
|
|
228
|
-
bucket: { field: "generatedAt", interval: "day", tz: timezone },
|
|
229
|
-
metrics: [{ op: "count", as: "count" }]
|
|
386
|
+
metrics: OUTCOME_METRICS
|
|
230
387
|
});
|
|
231
|
-
const dailySeriesError = dailySentError !== void 0 || dailyHeldError !== void 0;
|
|
232
388
|
const { rows: categories } = useRecordList("category", { limit: 500 }, toCategory);
|
|
233
389
|
const categoryNames = useMemo(() => toNameMap(categories), [categories]);
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
} = useRecordList(
|
|
239
|
-
"triage-decision",
|
|
240
|
-
{ sort: [{ field: "decidedAt", direction: "desc" }], limit: RECENT_ACTIVITY_LIMIT },
|
|
241
|
-
toTriageDecision
|
|
390
|
+
const totals = useMemo(() => foldOutcomes(dailyRows), [dailyRows]);
|
|
391
|
+
const compareTotals = useMemo(
|
|
392
|
+
() => bounds.previous === null ? null : foldOutcomes(previousRows),
|
|
393
|
+
[bounds.previous, previousRows]
|
|
242
394
|
);
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
395
|
+
const daily = useMemo(() => {
|
|
396
|
+
const folded = foldDailyOutcomes(dailyRows);
|
|
397
|
+
return bounds.interval === "day" ? fillMissingDays(folded, bounds.current.fromIso, bounds.current.toIso) : folded;
|
|
398
|
+
}, [dailyRows, bounds]);
|
|
399
|
+
const rate = autonomyRate(totals);
|
|
400
|
+
const compareRate = compareTotals === null ? Number.NaN : autonomyRate(compareTotals);
|
|
401
|
+
const settled = settledCount(totals);
|
|
402
|
+
const signals = useMemo(() => dashboardSignals(totals, compareTotals), [totals, compareTotals]);
|
|
247
403
|
const categoryBars = foldCategoryBreakdown(categoryCounts, categoryNames);
|
|
248
|
-
const
|
|
249
|
-
const
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
/* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsxs(CardContent, { className: "space-y-1 p-4", children: [
|
|
262
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Escalades" }),
|
|
263
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: escalatedLoading ? "\u2026" : escalatedError ? "Indisponible" : `${escalatedTotal} au total` })
|
|
264
|
-
] }) })
|
|
265
|
-
] }) })
|
|
266
|
-
] });
|
|
267
|
-
const columns = [
|
|
268
|
-
{ key: "ticketId", header: "Ticket", cell: (row) => row.ticketId },
|
|
269
|
-
{ key: "category", header: "Cat\xE9gorie", cell: (row) => row.categoryId && categoryNames.get(row.categoryId) || "\u2014" },
|
|
270
|
-
{
|
|
271
|
-
key: "escalated",
|
|
272
|
-
header: "Escalade",
|
|
273
|
-
cell: (row) => row.escalated ? /* @__PURE__ */ jsx(Badge, { variant: "warning", children: "Escalad\xE9" }) : /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "Non escalad\xE9" })
|
|
274
|
-
},
|
|
275
|
-
{ key: "decidedAt", header: "Date", cell: (row) => formatDate(row.decidedAt) }
|
|
276
|
-
];
|
|
404
|
+
const loading = dailyLoading || previousLoading;
|
|
405
|
+
const chartData = daily.map((point) => ({ ...point, jour: dayLabel(point.day) }));
|
|
406
|
+
const bucketWord = bounds.interval === "day" ? "jour" : "semaine";
|
|
407
|
+
const aCreuser = signals.find((signal) => signal.level === "creuser");
|
|
408
|
+
const lead = loading ? null : settled === 0 ? {
|
|
409
|
+
alert: false,
|
|
410
|
+
title: "Aucune demande r\xE9gl\xE9e sur cette p\xE9riode",
|
|
411
|
+
detail: "Choisis une autre p\xE9riode, ou v\xE9rifie que le triage tourne (Param\xE8tres \u203A Triage)."
|
|
412
|
+
} : aCreuser !== void 0 ? { alert: true, title: "Un point m\xE9rite ton attention", detail: aCreuser.text } : {
|
|
413
|
+
alert: false,
|
|
414
|
+
title: `${formatRate(rate)} des demandes r\xE9gl\xE9es sans personne`,
|
|
415
|
+
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.`
|
|
416
|
+
};
|
|
277
417
|
return /* @__PURE__ */ jsxs(PageShell, { children: [
|
|
278
418
|
/* @__PURE__ */ jsx(
|
|
279
419
|
PageHeader,
|
|
280
420
|
{
|
|
281
421
|
title: "Tableau de bord",
|
|
282
|
-
description: "
|
|
283
|
-
actions: /* @__PURE__ */
|
|
284
|
-
/* @__PURE__ */
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
422
|
+
description: "Ce que l\u2019IA a r\xE9gl\xE9 seule sur la p\xE9riode, et ce qui est retomb\xE9 sur un humain.",
|
|
423
|
+
actions: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
424
|
+
/* @__PURE__ */ jsx(
|
|
425
|
+
DateRangeCompare,
|
|
426
|
+
{
|
|
427
|
+
value: period,
|
|
428
|
+
onChange: setPeriod,
|
|
429
|
+
comparable: true,
|
|
430
|
+
presets: DASHBOARD_PRESETS,
|
|
431
|
+
align: "end"
|
|
432
|
+
}
|
|
433
|
+
),
|
|
291
434
|
/* @__PURE__ */ jsx(Link, { href: `/espace/${appSlug}/pipeline`, children: "Voir le pipeline complet" })
|
|
292
|
-
] })
|
|
435
|
+
] })
|
|
293
436
|
}
|
|
294
437
|
),
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
298
|
-
/* @__PURE__ */ jsx(KpiCard, { label: "G\xE9n\xE9r\xE9", value: statusLoading ? Number.NaN : totalGenerated, formatValue: (v) => Number.isNaN(v) ? "\u2026" : String(v) }),
|
|
299
|
-
/* @__PURE__ */ 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)." })
|
|
300
|
-
] }),
|
|
301
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
302
|
-
/* @__PURE__ */ jsx(
|
|
303
|
-
KpiCard,
|
|
304
|
-
{
|
|
305
|
-
label: "Taux d'envoi auto",
|
|
306
|
-
value: statusLoading || autoSendLoading ? Number.NaN : rateOrNaN(sentCount, totalGenerated),
|
|
307
|
-
formatValue: formatRate
|
|
308
|
-
}
|
|
309
|
-
),
|
|
310
|
-
/* @__PURE__ */ 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." })
|
|
311
|
-
] }),
|
|
438
|
+
lead !== null && /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsxs(CardContent, { className: "flex items-start gap-3 p-4", children: [
|
|
439
|
+
/* @__PURE__ */ jsx(Badge, { variant: lead.alert ? "warning" : "brand", children: lead.alert ? "\xC0 creuser" : "Cap" }),
|
|
312
440
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
313
|
-
/* @__PURE__ */ jsx(
|
|
314
|
-
|
|
315
|
-
{
|
|
316
|
-
label: "Taux de blocage",
|
|
317
|
-
value: statusLoading || autoSendLoading ? Number.NaN : rateOrNaN(heldCount, totalGenerated),
|
|
318
|
-
formatValue: formatRate,
|
|
319
|
-
lowerIsBetter: true
|
|
320
|
-
}
|
|
321
|
-
),
|
|
322
|
-
/* @__PURE__ */ 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)." })
|
|
441
|
+
/* @__PURE__ */ jsx("p", { className: "text-base font-semibold leading-snug", children: lead.title }),
|
|
442
|
+
/* @__PURE__ */ jsx("p", { className: "mt-1 text-sm leading-relaxed text-muted-foreground", children: lead.detail })
|
|
323
443
|
] })
|
|
324
|
-
] }),
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
444
|
+
] }) }),
|
|
445
|
+
/* @__PURE__ */ jsxs(
|
|
446
|
+
"div",
|
|
447
|
+
{
|
|
448
|
+
"data-testid": "dashboard-kpis",
|
|
449
|
+
className: "grid grid-cols-1 gap-4 sm:grid-cols-[1.3fr_1fr_1fr]",
|
|
450
|
+
children: [
|
|
451
|
+
/* @__PURE__ */ jsx(
|
|
452
|
+
AutonomyHero,
|
|
453
|
+
{
|
|
454
|
+
rate: loading ? Number.NaN : rate,
|
|
455
|
+
compareRate,
|
|
456
|
+
caption: loading ? "Calcul en cours\u2026" : `${formatCount(totals.auto)} r\xE9gl\xE9es par l\u2019IA sur ${formatCount(settled)} demandes r\xE9gl\xE9es.`
|
|
457
|
+
}
|
|
458
|
+
),
|
|
459
|
+
/* @__PURE__ */ jsx(
|
|
460
|
+
KpiCard,
|
|
461
|
+
{
|
|
462
|
+
label: "R\xE9gl\xE9 par l\u2019IA",
|
|
463
|
+
value: loading ? Number.NaN : totals.auto,
|
|
464
|
+
...compareTotals === null ? {} : { compareValue: compareTotals.auto },
|
|
465
|
+
formatValue: formatCount
|
|
466
|
+
}
|
|
467
|
+
),
|
|
468
|
+
/* @__PURE__ */ jsx(
|
|
469
|
+
KpiCard,
|
|
470
|
+
{
|
|
471
|
+
label: "Repris par un humain",
|
|
472
|
+
value: loading ? Number.NaN : totals.human,
|
|
473
|
+
...compareTotals === null ? {} : { compareValue: compareTotals.human },
|
|
474
|
+
formatValue: formatCount,
|
|
475
|
+
lowerIsBetter: true
|
|
476
|
+
}
|
|
477
|
+
)
|
|
478
|
+
]
|
|
479
|
+
}
|
|
480
|
+
),
|
|
481
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-3", children: [
|
|
482
|
+
/* @__PURE__ */ jsx(
|
|
483
|
+
KpiCard,
|
|
484
|
+
{
|
|
485
|
+
label: "Encore en cours",
|
|
486
|
+
value: loading ? Number.NaN : totals.inProgress,
|
|
487
|
+
formatValue: formatCount
|
|
488
|
+
}
|
|
489
|
+
),
|
|
490
|
+
/* @__PURE__ */ jsx(
|
|
491
|
+
KpiCard,
|
|
492
|
+
{
|
|
493
|
+
label: "Sans r\xE9ponse n\xE9cessaire",
|
|
494
|
+
value: loading ? Number.NaN : totals.noReplyNeeded,
|
|
495
|
+
formatValue: formatCount
|
|
496
|
+
}
|
|
497
|
+
),
|
|
353
498
|
/* @__PURE__ */ jsx(
|
|
354
|
-
|
|
499
|
+
KpiCard,
|
|
355
500
|
{
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
error: activityError ? "Erreur lors du chargement de l\u2019activit\xE9 r\xE9cente." : void 0,
|
|
362
|
-
empty: "Aucune d\xE9cision de triage enregistr\xE9e pour l\u2019instant."
|
|
501
|
+
label: "\xC9checs techniques",
|
|
502
|
+
value: loading ? Number.NaN : totals.failed,
|
|
503
|
+
...compareTotals === null ? {} : { compareValue: compareTotals.failed },
|
|
504
|
+
formatValue: formatCount,
|
|
505
|
+
lowerIsBetter: true
|
|
363
506
|
}
|
|
364
507
|
)
|
|
508
|
+
] }),
|
|
509
|
+
/* @__PURE__ */ 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." }),
|
|
510
|
+
dailyError !== void 0 && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: "Erreur lors du calcul des chiffres cl\xE9s." }),
|
|
511
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-4 lg:grid-cols-2", children: [
|
|
512
|
+
/* @__PURE__ */ jsxs(Card, { children: [
|
|
513
|
+
/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsxs(CardTitle, { className: "text-sm", children: [
|
|
514
|
+
"Automatique ou humain, ",
|
|
515
|
+
bucketWord,
|
|
516
|
+
" par ",
|
|
517
|
+
bucketWord
|
|
518
|
+
] }) }),
|
|
519
|
+
/* @__PURE__ */ jsx(CardContent, { children: dailyError !== void 0 ? /* @__PURE__ */ jsxs("p", { className: "text-sm text-destructive", children: [
|
|
520
|
+
"Impossible de calculer l\u2019\xE9volution par ",
|
|
521
|
+
bucketWord,
|
|
522
|
+
"."
|
|
523
|
+
] }) : chartData.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Aucune journ\xE9e mesur\xE9e sur cette p\xE9riode." }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
524
|
+
/* @__PURE__ */ jsx("p", { className: "mb-1 text-xs font-medium uppercase tracking-widest text-muted-foreground", children: "Part r\xE9gl\xE9e par l\u2019IA" }),
|
|
525
|
+
/* @__PURE__ */ jsx(
|
|
526
|
+
AreaChart,
|
|
527
|
+
{
|
|
528
|
+
data: chartData,
|
|
529
|
+
x: "jour",
|
|
530
|
+
series: [{ key: "rate", label: "Taux d\u2019autonomie" }],
|
|
531
|
+
formatValue: formatRate,
|
|
532
|
+
height: 150,
|
|
533
|
+
hideLegend: true
|
|
534
|
+
}
|
|
535
|
+
),
|
|
536
|
+
/* @__PURE__ */ jsx("p", { className: "mb-1 mt-4 text-xs font-medium uppercase tracking-widest text-muted-foreground", children: "Demandes r\xE9gl\xE9es, en volume" }),
|
|
537
|
+
/* @__PURE__ */ jsx(
|
|
538
|
+
StackedBarChart,
|
|
539
|
+
{
|
|
540
|
+
data: chartData,
|
|
541
|
+
x: "jour",
|
|
542
|
+
label: `Demandes r\xE9gl\xE9es par ${bucketWord}`,
|
|
543
|
+
series: [
|
|
544
|
+
{ key: "auto", label: "R\xE9gl\xE9 par l\u2019IA", colorIndex: 0 },
|
|
545
|
+
{ key: "human", label: "Repris par un humain", colorIndex: 1 }
|
|
546
|
+
],
|
|
547
|
+
formatValue: formatCount,
|
|
548
|
+
height: 150
|
|
549
|
+
}
|
|
550
|
+
),
|
|
551
|
+
/* @__PURE__ */ jsxs("p", { className: "mt-3 text-xs leading-relaxed text-muted-foreground", children: [
|
|
552
|
+
"La courbe est la ",
|
|
553
|
+
/* @__PURE__ */ jsx("strong", { children: "part" }),
|
|
554
|
+
" r\xE9gl\xE9e sans personne ; les barres sont le",
|
|
555
|
+
" ",
|
|
556
|
+
/* @__PURE__ */ jsx("strong", { children: "volume" }),
|
|
557
|
+
" qu\u2019elle recouvre. Un ",
|
|
558
|
+
bucketWord,
|
|
559
|
+
" \xE0 100 % sur deux demandes n\u2019est pas la m\xEAme nouvelle qu\u2019un ",
|
|
560
|
+
bucketWord,
|
|
561
|
+
" \xE0 80 % sur deux cents."
|
|
562
|
+
] }),
|
|
563
|
+
/* @__PURE__ */ jsxs("p", { className: "mt-1 text-xs leading-relaxed text-muted-foreground", children: [
|
|
564
|
+
"Un trou dans la courbe veut dire \xAB rien de r\xE9gl\xE9 ce ",
|
|
565
|
+
bucketWord,
|
|
566
|
+
"-l\xE0 \xBB, jamais \xAB 0 % \xBB : sans d\xE9nominateur, il n\u2019y a pas de taux \xE0 tracer."
|
|
567
|
+
] })
|
|
568
|
+
] }) })
|
|
569
|
+
] }),
|
|
570
|
+
/* @__PURE__ */ jsxs(Card, { children: [
|
|
571
|
+
/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "text-sm", children: "R\xE9partition par cat\xE9gorie" }) }),
|
|
572
|
+
/* @__PURE__ */ jsx(CardContent, { children: categoryLoading ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Chargement\u2026" }) : categoryError !== void 0 ? /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: "Impossible de calculer la r\xE9partition par cat\xE9gorie." }) : categoryBars.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Aucun volume calcul\xE9 pour l'instant sur cette p\xE9riode." }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
573
|
+
/* @__PURE__ */ jsx(
|
|
574
|
+
BarChart,
|
|
575
|
+
{
|
|
576
|
+
data: categoryBars,
|
|
577
|
+
x: "label",
|
|
578
|
+
series: [{ key: "value", label: "Volume", colorIndex: 0 }]
|
|
579
|
+
}
|
|
580
|
+
),
|
|
581
|
+
/* @__PURE__ */ 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." })
|
|
582
|
+
] }) })
|
|
583
|
+
] })
|
|
584
|
+
] }),
|
|
585
|
+
/* @__PURE__ */ jsxs(Card, { children: [
|
|
586
|
+
/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "text-sm", children: "Signaux \xE0 surveiller" }) }),
|
|
587
|
+
/* @__PURE__ */ jsx(CardContent, { children: signals.length === 0 ? /* @__PURE__ */ 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__ */ jsx("div", { className: "flex flex-col gap-3", children: signals.map((signal) => /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
|
|
588
|
+
/* @__PURE__ */ jsx(Badge, { variant: signal.level === "creuser" ? "warning" : "neutral", children: signal.level === "creuser" ? "\xC0 creuser" : "Info" }),
|
|
589
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm leading-relaxed", children: signal.text })
|
|
590
|
+
] }, signal.text)) }) })
|
|
365
591
|
] })
|
|
366
592
|
] });
|
|
367
593
|
}
|
|
594
|
+
function isHttpUrl(url) {
|
|
595
|
+
try {
|
|
596
|
+
const { protocol } = new URL(url);
|
|
597
|
+
return protocol === "http:" || protocol === "https:";
|
|
598
|
+
} catch {
|
|
599
|
+
return false;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
function TicketLink({ ticketId, url, label }) {
|
|
603
|
+
if (!url || !isHttpUrl(url)) return /* @__PURE__ */ jsx(Fragment, { children: label ?? ticketId });
|
|
604
|
+
return /* @__PURE__ */ jsx(
|
|
605
|
+
Link,
|
|
606
|
+
{
|
|
607
|
+
href: url,
|
|
608
|
+
target: "_blank",
|
|
609
|
+
rel: "noopener noreferrer",
|
|
610
|
+
className: "font-medium",
|
|
611
|
+
title: "Ouvrir le ticket dans Gorgias",
|
|
612
|
+
onClick: (event) => event.stopPropagation(),
|
|
613
|
+
children: label ?? ticketId
|
|
614
|
+
}
|
|
615
|
+
);
|
|
616
|
+
}
|
|
368
617
|
var UNCONFIGURED = { baseUrl: null, projectId: null };
|
|
369
618
|
function useLangfuseConfig() {
|
|
370
619
|
const { appSlug } = useAppContext();
|
|
@@ -566,6 +815,7 @@ function DetailPanel({
|
|
|
566
815
|
onClose
|
|
567
816
|
}) {
|
|
568
817
|
return /* @__PURE__ */ jsx(SidePanel, { open: true, onClose, title: `Ticket ${decision.ticketId}`, description: categoryName, children: /* @__PURE__ */ jsxs("div", { className: "space-y-4 text-sm", children: [
|
|
818
|
+
decision.ticketUrl && /* @__PURE__ */ jsx("p", { children: /* @__PURE__ */ jsx(TicketLink, { ticketId: decision.ticketId, url: decision.ticketUrl, label: "Ouvrir le ticket dans Gorgias" }) }),
|
|
569
819
|
decision.status === "error" && /* @__PURE__ */ jsxs("div", { className: "rounded-md bg-destructive/10 p-3 text-destructive", children: [
|
|
570
820
|
/* @__PURE__ */ jsx("p", { className: "text-xs font-semibold uppercase tracking-wider", children: TRIAGE_DECISION_STATUS_LABELS.error }),
|
|
571
821
|
decision.error && /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs", children: decision.error })
|
|
@@ -718,7 +968,7 @@ function TicketsPage() {
|
|
|
718
968
|
return withOutcome.filter((r) => r.job && responseOutcome(r.job).variant === outcomeFilter);
|
|
719
969
|
}, [decisions, jobByDecisionId, outcomeFilter]);
|
|
720
970
|
const columns = [
|
|
721
|
-
{ key: "ticketId", header: "Ticket", cell: ({ decision }) => decision.ticketId },
|
|
971
|
+
{ key: "ticketId", header: "Ticket", cell: ({ decision }) => /* @__PURE__ */ jsx(TicketLink, { ticketId: decision.ticketId, url: decision.ticketUrl }) },
|
|
722
972
|
{
|
|
723
973
|
key: "category",
|
|
724
974
|
header: "Cat\xE9gorie",
|
|
@@ -1015,7 +1265,7 @@ function computePipelineStats(rows, timezone = "UTC") {
|
|
|
1015
1265
|
}
|
|
1016
1266
|
var STATS_PAGE_SIZE = 200;
|
|
1017
1267
|
var TABLE_PAGE_SIZE = 200;
|
|
1018
|
-
var
|
|
1268
|
+
var WINDOW_OPTIONS = [7, 14, 30];
|
|
1019
1269
|
var DECISION_OPTIONS = [
|
|
1020
1270
|
{ value: "", label: "Tous" },
|
|
1021
1271
|
{ value: "sent", label: "Envoy\xE9s auto" },
|
|
@@ -1043,7 +1293,7 @@ function buildTableFilter(decision, status) {
|
|
|
1043
1293
|
function countOrEllipsis(value) {
|
|
1044
1294
|
return Number.isNaN(value) ? "\u2026" : String(value);
|
|
1045
1295
|
}
|
|
1046
|
-
function
|
|
1296
|
+
function windowCutoffIso(days) {
|
|
1047
1297
|
return new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString();
|
|
1048
1298
|
}
|
|
1049
1299
|
function ConfidenceCell({ confidence }) {
|
|
@@ -1131,7 +1381,7 @@ function PipelinePage() {
|
|
|
1131
1381
|
const toast = useToast();
|
|
1132
1382
|
const [isTriaging, setIsTriaging] = useState(false);
|
|
1133
1383
|
const isTriagingRef = useRef(false);
|
|
1134
|
-
const [windowDays, setWindowDays] = useState(
|
|
1384
|
+
const [windowDays, setWindowDays] = useState(WINDOW_OPTIONS[0]);
|
|
1135
1385
|
const [decisionFilter, setDecisionFilter] = useState("");
|
|
1136
1386
|
const [statusFilter, setStatusFilter] = useState("");
|
|
1137
1387
|
const [verdictFilter, setVerdictFilter] = useState("");
|
|
@@ -1166,7 +1416,7 @@ function PipelinePage() {
|
|
|
1166
1416
|
const categoryNames = useMemo(() => toNameMap(categories), [categories]);
|
|
1167
1417
|
const agentNames = useMemo(() => toNameMap(agents), [agents]);
|
|
1168
1418
|
const windowedStatsRows = useMemo(() => {
|
|
1169
|
-
const cutoff =
|
|
1419
|
+
const cutoff = windowCutoffIso(windowDays);
|
|
1170
1420
|
return statsRows.filter((row) => row.generatedAt !== null && row.generatedAt >= cutoff);
|
|
1171
1421
|
}, [statsRows, windowDays]);
|
|
1172
1422
|
const stats = useMemo(
|
|
@@ -1261,7 +1511,7 @@ function PipelinePage() {
|
|
|
1261
1511
|
),
|
|
1262
1512
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1263
1513
|
/* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "Fen\xEAtre :" }),
|
|
1264
|
-
|
|
1514
|
+
WINDOW_OPTIONS.map((days) => /* @__PURE__ */ jsxs(Button, { size: "sm", variant: windowDays === days ? "default" : "outline", onClick: () => setWindowDays(days), children: [
|
|
1265
1515
|
days,
|
|
1266
1516
|
" j"
|
|
1267
1517
|
] }, days))
|
|
@@ -2840,6 +3090,7 @@ function StatusBadge({ status, error }) {
|
|
|
2840
3090
|
}
|
|
2841
3091
|
function DetailPanel3({ row, categoryName, onClose }) {
|
|
2842
3092
|
return /* @__PURE__ */ jsx(SidePanel, { open: true, onClose, title: `Ticket ${row.ticketId}`, description: categoryName, children: /* @__PURE__ */ jsxs("div", { className: "space-y-4 text-sm", children: [
|
|
3093
|
+
row.ticketUrl && /* @__PURE__ */ jsx("p", { children: /* @__PURE__ */ jsx(TicketLink, { ticketId: row.ticketId, url: row.ticketUrl, label: "Ouvrir le ticket dans Gorgias" }) }),
|
|
2843
3094
|
row.reasoning && /* @__PURE__ */ jsxs("div", { children: [
|
|
2844
3095
|
/* @__PURE__ */ jsx("p", { className: "mb-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Raison du triage" }),
|
|
2845
3096
|
/* @__PURE__ */ jsx("p", { children: row.reasoning })
|
|
@@ -2897,7 +3148,7 @@ function EscalationsPage() {
|
|
|
2897
3148
|
const { rows: categories } = useRecordList("category", { limit: 500 }, toCategory);
|
|
2898
3149
|
const categoryNames = useMemo(() => toNameMap(categories), [categories]);
|
|
2899
3150
|
const columns = [
|
|
2900
|
-
{ key: "ticketId", header: "Ticket", cell: (row) => row.ticketId },
|
|
3151
|
+
{ key: "ticketId", header: "Ticket", cell: (row) => /* @__PURE__ */ jsx(TicketLink, { ticketId: row.ticketId, url: row.ticketUrl }) },
|
|
2901
3152
|
{ key: "category", header: "Cat\xE9gorie", cell: (row) => row.categoryId && categoryNames.get(row.categoryId) || "\u2014" },
|
|
2902
3153
|
{ key: "tag", header: "Tag", cell: (row) => row.tag ? /* @__PURE__ */ jsx("code", { className: "text-xs", children: row.tag }) : "\u2014" },
|
|
2903
3154
|
{
|
|
@@ -4345,16 +4596,59 @@ function SettingsPage() {
|
|
|
4345
4596
|
] })
|
|
4346
4597
|
);
|
|
4347
4598
|
}
|
|
4599
|
+
function readParam(name) {
|
|
4600
|
+
if (typeof window === "undefined") return null;
|
|
4601
|
+
return new URLSearchParams(window.location.search).get(name);
|
|
4602
|
+
}
|
|
4603
|
+
function useQueryParam(name) {
|
|
4604
|
+
const [value, setState] = useState(() => readParam(name));
|
|
4605
|
+
useEffect(() => {
|
|
4606
|
+
const sync = () => setState(readParam(name));
|
|
4607
|
+
sync();
|
|
4608
|
+
window.addEventListener("popstate", sync);
|
|
4609
|
+
return () => window.removeEventListener("popstate", sync);
|
|
4610
|
+
}, [name]);
|
|
4611
|
+
const setValue = useCallback(
|
|
4612
|
+
(next) => {
|
|
4613
|
+
const params = new URLSearchParams(window.location.search);
|
|
4614
|
+
if (next === null) params.delete(name);
|
|
4615
|
+
else params.set(name, next);
|
|
4616
|
+
const query = params.toString();
|
|
4617
|
+
window.history.pushState({}, "", `${window.location.pathname}${query ? `?${query}` : ""}`);
|
|
4618
|
+
setState(next);
|
|
4619
|
+
},
|
|
4620
|
+
[name]
|
|
4621
|
+
);
|
|
4622
|
+
return { value, setValue };
|
|
4623
|
+
}
|
|
4348
4624
|
|
|
4349
4625
|
// src/ui/graph-canvas/reachability.ts
|
|
4626
|
+
var EXIT_TONES = {
|
|
4627
|
+
sent: "delivered",
|
|
4628
|
+
failed: "failure",
|
|
4629
|
+
ready: "held",
|
|
4630
|
+
needs_human: "held",
|
|
4631
|
+
guardrail_hold: "held",
|
|
4632
|
+
awaiting_approval: "held",
|
|
4633
|
+
escalated: "held",
|
|
4634
|
+
triaged_only: "held",
|
|
4635
|
+
no_reply_needed: "held"
|
|
4636
|
+
};
|
|
4350
4637
|
function stubPrompts() {
|
|
4351
4638
|
const ref = { name: "", label: "production" };
|
|
4352
4639
|
return { triage: ref, escalate: ref, draft: ref, evaluate: ref };
|
|
4353
4640
|
}
|
|
4354
4641
|
var PROMPT_403_NODES = /* @__PURE__ */ new Set(["triage", "escalate", "draft", "evaluate", "revise"]);
|
|
4355
|
-
var PROMPT_403_NOTE =
|
|
4356
|
-
|
|
4357
|
-
|
|
4642
|
+
var PROMPT_403_NOTE = {
|
|
4643
|
+
id: "prompt-403",
|
|
4644
|
+
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.",
|
|
4645
|
+
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)."
|
|
4646
|
+
};
|
|
4647
|
+
function reason(kind, message, detail) {
|
|
4648
|
+
return detail === void 0 ? { kind, message } : { kind, message, detail };
|
|
4649
|
+
}
|
|
4650
|
+
function note(message, detail) {
|
|
4651
|
+
return detail === void 0 ? { message } : { message, detail };
|
|
4358
4652
|
}
|
|
4359
4653
|
function nodeModelOf(node, profile) {
|
|
4360
4654
|
switch (node) {
|
|
@@ -4370,17 +4664,35 @@ function nodeModelOf(node, profile) {
|
|
|
4370
4664
|
return null;
|
|
4371
4665
|
}
|
|
4372
4666
|
}
|
|
4373
|
-
var READY_EXIT = {
|
|
4667
|
+
var READY_EXIT = {
|
|
4668
|
+
key: "evaluate-ready",
|
|
4669
|
+
condition: "envoi auto non \xE9ligible",
|
|
4670
|
+
outcome: "ready"
|
|
4671
|
+
};
|
|
4374
4672
|
var NODE_EXITS = {
|
|
4375
|
-
fetchContext: [
|
|
4673
|
+
fetchContext: [
|
|
4674
|
+
{ key: "fetchContext-failed", condition: "lecture impossible", outcome: "failed" }
|
|
4675
|
+
],
|
|
4376
4676
|
triage: [
|
|
4377
4677
|
{ key: "triage-fallback", condition: "classification de repli", outcome: "triaged_only" },
|
|
4378
|
-
{
|
|
4379
|
-
|
|
4678
|
+
{
|
|
4679
|
+
key: "triage-closed",
|
|
4680
|
+
condition: "le dernier message client cl\xF4t la conversation",
|
|
4681
|
+
outcome: "no_reply_needed"
|
|
4682
|
+
},
|
|
4683
|
+
{
|
|
4684
|
+
key: "triage-whatsapp-gate",
|
|
4685
|
+
condition: "r\xE8gle de canal WhatsApp (STOP ou pas notre tour)",
|
|
4686
|
+
outcome: "guardrail_hold"
|
|
4687
|
+
}
|
|
4380
4688
|
],
|
|
4381
4689
|
escalate: [
|
|
4382
4690
|
{ key: "escalate-escalated", condition: "escalade demand\xE9e", outcome: "escalated" },
|
|
4383
|
-
{
|
|
4691
|
+
{
|
|
4692
|
+
key: "escalate-no-draft",
|
|
4693
|
+
condition: "profil sans n\u0153ud de r\xE9daction",
|
|
4694
|
+
outcome: "triaged_only"
|
|
4695
|
+
}
|
|
4384
4696
|
],
|
|
4385
4697
|
evaluate: [
|
|
4386
4698
|
{
|
|
@@ -4390,8 +4702,16 @@ var NODE_EXITS = {
|
|
|
4390
4702
|
},
|
|
4391
4703
|
READY_EXIT
|
|
4392
4704
|
],
|
|
4393
|
-
guardrails: [
|
|
4394
|
-
|
|
4705
|
+
guardrails: [
|
|
4706
|
+
{ key: "guardrails-content", condition: "garde-fou de contenu", outcome: "guardrail_hold" }
|
|
4707
|
+
],
|
|
4708
|
+
authorize: [
|
|
4709
|
+
{
|
|
4710
|
+
key: "authorize-awaiting",
|
|
4711
|
+
condition: "une action n'est pas \xAB auto \xBB",
|
|
4712
|
+
outcome: "awaiting_approval"
|
|
4713
|
+
}
|
|
4714
|
+
],
|
|
4395
4715
|
act: [
|
|
4396
4716
|
{ key: "act-collision", condition: "contr\xF4le anti-collision", outcome: "guardrail_hold" },
|
|
4397
4717
|
{ key: "act-sent-email", condition: "r\xE9ponse email", outcome: "sent" },
|
|
@@ -4400,10 +4720,15 @@ var NODE_EXITS = {
|
|
|
4400
4720
|
};
|
|
4401
4721
|
function exitsFor(node, evaluateConfigured) {
|
|
4402
4722
|
const raw = NODE_EXITS[node] ?? [];
|
|
4403
|
-
|
|
4723
|
+
const withTone = (exits) => exits.map((exit) => ({ ...exit, tone: EXIT_TONES[exit.outcome] }));
|
|
4724
|
+
if (evaluateConfigured) return withTone(raw);
|
|
4404
4725
|
if (node === "evaluate") return [];
|
|
4405
|
-
if (node === "draft") return [READY_EXIT];
|
|
4406
|
-
return raw;
|
|
4726
|
+
if (node === "draft") return withTone([READY_EXIT]);
|
|
4727
|
+
return withTone(raw);
|
|
4728
|
+
}
|
|
4729
|
+
function deriveCause(state, reasons) {
|
|
4730
|
+
if (state === "on") return null;
|
|
4731
|
+
return reasons.some((r) => r.kind !== "upstream-disabled") ? "root" : "consequence";
|
|
4407
4732
|
}
|
|
4408
4733
|
function deriveState(upstreamOk, blockingReasons, offReasons) {
|
|
4409
4734
|
if (!upstreamOk) return "unreachable";
|
|
@@ -4421,11 +4746,17 @@ function computeGraphReachability(rawSettings, hasCategoryWithAutoReply) {
|
|
|
4421
4746
|
nodes: NODE_NAMES.map((node) => ({
|
|
4422
4747
|
node,
|
|
4423
4748
|
state: "unreachable",
|
|
4424
|
-
|
|
4749
|
+
// Every node reports the SAME single root cause here — none of them
|
|
4750
|
+
// is "blocked by the one before", they are all blocked by the same
|
|
4751
|
+
// absent setting, so none is a mere consequence of another.
|
|
4752
|
+
cause: "root",
|
|
4753
|
+
reasons: [reason("missing-setting", message, "validateSettings: nodes.triage est \xE0 null.")],
|
|
4425
4754
|
notes: [],
|
|
4426
4755
|
model: null,
|
|
4427
|
-
exits: []
|
|
4428
|
-
|
|
4756
|
+
exits: [],
|
|
4757
|
+
promptWarning: false
|
|
4758
|
+
})),
|
|
4759
|
+
globalNotes: []
|
|
4429
4760
|
};
|
|
4430
4761
|
}
|
|
4431
4762
|
const settings = rawSettings;
|
|
@@ -4433,20 +4764,23 @@ function computeGraphReachability(rawSettings, hasCategoryWithAutoReply) {
|
|
|
4433
4764
|
const evaluateConfigured = profile.nodes.evaluate !== null;
|
|
4434
4765
|
const byNode = /* @__PURE__ */ new Map();
|
|
4435
4766
|
function set(node, state, reasons, notes = []) {
|
|
4436
|
-
const promptNote = state === "on" && PROMPT_403_NODES.has(node) ? [PROMPT_403_NOTE] : [];
|
|
4437
4767
|
byNode.set(node, {
|
|
4438
4768
|
node,
|
|
4439
4769
|
state,
|
|
4770
|
+
cause: deriveCause(state, reasons),
|
|
4440
4771
|
reasons,
|
|
4441
|
-
notes
|
|
4772
|
+
notes,
|
|
4442
4773
|
model: nodeModelOf(node, profile),
|
|
4443
|
-
exits: exitsFor(node, evaluateConfigured)
|
|
4774
|
+
exits: exitsFor(node, evaluateConfigured),
|
|
4775
|
+
promptWarning: state === "on" && PROMPT_403_NODES.has(node)
|
|
4444
4776
|
});
|
|
4445
4777
|
}
|
|
4446
4778
|
function getNode(node) {
|
|
4447
4779
|
const found = byNode.get(node);
|
|
4448
4780
|
if (!found) {
|
|
4449
|
-
throw new Error(
|
|
4781
|
+
throw new Error(
|
|
4782
|
+
`computeGraphReachability: no reachability rule was set for node "${node}" \u2014 NODE_NAMES gained an entry this module does not know how to place.`
|
|
4783
|
+
);
|
|
4450
4784
|
}
|
|
4451
4785
|
return found;
|
|
4452
4786
|
}
|
|
@@ -4455,121 +4789,329 @@ function computeGraphReachability(rawSettings, hasCategoryWithAutoReply) {
|
|
|
4455
4789
|
const fetchBlockingReasons = [];
|
|
4456
4790
|
const sourceViewIdIssue = issues.find((issue) => issue.key === "sourceViewId");
|
|
4457
4791
|
if (sourceViewIdIssue) {
|
|
4458
|
-
fetchBlockingReasons.push(
|
|
4792
|
+
fetchBlockingReasons.push(
|
|
4793
|
+
reason(
|
|
4794
|
+
"missing-setting",
|
|
4795
|
+
settingsIssueLabel("sourceViewId", sourceViewIdIssue.message),
|
|
4796
|
+
"validateSettings: sourceViewId est vide."
|
|
4797
|
+
)
|
|
4798
|
+
);
|
|
4459
4799
|
}
|
|
4460
4800
|
if (!settings.triageEnabled) {
|
|
4461
|
-
fetchOffReasons.push(
|
|
4801
|
+
fetchOffReasons.push(
|
|
4802
|
+
reason(
|
|
4803
|
+
"missing-setting",
|
|
4804
|
+
"Le pipeline est coup\xE9 : aucun ticket n'est lu, donc aucune \xE9tape ne s'ex\xE9cute.",
|
|
4805
|
+
"triageEnabled est d\xE9sactiv\xE9 \u2014 coupe-circuit global (\xA73.5)."
|
|
4806
|
+
)
|
|
4807
|
+
);
|
|
4462
4808
|
}
|
|
4463
|
-
set("fetchContext", deriveState(true, fetchBlockingReasons, fetchOffReasons), [
|
|
4809
|
+
set("fetchContext", deriveState(true, fetchBlockingReasons, fetchOffReasons), [
|
|
4810
|
+
...fetchBlockingReasons,
|
|
4811
|
+
...fetchOffReasons
|
|
4812
|
+
]);
|
|
4464
4813
|
const fetchNode = getNode("fetchContext");
|
|
4465
4814
|
const fetchRuns = passesControlOn("fetchContext");
|
|
4466
4815
|
set(
|
|
4467
4816
|
"triage",
|
|
4468
4817
|
fetchRuns ? "on" : "unreachable",
|
|
4469
4818
|
fetchRuns ? [] : [
|
|
4470
|
-
reason(
|
|
4819
|
+
fetchNode.state === "off" ? reason(
|
|
4471
4820
|
"upstream-disabled",
|
|
4472
|
-
|
|
4821
|
+
"La r\xE9cup\xE9ration du ticket est coup\xE9e \u2014 aucun ticket n'est jamais lu.",
|
|
4822
|
+
"fetchContext est d\xE9sactiv\xE9 (triageEnabled)."
|
|
4823
|
+
) : reason(
|
|
4824
|
+
"upstream-disabled",
|
|
4825
|
+
"La r\xE9cup\xE9ration du ticket est bloqu\xE9e \u2014 voir sa carte.",
|
|
4826
|
+
"fetchContext est inatteignable (sourceViewId)."
|
|
4473
4827
|
)
|
|
4474
4828
|
]
|
|
4475
4829
|
);
|
|
4476
4830
|
const triageRuns = passesControlOn("triage");
|
|
4477
4831
|
const escalateDisabled = profile.nodes.escalate === null;
|
|
4832
|
+
const escalateOff = reason(
|
|
4833
|
+
"disabled-step",
|
|
4834
|
+
"\xC9tape coup\xE9e dans les r\xE9glages \u2014 aucune escalade automatique n'est d\xE9cid\xE9e.",
|
|
4835
|
+
"nodes.escalate est \xE0 null (\xA73.6)."
|
|
4836
|
+
);
|
|
4478
4837
|
set(
|
|
4479
4838
|
"escalate",
|
|
4480
|
-
deriveState(triageRuns, [], escalateDisabled ? [
|
|
4481
|
-
triageRuns ? escalateDisabled ? [
|
|
4839
|
+
deriveState(triageRuns, [], escalateDisabled ? [escalateOff] : []),
|
|
4840
|
+
triageRuns ? escalateDisabled ? [escalateOff] : [] : [
|
|
4841
|
+
reason(
|
|
4842
|
+
"upstream-disabled",
|
|
4843
|
+
"Le triage n'est jamais atteint.",
|
|
4844
|
+
"triage est inatteignable."
|
|
4845
|
+
)
|
|
4846
|
+
]
|
|
4482
4847
|
);
|
|
4483
4848
|
const draftDisabled = hasNoDraftNode(profile);
|
|
4849
|
+
const draftOff = reason(
|
|
4850
|
+
"disabled-step",
|
|
4851
|
+
"\xC9tape coup\xE9e dans les r\xE9glages \u2014 aucune r\xE9ponse n'est r\xE9dig\xE9e.",
|
|
4852
|
+
"nodes.draft est \xE0 null \u2014 sortie \xAB triaged_only \xBB (run-ticket.ts#hasNoDraftNode)."
|
|
4853
|
+
);
|
|
4484
4854
|
set(
|
|
4485
4855
|
"draft",
|
|
4486
|
-
deriveState(triageRuns, [], draftDisabled ? [
|
|
4487
|
-
triageRuns ? draftDisabled ? [
|
|
4856
|
+
deriveState(triageRuns, [], draftDisabled ? [draftOff] : []),
|
|
4857
|
+
triageRuns ? draftDisabled ? [draftOff] : [] : [
|
|
4858
|
+
reason(
|
|
4859
|
+
"upstream-disabled",
|
|
4860
|
+
"Le triage n'est jamais atteint.",
|
|
4861
|
+
"triage est inatteignable."
|
|
4862
|
+
)
|
|
4863
|
+
]
|
|
4488
4864
|
);
|
|
4489
4865
|
const draftRuns = passesControlOn("draft");
|
|
4490
4866
|
const evaluateDisabled = !evaluateConfigured;
|
|
4867
|
+
const evaluateOff = reason(
|
|
4868
|
+
"disabled-step",
|
|
4869
|
+
"\xC9tape coup\xE9e dans les r\xE9glages \u2014 aucun verdict, la r\xE9ponse reste \xAB Disponible \xBB.",
|
|
4870
|
+
"nodes.evaluate est \xE0 null \u2014 la r\xE9ponse conserve l'issue \xAB ready \xBB."
|
|
4871
|
+
);
|
|
4491
4872
|
set(
|
|
4492
4873
|
"evaluate",
|
|
4493
|
-
deriveState(draftRuns, [], evaluateDisabled ? [
|
|
4494
|
-
draftRuns ? evaluateDisabled ? [
|
|
4874
|
+
deriveState(draftRuns, [], evaluateDisabled ? [evaluateOff] : []),
|
|
4875
|
+
draftRuns ? evaluateDisabled ? [evaluateOff] : [] : [
|
|
4876
|
+
getNode("draft").state === "off" ? reason(
|
|
4877
|
+
"upstream-disabled",
|
|
4878
|
+
"La r\xE9daction est coup\xE9e \u2014 aucun ticket n'atteint l'\xE9valuation.",
|
|
4879
|
+
"draft est d\xE9sactiv\xE9."
|
|
4880
|
+
) : reason(
|
|
4881
|
+
"upstream-disabled",
|
|
4882
|
+
"La r\xE9daction n'est jamais atteinte.",
|
|
4883
|
+
"draft est inatteignable."
|
|
4884
|
+
)
|
|
4885
|
+
]
|
|
4495
4886
|
);
|
|
4496
4887
|
const evaluateRuns = passesControlOn("evaluate");
|
|
4497
4888
|
const reviseDisabled = profile.nodes.revise === null;
|
|
4889
|
+
const reviseOff = reason(
|
|
4890
|
+
"disabled-step",
|
|
4891
|
+
"\xC9tape coup\xE9e dans les r\xE9glages \u2014 pas de passe de correction.",
|
|
4892
|
+
"nodes.revise est \xE0 null."
|
|
4893
|
+
);
|
|
4498
4894
|
set(
|
|
4499
4895
|
"revise",
|
|
4500
|
-
deriveState(evaluateRuns, [], reviseDisabled ? [
|
|
4501
|
-
evaluateRuns ? reviseDisabled ? [
|
|
4502
|
-
|
|
4896
|
+
deriveState(evaluateRuns, [], reviseDisabled ? [reviseOff] : []),
|
|
4897
|
+
evaluateRuns ? reviseDisabled ? [reviseOff] : [] : [
|
|
4898
|
+
getNode("evaluate").state === "off" ? reason(
|
|
4899
|
+
"upstream-disabled",
|
|
4900
|
+
"L'\xE9valuation est coup\xE9e \u2014 aucun ticket n'atteint la r\xE9vision.",
|
|
4901
|
+
"evaluate est d\xE9sactiv\xE9."
|
|
4902
|
+
) : reason(
|
|
4903
|
+
"upstream-disabled",
|
|
4904
|
+
"L'\xE9valuation n'est jamais atteinte.",
|
|
4905
|
+
"evaluate est inatteignable."
|
|
4906
|
+
)
|
|
4907
|
+
],
|
|
4908
|
+
evaluateRuns && !reviseDisabled ? [note("Au plus une passe de r\xE9vision par ticket.", "\xA73.3.")] : []
|
|
4503
4909
|
);
|
|
4504
4910
|
const autoSendBlockingReasons = [];
|
|
4505
4911
|
const autoSendOffReasons = [];
|
|
4506
4912
|
if (!profile.autoSend.enabled) {
|
|
4507
|
-
autoSendOffReasons.push(
|
|
4913
|
+
autoSendOffReasons.push(
|
|
4914
|
+
reason(
|
|
4915
|
+
"missing-setting",
|
|
4916
|
+
"L'envoi automatique est coup\xE9 \u2014 ce coupe-circuit emp\xEAche tout envoi.",
|
|
4917
|
+
"autoSendEnabled est d\xE9sactiv\xE9."
|
|
4918
|
+
)
|
|
4919
|
+
);
|
|
4508
4920
|
}
|
|
4509
4921
|
if (!hasCategoryWithAutoReply) {
|
|
4510
4922
|
autoSendBlockingReasons.push(
|
|
4511
|
-
reason(
|
|
4923
|
+
reason(
|
|
4924
|
+
"missing-setting",
|
|
4925
|
+
"Aucune cat\xE9gorie n'a \xAB Envoi auto \xBB activ\xE9 \u2014 sans elle, aucune r\xE9ponse n'est \xE9ligible \xE0 un envoi automatique.",
|
|
4926
|
+
"isAutoSendEligible exige category.autoReplyEnabled ; aucune cat\xE9gorie ne le porte aujourd'hui."
|
|
4927
|
+
)
|
|
4512
4928
|
);
|
|
4513
4929
|
}
|
|
4514
4930
|
const senderEmailIssue = issues.find((issue) => issue.key === "senderEmail");
|
|
4515
4931
|
if (senderEmailIssue) {
|
|
4516
|
-
autoSendBlockingReasons.push(
|
|
4932
|
+
autoSendBlockingReasons.push(
|
|
4933
|
+
reason(
|
|
4934
|
+
"missing-setting",
|
|
4935
|
+
settingsIssueLabel("senderEmail", senderEmailIssue.message),
|
|
4936
|
+
"validateSettings: senderEmail est vide alors que autoSendEnabled est actif."
|
|
4937
|
+
)
|
|
4938
|
+
);
|
|
4517
4939
|
}
|
|
4518
4940
|
const guardrailNotes = [];
|
|
4519
4941
|
if (!profile.autoSend.senderEmail && profile.guardrails.params.whatsappMode === "auto_reply") {
|
|
4520
4942
|
guardrailNotes.push(
|
|
4521
|
-
|
|
4943
|
+
note(
|
|
4944
|
+
"Sans adresse d'envoi, seuls les tickets WhatsApp en r\xE9ponse automatique passent ici : un ticket email reste bloqu\xE9 \xE0 \xAB Disponible \xBB.",
|
|
4945
|
+
`senderEmail est vide et whatsappMode="auto_reply" \u2014 hasSenderForMode n'est vrai que pour WhatsApp ; un ticket email n'atteint jamais guardrails/authorize/act.`
|
|
4946
|
+
)
|
|
4522
4947
|
);
|
|
4523
4948
|
}
|
|
4524
4949
|
if (profile.guardrails.params.whatsappMode === "draft_only") {
|
|
4525
4950
|
guardrailNotes.push(
|
|
4526
|
-
|
|
4951
|
+
note(
|
|
4952
|
+
"Les tickets WhatsApp ne d\xE9passent jamais \xAB Disponible \xBB (mode brouillon seul) : seuls les tickets email arrivent r\xE9ellement ici.",
|
|
4953
|
+
`whatsappMode="draft_only" \u2014 isAutoSendEligible exclut ce mode ; authorize/act ne s'ex\xE9cutent que pour le canal email.`
|
|
4954
|
+
)
|
|
4527
4955
|
);
|
|
4528
4956
|
}
|
|
4529
4957
|
if (profile.guardrails.params.whatsappMode === "escalate_only") {
|
|
4530
4958
|
guardrailNotes.push(
|
|
4531
|
-
|
|
4959
|
+
note(
|
|
4960
|
+
"Un ticket WhatsApp qui arrive ici est syst\xE9matiquement retenu : sur ce canal la r\xE9ponse est gard\xE9e, jamais envoy\xE9e.",
|
|
4961
|
+
`whatsappMode="escalate_only" \u2014 garde-fou \xAB whatsapp \xBB (\xA73.9) ; authorize/act ne s'ex\xE9cutent jamais pour ce canal.`
|
|
4962
|
+
)
|
|
4532
4963
|
);
|
|
4533
4964
|
}
|
|
4534
4965
|
set(
|
|
4535
4966
|
"guardrails",
|
|
4536
4967
|
deriveState(evaluateRuns, autoSendBlockingReasons, autoSendOffReasons),
|
|
4537
|
-
evaluateRuns ? [...autoSendBlockingReasons, ...autoSendOffReasons] : [
|
|
4968
|
+
evaluateRuns ? [...autoSendBlockingReasons, ...autoSendOffReasons] : [
|
|
4969
|
+
getNode("evaluate").state === "off" ? reason(
|
|
4970
|
+
"upstream-disabled",
|
|
4971
|
+
"L'\xE9valuation est coup\xE9e \u2014 sans verdict, aucun ticket n'arrive ici.",
|
|
4972
|
+
"evaluate est d\xE9sactiv\xE9."
|
|
4973
|
+
) : reason(
|
|
4974
|
+
"upstream-disabled",
|
|
4975
|
+
"L'\xE9valuation n'est jamais atteinte \u2014 aucun verdict ne peut donc \xEAtre produit.",
|
|
4976
|
+
"evaluate est inatteignable."
|
|
4977
|
+
)
|
|
4978
|
+
],
|
|
4538
4979
|
guardrailNotes
|
|
4539
4980
|
);
|
|
4540
4981
|
const guardrailsRuns = passesControlOn("guardrails");
|
|
4541
4982
|
set(
|
|
4542
4983
|
"authorize",
|
|
4543
4984
|
guardrailsRuns ? "on" : "unreachable",
|
|
4544
|
-
guardrailsRuns ? [] : [
|
|
4985
|
+
guardrailsRuns ? [] : [
|
|
4986
|
+
getNode("guardrails").state === "off" ? reason(
|
|
4987
|
+
"upstream-disabled",
|
|
4988
|
+
"Les garde-fous sont coup\xE9s \u2014 aucune action n'est jamais autoris\xE9e.",
|
|
4989
|
+
"guardrails est d\xE9sactiv\xE9 (autoSendEnabled)."
|
|
4990
|
+
) : reason(
|
|
4991
|
+
"upstream-disabled",
|
|
4992
|
+
"Les garde-fous ne sont jamais atteints \u2014 voir leur carte.",
|
|
4993
|
+
"guardrails est inatteignable."
|
|
4994
|
+
)
|
|
4995
|
+
],
|
|
4545
4996
|
guardrailsRuns ? guardrailNotes : []
|
|
4546
4997
|
);
|
|
4547
4998
|
const authorizeRuns = passesControlOn("authorize");
|
|
4548
|
-
const approvalNote =
|
|
4999
|
+
const approvalNote = note(
|
|
5000
|
+
"Le chemin d'approbation manuelle est inatteignable avec les r\xE9glages actuels : une r\xE9ponse autoris\xE9e part directement, jamais apr\xE8s une approbation.",
|
|
5001
|
+
"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)."
|
|
5002
|
+
);
|
|
4549
5003
|
set(
|
|
4550
5004
|
"act",
|
|
4551
5005
|
authorizeRuns ? "on" : "unreachable",
|
|
4552
|
-
authorizeRuns ? [] : [
|
|
5006
|
+
authorizeRuns ? [] : [
|
|
5007
|
+
reason(
|
|
5008
|
+
"upstream-disabled",
|
|
5009
|
+
"L'autorisation n'est jamais atteinte.",
|
|
5010
|
+
"authorize est inatteignable."
|
|
5011
|
+
)
|
|
5012
|
+
],
|
|
4553
5013
|
authorizeRuns ? [...guardrailNotes, approvalNote] : []
|
|
4554
5014
|
);
|
|
4555
|
-
|
|
5015
|
+
const nodes = NODE_NAMES.map((node) => getNode(node));
|
|
5016
|
+
const promptWarningNodes = nodes.filter((n) => n.promptWarning).map((n) => n.node);
|
|
5017
|
+
return {
|
|
5018
|
+
blocked: false,
|
|
5019
|
+
nodes,
|
|
5020
|
+
globalNotes: promptWarningNodes.length > 0 ? [{ ...PROMPT_403_NOTE, nodes: promptWarningNodes }] : []
|
|
5021
|
+
};
|
|
5022
|
+
}
|
|
5023
|
+
function windowCutoffIso2(days, now = Date.now()) {
|
|
5024
|
+
return new Date(now - days * 24 * 60 * 60 * 1e3).toISOString();
|
|
5025
|
+
}
|
|
5026
|
+
function totalOf(rows) {
|
|
5027
|
+
if (!Array.isArray(rows)) return null;
|
|
5028
|
+
let total = 0;
|
|
5029
|
+
for (const row of rows) {
|
|
5030
|
+
const value = row?.count;
|
|
5031
|
+
if (typeof value !== "number") return null;
|
|
5032
|
+
total += value;
|
|
5033
|
+
}
|
|
5034
|
+
return total;
|
|
5035
|
+
}
|
|
5036
|
+
function useGraphTraffic(windowDays) {
|
|
5037
|
+
const cutoffIso = useMemo(() => windowCutoffIso2(windowDays), [windowDays]);
|
|
5038
|
+
const triaged = useAggregate("triage-decision", {
|
|
5039
|
+
filter: { decidedAt: { gte: cutoffIso } },
|
|
5040
|
+
metrics: [{ op: "count", as: "count" }]
|
|
5041
|
+
});
|
|
5042
|
+
const escalated = useAggregate("triage-decision", {
|
|
5043
|
+
filter: { decidedAt: { gte: cutoffIso }, escalated: { eq: true } },
|
|
5044
|
+
metrics: [{ op: "count", as: "count" }]
|
|
5045
|
+
});
|
|
5046
|
+
const drafted = useAggregate("generated-response", {
|
|
5047
|
+
filter: { generatedAt: { gte: cutoffIso } },
|
|
5048
|
+
metrics: [{ op: "count", as: "count" }]
|
|
5049
|
+
});
|
|
5050
|
+
const sent = useAggregate("generated-response", {
|
|
5051
|
+
filter: { generatedAt: { gte: cutoffIso }, status: { eq: "sent" } },
|
|
5052
|
+
metrics: [{ op: "count", as: "count" }]
|
|
5053
|
+
});
|
|
5054
|
+
const isLoading = triaged.isLoading || escalated.isLoading || drafted.isLoading || sent.isLoading;
|
|
5055
|
+
const failed = [triaged, escalated, drafted, sent].some((q) => q.error !== void 0);
|
|
5056
|
+
const triagedTotal = totalOf(triaged.rows);
|
|
5057
|
+
const escalatedTotal = totalOf(escalated.rows);
|
|
5058
|
+
const draftedTotal = totalOf(drafted.rows);
|
|
5059
|
+
const sentTotal = totalOf(sent.rows);
|
|
5060
|
+
return useMemo(() => {
|
|
5061
|
+
const byNode = {};
|
|
5062
|
+
if (triagedTotal !== null) {
|
|
5063
|
+
byNode.fetchContext = {
|
|
5064
|
+
count: triagedTotal,
|
|
5065
|
+
witness: "tickets triag\xE9s (un triage suppose une lecture r\xE9ussie)"
|
|
5066
|
+
};
|
|
5067
|
+
byNode.triage = { count: triagedTotal, witness: "tickets triag\xE9s" };
|
|
5068
|
+
}
|
|
5069
|
+
if (escalatedTotal !== null)
|
|
5070
|
+
byNode.escalate = { count: escalatedTotal, witness: "tickets escalad\xE9s" };
|
|
5071
|
+
if (draftedTotal !== null) byNode.draft = { count: draftedTotal, witness: "r\xE9ponses r\xE9dig\xE9es" };
|
|
5072
|
+
if (sentTotal !== null) byNode.act = { count: sentTotal, witness: "r\xE9ponses envoy\xE9es" };
|
|
5073
|
+
return {
|
|
5074
|
+
byNode: failed ? {} : byNode,
|
|
5075
|
+
isLoading,
|
|
5076
|
+
unavailable: failed
|
|
5077
|
+
};
|
|
5078
|
+
}, [triagedTotal, escalatedTotal, draftedTotal, sentTotal, failed, isLoading]);
|
|
4556
5079
|
}
|
|
4557
5080
|
var CATEGORY_PAGE_SIZE = 500;
|
|
5081
|
+
var TRAFFIC_WINDOW_DAYS = 7;
|
|
4558
5082
|
var REASON_KIND_LABELS = {
|
|
4559
5083
|
"disabled-step": "\xC9tape d\xE9sactiv\xE9e",
|
|
4560
5084
|
"upstream-disabled": "Bloqu\xE9 en amont",
|
|
4561
5085
|
"missing-setting": "R\xE9glage manquant",
|
|
4562
5086
|
"channel-gate": "Restriction de canal"
|
|
4563
5087
|
};
|
|
4564
|
-
var
|
|
5088
|
+
var BADGE_LABELS = {
|
|
4565
5089
|
on: "Actif",
|
|
4566
5090
|
off: "D\xE9sactiv\xE9",
|
|
4567
|
-
|
|
5091
|
+
root: "Bloqu\xE9",
|
|
5092
|
+
consequence: "Hors d\u2019atteinte"
|
|
4568
5093
|
};
|
|
4569
|
-
var
|
|
5094
|
+
var BADGE_VARIANTS = {
|
|
4570
5095
|
on: "success",
|
|
4571
5096
|
off: "neutral",
|
|
4572
|
-
|
|
5097
|
+
root: "danger",
|
|
5098
|
+
consequence: "warning"
|
|
5099
|
+
};
|
|
5100
|
+
var BADGE_DEFINITIONS = {
|
|
5101
|
+
on: "Au moins un ticket peut atteindre ce n\u0153ud avec les r\xE9glages actuels.",
|
|
5102
|
+
off: "L\u2019op\xE9rateur a coup\xE9 ce n\u0153ud lui-m\xEAme \u2014 un choix, pas un incident.",
|
|
5103
|
+
root: "C\u2019est ici que le parcours s\u2019arr\xEAte : la cause est sur cette carte.",
|
|
5104
|
+
consequence: "Ce n\u0153ud n\u2019a rien de cass\xE9 \u2014 il est simplement priv\xE9 de tickets par un n\u0153ud en amont."
|
|
5105
|
+
};
|
|
5106
|
+
function badgeKindOf(node) {
|
|
5107
|
+
if (node.state === "on") return "on";
|
|
5108
|
+
if (node.state === "off") return "off";
|
|
5109
|
+
return node.cause === "consequence" ? "consequence" : "root";
|
|
5110
|
+
}
|
|
5111
|
+
var EXIT_TONE_CLASSES = {
|
|
5112
|
+
delivered: "border-status-success/30 bg-status-success/10 text-status-success",
|
|
5113
|
+
held: "border-border bg-muted text-muted-foreground",
|
|
5114
|
+
failure: "border-status-blocked/25 bg-status-blocked/10 text-status-blocked"
|
|
4573
5115
|
};
|
|
4574
5116
|
var NODE_SETTINGS_SECTION = {
|
|
4575
5117
|
fetchContext: { id: "source", title: "Source" },
|
|
@@ -4581,60 +5123,395 @@ var NODE_SETTINGS_SECTION = {
|
|
|
4581
5123
|
guardrails: { id: "guardrails", title: "Guardrails" },
|
|
4582
5124
|
act: { id: "envoi", title: "Envoi" }
|
|
4583
5125
|
};
|
|
4584
|
-
function
|
|
4585
|
-
const section = NODE_SETTINGS_SECTION[node
|
|
5126
|
+
function settingsHref(appSlug, node) {
|
|
5127
|
+
const section = NODE_SETTINGS_SECTION[node];
|
|
5128
|
+
return section ? `/parametres/espaces/${appSlug}#${section.id}` : null;
|
|
5129
|
+
}
|
|
5130
|
+
function dedupeExits(exits) {
|
|
5131
|
+
const byOutcome = /* @__PURE__ */ new Map();
|
|
5132
|
+
for (const exit of exits) {
|
|
5133
|
+
const existing = byOutcome.get(exit.outcome);
|
|
5134
|
+
if (existing) existing.conditions.push(exit.condition);
|
|
5135
|
+
else
|
|
5136
|
+
byOutcome.set(exit.outcome, {
|
|
5137
|
+
outcome: exit.outcome,
|
|
5138
|
+
tone: exit.tone,
|
|
5139
|
+
conditions: [exit.condition]
|
|
5140
|
+
});
|
|
5141
|
+
}
|
|
5142
|
+
return [...byOutcome.values()];
|
|
5143
|
+
}
|
|
5144
|
+
function computeVerdict(result) {
|
|
5145
|
+
const causes = result.nodes.filter((node) => node.state !== "on" && node.cause === "root");
|
|
5146
|
+
if (result.blocked) {
|
|
5147
|
+
return {
|
|
5148
|
+
tone: "critical",
|
|
5149
|
+
headline: "Le pipeline ne peut pas d\xE9marrer : le triage n\u2019est pas configur\xE9.",
|
|
5150
|
+
causes: causes.slice(0, 1)
|
|
5151
|
+
};
|
|
5152
|
+
}
|
|
5153
|
+
const act = result.nodes.find((node) => node.node === "act");
|
|
5154
|
+
if (act && act.state !== "on") {
|
|
5155
|
+
return {
|
|
5156
|
+
tone: "critical",
|
|
5157
|
+
headline: "Aucune r\xE9ponse ne peut partir automatiquement aujourd\u2019hui.",
|
|
5158
|
+
causes
|
|
5159
|
+
};
|
|
5160
|
+
}
|
|
5161
|
+
return {
|
|
5162
|
+
tone: "ok",
|
|
5163
|
+
headline: "Le parcours va jusqu\u2019\xE0 l\u2019envoi : une r\xE9ponse peut partir automatiquement.",
|
|
5164
|
+
causes
|
|
5165
|
+
};
|
|
5166
|
+
}
|
|
5167
|
+
function VerdictBanner({ verdict, appSlug }) {
|
|
5168
|
+
const critical = verdict.tone === "critical";
|
|
4586
5169
|
return /* @__PURE__ */ jsx(
|
|
4587
|
-
|
|
5170
|
+
"section",
|
|
5171
|
+
{
|
|
5172
|
+
"data-testid": "graph-verdict",
|
|
5173
|
+
className: cn(
|
|
5174
|
+
"rounded-lg border p-4",
|
|
5175
|
+
critical ? "border-status-blocked/30 bg-status-blocked/5" : "border-status-success/30 bg-status-success/5"
|
|
5176
|
+
),
|
|
5177
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
|
|
5178
|
+
/* @__PURE__ */ jsx(
|
|
5179
|
+
"span",
|
|
5180
|
+
{
|
|
5181
|
+
"aria-hidden": true,
|
|
5182
|
+
className: cn(
|
|
5183
|
+
"mt-0.5 text-lg leading-none",
|
|
5184
|
+
critical ? "text-status-blocked" : "text-status-success"
|
|
5185
|
+
),
|
|
5186
|
+
children: critical ? "\u26D4" : "\u2713"
|
|
5187
|
+
}
|
|
5188
|
+
),
|
|
5189
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
5190
|
+
/* @__PURE__ */ jsx(
|
|
5191
|
+
"p",
|
|
5192
|
+
{
|
|
5193
|
+
className: cn(
|
|
5194
|
+
"text-sm font-semibold",
|
|
5195
|
+
critical ? "text-status-blocked" : "text-status-success"
|
|
5196
|
+
),
|
|
5197
|
+
children: verdict.headline
|
|
5198
|
+
}
|
|
5199
|
+
),
|
|
5200
|
+
verdict.causes.length > 0 && /* @__PURE__ */ jsx("ul", { className: "space-y-2", children: verdict.causes.map((cause) => {
|
|
5201
|
+
const href = settingsHref(appSlug, cause.node);
|
|
5202
|
+
return /* @__PURE__ */ jsxs(
|
|
5203
|
+
"li",
|
|
5204
|
+
{
|
|
5205
|
+
className: "flex flex-wrap items-center gap-x-2 gap-y-1 text-sm",
|
|
5206
|
+
children: [
|
|
5207
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: NODE_LABELS[cause.node] }),
|
|
5208
|
+
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
|
|
5209
|
+
"\u2014 ",
|
|
5210
|
+
cause.reasons[0]?.message ?? ""
|
|
5211
|
+
] }),
|
|
5212
|
+
href && /* @__PURE__ */ jsx(
|
|
5213
|
+
Link,
|
|
5214
|
+
{
|
|
5215
|
+
href,
|
|
5216
|
+
className: cn(
|
|
5217
|
+
buttonVariants({ variant: "outline", size: "sm" }),
|
|
5218
|
+
"no-underline"
|
|
5219
|
+
),
|
|
5220
|
+
children: "Corriger"
|
|
5221
|
+
}
|
|
5222
|
+
)
|
|
5223
|
+
]
|
|
5224
|
+
},
|
|
5225
|
+
cause.node
|
|
5226
|
+
);
|
|
5227
|
+
}) })
|
|
5228
|
+
] })
|
|
5229
|
+
] })
|
|
5230
|
+
}
|
|
5231
|
+
);
|
|
5232
|
+
}
|
|
5233
|
+
function Legend() {
|
|
5234
|
+
return /* @__PURE__ */ jsx(
|
|
5235
|
+
"div",
|
|
5236
|
+
{
|
|
5237
|
+
className: "flex flex-wrap items-center gap-x-4 gap-y-2 text-xs text-muted-foreground",
|
|
5238
|
+
"data-testid": "graph-legend",
|
|
5239
|
+
children: Object.keys(BADGE_LABELS).map((kind) => /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5", title: BADGE_DEFINITIONS[kind], children: [
|
|
5240
|
+
/* @__PURE__ */ jsx(Badge, { variant: BADGE_VARIANTS[kind], children: BADGE_LABELS[kind] }),
|
|
5241
|
+
/* @__PURE__ */ jsx("span", { className: "max-w-64", children: BADGE_DEFINITIONS[kind] })
|
|
5242
|
+
] }, kind))
|
|
5243
|
+
}
|
|
5244
|
+
);
|
|
5245
|
+
}
|
|
5246
|
+
function trafficContradiction(node, traffic) {
|
|
5247
|
+
if (!traffic) return null;
|
|
5248
|
+
if (node.state === "on" && traffic.count === 0) {
|
|
5249
|
+
return `Aucun passage observ\xE9 sur ${TRAFFIC_WINDOW_DAYS} jours, alors que ce n\u0153ud est r\xE9put\xE9 atteignable.`;
|
|
5250
|
+
}
|
|
5251
|
+
if (node.state !== "on" && traffic.count > 0) {
|
|
5252
|
+
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.`;
|
|
5253
|
+
}
|
|
5254
|
+
return null;
|
|
5255
|
+
}
|
|
5256
|
+
function TrafficPill({
|
|
5257
|
+
node,
|
|
5258
|
+
traffic
|
|
5259
|
+
}) {
|
|
5260
|
+
if (!traffic) {
|
|
5261
|
+
return /* @__PURE__ */ jsx(
|
|
5262
|
+
"span",
|
|
5263
|
+
{
|
|
5264
|
+
className: "text-xs text-muted-foreground",
|
|
5265
|
+
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.",
|
|
5266
|
+
children: "\u2014 trafic non mesur\xE9"
|
|
5267
|
+
}
|
|
5268
|
+
);
|
|
5269
|
+
}
|
|
5270
|
+
const contradiction = trafficContradiction(node, traffic);
|
|
5271
|
+
return /* @__PURE__ */ jsxs(
|
|
5272
|
+
"span",
|
|
5273
|
+
{
|
|
5274
|
+
className: cn(
|
|
5275
|
+
"text-xs",
|
|
5276
|
+
contradiction ? "font-medium text-status-blocked" : "text-muted-foreground"
|
|
5277
|
+
),
|
|
5278
|
+
title: `${traffic.witness}, sur ${TRAFFIC_WINDOW_DAYS} jours.`,
|
|
5279
|
+
children: [
|
|
5280
|
+
traffic.count,
|
|
5281
|
+
" sur ",
|
|
5282
|
+
TRAFFIC_WINDOW_DAYS,
|
|
5283
|
+
" j",
|
|
5284
|
+
contradiction ? " \u26A0" : ""
|
|
5285
|
+
]
|
|
5286
|
+
}
|
|
5287
|
+
);
|
|
5288
|
+
}
|
|
5289
|
+
function Connector({ into, isBreak }) {
|
|
5290
|
+
const dead = into.state !== "on";
|
|
5291
|
+
return /* @__PURE__ */ jsxs(
|
|
5292
|
+
"div",
|
|
5293
|
+
{
|
|
5294
|
+
className: "flex items-center gap-2 pl-[3px]",
|
|
5295
|
+
"data-testid": `graph-edge-${into.node}`,
|
|
5296
|
+
"data-edge-state": dead ? "dead" : "live",
|
|
5297
|
+
children: [
|
|
5298
|
+
/* @__PURE__ */ jsx(
|
|
5299
|
+
"span",
|
|
5300
|
+
{
|
|
5301
|
+
"aria-hidden": true,
|
|
5302
|
+
className: cn(
|
|
5303
|
+
"h-6 w-0 border-l-2",
|
|
5304
|
+
dead ? "border-dashed" : "border-solid",
|
|
5305
|
+
into.state === "on" ? "border-status-success/50" : into.cause === "root" ? "border-status-blocked/60" : "border-border"
|
|
5306
|
+
)
|
|
5307
|
+
}
|
|
5308
|
+
),
|
|
5309
|
+
isBreak && /* @__PURE__ */ jsxs("span", { className: "text-xs font-medium text-status-blocked", children: [
|
|
5310
|
+
"\u26D4",
|
|
5311
|
+
" le parcours s",
|
|
5312
|
+
"\u2019",
|
|
5313
|
+
"arr\xEAte ici"
|
|
5314
|
+
] })
|
|
5315
|
+
]
|
|
5316
|
+
}
|
|
5317
|
+
);
|
|
5318
|
+
}
|
|
5319
|
+
function NodeRow({
|
|
5320
|
+
node,
|
|
5321
|
+
traffic,
|
|
5322
|
+
technical,
|
|
5323
|
+
globalNotes,
|
|
5324
|
+
onOpen
|
|
5325
|
+
}) {
|
|
5326
|
+
const kind = badgeKindOf(node);
|
|
5327
|
+
const exits = dedupeExits(node.exits);
|
|
5328
|
+
const contradiction = trafficContradiction(node, traffic);
|
|
5329
|
+
const headlineReason = node.reasons[0];
|
|
5330
|
+
const extraCount = Math.max(0, node.reasons.length - 1) + node.notes.length + globalNotes.length;
|
|
5331
|
+
return /* @__PURE__ */ jsxs(
|
|
5332
|
+
"div",
|
|
4588
5333
|
{
|
|
5334
|
+
className: "flex items-start gap-3",
|
|
4589
5335
|
"data-testid": "graph-node",
|
|
4590
5336
|
"data-node": node.node,
|
|
4591
|
-
|
|
4592
|
-
children:
|
|
4593
|
-
/* @__PURE__ */
|
|
4594
|
-
|
|
4595
|
-
/* @__PURE__ */ jsx(Badge, { variant: ACTIVATION_BADGE_VARIANT[node.state], children: ACTIVATION_LABELS[node.state] })
|
|
4596
|
-
] }),
|
|
4597
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs leading-snug text-muted-foreground", children: NODE_ROLE_LABELS[node.node] }),
|
|
4598
|
-
/* @__PURE__ */ jsx("p", { className: "font-mono text-[10px] text-muted-foreground", children: node.node }),
|
|
4599
|
-
node.model && /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
4600
|
-
"Mod\xE8le : ",
|
|
4601
|
-
/* @__PURE__ */ jsx("code", { className: "font-mono", children: node.model })
|
|
4602
|
-
] }),
|
|
4603
|
-
node.exits.length > 0 && /* @__PURE__ */ jsx("ul", { className: "flex flex-wrap gap-1.5 border-t pt-2", children: node.exits.map((exit) => /* @__PURE__ */ jsx(
|
|
4604
|
-
"li",
|
|
5337
|
+
"data-state": kind,
|
|
5338
|
+
children: [
|
|
5339
|
+
/* @__PURE__ */ jsx(
|
|
5340
|
+
"span",
|
|
4605
5341
|
{
|
|
4606
|
-
|
|
4607
|
-
className:
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
5342
|
+
"aria-hidden": true,
|
|
5343
|
+
className: cn(
|
|
5344
|
+
"mt-4 size-2 shrink-0 rounded-full",
|
|
5345
|
+
kind === "on" && "bg-status-success",
|
|
5346
|
+
kind === "off" && "bg-muted-foreground/50",
|
|
5347
|
+
kind === "root" && "bg-status-blocked",
|
|
5348
|
+
kind === "consequence" && "bg-status-pending"
|
|
5349
|
+
)
|
|
5350
|
+
}
|
|
5351
|
+
),
|
|
5352
|
+
/* @__PURE__ */ jsx(
|
|
5353
|
+
Card,
|
|
5354
|
+
{
|
|
5355
|
+
className: cn(
|
|
5356
|
+
"w-full max-w-2xl",
|
|
5357
|
+
kind === "root" && "border-status-blocked/40",
|
|
5358
|
+
(kind === "off" || kind === "consequence") && "border-dashed opacity-80"
|
|
5359
|
+
),
|
|
5360
|
+
children: /* @__PURE__ */ jsxs(CardContent, { className: "space-y-2 p-3", "data-testid": `graph-node-${node.node}`, children: [
|
|
5361
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-x-2 gap-y-1", children: [
|
|
5362
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: NODE_LABELS[node.node] }),
|
|
5363
|
+
/* @__PURE__ */ jsx(Badge, { variant: BADGE_VARIANTS[kind], title: BADGE_DEFINITIONS[kind], children: BADGE_LABELS[kind] }),
|
|
5364
|
+
node.promptWarning && /* @__PURE__ */ jsxs(Badge, { variant: "warning", title: "Voir l\u2019avertissement au-dessus du graphe.", children: [
|
|
5365
|
+
"\u26A0",
|
|
5366
|
+
" prompt non d\xE9clar\xE9"
|
|
5367
|
+
] }),
|
|
5368
|
+
technical && /* @__PURE__ */ jsx("code", { className: "font-mono text-[10px] text-muted-foreground", children: node.node }),
|
|
5369
|
+
technical && node.model && /* @__PURE__ */ jsx("code", { className: "font-mono text-[10px] text-muted-foreground", children: node.model }),
|
|
5370
|
+
/* @__PURE__ */ jsxs("span", { className: "ml-auto flex items-center gap-3", children: [
|
|
5371
|
+
/* @__PURE__ */ jsx(TrafficPill, { node, traffic }),
|
|
5372
|
+
/* @__PURE__ */ jsxs(Button, { variant: "ghost", size: "sm", onClick: onOpen, children: [
|
|
5373
|
+
"D\xE9tails",
|
|
5374
|
+
extraCount > 0 ? ` (${extraCount})` : ""
|
|
5375
|
+
] })
|
|
5376
|
+
] })
|
|
5377
|
+
] }),
|
|
5378
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs leading-snug text-muted-foreground", children: NODE_ROLE_LABELS[node.node] }),
|
|
5379
|
+
headlineReason && /* @__PURE__ */ jsxs("p", { className: "text-xs", children: [
|
|
5380
|
+
/* @__PURE__ */ jsxs("span", { className: "font-medium", children: [
|
|
5381
|
+
REASON_KIND_LABELS[headlineReason.kind],
|
|
5382
|
+
" \u2014 "
|
|
5383
|
+
] }),
|
|
5384
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: headlineReason.message }),
|
|
5385
|
+
technical && headlineReason.detail && /* @__PURE__ */ jsx("span", { className: "ml-1 font-mono text-[10px] text-muted-foreground", children: headlineReason.detail })
|
|
5386
|
+
] }),
|
|
5387
|
+
contradiction && /* @__PURE__ */ jsx("p", { className: "text-xs font-medium text-status-blocked", children: contradiction }),
|
|
5388
|
+
exits.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-1.5 border-t pt-2", children: [
|
|
5389
|
+
/* @__PURE__ */ jsx("span", { className: "text-[11px] text-muted-foreground", children: "Issues possibles :" }),
|
|
5390
|
+
exits.map((exit) => /* @__PURE__ */ jsx(
|
|
5391
|
+
"span",
|
|
5392
|
+
{
|
|
5393
|
+
title: exit.conditions.join(" \xB7 "),
|
|
5394
|
+
className: cn(
|
|
5395
|
+
"rounded-md border px-1.5 py-0.5 text-[11px] leading-tight",
|
|
5396
|
+
EXIT_TONE_CLASSES[exit.tone]
|
|
5397
|
+
),
|
|
5398
|
+
children: outcomeLabel(exit.outcome)
|
|
5399
|
+
},
|
|
5400
|
+
exit.outcome
|
|
5401
|
+
))
|
|
5402
|
+
] })
|
|
5403
|
+
] })
|
|
5404
|
+
}
|
|
5405
|
+
)
|
|
5406
|
+
]
|
|
5407
|
+
}
|
|
5408
|
+
);
|
|
5409
|
+
}
|
|
5410
|
+
function NodeDetailPanel({
|
|
5411
|
+
node,
|
|
5412
|
+
traffic,
|
|
5413
|
+
technical,
|
|
5414
|
+
appSlug,
|
|
5415
|
+
globalNotes,
|
|
5416
|
+
onClose
|
|
5417
|
+
}) {
|
|
5418
|
+
const href = node ? settingsHref(appSlug, node.node) : null;
|
|
5419
|
+
return /* @__PURE__ */ jsx(
|
|
5420
|
+
SidePanel,
|
|
5421
|
+
{
|
|
5422
|
+
open: node !== null,
|
|
5423
|
+
onClose,
|
|
5424
|
+
title: node ? NODE_LABELS[node.node] : "",
|
|
5425
|
+
description: node ? NODE_ROLE_LABELS[node.node] : "",
|
|
5426
|
+
children: node && /* @__PURE__ */ jsxs(
|
|
5427
|
+
"div",
|
|
5428
|
+
{
|
|
5429
|
+
className: "min-h-0 flex-1 space-y-4 overflow-y-auto text-sm",
|
|
5430
|
+
"data-testid": "graph-node-detail",
|
|
5431
|
+
children: [
|
|
5432
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
5433
|
+
/* @__PURE__ */ jsx(Badge, { variant: BADGE_VARIANTS[badgeKindOf(node)], children: BADGE_LABELS[badgeKindOf(node)] }),
|
|
5434
|
+
technical && /* @__PURE__ */ jsx("code", { className: "font-mono text-xs text-muted-foreground", children: node.node })
|
|
5435
|
+
] }),
|
|
5436
|
+
node.model && /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
5437
|
+
"Mod\xE8le : ",
|
|
5438
|
+
/* @__PURE__ */ jsx("code", { className: "font-mono", children: node.model })
|
|
5439
|
+
] }),
|
|
5440
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: traffic ? `${traffic.count} ${traffic.witness} sur ${TRAFFIC_WINDOW_DAYS} jours.` : "Aucun enregistrement ne t\xE9moigne du passage par ce n\u0153ud : cette page n\u2019en affiche donc aucun chiffre." }),
|
|
5441
|
+
node.reasons.length > 0 && /* @__PURE__ */ jsxs("section", { className: "space-y-2", children: [
|
|
5442
|
+
/* @__PURE__ */ jsx("h3", { className: "text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: "Pourquoi" }),
|
|
5443
|
+
/* @__PURE__ */ jsx("ul", { className: "space-y-2", children: node.reasons.map((r, i) => /* @__PURE__ */ jsxs("li", { className: "text-xs", children: [
|
|
5444
|
+
/* @__PURE__ */ jsxs("span", { className: "font-medium", children: [
|
|
5445
|
+
REASON_KIND_LABELS[r.kind],
|
|
5446
|
+
" \u2014 "
|
|
5447
|
+
] }),
|
|
5448
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: r.message }),
|
|
5449
|
+
technical && r.detail && /* @__PURE__ */ jsx("p", { className: "mt-0.5 font-mono text-[10px] text-muted-foreground", children: r.detail })
|
|
5450
|
+
] }, i)) })
|
|
5451
|
+
] }),
|
|
5452
|
+
(node.notes.length > 0 || globalNotes.length > 0) && /* @__PURE__ */ jsxs("section", { className: "space-y-2", children: [
|
|
5453
|
+
/* @__PURE__ */ jsx("h3", { className: "text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: "\xC0 savoir" }),
|
|
5454
|
+
/* @__PURE__ */ jsxs("ul", { className: "space-y-2", children: [
|
|
5455
|
+
node.notes.map((note2, i) => /* @__PURE__ */ jsxs("li", { className: "text-xs text-muted-foreground", children: [
|
|
5456
|
+
note2.message,
|
|
5457
|
+
technical && note2.detail && /* @__PURE__ */ jsx("p", { className: "mt-0.5 font-mono text-[10px]", children: note2.detail })
|
|
5458
|
+
] }, `note-${i}`)),
|
|
5459
|
+
globalNotes.map((note2) => /* @__PURE__ */ jsxs("li", { className: "text-xs text-muted-foreground", children: [
|
|
5460
|
+
note2.message,
|
|
5461
|
+
technical && note2.detail && /* @__PURE__ */ jsx("p", { className: "mt-0.5 font-mono text-[10px]", children: note2.detail })
|
|
5462
|
+
] }, note2.id))
|
|
5463
|
+
] })
|
|
5464
|
+
] }),
|
|
5465
|
+
node.exits.length > 0 && /* @__PURE__ */ jsxs("section", { className: "space-y-2", children: [
|
|
5466
|
+
/* @__PURE__ */ jsx("h3", { className: "text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: "Issues possibles" }),
|
|
5467
|
+
/* @__PURE__ */ jsx("ul", { className: "space-y-1", children: node.exits.map((exit) => /* @__PURE__ */ jsxs("li", { className: "flex items-baseline gap-2 text-xs", children: [
|
|
5468
|
+
/* @__PURE__ */ jsx(
|
|
5469
|
+
"span",
|
|
5470
|
+
{
|
|
5471
|
+
className: cn(
|
|
5472
|
+
"rounded-md border px-1.5 py-0.5 leading-tight",
|
|
5473
|
+
EXIT_TONE_CLASSES[exit.tone]
|
|
5474
|
+
),
|
|
5475
|
+
children: outcomeLabel(exit.outcome)
|
|
5476
|
+
}
|
|
5477
|
+
),
|
|
5478
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: exit.condition })
|
|
5479
|
+
] }, exit.key)) })
|
|
5480
|
+
] }),
|
|
5481
|
+
href && /* @__PURE__ */ jsx(
|
|
5482
|
+
Link,
|
|
5483
|
+
{
|
|
5484
|
+
href,
|
|
5485
|
+
className: cn(buttonVariants({ variant: "default", size: "sm" }), "no-underline"),
|
|
5486
|
+
children: "Ouvrir le r\xE9glage"
|
|
5487
|
+
}
|
|
5488
|
+
)
|
|
5489
|
+
]
|
|
5490
|
+
}
|
|
5491
|
+
)
|
|
4626
5492
|
}
|
|
4627
5493
|
);
|
|
4628
5494
|
}
|
|
4629
5495
|
function GraphCanvasPage() {
|
|
4630
5496
|
const { appSlug } = useAppContext();
|
|
4631
|
-
const {
|
|
5497
|
+
const { value: viewParam, setValue: setViewParam } = useQueryParam("vue");
|
|
5498
|
+
const technical = viewParam === "technique";
|
|
5499
|
+
const [openNode, setOpenNode] = useState(null);
|
|
5500
|
+
const {
|
|
5501
|
+
settings,
|
|
5502
|
+
isLoading: settingsLoading,
|
|
5503
|
+
error: settingsError
|
|
5504
|
+
} = useAppSettings();
|
|
4632
5505
|
const {
|
|
4633
5506
|
rows: categories,
|
|
4634
5507
|
isLoading: categoriesLoading,
|
|
4635
5508
|
error: categoriesError
|
|
4636
5509
|
} = useRecordList("category", { limit: CATEGORY_PAGE_SIZE }, toCategory);
|
|
4637
|
-
const
|
|
5510
|
+
const traffic = useGraphTraffic(TRAFFIC_WINDOW_DAYS);
|
|
5511
|
+
const hasCategoryWithAutoReply = useMemo(
|
|
5512
|
+
() => categories.some((c) => c.autoReplyEnabled),
|
|
5513
|
+
[categories]
|
|
5514
|
+
);
|
|
4638
5515
|
const categoriesMayBeTruncated = categories.length >= CATEGORY_PAGE_SIZE;
|
|
4639
5516
|
const result = useMemo(
|
|
4640
5517
|
() => settings ? computeGraphReachability(settings, hasCategoryWithAutoReply) : null,
|
|
@@ -4642,41 +5519,134 @@ function GraphCanvasPage() {
|
|
|
4642
5519
|
);
|
|
4643
5520
|
const isLoading = settingsLoading || categoriesLoading;
|
|
4644
5521
|
const isUnavailable = !isLoading && (settingsError !== void 0 || categoriesError !== void 0 || !result);
|
|
5522
|
+
const verdict = useMemo(() => result ? computeVerdict(result) : null, [result]);
|
|
5523
|
+
const selected = result?.nodes.find((node) => node.node === openNode) ?? null;
|
|
5524
|
+
const notesFor = (node) => result ? result.globalNotes.filter((note2) => note2.nodes.includes(node)) : [];
|
|
5525
|
+
const breakNode = result?.nodes.find((node) => node.state === "unreachable" && node.cause === "root")?.node ?? null;
|
|
5526
|
+
const rail = useMemo(() => {
|
|
5527
|
+
if (!result) return null;
|
|
5528
|
+
const rows = result.nodes.map((node, i) => /* @__PURE__ */ jsxs("div", { children: [
|
|
5529
|
+
i > 0 && /* @__PURE__ */ jsx(Connector, { into: node, isBreak: node.node === breakNode }),
|
|
5530
|
+
/* @__PURE__ */ jsx(
|
|
5531
|
+
NodeRow,
|
|
5532
|
+
{
|
|
5533
|
+
node,
|
|
5534
|
+
traffic: traffic.byNode[node.node],
|
|
5535
|
+
technical,
|
|
5536
|
+
globalNotes: result.globalNotes.filter((note2) => note2.nodes.includes(node.node)),
|
|
5537
|
+
onOpen: () => setOpenNode(node.node)
|
|
5538
|
+
}
|
|
5539
|
+
)
|
|
5540
|
+
] }, node.node));
|
|
5541
|
+
const from = result.nodes.findIndex((node) => node.node === "evaluate");
|
|
5542
|
+
const to = result.nodes.findIndex((node) => node.node === "revise");
|
|
5543
|
+
if (from < 0 || to <= from) return rows;
|
|
5544
|
+
return [
|
|
5545
|
+
...rows.slice(0, from),
|
|
5546
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
5547
|
+
/* @__PURE__ */ jsx(
|
|
5548
|
+
"div",
|
|
5549
|
+
{
|
|
5550
|
+
"aria-hidden": true,
|
|
5551
|
+
"data-testid": "graph-back-edge",
|
|
5552
|
+
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"
|
|
5553
|
+
}
|
|
5554
|
+
),
|
|
5555
|
+
/* @__PURE__ */ jsx("span", { className: "pointer-events-none absolute -left-9 top-1/2 w-6 -translate-y-1/2 text-center text-[10px] leading-none text-muted-foreground", children: "\u21BA" }),
|
|
5556
|
+
rows.slice(from, to + 1)
|
|
5557
|
+
] }, "back-edge"),
|
|
5558
|
+
...rows.slice(to + 1)
|
|
5559
|
+
];
|
|
5560
|
+
}, [result, breakNode, traffic.byNode, technical]);
|
|
4645
5561
|
return /* @__PURE__ */ jsxs(PageShell, { children: [
|
|
4646
|
-
/* @__PURE__ */ jsx(
|
|
5562
|
+
/* @__PURE__ */ jsx(
|
|
5563
|
+
PageHeader,
|
|
5564
|
+
{
|
|
5565
|
+
title: "Graphe",
|
|
5566
|
+
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.",
|
|
5567
|
+
actions: /* @__PURE__ */ jsxs(
|
|
5568
|
+
"div",
|
|
5569
|
+
{
|
|
5570
|
+
className: "flex items-center rounded-md border p-0.5",
|
|
5571
|
+
role: "group",
|
|
5572
|
+
"aria-label": "Registre d'affichage",
|
|
5573
|
+
children: [
|
|
5574
|
+
/* @__PURE__ */ jsx(
|
|
5575
|
+
Button,
|
|
5576
|
+
{
|
|
5577
|
+
variant: technical ? "ghost" : "secondary",
|
|
5578
|
+
size: "sm",
|
|
5579
|
+
"aria-pressed": !technical,
|
|
5580
|
+
onClick: () => setViewParam(null),
|
|
5581
|
+
children: "Op\xE9rateur"
|
|
5582
|
+
}
|
|
5583
|
+
),
|
|
5584
|
+
/* @__PURE__ */ jsx(
|
|
5585
|
+
Button,
|
|
5586
|
+
{
|
|
5587
|
+
variant: technical ? "secondary" : "ghost",
|
|
5588
|
+
size: "sm",
|
|
5589
|
+
"aria-pressed": technical,
|
|
5590
|
+
onClick: () => setViewParam("technique"),
|
|
5591
|
+
children: "Technique"
|
|
5592
|
+
}
|
|
5593
|
+
)
|
|
5594
|
+
]
|
|
5595
|
+
}
|
|
5596
|
+
)
|
|
5597
|
+
}
|
|
5598
|
+
),
|
|
4647
5599
|
isLoading ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center py-12", children: [
|
|
4648
5600
|
/* @__PURE__ */ jsx(Spinner, {}),
|
|
4649
5601
|
" ",
|
|
4650
5602
|
/* @__PURE__ */ jsx("span", { className: "ml-2 text-sm text-muted-foreground", children: "Chargement\u2026" })
|
|
4651
5603
|
] }) : isUnavailable ? /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: "Impossible de calculer le graphe : les r\xE9glages ou les cat\xE9gories n'ont pas pu \xEAtre charg\xE9s." }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
5604
|
+
/* @__PURE__ */ jsx(VerdictBanner, { verdict, appSlug }),
|
|
5605
|
+
result.globalNotes.map((note2) => /* @__PURE__ */ jsxs(
|
|
5606
|
+
"div",
|
|
5607
|
+
{
|
|
5608
|
+
"data-testid": `graph-global-note-${note2.id}`,
|
|
5609
|
+
className: "rounded-md border border-status-warning/40 bg-status-warning/10 p-3 text-sm text-status-warning",
|
|
5610
|
+
children: [
|
|
5611
|
+
/* @__PURE__ */ jsx("p", { children: note2.message }),
|
|
5612
|
+
/* @__PURE__ */ jsxs("p", { className: "mt-1 text-xs", children: [
|
|
5613
|
+
"N\u0153uds concern\xE9s (",
|
|
5614
|
+
note2.nodes.length,
|
|
5615
|
+
") :",
|
|
5616
|
+
" ",
|
|
5617
|
+
note2.nodes.map((n) => NODE_LABELS[n]).join(", "),
|
|
5618
|
+
"."
|
|
5619
|
+
] }),
|
|
5620
|
+
technical && note2.detail && /* @__PURE__ */ jsx("p", { className: "mt-1 font-mono text-[10px]", children: note2.detail })
|
|
5621
|
+
]
|
|
5622
|
+
},
|
|
5623
|
+
note2.id
|
|
5624
|
+
)),
|
|
4656
5625
|
!hasCategoryWithAutoReply && categoriesMayBeTruncated && /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
4657
5626
|
"La lecture des cat\xE9gories est born\xE9e aux ",
|
|
4658
5627
|
CATEGORY_PAGE_SIZE,
|
|
4659
5628
|
" premi\xE8res \u2014 au-del\xE0, l'absence de cat\xE9gorie avec \xAB Envoi auto \xBB activ\xE9 ci-dessous peut \xEAtre un simple effet de fen\xEAtre, pas un fait."
|
|
4660
5629
|
] }),
|
|
4661
|
-
/* @__PURE__ */ jsx(
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
5630
|
+
/* @__PURE__ */ jsx(Legend, {}),
|
|
5631
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: traffic.unavailable ? "Trafic observ\xE9 indisponible : le verdict ci-dessous reste calcul\xE9 sur les r\xE9glages seuls." : `Chiffres observ\xE9s sur les ${TRAFFIC_WINDOW_DAYS} derniers jours \u2014 seuls les n\u0153uds dont un enregistrement t\xE9moigne du passage en portent un.` }),
|
|
5632
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-0 pl-10", children: rail }),
|
|
5633
|
+
/* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
5634
|
+
"\u21BA",
|
|
5635
|
+
" \xAB R\xE9vision \xBB rejoue \xAB \xC9valuation \xBB \u2014 au plus une passe par ticket",
|
|
5636
|
+
technical ? " (\xA73.3)" : "",
|
|
5637
|
+
"."
|
|
5638
|
+
] }),
|
|
5639
|
+
/* @__PURE__ */ jsx(
|
|
5640
|
+
NodeDetailPanel,
|
|
5641
|
+
{
|
|
5642
|
+
node: selected,
|
|
5643
|
+
traffic: selected ? traffic.byNode[selected.node] : void 0,
|
|
5644
|
+
technical,
|
|
5645
|
+
appSlug,
|
|
5646
|
+
globalNotes: selected ? notesFor(selected.node) : [],
|
|
5647
|
+
onClose: () => setOpenNode(null)
|
|
5648
|
+
}
|
|
5649
|
+
)
|
|
4680
5650
|
] })
|
|
4681
5651
|
] });
|
|
4682
5652
|
}
|
|
@@ -5392,31 +6362,6 @@ function TestPage() {
|
|
|
5392
6362
|
!canRun ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Acc\xE8s en lecture seule \u2014 lancer un test n\xE9cessite le r\xF4le EDITOR (chaque ex\xE9cution consomme du budget LLM)." }) : /* @__PURE__ */ jsx(TestControls, {})
|
|
5393
6363
|
] });
|
|
5394
6364
|
}
|
|
5395
|
-
function readParam(name) {
|
|
5396
|
-
if (typeof window === "undefined") return null;
|
|
5397
|
-
return new URLSearchParams(window.location.search).get(name);
|
|
5398
|
-
}
|
|
5399
|
-
function useQueryParam(name) {
|
|
5400
|
-
const [value, setState] = useState(() => readParam(name));
|
|
5401
|
-
useEffect(() => {
|
|
5402
|
-
const sync = () => setState(readParam(name));
|
|
5403
|
-
sync();
|
|
5404
|
-
window.addEventListener("popstate", sync);
|
|
5405
|
-
return () => window.removeEventListener("popstate", sync);
|
|
5406
|
-
}, [name]);
|
|
5407
|
-
const setValue = useCallback(
|
|
5408
|
-
(next) => {
|
|
5409
|
-
const params = new URLSearchParams(window.location.search);
|
|
5410
|
-
if (next === null) params.delete(name);
|
|
5411
|
-
else params.set(name, next);
|
|
5412
|
-
const query = params.toString();
|
|
5413
|
-
window.history.pushState({}, "", `${window.location.pathname}${query ? `?${query}` : ""}`);
|
|
5414
|
-
setState(next);
|
|
5415
|
-
},
|
|
5416
|
-
[name]
|
|
5417
|
-
);
|
|
5418
|
-
return { value, setValue };
|
|
5419
|
-
}
|
|
5420
6365
|
function ExperimentStatusBadge({ experiment }) {
|
|
5421
6366
|
if (experiment.status === "done" && experiment.succeeded) {
|
|
5422
6367
|
return /* @__PURE__ */ jsx(Badge, { variant: "success", children: "Termin\xE9" });
|