@apotech-os/support-kit 8.1.0 → 8.3.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/README.md +11 -4
- package/dist/{chunk-LXHPPWPM.js → chunk-WVKCRPMV.js} +51 -10
- package/dist/chunk-WVKCRPMV.js.map +1 -0
- package/dist/index.cjs +133 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -1
- package/dist/index.d.ts +31 -1
- package/dist/index.js +75 -34
- package/dist/index.js.map +1 -1
- package/dist/ui/index.cjs +246 -25
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +207 -18
- package/dist/ui/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-LXHPPWPM.js.map +0 -1
package/dist/ui/index.cjs
CHANGED
|
@@ -1197,7 +1197,8 @@ function LangfuseTraceLink({ traceId, observationId, config, label = "Voir la tr
|
|
|
1197
1197
|
if (!traceId) {
|
|
1198
1198
|
return observationId ? /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CopyButton, { value: observationId, label }) : null;
|
|
1199
1199
|
}
|
|
1200
|
-
if (!config
|
|
1200
|
+
if (!config) return null;
|
|
1201
|
+
if (!config.baseUrl || !config.projectId) return /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CopyButton, { value: traceId, label });
|
|
1201
1202
|
const origin = parseHttpOrigin(config.baseUrl);
|
|
1202
1203
|
if (!origin) return null;
|
|
1203
1204
|
const url = buildTraceUrl(origin, config.projectId, traceId, observationId);
|
|
@@ -1280,6 +1281,74 @@ function outcomeLabel(outcome) {
|
|
|
1280
1281
|
return outcome ? OUTCOME_LABELS[outcome] : "\u2014";
|
|
1281
1282
|
}
|
|
1282
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
|
+
|
|
1283
1352
|
// src/status/machine.ts
|
|
1284
1353
|
var GENERATED_RESPONSE_STATUSES = [
|
|
1285
1354
|
"pending",
|
|
@@ -1456,7 +1525,8 @@ function toAuditTags(settings) {
|
|
|
1456
1525
|
escalationTag: settings.escalationTag,
|
|
1457
1526
|
sentTag: settings.autoRepliedTag,
|
|
1458
1527
|
needsHumanTag: settings.needsReviewTag,
|
|
1459
|
-
followupTag: settings.followupTag
|
|
1528
|
+
followupTag: settings.followupTag,
|
|
1529
|
+
appScopeTag: settings.appScopeTag
|
|
1460
1530
|
};
|
|
1461
1531
|
}
|
|
1462
1532
|
var DEFAULT_MIN_CONFIDENCE = 0.8;
|
|
@@ -1869,16 +1939,16 @@ function dedupe(names) {
|
|
|
1869
1939
|
const seen = /* @__PURE__ */ new Set();
|
|
1870
1940
|
const out = [];
|
|
1871
1941
|
for (const name of names) {
|
|
1872
|
-
const
|
|
1873
|
-
if (!
|
|
1874
|
-
seen.add(
|
|
1875
|
-
out.push(
|
|
1942
|
+
const trimmed2 = (name ?? "").trim();
|
|
1943
|
+
if (!trimmed2 || seen.has(trimmed2)) continue;
|
|
1944
|
+
seen.add(trimmed2);
|
|
1945
|
+
out.push(trimmed2);
|
|
1876
1946
|
}
|
|
1877
1947
|
return out;
|
|
1878
1948
|
}
|
|
1879
1949
|
function triageTagNames(input) {
|
|
1880
1950
|
const { decision, category, policy } = input;
|
|
1881
|
-
return [decision.tag, ...category?.extraTags ?? [], policy?.audit.handledTag];
|
|
1951
|
+
return [decision.tag, ...category?.extraTags ?? [], policy?.audit.handledTag, policy?.audit.appScopeTag];
|
|
1882
1952
|
}
|
|
1883
1953
|
function wasSimulated(job, policy) {
|
|
1884
1954
|
if (!job) return false;
|
|
@@ -1903,7 +1973,7 @@ function ticketActions(input) {
|
|
|
1903
1973
|
return { tags, taken, skipped, simulated, unrecorded: job !== void 0 && job.outcome === null };
|
|
1904
1974
|
}
|
|
1905
1975
|
function TimelinePanel(props) {
|
|
1906
|
-
const { decision, job, comparisons, conversation, conversationLoading, categoryName, policy, category, onClose, onInvalidate, isInvalidating } = props;
|
|
1976
|
+
const { decision, job, comparisons, conversation, conversationLoading, categoryName, policy, category, onClose, onInvalidate, isInvalidating, history, onSelectGeneration } = props;
|
|
1907
1977
|
const steps = buildTimeline({ decision, job, comparisons, conversation, conversationLoading, policy, category });
|
|
1908
1978
|
const notSentReason2 = steps.find((step2) => step2.key === "delivery")?.reason ?? null;
|
|
1909
1979
|
const actions = ticketActions({ decision, job, policy, category, notSentReason: notSentReason2 });
|
|
@@ -1913,10 +1983,41 @@ function TimelinePanel(props) {
|
|
|
1913
1983
|
/* @__PURE__ */ jsxRuntime.jsx(TicketLink, { ticketId: decision.ticketId, url: decision.ticketUrl, label: "Ouvrir le ticket dans Gorgias" }),
|
|
1914
1984
|
onInvalidate && canInvalidate && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", size: "sm", onClick: onInvalidate, disabled: isInvalidating, children: isInvalidating ? "Invalidation\u2026" : "Invalider la r\xE9ponse" })
|
|
1915
1985
|
] }),
|
|
1986
|
+
history !== void 0 && history.length > 1 && /* @__PURE__ */ jsxRuntime.jsx(ThreadHistory, { history, selectedDecisionId: decision.id, onSelect: onSelectGeneration }),
|
|
1916
1987
|
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)),
|
|
1917
1988
|
/* @__PURE__ */ jsxRuntime.jsx(ActionsBlock, { actions })
|
|
1918
1989
|
] }) });
|
|
1919
1990
|
}
|
|
1991
|
+
function ThreadHistory({
|
|
1992
|
+
history,
|
|
1993
|
+
selectedDecisionId,
|
|
1994
|
+
onSelect
|
|
1995
|
+
}) {
|
|
1996
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1 border-b pb-3", children: [
|
|
1997
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs font-medium", children: "Historique du fil" }),
|
|
1998
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { className: "space-y-1", children: history.map(({ decision, job }) => {
|
|
1999
|
+
const selected = decision.id === selectedDecisionId;
|
|
2000
|
+
const origin = generationOrigin(decision, job);
|
|
2001
|
+
const outcome = responseOutcome(job);
|
|
2002
|
+
return /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2003
|
+
"button",
|
|
2004
|
+
{
|
|
2005
|
+
type: "button",
|
|
2006
|
+
onClick: onSelect ? () => onSelect(decision) : void 0,
|
|
2007
|
+
"aria-current": selected || void 0,
|
|
2008
|
+
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"}`,
|
|
2009
|
+
children: [
|
|
2010
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-2", children: [
|
|
2011
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: formatDate(decision.decidedAt) }),
|
|
2012
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: origin.label })
|
|
2013
|
+
] }),
|
|
2014
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: outcome.variant, children: outcome.label })
|
|
2015
|
+
]
|
|
2016
|
+
}
|
|
2017
|
+
) }, decision.id);
|
|
2018
|
+
}) })
|
|
2019
|
+
] });
|
|
2020
|
+
}
|
|
1920
2021
|
function StepBlock({
|
|
1921
2022
|
step: step2,
|
|
1922
2023
|
index,
|
|
@@ -2157,6 +2258,16 @@ var CORRECTED_OPTIONS = [
|
|
|
2157
2258
|
{ value: "true", label: "Corrig\xE9s par un humain" },
|
|
2158
2259
|
{ value: "false", label: "Non corrig\xE9s" }
|
|
2159
2260
|
];
|
|
2261
|
+
var ORIGIN_FILTER_OPTIONS = [
|
|
2262
|
+
{ value: "", label: "Toutes origines" },
|
|
2263
|
+
{ value: "first", label: "1res r\xE9ponses" },
|
|
2264
|
+
{ value: "followup", label: "Messages suivants" },
|
|
2265
|
+
{ value: "test", label: "Brouillons d'essai" }
|
|
2266
|
+
];
|
|
2267
|
+
var VIEW_MODE_OPTIONS = [
|
|
2268
|
+
{ value: "byTicket", label: "Une ligne par ticket" },
|
|
2269
|
+
{ value: "all", label: "Toutes les g\xE9n\xE9rations" }
|
|
2270
|
+
];
|
|
2160
2271
|
function OutcomeBadge({ outcome }) {
|
|
2161
2272
|
return /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: OUTCOME_BADGE_VARIANT[outcome.variant], children: outcome.label });
|
|
2162
2273
|
}
|
|
@@ -2175,19 +2286,36 @@ function TicketsPage() {
|
|
|
2175
2286
|
const [verdictFilter, setVerdictFilter] = react.useState("");
|
|
2176
2287
|
const [promptVersionFilter, setPromptVersionFilter] = react.useState("");
|
|
2177
2288
|
const [correctedFilter, setCorrectedFilter] = react.useState("");
|
|
2289
|
+
const [originFilter, setOriginFilter] = react.useState("");
|
|
2290
|
+
const [viewMode, setViewMode] = react.useState("byTicket");
|
|
2178
2291
|
const [detailDecision, setDetailDecision] = react.useState(null);
|
|
2179
2292
|
const [isTriaging, setIsTriaging] = react.useState(false);
|
|
2180
2293
|
const [isInvalidating, setIsInvalidating] = react.useState(false);
|
|
2294
|
+
const requestedTicket = useQueryParam("ticket").value;
|
|
2295
|
+
const [ticketSearch, setTicketSearch] = react.useState(() => requestedTicket?.trim() ?? "");
|
|
2296
|
+
const searchDebounce = react.useRef(null);
|
|
2297
|
+
const onTableStateChange = react.useCallback((tableState) => {
|
|
2298
|
+
if (searchDebounce.current) clearTimeout(searchDebounce.current);
|
|
2299
|
+
searchDebounce.current = setTimeout(() => setTicketSearch(tableState.search.trim()), 300);
|
|
2300
|
+
}, []);
|
|
2301
|
+
react.useEffect(
|
|
2302
|
+
() => () => {
|
|
2303
|
+
if (searchDebounce.current) clearTimeout(searchDebounce.current);
|
|
2304
|
+
},
|
|
2305
|
+
[]
|
|
2306
|
+
);
|
|
2307
|
+
const history = useTicketHistory(detailDecision?.ticketId ?? null);
|
|
2181
2308
|
const [triageInFlight] = react.useState(() => ({ current: false }));
|
|
2182
2309
|
const periodKey = JSON.stringify(period);
|
|
2183
2310
|
const bounds = react.useMemo(() => periodBoundsOf(JSON.parse(periodKey)).current, [periodKey]);
|
|
2184
2311
|
const decisionFilter = react.useMemo(() => {
|
|
2312
|
+
if (ticketSearch) return { ticketId: { eq: ticketSearch } };
|
|
2185
2313
|
const filter = { decidedAt: { gte: bounds.fromIso, lte: bounds.toIso } };
|
|
2186
2314
|
if (categoryFilter) filter.categoryId = { eq: categoryFilter };
|
|
2187
2315
|
if (escalatedFilter) filter.escalated = { eq: escalatedFilter === "true" };
|
|
2188
2316
|
if (confidenceFilter) filter.confidence = { eq: confidenceFilter };
|
|
2189
2317
|
return filter;
|
|
2190
|
-
}, [bounds.fromIso, bounds.toIso, categoryFilter, escalatedFilter, confidenceFilter]);
|
|
2318
|
+
}, [ticketSearch, bounds.fromIso, bounds.toIso, categoryFilter, escalatedFilter, confidenceFilter]);
|
|
2191
2319
|
const {
|
|
2192
2320
|
rows: decisions,
|
|
2193
2321
|
isLoading: decisionsLoading,
|
|
@@ -2240,7 +2368,7 @@ function TicketsPage() {
|
|
|
2240
2368
|
const agentNames = react.useMemo(() => toNameMap(agents), [agents]);
|
|
2241
2369
|
const { config: langfuseConfig } = useLangfuseConfig();
|
|
2242
2370
|
function refreshAll() {
|
|
2243
|
-
return Promise.all([refreshDecisions(), refreshJobs(), refreshComparisons()]).then(() => void 0);
|
|
2371
|
+
return Promise.all([refreshDecisions(), refreshJobs(), refreshComparisons(), history.refresh()]).then(() => void 0);
|
|
2244
2372
|
}
|
|
2245
2373
|
const jobByDecisionId = react.useMemo(() => {
|
|
2246
2374
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -2287,10 +2415,20 @@ function TicketsPage() {
|
|
|
2287
2415
|
if (promptVersionFilter && String(row.job?.promptVersion ?? "") !== promptVersionFilter) return false;
|
|
2288
2416
|
if (correctedFilter === "true" && row.comparisons.length === 0) return false;
|
|
2289
2417
|
if (correctedFilter === "false" && row.comparisons.length > 0) return false;
|
|
2418
|
+
if (originFilter && generationOrigin(row.decision, row.job).kind !== originFilter) return false;
|
|
2290
2419
|
return true;
|
|
2291
2420
|
});
|
|
2292
|
-
}, [decisions, jobByDecisionId, comparisonsByTicketId, outcomeFilter, verdictFilter, promptVersionFilter, correctedFilter]);
|
|
2293
|
-
const
|
|
2421
|
+
}, [decisions, jobByDecisionId, comparisonsByTicketId, outcomeFilter, verdictFilter, promptVersionFilter, correctedFilter, originFilter]);
|
|
2422
|
+
const listRows = react.useMemo(() => {
|
|
2423
|
+
if (viewMode === "all") return rows.map((row) => ({ ...row, turnCount: 1 }));
|
|
2424
|
+
const byTicket = /* @__PURE__ */ new Map();
|
|
2425
|
+
for (const row of rows) {
|
|
2426
|
+
const seen = byTicket.get(row.decision.ticketId);
|
|
2427
|
+
if (seen) seen.turnCount += 1;
|
|
2428
|
+
else byTicket.set(row.decision.ticketId, { ...row, turnCount: 1 });
|
|
2429
|
+
}
|
|
2430
|
+
return [...byTicket.values()];
|
|
2431
|
+
}, [rows, viewMode]);
|
|
2294
2432
|
const deepLinkConsumed = react.useRef(false);
|
|
2295
2433
|
react.useEffect(() => {
|
|
2296
2434
|
if (deepLinkConsumed.current || !requestedTicket) return;
|
|
@@ -2338,6 +2476,25 @@ function TicketsPage() {
|
|
|
2338
2476
|
}
|
|
2339
2477
|
const columns = [
|
|
2340
2478
|
{ key: "ticketId", header: "Ticket", cell: ({ decision }) => /* @__PURE__ */ jsxRuntime.jsx(TicketLink, { ticketId: decision.ticketId, url: decision.ticketUrl }) },
|
|
2479
|
+
{
|
|
2480
|
+
key: "turns",
|
|
2481
|
+
header: "Tours",
|
|
2482
|
+
// Only a multi-turn ticket is worth marking: badging every row would
|
|
2483
|
+
// make the multi-turn ones invisible by saturation.
|
|
2484
|
+
cell: ({ turnCount }) => turnCount > 1 ? /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Badge, { variant: "neutral", children: [
|
|
2485
|
+
turnCount,
|
|
2486
|
+
" tours"
|
|
2487
|
+
] }) : null
|
|
2488
|
+
},
|
|
2489
|
+
{
|
|
2490
|
+
key: "origin",
|
|
2491
|
+
header: "Origine",
|
|
2492
|
+
cell: ({ decision, job }) => {
|
|
2493
|
+
const origin = generationOrigin(decision, job);
|
|
2494
|
+
if (origin.kind === "first") return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: origin.label });
|
|
2495
|
+
return /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: origin.kind === "test" ? "warning" : "info", children: origin.label });
|
|
2496
|
+
}
|
|
2497
|
+
},
|
|
2341
2498
|
{ key: "category", header: "Cat\xE9gorie", cell: ({ decision }) => decision.categoryId && categoryNames.get(decision.categoryId) || "\u2014" },
|
|
2342
2499
|
{ key: "tag", header: "Tag", cell: ({ decision }) => decision.tag ? /* @__PURE__ */ jsxRuntime.jsx("code", { className: "text-xs", children: decision.tag }) : "\u2014" },
|
|
2343
2500
|
{
|
|
@@ -2394,7 +2551,12 @@ function TicketsPage() {
|
|
|
2394
2551
|
},
|
|
2395
2552
|
{ key: "decidedAt", header: "D\xE9cid\xE9 le", cell: ({ decision }) => formatDate(decision.decidedAt) }
|
|
2396
2553
|
];
|
|
2397
|
-
const
|
|
2554
|
+
const historyEntry = detailDecision ? history.entries.find((entry) => entry.decision.id === detailDecision.id) : void 0;
|
|
2555
|
+
const pageRow = detailDecision ? rows.find((row) => row.decision.id === detailDecision.id) : void 0;
|
|
2556
|
+
const detailRow = detailDecision ? {
|
|
2557
|
+
job: historyEntry?.job ?? pageRow?.job,
|
|
2558
|
+
comparisons: comparisonsByTicketId.get(detailDecision.ticketId) ?? []
|
|
2559
|
+
} : void 0;
|
|
2398
2560
|
const liveConversation = useLiveConversation(detailDecision, detailRow);
|
|
2399
2561
|
const isLoading = decisionsLoading || jobsLoading;
|
|
2400
2562
|
const combinedError = decisionsError ?? jobsError ?? comparisonsError;
|
|
@@ -2428,10 +2590,21 @@ function TicketsPage() {
|
|
|
2428
2590
|
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Select, { items: VERDICT_OPTIONS, value: verdictFilter, onValueChange: setVerdictFilter, placeholder: "Tous les verdicts", "aria-label": "Filtrer par verdict" }),
|
|
2429
2591
|
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Select, { items: promptVersionOptions, value: promptVersionFilter, onValueChange: setPromptVersionFilter, placeholder: "Toutes versions de prompt", "aria-label": "Filtrer par version de prompt" }),
|
|
2430
2592
|
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Select, { items: CORRECTED_OPTIONS, value: correctedFilter, onValueChange: setCorrectedFilter, placeholder: "Corrig\xE9s ou non", "aria-label": "Filtrer par correction humaine" }),
|
|
2431
|
-
|
|
2432
|
-
|
|
2593
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Select, { items: ORIGIN_FILTER_OPTIONS, value: originFilter, onValueChange: setOriginFilter, placeholder: "Toutes origines", "aria-label": "Filtrer par origine" }),
|
|
2594
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2595
|
+
uiSdk.Select,
|
|
2596
|
+
{
|
|
2597
|
+
items: VIEW_MODE_OPTIONS,
|
|
2598
|
+
value: viewMode,
|
|
2599
|
+
onValueChange: (value) => setViewMode(value === "all" ? "all" : "byTicket"),
|
|
2600
|
+
placeholder: "Une ligne par ticket",
|
|
2601
|
+
"aria-label": "Filtrer par mode d'affichage"
|
|
2602
|
+
}
|
|
2603
|
+
),
|
|
2604
|
+
listRows.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ml-auto text-sm text-muted-foreground", children: [
|
|
2605
|
+
listRows.length,
|
|
2433
2606
|
" ticket",
|
|
2434
|
-
|
|
2607
|
+
listRows.length > 1 ? "s" : "",
|
|
2435
2608
|
" sur cette page"
|
|
2436
2609
|
] })
|
|
2437
2610
|
] }),
|
|
@@ -2439,9 +2612,12 @@ function TicketsPage() {
|
|
|
2439
2612
|
uiSdk.DataTable,
|
|
2440
2613
|
{
|
|
2441
2614
|
columns,
|
|
2442
|
-
rows,
|
|
2615
|
+
rows: listRows,
|
|
2443
2616
|
rowId: (row) => row.decision.id,
|
|
2444
2617
|
manual: true,
|
|
2618
|
+
defaultState: { search: requestedTicket?.trim() ?? "" },
|
|
2619
|
+
onStateChange: onTableStateChange,
|
|
2620
|
+
searchPlaceholder: "ID de ticket\u2026",
|
|
2445
2621
|
loading: isLoading,
|
|
2446
2622
|
onRowClick: (row) => setDetailDecision(row.decision),
|
|
2447
2623
|
pagination: {
|
|
@@ -2474,6 +2650,8 @@ function TicketsPage() {
|
|
|
2474
2650
|
category: categories.find((entry) => entry.id === detailDecision.categoryId) ?? null,
|
|
2475
2651
|
agentName: detailRow?.job?.agentId && agentNames.get(detailRow.job.agentId) || "\u2014",
|
|
2476
2652
|
langfuseConfig,
|
|
2653
|
+
history: history.entries,
|
|
2654
|
+
onSelectGeneration: (selected) => setDetailDecision(selected),
|
|
2477
2655
|
onClose: () => setDetailDecision(null),
|
|
2478
2656
|
onInvalidate: canWrite && detailRow?.job ? () => void invalidateResponse(detailRow.job.id) : void 0,
|
|
2479
2657
|
isInvalidating
|
|
@@ -4154,6 +4332,37 @@ function isConfiguredNode(nodes) {
|
|
|
4154
4332
|
const triage = nodes.triage;
|
|
4155
4333
|
return typeof triage === "object" && triage !== null;
|
|
4156
4334
|
}
|
|
4335
|
+
|
|
4336
|
+
// src/settings/warnings.ts
|
|
4337
|
+
var HUMAN_TAKEOVER_KEYS = ["escalationTag", "needsReviewTag", "followupTag"];
|
|
4338
|
+
var AUDIT_TAG_KEYS = ["unknownTag", "handledTag", "escalationTag", "autoRepliedTag", "needsReviewTag", "followupTag"];
|
|
4339
|
+
function settingsWarnings(settings) {
|
|
4340
|
+
const warnings = [];
|
|
4341
|
+
const appScopeTag = trimmed(settings.appScopeTag);
|
|
4342
|
+
const webhookScopeTag = trimmed(settings.webhookScopeTag);
|
|
4343
|
+
const collidesWith = (keys) => appScopeTag ? keys.filter((key) => trimmed(settings[key]) === appScopeTag) : [];
|
|
4344
|
+
if (collidesWith(HUMAN_TAKEOVER_KEYS).length > 0) {
|
|
4345
|
+
warnings.push({
|
|
4346
|
+
key: "appScopeTagVetoesFollowups",
|
|
4347
|
+
message: "Le tag d\u2019appartenance est l\u2019un des tags de reprise humaine (escalade, relecture, suivi) : le webhook de suivi consid\xE9rera que chaque ticket tri\xE9 a \xE9t\xE9 repris par un humain et ne r\xE9pondra plus \xE0 aucun message suivant."
|
|
4348
|
+
});
|
|
4349
|
+
} else if (collidesWith(AUDIT_TAG_KEYS).length > 0) {
|
|
4350
|
+
warnings.push({
|
|
4351
|
+
key: "appScopeTagCollision",
|
|
4352
|
+
message: "Le tag d\u2019appartenance est l\u2019un des autres tags d\u2019audit, que toutes les apps posent avec la m\xEAme valeur par d\xE9faut : il ne distingue donc pas cette app d\u2019une autre install\xE9e sur le m\xEAme compte Gorgias."
|
|
4353
|
+
});
|
|
4354
|
+
}
|
|
4355
|
+
if (appScopeTag && webhookScopeTag && appScopeTag !== webhookScopeTag) {
|
|
4356
|
+
warnings.push({
|
|
4357
|
+
key: "scopeTagMismatch",
|
|
4358
|
+
message: "Le tag de p\xE9rim\xE8tre du webhook de suivi n\u2019est pas celui que cette app pose sur ses tickets : le webhook ne r\xE9pondra sur aucun ticket tri\xE9 ici."
|
|
4359
|
+
});
|
|
4360
|
+
}
|
|
4361
|
+
return warnings;
|
|
4362
|
+
}
|
|
4363
|
+
function trimmed(value) {
|
|
4364
|
+
return typeof value === "string" ? value.trim() : "";
|
|
4365
|
+
}
|
|
4157
4366
|
function NumberField({ id, label, value, onChange, disabled, min, max, integer, hint }) {
|
|
4158
4367
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4159
4368
|
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: id, className: "mb-1 block text-sm font-medium", children: label }),
|
|
@@ -4817,6 +5026,7 @@ function SettingsPage() {
|
|
|
4817
5026
|
const claimedView = views.find((v) => v.id === sourceViewId);
|
|
4818
5027
|
const claimUnverifiable = installedAppsUnavailable || uncheckedAppSlugs.length > 0;
|
|
4819
5028
|
const issues = validateSettings(form);
|
|
5029
|
+
const warnings = settingsWarnings(form);
|
|
4820
5030
|
const nodesIssue = issues.find((issue) => issue.key === "nodes");
|
|
4821
5031
|
const summaryIssues = issues.filter((issue) => issue !== nodesIssue);
|
|
4822
5032
|
const guardrailsActive = Array.isArray(form.guardrailsActive) ? form.guardrailsActive : [];
|
|
@@ -4991,11 +5201,14 @@ function SettingsPage() {
|
|
|
4991
5201
|
["escalationTag", "Tag d'escalade"],
|
|
4992
5202
|
["autoRepliedTag", "Tag r\xE9pondu automatiquement"],
|
|
4993
5203
|
["needsReviewTag", "Tag \xE0 revoir avant envoi"],
|
|
4994
|
-
["followupTag", "Tag suivi requis"]
|
|
5204
|
+
["followupTag", "Tag suivi requis"],
|
|
5205
|
+
["appScopeTag", "Tag d'appartenance"]
|
|
4995
5206
|
].map(([key, label]) => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
4996
5207
|
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: key, className: "mb-1 block text-sm font-medium", children: label }),
|
|
4997
5208
|
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Input, { id: key, value: field(form[key]), onChange: (e) => set(key, e.target.value), disabled: !canWrite })
|
|
4998
|
-
] }, key))
|
|
5209
|
+
] }, key)),
|
|
5210
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: "Le tag d\u2019appartenance est pos\xE9 sur chaque ticket que le triage examine, dans le m\xEAme appel que les tags ci-dessus. Il doit \xEAtre propre \xE0 cette app : c\u2019est lui qui distingue ses tickets de ceux d\u2019une autre app install\xE9e sur le m\xEAme compte Gorgias." }),
|
|
5211
|
+
warnings.map((warning) => /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-status-pending", children: warning.message }, warning.key))
|
|
4999
5212
|
] }) }),
|
|
5000
5213
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5001
5214
|
FollowupWebhookCard,
|
|
@@ -6535,6 +6748,7 @@ function tagOrigin(tag, settings) {
|
|
|
6535
6748
|
if (tag === str(settings.followupTag)) return "tag de suivi";
|
|
6536
6749
|
if (tag === str(settings.escalationTag)) return "tag d'escalade";
|
|
6537
6750
|
if (tag === str(settings.handledTag)) return "tag de traitement";
|
|
6751
|
+
if (tag === str(settings.appScopeTag)) return "tag d'appartenance";
|
|
6538
6752
|
if (tag === str(settings.unknownTag)) return "classification de repli";
|
|
6539
6753
|
return "classification";
|
|
6540
6754
|
}
|
|
@@ -6769,7 +6983,8 @@ function parseRunResult(result) {
|
|
|
6769
6983
|
gates: raw.gates,
|
|
6770
6984
|
categoryName: typeof raw.categoryName === "string" ? raw.categoryName : null,
|
|
6771
6985
|
outcome: typeof raw.outcome === "string" ? raw.outcome : null,
|
|
6772
|
-
responseId: typeof raw.responseId === "string" ? raw.responseId : null
|
|
6986
|
+
responseId: typeof raw.responseId === "string" ? raw.responseId : null,
|
|
6987
|
+
ticketUrl: typeof raw.ticketUrl === "string" ? raw.ticketUrl : null
|
|
6773
6988
|
};
|
|
6774
6989
|
}
|
|
6775
6990
|
function describeRunDecision(result, mode) {
|
|
@@ -6882,7 +7097,13 @@ function FollowupWebhookCard2() {
|
|
|
6882
7097
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs font-medium", children: "Brouillon g\xE9n\xE9r\xE9" }),
|
|
6883
7098
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "whitespace-pre-wrap rounded border bg-muted/30 p-2 text-xs", children: draftText })
|
|
6884
7099
|
] }),
|
|
6885
|
-
/* @__PURE__ */ jsxRuntime.
|
|
7100
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs", children: [
|
|
7101
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Link, { href: `/espace/${appSlug}/tickets?ticket=${encodeURIComponent(runResult.ticketId ?? test.ticketId)}`, children: "Ouvrir la fiche du ticket" }),
|
|
7102
|
+
runResult.ticketUrl !== null && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
7103
|
+
" \xB7 ",
|
|
7104
|
+
/* @__PURE__ */ jsxRuntime.jsx(uiSdk.Link, { href: runResult.ticketUrl, target: "_blank", rel: "noopener noreferrer", children: "Ouvrir dans Gorgias" })
|
|
7105
|
+
] })
|
|
7106
|
+
] })
|
|
6886
7107
|
] })
|
|
6887
7108
|
] }),
|
|
6888
7109
|
test?.mode === "diagnostic" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
@@ -7252,14 +7473,14 @@ function useExperiments(datasetName) {
|
|
|
7252
7473
|
const api = uiSdk.useAppApi();
|
|
7253
7474
|
const apiRef = react.useRef(api);
|
|
7254
7475
|
apiRef.current = api;
|
|
7255
|
-
const
|
|
7476
|
+
const trimmed2 = datasetName.trim();
|
|
7256
7477
|
const load = react.useCallback(async () => {
|
|
7257
|
-
if (
|
|
7258
|
-
const params = new URLSearchParams({ datasetName:
|
|
7478
|
+
if (trimmed2.length === 0) return [];
|
|
7479
|
+
const params = new URLSearchParams({ datasetName: trimmed2 });
|
|
7259
7480
|
return apiRef.current.get(
|
|
7260
7481
|
`/data/apps/${appSlug}/quality/experiments?${params.toString()}`
|
|
7261
7482
|
);
|
|
7262
|
-
}, [appSlug,
|
|
7483
|
+
}, [appSlug, trimmed2]);
|
|
7263
7484
|
return useAsyncData(load, []);
|
|
7264
7485
|
}
|
|
7265
7486
|
function useReview(reviewId) {
|