@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.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EVALUATION_VERDICTS, WHATSAPP_MODES, validateSettings, AGENT_GUARDRAILS, toCategory, DEFAULT_MIN_CONFIDENCE, DEFAULT_ESCALATION_ENABLED, toAuditTags,
|
|
2
|
-
import { forwardRef, useState, useMemo,
|
|
3
|
-
import { Textarea, cn, useAppContext, useAppSettings, DateRangeCompare, Link, Card, CardHeader, CardTitle, CardContent, AreaChart, StackedBarChart, Badge, useAppApi, useToast, Button, Select, DataTable, Spinner, Switch, Input, Checkbox, comparisonRange, SidePanel, Modal, Tooltip, buttonVariants, AppInvokeError, CopyButton, relativeDelta, Table, TableHeader, TableRow, TableHead, TableBody, TableCell, downloadBlob } from '@apotech-os/ui-sdk';
|
|
1
|
+
import { EVALUATION_VERDICTS, WHATSAPP_MODES, validateSettings, AGENT_GUARDRAILS, toCategory, DEFAULT_MIN_CONFIDENCE, DEFAULT_ESCALATION_ENABLED, toAuditTags, toGeneratedResponse, toTriageDecision, toAgent, toResponseComparison, isGeneratedResponseStatus, isInvalidatableStatus, toCategoryGroup, followupIntegrationName, FOLLOWUP_WEBHOOK_TRIGGER, followupWebhookPath, FOLLOWUP_WEBHOOK_FORM, NODE_NAMES, settingsToProfile, hasNoDraftNode, outcomeTags, DEFAULT_LLM_PROVIDER, computeWordDiff, requiresFollowup, isSendableVerdict, DEFAULT_MAX_TOOL_CALLS } from '../chunk-LXHPPWPM.js';
|
|
2
|
+
import { forwardRef, useState, useMemo, useRef, useCallback, useEffect, useId } from 'react';
|
|
3
|
+
import { Textarea, cn, useAppContext, useAppSettings, DateRangeCompare, Link, Card, CardHeader, CardTitle, CardContent, AreaChart, StackedBarChart, Badge, useAppApi, useToast, Button, Select, DataTable, Spinner, Switch, Input, Checkbox, comparisonRange, SidePanel, Modal, Tooltip, buttonVariants, useAppRun, AppInvokeError, CopyButton, relativeDelta, 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) {
|
|
@@ -156,6 +156,7 @@ var EMPTY_TOTALS = {
|
|
|
156
156
|
failed: 0
|
|
157
157
|
};
|
|
158
158
|
function outcomeOf(status, autoSendDecision) {
|
|
159
|
+
if (status === "test_draft") return null;
|
|
159
160
|
if (status === "sent") return "auto";
|
|
160
161
|
if (status === "no_reply_needed") return "noReplyNeeded";
|
|
161
162
|
if (status === "failed") return "failed";
|
|
@@ -165,7 +166,8 @@ function outcomeOf(status, autoSendDecision) {
|
|
|
165
166
|
function foldOutcomes(rows) {
|
|
166
167
|
const totals = { ...EMPTY_TOTALS };
|
|
167
168
|
for (const row of rows) {
|
|
168
|
-
|
|
169
|
+
const outcome = outcomeOf(row["status"], row["autoSendDecision"]);
|
|
170
|
+
if (outcome !== null) totals[outcome] += Number(row["count"]) || 0;
|
|
169
171
|
}
|
|
170
172
|
return totals;
|
|
171
173
|
}
|
|
@@ -179,9 +181,11 @@ function autonomyRate(totals) {
|
|
|
179
181
|
function foldDailyOutcomes(rows) {
|
|
180
182
|
const byDay = /* @__PURE__ */ new Map();
|
|
181
183
|
for (const row of rows) {
|
|
184
|
+
const outcome = outcomeOf(row["status"], row["autoSendDecision"]);
|
|
185
|
+
if (outcome === null) continue;
|
|
182
186
|
const day = bucketDay(row);
|
|
183
187
|
const totals = byDay.get(day) ?? { ...EMPTY_TOTALS };
|
|
184
|
-
totals[
|
|
188
|
+
totals[outcome] += Number(row["count"]) || 0;
|
|
185
189
|
byDay.set(day, totals);
|
|
186
190
|
}
|
|
187
191
|
return [...byDay.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([day, totals]) => ({
|
|
@@ -934,6 +938,31 @@ function TicketLink({ ticketId, url, label }) {
|
|
|
934
938
|
}
|
|
935
939
|
);
|
|
936
940
|
}
|
|
941
|
+
function readParam(name) {
|
|
942
|
+
if (typeof window === "undefined") return null;
|
|
943
|
+
return new URLSearchParams(window.location.search).get(name);
|
|
944
|
+
}
|
|
945
|
+
function useQueryParam(name) {
|
|
946
|
+
const [value, setState] = useState(() => readParam(name));
|
|
947
|
+
useEffect(() => {
|
|
948
|
+
const sync = () => setState(readParam(name));
|
|
949
|
+
sync();
|
|
950
|
+
window.addEventListener("popstate", sync);
|
|
951
|
+
return () => window.removeEventListener("popstate", sync);
|
|
952
|
+
}, [name]);
|
|
953
|
+
const setValue = useCallback(
|
|
954
|
+
(next) => {
|
|
955
|
+
const params = new URLSearchParams(window.location.search);
|
|
956
|
+
if (next === null) params.delete(name);
|
|
957
|
+
else params.set(name, next);
|
|
958
|
+
const query = params.toString();
|
|
959
|
+
window.history.pushState({}, "", `${window.location.pathname}${query ? `?${query}` : ""}`);
|
|
960
|
+
setState(next);
|
|
961
|
+
},
|
|
962
|
+
[name]
|
|
963
|
+
);
|
|
964
|
+
return { value, setValue };
|
|
965
|
+
}
|
|
937
966
|
var UNCONFIGURED = { baseUrl: null, projectId: null };
|
|
938
967
|
function useLangfuseConfig() {
|
|
939
968
|
const { appSlug } = useAppContext();
|
|
@@ -984,7 +1013,8 @@ function LangfuseTraceLink({ traceId, observationId, config, label = "Voir la tr
|
|
|
984
1013
|
if (!traceId) {
|
|
985
1014
|
return observationId ? /* @__PURE__ */ jsx(CopyButton, { value: observationId, label }) : null;
|
|
986
1015
|
}
|
|
987
|
-
if (!config
|
|
1016
|
+
if (!config) return null;
|
|
1017
|
+
if (!config.baseUrl || !config.projectId) return /* @__PURE__ */ jsx(CopyButton, { value: traceId, label });
|
|
988
1018
|
const origin = parseHttpOrigin(config.baseUrl);
|
|
989
1019
|
if (!origin) return null;
|
|
990
1020
|
const url = buildTraceUrl(origin, config.projectId, traceId, observationId);
|
|
@@ -1011,7 +1041,8 @@ var GENERATED_RESPONSE_STATUS_LABELS = {
|
|
|
1011
1041
|
failed: "\xC9chec",
|
|
1012
1042
|
no_reply_needed: "Aucune r\xE9ponse n\xE9cessaire",
|
|
1013
1043
|
invalidated: "Invalid\xE9e",
|
|
1014
|
-
expired: "Expir\xE9e"
|
|
1044
|
+
expired: "Expir\xE9e",
|
|
1045
|
+
test_draft: "Brouillon d'essai \u2014 jamais envoy\xE9"
|
|
1015
1046
|
};
|
|
1016
1047
|
var AUTO_SEND_DECISION_LABELS = {
|
|
1017
1048
|
auto: "Autoris\xE9",
|
|
@@ -1066,6 +1097,74 @@ function outcomeLabel(outcome) {
|
|
|
1066
1097
|
return outcome ? OUTCOME_LABELS[outcome] : "\u2014";
|
|
1067
1098
|
}
|
|
1068
1099
|
|
|
1100
|
+
// src/ui/tickets/generation-origin.ts
|
|
1101
|
+
var ORIGINS = {
|
|
1102
|
+
first: { kind: "first", label: "1re r\xE9ponse" },
|
|
1103
|
+
followup: { kind: "followup", label: "Message suivant" },
|
|
1104
|
+
test: { kind: "test", label: "Brouillon d'essai" }
|
|
1105
|
+
};
|
|
1106
|
+
function generationOrigin(decision, job) {
|
|
1107
|
+
if (job?.status === "test_draft") return ORIGINS.test;
|
|
1108
|
+
return decision.origin === "followup" ? ORIGINS.followup : ORIGINS.first;
|
|
1109
|
+
}
|
|
1110
|
+
var HISTORY_LIMIT = 100;
|
|
1111
|
+
function useTicketHistory(ticketId) {
|
|
1112
|
+
const { appSlug } = useAppContext();
|
|
1113
|
+
const api = useAppApi();
|
|
1114
|
+
const [entries, setEntries] = useState([]);
|
|
1115
|
+
const clientRef = useRef(api);
|
|
1116
|
+
clientRef.current = api;
|
|
1117
|
+
const requestIdRef = useRef(0);
|
|
1118
|
+
const loadedTicketIdRef = useRef(null);
|
|
1119
|
+
const load = useCallback(async () => {
|
|
1120
|
+
const requestId = ++requestIdRef.current;
|
|
1121
|
+
if (ticketId === null) {
|
|
1122
|
+
loadedTicketIdRef.current = null;
|
|
1123
|
+
setEntries([]);
|
|
1124
|
+
return;
|
|
1125
|
+
}
|
|
1126
|
+
if (loadedTicketIdRef.current !== ticketId) {
|
|
1127
|
+
loadedTicketIdRef.current = null;
|
|
1128
|
+
setEntries([]);
|
|
1129
|
+
}
|
|
1130
|
+
const byTicket = (sortField) => ({
|
|
1131
|
+
filter: JSON.stringify({ ticketId: { eq: ticketId } }),
|
|
1132
|
+
sort: JSON.stringify([{ field: sortField, direction: "asc" }]),
|
|
1133
|
+
limit: String(HISTORY_LIMIT)
|
|
1134
|
+
});
|
|
1135
|
+
try {
|
|
1136
|
+
const [decisionsPage, jobsPage] = await Promise.all([
|
|
1137
|
+
clientRef.current.get(`/data/apps/${appSlug}/records/triage-decision`, byTicket("decidedAt")),
|
|
1138
|
+
// No sort: these land in a Map keyed by the unique `triageDecisionId`,
|
|
1139
|
+
// so their order is irrelevant (and `generatedAt` is nullable anyway).
|
|
1140
|
+
clientRef.current.get(`/data/apps/${appSlug}/records/generated-response`, {
|
|
1141
|
+
filter: JSON.stringify({ ticketId: { eq: ticketId } }),
|
|
1142
|
+
limit: String(HISTORY_LIMIT)
|
|
1143
|
+
})
|
|
1144
|
+
]);
|
|
1145
|
+
if (requestId !== requestIdRef.current) return;
|
|
1146
|
+
const jobByDecisionId = /* @__PURE__ */ new Map();
|
|
1147
|
+
for (const record of jobsPage.items) {
|
|
1148
|
+
const job = toGeneratedResponse(record);
|
|
1149
|
+
if (job.triageDecisionId) jobByDecisionId.set(job.triageDecisionId, job);
|
|
1150
|
+
}
|
|
1151
|
+
loadedTicketIdRef.current = ticketId;
|
|
1152
|
+
setEntries(
|
|
1153
|
+
decisionsPage.items.map((record) => toTriageDecision(record)).map((decision) => ({ decision, job: jobByDecisionId.get(decision.id) }))
|
|
1154
|
+
);
|
|
1155
|
+
} catch {
|
|
1156
|
+
if (requestId === requestIdRef.current) setEntries([]);
|
|
1157
|
+
}
|
|
1158
|
+
}, [ticketId, appSlug]);
|
|
1159
|
+
useEffect(() => {
|
|
1160
|
+
void load();
|
|
1161
|
+
return () => {
|
|
1162
|
+
requestIdRef.current += 1;
|
|
1163
|
+
};
|
|
1164
|
+
}, [load]);
|
|
1165
|
+
return { entries, refresh: load };
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1069
1168
|
// src/ui/tickets/ticket-outcome.ts
|
|
1070
1169
|
var NO_JOB = { label: "Aucune r\xE9ponse g\xE9n\xE9r\xE9e", variant: "neutral" };
|
|
1071
1170
|
function responseOutcome(job) {
|
|
@@ -1241,6 +1340,8 @@ function deliveryReason(input) {
|
|
|
1241
1340
|
}
|
|
1242
1341
|
case "failed":
|
|
1243
1342
|
return job.error ?? "La r\xE9ponse a \xE9chou\xE9 avant son envoi.";
|
|
1343
|
+
case "test_draft":
|
|
1344
|
+
return "Brouillon d'essai \u2014 jamais envoy\xE9.";
|
|
1244
1345
|
default:
|
|
1245
1346
|
return `La r\xE9ponse n'a pas \xE9t\xE9 envoy\xE9e (statut : ${job.status}).`;
|
|
1246
1347
|
}
|
|
@@ -1366,7 +1467,7 @@ function ticketActions(input) {
|
|
|
1366
1467
|
return { tags, taken, skipped, simulated, unrecorded: job !== void 0 && job.outcome === null };
|
|
1367
1468
|
}
|
|
1368
1469
|
function TimelinePanel(props) {
|
|
1369
|
-
const { decision, job, comparisons, conversation, conversationLoading, categoryName, policy, category, onClose, onInvalidate, isInvalidating } = props;
|
|
1470
|
+
const { decision, job, comparisons, conversation, conversationLoading, categoryName, policy, category, onClose, onInvalidate, isInvalidating, history, onSelectGeneration } = props;
|
|
1370
1471
|
const steps = buildTimeline({ decision, job, comparisons, conversation, conversationLoading, policy, category });
|
|
1371
1472
|
const notSentReason2 = steps.find((step2) => step2.key === "delivery")?.reason ?? null;
|
|
1372
1473
|
const actions = ticketActions({ decision, job, policy, category, notSentReason: notSentReason2 });
|
|
@@ -1376,10 +1477,41 @@ function TimelinePanel(props) {
|
|
|
1376
1477
|
/* @__PURE__ */ jsx(TicketLink, { ticketId: decision.ticketId, url: decision.ticketUrl, label: "Ouvrir le ticket dans Gorgias" }),
|
|
1377
1478
|
onInvalidate && canInvalidate && /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: onInvalidate, disabled: isInvalidating, children: isInvalidating ? "Invalidation\u2026" : "Invalider la r\xE9ponse" })
|
|
1378
1479
|
] }),
|
|
1480
|
+
history !== void 0 && history.length > 1 && /* @__PURE__ */ jsx(ThreadHistory, { history, selectedDecisionId: decision.id, onSelect: onSelectGeneration }),
|
|
1379
1481
|
steps.map((step2, index) => /* @__PURE__ */ jsx(StepBlock, { step: step2, index, last: index === steps.length - 1, children: step2.reached ? renderStep(step2.key, props) : null }, step2.key)),
|
|
1380
1482
|
/* @__PURE__ */ jsx(ActionsBlock, { actions })
|
|
1381
1483
|
] }) });
|
|
1382
1484
|
}
|
|
1485
|
+
function ThreadHistory({
|
|
1486
|
+
history,
|
|
1487
|
+
selectedDecisionId,
|
|
1488
|
+
onSelect
|
|
1489
|
+
}) {
|
|
1490
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-1 border-b pb-3", children: [
|
|
1491
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs font-medium", children: "Historique du fil" }),
|
|
1492
|
+
/* @__PURE__ */ jsx("ul", { className: "space-y-1", children: history.map(({ decision, job }) => {
|
|
1493
|
+
const selected = decision.id === selectedDecisionId;
|
|
1494
|
+
const origin = generationOrigin(decision, job);
|
|
1495
|
+
const outcome = responseOutcome(job);
|
|
1496
|
+
return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
|
|
1497
|
+
"button",
|
|
1498
|
+
{
|
|
1499
|
+
type: "button",
|
|
1500
|
+
onClick: onSelect ? () => onSelect(decision) : void 0,
|
|
1501
|
+
"aria-current": selected || void 0,
|
|
1502
|
+
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"}`,
|
|
1503
|
+
children: [
|
|
1504
|
+
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
1505
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: formatDate(decision.decidedAt) }),
|
|
1506
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: origin.label })
|
|
1507
|
+
] }),
|
|
1508
|
+
/* @__PURE__ */ jsx(Badge, { variant: outcome.variant, children: outcome.label })
|
|
1509
|
+
]
|
|
1510
|
+
}
|
|
1511
|
+
) }, decision.id);
|
|
1512
|
+
}) })
|
|
1513
|
+
] });
|
|
1514
|
+
}
|
|
1383
1515
|
function StepBlock({
|
|
1384
1516
|
step: step2,
|
|
1385
1517
|
index,
|
|
@@ -1620,6 +1752,12 @@ var CORRECTED_OPTIONS = [
|
|
|
1620
1752
|
{ value: "true", label: "Corrig\xE9s par un humain" },
|
|
1621
1753
|
{ value: "false", label: "Non corrig\xE9s" }
|
|
1622
1754
|
];
|
|
1755
|
+
var ORIGIN_FILTER_OPTIONS = [
|
|
1756
|
+
{ value: "", label: "Toutes origines" },
|
|
1757
|
+
{ value: "first", label: "1res r\xE9ponses" },
|
|
1758
|
+
{ value: "followup", label: "Messages suivants" },
|
|
1759
|
+
{ value: "test", label: "Brouillons d'essai" }
|
|
1760
|
+
];
|
|
1623
1761
|
function OutcomeBadge({ outcome }) {
|
|
1624
1762
|
return /* @__PURE__ */ jsx(Badge, { variant: OUTCOME_BADGE_VARIANT[outcome.variant], children: outcome.label });
|
|
1625
1763
|
}
|
|
@@ -1638,19 +1776,35 @@ function TicketsPage() {
|
|
|
1638
1776
|
const [verdictFilter, setVerdictFilter] = useState("");
|
|
1639
1777
|
const [promptVersionFilter, setPromptVersionFilter] = useState("");
|
|
1640
1778
|
const [correctedFilter, setCorrectedFilter] = useState("");
|
|
1779
|
+
const [originFilter, setOriginFilter] = useState("");
|
|
1641
1780
|
const [detailDecision, setDetailDecision] = useState(null);
|
|
1642
1781
|
const [isTriaging, setIsTriaging] = useState(false);
|
|
1643
1782
|
const [isInvalidating, setIsInvalidating] = useState(false);
|
|
1783
|
+
const requestedTicket = useQueryParam("ticket").value;
|
|
1784
|
+
const [ticketSearch, setTicketSearch] = useState(() => requestedTicket?.trim() ?? "");
|
|
1785
|
+
const searchDebounce = useRef(null);
|
|
1786
|
+
const onTableStateChange = useCallback((tableState) => {
|
|
1787
|
+
if (searchDebounce.current) clearTimeout(searchDebounce.current);
|
|
1788
|
+
searchDebounce.current = setTimeout(() => setTicketSearch(tableState.search.trim()), 300);
|
|
1789
|
+
}, []);
|
|
1790
|
+
useEffect(
|
|
1791
|
+
() => () => {
|
|
1792
|
+
if (searchDebounce.current) clearTimeout(searchDebounce.current);
|
|
1793
|
+
},
|
|
1794
|
+
[]
|
|
1795
|
+
);
|
|
1796
|
+
const history = useTicketHistory(detailDecision?.ticketId ?? null);
|
|
1644
1797
|
const [triageInFlight] = useState(() => ({ current: false }));
|
|
1645
1798
|
const periodKey = JSON.stringify(period);
|
|
1646
1799
|
const bounds = useMemo(() => periodBoundsOf(JSON.parse(periodKey)).current, [periodKey]);
|
|
1647
1800
|
const decisionFilter = useMemo(() => {
|
|
1801
|
+
if (ticketSearch) return { ticketId: { eq: ticketSearch } };
|
|
1648
1802
|
const filter = { decidedAt: { gte: bounds.fromIso, lte: bounds.toIso } };
|
|
1649
1803
|
if (categoryFilter) filter.categoryId = { eq: categoryFilter };
|
|
1650
1804
|
if (escalatedFilter) filter.escalated = { eq: escalatedFilter === "true" };
|
|
1651
1805
|
if (confidenceFilter) filter.confidence = { eq: confidenceFilter };
|
|
1652
1806
|
return filter;
|
|
1653
|
-
}, [bounds.fromIso, bounds.toIso, categoryFilter, escalatedFilter, confidenceFilter]);
|
|
1807
|
+
}, [ticketSearch, bounds.fromIso, bounds.toIso, categoryFilter, escalatedFilter, confidenceFilter]);
|
|
1654
1808
|
const {
|
|
1655
1809
|
rows: decisions,
|
|
1656
1810
|
isLoading: decisionsLoading,
|
|
@@ -1703,7 +1857,7 @@ function TicketsPage() {
|
|
|
1703
1857
|
const agentNames = useMemo(() => toNameMap(agents), [agents]);
|
|
1704
1858
|
const { config: langfuseConfig } = useLangfuseConfig();
|
|
1705
1859
|
function refreshAll() {
|
|
1706
|
-
return Promise.all([refreshDecisions(), refreshJobs(), refreshComparisons()]).then(() => void 0);
|
|
1860
|
+
return Promise.all([refreshDecisions(), refreshJobs(), refreshComparisons(), history.refresh()]).then(() => void 0);
|
|
1707
1861
|
}
|
|
1708
1862
|
const jobByDecisionId = useMemo(() => {
|
|
1709
1863
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -1750,9 +1904,18 @@ function TicketsPage() {
|
|
|
1750
1904
|
if (promptVersionFilter && String(row.job?.promptVersion ?? "") !== promptVersionFilter) return false;
|
|
1751
1905
|
if (correctedFilter === "true" && row.comparisons.length === 0) return false;
|
|
1752
1906
|
if (correctedFilter === "false" && row.comparisons.length > 0) return false;
|
|
1907
|
+
if (originFilter && generationOrigin(row.decision, row.job).kind !== originFilter) return false;
|
|
1753
1908
|
return true;
|
|
1754
1909
|
});
|
|
1755
|
-
}, [decisions, jobByDecisionId, comparisonsByTicketId, outcomeFilter, verdictFilter, promptVersionFilter, correctedFilter]);
|
|
1910
|
+
}, [decisions, jobByDecisionId, comparisonsByTicketId, outcomeFilter, verdictFilter, promptVersionFilter, correctedFilter, originFilter]);
|
|
1911
|
+
const deepLinkConsumed = useRef(false);
|
|
1912
|
+
useEffect(() => {
|
|
1913
|
+
if (deepLinkConsumed.current || !requestedTicket) return;
|
|
1914
|
+
const match = rows.find((row) => row.decision.ticketId === requestedTicket);
|
|
1915
|
+
if (!match) return;
|
|
1916
|
+
deepLinkConsumed.current = true;
|
|
1917
|
+
setDetailDecision(match.decision);
|
|
1918
|
+
}, [requestedTicket, rows]);
|
|
1756
1919
|
const categoryOptions = useMemo(
|
|
1757
1920
|
() => [{ value: "", label: "Toutes cat\xE9gories" }, ...categories.map((category) => ({ value: category.id, label: category.name }))],
|
|
1758
1921
|
[categories]
|
|
@@ -1792,6 +1955,15 @@ function TicketsPage() {
|
|
|
1792
1955
|
}
|
|
1793
1956
|
const columns = [
|
|
1794
1957
|
{ key: "ticketId", header: "Ticket", cell: ({ decision }) => /* @__PURE__ */ jsx(TicketLink, { ticketId: decision.ticketId, url: decision.ticketUrl }) },
|
|
1958
|
+
{
|
|
1959
|
+
key: "origin",
|
|
1960
|
+
header: "Origine",
|
|
1961
|
+
cell: ({ decision, job }) => {
|
|
1962
|
+
const origin = generationOrigin(decision, job);
|
|
1963
|
+
if (origin.kind === "first") return /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: origin.label });
|
|
1964
|
+
return /* @__PURE__ */ jsx(Badge, { variant: origin.kind === "test" ? "warning" : "info", children: origin.label });
|
|
1965
|
+
}
|
|
1966
|
+
},
|
|
1795
1967
|
{ key: "category", header: "Cat\xE9gorie", cell: ({ decision }) => decision.categoryId && categoryNames.get(decision.categoryId) || "\u2014" },
|
|
1796
1968
|
{ key: "tag", header: "Tag", cell: ({ decision }) => decision.tag ? /* @__PURE__ */ jsx("code", { className: "text-xs", children: decision.tag }) : "\u2014" },
|
|
1797
1969
|
{
|
|
@@ -1848,7 +2020,12 @@ function TicketsPage() {
|
|
|
1848
2020
|
},
|
|
1849
2021
|
{ key: "decidedAt", header: "D\xE9cid\xE9 le", cell: ({ decision }) => formatDate(decision.decidedAt) }
|
|
1850
2022
|
];
|
|
1851
|
-
const
|
|
2023
|
+
const historyEntry = detailDecision ? history.entries.find((entry) => entry.decision.id === detailDecision.id) : void 0;
|
|
2024
|
+
const pageRow = detailDecision ? rows.find((row) => row.decision.id === detailDecision.id) : void 0;
|
|
2025
|
+
const detailRow = detailDecision ? {
|
|
2026
|
+
job: historyEntry?.job ?? pageRow?.job,
|
|
2027
|
+
comparisons: comparisonsByTicketId.get(detailDecision.ticketId) ?? []
|
|
2028
|
+
} : void 0;
|
|
1852
2029
|
const liveConversation = useLiveConversation(detailDecision, detailRow);
|
|
1853
2030
|
const isLoading = decisionsLoading || jobsLoading;
|
|
1854
2031
|
const combinedError = decisionsError ?? jobsError ?? comparisonsError;
|
|
@@ -1882,6 +2059,7 @@ function TicketsPage() {
|
|
|
1882
2059
|
/* @__PURE__ */ jsx(Select, { items: VERDICT_OPTIONS, value: verdictFilter, onValueChange: setVerdictFilter, placeholder: "Tous les verdicts", "aria-label": "Filtrer par verdict" }),
|
|
1883
2060
|
/* @__PURE__ */ jsx(Select, { items: promptVersionOptions, value: promptVersionFilter, onValueChange: setPromptVersionFilter, placeholder: "Toutes versions de prompt", "aria-label": "Filtrer par version de prompt" }),
|
|
1884
2061
|
/* @__PURE__ */ jsx(Select, { items: CORRECTED_OPTIONS, value: correctedFilter, onValueChange: setCorrectedFilter, placeholder: "Corrig\xE9s ou non", "aria-label": "Filtrer par correction humaine" }),
|
|
2062
|
+
/* @__PURE__ */ jsx(Select, { items: ORIGIN_FILTER_OPTIONS, value: originFilter, onValueChange: setOriginFilter, placeholder: "Toutes origines", "aria-label": "Filtrer par origine" }),
|
|
1885
2063
|
rows.length > 0 && /* @__PURE__ */ jsxs("span", { className: "ml-auto text-sm text-muted-foreground", children: [
|
|
1886
2064
|
rows.length,
|
|
1887
2065
|
" ticket",
|
|
@@ -1896,6 +2074,9 @@ function TicketsPage() {
|
|
|
1896
2074
|
rows,
|
|
1897
2075
|
rowId: (row) => row.decision.id,
|
|
1898
2076
|
manual: true,
|
|
2077
|
+
defaultState: { search: requestedTicket?.trim() ?? "" },
|
|
2078
|
+
onStateChange: onTableStateChange,
|
|
2079
|
+
searchPlaceholder: "ID de ticket\u2026",
|
|
1899
2080
|
loading: isLoading,
|
|
1900
2081
|
onRowClick: (row) => setDetailDecision(row.decision),
|
|
1901
2082
|
pagination: {
|
|
@@ -1928,6 +2109,8 @@ function TicketsPage() {
|
|
|
1928
2109
|
category: categories.find((entry) => entry.id === detailDecision.categoryId) ?? null,
|
|
1929
2110
|
agentName: detailRow?.job?.agentId && agentNames.get(detailRow.job.agentId) || "\u2014",
|
|
1930
2111
|
langfuseConfig,
|
|
2112
|
+
history: history.entries,
|
|
2113
|
+
onSelectGeneration: (selected) => setDetailDecision(selected),
|
|
1931
2114
|
onClose: () => setDetailDecision(null),
|
|
1932
2115
|
onInvalidate: canWrite && detailRow?.job ? () => void invalidateResponse(detailRow.job.id) : void 0,
|
|
1933
2116
|
isInvalidating
|
|
@@ -4539,31 +4722,6 @@ function SettingsPage() {
|
|
|
4539
4722
|
);
|
|
4540
4723
|
}
|
|
4541
4724
|
var ReglagesPage = SettingsPage;
|
|
4542
|
-
function readParam(name) {
|
|
4543
|
-
if (typeof window === "undefined") return null;
|
|
4544
|
-
return new URLSearchParams(window.location.search).get(name);
|
|
4545
|
-
}
|
|
4546
|
-
function useQueryParam(name) {
|
|
4547
|
-
const [value, setState] = useState(() => readParam(name));
|
|
4548
|
-
useEffect(() => {
|
|
4549
|
-
const sync = () => setState(readParam(name));
|
|
4550
|
-
sync();
|
|
4551
|
-
window.addEventListener("popstate", sync);
|
|
4552
|
-
return () => window.removeEventListener("popstate", sync);
|
|
4553
|
-
}, [name]);
|
|
4554
|
-
const setValue = useCallback(
|
|
4555
|
-
(next) => {
|
|
4556
|
-
const params = new URLSearchParams(window.location.search);
|
|
4557
|
-
if (next === null) params.delete(name);
|
|
4558
|
-
else params.set(name, next);
|
|
4559
|
-
const query = params.toString();
|
|
4560
|
-
window.history.pushState({}, "", `${window.location.pathname}${query ? `?${query}` : ""}`);
|
|
4561
|
-
setState(next);
|
|
4562
|
-
},
|
|
4563
|
-
[name]
|
|
4564
|
-
);
|
|
4565
|
-
return { value, setValue };
|
|
4566
|
-
}
|
|
4567
4725
|
|
|
4568
4726
|
// src/ui/graph-canvas/reachability.ts
|
|
4569
4727
|
var EXIT_TONES = {
|
|
@@ -6140,20 +6298,81 @@ function DryRunResultView({ result, langfuseConfig, knownTags, tagSettings }) {
|
|
|
6140
6298
|
var STATUS_BADGE = {
|
|
6141
6299
|
passed: { label: "OK", variant: "success" },
|
|
6142
6300
|
stopped: { label: "Arr\xEAt", variant: "danger" },
|
|
6143
|
-
// A pre-gate that could not read its field.
|
|
6144
|
-
// (it evaluates no payload) but
|
|
6145
|
-
// than falling through to a blank badge.
|
|
6301
|
+
// A pre-gate that could not read its field. The diagnostic never produces
|
|
6302
|
+
// one (it evaluates no payload), but a run stopped on a pre-gate does —
|
|
6303
|
+
// rendered honestly rather than falling through to a blank badge.
|
|
6146
6304
|
muted: { label: "Muet", variant: "warning" },
|
|
6147
6305
|
skipped: { label: "Non \xE9valu\xE9", variant: "neutral" }
|
|
6148
6306
|
};
|
|
6307
|
+
function GatesTable({ gates }) {
|
|
6308
|
+
return /* @__PURE__ */ jsx("ul", { className: "space-y-1", children: gates.map((gate) => {
|
|
6309
|
+
const badge = STATUS_BADGE[gate.status] ?? STATUS_BADGE.skipped;
|
|
6310
|
+
return /* @__PURE__ */ jsxs("li", { className: "flex items-start gap-2 text-xs", children: [
|
|
6311
|
+
/* @__PURE__ */ jsx(Badge, { variant: badge.variant, children: badge.label }),
|
|
6312
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
6313
|
+
/* @__PURE__ */ jsxs("span", { className: "font-medium", children: [
|
|
6314
|
+
gate.gate,
|
|
6315
|
+
" \u2014 ",
|
|
6316
|
+
gate.label
|
|
6317
|
+
] }),
|
|
6318
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
6319
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: gate.detail })
|
|
6320
|
+
] })
|
|
6321
|
+
] }, gate.gate);
|
|
6322
|
+
}) });
|
|
6323
|
+
}
|
|
6324
|
+
function parseRunResult(result) {
|
|
6325
|
+
if (typeof result !== "object" || result === null) return null;
|
|
6326
|
+
const raw = result;
|
|
6327
|
+
if (!Array.isArray(raw.gates)) return null;
|
|
6328
|
+
return {
|
|
6329
|
+
ticketId: typeof raw.ticketId === "string" ? raw.ticketId : null,
|
|
6330
|
+
stoppedAt: typeof raw.stoppedAt === "string" ? raw.stoppedAt : null,
|
|
6331
|
+
reason: typeof raw.reason === "string" ? raw.reason : null,
|
|
6332
|
+
gates: raw.gates,
|
|
6333
|
+
categoryName: typeof raw.categoryName === "string" ? raw.categoryName : null,
|
|
6334
|
+
outcome: typeof raw.outcome === "string" ? raw.outcome : null,
|
|
6335
|
+
responseId: typeof raw.responseId === "string" ? raw.responseId : null,
|
|
6336
|
+
ticketUrl: typeof raw.ticketUrl === "string" ? raw.ticketUrl : null
|
|
6337
|
+
};
|
|
6338
|
+
}
|
|
6339
|
+
function describeRunDecision(result, mode) {
|
|
6340
|
+
if (result.stoppedAt !== null) return `Arr\xEAt en ${result.stoppedAt}.`;
|
|
6341
|
+
const category = result.categoryName ? ` (cat\xE9gorie \xAB ${result.categoryName} \xBB)` : "";
|
|
6342
|
+
if (result.outcome === "sent") {
|
|
6343
|
+
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}.`;
|
|
6344
|
+
}
|
|
6345
|
+
const label = result.outcome !== null && result.outcome in OUTCOME_LABELS ? OUTCOME_LABELS[result.outcome] : null;
|
|
6346
|
+
return label ? `${label}${category}.` : `Traitement termin\xE9${category}.`;
|
|
6347
|
+
}
|
|
6149
6348
|
function FollowupWebhookCard2() {
|
|
6150
6349
|
const api = useAppApi();
|
|
6350
|
+
const { appSlug } = useAppContext();
|
|
6151
6351
|
const toast = useToast();
|
|
6152
6352
|
const ticketId = useId();
|
|
6153
6353
|
const [ticket, setTicket] = useState("");
|
|
6154
6354
|
const [test, setTest] = useState(null);
|
|
6155
6355
|
const [isTesting, setIsTesting] = useState(false);
|
|
6156
6356
|
const [confirmingRealRun, setConfirmingRealRun] = useState(false);
|
|
6357
|
+
const followedRunId = test !== null && test.mode !== "diagnostic" ? test.runId : null;
|
|
6358
|
+
const { run, isPolling } = useAppRun(followedRunId);
|
|
6359
|
+
const runResult = run && run.status === "succeeded" ? parseRunResult(run.result) : null;
|
|
6360
|
+
const [draftText, setDraftText] = useState(null);
|
|
6361
|
+
useEffect(() => {
|
|
6362
|
+
setDraftText(null);
|
|
6363
|
+
const responseId = runResult?.responseId;
|
|
6364
|
+
if (!responseId) return;
|
|
6365
|
+
let cancelled = false;
|
|
6366
|
+
void api.get(
|
|
6367
|
+
`/data/apps/${appSlug}/records/generated-response/${encodeURIComponent(responseId)}`
|
|
6368
|
+
).then((record) => {
|
|
6369
|
+
if (!cancelled) setDraftText(record?.data?.responseText ?? null);
|
|
6370
|
+
}).catch(() => {
|
|
6371
|
+
});
|
|
6372
|
+
return () => {
|
|
6373
|
+
cancelled = true;
|
|
6374
|
+
};
|
|
6375
|
+
}, [runResult?.responseId, appSlug]);
|
|
6157
6376
|
async function runTest(mode) {
|
|
6158
6377
|
setIsTesting(true);
|
|
6159
6378
|
setTest(null);
|
|
@@ -6210,20 +6429,35 @@ function FollowupWebhookCard2() {
|
|
|
6210
6429
|
/* @__PURE__ */ jsx("code", { children: test.runId }),
|
|
6211
6430
|
"."
|
|
6212
6431
|
] }),
|
|
6432
|
+
test !== null && test.mode !== "diagnostic" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6433
|
+
isPolling && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [
|
|
6434
|
+
/* @__PURE__ */ jsx(Spinner, {}),
|
|
6435
|
+
" Ex\xE9cution en cours\u2026"
|
|
6436
|
+
] }),
|
|
6437
|
+
run?.status === "failed" && /* @__PURE__ */ jsxs("p", { className: "text-sm text-destructive", children: [
|
|
6438
|
+
"L'ex\xE9cution a \xE9chou\xE9 : ",
|
|
6439
|
+
run.error?.message ?? "erreur inconnue."
|
|
6440
|
+
] }),
|
|
6441
|
+
runResult && /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
6442
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: describeRunDecision(runResult, test.mode) }),
|
|
6443
|
+
runResult.stoppedAt !== null && runResult.reason !== null && !runResult.gates.some((gate) => gate.status === "stopped") && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: runResult.reason }),
|
|
6444
|
+
/* @__PURE__ */ jsx(GatesTable, { gates: runResult.gates }),
|
|
6445
|
+
draftText !== null && /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
6446
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs font-medium", children: "Brouillon g\xE9n\xE9r\xE9" }),
|
|
6447
|
+
/* @__PURE__ */ jsx("p", { className: "whitespace-pre-wrap rounded border bg-muted/30 p-2 text-xs", children: draftText })
|
|
6448
|
+
] }),
|
|
6449
|
+
/* @__PURE__ */ jsxs("p", { className: "text-xs", children: [
|
|
6450
|
+
/* @__PURE__ */ jsx(Link, { href: `/espace/${appSlug}/tickets?ticket=${encodeURIComponent(runResult.ticketId ?? test.ticketId)}`, children: "Ouvrir la fiche du ticket" }),
|
|
6451
|
+
runResult.ticketUrl !== null && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6452
|
+
" \xB7 ",
|
|
6453
|
+
/* @__PURE__ */ jsx(Link, { href: runResult.ticketUrl, target: "_blank", rel: "noopener noreferrer", children: "Ouvrir dans Gorgias" })
|
|
6454
|
+
] })
|
|
6455
|
+
] })
|
|
6456
|
+
] })
|
|
6457
|
+
] }),
|
|
6213
6458
|
test?.mode === "diagnostic" && /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
6214
6459
|
/* @__PURE__ */ 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}.` }),
|
|
6215
|
-
/* @__PURE__ */ jsx(
|
|
6216
|
-
/* @__PURE__ */ jsx(Badge, { variant: STATUS_BADGE[gate.status].variant, children: STATUS_BADGE[gate.status].label }),
|
|
6217
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
6218
|
-
/* @__PURE__ */ jsxs("span", { className: "font-medium", children: [
|
|
6219
|
-
gate.gate,
|
|
6220
|
-
" \u2014 ",
|
|
6221
|
-
gate.label
|
|
6222
|
-
] }),
|
|
6223
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
6224
|
-
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: gate.detail })
|
|
6225
|
-
] })
|
|
6226
|
-
] }, gate.gate)) })
|
|
6460
|
+
/* @__PURE__ */ jsx(GatesTable, { gates: test.gates })
|
|
6227
6461
|
] })
|
|
6228
6462
|
] })
|
|
6229
6463
|
] }),
|