@apotech-os/support-kit 3.4.0 → 4.1.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 +24 -20
- package/dist/{chunk-SFOPXCD4.js → chunk-D5N3UEOG.js} +23 -23
- package/dist/chunk-D5N3UEOG.js.map +1 -0
- package/dist/index.cjs +88 -116
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +125 -95
- package/dist/index.d.ts +125 -95
- package/dist/index.js +70 -109
- package/dist/index.js.map +1 -1
- package/dist/ui/index.cjs +1785 -2506
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.d.cts +1 -7
- package/dist/ui/index.d.ts +1 -7
- package/dist/ui/index.js +1076 -1780
- package/dist/ui/index.js.map +1 -1
- package/package.json +11 -11
- package/dist/chunk-SFOPXCD4.js.map +0 -1
package/dist/ui/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useState, useMemo,
|
|
3
|
-
import { useAppContext, useAppSettings, DateRangeCompare, Link, Card, CardHeader, CardTitle, CardContent, AreaChart, StackedBarChart, Badge,
|
|
1
|
+
import { EVALUATION_VERDICTS, WHATSAPP_MODES, validateSettings, AGENT_GUARDRAILS, toCategory, toAgent, toGeneratedResponse, toResponseComparison, toTriageDecision, isGeneratedResponseStatus, toCategoryGroup, NODE_NAMES, settingsToProfile, hasNoDraftNode, DEFAULT_LLM_PROVIDER, computeWordDiff, isSendableVerdict, DEFAULT_MAX_TOOL_CALLS, DEFAULT_MIN_CONFIDENCE, DEFAULT_ESCALATION_ENABLED } from '../chunk-D5N3UEOG.js';
|
|
2
|
+
import { useState, useMemo, useEffect, useRef, useCallback, useId } from 'react';
|
|
3
|
+
import { useAppContext, useAppSettings, DateRangeCompare, Link, Card, CardHeader, CardTitle, CardContent, AreaChart, StackedBarChart, Badge, useAppApi, useToast, Button, Select, DataTable, Spinner, Switch, Input, Checkbox, Textarea, comparisonRange, cn, SidePanel, Modal, Tooltip, buttonVariants, 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) {
|
|
@@ -573,7 +573,7 @@ function DashboardPage() {
|
|
|
573
573
|
align: "end"
|
|
574
574
|
}
|
|
575
575
|
),
|
|
576
|
-
/* @__PURE__ */ jsx(Link, { href: `/espace/${appSlug}/
|
|
576
|
+
/* @__PURE__ */ jsx(Link, { href: `/espace/${appSlug}/tickets`, children: "Voir tous les tickets" })
|
|
577
577
|
] })
|
|
578
578
|
}
|
|
579
579
|
),
|
|
@@ -774,6 +774,143 @@ function DashboardPage() {
|
|
|
774
774
|
] })
|
|
775
775
|
] });
|
|
776
776
|
}
|
|
777
|
+
|
|
778
|
+
// src/ui/shared/idempotency-key.ts
|
|
779
|
+
function idempotencyKeyFor(operation, payload) {
|
|
780
|
+
const seed = `${operation}:${JSON.stringify(payload)}`;
|
|
781
|
+
let hash = 2166136261;
|
|
782
|
+
for (let i = 0; i < seed.length; i++) {
|
|
783
|
+
hash ^= seed.charCodeAt(i);
|
|
784
|
+
hash = Math.imul(hash, 16777619);
|
|
785
|
+
}
|
|
786
|
+
return (hash >>> 0).toString(16);
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
// src/ui/shared/settings-issue-labels.ts
|
|
790
|
+
var SETTINGS_ISSUE_LABELS = {
|
|
791
|
+
sourceViewId: "Vue Gorgias source requise \u2014 choisissez la vue que cette app poss\xE8de.",
|
|
792
|
+
nodes: "nodes.triage doit \xEAtre configur\xE9 \u2014 une \xE9tape de triage \xE0 null ne triagerait rien.",
|
|
793
|
+
nodePrompt: "Chaque \xE9tape active doit d\xE9signer un prompt Langfuse \u2014 sans prompt, l'\xE9tape n'a rien \xE0 dire au mod\xE8le.",
|
|
794
|
+
senderEmail: "Adresse d'envoi requise quand l'envoi automatique est actif (sauf en mode WhatsApp \xAB auto_reply \xBB)."
|
|
795
|
+
};
|
|
796
|
+
function settingsIssueLabel(key, fallback) {
|
|
797
|
+
return SETTINGS_ISSUE_LABELS[key] ?? fallback;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
// src/ui/shared/function-error-labels.ts
|
|
801
|
+
var EXACT_MESSAGE_LABELS = {
|
|
802
|
+
"name is required": "Le nom est requis.",
|
|
803
|
+
"content is required": "Le contenu est requis.",
|
|
804
|
+
"agentId is required": "L'agent est requis.",
|
|
805
|
+
"ticketId is required": "Le ticket est requis.",
|
|
806
|
+
"No non-identical comparison found for this agent": "Aucune comparaison diff\xE9rente de l'original n'a \xE9t\xE9 trouv\xE9e pour cet agent.",
|
|
807
|
+
"The model returned an invalid JSON response": "Le mod\xE8le a renvoy\xE9 une r\xE9ponse JSON invalide.",
|
|
808
|
+
"Either viewId or ticketIds is required": "Une vue ou une liste de tickets est requise."
|
|
809
|
+
};
|
|
810
|
+
var SETTINGS_VALIDATION_MESSAGE_LABELS = {
|
|
811
|
+
"sourceViewId is required \u2014 pick the Gorgias view this app owns.": SETTINGS_ISSUE_LABELS.sourceViewId,
|
|
812
|
+
"nodes.triage must be configured \u2014 a null triage step would triage nothing.": SETTINGS_ISSUE_LABELS.nodes,
|
|
813
|
+
"senderEmail is required when autoSendEnabled is on, unless whatsappMode is 'auto_reply'.": SETTINGS_ISSUE_LABELS.senderEmail
|
|
814
|
+
};
|
|
815
|
+
var DYNAMIC_MESSAGE_PATTERNS = [
|
|
816
|
+
{
|
|
817
|
+
// create-shared-prompt-version.ts
|
|
818
|
+
pattern: /^"(.+)" is not a shared\/\* prompt — create-shared-prompt-version only writes the shared\/\* library\.$/,
|
|
819
|
+
build: ([, name]) => `\xAB ${name} \xBB n'est pas un prompt shared/* \u2014 seule la biblioth\xE8que shared/* peut \xEAtre \xE9crite ici.`
|
|
820
|
+
},
|
|
821
|
+
{
|
|
822
|
+
// run-diff-analysis.ts / suggest-prompt.ts
|
|
823
|
+
pattern: /^Agent "(.+)" has no promptName configured$/,
|
|
824
|
+
build: ([, agentId]) => `L'agent \xAB ${agentId} \xBB n'a pas de promptName configur\xE9.`
|
|
825
|
+
},
|
|
826
|
+
{
|
|
827
|
+
// graph-dry-run.ts
|
|
828
|
+
pattern: /^Category "(.+)" not found$/,
|
|
829
|
+
build: ([, categoryId]) => `Cat\xE9gorie \xAB ${categoryId} \xBB introuvable.`
|
|
830
|
+
},
|
|
831
|
+
{
|
|
832
|
+
// validate-references.ts, via create-shared-prompt-version.ts's "Invalid reference tags: …"
|
|
833
|
+
pattern: /^Malformed reference tag near "(.*)": it will be saved as literal text instead of being resolved\.$/,
|
|
834
|
+
build: ([, snippet]) => `Balise de r\xE9f\xE9rence malform\xE9e pr\xE8s de \xAB ${snippet} \xBB : elle sera enregistr\xE9e telle quelle au lieu d'\xEAtre r\xE9solue.`
|
|
835
|
+
},
|
|
836
|
+
{
|
|
837
|
+
pattern: /^Reference "(.+)" points to this same prompt \("(.+)"\) — a prompt cannot reference itself\.$/,
|
|
838
|
+
build: ([, raw, self]) => `La r\xE9f\xE9rence \xAB ${raw} \xBB pointe vers ce m\xEAme prompt (\xAB ${self} \xBB) \u2014 un prompt ne peut pas se r\xE9f\xE9rencer lui-m\xEAme.`
|
|
839
|
+
},
|
|
840
|
+
{
|
|
841
|
+
pattern: /^Reference "(.+)" points to prompt "(.+)", which exists but is outside this app's prompts allowlist \(role\.prompts\) — it cannot be composed here even though it can be read elsewhere\.$/,
|
|
842
|
+
build: ([, raw, name]) => `La r\xE9f\xE9rence \xAB ${raw} \xBB pointe vers le prompt \xAB ${name} \xBB, qui existe mais est hors de la liste autoris\xE9e de cette app (role.prompts) \u2014 il ne peut pas \xEAtre compos\xE9 ici, m\xEAme s'il reste lisible ailleurs.`
|
|
843
|
+
},
|
|
844
|
+
{
|
|
845
|
+
pattern: /^Reference "(.+)" could not be resolved: prompt "(.+)" with (.+) was not found, or the prompt store could not be reached to verify it\.$/,
|
|
846
|
+
build: ([, raw, name, locator]) => `La r\xE9f\xE9rence \xAB ${raw} \xBB n'a pas pu \xEAtre r\xE9solue : le prompt \xAB ${name} \xBB avec ${locator} est introuvable, ou le magasin de prompts \xE9tait injoignable pour le v\xE9rifier.`
|
|
847
|
+
},
|
|
848
|
+
{
|
|
849
|
+
pattern: /^Reference "(.+)" creates a cycle: prompt "(.+)" \(transitively\) references this prompt \("(.+)"\)\.$/,
|
|
850
|
+
build: ([, raw, name, self]) => `La r\xE9f\xE9rence \xAB ${raw} \xBB cr\xE9e un cycle : le prompt \xAB ${name} \xBB r\xE9f\xE9rence (de fa\xE7on transitive) ce m\xEAme prompt (\xAB ${self} \xBB).`
|
|
851
|
+
},
|
|
852
|
+
{
|
|
853
|
+
pattern: /^Reference chain exceeds the runtime composition cap \((\d+) levels\): the segment past that depth would be silently stripped when this prompt is resolved\.$/,
|
|
854
|
+
build: ([, levels]) => `La cha\xEEne de r\xE9f\xE9rences d\xE9passe la limite de composition (${levels} niveaux) : le segment au-del\xE0 de cette profondeur serait silencieusement supprim\xE9 lors de la r\xE9solution du prompt.`
|
|
855
|
+
}
|
|
856
|
+
];
|
|
857
|
+
function translateSettingsInvalidMessage(message) {
|
|
858
|
+
const prefix = "Settings are invalid: ";
|
|
859
|
+
if (!message.startsWith(prefix)) return null;
|
|
860
|
+
const rest = message.slice(prefix.length);
|
|
861
|
+
const translatedRest = Object.entries(SETTINGS_VALIDATION_MESSAGE_LABELS).reduce(
|
|
862
|
+
(acc, [en, fr]) => acc.split(en).join(fr),
|
|
863
|
+
rest
|
|
864
|
+
);
|
|
865
|
+
return `R\xE9glages invalides : ${translatedRest}`;
|
|
866
|
+
}
|
|
867
|
+
function translateReferenceTagsMessage(message) {
|
|
868
|
+
const prefix = "Invalid reference tags: ";
|
|
869
|
+
if (!message.startsWith(prefix)) return null;
|
|
870
|
+
const rest = message.slice(prefix.length);
|
|
871
|
+
const translatedRest = translateFunctionErrorMessage(rest);
|
|
872
|
+
return `Balises de r\xE9f\xE9rence invalides : ${translatedRest}`;
|
|
873
|
+
}
|
|
874
|
+
function translateDynamicMessage(message) {
|
|
875
|
+
for (const { pattern, build } of DYNAMIC_MESSAGE_PATTERNS) {
|
|
876
|
+
const match = message.match(pattern);
|
|
877
|
+
if (match) return build(match);
|
|
878
|
+
}
|
|
879
|
+
return null;
|
|
880
|
+
}
|
|
881
|
+
function translateFunctionErrorMessage(message) {
|
|
882
|
+
if (message in EXACT_MESSAGE_LABELS) return EXACT_MESSAGE_LABELS[message];
|
|
883
|
+
const settingsTranslated = translateSettingsInvalidMessage(message);
|
|
884
|
+
if (settingsTranslated !== null) return settingsTranslated;
|
|
885
|
+
const referenceTagsTranslated = translateReferenceTagsMessage(message);
|
|
886
|
+
if (referenceTagsTranslated !== null) return referenceTagsTranslated;
|
|
887
|
+
const dynamicTranslated = translateDynamicMessage(message);
|
|
888
|
+
if (dynamicTranslated !== null) return dynamicTranslated;
|
|
889
|
+
return message;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
// src/ui/shared/invoke-error.ts
|
|
893
|
+
var GENERIC_MESSAGE = "Une erreur est survenue. R\xE9essayez, ou contactez un administrateur si le probl\xE8me persiste.";
|
|
894
|
+
function describeInvokeError(err) {
|
|
895
|
+
if (err instanceof AppInvokeError && err.code === "FUNCTION_REJECTED") {
|
|
896
|
+
return translateFunctionErrorMessage(err.message);
|
|
897
|
+
}
|
|
898
|
+
return GENERIC_MESSAGE;
|
|
899
|
+
}
|
|
900
|
+
function describeApiError(err) {
|
|
901
|
+
const shape = err;
|
|
902
|
+
const status = shape?.response?.status ?? shape?.status;
|
|
903
|
+
const message = shape?.response?.data?.message ?? shape?.message;
|
|
904
|
+
if (typeof status === "number" && status >= 400 && status < 500 && message) {
|
|
905
|
+
return message;
|
|
906
|
+
}
|
|
907
|
+
return GENERIC_MESSAGE;
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
// src/ui/shared/roles.ts
|
|
911
|
+
function canWriteForRole(role) {
|
|
912
|
+
return role === "EDITOR" || role === "ADMIN";
|
|
913
|
+
}
|
|
777
914
|
function isHttpUrl(url) {
|
|
778
915
|
try {
|
|
779
916
|
const { protocol } = new URL(url);
|
|
@@ -890,7 +1027,6 @@ var TRIAGE_CONFIDENCE_LABELS = {
|
|
|
890
1027
|
low: "Faible"
|
|
891
1028
|
};
|
|
892
1029
|
var TRIAGE_DECISION_STATUS_LABELS = {
|
|
893
|
-
ok: "R\xE9ussi",
|
|
894
1030
|
error: "Erreur"
|
|
895
1031
|
};
|
|
896
1032
|
var NODE_LABELS = {
|
|
@@ -930,7 +1066,70 @@ function outcomeLabel(outcome) {
|
|
|
930
1066
|
return outcome ? OUTCOME_LABELS[outcome] : "\u2014";
|
|
931
1067
|
}
|
|
932
1068
|
|
|
933
|
-
// src/ui/
|
|
1069
|
+
// src/ui/tickets/ticket-outcome.ts
|
|
1070
|
+
var NO_JOB = { label: "Aucune r\xE9ponse g\xE9n\xE9r\xE9e", variant: "neutral" };
|
|
1071
|
+
function responseOutcome(job) {
|
|
1072
|
+
if (!job) return NO_JOB;
|
|
1073
|
+
if (job.autoSendDecision === "hold") return { label: AUTO_SEND_DECISION_LABELS.hold, variant: "warning" };
|
|
1074
|
+
if (job.status === "sent") return { label: GENERATED_RESPONSE_STATUS_LABELS.sent, variant: "success" };
|
|
1075
|
+
if (job.status === "failed") return { label: GENERATED_RESPONSE_STATUS_LABELS.failed, variant: "danger" };
|
|
1076
|
+
if (job.status === "pending" || job.status === "sending") return { label: "En cours", variant: "neutral" };
|
|
1077
|
+
const label = isGeneratedResponseStatus(job.status) ? GENERATED_RESPONSE_STATUS_LABELS[job.status] : job.status;
|
|
1078
|
+
return { label, variant: "neutral" };
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
// src/ui/tickets/match.ts
|
|
1082
|
+
function tokensFor(row) {
|
|
1083
|
+
return row.diff ?? computeWordDiff(row.generatedText, row.sentText);
|
|
1084
|
+
}
|
|
1085
|
+
function matchPercentage(row) {
|
|
1086
|
+
if (!row.generatedText) return null;
|
|
1087
|
+
const tokens = tokensFor(row);
|
|
1088
|
+
if (tokens.length === 0) return null;
|
|
1089
|
+
const equal = tokens.filter((token) => token.op === "equal").length;
|
|
1090
|
+
return Math.round(equal / tokens.length * 100);
|
|
1091
|
+
}
|
|
1092
|
+
function matchBadgeClass(pct) {
|
|
1093
|
+
if (pct >= 80) return "border-status-success/25 bg-status-success/10 text-status-success";
|
|
1094
|
+
if (pct >= 50) return "border-status-warning/25 bg-status-warning/10 text-status-warning";
|
|
1095
|
+
return "border-destructive/25 bg-destructive/10 text-destructive";
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
// src/ui/tickets/conversation-source.ts
|
|
1099
|
+
function resolveConversation(sources) {
|
|
1100
|
+
if (sources.tracedInput.length > 0) {
|
|
1101
|
+
return {
|
|
1102
|
+
origin: "traced",
|
|
1103
|
+
systemPrompt: sources.tracedInput.find((message) => message.role === "system")?.content ?? null,
|
|
1104
|
+
messages: sources.tracedInput.filter((message) => message.role !== "system")
|
|
1105
|
+
};
|
|
1106
|
+
}
|
|
1107
|
+
if (sources.comparisonMessages.length > 0) {
|
|
1108
|
+
return { origin: "comparison", systemPrompt: null, messages: sources.comparisonMessages };
|
|
1109
|
+
}
|
|
1110
|
+
if (sources.liveMessages && sources.liveMessages.length > 0) {
|
|
1111
|
+
return { origin: "live", systemPrompt: null, messages: sources.liveMessages };
|
|
1112
|
+
}
|
|
1113
|
+
return null;
|
|
1114
|
+
}
|
|
1115
|
+
var CONVERSATION_ORIGIN_NOTE = {
|
|
1116
|
+
traced: null,
|
|
1117
|
+
comparison: "Captur\xE9 au moment o\xF9 un agent a r\xE9pondu.",
|
|
1118
|
+
live: "Lu maintenant chez Gorgias \u2014 pas ce que le mod\xE8le avait sous les yeux."
|
|
1119
|
+
};
|
|
1120
|
+
function WordDiffView({ title, tokens, keep, hideEqual = false }) {
|
|
1121
|
+
const highlightCls = keep === "delete" ? "bg-destructive/10 text-destructive" : "bg-status-success/10 text-status-success";
|
|
1122
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col overflow-hidden rounded-md border", children: [
|
|
1123
|
+
/* @__PURE__ */ jsx("div", { className: "border-b bg-muted px-3 py-1.5 text-xs font-semibold text-muted-foreground", children: title }),
|
|
1124
|
+
/* @__PURE__ */ jsx("pre", { className: "max-h-96 overflow-y-auto whitespace-pre-wrap p-3 text-xs", children: tokens.map((op, index) => {
|
|
1125
|
+
if (op.op === "equal") return hideEqual ? null : /* @__PURE__ */ jsx("span", { children: op.text }, index);
|
|
1126
|
+
if (op.op !== keep) return null;
|
|
1127
|
+
return /* @__PURE__ */ jsx("span", { className: `rounded px-0.5 ${highlightCls}`, children: op.text }, index);
|
|
1128
|
+
}) })
|
|
1129
|
+
] });
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
// src/ui/tickets/guardrail-labels.ts
|
|
934
1133
|
var NO_GUARDRAIL_REASON = "no_guardrail";
|
|
935
1134
|
var GUARDRAIL_LABELS = {
|
|
936
1135
|
whatsapp: "conversation WhatsApp",
|
|
@@ -952,150 +1151,347 @@ function guardrailHitLabel(hit) {
|
|
|
952
1151
|
return GUARDRAIL_LABELS[hit] ?? hit;
|
|
953
1152
|
}
|
|
954
1153
|
|
|
955
|
-
// src/ui/tickets/
|
|
956
|
-
var
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
return { label, variant: "neutral" };
|
|
965
|
-
}
|
|
966
|
-
var DECISIONS_PAGE_SIZE = 50;
|
|
967
|
-
var JOBS_WINDOW_SIZE = 200;
|
|
968
|
-
var OUTCOME_BADGE_VARIANT = {
|
|
969
|
-
neutral: "neutral",
|
|
970
|
-
success: "success",
|
|
971
|
-
warning: "warning",
|
|
972
|
-
danger: "danger"
|
|
1154
|
+
// src/ui/tickets/timeline.ts
|
|
1155
|
+
var TITLES = {
|
|
1156
|
+
received: "Re\xE7u",
|
|
1157
|
+
prompt: "Prompt envoy\xE9",
|
|
1158
|
+
triage: "Triage",
|
|
1159
|
+
draft: "R\xE9daction",
|
|
1160
|
+
evaluation: "\xC9valuation",
|
|
1161
|
+
delivery: "Envoi",
|
|
1162
|
+
correction: "Corrig\xE9 par un humain"
|
|
973
1163
|
};
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
{ value: "danger", label: "\xC9checs" }
|
|
985
|
-
];
|
|
986
|
-
function buildFilter(escalated) {
|
|
987
|
-
return escalated ? { escalated: { eq: escalated === "true" } } : void 0;
|
|
1164
|
+
function buildTimeline(input) {
|
|
1165
|
+
return [
|
|
1166
|
+
step("received", receivedReason(input)),
|
|
1167
|
+
step("prompt", promptReason(input)),
|
|
1168
|
+
step("triage", triageReason(input)),
|
|
1169
|
+
step("draft", draftReason(input)),
|
|
1170
|
+
step("evaluation", evaluationReason(input)),
|
|
1171
|
+
step("delivery", deliveryReason(input)),
|
|
1172
|
+
step("correction", correctionReason(input))
|
|
1173
|
+
];
|
|
988
1174
|
}
|
|
989
|
-
function
|
|
990
|
-
return
|
|
1175
|
+
function step(key, reason2) {
|
|
1176
|
+
return reason2 === null ? { key, title: TITLES[key], reached: true } : { key, title: TITLES[key], reached: false, reason: reason2 };
|
|
991
1177
|
}
|
|
992
|
-
function
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
1178
|
+
function receivedReason({ conversation, conversationLoading }) {
|
|
1179
|
+
if (conversation) return null;
|
|
1180
|
+
if (conversationLoading) return "Lecture de la conversation en cours\u2026";
|
|
1181
|
+
return "Aucune conversation disponible : rien n'a \xE9t\xE9 captur\xE9 au moment du run, et le fil n'a pas pu \xEAtre relu chez Gorgias.";
|
|
1182
|
+
}
|
|
1183
|
+
function promptReason({ conversation, job, decision }) {
|
|
1184
|
+
if (!job) return noResponseCause(decision);
|
|
1185
|
+
if (conversation?.systemPrompt) return null;
|
|
1186
|
+
return "Le prompt rendu n'a pas \xE9t\xE9 captur\xE9 sur cette r\xE9ponse \u2014 les r\xE9ponses \xE9crites avant cette capture n'en gardent que le nom et la version.";
|
|
1187
|
+
}
|
|
1188
|
+
function triageReason({ decision }) {
|
|
1189
|
+
if (decision.status === "error" && !decision.tag) {
|
|
1190
|
+
return decision.error ?? "Le triage a \xE9chou\xE9 sans produire de classification.";
|
|
1191
|
+
}
|
|
1192
|
+
return null;
|
|
1193
|
+
}
|
|
1194
|
+
function draftReason({ job, decision }) {
|
|
1195
|
+
if (!job) return noResponseCause(decision);
|
|
1196
|
+
if (job.responseText) return null;
|
|
1197
|
+
if (job.status === "pending") return "La r\xE9daction n'a pas encore tourn\xE9.";
|
|
1198
|
+
return job.error ?? "La r\xE9daction n'a produit aucun texte.";
|
|
1199
|
+
}
|
|
1200
|
+
function evaluationReason({ job, decision }) {
|
|
1201
|
+
if (!job) return noResponseCause(decision);
|
|
1202
|
+
if (job.verdict) return null;
|
|
1203
|
+
if (job.status === "pending") return "L'\xE9valuation n'a pas encore tourn\xE9.";
|
|
1204
|
+
return "Aucun verdict : l'\xE9valuation n'a pas \xE9t\xE9 atteinte.";
|
|
1205
|
+
}
|
|
1206
|
+
function deliveryReason({ job, decision }) {
|
|
1207
|
+
if (!job) return noResponseCause(decision);
|
|
1208
|
+
switch (job.status) {
|
|
1209
|
+
case "sent":
|
|
1210
|
+
return null;
|
|
1211
|
+
case "pending":
|
|
1212
|
+
return "La r\xE9ponse est encore en file.";
|
|
1213
|
+
case "ready":
|
|
1214
|
+
return job.autoSendDecision === "hold" ? "Retenue avant envoi : l'\xE9valuation ou un garde-fou a bloqu\xE9 l'envoi automatique." : "R\xE9dig\xE9e, en attente d'un envoi.";
|
|
1215
|
+
case "expired":
|
|
1216
|
+
return "La r\xE9ponse a expir\xE9 avant son envoi.";
|
|
1217
|
+
case "failed":
|
|
1218
|
+
return job.error ?? "La r\xE9ponse a \xE9chou\xE9 avant son envoi.";
|
|
1219
|
+
default:
|
|
1220
|
+
return `La r\xE9ponse n'a pas \xE9t\xE9 envoy\xE9e (statut : ${job.status}).`;
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
function correctionReason({ comparisons }) {
|
|
1224
|
+
if (comparisons.length > 0) return null;
|
|
1225
|
+
return "Aucune correction captur\xE9e : l'agent n'a pas r\xE9\xE9crit de r\xE9ponse sur ce ticket.";
|
|
1226
|
+
}
|
|
1227
|
+
function noResponseCause(decision) {
|
|
1228
|
+
if (decision.escalated) return "Ticket escalad\xE9 \xE0 un humain \u2014 le graphe ne r\xE9dige pas.";
|
|
1229
|
+
if (decision.conversationOver) return "Conversation consid\xE9r\xE9e close \u2014 rien \xE0 r\xE9pondre.";
|
|
1230
|
+
if (decision.status === "error") return decision.error ?? "Le triage a \xE9chou\xE9.";
|
|
1231
|
+
return "La cat\xE9gorie n'a pas la r\xE9ponse rapide activ\xE9e, ou n'a pas d'agent r\xE9dacteur.";
|
|
1232
|
+
}
|
|
1233
|
+
function TimelinePanel(props) {
|
|
1234
|
+
const { decision, job, comparisons, conversation, conversationLoading, categoryName, onClose } = props;
|
|
1235
|
+
const steps = buildTimeline({ decision, job, comparisons, conversation, conversationLoading });
|
|
1236
|
+
return /* @__PURE__ */ jsx(SidePanel, { open: true, onClose, title: `Ticket ${decision.ticketId}`, description: categoryName, children: /* @__PURE__ */ jsxs("div", { className: "space-y-1 text-sm", children: [
|
|
1237
|
+
/* @__PURE__ */ jsx("p", { className: "pb-3", children: /* @__PURE__ */ jsx(TicketLink, { ticketId: decision.ticketId, url: decision.ticketUrl, label: "Ouvrir le ticket dans Gorgias" }) }),
|
|
1238
|
+
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))
|
|
1239
|
+
] }) });
|
|
1240
|
+
}
|
|
1241
|
+
function StepBlock({
|
|
1242
|
+
step: step2,
|
|
1243
|
+
index,
|
|
1244
|
+
last,
|
|
1245
|
+
children
|
|
999
1246
|
}) {
|
|
1000
|
-
return /* @__PURE__ */
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1247
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex gap-3", children: [
|
|
1248
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center", children: [
|
|
1249
|
+
/* @__PURE__ */ jsx(
|
|
1250
|
+
"span",
|
|
1251
|
+
{
|
|
1252
|
+
className: `flex h-6 w-6 shrink-0 items-center justify-center rounded-full border text-xs font-semibold ${step2.reached ? "border-primary/30 bg-primary/10 text-primary" : "border-muted bg-muted text-muted-foreground"}`,
|
|
1253
|
+
"aria-hidden": true,
|
|
1254
|
+
children: index + 1
|
|
1255
|
+
}
|
|
1256
|
+
),
|
|
1257
|
+
!last && /* @__PURE__ */ jsx("span", { className: "w-px flex-1 bg-border", "aria-hidden": true })
|
|
1005
1258
|
] }),
|
|
1006
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
1007
|
-
/* @__PURE__ */ jsx("p", { className: "
|
|
1008
|
-
/* @__PURE__ */ jsx("
|
|
1009
|
-
|
|
1259
|
+
/* @__PURE__ */ jsxs("div", { className: `min-w-0 flex-1 pb-5 ${step2.reached ? "" : "text-muted-foreground"}`, children: [
|
|
1260
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs font-semibold uppercase tracking-wider", children: step2.title }),
|
|
1261
|
+
step2.reached ? /* @__PURE__ */ jsx("div", { className: "mt-2 space-y-2", children }) : /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs", children: step2.reason })
|
|
1262
|
+
] })
|
|
1263
|
+
] });
|
|
1264
|
+
}
|
|
1265
|
+
function renderStep(key, props) {
|
|
1266
|
+
switch (key) {
|
|
1267
|
+
case "received":
|
|
1268
|
+
return /* @__PURE__ */ jsx(ReceivedStep, { ...props });
|
|
1269
|
+
case "prompt":
|
|
1270
|
+
return /* @__PURE__ */ jsx(PromptStep, { ...props });
|
|
1271
|
+
case "triage":
|
|
1272
|
+
return /* @__PURE__ */ jsx(TriageStep, { ...props });
|
|
1273
|
+
case "draft":
|
|
1274
|
+
return /* @__PURE__ */ jsx(DraftStep, { ...props });
|
|
1275
|
+
case "evaluation":
|
|
1276
|
+
return /* @__PURE__ */ jsx(EvaluationStep, { ...props });
|
|
1277
|
+
case "delivery":
|
|
1278
|
+
return /* @__PURE__ */ jsx(DeliveryStep, { ...props });
|
|
1279
|
+
case "correction":
|
|
1280
|
+
return /* @__PURE__ */ jsx(CorrectionStep, { ...props });
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
var ROLE_LABELS = { user: "Client", assistant: "Agent", tool: "Outil", system: "Syst\xE8me" };
|
|
1284
|
+
function ReceivedStep({ conversation }) {
|
|
1285
|
+
if (!conversation) return null;
|
|
1286
|
+
const note2 = CONVERSATION_ORIGIN_NOTE[conversation.origin];
|
|
1287
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1288
|
+
note2 && /* @__PURE__ */ jsx("p", { className: "text-xs italic text-muted-foreground", children: note2 }),
|
|
1289
|
+
conversation.messages.map((message, index) => /* @__PURE__ */ jsxs("div", { className: "rounded-md border p-2", children: [
|
|
1290
|
+
/* @__PURE__ */ jsx("p", { className: "text-[10px] font-semibold uppercase tracking-wider text-muted-foreground", children: ROLE_LABELS[message.role] ?? message.role }),
|
|
1291
|
+
/* @__PURE__ */ jsx("p", { className: "mt-1 whitespace-pre-wrap text-xs", children: message.content })
|
|
1292
|
+
] }, index))
|
|
1293
|
+
] });
|
|
1294
|
+
}
|
|
1295
|
+
function PromptStep({ conversation, job, langfuseConfig }) {
|
|
1296
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1297
|
+
/* @__PURE__ */ jsx(PromptAttribution, { name: job?.promptName ?? null, version: job?.promptVersion ?? null }),
|
|
1298
|
+
conversation?.systemPrompt && /* @__PURE__ */ jsx("pre", { className: "max-h-72 overflow-y-auto whitespace-pre-wrap rounded-md border p-3 text-xs", children: conversation.systemPrompt }),
|
|
1299
|
+
/* @__PURE__ */ jsx(LangfuseTraceLink, { traceId: job?.langfuseTraceId ?? null, config: langfuseConfig, label: "Trace g\xE9n\xE9ration" })
|
|
1300
|
+
] });
|
|
1301
|
+
}
|
|
1302
|
+
function TriageStep({ decision }) {
|
|
1303
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1304
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
1305
|
+
decision.tag && /* @__PURE__ */ jsx("code", { className: "rounded bg-muted px-1.5 py-0.5 text-xs", children: decision.tag }),
|
|
1306
|
+
decision.confidence && /* @__PURE__ */ jsxs(Badge, { variant: "neutral", children: [
|
|
1307
|
+
"Confiance ",
|
|
1308
|
+
TRIAGE_CONFIDENCE_LABELS[decision.confidence]
|
|
1309
|
+
] }),
|
|
1310
|
+
decision.escalated ? /* @__PURE__ */ jsx(Badge, { variant: "warning", children: "Escalad\xE9" }) : /* @__PURE__ */ jsx(Badge, { variant: "neutral", children: "Non escalad\xE9" }),
|
|
1311
|
+
decision.conversationOver && /* @__PURE__ */ jsx(Badge, { variant: "neutral", children: "Conversation close" }),
|
|
1312
|
+
decision.subjectRenamed && /* @__PURE__ */ jsx(Badge, { variant: "neutral", children: "Sujet renomm\xE9" })
|
|
1010
1313
|
] }),
|
|
1011
|
-
decision.
|
|
1012
|
-
|
|
1013
|
-
/* @__PURE__ */ jsxs("p", { children: [
|
|
1014
|
-
"
|
|
1015
|
-
" ",
|
|
1314
|
+
decision.reasoning && /* @__PURE__ */ jsx("p", { className: "text-xs", children: decision.reasoning }),
|
|
1315
|
+
decision.escalated && /* @__PURE__ */ jsxs("div", { className: "rounded-md border border-status-warning/25 bg-status-warning/5 p-2", children: [
|
|
1316
|
+
/* @__PURE__ */ jsxs("p", { className: "text-[10px] font-semibold uppercase tracking-wider text-muted-foreground", children: [
|
|
1317
|
+
"Escalade \u2014 confiance ",
|
|
1016
1318
|
decision.escalationConfidence ? TRIAGE_CONFIDENCE_LABELS[decision.escalationConfidence] : "\u2014"
|
|
1017
1319
|
] }),
|
|
1018
|
-
|
|
1320
|
+
/* @__PURE__ */ jsx("p", { className: "mt-1 text-xs", children: decision.escalationReasoning ?? decision.reasoning ?? "\u2014" })
|
|
1019
1321
|
] }),
|
|
1020
|
-
/* @__PURE__ */
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
] })
|
|
1045
|
-
] }),
|
|
1046
|
-
job.responseText && /* @__PURE__ */ jsxs("div", { children: [
|
|
1047
|
-
/* @__PURE__ */ jsx("pre", { className: "whitespace-pre-wrap rounded-md border p-3 text-xs", children: job.responseText }),
|
|
1048
|
-
/* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(CopyButton, { value: job.responseText, label: "Copier la r\xE9ponse" }) })
|
|
1049
|
-
] }),
|
|
1050
|
-
job.verdict?.reason && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: job.verdict.reason }),
|
|
1051
|
-
job.guardrailHits.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1", children: job.guardrailHits.map((hit, index) => /* @__PURE__ */ jsx("code", { className: "rounded bg-status-warning/10 px-1.5 py-0.5 text-xs text-status-warning", children: guardrailHitLabel(hit) }, `${hit}-${index}`)) }),
|
|
1052
|
-
job.error && /* @__PURE__ */ jsxs("div", { className: "rounded-md bg-destructive/10 p-3 text-destructive", children: [
|
|
1053
|
-
"Erreur : ",
|
|
1054
|
-
job.error
|
|
1055
|
-
] }),
|
|
1056
|
-
job.sentAt && /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
1057
|
-
"Envoy\xE9e le ",
|
|
1058
|
-
formatDate(job.sentAt)
|
|
1059
|
-
] }),
|
|
1060
|
-
(job.promptName || job.sentMessageId) && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground", children: [
|
|
1061
|
-
job.promptName && /* @__PURE__ */ jsxs("span", { children: [
|
|
1062
|
-
"Prompt : ",
|
|
1063
|
-
/* @__PURE__ */ jsx("code", { children: job.promptName }),
|
|
1064
|
-
job.promptVersion !== null ? ` v${job.promptVersion}` : ""
|
|
1065
|
-
] }),
|
|
1066
|
-
job.sentMessageId && /* @__PURE__ */ jsxs("span", { children: [
|
|
1067
|
-
"Message Gorgias : ",
|
|
1068
|
-
job.sentMessageId
|
|
1069
|
-
] })
|
|
1070
|
-
] }),
|
|
1071
|
-
(job.langfuseTraceId || job.langfuseObservationId) && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
|
|
1072
|
-
/* @__PURE__ */ jsx(LangfuseTraceLink, { traceId: job.langfuseTraceId, config: langfuseConfig, label: "Trace g\xE9n\xE9ration" }),
|
|
1073
|
-
/* @__PURE__ */ jsx(
|
|
1074
|
-
LangfuseTraceLink,
|
|
1075
|
-
{
|
|
1076
|
-
traceId: job.langfuseTraceId,
|
|
1077
|
-
observationId: job.langfuseObservationId,
|
|
1078
|
-
config: langfuseConfig,
|
|
1079
|
-
label: "Trace \xE9valuation"
|
|
1080
|
-
}
|
|
1081
|
-
)
|
|
1322
|
+
decision.status === "error" && decision.error && /* @__PURE__ */ jsx("div", { className: "rounded-md bg-destructive/10 p-2 text-xs text-destructive", children: decision.error }),
|
|
1323
|
+
/* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
1324
|
+
"D\xE9cid\xE9 le ",
|
|
1325
|
+
formatDate(decision.decidedAt)
|
|
1326
|
+
] })
|
|
1327
|
+
] });
|
|
1328
|
+
}
|
|
1329
|
+
function DraftStep({ job, agentName }) {
|
|
1330
|
+
if (!job?.responseText) return null;
|
|
1331
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1332
|
+
/* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
1333
|
+
"Agent : ",
|
|
1334
|
+
agentName,
|
|
1335
|
+
job.channel ? ` \xB7 Canal : ${job.channel}` : ""
|
|
1336
|
+
] }),
|
|
1337
|
+
/* @__PURE__ */ jsx("pre", { className: "max-h-72 overflow-y-auto whitespace-pre-wrap rounded-md border p-3 text-xs", children: job.responseText }),
|
|
1338
|
+
/* @__PURE__ */ jsx(CopyButton, { value: job.responseText, label: "Copier la r\xE9ponse" }),
|
|
1339
|
+
job.sources.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
|
|
1340
|
+
/* @__PURE__ */ jsx("p", { className: "text-[10px] font-semibold uppercase tracking-wider text-muted-foreground", children: "Outils appel\xE9s" }),
|
|
1341
|
+
/* @__PURE__ */ jsx("ul", { className: "mt-1 space-y-1", children: job.sources.map((source, index) => /* @__PURE__ */ jsxs("li", { className: "text-xs", children: [
|
|
1342
|
+
/* @__PURE__ */ jsx("code", { children: source.name }),
|
|
1343
|
+
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
|
|
1344
|
+
" \u2192 ",
|
|
1345
|
+
source.observation
|
|
1082
1346
|
] })
|
|
1083
|
-
] }
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1347
|
+
] }, index)) })
|
|
1348
|
+
] })
|
|
1349
|
+
] });
|
|
1350
|
+
}
|
|
1351
|
+
function EvaluationStep({ job, langfuseConfig }) {
|
|
1352
|
+
const verdict = job?.verdict;
|
|
1353
|
+
if (!verdict) return null;
|
|
1354
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1355
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
1356
|
+
verdict.verdict && /* @__PURE__ */ jsx(Badge, { variant: verdict.verdict === "hold" ? "warning" : "success", children: EVALUATION_VERDICT_LABELS[verdict.verdict] }),
|
|
1357
|
+
verdict.confidence !== null && /* @__PURE__ */ jsxs("span", { className: "text-xs tabular-nums", children: [
|
|
1358
|
+
Math.round(verdict.confidence * 100),
|
|
1359
|
+
" %"
|
|
1087
1360
|
] })
|
|
1088
1361
|
] }),
|
|
1089
|
-
/* @__PURE__ */
|
|
1090
|
-
|
|
1091
|
-
|
|
1362
|
+
verdict.reason && /* @__PURE__ */ jsx("p", { className: "text-xs", children: verdict.reason }),
|
|
1363
|
+
job && job.guardrailHits.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1", children: job.guardrailHits.map((hit, index) => /* @__PURE__ */ jsx("code", { className: "rounded bg-status-warning/10 px-1.5 py-0.5 text-xs text-status-warning", children: guardrailHitLabel(hit) }, `${hit}-${index}`)) }),
|
|
1364
|
+
/* @__PURE__ */ jsx(
|
|
1365
|
+
LangfuseTraceLink,
|
|
1366
|
+
{
|
|
1367
|
+
traceId: job?.langfuseTraceId ?? null,
|
|
1368
|
+
observationId: verdict.observationId ?? job?.langfuseObservationId ?? null,
|
|
1369
|
+
config: langfuseConfig,
|
|
1370
|
+
label: "Trace \xE9valuation"
|
|
1371
|
+
}
|
|
1372
|
+
)
|
|
1373
|
+
] });
|
|
1374
|
+
}
|
|
1375
|
+
function DeliveryStep({ job }) {
|
|
1376
|
+
if (!job) return null;
|
|
1377
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1378
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
1379
|
+
/* @__PURE__ */ jsx(Badge, { variant: "success", children: "Envoy\xE9e" }),
|
|
1380
|
+
job.autoSendDecision === "auto" && /* @__PURE__ */ jsx(Badge, { variant: "neutral", children: "Envoi automatique" })
|
|
1381
|
+
] }),
|
|
1382
|
+
/* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
1383
|
+
"Envoy\xE9e le ",
|
|
1384
|
+
formatDate(job.sentAt)
|
|
1385
|
+
] }),
|
|
1386
|
+
job.sentMessageId && /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
1387
|
+
"Message Gorgias : ",
|
|
1388
|
+
/* @__PURE__ */ jsx("code", { children: job.sentMessageId })
|
|
1092
1389
|
] })
|
|
1093
|
-
] })
|
|
1390
|
+
] });
|
|
1391
|
+
}
|
|
1392
|
+
function CorrectionStep({ comparisons, langfuseConfig }) {
|
|
1393
|
+
return /* @__PURE__ */ jsx(Fragment, { children: comparisons.map((comparison) => {
|
|
1394
|
+
const pct = matchPercentage(comparison);
|
|
1395
|
+
const tokens = tokensFor(comparison);
|
|
1396
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-2 rounded-md border p-2", children: [
|
|
1397
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
1398
|
+
pct !== null && /* @__PURE__ */ jsxs(Badge, { className: matchBadgeClass(pct), children: [
|
|
1399
|
+
pct,
|
|
1400
|
+
" % de correspondance"
|
|
1401
|
+
] }),
|
|
1402
|
+
/* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground", children: [
|
|
1403
|
+
"Captur\xE9 le ",
|
|
1404
|
+
formatDate(comparison.capturedAt)
|
|
1405
|
+
] })
|
|
1406
|
+
] }),
|
|
1407
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-2", children: [
|
|
1408
|
+
/* @__PURE__ */ jsx(WordDiffView, { title: "G\xE9n\xE9r\xE9 par l'IA", tokens, keep: "delete" }),
|
|
1409
|
+
/* @__PURE__ */ jsx(WordDiffView, { title: "Envoy\xE9 par l'agent", tokens, keep: "insert" })
|
|
1410
|
+
] }),
|
|
1411
|
+
/* @__PURE__ */ jsx(PromptAttribution, { name: comparison.promptName, version: comparison.promptVersion }),
|
|
1412
|
+
/* @__PURE__ */ jsx(
|
|
1413
|
+
LangfuseTraceLink,
|
|
1414
|
+
{
|
|
1415
|
+
traceId: comparison.langfuseTraceId,
|
|
1416
|
+
observationId: comparison.langfuseObservationId,
|
|
1417
|
+
config: langfuseConfig,
|
|
1418
|
+
label: "Trace de la r\xE9ponse corrig\xE9e"
|
|
1419
|
+
}
|
|
1420
|
+
)
|
|
1421
|
+
] }, comparison.id);
|
|
1422
|
+
}) });
|
|
1423
|
+
}
|
|
1424
|
+
function PromptAttribution({ name, version }) {
|
|
1425
|
+
if (!name) return null;
|
|
1426
|
+
return /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
1427
|
+
"Prompt : ",
|
|
1428
|
+
/* @__PURE__ */ jsx("code", { children: name }),
|
|
1429
|
+
version !== null ? ` v${version}` : ""
|
|
1430
|
+
] });
|
|
1431
|
+
}
|
|
1432
|
+
var DECISIONS_PAGE_SIZE = 50;
|
|
1433
|
+
var JOIN_WINDOW_SIZE = 500;
|
|
1434
|
+
var OUTCOME_BADGE_VARIANT = {
|
|
1435
|
+
neutral: "neutral",
|
|
1436
|
+
success: "success",
|
|
1437
|
+
warning: "warning",
|
|
1438
|
+
danger: "danger"
|
|
1439
|
+
};
|
|
1440
|
+
var ESCALATED_OPTIONS = [
|
|
1441
|
+
{ value: "", label: "Toutes d\xE9cisions" },
|
|
1442
|
+
{ value: "true", label: "Escalad\xE9s" },
|
|
1443
|
+
{ value: "false", label: "Non escalad\xE9s" }
|
|
1444
|
+
];
|
|
1445
|
+
var CONFIDENCE_OPTIONS = [
|
|
1446
|
+
{ value: "", label: "Toutes confiances" },
|
|
1447
|
+
{ value: "high", label: TRIAGE_CONFIDENCE_LABELS.high },
|
|
1448
|
+
{ value: "low", label: TRIAGE_CONFIDENCE_LABELS.low }
|
|
1449
|
+
];
|
|
1450
|
+
var OUTCOME_FILTER_OPTIONS = [
|
|
1451
|
+
{ value: "", label: "Tous les r\xE9sultats" },
|
|
1452
|
+
{ value: "none", label: "Aucune r\xE9ponse g\xE9n\xE9r\xE9e" },
|
|
1453
|
+
{ value: "success", label: "Envoy\xE9es" },
|
|
1454
|
+
{ value: "warning", label: "Bloqu\xE9es" },
|
|
1455
|
+
{ value: "danger", label: "\xC9checs" }
|
|
1456
|
+
];
|
|
1457
|
+
var VERDICT_OPTIONS = [
|
|
1458
|
+
{ value: "", label: "Tous les verdicts" },
|
|
1459
|
+
...EVALUATION_VERDICTS.map((verdict) => ({ value: verdict, label: EVALUATION_VERDICT_LABELS[verdict] }))
|
|
1460
|
+
];
|
|
1461
|
+
var CORRECTED_OPTIONS = [
|
|
1462
|
+
{ value: "", label: "Corrig\xE9s ou non" },
|
|
1463
|
+
{ value: "true", label: "Corrig\xE9s par un humain" },
|
|
1464
|
+
{ value: "false", label: "Non corrig\xE9s" }
|
|
1465
|
+
];
|
|
1466
|
+
function OutcomeBadge({ outcome }) {
|
|
1467
|
+
return /* @__PURE__ */ jsx(Badge, { variant: OUTCOME_BADGE_VARIANT[outcome.variant], children: outcome.label });
|
|
1094
1468
|
}
|
|
1095
1469
|
function TicketsPage() {
|
|
1470
|
+
const { role } = useAppContext();
|
|
1471
|
+
const canWrite = canWriteForRole(role);
|
|
1472
|
+
const api = useAppApi();
|
|
1473
|
+
const toast = useToast();
|
|
1474
|
+
const { settings } = useAppSettings();
|
|
1475
|
+
const [period, setPeriod] = useState(() => defaultPeriod());
|
|
1476
|
+
const [categoryFilter, setCategoryFilter] = useState("");
|
|
1096
1477
|
const [escalatedFilter, setEscalatedFilter] = useState("");
|
|
1478
|
+
const [confidenceFilter, setConfidenceFilter] = useState("");
|
|
1097
1479
|
const [outcomeFilter, setOutcomeFilter] = useState("");
|
|
1480
|
+
const [verdictFilter, setVerdictFilter] = useState("");
|
|
1481
|
+
const [promptVersionFilter, setPromptVersionFilter] = useState("");
|
|
1482
|
+
const [correctedFilter, setCorrectedFilter] = useState("");
|
|
1098
1483
|
const [detailDecision, setDetailDecision] = useState(null);
|
|
1484
|
+
const [isTriaging, setIsTriaging] = useState(false);
|
|
1485
|
+
const [triageInFlight] = useState(() => ({ current: false }));
|
|
1486
|
+
const periodKey = JSON.stringify(period);
|
|
1487
|
+
const bounds = useMemo(() => periodBoundsOf(JSON.parse(periodKey)).current, [periodKey]);
|
|
1488
|
+
const decisionFilter = useMemo(() => {
|
|
1489
|
+
const filter = { decidedAt: { gte: bounds.fromIso, lte: bounds.toIso } };
|
|
1490
|
+
if (categoryFilter) filter.categoryId = { eq: categoryFilter };
|
|
1491
|
+
if (escalatedFilter) filter.escalated = { eq: escalatedFilter === "true" };
|
|
1492
|
+
if (confidenceFilter) filter.confidence = { eq: confidenceFilter };
|
|
1493
|
+
return filter;
|
|
1494
|
+
}, [bounds.fromIso, bounds.toIso, categoryFilter, escalatedFilter, confidenceFilter]);
|
|
1099
1495
|
const {
|
|
1100
1496
|
rows: decisions,
|
|
1101
1497
|
isLoading: decisionsLoading,
|
|
@@ -1108,7 +1504,7 @@ function TicketsPage() {
|
|
|
1108
1504
|
} = useRecordList(
|
|
1109
1505
|
"triage-decision",
|
|
1110
1506
|
{
|
|
1111
|
-
filter:
|
|
1507
|
+
filter: decisionFilter,
|
|
1112
1508
|
sort: [{ field: "decidedAt", direction: "desc" }],
|
|
1113
1509
|
limit: DECISIONS_PAGE_SIZE,
|
|
1114
1510
|
paginate: true
|
|
@@ -1122,17 +1518,34 @@ function TicketsPage() {
|
|
|
1122
1518
|
refresh: refreshJobs
|
|
1123
1519
|
} = useRecordList(
|
|
1124
1520
|
"generated-response",
|
|
1125
|
-
{
|
|
1521
|
+
{
|
|
1522
|
+
filter: { generatedAt: { gte: bounds.fromIso, lte: bounds.toIso } },
|
|
1523
|
+
sort: [{ field: "generatedAt", direction: "desc" }],
|
|
1524
|
+
limit: JOIN_WINDOW_SIZE
|
|
1525
|
+
},
|
|
1126
1526
|
toGeneratedResponse
|
|
1127
1527
|
);
|
|
1128
|
-
const {
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
}
|
|
1528
|
+
const {
|
|
1529
|
+
rows: comparisons,
|
|
1530
|
+
error: comparisonsError,
|
|
1531
|
+
refresh: refreshComparisons
|
|
1532
|
+
} = useRecordList(
|
|
1533
|
+
"response-comparison",
|
|
1534
|
+
{
|
|
1535
|
+
filter: { capturedAt: { gte: bounds.fromIso } },
|
|
1536
|
+
sort: [{ field: "capturedAt", direction: "desc" }],
|
|
1537
|
+
limit: JOIN_WINDOW_SIZE
|
|
1538
|
+
},
|
|
1539
|
+
toResponseComparison
|
|
1540
|
+
);
|
|
1133
1541
|
const { rows: categories } = useRecordList("category", { limit: 500 }, toCategory);
|
|
1134
1542
|
const categoryNames = useMemo(() => toNameMap(categories), [categories]);
|
|
1543
|
+
const { rows: agents } = useRecordList("agent", { limit: 500 }, toAgent);
|
|
1544
|
+
const agentNames = useMemo(() => toNameMap(agents), [agents]);
|
|
1135
1545
|
const { config: langfuseConfig } = useLangfuseConfig();
|
|
1546
|
+
function refreshAll() {
|
|
1547
|
+
return Promise.all([refreshDecisions(), refreshJobs(), refreshComparisons()]).then(() => void 0);
|
|
1548
|
+
}
|
|
1136
1549
|
const jobByDecisionId = useMemo(() => {
|
|
1137
1550
|
const map = /* @__PURE__ */ new Map();
|
|
1138
1551
|
for (const job of jobs) {
|
|
@@ -1140,80 +1553,167 @@ function TicketsPage() {
|
|
|
1140
1553
|
}
|
|
1141
1554
|
return map;
|
|
1142
1555
|
}, [jobs]);
|
|
1143
|
-
const
|
|
1556
|
+
const comparisonsByTicketId = useMemo(() => {
|
|
1557
|
+
const map = /* @__PURE__ */ new Map();
|
|
1558
|
+
for (const comparison of comparisons) {
|
|
1559
|
+
if (!comparison.ticketId) continue;
|
|
1560
|
+
const list2 = map.get(comparison.ticketId);
|
|
1561
|
+
if (list2) list2.push(comparison);
|
|
1562
|
+
else map.set(comparison.ticketId, [comparison]);
|
|
1563
|
+
}
|
|
1564
|
+
return map;
|
|
1565
|
+
}, [comparisons]);
|
|
1566
|
+
const joinWindowMayBeIncomplete = jobs.length >= JOIN_WINDOW_SIZE || comparisons.length >= JOIN_WINDOW_SIZE;
|
|
1567
|
+
const promptVersions = useMemo(() => {
|
|
1568
|
+
const versions = /* @__PURE__ */ new Set();
|
|
1569
|
+
for (const job of jobs) {
|
|
1570
|
+
if (job.promptVersion !== null) versions.add(job.promptVersion);
|
|
1571
|
+
}
|
|
1572
|
+
return [...versions].sort((a, b) => b - a);
|
|
1573
|
+
}, [jobs]);
|
|
1574
|
+
const promptVersionOptions = useMemo(
|
|
1575
|
+
() => [
|
|
1576
|
+
{ value: "", label: "Toutes versions de prompt" },
|
|
1577
|
+
...promptVersions.map((version) => ({ value: String(version), label: `v${version}` }))
|
|
1578
|
+
],
|
|
1579
|
+
[promptVersions]
|
|
1580
|
+
);
|
|
1144
1581
|
const rows = useMemo(() => {
|
|
1145
|
-
const
|
|
1582
|
+
const joined = decisions.map((decision) => ({
|
|
1146
1583
|
decision,
|
|
1147
|
-
job: jobByDecisionId.get(decision.id)
|
|
1584
|
+
job: jobByDecisionId.get(decision.id),
|
|
1585
|
+
comparisons: comparisonsByTicketId.get(decision.ticketId) ?? []
|
|
1148
1586
|
}));
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1587
|
+
return joined.filter((row) => {
|
|
1588
|
+
if (outcomeFilter === "none" && row.job) return false;
|
|
1589
|
+
if (outcomeFilter && outcomeFilter !== "none" && (!row.job || responseOutcome(row.job).variant !== outcomeFilter)) return false;
|
|
1590
|
+
if (verdictFilter && row.job?.verdict?.verdict !== verdictFilter) return false;
|
|
1591
|
+
if (promptVersionFilter && String(row.job?.promptVersion ?? "") !== promptVersionFilter) return false;
|
|
1592
|
+
if (correctedFilter === "true" && row.comparisons.length === 0) return false;
|
|
1593
|
+
if (correctedFilter === "false" && row.comparisons.length > 0) return false;
|
|
1594
|
+
return true;
|
|
1595
|
+
});
|
|
1596
|
+
}, [decisions, jobByDecisionId, comparisonsByTicketId, outcomeFilter, verdictFilter, promptVersionFilter, correctedFilter]);
|
|
1597
|
+
const categoryOptions = useMemo(
|
|
1598
|
+
() => [{ value: "", label: "Toutes cat\xE9gories" }, ...categories.map((category) => ({ value: category.id, label: category.name }))],
|
|
1599
|
+
[categories]
|
|
1600
|
+
);
|
|
1601
|
+
async function runTriageNow() {
|
|
1602
|
+
if (triageInFlight.current) return;
|
|
1603
|
+
triageInFlight.current = true;
|
|
1604
|
+
setIsTriaging(true);
|
|
1605
|
+
try {
|
|
1606
|
+
const result = await api.invoke(
|
|
1607
|
+
"run-triage-now",
|
|
1608
|
+
{},
|
|
1609
|
+
{ idempotencyKey: idempotencyKeyFor("run-triage-now", {}) }
|
|
1610
|
+
);
|
|
1611
|
+
toast(
|
|
1612
|
+
result.status === "already-running" ? { title: "Un triage est d\xE9j\xE0 en cours \u2014 aucun second lot n\u2019a \xE9t\xE9 lanc\xE9.", variant: "info" } : { title: "Triage lanc\xE9 \u2014 suivez le run pour son avancement.", variant: "success" }
|
|
1613
|
+
);
|
|
1614
|
+
await refreshAll();
|
|
1615
|
+
} catch (err) {
|
|
1616
|
+
toast({ title: "\xC9chec du lancement du triage", description: describeInvokeError(err), variant: "error" });
|
|
1617
|
+
} finally {
|
|
1618
|
+
triageInFlight.current = false;
|
|
1619
|
+
setIsTriaging(false);
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1153
1622
|
const columns = [
|
|
1154
1623
|
{ key: "ticketId", header: "Ticket", cell: ({ decision }) => /* @__PURE__ */ jsx(TicketLink, { ticketId: decision.ticketId, url: decision.ticketUrl }) },
|
|
1155
|
-
{
|
|
1156
|
-
key: "category",
|
|
1157
|
-
header: "Cat\xE9gorie",
|
|
1158
|
-
cell: ({ decision }) => decision.categoryId && categoryNames.get(decision.categoryId) || "\u2014"
|
|
1159
|
-
},
|
|
1624
|
+
{ key: "category", header: "Cat\xE9gorie", cell: ({ decision }) => decision.categoryId && categoryNames.get(decision.categoryId) || "\u2014" },
|
|
1160
1625
|
{ key: "tag", header: "Tag", cell: ({ decision }) => decision.tag ? /* @__PURE__ */ jsx("code", { className: "text-xs", children: decision.tag }) : "\u2014" },
|
|
1161
1626
|
{
|
|
1162
|
-
key: "
|
|
1163
|
-
header: "
|
|
1164
|
-
|
|
1165
|
-
// surface of this page in pass 1 (T27 rework, pass 2 of 2), so an
|
|
1166
|
-
// errored triage was indistinguishable from a clean one at a glance.
|
|
1167
|
-
cell: ({ decision }) => decision.status === "error" ? /* @__PURE__ */ jsx(Badge, { variant: "danger", children: TRIAGE_DECISION_STATUS_LABELS.error }) : /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "\u2014" })
|
|
1627
|
+
key: "confidence",
|
|
1628
|
+
header: "Confiance",
|
|
1629
|
+
cell: ({ decision }) => decision.confidence ? TRIAGE_CONFIDENCE_LABELS[decision.confidence] : "\u2014"
|
|
1168
1630
|
},
|
|
1169
1631
|
{
|
|
1170
1632
|
key: "escalated",
|
|
1171
1633
|
header: "Escalade",
|
|
1172
|
-
cell: ({ decision }) =>
|
|
1634
|
+
cell: ({ decision }) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0.5", children: [
|
|
1635
|
+
decision.escalated ? /* @__PURE__ */ jsx(Badge, { variant: "warning", children: "Escalad\xE9" }) : /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "Non escalad\xE9" }),
|
|
1636
|
+
decision.status === "error" && /* @__PURE__ */ jsx(Badge, { variant: "danger", className: "w-fit text-[10px]", children: TRIAGE_DECISION_STATUS_LABELS.error })
|
|
1637
|
+
] })
|
|
1638
|
+
},
|
|
1639
|
+
{
|
|
1640
|
+
key: "verdict",
|
|
1641
|
+
header: "Verdict",
|
|
1642
|
+
cell: ({ job }) => job?.verdict?.verdict ? /* @__PURE__ */ jsx(Badge, { variant: job.verdict.verdict === "hold" ? "warning" : "success", children: EVALUATION_VERDICT_LABELS[job.verdict.verdict] }) : "\u2014"
|
|
1643
|
+
},
|
|
1644
|
+
{
|
|
1645
|
+
key: "autoSendDecision",
|
|
1646
|
+
header: "Envoi auto",
|
|
1647
|
+
cell: ({ job }) => job?.autoSendDecision ? /* @__PURE__ */ jsx(Badge, { variant: job.autoSendDecision === "auto" ? "success" : "warning", children: AUTO_SEND_DECISION_LABELS[job.autoSendDecision] }) : "\u2014"
|
|
1173
1648
|
},
|
|
1174
1649
|
{ key: "outcome", header: "R\xE9ponse", cell: ({ job }) => /* @__PURE__ */ jsx(OutcomeBadge, { outcome: responseOutcome(job) }) },
|
|
1650
|
+
{
|
|
1651
|
+
key: "match",
|
|
1652
|
+
header: "Correspondance",
|
|
1653
|
+
cell: ({ comparisons: rowComparisons }) => {
|
|
1654
|
+
const latest = rowComparisons[0];
|
|
1655
|
+
const pct = latest ? matchPercentage(latest) : null;
|
|
1656
|
+
return pct === null ? /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "\u2014" }) : /* @__PURE__ */ jsxs(Badge, { className: matchBadgeClass(pct), children: [
|
|
1657
|
+
pct,
|
|
1658
|
+
" %"
|
|
1659
|
+
] });
|
|
1660
|
+
}
|
|
1661
|
+
},
|
|
1662
|
+
{
|
|
1663
|
+
key: "langfuse",
|
|
1664
|
+
header: "Langfuse",
|
|
1665
|
+
cell: ({ job }) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", onClick: (e) => e.stopPropagation(), children: [
|
|
1666
|
+
/* @__PURE__ */ jsx(LangfuseTraceLink, { traceId: job?.langfuseTraceId ?? null, config: langfuseConfig, label: "G\xE9n\xE9ration" }),
|
|
1667
|
+
/* @__PURE__ */ jsx(
|
|
1668
|
+
LangfuseTraceLink,
|
|
1669
|
+
{
|
|
1670
|
+
traceId: job?.langfuseTraceId ?? null,
|
|
1671
|
+
observationId: job?.verdict?.observationId ?? job?.langfuseObservationId ?? null,
|
|
1672
|
+
config: langfuseConfig,
|
|
1673
|
+
label: "\xC9valuation"
|
|
1674
|
+
}
|
|
1675
|
+
)
|
|
1676
|
+
] })
|
|
1677
|
+
},
|
|
1175
1678
|
{ key: "decidedAt", header: "D\xE9cid\xE9 le", cell: ({ decision }) => formatDate(decision.decidedAt) }
|
|
1176
1679
|
];
|
|
1680
|
+
const detailRow = detailDecision ? rows.find((row) => row.decision.id === detailDecision.id) : void 0;
|
|
1681
|
+
const liveConversation = useLiveConversation(detailDecision, detailRow);
|
|
1177
1682
|
const isLoading = decisionsLoading || jobsLoading;
|
|
1178
|
-
const combinedError = decisionsError ?? jobsError;
|
|
1683
|
+
const combinedError = decisionsError ?? jobsError ?? comparisonsError;
|
|
1179
1684
|
return /* @__PURE__ */ jsxs(PageShell, { children: [
|
|
1180
1685
|
/* @__PURE__ */ jsx(
|
|
1181
1686
|
PageHeader,
|
|
1182
1687
|
{
|
|
1183
|
-
title: "
|
|
1184
|
-
description: "
|
|
1185
|
-
actions: /* @__PURE__ */
|
|
1688
|
+
title: "Tickets",
|
|
1689
|
+
description: "Tout ticket vu par le graphe, et le parcours de chacun.",
|
|
1690
|
+
actions: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
1691
|
+
settings && /* @__PURE__ */ jsxs(Badge, { variant: settings.autoSendEnabled ? "success" : "neutral", children: [
|
|
1692
|
+
"Envoi auto : ",
|
|
1693
|
+
settings.autoSendEnabled ? "ACTIF" : "INACTIF"
|
|
1694
|
+
] }),
|
|
1695
|
+
/* @__PURE__ */ jsx(DateRangeCompare, { value: period, onChange: setPeriod, presets: DASHBOARD_PRESETS, align: "end" }),
|
|
1696
|
+
/* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => void refreshAll(), children: "Actualiser" }),
|
|
1697
|
+
canWrite && /* @__PURE__ */ jsx(Button, { onClick: () => void runTriageNow(), disabled: isTriaging, children: isTriaging ? "Triage en cours\u2026" : "Lancer le triage maintenant" })
|
|
1698
|
+
] })
|
|
1186
1699
|
}
|
|
1187
1700
|
),
|
|
1188
1701
|
joinWindowMayBeIncomplete && /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
1189
|
-
"
|
|
1190
|
-
|
|
1191
|
-
" derni\xE8res r\xE9ponses g\xE9n\xE9r\xE9es \u2014 au-del\xE0,
|
|
1702
|
+
"Les jointures ne lisent que les ",
|
|
1703
|
+
JOIN_WINDOW_SIZE,
|
|
1704
|
+
" derni\xE8res r\xE9ponses g\xE9n\xE9r\xE9es et corrections de la p\xE9riode \u2014 au-del\xE0, une r\xE9ponse ou une correction absente ici peut \xEAtre un simple effet de fen\xEAtre, pas un fait."
|
|
1192
1705
|
] }),
|
|
1193
1706
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
|
|
1194
|
-
/* @__PURE__ */ jsx(
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
"aria-label": "Filtrer par d\xE9cision"
|
|
1202
|
-
}
|
|
1203
|
-
),
|
|
1204
|
-
/* @__PURE__ */ jsx(
|
|
1205
|
-
Select,
|
|
1206
|
-
{
|
|
1207
|
-
items: OUTCOME_FILTER_OPTIONS,
|
|
1208
|
-
value: outcomeFilter,
|
|
1209
|
-
onValueChange: setOutcomeFilter,
|
|
1210
|
-
placeholder: "Tous les r\xE9sultats",
|
|
1211
|
-
"aria-label": "Filtrer par r\xE9sultat de r\xE9ponse"
|
|
1212
|
-
}
|
|
1213
|
-
),
|
|
1707
|
+
/* @__PURE__ */ jsx(Select, { items: categoryOptions, value: categoryFilter, onValueChange: setCategoryFilter, placeholder: "Toutes cat\xE9gories", "aria-label": "Filtrer par cat\xE9gorie" }),
|
|
1708
|
+
/* @__PURE__ */ jsx(Select, { items: ESCALATED_OPTIONS, value: escalatedFilter, onValueChange: setEscalatedFilter, placeholder: "Toutes d\xE9cisions", "aria-label": "Filtrer par d\xE9cision" }),
|
|
1709
|
+
/* @__PURE__ */ jsx(Select, { items: CONFIDENCE_OPTIONS, value: confidenceFilter, onValueChange: setConfidenceFilter, placeholder: "Toutes confiances", "aria-label": "Filtrer par confiance" }),
|
|
1710
|
+
/* @__PURE__ */ jsx(Select, { items: OUTCOME_FILTER_OPTIONS, value: outcomeFilter, onValueChange: setOutcomeFilter, placeholder: "Tous les r\xE9sultats", "aria-label": "Filtrer par r\xE9sultat de r\xE9ponse" }),
|
|
1711
|
+
/* @__PURE__ */ jsx(Select, { items: VERDICT_OPTIONS, value: verdictFilter, onValueChange: setVerdictFilter, placeholder: "Tous les verdicts", "aria-label": "Filtrer par verdict" }),
|
|
1712
|
+
/* @__PURE__ */ jsx(Select, { items: promptVersionOptions, value: promptVersionFilter, onValueChange: setPromptVersionFilter, placeholder: "Toutes versions de prompt", "aria-label": "Filtrer par version de prompt" }),
|
|
1713
|
+
/* @__PURE__ */ jsx(Select, { items: CORRECTED_OPTIONS, value: correctedFilter, onValueChange: setCorrectedFilter, placeholder: "Corrig\xE9s ou non", "aria-label": "Filtrer par correction humaine" }),
|
|
1214
1714
|
rows.length > 0 && /* @__PURE__ */ jsxs("span", { className: "ml-auto text-sm text-muted-foreground", children: [
|
|
1215
1715
|
rows.length,
|
|
1216
|
-
"
|
|
1716
|
+
" ticket",
|
|
1217
1717
|
rows.length > 1 ? "s" : "",
|
|
1218
1718
|
" sur cette page"
|
|
1219
1719
|
] })
|
|
@@ -1234,742 +1734,203 @@ function TicketsPage() {
|
|
|
1234
1734
|
onPrevious: goToPreviousPage
|
|
1235
1735
|
},
|
|
1236
1736
|
error: combinedError !== void 0 ? /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-3", children: [
|
|
1237
|
-
"Erreur lors du chargement des
|
|
1238
|
-
/* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: () => void
|
|
1737
|
+
"Erreur lors du chargement des tickets.",
|
|
1738
|
+
/* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: () => void refreshAll(), children: "R\xE9essayer" })
|
|
1239
1739
|
] }) : void 0,
|
|
1240
|
-
empty: "
|
|
1740
|
+
empty: "Aucun ticket tri\xE9 sur cette p\xE9riode."
|
|
1241
1741
|
}
|
|
1242
1742
|
),
|
|
1243
1743
|
detailDecision && /* @__PURE__ */ jsx(
|
|
1244
|
-
|
|
1744
|
+
TimelinePanel,
|
|
1245
1745
|
{
|
|
1246
1746
|
decision: detailDecision,
|
|
1747
|
+
job: detailRow?.job,
|
|
1748
|
+
comparisons: detailRow?.comparisons ?? [],
|
|
1749
|
+
conversation: resolveConversation({
|
|
1750
|
+
tracedInput: detailRow?.job?.tracedInput ?? [],
|
|
1751
|
+
comparisonMessages: detailRow?.comparisons[0]?.conversationMessages ?? [],
|
|
1752
|
+
liveMessages: liveConversation.messages
|
|
1753
|
+
}),
|
|
1754
|
+
conversationLoading: liveConversation.isLoading,
|
|
1247
1755
|
categoryName: detailDecision.categoryId && categoryNames.get(detailDecision.categoryId) || "\u2014",
|
|
1248
|
-
|
|
1249
|
-
agentName: jobByDecisionId.get(detailDecision.id)?.agentId && agentNames.get(jobByDecisionId.get(detailDecision.id).agentId) || "\u2014",
|
|
1756
|
+
agentName: detailRow?.job?.agentId && agentNames.get(detailRow.job.agentId) || "\u2014",
|
|
1250
1757
|
langfuseConfig,
|
|
1251
1758
|
onClose: () => setDetailDecision(null)
|
|
1252
1759
|
}
|
|
1253
1760
|
)
|
|
1254
1761
|
] });
|
|
1255
1762
|
}
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
};
|
|
1275
|
-
|
|
1276
|
-
|
|
1763
|
+
function useLiveConversation(decision, row) {
|
|
1764
|
+
const api = useAppApi();
|
|
1765
|
+
const [state, setState] = useState(
|
|
1766
|
+
{ ticketId: null, messages: null, isLoading: false }
|
|
1767
|
+
);
|
|
1768
|
+
const hasPersisted = (row?.job?.tracedInput.length ?? 0) > 0 || (row?.comparisons[0]?.conversationMessages.length ?? 0) > 0;
|
|
1769
|
+
const ticketId = decision && !hasPersisted ? decision.ticketId : null;
|
|
1770
|
+
useEffect(() => {
|
|
1771
|
+
if (!ticketId) {
|
|
1772
|
+
setState({ ticketId: null, messages: null, isLoading: false });
|
|
1773
|
+
return;
|
|
1774
|
+
}
|
|
1775
|
+
let cancelled = false;
|
|
1776
|
+
setState({ ticketId, messages: null, isLoading: true });
|
|
1777
|
+
api.invoke("get-ticket-conversation", { ticketId }).then((result) => {
|
|
1778
|
+
if (!cancelled) setState({ ticketId, messages: result.messages, isLoading: false });
|
|
1779
|
+
}).catch(() => {
|
|
1780
|
+
if (!cancelled) setState({ ticketId, messages: null, isLoading: false });
|
|
1781
|
+
});
|
|
1782
|
+
return () => {
|
|
1783
|
+
cancelled = true;
|
|
1784
|
+
};
|
|
1785
|
+
}, [api, ticketId]);
|
|
1786
|
+
return { messages: state.messages, isLoading: state.isLoading };
|
|
1277
1787
|
}
|
|
1278
1788
|
|
|
1279
|
-
// src/ui/
|
|
1280
|
-
var
|
|
1281
|
-
|
|
1282
|
-
"content is required": "Le contenu est requis.",
|
|
1283
|
-
"agentId is required": "L'agent est requis.",
|
|
1284
|
-
"ticketId is required": "Le ticket est requis.",
|
|
1285
|
-
"No non-identical comparison found for this agent": "Aucune comparaison diff\xE9rente de l'original n'a \xE9t\xE9 trouv\xE9e pour cet agent.",
|
|
1286
|
-
"The model returned an invalid JSON response": "Le mod\xE8le a renvoy\xE9 une r\xE9ponse JSON invalide.",
|
|
1287
|
-
"Either viewId or ticketIds is required": "Une vue ou une liste de tickets est requise."
|
|
1288
|
-
};
|
|
1289
|
-
var SETTINGS_VALIDATION_MESSAGE_LABELS = {
|
|
1290
|
-
"sourceViewId is required \u2014 pick the Gorgias view this app owns.": SETTINGS_ISSUE_LABELS.sourceViewId,
|
|
1291
|
-
"nodes.triage must be configured \u2014 a null triage step would triage nothing.": SETTINGS_ISSUE_LABELS.nodes,
|
|
1292
|
-
"senderEmail is required when autoSendEnabled is on, unless whatsappMode is 'auto_reply'.": SETTINGS_ISSUE_LABELS.senderEmail
|
|
1293
|
-
};
|
|
1294
|
-
var DYNAMIC_MESSAGE_PATTERNS = [
|
|
1295
|
-
{
|
|
1296
|
-
// create-shared-prompt-version.ts
|
|
1297
|
-
pattern: /^"(.+)" is not a shared\/\* prompt — create-shared-prompt-version only writes the shared\/\* library\.$/,
|
|
1298
|
-
build: ([, name]) => `\xAB ${name} \xBB n'est pas un prompt shared/* \u2014 seule la biblioth\xE8que shared/* peut \xEAtre \xE9crite ici.`
|
|
1299
|
-
},
|
|
1789
|
+
// src/ui/settings/pipeline-nodes.ts
|
|
1790
|
+
var PIPELINE_STEP_KEYS = ["triage", "escalate", "draft", "evaluate", "revise"];
|
|
1791
|
+
var PIPELINE_STEPS = [
|
|
1300
1792
|
{
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1793
|
+
key: "triage",
|
|
1794
|
+
label: "Triage",
|
|
1795
|
+
description: "comprend et classe chaque demande entrante",
|
|
1796
|
+
requires: null,
|
|
1797
|
+
blockedReason: null
|
|
1304
1798
|
},
|
|
1305
1799
|
{
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1800
|
+
key: "escalate",
|
|
1801
|
+
label: "Escalade",
|
|
1802
|
+
description: "passe la main \xE0 un humain",
|
|
1803
|
+
requires: null,
|
|
1804
|
+
blockedReason: null
|
|
1309
1805
|
},
|
|
1310
1806
|
{
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
pattern: /^Reference "(.+)" points to this same prompt \("(.+)"\) — a prompt cannot reference itself\.$/,
|
|
1317
|
-
build: ([, raw, self]) => `La r\xE9f\xE9rence \xAB ${raw} \xBB pointe vers ce m\xEAme prompt (\xAB ${self} \xBB) \u2014 un prompt ne peut pas se r\xE9f\xE9rencer lui-m\xEAme.`
|
|
1318
|
-
},
|
|
1319
|
-
{
|
|
1320
|
-
pattern: /^Reference "(.+)" points to prompt "(.+)", which exists but is outside this app's prompts allowlist \(role\.prompts\) — it cannot be composed here even though it can be read elsewhere\.$/,
|
|
1321
|
-
build: ([, raw, name]) => `La r\xE9f\xE9rence \xAB ${raw} \xBB pointe vers le prompt \xAB ${name} \xBB, qui existe mais est hors de la liste autoris\xE9e de cette app (role.prompts) \u2014 il ne peut pas \xEAtre compos\xE9 ici, m\xEAme s'il reste lisible ailleurs.`
|
|
1322
|
-
},
|
|
1323
|
-
{
|
|
1324
|
-
pattern: /^Reference "(.+)" could not be resolved: prompt "(.+)" with (.+) was not found, or the prompt store could not be reached to verify it\.$/,
|
|
1325
|
-
build: ([, raw, name, locator]) => `La r\xE9f\xE9rence \xAB ${raw} \xBB n'a pas pu \xEAtre r\xE9solue : le prompt \xAB ${name} \xBB avec ${locator} est introuvable, ou le magasin de prompts \xE9tait injoignable pour le v\xE9rifier.`
|
|
1807
|
+
key: "draft",
|
|
1808
|
+
label: "R\xE9daction",
|
|
1809
|
+
description: "pr\xE9pare un projet de r\xE9ponse",
|
|
1810
|
+
requires: null,
|
|
1811
|
+
blockedReason: null
|
|
1326
1812
|
},
|
|
1327
1813
|
{
|
|
1328
|
-
|
|
1329
|
-
|
|
1814
|
+
key: "evaluate",
|
|
1815
|
+
label: "\xC9valuation",
|
|
1816
|
+
description: "relit la r\xE9ponse avant envoi",
|
|
1817
|
+
requires: "draft",
|
|
1818
|
+
blockedReason: "Il n'y a rien \xE0 \xE9valuer sans r\xE9daction."
|
|
1330
1819
|
},
|
|
1331
1820
|
{
|
|
1332
|
-
|
|
1333
|
-
|
|
1821
|
+
key: "revise",
|
|
1822
|
+
label: "R\xE9vision",
|
|
1823
|
+
description: "r\xE9\xE9crit la r\xE9ponse si l'\xE9valuation la juge insuffisante",
|
|
1824
|
+
requires: "evaluate",
|
|
1825
|
+
blockedReason: "Sans \xE9valuation, rien ne d\xE9clenche une r\xE9vision."
|
|
1334
1826
|
}
|
|
1335
1827
|
];
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
const
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
rest
|
|
1343
|
-
);
|
|
1344
|
-
return `R\xE9glages invalides : ${translatedRest}`;
|
|
1828
|
+
var TRIAGE_LOCK_REASON = "Sans triage l'app ne traite rien.";
|
|
1829
|
+
var STEP_BY_KEY = new Map(PIPELINE_STEPS.map((step2) => [step2.key, step2]));
|
|
1830
|
+
function pipelineStep(key) {
|
|
1831
|
+
const step2 = STEP_BY_KEY.get(key);
|
|
1832
|
+
if (!step2) throw new Error(`unknown pipeline step: ${key}`);
|
|
1833
|
+
return step2;
|
|
1345
1834
|
}
|
|
1346
|
-
function
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
const rest = message.slice(prefix.length);
|
|
1350
|
-
const translatedRest = translateFunctionErrorMessage(rest);
|
|
1351
|
-
return `Balises de r\xE9f\xE9rence invalides : ${translatedRest}`;
|
|
1835
|
+
function readNodes(value) {
|
|
1836
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return {};
|
|
1837
|
+
return value;
|
|
1352
1838
|
}
|
|
1353
|
-
function
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
}
|
|
1358
|
-
return null;
|
|
1839
|
+
function readStep(value, key) {
|
|
1840
|
+
const step2 = readNodes(value)[key];
|
|
1841
|
+
if (typeof step2 !== "object" || step2 === null || Array.isArray(step2)) return null;
|
|
1842
|
+
return step2;
|
|
1359
1843
|
}
|
|
1360
|
-
function
|
|
1361
|
-
|
|
1362
|
-
const settingsTranslated = translateSettingsInvalidMessage(message);
|
|
1363
|
-
if (settingsTranslated !== null) return settingsTranslated;
|
|
1364
|
-
const referenceTagsTranslated = translateReferenceTagsMessage(message);
|
|
1365
|
-
if (referenceTagsTranslated !== null) return referenceTagsTranslated;
|
|
1366
|
-
const dynamicTranslated = translateDynamicMessage(message);
|
|
1367
|
-
if (dynamicTranslated !== null) return dynamicTranslated;
|
|
1368
|
-
return message;
|
|
1844
|
+
function isStepEnabled(value, key) {
|
|
1845
|
+
return readStep(value, key) !== null;
|
|
1369
1846
|
}
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
if (err instanceof AppInvokeError && err.code === "FUNCTION_REJECTED") {
|
|
1375
|
-
return translateFunctionErrorMessage(err.message);
|
|
1376
|
-
}
|
|
1377
|
-
return GENERIC_MESSAGE;
|
|
1847
|
+
function stepBlockedReason(value, key) {
|
|
1848
|
+
const { requires, blockedReason } = pipelineStep(key);
|
|
1849
|
+
if (!requires) return null;
|
|
1850
|
+
return isStepActive(value, requires) ? null : blockedReason;
|
|
1378
1851
|
}
|
|
1379
|
-
function
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1852
|
+
function isStepActive(value, key) {
|
|
1853
|
+
return isStepEnabled(value, key) && stepBlockedReason(value, key) === null;
|
|
1854
|
+
}
|
|
1855
|
+
function withStep(value, key, step2) {
|
|
1856
|
+
return { ...readNodes(value), [key]: step2 };
|
|
1857
|
+
}
|
|
1858
|
+
function withStepFields(value, key, patch) {
|
|
1859
|
+
const step2 = readStep(value, key);
|
|
1860
|
+
if (!step2) return readNodes(value);
|
|
1861
|
+
const next = { ...step2 };
|
|
1862
|
+
for (const [field2, fieldValue] of Object.entries(patch)) {
|
|
1863
|
+
if (fieldValue === void 0) delete next[field2];
|
|
1864
|
+
else next[field2] = fieldValue;
|
|
1385
1865
|
}
|
|
1386
|
-
return
|
|
1866
|
+
return withStep(value, key, next);
|
|
1387
1867
|
}
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
return role === "EDITOR" || role === "ADMIN";
|
|
1868
|
+
function stepString(step2, field2) {
|
|
1869
|
+
const value = step2?.[field2];
|
|
1870
|
+
return typeof value === "string" ? value : "";
|
|
1392
1871
|
}
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
var REACHED_READY_STATUSES = /* @__PURE__ */ new Set(["ready", "sent", "expired", "invalidated"]);
|
|
1397
|
-
var GENERATION_ATTEMPT_STATUSES = /* @__PURE__ */ new Set(["ready", "sent", "expired", "invalidated", "failed"]);
|
|
1398
|
-
function toCalendarDay(iso, timezone) {
|
|
1399
|
-
return new Intl.DateTimeFormat("en-CA", { timeZone: timezone, year: "numeric", month: "2-digit", day: "2-digit" }).format(
|
|
1400
|
-
new Date(iso)
|
|
1401
|
-
);
|
|
1872
|
+
function stepNumber(step2, field2, fallback) {
|
|
1873
|
+
const value = step2?.[field2];
|
|
1874
|
+
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
1402
1875
|
}
|
|
1403
|
-
function
|
|
1404
|
-
|
|
1405
|
-
return
|
|
1406
|
-
}
|
|
1407
|
-
function computePipelineStats(rows, timezone = "UTC") {
|
|
1408
|
-
const totalGenerated = rows.length;
|
|
1409
|
-
const sent = rows.filter((r) => r.status === "sent").length;
|
|
1410
|
-
const held = rows.filter((r) => r.autoSendDecision === "hold").length;
|
|
1411
|
-
const treated = rows.filter((r) => isGeneratedResponseStatus(r.status) && TREATED_STATUSES.has(r.status)).length;
|
|
1412
|
-
const reachedReady = rows.filter((r) => isGeneratedResponseStatus(r.status) && REACHED_READY_STATUSES.has(r.status));
|
|
1413
|
-
const servedAtLeastOnce = reachedReady.filter((r) => r.servedCount > 0).length;
|
|
1414
|
-
const attempts = rows.filter((r) => isGeneratedResponseStatus(r.status) && GENERATION_ATTEMPT_STATUSES.has(r.status));
|
|
1415
|
-
const failedAttempts = attempts.filter((r) => r.status === "failed").length;
|
|
1416
|
-
const servedTotal = rows.reduce((sum, r) => sum + r.servedCount, 0);
|
|
1417
|
-
const holdReasonCounts = /* @__PURE__ */ new Map();
|
|
1418
|
-
for (const row of rows) {
|
|
1419
|
-
if (row.autoSendDecision !== "hold") continue;
|
|
1420
|
-
for (const reason2 of holdReasonsFor(row)) {
|
|
1421
|
-
holdReasonCounts.set(reason2, (holdReasonCounts.get(reason2) ?? 0) + 1);
|
|
1422
|
-
}
|
|
1423
|
-
}
|
|
1424
|
-
const dailyCounts = /* @__PURE__ */ new Map();
|
|
1425
|
-
for (const row of rows) {
|
|
1426
|
-
if (!row.generatedAt) continue;
|
|
1427
|
-
const day = toCalendarDay(row.generatedAt, timezone);
|
|
1428
|
-
const bucket = dailyCounts.get(day) ?? { sent: 0, held: 0 };
|
|
1429
|
-
if (row.status === "sent") bucket.sent += 1;
|
|
1430
|
-
if (row.autoSendDecision === "hold") bucket.held += 1;
|
|
1431
|
-
dailyCounts.set(day, bucket);
|
|
1432
|
-
}
|
|
1433
|
-
return {
|
|
1434
|
-
totalGenerated,
|
|
1435
|
-
sent,
|
|
1436
|
-
held,
|
|
1437
|
-
reuseRate: reachedReady.length === 0 ? null : servedAtLeastOnce / reachedReady.length,
|
|
1438
|
-
generationSuccessRate: attempts.length === 0 ? null : (attempts.length - failedAttempts) / attempts.length,
|
|
1439
|
-
servedTotal,
|
|
1440
|
-
funnel: [
|
|
1441
|
-
{ label: "G\xE9n\xE9r\xE9", value: totalGenerated },
|
|
1442
|
-
{ label: "Trait\xE9", value: treated },
|
|
1443
|
-
{ label: "Envoy\xE9", value: sent }
|
|
1444
|
-
],
|
|
1445
|
-
holdReasons: [...holdReasonCounts.entries()].map(([reason2, count]) => ({ reason: reason2, count })),
|
|
1446
|
-
daily: [...dailyCounts.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([day, counts]) => ({ day, ...counts }))
|
|
1447
|
-
};
|
|
1876
|
+
function stepBoolean(step2, field2, fallback) {
|
|
1877
|
+
const value = step2?.[field2];
|
|
1878
|
+
return typeof value === "boolean" ? value : fallback;
|
|
1448
1879
|
}
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
var WINDOW_OPTIONS = [7, 14, 30];
|
|
1452
|
-
var DECISION_OPTIONS = [
|
|
1453
|
-
{ value: "", label: "Tous" },
|
|
1454
|
-
{ value: "sent", label: "Envoy\xE9s auto" },
|
|
1455
|
-
{ value: "held", label: "Bloqu\xE9s" },
|
|
1456
|
-
{ value: "error", label: "Erreurs" }
|
|
1457
|
-
];
|
|
1458
|
-
var STATUS_FILTER_OPTIONS = [
|
|
1459
|
-
{ value: "", label: "Tous les statuts" },
|
|
1460
|
-
...GENERATED_RESPONSE_STATUSES.map((status) => ({ value: status, label: GENERATED_RESPONSE_STATUS_LABELS[status] }))
|
|
1461
|
-
];
|
|
1462
|
-
var VERDICT_FILTER_OPTIONS = [
|
|
1463
|
-
{ value: "", label: "Tous les verdicts" },
|
|
1464
|
-
...EVALUATION_VERDICTS.map((verdict) => ({ value: verdict, label: EVALUATION_VERDICT_LABELS[verdict] }))
|
|
1465
|
-
];
|
|
1466
|
-
function statusLabel(status) {
|
|
1467
|
-
return isGeneratedResponseStatus(status) ? GENERATED_RESPONSE_STATUS_LABELS[status] : status;
|
|
1468
|
-
}
|
|
1469
|
-
function buildTableFilter(decision, status) {
|
|
1470
|
-
if (decision === "sent") return { status: { eq: "sent" } };
|
|
1471
|
-
if (decision === "held") return { autoSendDecision: { eq: "hold" } };
|
|
1472
|
-
if (decision === "error") return { error: { nempty: true } };
|
|
1473
|
-
if (status) return { status: { eq: status } };
|
|
1474
|
-
return void 0;
|
|
1880
|
+
function stepUsesAgentPrompt(key) {
|
|
1881
|
+
return key === "draft" || key === "revise";
|
|
1475
1882
|
}
|
|
1476
|
-
|
|
1477
|
-
|
|
1883
|
+
var DEFAULT_PROMPT_LABEL = "production";
|
|
1884
|
+
function stepPromptName(step2) {
|
|
1885
|
+
return readPromptField(step2, "name");
|
|
1478
1886
|
}
|
|
1479
|
-
function
|
|
1480
|
-
return
|
|
1887
|
+
function stepPromptLabel(step2) {
|
|
1888
|
+
return readPromptField(step2, "label") || DEFAULT_PROMPT_LABEL;
|
|
1481
1889
|
}
|
|
1482
|
-
function
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
] });
|
|
1890
|
+
function readPromptField(step2, field2) {
|
|
1891
|
+
const prompt = step2?.prompt;
|
|
1892
|
+
if (typeof prompt !== "object" || prompt === null) return "";
|
|
1893
|
+
const value = prompt[field2];
|
|
1894
|
+
return typeof value === "string" ? value : "";
|
|
1488
1895
|
}
|
|
1489
|
-
function
|
|
1490
|
-
|
|
1491
|
-
categoryName,
|
|
1492
|
-
agentName,
|
|
1493
|
-
langfuseConfig,
|
|
1494
|
-
onClose
|
|
1495
|
-
}) {
|
|
1496
|
-
return /* @__PURE__ */ jsx(SidePanel, { open: true, onClose, title: `Ticket ${row.ticketId}`, description: `${categoryName} \u2014 ${agentName}`, children: /* @__PURE__ */ jsxs("div", { className: "space-y-4 text-sm", children: [
|
|
1497
|
-
row.responseText && /* @__PURE__ */ jsxs("div", { children: [
|
|
1498
|
-
/* @__PURE__ */ jsx("p", { className: "mb-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "R\xE9ponse g\xE9n\xE9r\xE9e" }),
|
|
1499
|
-
/* @__PURE__ */ jsx("pre", { className: "whitespace-pre-wrap rounded-md border p-3 text-xs", children: row.responseText })
|
|
1500
|
-
] }),
|
|
1501
|
-
row.verdict?.reason && /* @__PURE__ */ jsxs("div", { children: [
|
|
1502
|
-
/* @__PURE__ */ jsx("p", { className: "mb-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Raison \xE9valuation" }),
|
|
1503
|
-
/* @__PURE__ */ jsx("p", { children: row.verdict.reason })
|
|
1504
|
-
] }),
|
|
1505
|
-
row.guardrailHits.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
|
|
1506
|
-
/* @__PURE__ */ jsx("p", { className: "mb-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Garde-fous d\xE9clench\xE9s" }),
|
|
1507
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1", children: row.guardrailHits.map((hit, index) => /* @__PURE__ */ jsx("code", { className: "rounded bg-status-warning/10 px-1.5 py-0.5 text-xs text-status-warning", children: guardrailHitLabel(hit) }, `${hit}-${index}`)) })
|
|
1508
|
-
] }),
|
|
1509
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4 sm:grid-cols-3", children: [
|
|
1510
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
1511
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs uppercase tracking-wide text-muted-foreground", children: "Msg. lors g\xE9n\xE9ration" }),
|
|
1512
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs font-semibold", children: row.generatedMessageCount })
|
|
1513
|
-
] }),
|
|
1514
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
1515
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs uppercase tracking-wide text-muted-foreground", children: "Expire" }),
|
|
1516
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs font-semibold", children: formatDate(row.expiresAt) })
|
|
1517
|
-
] }),
|
|
1518
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
1519
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs uppercase tracking-wide text-muted-foreground", children: "Envoy\xE9 le" }),
|
|
1520
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs font-semibold", children: formatDate(row.sentAt) })
|
|
1521
|
-
] })
|
|
1522
|
-
] }),
|
|
1523
|
-
row.sentMessageId && /* @__PURE__ */ jsxs("div", { children: [
|
|
1524
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs uppercase tracking-wide text-muted-foreground", children: "Message Gorgias" }),
|
|
1525
|
-
/* @__PURE__ */ jsx("code", { className: "text-xs", children: row.sentMessageId })
|
|
1526
|
-
] }),
|
|
1527
|
-
row.error && /* @__PURE__ */ jsxs("div", { className: "rounded-md bg-destructive/10 p-3 text-destructive", children: [
|
|
1528
|
-
"Erreur : ",
|
|
1529
|
-
row.error
|
|
1530
|
-
] }),
|
|
1531
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground", children: [
|
|
1532
|
-
/* @__PURE__ */ jsx("span", { children: "Valeurs brutes" }),
|
|
1533
|
-
/* @__PURE__ */ jsxs("code", { children: [
|
|
1534
|
-
"status=",
|
|
1535
|
-
row.status
|
|
1536
|
-
] }),
|
|
1537
|
-
/* @__PURE__ */ jsxs("code", { children: [
|
|
1538
|
-
"autoSendDecision=",
|
|
1539
|
-
row.autoSendDecision ?? "\u2014"
|
|
1540
|
-
] }),
|
|
1541
|
-
/* @__PURE__ */ jsxs("code", { children: [
|
|
1542
|
-
"verdict=",
|
|
1543
|
-
row.verdict?.verdict ?? "\u2014"
|
|
1544
|
-
] })
|
|
1545
|
-
] }),
|
|
1546
|
-
(row.langfuseTraceId || row.langfuseObservationId) && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
|
|
1547
|
-
/* @__PURE__ */ jsx(LangfuseTraceLink, { traceId: row.langfuseTraceId, config: langfuseConfig, label: "Trace g\xE9n\xE9ration" }),
|
|
1548
|
-
/* @__PURE__ */ jsx(
|
|
1549
|
-
LangfuseTraceLink,
|
|
1550
|
-
{
|
|
1551
|
-
traceId: row.langfuseTraceId,
|
|
1552
|
-
observationId: row.langfuseObservationId,
|
|
1553
|
-
config: langfuseConfig,
|
|
1554
|
-
label: "Trace \xE9valuation"
|
|
1555
|
-
}
|
|
1556
|
-
)
|
|
1557
|
-
] })
|
|
1558
|
-
] }) });
|
|
1896
|
+
function promptPatch(name, label) {
|
|
1897
|
+
return { prompt: { name, label } };
|
|
1559
1898
|
}
|
|
1560
|
-
function
|
|
1561
|
-
const
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
"
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
"generated-response",
|
|
1589
|
-
{
|
|
1590
|
-
filter: buildTableFilter(decisionFilter, statusFilter),
|
|
1591
|
-
sort: [{ field: "generatedAt", direction: "desc" }],
|
|
1592
|
-
limit: TABLE_PAGE_SIZE
|
|
1593
|
-
},
|
|
1594
|
-
toGeneratedResponse
|
|
1595
|
-
);
|
|
1596
|
-
const { rows: categories } = useRecordList("category", { limit: 500 }, toCategory);
|
|
1597
|
-
const { rows: agents } = useRecordList("agent", { limit: 500 }, toAgent);
|
|
1598
|
-
const { config: langfuseConfig } = useLangfuseConfig();
|
|
1599
|
-
const categoryNames = useMemo(() => toNameMap(categories), [categories]);
|
|
1600
|
-
const agentNames = useMemo(() => toNameMap(agents), [agents]);
|
|
1601
|
-
const windowedStatsRows = useMemo(() => {
|
|
1602
|
-
const cutoff = windowCutoffIso(windowDays);
|
|
1603
|
-
return statsRows.filter((row) => row.generatedAt !== null && row.generatedAt >= cutoff);
|
|
1604
|
-
}, [statsRows, windowDays]);
|
|
1605
|
-
const stats = useMemo(
|
|
1606
|
-
() => computePipelineStats(windowedStatsRows, settings?.statsTimezone ?? "UTC"),
|
|
1607
|
-
[windowedStatsRows, settings?.statsTimezone]
|
|
1608
|
-
);
|
|
1609
|
-
const visibleRows = useMemo(
|
|
1610
|
-
() => verdictFilter ? tableRows.filter((row) => row.verdict?.verdict === verdictFilter) : tableRows,
|
|
1611
|
-
[tableRows, verdictFilter]
|
|
1612
|
-
);
|
|
1613
|
-
async function refreshAll() {
|
|
1614
|
-
await Promise.all([refreshStats(), refreshTable()]);
|
|
1615
|
-
}
|
|
1616
|
-
async function runTriageNow() {
|
|
1617
|
-
if (isTriagingRef.current) return;
|
|
1618
|
-
isTriagingRef.current = true;
|
|
1619
|
-
setIsTriaging(true);
|
|
1620
|
-
try {
|
|
1621
|
-
const result = await api.invoke(
|
|
1622
|
-
"run-triage-now",
|
|
1623
|
-
{},
|
|
1624
|
-
{ idempotencyKey: idempotencyKeyFor("run-triage-now", {}) }
|
|
1625
|
-
);
|
|
1626
|
-
toast(
|
|
1627
|
-
result.status === "already-running" ? { title: "Un triage est d\xE9j\xE0 en cours \u2014 aucun second lot n\u2019a \xE9t\xE9 lanc\xE9.", variant: "info" } : { title: "Triage lanc\xE9 \u2014 suivez le run pour son avancement.", variant: "success" }
|
|
1628
|
-
);
|
|
1629
|
-
await refreshAll();
|
|
1630
|
-
} catch (err) {
|
|
1631
|
-
toast({ title: "\xC9chec du lancement du triage", description: describeInvokeError(err), variant: "error" });
|
|
1632
|
-
} finally {
|
|
1633
|
-
isTriagingRef.current = false;
|
|
1634
|
-
setIsTriaging(false);
|
|
1635
|
-
}
|
|
1899
|
+
function stepReasoning(step2) {
|
|
1900
|
+
const value = step2?.reasoning;
|
|
1901
|
+
return REASONING_EFFORTS.some((effort) => effort.value === value) ? value : "off";
|
|
1902
|
+
}
|
|
1903
|
+
var REASONING_EFFORTS = [
|
|
1904
|
+
{ value: "off", label: "Aucun" },
|
|
1905
|
+
{ value: "low", label: "L\xE9ger" },
|
|
1906
|
+
{ value: "medium", label: "Moyen" },
|
|
1907
|
+
{ value: "high", label: "Pouss\xE9" }
|
|
1908
|
+
];
|
|
1909
|
+
var CUSTOM_MODEL_VALUE = "__custom__";
|
|
1910
|
+
var DEFAULT_STEP_MODEL = "gpt-4o-mini";
|
|
1911
|
+
var DEFAULT_STEP_PROVIDER = "openai";
|
|
1912
|
+
function defaultStep() {
|
|
1913
|
+
return { model: DEFAULT_STEP_MODEL, provider: DEFAULT_STEP_PROVIDER, reasoning: "off" };
|
|
1914
|
+
}
|
|
1915
|
+
var PIPELINE_PRESETS = [
|
|
1916
|
+
{
|
|
1917
|
+
id: "triage-only",
|
|
1918
|
+
label: "D\xE9marrage prudent \u2014 triage seul",
|
|
1919
|
+
description: "Les demandes sont comprises et class\xE9es. Aucune r\xE9ponse n\u2019est pr\xE9par\xE9e.",
|
|
1920
|
+
enabled: ["triage"]
|
|
1921
|
+
},
|
|
1922
|
+
{
|
|
1923
|
+
id: "assisted",
|
|
1924
|
+
label: "R\xE9ponse assist\xE9e",
|
|
1925
|
+
description: "Triage, escalade et r\xE9daction : un projet de r\xE9ponse est pr\xE9par\xE9 pour un humain. L\u2019envoi automatique reste d\xE9sactiv\xE9.",
|
|
1926
|
+
enabled: ["triage", "escalate", "draft"]
|
|
1636
1927
|
}
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
{ key: "category", header: "Cat\xE9gorie", cell: (row) => row.categoryId && categoryNames.get(row.categoryId) || "\u2014" },
|
|
1644
|
-
{ key: "agent", header: "Agent", cell: (row) => row.agentId && agentNames.get(row.agentId) || "\u2014" },
|
|
1645
|
-
{ key: "status", header: "Statut", cell: (row) => /* @__PURE__ */ jsx(Badge, { children: statusLabel(row.status) }) },
|
|
1646
|
-
{ key: "confidence", header: "Confiance", cell: (row) => /* @__PURE__ */ jsx(ConfidenceCell, { confidence: row.verdict?.confidence ?? null }) },
|
|
1647
|
-
{
|
|
1648
|
-
key: "verdict",
|
|
1649
|
-
header: "Verdict",
|
|
1650
|
-
cell: (row) => row.verdict?.verdict ? /* @__PURE__ */ jsx(Badge, { variant: row.verdict.verdict === "hold" ? "warning" : "success", children: EVALUATION_VERDICT_LABELS[row.verdict.verdict] }) : "\u2014"
|
|
1651
|
-
},
|
|
1652
|
-
{
|
|
1653
|
-
key: "autoSendDecision",
|
|
1654
|
-
header: "Envoi auto",
|
|
1655
|
-
cell: (row) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0.5", children: [
|
|
1656
|
-
row.autoSendDecision ? /* @__PURE__ */ jsx(Badge, { variant: row.autoSendDecision === "auto" ? "success" : "warning", children: AUTO_SEND_DECISION_LABELS[row.autoSendDecision] }) : "\u2014",
|
|
1657
|
-
row.status === "sent" && row.verdict?.verdict === "send_and_escalate" && /* @__PURE__ */ jsx(Badge, { variant: "warning", className: "w-fit text-[10px]", children: "\xE0 escalader" }),
|
|
1658
|
-
row.sentAt && /* @__PURE__ */ jsx("span", { className: "whitespace-nowrap text-xs text-muted-foreground", children: formatDate(row.sentAt) })
|
|
1659
|
-
] })
|
|
1660
|
-
},
|
|
1661
|
-
{ key: "servedCount", header: "Servi", align: "right", cell: (row) => String(row.servedCount) },
|
|
1662
|
-
{ key: "generatedAt", header: "G\xE9n\xE9r\xE9 le", cell: (row) => formatDate(row.generatedAt) },
|
|
1663
|
-
{
|
|
1664
|
-
key: "langfuse",
|
|
1665
|
-
header: "Langfuse",
|
|
1666
|
-
cell: (row) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", onClick: (e) => e.stopPropagation(), children: [
|
|
1667
|
-
/* @__PURE__ */ jsx(LangfuseTraceLink, { traceId: row.langfuseTraceId, config: langfuseConfig, label: "G\xE9n\xE9ration" }),
|
|
1668
|
-
/* @__PURE__ */ jsx(
|
|
1669
|
-
LangfuseTraceLink,
|
|
1670
|
-
{
|
|
1671
|
-
traceId: row.langfuseTraceId,
|
|
1672
|
-
observationId: row.langfuseObservationId,
|
|
1673
|
-
config: langfuseConfig,
|
|
1674
|
-
label: "\xC9valuation"
|
|
1675
|
-
}
|
|
1676
|
-
)
|
|
1677
|
-
] })
|
|
1678
|
-
}
|
|
1679
|
-
];
|
|
1680
|
-
return /* @__PURE__ */ jsxs(PageShell, { children: [
|
|
1681
|
-
/* @__PURE__ */ jsx(
|
|
1682
|
-
PageHeader,
|
|
1683
|
-
{
|
|
1684
|
-
title: "Pipeline",
|
|
1685
|
-
description: "Cycle de vie des r\xE9ponses g\xE9n\xE9r\xE9es automatiquement.",
|
|
1686
|
-
actions: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
1687
|
-
settings && /* @__PURE__ */ jsxs(Badge, { variant: settings.autoSendEnabled ? "success" : "neutral", children: [
|
|
1688
|
-
"Envoi auto : ",
|
|
1689
|
-
settings.autoSendEnabled ? "ACTIF" : "INACTIF"
|
|
1690
|
-
] }),
|
|
1691
|
-
canWrite && /* @__PURE__ */ jsx(Button, { onClick: () => void runTriageNow(), disabled: isTriaging, children: isTriaging ? "Triage en cours\u2026" : "Lancer le triage maintenant" })
|
|
1692
|
-
] }) })
|
|
1693
|
-
}
|
|
1694
|
-
),
|
|
1695
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1696
|
-
/* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "Fen\xEAtre :" }),
|
|
1697
|
-
WINDOW_OPTIONS.map((days) => /* @__PURE__ */ jsxs(Button, { size: "sm", variant: windowDays === days ? "default" : "outline", onClick: () => setWindowDays(days), children: [
|
|
1698
|
-
days,
|
|
1699
|
-
" j"
|
|
1700
|
-
] }, days))
|
|
1701
|
-
] }),
|
|
1702
|
-
/* @__PURE__ */ jsxs("div", { "data-testid": "pipeline-kpis", className: "grid grid-cols-1 gap-4 sm:grid-cols-3", children: [
|
|
1703
|
-
/* @__PURE__ */ jsx(KpiCard, { label: "G\xE9n\xE9r\xE9", value: statsLoading ? Number.NaN : stats.totalGenerated, formatValue: countOrEllipsis }),
|
|
1704
|
-
/* @__PURE__ */ jsx(KpiCard, { label: "Envoy\xE9", value: statsLoading ? Number.NaN : stats.sent, formatValue: countOrEllipsis }),
|
|
1705
|
-
/* @__PURE__ */ jsx(
|
|
1706
|
-
KpiCard,
|
|
1707
|
-
{
|
|
1708
|
-
label: "Bloqu\xE9s",
|
|
1709
|
-
value: statsLoading ? Number.NaN : stats.held,
|
|
1710
|
-
formatValue: countOrEllipsis,
|
|
1711
|
-
lowerIsBetter: true
|
|
1712
|
-
}
|
|
1713
|
-
)
|
|
1714
|
-
] }),
|
|
1715
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-x-8 gap-y-1 text-xs text-muted-foreground", children: [
|
|
1716
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
1717
|
-
"Taux de r\xE9utilisation",
|
|
1718
|
-
" ",
|
|
1719
|
-
/* @__PURE__ */ jsx("span", { className: "font-semibold tabular-nums text-foreground", children: stats.reuseRate === null ? "\u2014" : `${Math.round(stats.reuseRate * 100)}%` })
|
|
1720
|
-
] }),
|
|
1721
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
1722
|
-
"Succ\xE8s g\xE9n\xE9ration",
|
|
1723
|
-
" ",
|
|
1724
|
-
/* @__PURE__ */ jsx("span", { className: "font-semibold tabular-nums text-foreground", children: stats.generationSuccessRate === null ? "\u2014" : `${Math.round(stats.generationSuccessRate * 100)}%` })
|
|
1725
|
-
] }),
|
|
1726
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
1727
|
-
"Servis ",
|
|
1728
|
-
/* @__PURE__ */ jsx("span", { className: "font-semibold tabular-nums text-foreground", children: stats.servedTotal })
|
|
1729
|
-
] })
|
|
1730
|
-
] }),
|
|
1731
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-4 lg:grid-cols-2", children: [
|
|
1732
|
-
/* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsx(CardContent, { className: "p-4", children: /* @__PURE__ */ jsx(FunnelChart, { data: stats.funnel, label: "Entonnoir du pipeline" }) }) }),
|
|
1733
|
-
/* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsxs(CardContent, { className: "space-y-2 p-4", children: [
|
|
1734
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: "Raisons de blocage" }),
|
|
1735
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Une r\xE9ponse bloqu\xE9e peut d\xE9clencher plusieurs garde-fous : le total peut d\xE9passer le nombre de r\xE9ponses bloqu\xE9es." }),
|
|
1736
|
-
stats.holdReasons.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Aucun garde-fou n\u2019a bloqu\xE9 de r\xE9ponse sur cette fen\xEAtre." }) : /* @__PURE__ */ jsx("ul", { className: "space-y-1 text-sm", children: [...stats.holdReasons].sort((a, b) => b.count - a.count).map((r) => /* @__PURE__ */ jsxs("li", { className: "flex items-center justify-between gap-3", children: [
|
|
1737
|
-
/* @__PURE__ */ jsx("span", { className: "truncate", children: guardrailHitLabel(r.reason) }),
|
|
1738
|
-
/* @__PURE__ */ jsx("span", { className: "tabular-nums text-muted-foreground", children: r.count })
|
|
1739
|
-
] }, r.reason)) })
|
|
1740
|
-
] }) })
|
|
1741
|
-
] }),
|
|
1742
|
-
/* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsx(CardContent, { className: "p-4", children: stats.daily.length === 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1743
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: "\xC9volution par jour" }),
|
|
1744
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Aucune journ\xE9e mesur\xE9e sur cette fen\xEAtre." })
|
|
1745
|
-
] }) : /* @__PURE__ */ jsx(
|
|
1746
|
-
StackedBarChart,
|
|
1747
|
-
{
|
|
1748
|
-
data: stats.daily,
|
|
1749
|
-
x: "day",
|
|
1750
|
-
label: "\xC9volution par jour",
|
|
1751
|
-
series: [
|
|
1752
|
-
{ key: "sent", label: "Envoy\xE9es", colorIndex: 0 },
|
|
1753
|
-
{ key: "held", label: "Bloqu\xE9es", colorIndex: 1 }
|
|
1754
|
-
]
|
|
1755
|
-
}
|
|
1756
|
-
) }) }),
|
|
1757
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
|
|
1758
|
-
DECISION_OPTIONS.map((option) => /* @__PURE__ */ jsx(
|
|
1759
|
-
Button,
|
|
1760
|
-
{
|
|
1761
|
-
size: "sm",
|
|
1762
|
-
variant: decisionFilter === option.value ? "default" : "outline",
|
|
1763
|
-
onClick: () => selectDecision(option.value),
|
|
1764
|
-
children: option.label
|
|
1765
|
-
},
|
|
1766
|
-
option.value
|
|
1767
|
-
)),
|
|
1768
|
-
/* @__PURE__ */ jsx(
|
|
1769
|
-
Select,
|
|
1770
|
-
{
|
|
1771
|
-
items: STATUS_FILTER_OPTIONS,
|
|
1772
|
-
value: statusFilter,
|
|
1773
|
-
onValueChange: setStatusFilter,
|
|
1774
|
-
disabled: decisionFilter !== "",
|
|
1775
|
-
placeholder: "Tous les statuts",
|
|
1776
|
-
"aria-label": "Filtrer par statut"
|
|
1777
|
-
}
|
|
1778
|
-
),
|
|
1779
|
-
/* @__PURE__ */ jsx(
|
|
1780
|
-
Select,
|
|
1781
|
-
{
|
|
1782
|
-
items: VERDICT_FILTER_OPTIONS,
|
|
1783
|
-
value: verdictFilter,
|
|
1784
|
-
onValueChange: setVerdictFilter,
|
|
1785
|
-
placeholder: "Tous les verdicts",
|
|
1786
|
-
"aria-label": "Filtrer par verdict"
|
|
1787
|
-
}
|
|
1788
|
-
),
|
|
1789
|
-
/* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: () => void refreshTable(), children: "Actualiser" }),
|
|
1790
|
-
visibleRows.length > 0 && /* @__PURE__ */ jsxs("span", { className: "ml-auto text-sm text-muted-foreground", children: [
|
|
1791
|
-
visibleRows.length,
|
|
1792
|
-
" r\xE9sultat",
|
|
1793
|
-
visibleRows.length > 1 ? "s" : ""
|
|
1794
|
-
] })
|
|
1795
|
-
] }),
|
|
1796
|
-
tableLoading || statsLoading ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center py-12", children: [
|
|
1797
|
-
/* @__PURE__ */ jsx(Spinner, {}),
|
|
1798
|
-
" ",
|
|
1799
|
-
/* @__PURE__ */ jsx("span", { className: "ml-2 text-sm text-muted-foreground", children: "Chargement de la file\u2026" })
|
|
1800
|
-
] }) : /* @__PURE__ */ jsx(
|
|
1801
|
-
DataTable,
|
|
1802
|
-
{
|
|
1803
|
-
columns,
|
|
1804
|
-
rows: visibleRows,
|
|
1805
|
-
rowId: (row) => row.id,
|
|
1806
|
-
manual: true,
|
|
1807
|
-
onRowClick: (row) => setDetailRow(row),
|
|
1808
|
-
error: tableError ? /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-3", children: [
|
|
1809
|
-
"Erreur lors du chargement de la file.",
|
|
1810
|
-
/* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: () => void refreshTable(), children: "R\xE9essayer" })
|
|
1811
|
-
] }) : void 0,
|
|
1812
|
-
empty: "Aucune r\xE9ponse g\xE9n\xE9r\xE9e pour l'instant."
|
|
1813
|
-
}
|
|
1814
|
-
),
|
|
1815
|
-
detailRow && /* @__PURE__ */ jsx(
|
|
1816
|
-
DetailPanel2,
|
|
1817
|
-
{
|
|
1818
|
-
row: detailRow,
|
|
1819
|
-
categoryName: detailRow.categoryId && categoryNames.get(detailRow.categoryId) || "\u2014",
|
|
1820
|
-
agentName: detailRow.agentId && agentNames.get(detailRow.agentId) || "\u2014",
|
|
1821
|
-
langfuseConfig,
|
|
1822
|
-
onClose: () => setDetailRow(null)
|
|
1823
|
-
}
|
|
1824
|
-
)
|
|
1825
|
-
] });
|
|
1826
|
-
}
|
|
1827
|
-
|
|
1828
|
-
// src/ui/settings/pipeline-nodes.ts
|
|
1829
|
-
var PIPELINE_STEP_KEYS = ["triage", "escalate", "draft", "evaluate", "revise"];
|
|
1830
|
-
var PIPELINE_STEPS = [
|
|
1831
|
-
{
|
|
1832
|
-
key: "triage",
|
|
1833
|
-
label: "Triage",
|
|
1834
|
-
description: "comprend et classe chaque demande entrante",
|
|
1835
|
-
requires: null,
|
|
1836
|
-
blockedReason: null
|
|
1837
|
-
},
|
|
1838
|
-
{
|
|
1839
|
-
key: "escalate",
|
|
1840
|
-
label: "Escalade",
|
|
1841
|
-
description: "passe la main \xE0 un humain",
|
|
1842
|
-
requires: null,
|
|
1843
|
-
blockedReason: null
|
|
1844
|
-
},
|
|
1845
|
-
{
|
|
1846
|
-
key: "draft",
|
|
1847
|
-
label: "R\xE9daction",
|
|
1848
|
-
description: "pr\xE9pare un projet de r\xE9ponse",
|
|
1849
|
-
requires: null,
|
|
1850
|
-
blockedReason: null
|
|
1851
|
-
},
|
|
1852
|
-
{
|
|
1853
|
-
key: "evaluate",
|
|
1854
|
-
label: "\xC9valuation",
|
|
1855
|
-
description: "relit la r\xE9ponse avant envoi",
|
|
1856
|
-
requires: "draft",
|
|
1857
|
-
blockedReason: "Il n'y a rien \xE0 \xE9valuer sans r\xE9daction."
|
|
1858
|
-
},
|
|
1859
|
-
{
|
|
1860
|
-
key: "revise",
|
|
1861
|
-
label: "R\xE9vision",
|
|
1862
|
-
description: "r\xE9\xE9crit la r\xE9ponse si l'\xE9valuation la juge insuffisante",
|
|
1863
|
-
requires: "evaluate",
|
|
1864
|
-
blockedReason: "Sans \xE9valuation, rien ne d\xE9clenche une r\xE9vision."
|
|
1865
|
-
}
|
|
1866
|
-
];
|
|
1867
|
-
var TRIAGE_LOCK_REASON = "Sans triage l'app ne traite rien.";
|
|
1868
|
-
var STEP_BY_KEY = new Map(PIPELINE_STEPS.map((step) => [step.key, step]));
|
|
1869
|
-
function pipelineStep(key) {
|
|
1870
|
-
const step = STEP_BY_KEY.get(key);
|
|
1871
|
-
if (!step) throw new Error(`unknown pipeline step: ${key}`);
|
|
1872
|
-
return step;
|
|
1873
|
-
}
|
|
1874
|
-
function readNodes(value) {
|
|
1875
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return {};
|
|
1876
|
-
return value;
|
|
1877
|
-
}
|
|
1878
|
-
function readStep(value, key) {
|
|
1879
|
-
const step = readNodes(value)[key];
|
|
1880
|
-
if (typeof step !== "object" || step === null || Array.isArray(step)) return null;
|
|
1881
|
-
return step;
|
|
1882
|
-
}
|
|
1883
|
-
function isStepEnabled(value, key) {
|
|
1884
|
-
return readStep(value, key) !== null;
|
|
1885
|
-
}
|
|
1886
|
-
function stepBlockedReason(value, key) {
|
|
1887
|
-
const { requires, blockedReason } = pipelineStep(key);
|
|
1888
|
-
if (!requires) return null;
|
|
1889
|
-
return isStepActive(value, requires) ? null : blockedReason;
|
|
1890
|
-
}
|
|
1891
|
-
function isStepActive(value, key) {
|
|
1892
|
-
return isStepEnabled(value, key) && stepBlockedReason(value, key) === null;
|
|
1893
|
-
}
|
|
1894
|
-
function withStep(value, key, step) {
|
|
1895
|
-
return { ...readNodes(value), [key]: step };
|
|
1896
|
-
}
|
|
1897
|
-
function withStepFields(value, key, patch) {
|
|
1898
|
-
const step = readStep(value, key);
|
|
1899
|
-
if (!step) return readNodes(value);
|
|
1900
|
-
const next = { ...step };
|
|
1901
|
-
for (const [field2, fieldValue] of Object.entries(patch)) {
|
|
1902
|
-
if (fieldValue === void 0) delete next[field2];
|
|
1903
|
-
else next[field2] = fieldValue;
|
|
1904
|
-
}
|
|
1905
|
-
return withStep(value, key, next);
|
|
1906
|
-
}
|
|
1907
|
-
function stepString(step, field2) {
|
|
1908
|
-
const value = step?.[field2];
|
|
1909
|
-
return typeof value === "string" ? value : "";
|
|
1910
|
-
}
|
|
1911
|
-
function stepNumber(step, field2, fallback) {
|
|
1912
|
-
const value = step?.[field2];
|
|
1913
|
-
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
1914
|
-
}
|
|
1915
|
-
function stepBoolean(step, field2, fallback) {
|
|
1916
|
-
const value = step?.[field2];
|
|
1917
|
-
return typeof value === "boolean" ? value : fallback;
|
|
1918
|
-
}
|
|
1919
|
-
function stepUsesAgentPrompt(key) {
|
|
1920
|
-
return key === "draft" || key === "revise";
|
|
1921
|
-
}
|
|
1922
|
-
var DEFAULT_PROMPT_LABEL = "production";
|
|
1923
|
-
function stepPromptName(step) {
|
|
1924
|
-
return readPromptField(step, "name");
|
|
1925
|
-
}
|
|
1926
|
-
function stepPromptLabel(step) {
|
|
1927
|
-
return readPromptField(step, "label") || DEFAULT_PROMPT_LABEL;
|
|
1928
|
-
}
|
|
1929
|
-
function readPromptField(step, field2) {
|
|
1930
|
-
const prompt = step?.prompt;
|
|
1931
|
-
if (typeof prompt !== "object" || prompt === null) return "";
|
|
1932
|
-
const value = prompt[field2];
|
|
1933
|
-
return typeof value === "string" ? value : "";
|
|
1934
|
-
}
|
|
1935
|
-
function promptPatch(name, label) {
|
|
1936
|
-
return { prompt: { name, label } };
|
|
1937
|
-
}
|
|
1938
|
-
function stepReasoning(step) {
|
|
1939
|
-
const value = step?.reasoning;
|
|
1940
|
-
return REASONING_EFFORTS.some((effort) => effort.value === value) ? value : "off";
|
|
1941
|
-
}
|
|
1942
|
-
var REASONING_EFFORTS = [
|
|
1943
|
-
{ value: "off", label: "Aucun" },
|
|
1944
|
-
{ value: "low", label: "L\xE9ger" },
|
|
1945
|
-
{ value: "medium", label: "Moyen" },
|
|
1946
|
-
{ value: "high", label: "Pouss\xE9" }
|
|
1947
|
-
];
|
|
1948
|
-
var CUSTOM_MODEL_VALUE = "__custom__";
|
|
1949
|
-
var DEFAULT_STEP_MODEL = "gpt-4o-mini";
|
|
1950
|
-
var DEFAULT_STEP_PROVIDER = "openai";
|
|
1951
|
-
function defaultStep() {
|
|
1952
|
-
return { model: DEFAULT_STEP_MODEL, provider: DEFAULT_STEP_PROVIDER, reasoning: "off" };
|
|
1953
|
-
}
|
|
1954
|
-
var PIPELINE_PRESETS = [
|
|
1955
|
-
{
|
|
1956
|
-
id: "triage-only",
|
|
1957
|
-
label: "D\xE9marrage prudent \u2014 triage seul",
|
|
1958
|
-
description: "Les demandes sont comprises et class\xE9es. Aucune r\xE9ponse n\u2019est pr\xE9par\xE9e.",
|
|
1959
|
-
enabled: ["triage"]
|
|
1960
|
-
},
|
|
1961
|
-
{
|
|
1962
|
-
id: "assisted",
|
|
1963
|
-
label: "R\xE9ponse assist\xE9e",
|
|
1964
|
-
description: "Triage, escalade et r\xE9daction : un projet de r\xE9ponse est pr\xE9par\xE9 pour un humain. L\u2019envoi automatique reste d\xE9sactiv\xE9.",
|
|
1965
|
-
enabled: ["triage", "escalate", "draft"]
|
|
1966
|
-
}
|
|
1967
|
-
];
|
|
1968
|
-
function applyPreset(value, preset, restore) {
|
|
1969
|
-
let next = readNodes(value);
|
|
1970
|
-
for (const key of PIPELINE_STEP_KEYS) {
|
|
1971
|
-
const on = preset.enabled.includes(key);
|
|
1972
|
-
next = withStep(next, key, on ? readStep(next, key) ?? restore(key) : null);
|
|
1928
|
+
];
|
|
1929
|
+
function applyPreset(value, preset, restore) {
|
|
1930
|
+
let next = readNodes(value);
|
|
1931
|
+
for (const key of PIPELINE_STEP_KEYS) {
|
|
1932
|
+
const on = preset.enabled.includes(key);
|
|
1933
|
+
next = withStep(next, key, on ? readStep(next, key) ?? restore(key) : null);
|
|
1973
1934
|
}
|
|
1974
1935
|
return next;
|
|
1975
1936
|
}
|
|
@@ -2164,17 +2125,6 @@ function usePromptVersions(promptName) {
|
|
|
2164
2125
|
);
|
|
2165
2126
|
return { versions, isLoading, error, refresh: load, promote, deleteVersion, createVersion };
|
|
2166
2127
|
}
|
|
2167
|
-
function WordDiffView({ title, tokens, keep, hideEqual = false }) {
|
|
2168
|
-
const highlightCls = keep === "delete" ? "bg-destructive/10 text-destructive" : "bg-status-success/10 text-status-success";
|
|
2169
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col overflow-hidden rounded-md border", children: [
|
|
2170
|
-
/* @__PURE__ */ jsx("div", { className: "border-b bg-muted px-3 py-1.5 text-xs font-semibold text-muted-foreground", children: title }),
|
|
2171
|
-
/* @__PURE__ */ jsx("pre", { className: "max-h-96 overflow-y-auto whitespace-pre-wrap p-3 text-xs", children: tokens.map((op, index) => {
|
|
2172
|
-
if (op.op === "equal") return hideEqual ? null : /* @__PURE__ */ jsx("span", { children: op.text }, index);
|
|
2173
|
-
if (op.op !== keep) return null;
|
|
2174
|
-
return /* @__PURE__ */ jsx("span", { className: `rounded px-0.5 ${highlightCls}`, children: op.text }, index);
|
|
2175
|
-
}) })
|
|
2176
|
-
] });
|
|
2177
|
-
}
|
|
2178
2128
|
function versionLabel(version) {
|
|
2179
2129
|
return version.label ? `v${version.version} \u2014 ${version.label}` : `v${version.version}`;
|
|
2180
2130
|
}
|
|
@@ -2319,7 +2269,7 @@ function AgentFormModal({
|
|
|
2319
2269
|
Select,
|
|
2320
2270
|
{
|
|
2321
2271
|
"aria-label": "Mod\xE8le",
|
|
2322
|
-
value: showModelFreeText ? CUSTOM_MODEL_VALUE :
|
|
2272
|
+
value: showModelFreeText ? CUSTOM_MODEL_VALUE : form.modelId,
|
|
2323
2273
|
onValueChange: (next) => {
|
|
2324
2274
|
if (next === CUSTOM_MODEL_VALUE) {
|
|
2325
2275
|
setFreeTextModel(true);
|
|
@@ -2329,6 +2279,9 @@ function AgentFormModal({
|
|
|
2329
2279
|
setForm({ ...form, modelId: next, provider: DEFAULT_STEP_PROVIDER });
|
|
2330
2280
|
},
|
|
2331
2281
|
items: [
|
|
2282
|
+
// The stored model, listed so the trigger can print it while the
|
|
2283
|
+
// provider's own list is still loading.
|
|
2284
|
+
...!showModelFreeText && form.modelId !== "" && !knownModel ? [{ value: form.modelId, label: form.modelId }] : [],
|
|
2332
2285
|
...models.map((name) => ({ value: name, label: name })),
|
|
2333
2286
|
{ value: CUSTOM_MODEL_VALUE, label: "Autre \u2014 saisir un identifiant de mod\xE8le" }
|
|
2334
2287
|
],
|
|
@@ -2363,7 +2316,7 @@ function AgentFormModal({
|
|
|
2363
2316
|
Select,
|
|
2364
2317
|
{
|
|
2365
2318
|
"aria-label": "Prompt Langfuse",
|
|
2366
|
-
value: showPromptFreeText ? CUSTOM_PROMPT_VALUE :
|
|
2319
|
+
value: showPromptFreeText ? CUSTOM_PROMPT_VALUE : agent === "new" && form.promptName === "" ? DERIVED_PROMPT_VALUE : form.promptName,
|
|
2367
2320
|
onValueChange: pickPrompt,
|
|
2368
2321
|
items: [
|
|
2369
2322
|
...agent === "new" ? [
|
|
@@ -2372,6 +2325,9 @@ function AgentFormModal({
|
|
|
2372
2325
|
label: "Nouveau prompt \u2014 agent/<g\xE9n\xE9r\xE9 automatiquement>"
|
|
2373
2326
|
}
|
|
2374
2327
|
] : [],
|
|
2328
|
+
// The agent's stored prompt, listed so the trigger can print it
|
|
2329
|
+
// while the catalogue is still loading.
|
|
2330
|
+
...!showPromptFreeText && form.promptName !== "" && !knownPrompt ? [{ value: form.promptName, label: form.promptName }] : [],
|
|
2375
2331
|
...prompts.map((entry) => ({ value: entry.name, label: entry.name })),
|
|
2376
2332
|
{ value: CUSTOM_PROMPT_VALUE, label: "Autre \u2014 saisir un nom de prompt" }
|
|
2377
2333
|
],
|
|
@@ -3028,878 +2984,214 @@ function CategoriesPage() {
|
|
|
3028
2984
|
}
|
|
3029
2985
|
async function toggleFastResponse(category) {
|
|
3030
2986
|
const next = !category.fastResponseEnabled;
|
|
3031
|
-
const data = { fastResponseEnabled: next };
|
|
3032
|
-
if (!next && category.autoReplyEnabled) data.autoReplyEnabled = false;
|
|
3033
|
-
try {
|
|
3034
|
-
await api.patch(categoryPath(category.id), { data });
|
|
3035
|
-
await refreshCategories();
|
|
3036
|
-
} catch (err) {
|
|
3037
|
-
toast({ title: "\xC9chec de la mise \xE0 jour", description: describeApiError(err), variant: "error" });
|
|
3038
|
-
}
|
|
3039
|
-
}
|
|
3040
|
-
async function toggleAutoReply(category) {
|
|
3041
|
-
try {
|
|
3042
|
-
await api.patch(categoryPath(category.id), { data: { autoReplyEnabled: !category.autoReplyEnabled } });
|
|
3043
|
-
await refreshCategories();
|
|
3044
|
-
} catch (err) {
|
|
3045
|
-
toast({ title: "\xC9chec de la mise \xE0 jour", description: describeApiError(err), variant: "error" });
|
|
3046
|
-
}
|
|
3047
|
-
}
|
|
3048
|
-
async function move(category, direction) {
|
|
3049
|
-
const siblings = byGroup.get(category.groupId ?? UNGROUPED_KEY) ?? [];
|
|
3050
|
-
const index = siblings.findIndex((c) => c.id === category.id);
|
|
3051
|
-
const swapWith = siblings[index + direction];
|
|
3052
|
-
if (!swapWith) return;
|
|
3053
|
-
try {
|
|
3054
|
-
await api.patch(categoryPath(category.id), { data: { order: swapWith.order } });
|
|
3055
|
-
await api.patch(categoryPath(swapWith.id), { data: { order: category.order } });
|
|
3056
|
-
await refreshCategories();
|
|
3057
|
-
} catch (err) {
|
|
3058
|
-
toast({ title: "\xC9chec du r\xE9ordonnancement", description: describeApiError(err), variant: "error" });
|
|
3059
|
-
await refreshCategories();
|
|
3060
|
-
}
|
|
3061
|
-
}
|
|
3062
|
-
function renderCategoryList(groupCategories) {
|
|
3063
|
-
return /* @__PURE__ */ jsx("div", { className: "space-y-2", children: groupCategories.map((category, index) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 rounded-md border p-2", children: [
|
|
3064
|
-
canWrite && /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
3065
|
-
/* @__PURE__ */ jsx(
|
|
3066
|
-
Button,
|
|
3067
|
-
{
|
|
3068
|
-
type: "button",
|
|
3069
|
-
variant: "ghost",
|
|
3070
|
-
"aria-label": `Monter \u2014 ${category.name}`,
|
|
3071
|
-
disabled: index === 0,
|
|
3072
|
-
onClick: () => void move(category, -1),
|
|
3073
|
-
className: "h-4 min-w-0 p-0 text-xs leading-none",
|
|
3074
|
-
children: "\u25B2"
|
|
3075
|
-
}
|
|
3076
|
-
),
|
|
3077
|
-
/* @__PURE__ */ jsx(
|
|
3078
|
-
Button,
|
|
3079
|
-
{
|
|
3080
|
-
type: "button",
|
|
3081
|
-
variant: "ghost",
|
|
3082
|
-
"aria-label": `Descendre \u2014 ${category.name}`,
|
|
3083
|
-
disabled: index === groupCategories.length - 1,
|
|
3084
|
-
onClick: () => void move(category, 1),
|
|
3085
|
-
className: "h-4 min-w-0 p-0 text-xs leading-none",
|
|
3086
|
-
children: "\u25BC"
|
|
3087
|
-
}
|
|
3088
|
-
)
|
|
3089
|
-
] }),
|
|
3090
|
-
/* @__PURE__ */ jsxs("div", { className: "flex-1", children: [
|
|
3091
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: category.name }),
|
|
3092
|
-
/* @__PURE__ */ jsx("code", { className: "text-xs text-muted-foreground", children: category.tagName })
|
|
3093
|
-
] }),
|
|
3094
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
3095
|
-
/* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "R\xE9ponse rapide" }),
|
|
3096
|
-
/* @__PURE__ */ jsx(
|
|
3097
|
-
Switch,
|
|
3098
|
-
{
|
|
3099
|
-
"aria-label": `R\xE9ponse rapide \u2014 ${category.name}`,
|
|
3100
|
-
checked: category.fastResponseEnabled,
|
|
3101
|
-
onCheckedChange: () => void toggleFastResponse(category),
|
|
3102
|
-
disabled: !canWrite || !category.agentId
|
|
3103
|
-
}
|
|
3104
|
-
)
|
|
3105
|
-
] }),
|
|
3106
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
3107
|
-
/* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "Envoi auto" }),
|
|
3108
|
-
/* @__PURE__ */ jsx(
|
|
3109
|
-
Switch,
|
|
3110
|
-
{
|
|
3111
|
-
"aria-label": `Envoi auto \u2014 ${category.name}`,
|
|
3112
|
-
checked: category.autoReplyEnabled,
|
|
3113
|
-
onCheckedChange: () => void toggleAutoReply(category),
|
|
3114
|
-
disabled: !canWrite || !category.fastResponseEnabled || !category.agentId
|
|
3115
|
-
}
|
|
3116
|
-
)
|
|
3117
|
-
] }),
|
|
3118
|
-
category.extraTags.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex gap-1", children: category.extraTags.map((tag) => /* @__PURE__ */ jsx(Badge, { variant: "outline", children: tag }, tag)) }),
|
|
3119
|
-
canWrite && /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
3120
|
-
/* @__PURE__ */ jsx(
|
|
3121
|
-
Button,
|
|
3122
|
-
{
|
|
3123
|
-
variant: "outline",
|
|
3124
|
-
size: "sm",
|
|
3125
|
-
onClick: () => setCategoryForm({ groupId: category.groupId ?? UNGROUPED_KEY, category }),
|
|
3126
|
-
children: "Modifier"
|
|
3127
|
-
}
|
|
3128
|
-
),
|
|
3129
|
-
/* @__PURE__ */ jsx(
|
|
3130
|
-
Button,
|
|
3131
|
-
{
|
|
3132
|
-
variant: "outline",
|
|
3133
|
-
size: "sm",
|
|
3134
|
-
"aria-label": `Supprimer \u2014 ${category.name}`,
|
|
3135
|
-
onClick: () => setDeletingCategory(category),
|
|
3136
|
-
children: "Supprimer"
|
|
3137
|
-
}
|
|
3138
|
-
)
|
|
3139
|
-
] })
|
|
3140
|
-
] }, category.id)) });
|
|
3141
|
-
}
|
|
3142
|
-
const isLoading = groupsLoading || categoriesLoading;
|
|
3143
|
-
const loadError = groupsError ?? categoriesError;
|
|
3144
|
-
const ungrouped = byGroup.get(UNGROUPED_KEY) ?? [];
|
|
3145
|
-
return /* @__PURE__ */ jsxs(PageShell, { children: [
|
|
3146
|
-
/* @__PURE__ */ jsx(
|
|
3147
|
-
PageHeader,
|
|
3148
|
-
{
|
|
3149
|
-
title: "Cat\xE9gories",
|
|
3150
|
-
description: "R\xE9f\xE9rentiel de cat\xE9gorisation des tickets.",
|
|
3151
|
-
actions: canWrite && /* @__PURE__ */ jsx(Button, { onClick: () => setNewGroup(true), children: "Nouveau groupe" })
|
|
3152
|
-
}
|
|
3153
|
-
),
|
|
3154
|
-
loadError ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-3 py-12", children: [
|
|
3155
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: "Erreur lors du chargement des cat\xE9gories." }),
|
|
3156
|
-
/* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => void Promise.all([refreshGroups(), refreshCategories()]), children: "R\xE9essayer" })
|
|
3157
|
-
] }) : isLoading ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center py-12", children: [
|
|
3158
|
-
/* @__PURE__ */ jsx(Spinner, {}),
|
|
3159
|
-
" ",
|
|
3160
|
-
/* @__PURE__ */ jsx("span", { className: "ml-2 text-sm text-muted-foreground", children: "Chargement\u2026" })
|
|
3161
|
-
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3162
|
-
groups.slice().sort((a, b) => a.order - b.order).map((group) => {
|
|
3163
|
-
const groupCategories = byGroup.get(group.id) ?? [];
|
|
3164
|
-
return /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsxs(CardContent, { className: "space-y-2 p-4", children: [
|
|
3165
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
3166
|
-
/* @__PURE__ */ jsx("h2", { className: "font-medium", children: group.name }),
|
|
3167
|
-
canWrite && /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
3168
|
-
/* @__PURE__ */ jsx(
|
|
3169
|
-
Button,
|
|
3170
|
-
{
|
|
3171
|
-
variant: "outline",
|
|
3172
|
-
size: "sm",
|
|
3173
|
-
onClick: () => setCategoryForm({ groupId: group.id, category: null }),
|
|
3174
|
-
children: "Ajouter une cat\xE9gorie"
|
|
3175
|
-
}
|
|
3176
|
-
),
|
|
3177
|
-
/* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: () => setDeletingGroup(group), children: "Supprimer le groupe" })
|
|
3178
|
-
] })
|
|
3179
|
-
] }),
|
|
3180
|
-
renderCategoryList(groupCategories)
|
|
3181
|
-
] }) }, group.id);
|
|
3182
|
-
}),
|
|
3183
|
-
/* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsxs(CardContent, { className: "space-y-2 p-4", children: [
|
|
3184
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
3185
|
-
/* @__PURE__ */ jsx("h2", { className: "font-medium", children: "Sans groupe" }),
|
|
3186
|
-
canWrite && /* @__PURE__ */ jsx(
|
|
3187
|
-
Button,
|
|
3188
|
-
{
|
|
3189
|
-
variant: "outline",
|
|
3190
|
-
size: "sm",
|
|
3191
|
-
onClick: () => setCategoryForm({ groupId: UNGROUPED_KEY, category: null }),
|
|
3192
|
-
children: "Ajouter une cat\xE9gorie"
|
|
3193
|
-
}
|
|
3194
|
-
)
|
|
3195
|
-
] }),
|
|
3196
|
-
ungrouped.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Aucune cat\xE9gorie sans groupe." }) : renderCategoryList(ungrouped)
|
|
3197
|
-
] }) })
|
|
3198
|
-
] }),
|
|
3199
|
-
newGroup && /* @__PURE__ */ jsx(GroupFormModal, { onClose: () => setNewGroup(false), onSave: createGroup }),
|
|
3200
|
-
categoryForm && /* @__PURE__ */ jsx(
|
|
3201
|
-
CategoryFormModal,
|
|
3202
|
-
{
|
|
3203
|
-
groupId: categoryForm.groupId,
|
|
3204
|
-
category: categoryForm.category,
|
|
3205
|
-
agents,
|
|
3206
|
-
onClose: () => setCategoryForm(null),
|
|
3207
|
-
onSave: saveCategory
|
|
3208
|
-
}
|
|
3209
|
-
),
|
|
3210
|
-
deletingGroup && /* @__PURE__ */ jsx(
|
|
3211
|
-
ConfirmModal,
|
|
3212
|
-
{
|
|
3213
|
-
title: "Supprimer le groupe ?",
|
|
3214
|
-
description: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3215
|
-
"Le groupe \xAB ",
|
|
3216
|
-
deletingGroup.name,
|
|
3217
|
-
" \xBB sera supprim\xE9. Ses cat\xE9gories ne seront PAS supprim\xE9es \u2014 elles passeront dans \xAB Sans groupe \xBB."
|
|
3218
|
-
] }),
|
|
3219
|
-
confirmLabel: "Supprimer le groupe",
|
|
3220
|
-
onConfirm: confirmDeleteGroup,
|
|
3221
|
-
onCancel: () => setDeletingGroup(null)
|
|
3222
|
-
}
|
|
3223
|
-
),
|
|
3224
|
-
deletingCategory && /* @__PURE__ */ jsx(
|
|
3225
|
-
ConfirmModal,
|
|
3226
|
-
{
|
|
3227
|
-
title: "Supprimer la cat\xE9gorie ?",
|
|
3228
|
-
description: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3229
|
-
"La cat\xE9gorie \xAB ",
|
|
3230
|
-
deletingCategory.name,
|
|
3231
|
-
" \xBB sera supprim\xE9e. Les tickets d\xE9j\xE0 tagu\xE9s",
|
|
3232
|
-
" ",
|
|
3233
|
-
/* @__PURE__ */ jsx("code", { children: deletingCategory.tagName }),
|
|
3234
|
-
" ne seront plus reconnus par le triage."
|
|
3235
|
-
] }),
|
|
3236
|
-
confirmLabel: "Supprimer la cat\xE9gorie",
|
|
3237
|
-
onConfirm: confirmDeleteCategory,
|
|
3238
|
-
onCancel: () => setDeletingCategory(null)
|
|
3239
|
-
}
|
|
3240
|
-
)
|
|
3241
|
-
] });
|
|
3242
|
-
}
|
|
3243
|
-
var ESCALATIONS_PAGE_SIZE = 200;
|
|
3244
|
-
var ESCALATED_OPTIONS2 = [
|
|
3245
|
-
{ value: "", label: "Toutes d\xE9cisions" },
|
|
3246
|
-
{ value: "true", label: "Escalad\xE9s" },
|
|
3247
|
-
{ value: "false", label: "Non escalad\xE9s" }
|
|
3248
|
-
];
|
|
3249
|
-
var CONFIDENCE_OPTIONS = [
|
|
3250
|
-
{ value: "", label: "Toutes confiances" },
|
|
3251
|
-
{ value: "high", label: TRIAGE_CONFIDENCE_LABELS.high },
|
|
3252
|
-
{ value: "low", label: TRIAGE_CONFIDENCE_LABELS.low }
|
|
3253
|
-
];
|
|
3254
|
-
var STATUS_OPTIONS = [
|
|
3255
|
-
{ value: "", label: "Tous les statuts" },
|
|
3256
|
-
{ value: "ok", label: TRIAGE_DECISION_STATUS_LABELS.ok },
|
|
3257
|
-
{ value: "error", label: TRIAGE_DECISION_STATUS_LABELS.error }
|
|
3258
|
-
];
|
|
3259
|
-
function buildFilter2(escalated, confidence, status) {
|
|
3260
|
-
const filter = {};
|
|
3261
|
-
if (escalated) filter.escalated = { eq: escalated === "true" };
|
|
3262
|
-
if (confidence) filter.escalationConfidence = { eq: confidence };
|
|
3263
|
-
if (status) filter.status = { eq: status };
|
|
3264
|
-
return Object.keys(filter).length > 0 ? filter : void 0;
|
|
3265
|
-
}
|
|
3266
|
-
function ConfidenceBadge({ confidence }) {
|
|
3267
|
-
if (!confidence) return /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "\u2014" });
|
|
3268
|
-
return /* @__PURE__ */ jsx(Badge, { variant: confidence === "high" ? "success" : "warning", children: TRIAGE_CONFIDENCE_LABELS[confidence] });
|
|
3269
|
-
}
|
|
3270
|
-
function StatusBadge({ status, error }) {
|
|
3271
|
-
if (!status) return /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "\u2014" });
|
|
3272
|
-
return /* @__PURE__ */ jsx(Badge, { variant: status === "error" ? "danger" : "neutral", title: status === "error" ? error ?? void 0 : void 0, children: TRIAGE_DECISION_STATUS_LABELS[status] });
|
|
3273
|
-
}
|
|
3274
|
-
function DetailPanel3({ row, categoryName, onClose }) {
|
|
3275
|
-
return /* @__PURE__ */ jsx(SidePanel, { open: true, onClose, title: `Ticket ${row.ticketId}`, description: categoryName, children: /* @__PURE__ */ jsxs("div", { className: "space-y-4 text-sm", children: [
|
|
3276
|
-
row.ticketUrl && /* @__PURE__ */ jsx("p", { children: /* @__PURE__ */ jsx(TicketLink, { ticketId: row.ticketId, url: row.ticketUrl, label: "Ouvrir le ticket dans Gorgias" }) }),
|
|
3277
|
-
row.reasoning && /* @__PURE__ */ jsxs("div", { children: [
|
|
3278
|
-
/* @__PURE__ */ jsx("p", { className: "mb-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Raison du triage" }),
|
|
3279
|
-
/* @__PURE__ */ jsx("p", { children: row.reasoning })
|
|
3280
|
-
] }),
|
|
3281
|
-
row.escalationReasoning && /* @__PURE__ */ jsxs("div", { children: [
|
|
3282
|
-
/* @__PURE__ */ jsx("p", { className: "mb-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Raison de l\u2019escalade" }),
|
|
3283
|
-
/* @__PURE__ */ jsx("p", { children: row.escalationReasoning })
|
|
3284
|
-
] }),
|
|
3285
|
-
row.error && /* @__PURE__ */ jsxs("div", { className: "rounded-md bg-destructive/10 p-3 text-destructive", children: [
|
|
3286
|
-
"Erreur : ",
|
|
3287
|
-
row.error
|
|
3288
|
-
] }),
|
|
3289
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
3290
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
3291
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs uppercase tracking-wide text-muted-foreground", children: "Run parent" }),
|
|
3292
|
-
/* @__PURE__ */ jsx("code", { className: "text-xs", children: row.runId ?? "\u2014" })
|
|
3293
|
-
] }),
|
|
3294
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
3295
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs uppercase tracking-wide text-muted-foreground", children: "D\xE9cid\xE9 le" }),
|
|
3296
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs font-semibold", children: formatDate(row.decidedAt) })
|
|
3297
|
-
] })
|
|
3298
|
-
] }),
|
|
3299
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground", children: [
|
|
3300
|
-
/* @__PURE__ */ jsx("span", { children: "Valeurs brutes" }),
|
|
3301
|
-
/* @__PURE__ */ jsxs("code", { children: [
|
|
3302
|
-
"status=",
|
|
3303
|
-
row.status ?? "\u2014"
|
|
3304
|
-
] }),
|
|
3305
|
-
/* @__PURE__ */ jsxs("code", { children: [
|
|
3306
|
-
"escalationConfidence=",
|
|
3307
|
-
row.escalationConfidence ?? "\u2014"
|
|
3308
|
-
] })
|
|
3309
|
-
] })
|
|
3310
|
-
] }) });
|
|
3311
|
-
}
|
|
3312
|
-
function EscalationsPage() {
|
|
3313
|
-
const [escalatedFilter, setEscalatedFilter] = useState("");
|
|
3314
|
-
const [confidenceFilter, setConfidenceFilter] = useState("");
|
|
3315
|
-
const [statusFilter, setStatusFilter] = useState("");
|
|
3316
|
-
const [detailRow, setDetailRow] = useState(null);
|
|
3317
|
-
const {
|
|
3318
|
-
rows: escalations,
|
|
3319
|
-
isLoading,
|
|
3320
|
-
error,
|
|
3321
|
-
refresh
|
|
3322
|
-
} = useRecordList(
|
|
3323
|
-
"triage-decision",
|
|
3324
|
-
{
|
|
3325
|
-
filter: buildFilter2(escalatedFilter, confidenceFilter, statusFilter),
|
|
3326
|
-
sort: [{ field: "decidedAt", direction: "desc" }],
|
|
3327
|
-
limit: ESCALATIONS_PAGE_SIZE
|
|
3328
|
-
},
|
|
3329
|
-
toTriageDecision
|
|
3330
|
-
);
|
|
3331
|
-
const { rows: categories } = useRecordList("category", { limit: 500 }, toCategory);
|
|
3332
|
-
const categoryNames = useMemo(() => toNameMap(categories), [categories]);
|
|
3333
|
-
const columns = [
|
|
3334
|
-
{ key: "ticketId", header: "Ticket", cell: (row) => /* @__PURE__ */ jsx(TicketLink, { ticketId: row.ticketId, url: row.ticketUrl }) },
|
|
3335
|
-
{ key: "category", header: "Cat\xE9gorie", cell: (row) => row.categoryId && categoryNames.get(row.categoryId) || "\u2014" },
|
|
3336
|
-
{ key: "tag", header: "Tag", cell: (row) => row.tag ? /* @__PURE__ */ jsx("code", { className: "text-xs", children: row.tag }) : "\u2014" },
|
|
3337
|
-
{
|
|
3338
|
-
key: "escalationConfidence",
|
|
3339
|
-
header: "Confiance",
|
|
3340
|
-
cell: (row) => /* @__PURE__ */ jsx(ConfidenceBadge, { confidence: row.escalationConfidence })
|
|
3341
|
-
},
|
|
3342
|
-
// Header is plain "Raison", not "Raison de l'escalade": the cell falls
|
|
3343
|
-
// back to `reasoning` (the TRIAGE reason) for a row the escalation step
|
|
3344
|
-
// left empty, and labelling that as the escalation's own reason is a
|
|
3345
|
-
// lie. Marking the fallback per row would need a second badge in an
|
|
3346
|
-
// already dense table — the detail panel labels the two apart
|
|
3347
|
-
// ("Raison du triage" / "Raison de l’escalade") for whoever needs it.
|
|
3348
|
-
{ key: "escalationReasoning", header: "Raison", cell: (row) => row.escalationReasoning ?? row.reasoning ?? "\u2014" },
|
|
3349
|
-
{
|
|
3350
|
-
key: "status",
|
|
3351
|
-
header: "Statut",
|
|
3352
|
-
cell: (row) => /* @__PURE__ */ jsx(StatusBadge, { status: row.status, error: row.error })
|
|
3353
|
-
},
|
|
3354
|
-
{ key: "decidedAt", header: "D\xE9cid\xE9 le", cell: (row) => formatDate(row.decidedAt) }
|
|
3355
|
-
];
|
|
3356
|
-
return /* @__PURE__ */ jsxs(PageShell, { children: [
|
|
3357
|
-
/* @__PURE__ */ jsx(
|
|
3358
|
-
PageHeader,
|
|
3359
|
-
{
|
|
3360
|
-
title: "Escalades",
|
|
3361
|
-
description: "D\xE9cisions d\u2019escalade humaine \xE9valu\xE9es lors des runs de triage.",
|
|
3362
|
-
actions: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => void refresh(), children: "Actualiser" }) })
|
|
3363
|
-
}
|
|
3364
|
-
),
|
|
3365
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
|
|
3366
|
-
/* @__PURE__ */ jsx(
|
|
3367
|
-
Select,
|
|
3368
|
-
{
|
|
3369
|
-
items: ESCALATED_OPTIONS2,
|
|
3370
|
-
value: escalatedFilter,
|
|
3371
|
-
onValueChange: setEscalatedFilter,
|
|
3372
|
-
placeholder: "Toutes d\xE9cisions",
|
|
3373
|
-
"aria-label": "Filtrer par d\xE9cision"
|
|
3374
|
-
}
|
|
3375
|
-
),
|
|
3376
|
-
/* @__PURE__ */ jsx(
|
|
3377
|
-
Select,
|
|
3378
|
-
{
|
|
3379
|
-
items: CONFIDENCE_OPTIONS,
|
|
3380
|
-
value: confidenceFilter,
|
|
3381
|
-
onValueChange: setConfidenceFilter,
|
|
3382
|
-
placeholder: "Toutes confiances",
|
|
3383
|
-
"aria-label": "Filtrer par confiance"
|
|
3384
|
-
}
|
|
3385
|
-
),
|
|
3386
|
-
/* @__PURE__ */ jsx(
|
|
3387
|
-
Select,
|
|
3388
|
-
{
|
|
3389
|
-
items: STATUS_OPTIONS,
|
|
3390
|
-
value: statusFilter,
|
|
3391
|
-
onValueChange: setStatusFilter,
|
|
3392
|
-
placeholder: "Tous les statuts",
|
|
3393
|
-
"aria-label": "Filtrer par statut"
|
|
3394
|
-
}
|
|
3395
|
-
),
|
|
3396
|
-
escalations.length > 0 && /* @__PURE__ */ jsxs("span", { className: "ml-auto text-sm text-muted-foreground", children: [
|
|
3397
|
-
escalations.length,
|
|
3398
|
-
" r\xE9sultat",
|
|
3399
|
-
escalations.length > 1 ? "s" : ""
|
|
3400
|
-
] })
|
|
3401
|
-
] }),
|
|
3402
|
-
/* @__PURE__ */ jsx(
|
|
3403
|
-
DataTable,
|
|
3404
|
-
{
|
|
3405
|
-
columns,
|
|
3406
|
-
rows: escalations,
|
|
3407
|
-
rowId: (row) => row.id,
|
|
3408
|
-
manual: true,
|
|
3409
|
-
loading: isLoading,
|
|
3410
|
-
onRowClick: (row) => setDetailRow(row),
|
|
3411
|
-
error: error ? /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-3", children: [
|
|
3412
|
-
"Erreur lors du chargement des escalades.",
|
|
3413
|
-
/* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: () => void refresh(), children: "R\xE9essayer" })
|
|
3414
|
-
] }) : void 0,
|
|
3415
|
-
empty: "Aucune d\xE9cision d'escalade pour l'instant."
|
|
3416
|
-
}
|
|
3417
|
-
),
|
|
3418
|
-
detailRow && /* @__PURE__ */ jsx(
|
|
3419
|
-
DetailPanel3,
|
|
3420
|
-
{
|
|
3421
|
-
row: detailRow,
|
|
3422
|
-
categoryName: detailRow.categoryId && categoryNames.get(detailRow.categoryId) || "\u2014",
|
|
3423
|
-
onClose: () => setDetailRow(null)
|
|
3424
|
-
}
|
|
3425
|
-
)
|
|
3426
|
-
] });
|
|
3427
|
-
}
|
|
3428
|
-
|
|
3429
|
-
// src/ui/corrections/corrections-stats.ts
|
|
3430
|
-
function isTextChanged(row) {
|
|
3431
|
-
return Boolean(row.generatedText) && row.generatedText.trim() !== row.sentText.trim();
|
|
3432
|
-
}
|
|
3433
|
-
function toCalendarDay2(iso, timezone) {
|
|
3434
|
-
return new Intl.DateTimeFormat("en-CA", { timeZone: timezone, year: "numeric", month: "2-digit", day: "2-digit" }).format(
|
|
3435
|
-
new Date(iso)
|
|
3436
|
-
);
|
|
3437
|
-
}
|
|
3438
|
-
function wordChangeRatio(row) {
|
|
3439
|
-
if (!row.generatedText) return null;
|
|
3440
|
-
const tokens = row.diff ?? computeWordDiff(row.generatedText, row.sentText);
|
|
3441
|
-
if (tokens.length === 0) return null;
|
|
3442
|
-
const changed = tokens.filter((token) => token.op !== "equal").length;
|
|
3443
|
-
return changed / tokens.length * 100;
|
|
3444
|
-
}
|
|
3445
|
-
function matchPercentage(row) {
|
|
3446
|
-
const changeRatio = wordChangeRatio(row);
|
|
3447
|
-
return changeRatio === null ? null : Math.round(100 - changeRatio);
|
|
3448
|
-
}
|
|
3449
|
-
function versionSeriesKey(promptVersion) {
|
|
3450
|
-
return `v${promptVersion}`;
|
|
3451
|
-
}
|
|
3452
|
-
function computeRewriteRateByVersion(rows, timezone = "UTC") {
|
|
3453
|
-
const byDay = /* @__PURE__ */ new Map();
|
|
3454
|
-
const versions = /* @__PURE__ */ new Set();
|
|
3455
|
-
for (const row of rows) {
|
|
3456
|
-
if (!row.capturedAt || row.promptVersion === null) continue;
|
|
3457
|
-
const ratio = wordChangeRatio(row);
|
|
3458
|
-
if (ratio === null) continue;
|
|
3459
|
-
const day = toCalendarDay2(row.capturedAt, timezone);
|
|
3460
|
-
const byVersion = byDay.get(day) ?? /* @__PURE__ */ new Map();
|
|
3461
|
-
const bucket = byVersion.get(row.promptVersion) ?? { sum: 0, count: 0 };
|
|
3462
|
-
bucket.sum += ratio;
|
|
3463
|
-
bucket.count += 1;
|
|
3464
|
-
byVersion.set(row.promptVersion, bucket);
|
|
3465
|
-
byDay.set(day, byVersion);
|
|
3466
|
-
versions.add(row.promptVersion);
|
|
3467
|
-
}
|
|
3468
|
-
const points = [...byDay.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([day, byVersion]) => {
|
|
3469
|
-
const point = { day };
|
|
3470
|
-
for (const [version, { sum, count }] of byVersion) {
|
|
3471
|
-
point[versionSeriesKey(version)] = Math.round(sum / count);
|
|
3472
|
-
}
|
|
3473
|
-
return point;
|
|
3474
|
-
});
|
|
3475
|
-
return { points, versions: [...versions].sort((a, b) => a - b) };
|
|
3476
|
-
}
|
|
3477
|
-
var PAGE_SIZE = 50;
|
|
3478
|
-
var MATCH_BADGE_CLASS = (pct) => {
|
|
3479
|
-
if (pct >= 80) return "border-status-success/25 bg-status-success/10 text-status-success";
|
|
3480
|
-
if (pct >= 50) return "border-status-warning/25 bg-status-warning/10 text-status-warning";
|
|
3481
|
-
return "border-destructive/25 bg-destructive/10 text-destructive";
|
|
3482
|
-
};
|
|
3483
|
-
var VERSION_LINE_COLORS = 8;
|
|
3484
|
-
function tokensFor(row) {
|
|
3485
|
-
return row.diff ?? computeWordDiff(row.generatedText, row.sentText);
|
|
3486
|
-
}
|
|
3487
|
-
function MatchBadge({ row }) {
|
|
3488
|
-
const pct = matchPercentage(row);
|
|
3489
|
-
if (pct === null) return null;
|
|
3490
|
-
return /* @__PURE__ */ jsxs(Badge, { className: MATCH_BADGE_CLASS(pct), children: [
|
|
3491
|
-
pct,
|
|
3492
|
-
" % de correspondance"
|
|
3493
|
-
] });
|
|
3494
|
-
}
|
|
3495
|
-
function DetailPanel4({
|
|
3496
|
-
row,
|
|
3497
|
-
agentName,
|
|
3498
|
-
langfuseConfig,
|
|
3499
|
-
diffOnly,
|
|
3500
|
-
onClose
|
|
3501
|
-
}) {
|
|
3502
|
-
const tokens = tokensFor(row);
|
|
3503
|
-
return /* @__PURE__ */ jsx(
|
|
3504
|
-
SidePanel,
|
|
3505
|
-
{
|
|
3506
|
-
open: true,
|
|
3507
|
-
onClose,
|
|
3508
|
-
title: `Ticket ${row.ticketId ?? "\u2014"}`,
|
|
3509
|
-
description: agentName,
|
|
3510
|
-
children: /* @__PURE__ */ jsxs("div", { className: "space-y-4 text-sm", children: [
|
|
3511
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
3512
|
-
/* @__PURE__ */ jsx(MatchBadge, { row }),
|
|
3513
|
-
row.ticketUrl && /* @__PURE__ */ jsx(
|
|
3514
|
-
Link,
|
|
3515
|
-
{
|
|
3516
|
-
href: row.ticketUrl,
|
|
3517
|
-
target: "_blank",
|
|
3518
|
-
rel: "noopener noreferrer",
|
|
3519
|
-
className: "text-xs",
|
|
3520
|
-
children: "Ouvrir le ticket"
|
|
3521
|
-
}
|
|
3522
|
-
)
|
|
3523
|
-
] }),
|
|
3524
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-3 sm:grid-cols-2", children: [
|
|
3525
|
-
/* @__PURE__ */ jsx(
|
|
3526
|
-
WordDiffView,
|
|
3527
|
-
{
|
|
3528
|
-
title: "G\xE9n\xE9r\xE9 par l'IA",
|
|
3529
|
-
tokens,
|
|
3530
|
-
keep: "delete",
|
|
3531
|
-
hideEqual: diffOnly
|
|
3532
|
-
}
|
|
3533
|
-
),
|
|
3534
|
-
/* @__PURE__ */ jsx(
|
|
3535
|
-
WordDiffView,
|
|
3536
|
-
{
|
|
3537
|
-
title: "Envoy\xE9 par l'agent",
|
|
3538
|
-
tokens,
|
|
3539
|
-
keep: "insert",
|
|
3540
|
-
hideEqual: diffOnly
|
|
3541
|
-
}
|
|
3542
|
-
)
|
|
3543
|
-
] }),
|
|
3544
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground", children: [
|
|
3545
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
3546
|
-
"Captur\xE9 le ",
|
|
3547
|
-
formatDate(row.capturedAt)
|
|
3548
|
-
] }),
|
|
3549
|
-
row.promptName && /* @__PURE__ */ jsxs("span", { children: [
|
|
3550
|
-
"Prompt : ",
|
|
3551
|
-
/* @__PURE__ */ jsx("code", { children: row.promptName }),
|
|
3552
|
-
row.promptVersion !== null ? ` v${row.promptVersion}` : ""
|
|
3553
|
-
] })
|
|
3554
|
-
] }),
|
|
3555
|
-
(row.langfuseTraceId || row.langfuseObservationId) && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
|
|
3556
|
-
/* @__PURE__ */ jsx(
|
|
3557
|
-
LangfuseTraceLink,
|
|
3558
|
-
{
|
|
3559
|
-
traceId: row.langfuseTraceId,
|
|
3560
|
-
config: langfuseConfig,
|
|
3561
|
-
label: "Trace g\xE9n\xE9ration"
|
|
3562
|
-
}
|
|
3563
|
-
),
|
|
3564
|
-
/* @__PURE__ */ jsx(
|
|
3565
|
-
LangfuseTraceLink,
|
|
3566
|
-
{
|
|
3567
|
-
traceId: row.langfuseTraceId,
|
|
3568
|
-
observationId: row.langfuseObservationId,
|
|
3569
|
-
config: langfuseConfig,
|
|
3570
|
-
label: "Trace \xE9valuation"
|
|
3571
|
-
}
|
|
3572
|
-
)
|
|
3573
|
-
] })
|
|
3574
|
-
] })
|
|
3575
|
-
}
|
|
3576
|
-
);
|
|
3577
|
-
}
|
|
3578
|
-
function CorrectionsPage() {
|
|
3579
|
-
const { role, appSlug } = useAppContext();
|
|
3580
|
-
const canWrite = canWriteForRole(role);
|
|
3581
|
-
const api = useAppApi();
|
|
3582
|
-
const toast = useToast();
|
|
3583
|
-
const { config: langfuseConfig } = useLangfuseConfig();
|
|
3584
|
-
const { settings } = useAppSettings();
|
|
3585
|
-
const timezone = settings?.statsTimezone ?? "UTC";
|
|
3586
|
-
const [agentFilter, setAgentFilter] = useState("");
|
|
3587
|
-
const [versionFilter, setVersionFilter] = useState("");
|
|
3588
|
-
const [diffOnly, setDiffOnly] = useState(false);
|
|
3589
|
-
const [detailRow, setDetailRow] = useState(null);
|
|
3590
|
-
const [isAnalyzing, setIsAnalyzing] = useState(false);
|
|
3591
|
-
const [pendingDeleteRow, setPendingDeleteRow] = useState(null);
|
|
3592
|
-
const [pendingDeleteAll, setPendingDeleteAll] = useState(false);
|
|
3593
|
-
const [isDeleting, setIsDeleting] = useState(false);
|
|
3594
|
-
function handleAgentFilterChange(value) {
|
|
3595
|
-
setAgentFilter(value);
|
|
3596
|
-
setVersionFilter("");
|
|
3597
|
-
}
|
|
3598
|
-
const comparisonFilter = useMemo(() => {
|
|
3599
|
-
if (!agentFilter) return void 0;
|
|
3600
|
-
const filter = { agentId: { eq: agentFilter } };
|
|
3601
|
-
if (versionFilter !== "") filter.promptVersion = { eq: Number(versionFilter) };
|
|
3602
|
-
return filter;
|
|
3603
|
-
}, [agentFilter, versionFilter]);
|
|
3604
|
-
const {
|
|
3605
|
-
rows: comparisons,
|
|
3606
|
-
isLoading,
|
|
3607
|
-
error,
|
|
3608
|
-
refresh,
|
|
3609
|
-
hasNextPage,
|
|
3610
|
-
hasPreviousPage,
|
|
3611
|
-
goToNextPage,
|
|
3612
|
-
goToPreviousPage
|
|
3613
|
-
} = useRecordList(
|
|
3614
|
-
"response-comparison",
|
|
3615
|
-
{
|
|
3616
|
-
filter: comparisonFilter,
|
|
3617
|
-
sort: [{ field: "capturedAt", direction: "desc" }],
|
|
3618
|
-
limit: PAGE_SIZE,
|
|
3619
|
-
paginate: true
|
|
3620
|
-
},
|
|
3621
|
-
toResponseComparison
|
|
3622
|
-
);
|
|
3623
|
-
const visibleRows = useMemo(
|
|
3624
|
-
() => diffOnly ? comparisons.filter(isTextChanged) : comparisons,
|
|
3625
|
-
[comparisons, diffOnly]
|
|
3626
|
-
);
|
|
3627
|
-
const { rows: agents } = useRecordList("agent", { limit: 500 }, toAgent);
|
|
3628
|
-
const agentNames = useMemo(() => toNameMap(agents), [agents]);
|
|
3629
|
-
const selectedAgent = agents.find((a) => a.id === agentFilter);
|
|
3630
|
-
const { versions: promptVersions } = usePromptVersions(selectedAgent?.promptName ?? null);
|
|
3631
|
-
const versionOptions = [
|
|
3632
|
-
{ value: "", label: "Toutes les versions" },
|
|
3633
|
-
...promptVersions.map((v) => ({
|
|
3634
|
-
value: String(v.version),
|
|
3635
|
-
label: `v${v.version}${v.labels.includes("production") ? " (active)" : ""}`
|
|
3636
|
-
}))
|
|
3637
|
-
];
|
|
3638
|
-
const { rows: diffAnalyses, refresh: refreshDiffAnalyses } = useRecordList(
|
|
3639
|
-
"diff-analysis",
|
|
3640
|
-
{ filter: agentFilter ? { agentId: { eq: agentFilter } } : void 0, limit: 50 },
|
|
3641
|
-
toDiffAnalysis
|
|
3642
|
-
);
|
|
3643
|
-
const sortedAnalyses = useMemo(
|
|
3644
|
-
() => [...diffAnalyses].sort((a, b) => b.promptVersion - a.promptVersion),
|
|
3645
|
-
[diffAnalyses]
|
|
3646
|
-
);
|
|
3647
|
-
const rewriteRate = useMemo(
|
|
3648
|
-
() => computeRewriteRateByVersion(comparisons, timezone),
|
|
3649
|
-
[comparisons, timezone]
|
|
3650
|
-
);
|
|
3651
|
-
const rewriteRateSeries = useMemo(
|
|
3652
|
-
() => rewriteRate.versions.map((version, index) => ({
|
|
3653
|
-
key: versionSeriesKey(version),
|
|
3654
|
-
label: `v${version}`,
|
|
3655
|
-
colorIndex: index % VERSION_LINE_COLORS
|
|
3656
|
-
})),
|
|
3657
|
-
[rewriteRate.versions]
|
|
3658
|
-
);
|
|
3659
|
-
const agentOptions = [
|
|
3660
|
-
{ value: "", label: "Tous les agents" },
|
|
3661
|
-
...agents.map((a) => ({ value: a.id, label: a.name }))
|
|
3662
|
-
];
|
|
3663
|
-
async function runAnalysis() {
|
|
3664
|
-
if (!agentFilter) return;
|
|
3665
|
-
setIsAnalyzing(true);
|
|
3666
|
-
const payload = { agentId: agentFilter, limit: 50 };
|
|
2987
|
+
const data = { fastResponseEnabled: next };
|
|
2988
|
+
if (!next && category.autoReplyEnabled) data.autoReplyEnabled = false;
|
|
3667
2989
|
try {
|
|
3668
|
-
await api.
|
|
3669
|
-
|
|
3670
|
-
});
|
|
3671
|
-
toast({ title: "Analyse lanc\xE9e \u2014 les nouveaux points sont ci-dessous.", variant: "success" });
|
|
3672
|
-
await refreshDiffAnalyses();
|
|
2990
|
+
await api.patch(categoryPath(category.id), { data });
|
|
2991
|
+
await refreshCategories();
|
|
3673
2992
|
} catch (err) {
|
|
3674
|
-
toast({
|
|
3675
|
-
title: "\xC9chec de l'analyse",
|
|
3676
|
-
description: describeInvokeError(err),
|
|
3677
|
-
variant: "error"
|
|
3678
|
-
});
|
|
3679
|
-
} finally {
|
|
3680
|
-
setIsAnalyzing(false);
|
|
2993
|
+
toast({ title: "\xC9chec de la mise \xE0 jour", description: describeApiError(err), variant: "error" });
|
|
3681
2994
|
}
|
|
3682
2995
|
}
|
|
3683
|
-
|
|
3684
|
-
async function confirmDeleteRow() {
|
|
3685
|
-
if (!pendingDeleteRow) return;
|
|
3686
|
-
const row = pendingDeleteRow;
|
|
3687
|
-
setIsDeleting(true);
|
|
2996
|
+
async function toggleAutoReply(category) {
|
|
3688
2997
|
try {
|
|
3689
|
-
await api.
|
|
3690
|
-
await
|
|
3691
|
-
toast({ title: "Comparaison supprim\xE9e.", variant: "success" });
|
|
2998
|
+
await api.patch(categoryPath(category.id), { data: { autoReplyEnabled: !category.autoReplyEnabled } });
|
|
2999
|
+
await refreshCategories();
|
|
3692
3000
|
} catch (err) {
|
|
3693
|
-
toast({
|
|
3694
|
-
title: "\xC9chec de la suppression",
|
|
3695
|
-
description: describeApiError(err),
|
|
3696
|
-
variant: "error"
|
|
3697
|
-
});
|
|
3698
|
-
} finally {
|
|
3699
|
-
setIsDeleting(false);
|
|
3700
|
-
setPendingDeleteRow(null);
|
|
3001
|
+
toast({ title: "\xC9chec de la mise \xE0 jour", description: describeApiError(err), variant: "error" });
|
|
3701
3002
|
}
|
|
3702
3003
|
}
|
|
3703
|
-
async function
|
|
3704
|
-
|
|
3004
|
+
async function move(category, direction) {
|
|
3005
|
+
const siblings = byGroup.get(category.groupId ?? UNGROUPED_KEY) ?? [];
|
|
3006
|
+
const index = siblings.findIndex((c) => c.id === category.id);
|
|
3007
|
+
const swapWith = siblings[index + direction];
|
|
3008
|
+
if (!swapWith) return;
|
|
3705
3009
|
try {
|
|
3706
|
-
await
|
|
3707
|
-
await
|
|
3708
|
-
|
|
3010
|
+
await api.patch(categoryPath(category.id), { data: { order: swapWith.order } });
|
|
3011
|
+
await api.patch(categoryPath(swapWith.id), { data: { order: category.order } });
|
|
3012
|
+
await refreshCategories();
|
|
3709
3013
|
} catch (err) {
|
|
3710
|
-
toast({
|
|
3711
|
-
|
|
3712
|
-
description: describeApiError(err),
|
|
3713
|
-
variant: "error"
|
|
3714
|
-
});
|
|
3715
|
-
} finally {
|
|
3716
|
-
setIsDeleting(false);
|
|
3717
|
-
setPendingDeleteAll(false);
|
|
3014
|
+
toast({ title: "\xC9chec du r\xE9ordonnancement", description: describeApiError(err), variant: "error" });
|
|
3015
|
+
await refreshCategories();
|
|
3718
3016
|
}
|
|
3719
3017
|
}
|
|
3720
|
-
|
|
3721
|
-
{
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
key: "agent",
|
|
3737
|
-
header: "Agent",
|
|
3738
|
-
cell: (row) => row.agentId && agentNames.get(row.agentId) || "\u2014"
|
|
3739
|
-
},
|
|
3740
|
-
{
|
|
3741
|
-
key: "changed",
|
|
3742
|
-
header: "R\xE9sultat",
|
|
3743
|
-
cell: (row) => isTextChanged(row) ? /* @__PURE__ */ jsx(Badge, { variant: "warning", children: "Modifi\xE9" }) : /* @__PURE__ */ jsx(Badge, { variant: "neutral", children: "Identique" })
|
|
3744
|
-
},
|
|
3745
|
-
{ key: "match", header: "Correspondance", cell: (row) => /* @__PURE__ */ jsx(MatchBadge, { row }) },
|
|
3746
|
-
{ key: "capturedAt", header: "Captur\xE9 le", cell: (row) => formatDate(row.capturedAt) },
|
|
3747
|
-
...canWrite ? [
|
|
3748
|
-
{
|
|
3749
|
-
key: "actions",
|
|
3750
|
-
header: "",
|
|
3751
|
-
cell: (row) => /* @__PURE__ */ jsx(
|
|
3018
|
+
function renderCategoryList(groupCategories) {
|
|
3019
|
+
return /* @__PURE__ */ jsx("div", { className: "space-y-2", children: groupCategories.map((category, index) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 rounded-md border p-2", children: [
|
|
3020
|
+
canWrite && /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
3021
|
+
/* @__PURE__ */ jsx(
|
|
3022
|
+
Button,
|
|
3023
|
+
{
|
|
3024
|
+
type: "button",
|
|
3025
|
+
variant: "ghost",
|
|
3026
|
+
"aria-label": `Monter \u2014 ${category.name}`,
|
|
3027
|
+
disabled: index === 0,
|
|
3028
|
+
onClick: () => void move(category, -1),
|
|
3029
|
+
className: "h-4 min-w-0 p-0 text-xs leading-none",
|
|
3030
|
+
children: "\u25B2"
|
|
3031
|
+
}
|
|
3032
|
+
),
|
|
3033
|
+
/* @__PURE__ */ jsx(
|
|
3752
3034
|
Button,
|
|
3753
3035
|
{
|
|
3036
|
+
type: "button",
|
|
3754
3037
|
variant: "ghost",
|
|
3038
|
+
"aria-label": `Descendre \u2014 ${category.name}`,
|
|
3039
|
+
disabled: index === groupCategories.length - 1,
|
|
3040
|
+
onClick: () => void move(category, 1),
|
|
3041
|
+
className: "h-4 min-w-0 p-0 text-xs leading-none",
|
|
3042
|
+
children: "\u25BC"
|
|
3043
|
+
}
|
|
3044
|
+
)
|
|
3045
|
+
] }),
|
|
3046
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-1", children: [
|
|
3047
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: category.name }),
|
|
3048
|
+
/* @__PURE__ */ jsx("code", { className: "text-xs text-muted-foreground", children: category.tagName })
|
|
3049
|
+
] }),
|
|
3050
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
3051
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "R\xE9ponse rapide" }),
|
|
3052
|
+
/* @__PURE__ */ jsx(
|
|
3053
|
+
Switch,
|
|
3054
|
+
{
|
|
3055
|
+
"aria-label": `R\xE9ponse rapide \u2014 ${category.name}`,
|
|
3056
|
+
checked: category.fastResponseEnabled,
|
|
3057
|
+
onCheckedChange: () => void toggleFastResponse(category),
|
|
3058
|
+
disabled: !canWrite || !category.agentId
|
|
3059
|
+
}
|
|
3060
|
+
)
|
|
3061
|
+
] }),
|
|
3062
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
3063
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "Envoi auto" }),
|
|
3064
|
+
/* @__PURE__ */ jsx(
|
|
3065
|
+
Switch,
|
|
3066
|
+
{
|
|
3067
|
+
"aria-label": `Envoi auto \u2014 ${category.name}`,
|
|
3068
|
+
checked: category.autoReplyEnabled,
|
|
3069
|
+
onCheckedChange: () => void toggleAutoReply(category),
|
|
3070
|
+
disabled: !canWrite || !category.fastResponseEnabled || !category.agentId
|
|
3071
|
+
}
|
|
3072
|
+
)
|
|
3073
|
+
] }),
|
|
3074
|
+
category.extraTags.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex gap-1", children: category.extraTags.map((tag) => /* @__PURE__ */ jsx(Badge, { variant: "outline", children: tag }, tag)) }),
|
|
3075
|
+
canWrite && /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
3076
|
+
/* @__PURE__ */ jsx(
|
|
3077
|
+
Button,
|
|
3078
|
+
{
|
|
3079
|
+
variant: "outline",
|
|
3755
3080
|
size: "sm",
|
|
3756
|
-
onClick: (
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3081
|
+
onClick: () => setCategoryForm({ groupId: category.groupId ?? UNGROUPED_KEY, category }),
|
|
3082
|
+
children: "Modifier"
|
|
3083
|
+
}
|
|
3084
|
+
),
|
|
3085
|
+
/* @__PURE__ */ jsx(
|
|
3086
|
+
Button,
|
|
3087
|
+
{
|
|
3088
|
+
variant: "outline",
|
|
3089
|
+
size: "sm",
|
|
3090
|
+
"aria-label": `Supprimer \u2014 ${category.name}`,
|
|
3091
|
+
onClick: () => setDeletingCategory(category),
|
|
3760
3092
|
children: "Supprimer"
|
|
3761
3093
|
}
|
|
3762
3094
|
)
|
|
3763
|
-
}
|
|
3764
|
-
]
|
|
3765
|
-
|
|
3095
|
+
] })
|
|
3096
|
+
] }, category.id)) });
|
|
3097
|
+
}
|
|
3098
|
+
const isLoading = groupsLoading || categoriesLoading;
|
|
3099
|
+
const loadError = groupsError ?? categoriesError;
|
|
3100
|
+
const ungrouped = byGroup.get(UNGROUPED_KEY) ?? [];
|
|
3766
3101
|
return /* @__PURE__ */ jsxs(PageShell, { children: [
|
|
3767
3102
|
/* @__PURE__ */ jsx(
|
|
3768
3103
|
PageHeader,
|
|
3769
3104
|
{
|
|
3770
|
-
title: "
|
|
3771
|
-
description: "
|
|
3772
|
-
actions:
|
|
3105
|
+
title: "Cat\xE9gories",
|
|
3106
|
+
description: "R\xE9f\xE9rentiel de cat\xE9gorisation des tickets.",
|
|
3107
|
+
actions: canWrite && /* @__PURE__ */ jsx(Button, { onClick: () => setNewGroup(true), children: "Nouveau groupe" })
|
|
3773
3108
|
}
|
|
3774
3109
|
),
|
|
3775
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-
|
|
3776
|
-
/* @__PURE__ */ jsx(
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
variant: diffOnly ? "default" : "outline",
|
|
3801
|
-
size: "sm",
|
|
3802
|
-
onClick: () => setDiffOnly((v) => !v),
|
|
3803
|
-
children: diffOnly ? "Afficher toutes les lignes" : "Masquer les lignes identiques"
|
|
3804
|
-
}
|
|
3805
|
-
),
|
|
3806
|
-
canWrite && agentFilter && /* @__PURE__ */ jsx(
|
|
3807
|
-
Button,
|
|
3808
|
-
{
|
|
3809
|
-
variant: "outline",
|
|
3810
|
-
size: "sm",
|
|
3811
|
-
onClick: () => setPendingDeleteAll(true),
|
|
3812
|
-
disabled: isDeleting,
|
|
3813
|
-
children: "Tout supprimer"
|
|
3814
|
-
}
|
|
3815
|
-
)
|
|
3816
|
-
] }),
|
|
3817
|
-
/* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsxs(CardContent, { className: "p-4", children: [
|
|
3818
|
-
/* @__PURE__ */ jsx("p", { className: "mb-1 text-sm font-medium", children: "Taux de r\xE9\xE9criture" }),
|
|
3819
|
-
/* @__PURE__ */ jsx("p", { className: "mb-3 text-xs text-muted-foreground", children: "Part moyenne de la r\xE9ponse IA modifi\xE9e avant envoi, par version de prompt \u2014 plus le taux est bas, mieux c'est." }),
|
|
3820
|
-
rewriteRate.points.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Aucune donn\xE9e de r\xE9\xE9criture pour cette s\xE9lection." }) : /* @__PURE__ */ jsx(
|
|
3821
|
-
LineChart,
|
|
3822
|
-
{
|
|
3823
|
-
data: rewriteRate.points,
|
|
3824
|
-
x: "day",
|
|
3825
|
-
series: rewriteRateSeries,
|
|
3826
|
-
formatValue: (v) => `${v}%`
|
|
3827
|
-
}
|
|
3828
|
-
)
|
|
3829
|
-
] }) }),
|
|
3830
|
-
agentFilter && /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsxs(CardContent, { className: "space-y-3 p-4", children: [
|
|
3831
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
3832
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
3833
|
-
/* @__PURE__ */ jsxs("p", { className: "text-sm font-medium", children: [
|
|
3834
|
-
"Analyse des corrections \u2014 ",
|
|
3835
|
-
selectedAgent?.name ?? agentFilter
|
|
3110
|
+
loadError ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-3 py-12", children: [
|
|
3111
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: "Erreur lors du chargement des cat\xE9gories." }),
|
|
3112
|
+
/* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => void Promise.all([refreshGroups(), refreshCategories()]), children: "R\xE9essayer" })
|
|
3113
|
+
] }) : isLoading ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center py-12", children: [
|
|
3114
|
+
/* @__PURE__ */ jsx(Spinner, {}),
|
|
3115
|
+
" ",
|
|
3116
|
+
/* @__PURE__ */ jsx("span", { className: "ml-2 text-sm text-muted-foreground", children: "Chargement\u2026" })
|
|
3117
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3118
|
+
groups.slice().sort((a, b) => a.order - b.order).map((group) => {
|
|
3119
|
+
const groupCategories = byGroup.get(group.id) ?? [];
|
|
3120
|
+
return /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsxs(CardContent, { className: "space-y-2 p-4", children: [
|
|
3121
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
3122
|
+
/* @__PURE__ */ jsx("h2", { className: "font-medium", children: group.name }),
|
|
3123
|
+
canWrite && /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
3124
|
+
/* @__PURE__ */ jsx(
|
|
3125
|
+
Button,
|
|
3126
|
+
{
|
|
3127
|
+
variant: "outline",
|
|
3128
|
+
size: "sm",
|
|
3129
|
+
onClick: () => setCategoryForm({ groupId: group.id, category: null }),
|
|
3130
|
+
children: "Ajouter une cat\xE9gorie"
|
|
3131
|
+
}
|
|
3132
|
+
),
|
|
3133
|
+
/* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: () => setDeletingGroup(group), children: "Supprimer le groupe" })
|
|
3134
|
+
] })
|
|
3836
3135
|
] }),
|
|
3837
|
-
|
|
3838
|
-
] }),
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3136
|
+
renderCategoryList(groupCategories)
|
|
3137
|
+
] }) }, group.id);
|
|
3138
|
+
}),
|
|
3139
|
+
/* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsxs(CardContent, { className: "space-y-2 p-4", children: [
|
|
3140
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
3141
|
+
/* @__PURE__ */ jsx("h2", { className: "font-medium", children: "Sans groupe" }),
|
|
3142
|
+
canWrite && /* @__PURE__ */ jsx(
|
|
3143
|
+
Button,
|
|
3144
|
+
{
|
|
3145
|
+
variant: "outline",
|
|
3146
|
+
size: "sm",
|
|
3147
|
+
onClick: () => setCategoryForm({ groupId: UNGROUPED_KEY, category: null }),
|
|
3148
|
+
children: "Ajouter une cat\xE9gorie"
|
|
3149
|
+
}
|
|
3150
|
+
)
|
|
3849
3151
|
] }),
|
|
3850
|
-
/* @__PURE__ */ jsx("
|
|
3851
|
-
] }
|
|
3852
|
-
] })
|
|
3853
|
-
/* @__PURE__ */ jsx(
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
columns,
|
|
3857
|
-
rows: visibleRows,
|
|
3858
|
-
rowId: (row) => row.id,
|
|
3859
|
-
manual: true,
|
|
3860
|
-
loading: isLoading,
|
|
3861
|
-
onRowClick: (row) => setDetailRow(row),
|
|
3862
|
-
pagination: {
|
|
3863
|
-
hasNext: hasNextPage,
|
|
3864
|
-
hasPrevious: hasPreviousPage,
|
|
3865
|
-
onNext: goToNextPage,
|
|
3866
|
-
onPrevious: goToPreviousPage
|
|
3867
|
-
},
|
|
3868
|
-
error: error !== void 0 ? /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-3", children: [
|
|
3869
|
-
"Erreur lors du chargement des corrections.",
|
|
3870
|
-
/* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: () => void refresh(), children: "R\xE9essayer" })
|
|
3871
|
-
] }) : void 0,
|
|
3872
|
-
empty: "Aucune correction enregistr\xE9e pour l'instant."
|
|
3873
|
-
}
|
|
3874
|
-
),
|
|
3875
|
-
detailRow && /* @__PURE__ */ jsx(
|
|
3876
|
-
DetailPanel4,
|
|
3152
|
+
ungrouped.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Aucune cat\xE9gorie sans groupe." }) : renderCategoryList(ungrouped)
|
|
3153
|
+
] }) })
|
|
3154
|
+
] }),
|
|
3155
|
+
newGroup && /* @__PURE__ */ jsx(GroupFormModal, { onClose: () => setNewGroup(false), onSave: createGroup }),
|
|
3156
|
+
categoryForm && /* @__PURE__ */ jsx(
|
|
3157
|
+
CategoryFormModal,
|
|
3877
3158
|
{
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3159
|
+
groupId: categoryForm.groupId,
|
|
3160
|
+
category: categoryForm.category,
|
|
3161
|
+
agents,
|
|
3162
|
+
onClose: () => setCategoryForm(null),
|
|
3163
|
+
onSave: saveCategory
|
|
3883
3164
|
}
|
|
3884
3165
|
),
|
|
3885
|
-
|
|
3166
|
+
deletingGroup && /* @__PURE__ */ jsx(
|
|
3886
3167
|
ConfirmModal,
|
|
3887
3168
|
{
|
|
3888
|
-
title: "Supprimer
|
|
3889
|
-
description:
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3169
|
+
title: "Supprimer le groupe ?",
|
|
3170
|
+
description: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3171
|
+
"Le groupe \xAB ",
|
|
3172
|
+
deletingGroup.name,
|
|
3173
|
+
" \xBB sera supprim\xE9. Ses cat\xE9gories ne seront PAS supprim\xE9es \u2014 elles passeront dans \xAB Sans groupe \xBB."
|
|
3174
|
+
] }),
|
|
3175
|
+
confirmLabel: "Supprimer le groupe",
|
|
3176
|
+
onConfirm: confirmDeleteGroup,
|
|
3177
|
+
onCancel: () => setDeletingGroup(null)
|
|
3893
3178
|
}
|
|
3894
3179
|
),
|
|
3895
|
-
|
|
3180
|
+
deletingCategory && /* @__PURE__ */ jsx(
|
|
3896
3181
|
ConfirmModal,
|
|
3897
3182
|
{
|
|
3898
|
-
title: "Supprimer
|
|
3899
|
-
description:
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3183
|
+
title: "Supprimer la cat\xE9gorie ?",
|
|
3184
|
+
description: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3185
|
+
"La cat\xE9gorie \xAB ",
|
|
3186
|
+
deletingCategory.name,
|
|
3187
|
+
" \xBB sera supprim\xE9e. Les tickets d\xE9j\xE0 tagu\xE9s",
|
|
3188
|
+
" ",
|
|
3189
|
+
/* @__PURE__ */ jsx("code", { children: deletingCategory.tagName }),
|
|
3190
|
+
" ne seront plus reconnus par le triage."
|
|
3191
|
+
] }),
|
|
3192
|
+
confirmLabel: "Supprimer la cat\xE9gorie",
|
|
3193
|
+
onConfirm: confirmDeleteCategory,
|
|
3194
|
+
onCancel: () => setDeletingCategory(null)
|
|
3903
3195
|
}
|
|
3904
3196
|
)
|
|
3905
3197
|
] });
|
|
@@ -3946,9 +3238,9 @@ function PipelineNodesForm({
|
|
|
3946
3238
|
let changed = false;
|
|
3947
3239
|
const next = { ...prev };
|
|
3948
3240
|
for (const key of PIPELINE_STEP_KEYS) {
|
|
3949
|
-
const
|
|
3950
|
-
if (
|
|
3951
|
-
next[key] =
|
|
3241
|
+
const step2 = readStep(value, key);
|
|
3242
|
+
if (step2 && JSON.stringify(step2) !== JSON.stringify(prev[key])) {
|
|
3243
|
+
next[key] = step2;
|
|
3952
3244
|
changed = true;
|
|
3953
3245
|
}
|
|
3954
3246
|
}
|
|
@@ -3977,26 +3269,26 @@ function PipelineNodesForm({
|
|
|
3977
3269
|
) }, preset.id))
|
|
3978
3270
|
] }),
|
|
3979
3271
|
/* @__PURE__ */ jsx("p", { className: "-mt-2 text-xs text-muted-foreground", children: "Un pr\xE9r\xE9glage remplit ce formulaire \u2014 il n'enregistre rien tant que vous n'avez pas cliqu\xE9 sur Enregistrer." }),
|
|
3980
|
-
/* @__PURE__ */ jsx("div", { className: "divide-y rounded-md border", children: PIPELINE_STEPS.map((
|
|
3272
|
+
/* @__PURE__ */ jsx("div", { className: "divide-y rounded-md border", children: PIPELINE_STEPS.map((step2) => /* @__PURE__ */ jsx(
|
|
3981
3273
|
StepRow,
|
|
3982
3274
|
{
|
|
3983
|
-
step,
|
|
3275
|
+
step: step2,
|
|
3984
3276
|
value,
|
|
3985
3277
|
canWrite,
|
|
3986
|
-
issueMessage:
|
|
3278
|
+
issueMessage: step2.key === "triage" ? issueMessage : null,
|
|
3987
3279
|
prompts,
|
|
3988
3280
|
promptsLoading,
|
|
3989
3281
|
models,
|
|
3990
3282
|
modelsLoading,
|
|
3991
|
-
onToggle: (on) => toggleStep(
|
|
3992
|
-
onPatch: (patch) => onChange(withStepFields(value,
|
|
3283
|
+
onToggle: (on) => toggleStep(step2.key, on),
|
|
3284
|
+
onPatch: (patch) => onChange(withStepFields(value, step2.key, patch))
|
|
3993
3285
|
},
|
|
3994
|
-
|
|
3286
|
+
step2.key
|
|
3995
3287
|
)) })
|
|
3996
3288
|
] });
|
|
3997
3289
|
}
|
|
3998
3290
|
function StepRow({
|
|
3999
|
-
step,
|
|
3291
|
+
step: step2,
|
|
4000
3292
|
value,
|
|
4001
3293
|
canWrite,
|
|
4002
3294
|
issueMessage,
|
|
@@ -4007,15 +3299,15 @@ function StepRow({
|
|
|
4007
3299
|
onToggle,
|
|
4008
3300
|
onPatch
|
|
4009
3301
|
}) {
|
|
4010
|
-
const enabled = isStepEnabled(value,
|
|
4011
|
-
const blockedReason = stepBlockedReason(value,
|
|
3302
|
+
const enabled = isStepEnabled(value, step2.key);
|
|
3303
|
+
const blockedReason = stepBlockedReason(value, step2.key);
|
|
4012
3304
|
const promptFieldId = useId();
|
|
4013
|
-
const triageLocked =
|
|
3305
|
+
const triageLocked = step2.key === "triage" && enabled;
|
|
4014
3306
|
const editable = canWrite && !blockedReason && !triageLocked;
|
|
4015
3307
|
const toggle = /* @__PURE__ */ jsx(
|
|
4016
3308
|
Switch,
|
|
4017
3309
|
{
|
|
4018
|
-
"aria-label": `${
|
|
3310
|
+
"aria-label": `${step2.label} \u2014 activer l'\xE9tape`,
|
|
4019
3311
|
checked: enabled,
|
|
4020
3312
|
onCheckedChange: onToggle,
|
|
4021
3313
|
disabled: !editable
|
|
@@ -4024,8 +3316,8 @@ function StepRow({
|
|
|
4024
3316
|
return /* @__PURE__ */ jsxs("div", { className: blockedReason ? "space-y-2 p-4 opacity-60" : "space-y-2 p-4", children: [
|
|
4025
3317
|
/* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-3", children: [
|
|
4026
3318
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
4027
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children:
|
|
4028
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children:
|
|
3319
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: step2.label }),
|
|
3320
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: step2.description })
|
|
4029
3321
|
] }),
|
|
4030
3322
|
/* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-2 text-sm", children: [
|
|
4031
3323
|
triageLocked ? /* @__PURE__ */ jsx(Tooltip, { label: TRIAGE_LOCK_REASON, children: toggle }) : toggle,
|
|
@@ -4040,8 +3332,8 @@ function StepRow({
|
|
|
4040
3332
|
/* @__PURE__ */ jsx("div", { className: "rounded-md bg-muted/40 p-3", children: /* @__PURE__ */ jsx(
|
|
4041
3333
|
StepPromptField,
|
|
4042
3334
|
{
|
|
4043
|
-
step,
|
|
4044
|
-
settings: readStep(value,
|
|
3335
|
+
step: step2,
|
|
3336
|
+
settings: readStep(value, step2.key),
|
|
4045
3337
|
disabled: !canWrite || blockedReason !== null,
|
|
4046
3338
|
prompts,
|
|
4047
3339
|
promptsLoading,
|
|
@@ -4054,8 +3346,8 @@ function StepRow({
|
|
|
4054
3346
|
/* @__PURE__ */ jsx("div", { className: "mt-3 grid gap-4 rounded-md bg-muted/40 p-3 sm:grid-cols-2", children: /* @__PURE__ */ jsx(
|
|
4055
3347
|
StepOptions,
|
|
4056
3348
|
{
|
|
4057
|
-
step,
|
|
4058
|
-
settings: readStep(value,
|
|
3349
|
+
step: step2,
|
|
3350
|
+
settings: readStep(value, step2.key),
|
|
4059
3351
|
disabled: !canWrite || blockedReason !== null,
|
|
4060
3352
|
models,
|
|
4061
3353
|
modelsLoading,
|
|
@@ -4066,7 +3358,7 @@ function StepRow({
|
|
|
4066
3358
|
] });
|
|
4067
3359
|
}
|
|
4068
3360
|
function StepOptions({
|
|
4069
|
-
step,
|
|
3361
|
+
step: step2,
|
|
4070
3362
|
settings,
|
|
4071
3363
|
disabled,
|
|
4072
3364
|
models,
|
|
@@ -4077,15 +3369,15 @@ function StepOptions({
|
|
|
4077
3369
|
const known = models.includes(model);
|
|
4078
3370
|
const [freeText, setFreeText] = useState(false);
|
|
4079
3371
|
const showFreeText = freeText || model !== "" && !known && !modelsLoading;
|
|
4080
|
-
const ids = useIds(
|
|
3372
|
+
const ids = useIds(step2.key);
|
|
4081
3373
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4082
3374
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
4083
3375
|
/* @__PURE__ */ jsx("label", { htmlFor: ids.model, className: "mb-1 block text-sm font-medium", children: "Mod\xE8le" }),
|
|
4084
3376
|
/* @__PURE__ */ jsx(
|
|
4085
3377
|
Select,
|
|
4086
3378
|
{
|
|
4087
|
-
"aria-label": `Mod\xE8le \u2014 ${
|
|
4088
|
-
value: showFreeText ? CUSTOM_MODEL_VALUE :
|
|
3379
|
+
"aria-label": `Mod\xE8le \u2014 ${step2.label}`,
|
|
3380
|
+
value: showFreeText ? CUSTOM_MODEL_VALUE : model,
|
|
4089
3381
|
onValueChange: (next) => {
|
|
4090
3382
|
if (next === CUSTOM_MODEL_VALUE) {
|
|
4091
3383
|
setFreeText(true);
|
|
@@ -4095,6 +3387,9 @@ function StepOptions({
|
|
|
4095
3387
|
onPatch({ model: next, provider: DEFAULT_STEP_PROVIDER });
|
|
4096
3388
|
},
|
|
4097
3389
|
items: [
|
|
3390
|
+
// The stored model, listed so the trigger can print it while the
|
|
3391
|
+
// provider's own list is still loading.
|
|
3392
|
+
...!showFreeText && model !== "" && !known ? [{ value: model, label: model }] : [],
|
|
4098
3393
|
...models.map((name) => ({ value: name, label: name })),
|
|
4099
3394
|
{ value: CUSTOM_MODEL_VALUE, label: "Autre \u2014 saisir un identifiant de mod\xE8le" }
|
|
4100
3395
|
],
|
|
@@ -4111,7 +3406,7 @@ function StepOptions({
|
|
|
4111
3406
|
Input,
|
|
4112
3407
|
{
|
|
4113
3408
|
id: ids.model,
|
|
4114
|
-
"aria-label": `Identifiant de mod\xE8le \u2014 ${
|
|
3409
|
+
"aria-label": `Identifiant de mod\xE8le \u2014 ${step2.label}`,
|
|
4115
3410
|
value: model,
|
|
4116
3411
|
disabled,
|
|
4117
3412
|
onChange: (e) => onPatch({ model: e.target.value })
|
|
@@ -4121,7 +3416,7 @@ function StepOptions({
|
|
|
4121
3416
|
Input,
|
|
4122
3417
|
{
|
|
4123
3418
|
id: ids.provider,
|
|
4124
|
-
"aria-label": `Fournisseur \u2014 ${
|
|
3419
|
+
"aria-label": `Fournisseur \u2014 ${step2.label}`,
|
|
4125
3420
|
value: stepString(settings, "provider") || DEFAULT_LLM_PROVIDER,
|
|
4126
3421
|
disabled,
|
|
4127
3422
|
onChange: (e) => onPatch({ provider: e.target.value })
|
|
@@ -4135,7 +3430,7 @@ function StepOptions({
|
|
|
4135
3430
|
/* @__PURE__ */ jsx(
|
|
4136
3431
|
Select,
|
|
4137
3432
|
{
|
|
4138
|
-
"aria-label": `Effort de raisonnement \u2014 ${
|
|
3433
|
+
"aria-label": `Effort de raisonnement \u2014 ${step2.label}`,
|
|
4139
3434
|
value: stepReasoning(settings),
|
|
4140
3435
|
onValueChange: (next) => onPatch({ reasoning: next }),
|
|
4141
3436
|
items: REASONING_EFFORTS.map((effort) => ({ value: effort.value, label: effort.label })),
|
|
@@ -4143,7 +3438,7 @@ function StepOptions({
|
|
|
4143
3438
|
}
|
|
4144
3439
|
)
|
|
4145
3440
|
] }),
|
|
4146
|
-
|
|
3441
|
+
step2.key === "draft" && /* @__PURE__ */ jsx(
|
|
4147
3442
|
NumberField,
|
|
4148
3443
|
{
|
|
4149
3444
|
id: ids.maxToolCalls,
|
|
@@ -4156,7 +3451,7 @@ function StepOptions({
|
|
|
4156
3451
|
hint: "Chaque consultation (commande, livraison\u2026) co\xFBte un appel suppl\xE9mentaire."
|
|
4157
3452
|
}
|
|
4158
3453
|
),
|
|
4159
|
-
|
|
3454
|
+
step2.key === "evaluate" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4160
3455
|
/* @__PURE__ */ jsx(
|
|
4161
3456
|
NumberField,
|
|
4162
3457
|
{
|
|
@@ -4187,7 +3482,7 @@ function StepOptions({
|
|
|
4187
3482
|
] });
|
|
4188
3483
|
}
|
|
4189
3484
|
function StepPromptField({
|
|
4190
|
-
step,
|
|
3485
|
+
step: step2,
|
|
4191
3486
|
settings,
|
|
4192
3487
|
disabled,
|
|
4193
3488
|
prompts,
|
|
@@ -4195,13 +3490,14 @@ function StepPromptField({
|
|
|
4195
3490
|
id,
|
|
4196
3491
|
onPatch
|
|
4197
3492
|
}) {
|
|
4198
|
-
if (stepUsesAgentPrompt(
|
|
4199
|
-
return /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children:
|
|
3493
|
+
if (stepUsesAgentPrompt(step2.key)) {
|
|
3494
|
+
return /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: step2.key === "revise" ? "Cette \xE9tape relance l'agent qui r\xE9dige avec l'objection du relecteur \u2014 elle n'a pas de prompt \xE0 choisir." : "Le prompt de cette \xE9tape est celui de l'agent qui r\xE9dige \u2014 il se choisit sur la page Agents." });
|
|
4200
3495
|
}
|
|
4201
3496
|
const name = stepPromptName(settings);
|
|
4202
3497
|
const label = stepPromptLabel(settings);
|
|
4203
3498
|
const known = prompts.find((entry) => entry.name === name);
|
|
4204
|
-
const
|
|
3499
|
+
const unlisted = name !== "" && !known;
|
|
3500
|
+
const orphaned = unlisted && !promptsLoading;
|
|
4205
3501
|
const labels = known?.labels.length ? known.labels : [DEFAULT_PROMPT_LABEL];
|
|
4206
3502
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4207
3503
|
/* @__PURE__ */ jsx("label", { htmlFor: id, className: "mb-1 block text-sm font-medium", children: "Prompt Langfuse" }),
|
|
@@ -4209,11 +3505,11 @@ function StepPromptField({
|
|
|
4209
3505
|
/* @__PURE__ */ jsx(
|
|
4210
3506
|
Select,
|
|
4211
3507
|
{
|
|
4212
|
-
"aria-label": `Prompt \u2014 ${
|
|
4213
|
-
value:
|
|
3508
|
+
"aria-label": `Prompt \u2014 ${step2.label}`,
|
|
3509
|
+
value: name,
|
|
4214
3510
|
onValueChange: (next) => onPatch(promptPatch(next, DEFAULT_PROMPT_LABEL)),
|
|
4215
3511
|
items: [
|
|
4216
|
-
...
|
|
3512
|
+
...unlisted ? [{ value: name, label: orphaned ? `${name} \u2014 introuvable dans Langfuse` : name }] : [],
|
|
4217
3513
|
...prompts.map((entry) => ({ value: entry.name, label: entry.name }))
|
|
4218
3514
|
],
|
|
4219
3515
|
disabled: disabled || promptsLoading
|
|
@@ -4222,8 +3518,8 @@ function StepPromptField({
|
|
|
4222
3518
|
/* @__PURE__ */ jsx(
|
|
4223
3519
|
Select,
|
|
4224
3520
|
{
|
|
4225
|
-
"aria-label": `Version du prompt \u2014 ${
|
|
4226
|
-
value: labels.includes(label) ? label :
|
|
3521
|
+
"aria-label": `Version du prompt \u2014 ${step2.label}`,
|
|
3522
|
+
value: labels.includes(label) ? label : "",
|
|
4227
3523
|
onValueChange: (next) => onPatch(promptPatch(name, next)),
|
|
4228
3524
|
items: labels.map((entry) => ({ value: entry, label: entry })),
|
|
4229
3525
|
disabled: disabled || promptsLoading || name === ""
|
|
@@ -4604,7 +3900,7 @@ function SettingsPage() {
|
|
|
4604
3900
|
Select,
|
|
4605
3901
|
{
|
|
4606
3902
|
"aria-label": "Mode WhatsApp",
|
|
4607
|
-
value: field(form.whatsappMode)
|
|
3903
|
+
value: field(form.whatsappMode),
|
|
4608
3904
|
onValueChange: (v) => set("whatsappMode", v),
|
|
4609
3905
|
items: WHATSAPP_MODE_OPTIONS,
|
|
4610
3906
|
disabled: !canWrite
|
|
@@ -5203,7 +4499,7 @@ function computeGraphReachability(rawSettings, hasCategoryWithAutoReply) {
|
|
|
5203
4499
|
globalNotes: promptWarningNodes.length > 0 ? [{ ...PROMPT_403_NOTE, nodes: promptWarningNodes }] : []
|
|
5204
4500
|
};
|
|
5205
4501
|
}
|
|
5206
|
-
function
|
|
4502
|
+
function windowCutoffIso(days, now = Date.now()) {
|
|
5207
4503
|
return new Date(now - days * 24 * 60 * 60 * 1e3).toISOString();
|
|
5208
4504
|
}
|
|
5209
4505
|
function totalOf(rows) {
|
|
@@ -5217,7 +4513,7 @@ function totalOf(rows) {
|
|
|
5217
4513
|
return total;
|
|
5218
4514
|
}
|
|
5219
4515
|
function useGraphTraffic(windowDays) {
|
|
5220
|
-
const cutoffIso = useMemo(() =>
|
|
4516
|
+
const cutoffIso = useMemo(() => windowCutoffIso(windowDays), [windowDays]);
|
|
5221
4517
|
const triaged = useAggregate("triage-decision", {
|
|
5222
4518
|
filter: { decidedAt: { gte: cutoffIso } },
|
|
5223
4519
|
metrics: [{ op: "count", as: "count" }]
|
|
@@ -6191,7 +5487,7 @@ function readySentence(result) {
|
|
|
6191
5487
|
}
|
|
6192
5488
|
function describeVerdict(result) {
|
|
6193
5489
|
if (result.error) {
|
|
6194
|
-
const failing = result.steps.find((
|
|
5490
|
+
const failing = result.steps.find((step2) => step2.error);
|
|
6195
5491
|
return {
|
|
6196
5492
|
label: "Erreur technique",
|
|
6197
5493
|
tone: "danger",
|
|
@@ -6236,7 +5532,7 @@ function describeVerdict(result) {
|
|
|
6236
5532
|
}
|
|
6237
5533
|
}
|
|
6238
5534
|
function totalDurationMs(result) {
|
|
6239
|
-
return result.steps.reduce((total,
|
|
5535
|
+
return result.steps.reduce((total, step2) => total + step2.durationMs, 0);
|
|
6240
5536
|
}
|
|
6241
5537
|
var VERDICT_BADGE_VARIANT = {
|
|
6242
5538
|
success: "success",
|
|
@@ -6246,7 +5542,7 @@ var VERDICT_BADGE_VARIANT = {
|
|
|
6246
5542
|
};
|
|
6247
5543
|
function DryRunResultView({ result, langfuseConfig, knownTags, tagSettings }) {
|
|
6248
5544
|
const verdict = describeVerdict(result);
|
|
6249
|
-
const triageStep = result.steps.find((
|
|
5545
|
+
const triageStep = result.steps.find((step2) => step2.node === "triage");
|
|
6250
5546
|
const triageTag = triageStep?.patch.classification?.category;
|
|
6251
5547
|
const isFallbackClassification = triageStep?.patch.classification?.isFallback === true;
|
|
6252
5548
|
const unknownTag = Boolean(triageTag) && !isFallbackClassification && knownTags !== void 0 && !knownTags.includes(triageTag);
|
|
@@ -6280,18 +5576,18 @@ function DryRunResultView({ result, langfuseConfig, knownTags, tagSettings }) {
|
|
|
6280
5576
|
] }),
|
|
6281
5577
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
6282
5578
|
/* @__PURE__ */ jsx("p", { className: "mb-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "N\u0153uds ex\xE9cut\xE9s" }),
|
|
6283
|
-
/* @__PURE__ */ jsx("ul", { className: "space-y-1", children: result.steps.map((
|
|
5579
|
+
/* @__PURE__ */ jsx("ul", { className: "space-y-1", children: result.steps.map((step2, i) => /* @__PURE__ */ jsxs("li", { className: "flex items-center justify-between gap-3", children: [
|
|
6284
5580
|
/* @__PURE__ */ jsxs("span", { children: [
|
|
6285
|
-
NODE_LABELS[
|
|
5581
|
+
NODE_LABELS[step2.node],
|
|
6286
5582
|
" (",
|
|
6287
|
-
|
|
5583
|
+
step2.node,
|
|
6288
5584
|
")",
|
|
6289
|
-
|
|
5585
|
+
step2.node === "triage" && unknownTag && /* @__PURE__ */ jsx("span", { className: "ml-2 text-xs text-status-warning", children: "\u2014 ce tag ne correspond \xE0 aucune cat\xE9gorie configur\xE9e" })
|
|
6290
5586
|
] }),
|
|
6291
5587
|
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
|
|
6292
|
-
|
|
5588
|
+
step2.durationMs,
|
|
6293
5589
|
" ms",
|
|
6294
|
-
|
|
5590
|
+
step2.error && /* @__PURE__ */ jsx(Badge, { variant: "danger", children: step2.error })
|
|
6295
5591
|
] })
|
|
6296
5592
|
] }, i)) })
|
|
6297
5593
|
] }),
|
|
@@ -7670,6 +6966,6 @@ function QualityPage() {
|
|
|
7670
6966
|
return /* @__PURE__ */ jsx(ExperimentsView, { canEdit, onReviewCreated: setReviewId });
|
|
7671
6967
|
}
|
|
7672
6968
|
|
|
7673
|
-
export { AgentsPage, CategoriesPage,
|
|
6969
|
+
export { AgentsPage, CategoriesPage, DashboardPage, GraphCanvasPage, QualityPage, SettingsPage, SharedPromptsPage, TestPage, TicketsPage };
|
|
7674
6970
|
//# sourceMappingURL=index.js.map
|
|
7675
6971
|
//# sourceMappingURL=index.js.map
|