@apotech-os/support-kit 8.0.0 → 8.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-2UHFKGMI.js → chunk-LXHPPWPM.js} +20 -6
- package/dist/chunk-LXHPPWPM.js.map +1 -0
- package/dist/index.cjs +146 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +131 -62
- package/dist/index.js.map +1 -1
- package/dist/ui/index.cjs +299 -52
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +286 -52
- package/dist/ui/index.js.map +1 -1
- package/package.json +11 -11
- package/dist/chunk-2UHFKGMI.js.map +0 -1
package/dist/ui/index.cjs
CHANGED
|
@@ -340,6 +340,7 @@ var EMPTY_TOTALS = {
|
|
|
340
340
|
failed: 0
|
|
341
341
|
};
|
|
342
342
|
function outcomeOf(status, autoSendDecision) {
|
|
343
|
+
if (status === "test_draft") return null;
|
|
343
344
|
if (status === "sent") return "auto";
|
|
344
345
|
if (status === "no_reply_needed") return "noReplyNeeded";
|
|
345
346
|
if (status === "failed") return "failed";
|
|
@@ -349,7 +350,8 @@ function outcomeOf(status, autoSendDecision) {
|
|
|
349
350
|
function foldOutcomes(rows) {
|
|
350
351
|
const totals = { ...EMPTY_TOTALS };
|
|
351
352
|
for (const row of rows) {
|
|
352
|
-
|
|
353
|
+
const outcome = outcomeOf(row["status"], row["autoSendDecision"]);
|
|
354
|
+
if (outcome !== null) totals[outcome] += Number(row["count"]) || 0;
|
|
353
355
|
}
|
|
354
356
|
return totals;
|
|
355
357
|
}
|
|
@@ -363,9 +365,11 @@ function autonomyRate(totals) {
|
|
|
363
365
|
function foldDailyOutcomes(rows) {
|
|
364
366
|
const byDay = /* @__PURE__ */ new Map();
|
|
365
367
|
for (const row of rows) {
|
|
368
|
+
const outcome = outcomeOf(row["status"], row["autoSendDecision"]);
|
|
369
|
+
if (outcome === null) continue;
|
|
366
370
|
const day = bucketDay(row);
|
|
367
371
|
const totals = byDay.get(day) ?? { ...EMPTY_TOTALS };
|
|
368
|
-
totals[
|
|
372
|
+
totals[outcome] += Number(row["count"]) || 0;
|
|
369
373
|
byDay.set(day, totals);
|
|
370
374
|
}
|
|
371
375
|
return [...byDay.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([day, totals]) => ({
|
|
@@ -1118,6 +1122,31 @@ function TicketLink({ ticketId, url, label }) {
|
|
|
1118
1122
|
}
|
|
1119
1123
|
);
|
|
1120
1124
|
}
|
|
1125
|
+
function readParam(name) {
|
|
1126
|
+
if (typeof window === "undefined") return null;
|
|
1127
|
+
return new URLSearchParams(window.location.search).get(name);
|
|
1128
|
+
}
|
|
1129
|
+
function useQueryParam(name) {
|
|
1130
|
+
const [value, setState] = react.useState(() => readParam(name));
|
|
1131
|
+
react.useEffect(() => {
|
|
1132
|
+
const sync = () => setState(readParam(name));
|
|
1133
|
+
sync();
|
|
1134
|
+
window.addEventListener("popstate", sync);
|
|
1135
|
+
return () => window.removeEventListener("popstate", sync);
|
|
1136
|
+
}, [name]);
|
|
1137
|
+
const setValue = react.useCallback(
|
|
1138
|
+
(next) => {
|
|
1139
|
+
const params = new URLSearchParams(window.location.search);
|
|
1140
|
+
if (next === null) params.delete(name);
|
|
1141
|
+
else params.set(name, next);
|
|
1142
|
+
const query = params.toString();
|
|
1143
|
+
window.history.pushState({}, "", `${window.location.pathname}${query ? `?${query}` : ""}`);
|
|
1144
|
+
setState(next);
|
|
1145
|
+
},
|
|
1146
|
+
[name]
|
|
1147
|
+
);
|
|
1148
|
+
return { value, setValue };
|
|
1149
|
+
}
|
|
1121
1150
|
var UNCONFIGURED = { baseUrl: null, projectId: null };
|
|
1122
1151
|
function useLangfuseConfig() {
|
|
1123
1152
|
const { appSlug } = uiSdk.useAppContext();
|
|
@@ -1168,7 +1197,8 @@ function LangfuseTraceLink({ traceId, observationId, config, label = "Voir la tr
|
|
|
1168
1197
|
if (!traceId) {
|
|
1169
1198
|
return observationId ? /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CopyButton, { value: observationId, label }) : null;
|
|
1170
1199
|
}
|
|
1171
|
-
if (!config
|
|
1200
|
+
if (!config) return null;
|
|
1201
|
+
if (!config.baseUrl || !config.projectId) return /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CopyButton, { value: traceId, label });
|
|
1172
1202
|
const origin = parseHttpOrigin(config.baseUrl);
|
|
1173
1203
|
if (!origin) return null;
|
|
1174
1204
|
const url = buildTraceUrl(origin, config.projectId, traceId, observationId);
|
|
@@ -1195,7 +1225,8 @@ var GENERATED_RESPONSE_STATUS_LABELS = {
|
|
|
1195
1225
|
failed: "\xC9chec",
|
|
1196
1226
|
no_reply_needed: "Aucune r\xE9ponse n\xE9cessaire",
|
|
1197
1227
|
invalidated: "Invalid\xE9e",
|
|
1198
|
-
expired: "Expir\xE9e"
|
|
1228
|
+
expired: "Expir\xE9e",
|
|
1229
|
+
test_draft: "Brouillon d'essai \u2014 jamais envoy\xE9"
|
|
1199
1230
|
};
|
|
1200
1231
|
var AUTO_SEND_DECISION_LABELS = {
|
|
1201
1232
|
auto: "Autoris\xE9",
|
|
@@ -1250,6 +1281,74 @@ function outcomeLabel(outcome) {
|
|
|
1250
1281
|
return outcome ? OUTCOME_LABELS[outcome] : "\u2014";
|
|
1251
1282
|
}
|
|
1252
1283
|
|
|
1284
|
+
// src/ui/tickets/generation-origin.ts
|
|
1285
|
+
var ORIGINS = {
|
|
1286
|
+
first: { kind: "first", label: "1re r\xE9ponse" },
|
|
1287
|
+
followup: { kind: "followup", label: "Message suivant" },
|
|
1288
|
+
test: { kind: "test", label: "Brouillon d'essai" }
|
|
1289
|
+
};
|
|
1290
|
+
function generationOrigin(decision, job) {
|
|
1291
|
+
if (job?.status === "test_draft") return ORIGINS.test;
|
|
1292
|
+
return decision.origin === "followup" ? ORIGINS.followup : ORIGINS.first;
|
|
1293
|
+
}
|
|
1294
|
+
var HISTORY_LIMIT = 100;
|
|
1295
|
+
function useTicketHistory(ticketId) {
|
|
1296
|
+
const { appSlug } = uiSdk.useAppContext();
|
|
1297
|
+
const api = uiSdk.useAppApi();
|
|
1298
|
+
const [entries, setEntries] = react.useState([]);
|
|
1299
|
+
const clientRef = react.useRef(api);
|
|
1300
|
+
clientRef.current = api;
|
|
1301
|
+
const requestIdRef = react.useRef(0);
|
|
1302
|
+
const loadedTicketIdRef = react.useRef(null);
|
|
1303
|
+
const load = react.useCallback(async () => {
|
|
1304
|
+
const requestId = ++requestIdRef.current;
|
|
1305
|
+
if (ticketId === null) {
|
|
1306
|
+
loadedTicketIdRef.current = null;
|
|
1307
|
+
setEntries([]);
|
|
1308
|
+
return;
|
|
1309
|
+
}
|
|
1310
|
+
if (loadedTicketIdRef.current !== ticketId) {
|
|
1311
|
+
loadedTicketIdRef.current = null;
|
|
1312
|
+
setEntries([]);
|
|
1313
|
+
}
|
|
1314
|
+
const byTicket = (sortField) => ({
|
|
1315
|
+
filter: JSON.stringify({ ticketId: { eq: ticketId } }),
|
|
1316
|
+
sort: JSON.stringify([{ field: sortField, direction: "asc" }]),
|
|
1317
|
+
limit: String(HISTORY_LIMIT)
|
|
1318
|
+
});
|
|
1319
|
+
try {
|
|
1320
|
+
const [decisionsPage, jobsPage] = await Promise.all([
|
|
1321
|
+
clientRef.current.get(`/data/apps/${appSlug}/records/triage-decision`, byTicket("decidedAt")),
|
|
1322
|
+
// No sort: these land in a Map keyed by the unique `triageDecisionId`,
|
|
1323
|
+
// so their order is irrelevant (and `generatedAt` is nullable anyway).
|
|
1324
|
+
clientRef.current.get(`/data/apps/${appSlug}/records/generated-response`, {
|
|
1325
|
+
filter: JSON.stringify({ ticketId: { eq: ticketId } }),
|
|
1326
|
+
limit: String(HISTORY_LIMIT)
|
|
1327
|
+
})
|
|
1328
|
+
]);
|
|
1329
|
+
if (requestId !== requestIdRef.current) return;
|
|
1330
|
+
const jobByDecisionId = /* @__PURE__ */ new Map();
|
|
1331
|
+
for (const record of jobsPage.items) {
|
|
1332
|
+
const job = toGeneratedResponse(record);
|
|
1333
|
+
if (job.triageDecisionId) jobByDecisionId.set(job.triageDecisionId, job);
|
|
1334
|
+
}
|
|
1335
|
+
loadedTicketIdRef.current = ticketId;
|
|
1336
|
+
setEntries(
|
|
1337
|
+
decisionsPage.items.map((record) => toTriageDecision(record)).map((decision) => ({ decision, job: jobByDecisionId.get(decision.id) }))
|
|
1338
|
+
);
|
|
1339
|
+
} catch {
|
|
1340
|
+
if (requestId === requestIdRef.current) setEntries([]);
|
|
1341
|
+
}
|
|
1342
|
+
}, [ticketId, appSlug]);
|
|
1343
|
+
react.useEffect(() => {
|
|
1344
|
+
void load();
|
|
1345
|
+
return () => {
|
|
1346
|
+
requestIdRef.current += 1;
|
|
1347
|
+
};
|
|
1348
|
+
}, [load]);
|
|
1349
|
+
return { entries, refresh: load };
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1253
1352
|
// src/status/machine.ts
|
|
1254
1353
|
var GENERATED_RESPONSE_STATUSES = [
|
|
1255
1354
|
"pending",
|
|
@@ -1259,20 +1358,33 @@ var GENERATED_RESPONSE_STATUSES = [
|
|
|
1259
1358
|
"failed",
|
|
1260
1359
|
"no_reply_needed",
|
|
1261
1360
|
"invalidated",
|
|
1262
|
-
"expired"
|
|
1361
|
+
"expired",
|
|
1362
|
+
// 24/09/2026 — where "générer sans envoyer" rests its draft. It used to
|
|
1363
|
+
// finalize as `invalidated`, which the ticket page and the dashboard both
|
|
1364
|
+
// read as "an agent had already answered": the test artefact was stored,
|
|
1365
|
+
// but disguised as a human intervention. Terminal on purpose — nothing may
|
|
1366
|
+
// serve, send or revive a test draft — and terminal is also what frees the
|
|
1367
|
+
// `openTicketKey` (see `openTicketKeyFor`), so an essay can never hold the
|
|
1368
|
+
// real webhook at G9.
|
|
1369
|
+
"test_draft"
|
|
1263
1370
|
];
|
|
1264
1371
|
function isGeneratedResponseStatus(value) {
|
|
1265
1372
|
return typeof value === "string" && GENERATED_RESPONSE_STATUSES.includes(value);
|
|
1266
1373
|
}
|
|
1267
1374
|
var ALLOWED_TRANSITIONS = {
|
|
1268
|
-
pending:
|
|
1375
|
+
// `pending -> test_draft` is the ONLY way in: the test pass finalizes the
|
|
1376
|
+
// very `pending` row it opened, and no other status can become a test
|
|
1377
|
+
// draft after the fact — an operator invalidating a real `ready` draft is
|
|
1378
|
+
// expressing "discard this", not "this was an essay".
|
|
1379
|
+
pending: ["ready", "failed", "no_reply_needed", "sending", "invalidated", "test_draft"],
|
|
1269
1380
|
ready: ["sending", "invalidated", "expired"],
|
|
1270
1381
|
sending: ["sent", "ready"],
|
|
1271
1382
|
sent: [],
|
|
1272
1383
|
failed: [],
|
|
1273
1384
|
no_reply_needed: [],
|
|
1274
1385
|
invalidated: [],
|
|
1275
|
-
expired: []
|
|
1386
|
+
expired: [],
|
|
1387
|
+
test_draft: []
|
|
1276
1388
|
};
|
|
1277
1389
|
function canTransition(from, to) {
|
|
1278
1390
|
if (!isGeneratedResponseStatus(from) || !isGeneratedResponseStatus(to)) return false;
|
|
@@ -1708,6 +1820,8 @@ function deliveryReason(input) {
|
|
|
1708
1820
|
}
|
|
1709
1821
|
case "failed":
|
|
1710
1822
|
return job.error ?? "La r\xE9ponse a \xE9chou\xE9 avant son envoi.";
|
|
1823
|
+
case "test_draft":
|
|
1824
|
+
return "Brouillon d'essai \u2014 jamais envoy\xE9.";
|
|
1711
1825
|
default:
|
|
1712
1826
|
return `La r\xE9ponse n'a pas \xE9t\xE9 envoy\xE9e (statut : ${job.status}).`;
|
|
1713
1827
|
}
|
|
@@ -1858,7 +1972,7 @@ function ticketActions(input) {
|
|
|
1858
1972
|
return { tags, taken, skipped, simulated, unrecorded: job !== void 0 && job.outcome === null };
|
|
1859
1973
|
}
|
|
1860
1974
|
function TimelinePanel(props) {
|
|
1861
|
-
const { decision, job, comparisons, conversation, conversationLoading, categoryName, policy, category, onClose, onInvalidate, isInvalidating } = props;
|
|
1975
|
+
const { decision, job, comparisons, conversation, conversationLoading, categoryName, policy, category, onClose, onInvalidate, isInvalidating, history, onSelectGeneration } = props;
|
|
1862
1976
|
const steps = buildTimeline({ decision, job, comparisons, conversation, conversationLoading, policy, category });
|
|
1863
1977
|
const notSentReason2 = steps.find((step2) => step2.key === "delivery")?.reason ?? null;
|
|
1864
1978
|
const actions = ticketActions({ decision, job, policy, category, notSentReason: notSentReason2 });
|
|
@@ -1868,10 +1982,41 @@ function TimelinePanel(props) {
|
|
|
1868
1982
|
/* @__PURE__ */ jsxRuntime.jsx(TicketLink, { ticketId: decision.ticketId, url: decision.ticketUrl, label: "Ouvrir le ticket dans Gorgias" }),
|
|
1869
1983
|
onInvalidate && canInvalidate && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", size: "sm", onClick: onInvalidate, disabled: isInvalidating, children: isInvalidating ? "Invalidation\u2026" : "Invalider la r\xE9ponse" })
|
|
1870
1984
|
] }),
|
|
1985
|
+
history !== void 0 && history.length > 1 && /* @__PURE__ */ jsxRuntime.jsx(ThreadHistory, { history, selectedDecisionId: decision.id, onSelect: onSelectGeneration }),
|
|
1871
1986
|
steps.map((step2, index) => /* @__PURE__ */ jsxRuntime.jsx(StepBlock, { step: step2, index, last: index === steps.length - 1, children: step2.reached ? renderStep(step2.key, props) : null }, step2.key)),
|
|
1872
1987
|
/* @__PURE__ */ jsxRuntime.jsx(ActionsBlock, { actions })
|
|
1873
1988
|
] }) });
|
|
1874
1989
|
}
|
|
1990
|
+
function ThreadHistory({
|
|
1991
|
+
history,
|
|
1992
|
+
selectedDecisionId,
|
|
1993
|
+
onSelect
|
|
1994
|
+
}) {
|
|
1995
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1 border-b pb-3", children: [
|
|
1996
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs font-medium", children: "Historique du fil" }),
|
|
1997
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "space-y-1", children: history.map(({ decision, job }) => {
|
|
1998
|
+
const selected = decision.id === selectedDecisionId;
|
|
1999
|
+
const origin = generationOrigin(decision, job);
|
|
2000
|
+
const outcome = responseOutcome(job);
|
|
2001
|
+
return /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2002
|
+
"button",
|
|
2003
|
+
{
|
|
2004
|
+
type: "button",
|
|
2005
|
+
onClick: onSelect ? () => onSelect(decision) : void 0,
|
|
2006
|
+
"aria-current": selected || void 0,
|
|
2007
|
+
className: `flex w-full items-center justify-between gap-2 rounded border px-2 py-1 text-left text-xs ${selected ? "border-primary/40 bg-primary/5" : "border-border hover:bg-muted/40"}`,
|
|
2008
|
+
children: [
|
|
2009
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-2", children: [
|
|
2010
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: formatDate(decision.decidedAt) }),
|
|
2011
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: origin.label })
|
|
2012
|
+
] }),
|
|
2013
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: outcome.variant, children: outcome.label })
|
|
2014
|
+
]
|
|
2015
|
+
}
|
|
2016
|
+
) }, decision.id);
|
|
2017
|
+
}) })
|
|
2018
|
+
] });
|
|
2019
|
+
}
|
|
1875
2020
|
function StepBlock({
|
|
1876
2021
|
step: step2,
|
|
1877
2022
|
index,
|
|
@@ -2112,6 +2257,12 @@ var CORRECTED_OPTIONS = [
|
|
|
2112
2257
|
{ value: "true", label: "Corrig\xE9s par un humain" },
|
|
2113
2258
|
{ value: "false", label: "Non corrig\xE9s" }
|
|
2114
2259
|
];
|
|
2260
|
+
var ORIGIN_FILTER_OPTIONS = [
|
|
2261
|
+
{ value: "", label: "Toutes origines" },
|
|
2262
|
+
{ value: "first", label: "1res r\xE9ponses" },
|
|
2263
|
+
{ value: "followup", label: "Messages suivants" },
|
|
2264
|
+
{ value: "test", label: "Brouillons d'essai" }
|
|
2265
|
+
];
|
|
2115
2266
|
function OutcomeBadge({ outcome }) {
|
|
2116
2267
|
return /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: OUTCOME_BADGE_VARIANT[outcome.variant], children: outcome.label });
|
|
2117
2268
|
}
|
|
@@ -2130,19 +2281,35 @@ function TicketsPage() {
|
|
|
2130
2281
|
const [verdictFilter, setVerdictFilter] = react.useState("");
|
|
2131
2282
|
const [promptVersionFilter, setPromptVersionFilter] = react.useState("");
|
|
2132
2283
|
const [correctedFilter, setCorrectedFilter] = react.useState("");
|
|
2284
|
+
const [originFilter, setOriginFilter] = react.useState("");
|
|
2133
2285
|
const [detailDecision, setDetailDecision] = react.useState(null);
|
|
2134
2286
|
const [isTriaging, setIsTriaging] = react.useState(false);
|
|
2135
2287
|
const [isInvalidating, setIsInvalidating] = react.useState(false);
|
|
2288
|
+
const requestedTicket = useQueryParam("ticket").value;
|
|
2289
|
+
const [ticketSearch, setTicketSearch] = react.useState(() => requestedTicket?.trim() ?? "");
|
|
2290
|
+
const searchDebounce = react.useRef(null);
|
|
2291
|
+
const onTableStateChange = react.useCallback((tableState) => {
|
|
2292
|
+
if (searchDebounce.current) clearTimeout(searchDebounce.current);
|
|
2293
|
+
searchDebounce.current = setTimeout(() => setTicketSearch(tableState.search.trim()), 300);
|
|
2294
|
+
}, []);
|
|
2295
|
+
react.useEffect(
|
|
2296
|
+
() => () => {
|
|
2297
|
+
if (searchDebounce.current) clearTimeout(searchDebounce.current);
|
|
2298
|
+
},
|
|
2299
|
+
[]
|
|
2300
|
+
);
|
|
2301
|
+
const history = useTicketHistory(detailDecision?.ticketId ?? null);
|
|
2136
2302
|
const [triageInFlight] = react.useState(() => ({ current: false }));
|
|
2137
2303
|
const periodKey = JSON.stringify(period);
|
|
2138
2304
|
const bounds = react.useMemo(() => periodBoundsOf(JSON.parse(periodKey)).current, [periodKey]);
|
|
2139
2305
|
const decisionFilter = react.useMemo(() => {
|
|
2306
|
+
if (ticketSearch) return { ticketId: { eq: ticketSearch } };
|
|
2140
2307
|
const filter = { decidedAt: { gte: bounds.fromIso, lte: bounds.toIso } };
|
|
2141
2308
|
if (categoryFilter) filter.categoryId = { eq: categoryFilter };
|
|
2142
2309
|
if (escalatedFilter) filter.escalated = { eq: escalatedFilter === "true" };
|
|
2143
2310
|
if (confidenceFilter) filter.confidence = { eq: confidenceFilter };
|
|
2144
2311
|
return filter;
|
|
2145
|
-
}, [bounds.fromIso, bounds.toIso, categoryFilter, escalatedFilter, confidenceFilter]);
|
|
2312
|
+
}, [ticketSearch, bounds.fromIso, bounds.toIso, categoryFilter, escalatedFilter, confidenceFilter]);
|
|
2146
2313
|
const {
|
|
2147
2314
|
rows: decisions,
|
|
2148
2315
|
isLoading: decisionsLoading,
|
|
@@ -2195,7 +2362,7 @@ function TicketsPage() {
|
|
|
2195
2362
|
const agentNames = react.useMemo(() => toNameMap(agents), [agents]);
|
|
2196
2363
|
const { config: langfuseConfig } = useLangfuseConfig();
|
|
2197
2364
|
function refreshAll() {
|
|
2198
|
-
return Promise.all([refreshDecisions(), refreshJobs(), refreshComparisons()]).then(() => void 0);
|
|
2365
|
+
return Promise.all([refreshDecisions(), refreshJobs(), refreshComparisons(), history.refresh()]).then(() => void 0);
|
|
2199
2366
|
}
|
|
2200
2367
|
const jobByDecisionId = react.useMemo(() => {
|
|
2201
2368
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -2242,9 +2409,18 @@ function TicketsPage() {
|
|
|
2242
2409
|
if (promptVersionFilter && String(row.job?.promptVersion ?? "") !== promptVersionFilter) return false;
|
|
2243
2410
|
if (correctedFilter === "true" && row.comparisons.length === 0) return false;
|
|
2244
2411
|
if (correctedFilter === "false" && row.comparisons.length > 0) return false;
|
|
2412
|
+
if (originFilter && generationOrigin(row.decision, row.job).kind !== originFilter) return false;
|
|
2245
2413
|
return true;
|
|
2246
2414
|
});
|
|
2247
|
-
}, [decisions, jobByDecisionId, comparisonsByTicketId, outcomeFilter, verdictFilter, promptVersionFilter, correctedFilter]);
|
|
2415
|
+
}, [decisions, jobByDecisionId, comparisonsByTicketId, outcomeFilter, verdictFilter, promptVersionFilter, correctedFilter, originFilter]);
|
|
2416
|
+
const deepLinkConsumed = react.useRef(false);
|
|
2417
|
+
react.useEffect(() => {
|
|
2418
|
+
if (deepLinkConsumed.current || !requestedTicket) return;
|
|
2419
|
+
const match = rows.find((row) => row.decision.ticketId === requestedTicket);
|
|
2420
|
+
if (!match) return;
|
|
2421
|
+
deepLinkConsumed.current = true;
|
|
2422
|
+
setDetailDecision(match.decision);
|
|
2423
|
+
}, [requestedTicket, rows]);
|
|
2248
2424
|
const categoryOptions = react.useMemo(
|
|
2249
2425
|
() => [{ value: "", label: "Toutes cat\xE9gories" }, ...categories.map((category) => ({ value: category.id, label: category.name }))],
|
|
2250
2426
|
[categories]
|
|
@@ -2284,6 +2460,15 @@ function TicketsPage() {
|
|
|
2284
2460
|
}
|
|
2285
2461
|
const columns = [
|
|
2286
2462
|
{ key: "ticketId", header: "Ticket", cell: ({ decision }) => /* @__PURE__ */ jsxRuntime.jsx(TicketLink, { ticketId: decision.ticketId, url: decision.ticketUrl }) },
|
|
2463
|
+
{
|
|
2464
|
+
key: "origin",
|
|
2465
|
+
header: "Origine",
|
|
2466
|
+
cell: ({ decision, job }) => {
|
|
2467
|
+
const origin = generationOrigin(decision, job);
|
|
2468
|
+
if (origin.kind === "first") return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: origin.label });
|
|
2469
|
+
return /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: origin.kind === "test" ? "warning" : "info", children: origin.label });
|
|
2470
|
+
}
|
|
2471
|
+
},
|
|
2287
2472
|
{ key: "category", header: "Cat\xE9gorie", cell: ({ decision }) => decision.categoryId && categoryNames.get(decision.categoryId) || "\u2014" },
|
|
2288
2473
|
{ key: "tag", header: "Tag", cell: ({ decision }) => decision.tag ? /* @__PURE__ */ jsxRuntime.jsx("code", { className: "text-xs", children: decision.tag }) : "\u2014" },
|
|
2289
2474
|
{
|
|
@@ -2340,7 +2525,12 @@ function TicketsPage() {
|
|
|
2340
2525
|
},
|
|
2341
2526
|
{ key: "decidedAt", header: "D\xE9cid\xE9 le", cell: ({ decision }) => formatDate(decision.decidedAt) }
|
|
2342
2527
|
];
|
|
2343
|
-
const
|
|
2528
|
+
const historyEntry = detailDecision ? history.entries.find((entry) => entry.decision.id === detailDecision.id) : void 0;
|
|
2529
|
+
const pageRow = detailDecision ? rows.find((row) => row.decision.id === detailDecision.id) : void 0;
|
|
2530
|
+
const detailRow = detailDecision ? {
|
|
2531
|
+
job: historyEntry?.job ?? pageRow?.job,
|
|
2532
|
+
comparisons: comparisonsByTicketId.get(detailDecision.ticketId) ?? []
|
|
2533
|
+
} : void 0;
|
|
2344
2534
|
const liveConversation = useLiveConversation(detailDecision, detailRow);
|
|
2345
2535
|
const isLoading = decisionsLoading || jobsLoading;
|
|
2346
2536
|
const combinedError = decisionsError ?? jobsError ?? comparisonsError;
|
|
@@ -2374,6 +2564,7 @@ function TicketsPage() {
|
|
|
2374
2564
|
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Select, { items: VERDICT_OPTIONS, value: verdictFilter, onValueChange: setVerdictFilter, placeholder: "Tous les verdicts", "aria-label": "Filtrer par verdict" }),
|
|
2375
2565
|
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Select, { items: promptVersionOptions, value: promptVersionFilter, onValueChange: setPromptVersionFilter, placeholder: "Toutes versions de prompt", "aria-label": "Filtrer par version de prompt" }),
|
|
2376
2566
|
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Select, { items: CORRECTED_OPTIONS, value: correctedFilter, onValueChange: setCorrectedFilter, placeholder: "Corrig\xE9s ou non", "aria-label": "Filtrer par correction humaine" }),
|
|
2567
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Select, { items: ORIGIN_FILTER_OPTIONS, value: originFilter, onValueChange: setOriginFilter, placeholder: "Toutes origines", "aria-label": "Filtrer par origine" }),
|
|
2377
2568
|
rows.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ml-auto text-sm text-muted-foreground", children: [
|
|
2378
2569
|
rows.length,
|
|
2379
2570
|
" ticket",
|
|
@@ -2388,6 +2579,9 @@ function TicketsPage() {
|
|
|
2388
2579
|
rows,
|
|
2389
2580
|
rowId: (row) => row.decision.id,
|
|
2390
2581
|
manual: true,
|
|
2582
|
+
defaultState: { search: requestedTicket?.trim() ?? "" },
|
|
2583
|
+
onStateChange: onTableStateChange,
|
|
2584
|
+
searchPlaceholder: "ID de ticket\u2026",
|
|
2391
2585
|
loading: isLoading,
|
|
2392
2586
|
onRowClick: (row) => setDetailDecision(row.decision),
|
|
2393
2587
|
pagination: {
|
|
@@ -2420,6 +2614,8 @@ function TicketsPage() {
|
|
|
2420
2614
|
category: categories.find((entry) => entry.id === detailDecision.categoryId) ?? null,
|
|
2421
2615
|
agentName: detailRow?.job?.agentId && agentNames.get(detailRow.job.agentId) || "\u2014",
|
|
2422
2616
|
langfuseConfig,
|
|
2617
|
+
history: history.entries,
|
|
2618
|
+
onSelectGeneration: (selected) => setDetailDecision(selected),
|
|
2423
2619
|
onClose: () => setDetailDecision(null),
|
|
2424
2620
|
onInvalidate: canWrite && detailRow?.job ? () => void invalidateResponse(detailRow.job.id) : void 0,
|
|
2425
2621
|
isInvalidating
|
|
@@ -5105,31 +5301,6 @@ function SettingsPage() {
|
|
|
5105
5301
|
);
|
|
5106
5302
|
}
|
|
5107
5303
|
var ReglagesPage = SettingsPage;
|
|
5108
|
-
function readParam(name) {
|
|
5109
|
-
if (typeof window === "undefined") return null;
|
|
5110
|
-
return new URLSearchParams(window.location.search).get(name);
|
|
5111
|
-
}
|
|
5112
|
-
function useQueryParam(name) {
|
|
5113
|
-
const [value, setState] = react.useState(() => readParam(name));
|
|
5114
|
-
react.useEffect(() => {
|
|
5115
|
-
const sync = () => setState(readParam(name));
|
|
5116
|
-
sync();
|
|
5117
|
-
window.addEventListener("popstate", sync);
|
|
5118
|
-
return () => window.removeEventListener("popstate", sync);
|
|
5119
|
-
}, [name]);
|
|
5120
|
-
const setValue = react.useCallback(
|
|
5121
|
-
(next) => {
|
|
5122
|
-
const params = new URLSearchParams(window.location.search);
|
|
5123
|
-
if (next === null) params.delete(name);
|
|
5124
|
-
else params.set(name, next);
|
|
5125
|
-
const query = params.toString();
|
|
5126
|
-
window.history.pushState({}, "", `${window.location.pathname}${query ? `?${query}` : ""}`);
|
|
5127
|
-
setState(next);
|
|
5128
|
-
},
|
|
5129
|
-
[name]
|
|
5130
|
-
);
|
|
5131
|
-
return { value, setValue };
|
|
5132
|
-
}
|
|
5133
5304
|
|
|
5134
5305
|
// src/ui/graph-canvas/reachability.ts
|
|
5135
5306
|
var EXIT_TONES = {
|
|
@@ -6706,20 +6877,81 @@ function DryRunResultView({ result, langfuseConfig, knownTags, tagSettings }) {
|
|
|
6706
6877
|
var STATUS_BADGE = {
|
|
6707
6878
|
passed: { label: "OK", variant: "success" },
|
|
6708
6879
|
stopped: { label: "Arr\xEAt", variant: "danger" },
|
|
6709
|
-
// A pre-gate that could not read its field.
|
|
6710
|
-
// (it evaluates no payload) but
|
|
6711
|
-
// than falling through to a blank badge.
|
|
6880
|
+
// A pre-gate that could not read its field. The diagnostic never produces
|
|
6881
|
+
// one (it evaluates no payload), but a run stopped on a pre-gate does —
|
|
6882
|
+
// rendered honestly rather than falling through to a blank badge.
|
|
6712
6883
|
muted: { label: "Muet", variant: "warning" },
|
|
6713
6884
|
skipped: { label: "Non \xE9valu\xE9", variant: "neutral" }
|
|
6714
6885
|
};
|
|
6886
|
+
function GatesTable({ gates }) {
|
|
6887
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "space-y-1", children: gates.map((gate) => {
|
|
6888
|
+
const badge = STATUS_BADGE[gate.status] ?? STATUS_BADGE.skipped;
|
|
6889
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "flex items-start gap-2 text-xs", children: [
|
|
6890
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: badge.variant, children: badge.label }),
|
|
6891
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
6892
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-medium", children: [
|
|
6893
|
+
gate.gate,
|
|
6894
|
+
" \u2014 ",
|
|
6895
|
+
gate.label
|
|
6896
|
+
] }),
|
|
6897
|
+
/* @__PURE__ */ jsxRuntime.jsx("br", {}),
|
|
6898
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: gate.detail })
|
|
6899
|
+
] })
|
|
6900
|
+
] }, gate.gate);
|
|
6901
|
+
}) });
|
|
6902
|
+
}
|
|
6903
|
+
function parseRunResult(result) {
|
|
6904
|
+
if (typeof result !== "object" || result === null) return null;
|
|
6905
|
+
const raw = result;
|
|
6906
|
+
if (!Array.isArray(raw.gates)) return null;
|
|
6907
|
+
return {
|
|
6908
|
+
ticketId: typeof raw.ticketId === "string" ? raw.ticketId : null,
|
|
6909
|
+
stoppedAt: typeof raw.stoppedAt === "string" ? raw.stoppedAt : null,
|
|
6910
|
+
reason: typeof raw.reason === "string" ? raw.reason : null,
|
|
6911
|
+
gates: raw.gates,
|
|
6912
|
+
categoryName: typeof raw.categoryName === "string" ? raw.categoryName : null,
|
|
6913
|
+
outcome: typeof raw.outcome === "string" ? raw.outcome : null,
|
|
6914
|
+
responseId: typeof raw.responseId === "string" ? raw.responseId : null,
|
|
6915
|
+
ticketUrl: typeof raw.ticketUrl === "string" ? raw.ticketUrl : null
|
|
6916
|
+
};
|
|
6917
|
+
}
|
|
6918
|
+
function describeRunDecision(result, mode) {
|
|
6919
|
+
if (result.stoppedAt !== null) return `Arr\xEAt en ${result.stoppedAt}.`;
|
|
6920
|
+
const category = result.categoryName ? ` (cat\xE9gorie \xAB ${result.categoryName} \xBB)` : "";
|
|
6921
|
+
if (result.outcome === "sent") {
|
|
6922
|
+
return mode === "generate" ? `La r\xE9ponse aurait \xE9t\xE9 envoy\xE9e au client${category} \u2014 g\xE9n\xE9r\xE9e sans envoi.` : `La r\xE9ponse a \xE9t\xE9 envoy\xE9e au client${category}.`;
|
|
6923
|
+
}
|
|
6924
|
+
const label = result.outcome !== null && result.outcome in OUTCOME_LABELS ? OUTCOME_LABELS[result.outcome] : null;
|
|
6925
|
+
return label ? `${label}${category}.` : `Traitement termin\xE9${category}.`;
|
|
6926
|
+
}
|
|
6715
6927
|
function FollowupWebhookCard2() {
|
|
6716
6928
|
const api = uiSdk.useAppApi();
|
|
6929
|
+
const { appSlug } = uiSdk.useAppContext();
|
|
6717
6930
|
const toast = uiSdk.useToast();
|
|
6718
6931
|
const ticketId = react.useId();
|
|
6719
6932
|
const [ticket, setTicket] = react.useState("");
|
|
6720
6933
|
const [test, setTest] = react.useState(null);
|
|
6721
6934
|
const [isTesting, setIsTesting] = react.useState(false);
|
|
6722
6935
|
const [confirmingRealRun, setConfirmingRealRun] = react.useState(false);
|
|
6936
|
+
const followedRunId = test !== null && test.mode !== "diagnostic" ? test.runId : null;
|
|
6937
|
+
const { run, isPolling } = uiSdk.useAppRun(followedRunId);
|
|
6938
|
+
const runResult = run && run.status === "succeeded" ? parseRunResult(run.result) : null;
|
|
6939
|
+
const [draftText, setDraftText] = react.useState(null);
|
|
6940
|
+
react.useEffect(() => {
|
|
6941
|
+
setDraftText(null);
|
|
6942
|
+
const responseId = runResult?.responseId;
|
|
6943
|
+
if (!responseId) return;
|
|
6944
|
+
let cancelled = false;
|
|
6945
|
+
void api.get(
|
|
6946
|
+
`/data/apps/${appSlug}/records/generated-response/${encodeURIComponent(responseId)}`
|
|
6947
|
+
).then((record) => {
|
|
6948
|
+
if (!cancelled) setDraftText(record?.data?.responseText ?? null);
|
|
6949
|
+
}).catch(() => {
|
|
6950
|
+
});
|
|
6951
|
+
return () => {
|
|
6952
|
+
cancelled = true;
|
|
6953
|
+
};
|
|
6954
|
+
}, [runResult?.responseId, appSlug]);
|
|
6723
6955
|
async function runTest(mode) {
|
|
6724
6956
|
setIsTesting(true);
|
|
6725
6957
|
setTest(null);
|
|
@@ -6776,20 +7008,35 @@ function FollowupWebhookCard2() {
|
|
|
6776
7008
|
/* @__PURE__ */ jsxRuntime.jsx("code", { children: test.runId }),
|
|
6777
7009
|
"."
|
|
6778
7010
|
] }),
|
|
7011
|
+
test !== null && test.mode !== "diagnostic" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
7012
|
+
isPolling && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [
|
|
7013
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Spinner, {}),
|
|
7014
|
+
" Ex\xE9cution en cours\u2026"
|
|
7015
|
+
] }),
|
|
7016
|
+
run?.status === "failed" && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-destructive", children: [
|
|
7017
|
+
"L'ex\xE9cution a \xE9chou\xE9 : ",
|
|
7018
|
+
run.error?.message ?? "erreur inconnue."
|
|
7019
|
+
] }),
|
|
7020
|
+
runResult && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
7021
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium", children: describeRunDecision(runResult, test.mode) }),
|
|
7022
|
+
runResult.stoppedAt !== null && runResult.reason !== null && !runResult.gates.some((gate) => gate.status === "stopped") && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: runResult.reason }),
|
|
7023
|
+
/* @__PURE__ */ jsxRuntime.jsx(GatesTable, { gates: runResult.gates }),
|
|
7024
|
+
draftText !== null && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
|
|
7025
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs font-medium", children: "Brouillon g\xE9n\xE9r\xE9" }),
|
|
7026
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "whitespace-pre-wrap rounded border bg-muted/30 p-2 text-xs", children: draftText })
|
|
7027
|
+
] }),
|
|
7028
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs", children: [
|
|
7029
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Link, { href: `/espace/${appSlug}/tickets?ticket=${encodeURIComponent(runResult.ticketId ?? test.ticketId)}`, children: "Ouvrir la fiche du ticket" }),
|
|
7030
|
+
runResult.ticketUrl !== null && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
7031
|
+
" \xB7 ",
|
|
7032
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Link, { href: runResult.ticketUrl, target: "_blank", rel: "noopener noreferrer", children: "Ouvrir dans Gorgias" })
|
|
7033
|
+
] })
|
|
7034
|
+
] })
|
|
7035
|
+
] })
|
|
7036
|
+
] }),
|
|
6779
7037
|
test?.mode === "diagnostic" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
6780
7038
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium", children: test.stoppedAt === null ? `Ticket ${test.ticketId} : il aurait re\xE7u une r\xE9ponse de suite.` : `Ticket ${test.ticketId} : arr\xEAt en ${test.stoppedAt}.` }),
|
|
6781
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6782
|
-
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: STATUS_BADGE[gate.status].variant, children: STATUS_BADGE[gate.status].label }),
|
|
6783
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
6784
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-medium", children: [
|
|
6785
|
-
gate.gate,
|
|
6786
|
-
" \u2014 ",
|
|
6787
|
-
gate.label
|
|
6788
|
-
] }),
|
|
6789
|
-
/* @__PURE__ */ jsxRuntime.jsx("br", {}),
|
|
6790
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: gate.detail })
|
|
6791
|
-
] })
|
|
6792
|
-
] }, gate.gate)) })
|
|
7039
|
+
/* @__PURE__ */ jsxRuntime.jsx(GatesTable, { gates: test.gates })
|
|
6793
7040
|
] })
|
|
6794
7041
|
] })
|
|
6795
7042
|
] }),
|