@apotech-os/support-kit 2.6.0 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ui/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { GENERATED_RESPONSE_STATUSES, EVALUATION_VERDICTS, WHATSAPP_MODES, validateSettings, AGENT_GUARDRAILS, toCategory, toTriageDecision, toAgent, toGeneratedResponse, isGeneratedResponseStatus, toCategoryGroup, toResponseComparison, toDiffAnalysis, NODE_NAMES, settingsToProfile, hasNoDraftNode, guardrailBucket, computeWordDiff, isSendableVerdict } from '../chunk-KDOL3MLH.js';
1
+ import { GENERATED_RESPONSE_STATUSES, EVALUATION_VERDICTS, WHATSAPP_MODES, validateSettings, AGENT_GUARDRAILS, toCategory, toTriageDecision, toAgent, toGeneratedResponse, isGeneratedResponseStatus, toCategoryGroup, toResponseComparison, toDiffAnalysis, NODE_NAMES, settingsToProfile, hasNoDraftNode, guardrailBucket, computeWordDiff, DEFAULT_LLM_PROVIDER, isSendableVerdict, DEFAULT_MAX_TOOL_CALLS, DEFAULT_MIN_CONFIDENCE, DEFAULT_ESCALATION_ENABLED } from '../chunk-HE7Q4VCS.js';
2
2
  import { useState, useMemo, useRef, useEffect, useCallback, useId } from 'react';
3
- import { useAppContext, useAppSettings, Card, CardContent, Button, Link, KpiCard, BarChart, StackedBarChart, DataTable, Select, useAppApi, useToast, Badge, FunnelChart, Spinner, LineChart, Input, Switch, Checkbox, Textarea, SidePanel, CopyButton, Modal, cn, Tabs, TabsList, TabsTrigger, TabsContent, AppInvokeError } from '@apotech-os/ui-sdk';
3
+ import { useAppContext, useAppSettings, Card, CardContent, Button, Link, KpiCard, BarChart, StackedBarChart, DataTable, Select, useAppApi, useToast, Badge, FunnelChart, Spinner, LineChart, Input, Switch, Checkbox, Textarea, cn, SidePanel, CopyButton, Modal, Tooltip, AppInvokeError } from '@apotech-os/ui-sdk';
4
4
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
5
5
 
6
6
  function useRecordList(objectKey, query, mapper) {
@@ -81,6 +81,22 @@ function useRecordList(objectKey, query, mapper) {
81
81
  goToPreviousPage
82
82
  };
83
83
  }
84
+ function PageShell({ className, children }) {
85
+ return /* @__PURE__ */ jsx("div", { className: cn("space-y-6 px-8 py-6", className), children });
86
+ }
87
+ function PageHeader({
88
+ title,
89
+ description,
90
+ actions
91
+ }) {
92
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-start justify-between gap-4", children: [
93
+ /* @__PURE__ */ jsxs("div", { children: [
94
+ /* @__PURE__ */ jsx("h1", { className: "text-2xl font-semibold", children: title }),
95
+ description && /* @__PURE__ */ jsx("p", { className: "mt-1 max-w-3xl text-sm text-muted-foreground", children: description })
96
+ ] }),
97
+ actions && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap items-center gap-2", children: actions })
98
+ ] });
99
+ }
84
100
  function useAggregate(objectKey, spec) {
85
101
  const { appSlug } = useAppContext();
86
102
  const api = useAppApi();
@@ -258,23 +274,24 @@ function DashboardPage() {
258
274
  },
259
275
  { key: "decidedAt", header: "Date", cell: (row) => formatDate(row.decidedAt) }
260
276
  ];
261
- return /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
262
- /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-4", children: [
263
- /* @__PURE__ */ jsxs("div", { children: [
264
- /* @__PURE__ */ jsx("h1", { className: "text-lg font-semibold", children: "Tableau de bord" }),
265
- /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Les chiffres cl\xE9s et les graphiques couvrent la fen\xEAtre choisie ; la sant\xE9 annonce la sienne." })
266
- ] }),
267
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
268
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
269
- /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "Fen\xEAtre :" }),
270
- WINDOW_OPTIONS.map((days) => /* @__PURE__ */ jsxs(Button, { size: "sm", variant: windowDays === days ? "default" : "outline", onClick: () => setWindowDays(days), children: [
271
- days,
272
- " j"
273
- ] }, days))
274
- ] }),
275
- /* @__PURE__ */ jsx(Link, { href: `/espace/${appSlug}/pipeline`, children: "Voir le pipeline complet" })
276
- ] })
277
- ] }),
277
+ return /* @__PURE__ */ jsxs(PageShell, { children: [
278
+ /* @__PURE__ */ jsx(
279
+ PageHeader,
280
+ {
281
+ title: "Tableau de bord",
282
+ description: "Les chiffres cl\xE9s et les graphiques couvrent la fen\xEAtre choisie ; la sant\xE9 annonce la sienne.",
283
+ actions: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
284
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
285
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "Fen\xEAtre :" }),
286
+ WINDOW_OPTIONS.map((days) => /* @__PURE__ */ jsxs(Button, { size: "sm", variant: windowDays === days ? "default" : "outline", onClick: () => setWindowDays(days), children: [
287
+ days,
288
+ " j"
289
+ ] }, days))
290
+ ] }),
291
+ /* @__PURE__ */ jsx(Link, { href: `/espace/${appSlug}/pipeline`, children: "Voir le pipeline complet" })
292
+ ] }) })
293
+ }
294
+ ),
278
295
  alarming && healthBand,
279
296
  /* @__PURE__ */ jsxs("div", { "data-testid": "dashboard-kpis", className: "grid grid-cols-1 gap-4 sm:grid-cols-3", children: [
280
297
  /* @__PURE__ */ jsxs("div", { children: [
@@ -726,14 +743,15 @@ function TicketsPage() {
726
743
  ];
727
744
  const isLoading = decisionsLoading || jobsLoading;
728
745
  const combinedError = decisionsError ?? jobsError;
729
- return /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
730
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
731
- /* @__PURE__ */ jsxs("div", { children: [
732
- /* @__PURE__ */ jsx("h1", { className: "text-lg font-semibold", children: "Demandes" }),
733
- /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Les tickets trait\xE9s par le graphe, et le parcours de chacun." })
734
- ] }),
735
- /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => void refreshBoth(), children: "Actualiser" })
736
- ] }),
746
+ return /* @__PURE__ */ jsxs(PageShell, { children: [
747
+ /* @__PURE__ */ jsx(
748
+ PageHeader,
749
+ {
750
+ title: "Demandes",
751
+ description: "Les tickets trait\xE9s par le graphe, et le parcours de chacun.",
752
+ actions: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => void refreshBoth(), children: "Actualiser" }) })
753
+ }
754
+ ),
737
755
  joinWindowMayBeIncomplete && /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
738
756
  "La jointure ne lit que les ",
739
757
  JOBS_WINDOW_SIZE,
@@ -1225,20 +1243,21 @@ function PipelinePage() {
1225
1243
  ] })
1226
1244
  }
1227
1245
  ];
1228
- return /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
1229
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
1230
- /* @__PURE__ */ jsxs("div", { children: [
1231
- /* @__PURE__ */ jsx("h1", { className: "text-lg font-semibold", children: "Pipeline" }),
1232
- /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Cycle de vie des r\xE9ponses g\xE9n\xE9r\xE9es automatiquement." })
1233
- ] }),
1234
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
1235
- settings && /* @__PURE__ */ jsxs(Badge, { variant: settings.autoSendEnabled ? "success" : "neutral", children: [
1236
- "Envoi auto : ",
1237
- settings.autoSendEnabled ? "ACTIF" : "INACTIF"
1238
- ] }),
1239
- canWrite && /* @__PURE__ */ jsx(Button, { onClick: () => void runTriageNow(), disabled: isTriaging, children: isTriaging ? "Triage en cours\u2026" : "Lancer le triage maintenant" })
1240
- ] })
1241
- ] }),
1246
+ return /* @__PURE__ */ jsxs(PageShell, { children: [
1247
+ /* @__PURE__ */ jsx(
1248
+ PageHeader,
1249
+ {
1250
+ title: "Pipeline",
1251
+ description: "Cycle de vie des r\xE9ponses g\xE9n\xE9r\xE9es automatiquement.",
1252
+ actions: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
1253
+ settings && /* @__PURE__ */ jsxs(Badge, { variant: settings.autoSendEnabled ? "success" : "neutral", children: [
1254
+ "Envoi auto : ",
1255
+ settings.autoSendEnabled ? "ACTIF" : "INACTIF"
1256
+ ] }),
1257
+ canWrite && /* @__PURE__ */ jsx(Button, { onClick: () => void runTriageNow(), disabled: isTriaging, children: isTriaging ? "Triage en cours\u2026" : "Lancer le triage maintenant" })
1258
+ ] }) })
1259
+ }
1260
+ ),
1242
1261
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
1243
1262
  /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "Fen\xEAtre :" }),
1244
1263
  WINDOW_OPTIONS2.map((days) => /* @__PURE__ */ jsxs(Button, { size: "sm", variant: windowDays === days ? "default" : "outline", onClick: () => setWindowDays(days), children: [
@@ -1884,14 +1903,15 @@ function AgentsPage() {
1884
1903
  ] })
1885
1904
  }
1886
1905
  ];
1887
- return /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
1888
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
1889
- /* @__PURE__ */ jsxs("div", { children: [
1890
- /* @__PURE__ */ jsx("h1", { className: "text-lg font-semibold", children: "Agents" }),
1891
- /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Agents de r\xE9daction et leurs prompts." })
1892
- ] }),
1893
- canWrite && /* @__PURE__ */ jsx(Button, { onClick: () => setFormAgent("new"), children: "Nouvel agent" })
1894
- ] }),
1906
+ return /* @__PURE__ */ jsxs(PageShell, { children: [
1907
+ /* @__PURE__ */ jsx(
1908
+ PageHeader,
1909
+ {
1910
+ title: "Agents",
1911
+ description: "Agents de r\xE9daction et leurs prompts.",
1912
+ actions: canWrite && /* @__PURE__ */ jsx(Button, { onClick: () => setFormAgent("new"), children: "Nouvel agent" })
1913
+ }
1914
+ ),
1895
1915
  /* @__PURE__ */ jsx(
1896
1916
  DataTable,
1897
1917
  {
@@ -2245,14 +2265,15 @@ function CategoriesPage() {
2245
2265
  const isLoading = groupsLoading || categoriesLoading;
2246
2266
  const loadError = groupsError ?? categoriesError;
2247
2267
  const ungrouped = byGroup.get(UNGROUPED_KEY) ?? [];
2248
- return /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
2249
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
2250
- /* @__PURE__ */ jsxs("div", { children: [
2251
- /* @__PURE__ */ jsx("h1", { className: "text-lg font-semibold", children: "Cat\xE9gories" }),
2252
- /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "R\xE9f\xE9rentiel de cat\xE9gorisation des tickets." })
2253
- ] }),
2254
- canWrite && /* @__PURE__ */ jsx(Button, { onClick: () => setNewGroup(true), children: "Nouveau groupe" })
2255
- ] }),
2268
+ return /* @__PURE__ */ jsxs(PageShell, { children: [
2269
+ /* @__PURE__ */ jsx(
2270
+ PageHeader,
2271
+ {
2272
+ title: "Cat\xE9gories",
2273
+ description: "R\xE9f\xE9rentiel de cat\xE9gorisation des tickets.",
2274
+ actions: canWrite && /* @__PURE__ */ jsx(Button, { onClick: () => setNewGroup(true), children: "Nouveau groupe" })
2275
+ }
2276
+ ),
2256
2277
  loadError ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-3 py-12", children: [
2257
2278
  /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: "Erreur lors du chargement des cat\xE9gories." }),
2258
2279
  /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => void Promise.all([refreshGroups(), refreshCategories()]), children: "R\xE9essayer" })
@@ -2454,14 +2475,15 @@ function EscalationsPage() {
2454
2475
  },
2455
2476
  { key: "decidedAt", header: "D\xE9cid\xE9 le", cell: (row) => formatDate(row.decidedAt) }
2456
2477
  ];
2457
- return /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
2458
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
2459
- /* @__PURE__ */ jsxs("div", { children: [
2460
- /* @__PURE__ */ jsx("h1", { className: "text-lg font-semibold", children: "Escalades" }),
2461
- /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "D\xE9cisions d\u2019escalade humaine \xE9valu\xE9es lors des runs de triage." })
2462
- ] }),
2463
- /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => void refresh(), children: "Actualiser" })
2464
- ] }),
2478
+ return /* @__PURE__ */ jsxs(PageShell, { children: [
2479
+ /* @__PURE__ */ jsx(
2480
+ PageHeader,
2481
+ {
2482
+ title: "Escalades",
2483
+ description: "D\xE9cisions d\u2019escalade humaine \xE9valu\xE9es lors des runs de triage.",
2484
+ actions: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => void refresh(), children: "Actualiser" }) })
2485
+ }
2486
+ ),
2465
2487
  /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
2466
2488
  /* @__PURE__ */ jsx(
2467
2489
  Select,
@@ -2787,14 +2809,15 @@ function CorrectionsPage() {
2787
2809
  }
2788
2810
  ] : []
2789
2811
  ];
2790
- return /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
2791
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
2792
- /* @__PURE__ */ jsxs("div", { children: [
2793
- /* @__PURE__ */ jsx("h1", { className: "text-lg font-semibold", children: "Corrections" }),
2794
- /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Ce que l'IA a propos\xE9, compar\xE9 \xE0 ce que l'agent a r\xE9ellement envoy\xE9." })
2795
- ] }),
2796
- /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => void refresh(), children: "Actualiser" })
2797
- ] }),
2812
+ return /* @__PURE__ */ jsxs(PageShell, { children: [
2813
+ /* @__PURE__ */ jsx(
2814
+ PageHeader,
2815
+ {
2816
+ title: "Corrections",
2817
+ description: "Ce que l'IA a propos\xE9, compar\xE9 \xE0 ce que l'agent a r\xE9ellement envoy\xE9.",
2818
+ actions: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => void refresh(), children: "Actualiser" }) })
2819
+ }
2820
+ ),
2798
2821
  /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
2799
2822
  /* @__PURE__ */ jsx(
2800
2823
  Select,
@@ -2910,35 +2933,462 @@ function CorrectionsPage() {
2910
2933
  )
2911
2934
  ] });
2912
2935
  }
2913
- var WHATSAPP_MODE_LABELS = {
2914
- escalate_only: "Escalade uniquement",
2915
- draft_only: "Brouillon uniquement",
2916
- auto_reply: "R\xE9ponse automatique"
2917
- };
2918
- var WHATSAPP_MODE_OPTIONS = WHATSAPP_MODES.map((value) => ({ value, label: WHATSAPP_MODE_LABELS[value] }));
2919
- function field(value) {
2936
+ function NumberField({ id, label, value, onChange, disabled, min, max, integer, hint }) {
2937
+ return /* @__PURE__ */ jsxs("div", { children: [
2938
+ /* @__PURE__ */ jsx("label", { htmlFor: id, className: "mb-1 block text-sm font-medium", children: label }),
2939
+ /* @__PURE__ */ jsx(
2940
+ Input,
2941
+ {
2942
+ id,
2943
+ type: "number",
2944
+ min,
2945
+ max,
2946
+ value,
2947
+ disabled,
2948
+ step: integer ? 1 : void 0,
2949
+ onChange: (e) => {
2950
+ const parsed = Number(e.target.value);
2951
+ if (e.target.value.trim() === "" || !Number.isFinite(parsed)) return;
2952
+ const rounded = integer ? Math.round(parsed) : parsed;
2953
+ const bounded = Math.min(max ?? Infinity, Math.max(min ?? -Infinity, rounded));
2954
+ onChange(bounded);
2955
+ }
2956
+ }
2957
+ ),
2958
+ hint && /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: hint })
2959
+ ] });
2960
+ }
2961
+
2962
+ // src/ui/settings/pipeline-nodes.ts
2963
+ var PIPELINE_STEP_KEYS = ["triage", "escalate", "draft", "evaluate", "revise"];
2964
+ var PIPELINE_STEPS = [
2965
+ {
2966
+ key: "triage",
2967
+ label: "Triage",
2968
+ description: "comprend et classe chaque demande entrante",
2969
+ requires: null,
2970
+ blockedReason: null
2971
+ },
2972
+ {
2973
+ key: "escalate",
2974
+ label: "Escalade",
2975
+ description: "passe la main \xE0 un humain",
2976
+ requires: null,
2977
+ blockedReason: null
2978
+ },
2979
+ {
2980
+ key: "draft",
2981
+ label: "R\xE9daction",
2982
+ description: "pr\xE9pare un projet de r\xE9ponse",
2983
+ requires: null,
2984
+ blockedReason: null
2985
+ },
2986
+ {
2987
+ key: "evaluate",
2988
+ label: "\xC9valuation",
2989
+ description: "relit la r\xE9ponse avant envoi",
2990
+ requires: "draft",
2991
+ blockedReason: "Il n'y a rien \xE0 \xE9valuer sans r\xE9daction."
2992
+ },
2993
+ {
2994
+ key: "revise",
2995
+ label: "R\xE9vision",
2996
+ description: "r\xE9\xE9crit la r\xE9ponse si l'\xE9valuation la juge insuffisante",
2997
+ requires: "evaluate",
2998
+ blockedReason: "Sans \xE9valuation, rien ne d\xE9clenche une r\xE9vision."
2999
+ }
3000
+ ];
3001
+ var TRIAGE_LOCK_REASON = "Sans triage l'app ne traite rien.";
3002
+ var STEP_BY_KEY = new Map(PIPELINE_STEPS.map((step) => [step.key, step]));
3003
+ function pipelineStep(key) {
3004
+ const step = STEP_BY_KEY.get(key);
3005
+ if (!step) throw new Error(`unknown pipeline step: ${key}`);
3006
+ return step;
3007
+ }
3008
+ function readNodes(value) {
3009
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return {};
3010
+ return value;
3011
+ }
3012
+ function readStep(value, key) {
3013
+ const step = readNodes(value)[key];
3014
+ if (typeof step !== "object" || step === null || Array.isArray(step)) return null;
3015
+ return step;
3016
+ }
3017
+ function isStepEnabled(value, key) {
3018
+ return readStep(value, key) !== null;
3019
+ }
3020
+ function stepBlockedReason(value, key) {
3021
+ const { requires, blockedReason } = pipelineStep(key);
3022
+ if (!requires) return null;
3023
+ return isStepActive(value, requires) ? null : blockedReason;
3024
+ }
3025
+ function isStepActive(value, key) {
3026
+ return isStepEnabled(value, key) && stepBlockedReason(value, key) === null;
3027
+ }
3028
+ function withStep(value, key, step) {
3029
+ return { ...readNodes(value), [key]: step };
3030
+ }
3031
+ function withStepFields(value, key, patch) {
3032
+ const step = readStep(value, key);
3033
+ if (!step) return readNodes(value);
3034
+ const next = { ...step };
3035
+ for (const [field2, fieldValue] of Object.entries(patch)) {
3036
+ if (fieldValue === void 0) delete next[field2];
3037
+ else next[field2] = fieldValue;
3038
+ }
3039
+ return withStep(value, key, next);
3040
+ }
3041
+ function stepString(step, field2) {
3042
+ const value = step?.[field2];
2920
3043
  return typeof value === "string" ? value : "";
2921
3044
  }
2922
- function bool(value) {
2923
- return value === true;
3045
+ function stepNumber(step, field2, fallback) {
3046
+ const value = step?.[field2];
3047
+ return typeof value === "number" && Number.isFinite(value) ? value : fallback;
2924
3048
  }
2925
- function num(value) {
2926
- return typeof value === "number" ? value : 0;
3049
+ function stepBoolean(step, field2, fallback) {
3050
+ const value = step?.[field2];
3051
+ return typeof value === "boolean" ? value : fallback;
2927
3052
  }
2928
- function list(value) {
2929
- return Array.isArray(value) ? value.join(", ") : "";
3053
+ function stepReasoning(step) {
3054
+ const value = step?.reasoning;
3055
+ return REASONING_EFFORTS.some((effort) => effort.value === value) ? value : "off";
2930
3056
  }
2931
- function parseList(value) {
2932
- return value.split(",").map((v) => v.trim()).filter(Boolean);
3057
+ var REASONING_EFFORTS = [
3058
+ { value: "off", label: "Aucun" },
3059
+ { value: "low", label: "L\xE9ger" },
3060
+ { value: "medium", label: "Moyen" },
3061
+ { value: "high", label: "Pouss\xE9" }
3062
+ ];
3063
+ var KNOWN_MODELS = [
3064
+ {
3065
+ provider: "openai",
3066
+ model: "gpt-4o-mini",
3067
+ label: "GPT-4o mini",
3068
+ hint: "Le moins cher, tr\xE8s rapide \u2014 suffisant pour classer"
3069
+ },
3070
+ {
3071
+ provider: "openai",
3072
+ model: "gpt-5-mini",
3073
+ label: "GPT-5 mini",
3074
+ hint: "Rapide, bon march\xE9, meilleur raisonnement"
3075
+ },
3076
+ {
3077
+ provider: "openai",
3078
+ model: "gpt-4.1",
3079
+ label: "GPT-4.1",
3080
+ hint: "Co\xFBt moyen \u2014 r\xE9daction soign\xE9e"
3081
+ },
3082
+ {
3083
+ provider: "openai",
3084
+ model: "gpt-5",
3085
+ label: "GPT-5",
3086
+ hint: "Le plus capable \u2014 le plus lent et le plus cher"
3087
+ },
3088
+ {
3089
+ provider: "anthropic",
3090
+ model: "claude-3-5-haiku-latest",
3091
+ label: "Claude 3.5 Haiku",
3092
+ hint: "Rapide et bon march\xE9"
3093
+ },
3094
+ {
3095
+ provider: "anthropic",
3096
+ model: "claude-3-5-sonnet-latest",
3097
+ label: "Claude 3.5 Sonnet",
3098
+ hint: "Co\xFBt moyen \u2014 r\xE9daction soign\xE9e"
3099
+ }
3100
+ ];
3101
+ var CUSTOM_MODEL_VALUE = "__custom__";
3102
+ function findModelOption(model) {
3103
+ return KNOWN_MODELS.find((option) => option.model === model);
3104
+ }
3105
+ function defaultStep() {
3106
+ const [first] = KNOWN_MODELS;
3107
+ return { model: first.model, provider: first.provider, reasoning: "off" };
3108
+ }
3109
+ var PIPELINE_PRESETS = [
3110
+ {
3111
+ id: "triage-only",
3112
+ label: "D\xE9marrage prudent \u2014 triage seul",
3113
+ description: "Les demandes sont comprises et class\xE9es. Aucune r\xE9ponse n\u2019est pr\xE9par\xE9e.",
3114
+ enabled: ["triage"]
3115
+ },
3116
+ {
3117
+ id: "assisted",
3118
+ label: "R\xE9ponse assist\xE9e",
3119
+ 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.",
3120
+ enabled: ["triage", "escalate", "draft"]
3121
+ }
3122
+ ];
3123
+ function applyPreset(value, preset, restore) {
3124
+ let next = readNodes(value);
3125
+ for (const key of PIPELINE_STEP_KEYS) {
3126
+ const on = preset.enabled.includes(key);
3127
+ next = withStep(next, key, on ? readStep(next, key) ?? restore(key) : null);
3128
+ }
3129
+ return next;
3130
+ }
3131
+ var PERCENT = 100;
3132
+ function PipelineNodesForm({ value, onChange, canWrite, issueMessage }) {
3133
+ const [remembered, setRemembered] = useState({});
3134
+ useEffect(() => {
3135
+ setRemembered((prev) => {
3136
+ let changed = false;
3137
+ const next = { ...prev };
3138
+ for (const key of PIPELINE_STEP_KEYS) {
3139
+ const step = readStep(value, key);
3140
+ if (step && JSON.stringify(step) !== JSON.stringify(prev[key])) {
3141
+ next[key] = step;
3142
+ changed = true;
3143
+ }
3144
+ }
3145
+ return changed ? next : prev;
3146
+ });
3147
+ }, [value]);
3148
+ function restore(key) {
3149
+ return remembered[key] ?? defaultStep();
3150
+ }
3151
+ function toggleStep(key, on) {
3152
+ onChange(withStep(value, key, on ? restore(key) : null));
3153
+ }
3154
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
3155
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Les \xE9tapes ci-dessous s'ex\xE9cutent dans cet ordre pour chaque demande re\xE7ue." }),
3156
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
3157
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "Pr\xE9r\xE9glages :" }),
3158
+ PIPELINE_PRESETS.map((preset) => /* @__PURE__ */ jsx(Tooltip, { label: preset.description, children: /* @__PURE__ */ jsx(
3159
+ Button,
3160
+ {
3161
+ variant: "outline",
3162
+ size: "sm",
3163
+ disabled: !canWrite,
3164
+ onClick: () => onChange(applyPreset(value, preset, restore)),
3165
+ children: preset.label
3166
+ }
3167
+ ) }, preset.id))
3168
+ ] }),
3169
+ /* @__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." }),
3170
+ /* @__PURE__ */ jsx("div", { className: "divide-y rounded-md border", children: PIPELINE_STEPS.map((step) => /* @__PURE__ */ jsx(
3171
+ StepRow,
3172
+ {
3173
+ step,
3174
+ value,
3175
+ canWrite,
3176
+ issueMessage: step.key === "triage" ? issueMessage : null,
3177
+ onToggle: (on) => toggleStep(step.key, on),
3178
+ onPatch: (patch) => onChange(withStepFields(value, step.key, patch))
3179
+ },
3180
+ step.key
3181
+ )) }),
3182
+ /* @__PURE__ */ jsxs("details", { children: [
3183
+ /* @__PURE__ */ jsx("summary", { className: "cursor-pointer text-sm font-medium", children: "Mode avanc\xE9 (JSON)" }),
3184
+ /* @__PURE__ */ jsx("div", { className: "mt-3", children: /* @__PURE__ */ jsx(NodesJsonField, { value, onChange, disabled: !canWrite }) })
3185
+ ] })
3186
+ ] });
3187
+ }
3188
+ function StepRow({
3189
+ step,
3190
+ value,
3191
+ canWrite,
3192
+ issueMessage,
3193
+ onToggle,
3194
+ onPatch
3195
+ }) {
3196
+ const enabled = isStepEnabled(value, step.key);
3197
+ const blockedReason = stepBlockedReason(value, step.key);
3198
+ const triageLocked = step.key === "triage" && enabled;
3199
+ const editable = canWrite && !blockedReason && !triageLocked;
3200
+ const toggle = /* @__PURE__ */ jsx(
3201
+ Switch,
3202
+ {
3203
+ "aria-label": `${step.label} \u2014 activer l'\xE9tape`,
3204
+ checked: enabled,
3205
+ onCheckedChange: onToggle,
3206
+ disabled: !editable
3207
+ }
3208
+ );
3209
+ return /* @__PURE__ */ jsxs("div", { className: blockedReason ? "space-y-2 p-4 opacity-60" : "space-y-2 p-4", children: [
3210
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-3", children: [
3211
+ /* @__PURE__ */ jsxs("div", { children: [
3212
+ /* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: step.label }),
3213
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: step.description })
3214
+ ] }),
3215
+ /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-2 text-sm", children: [
3216
+ triageLocked ? /* @__PURE__ */ jsx(Tooltip, { label: TRIAGE_LOCK_REASON, children: toggle }) : toggle,
3217
+ /* @__PURE__ */ jsx("span", { children: enabled ? "Activ\xE9" : "D\xE9sactiv\xE9" })
3218
+ ] })
3219
+ ] }),
3220
+ blockedReason && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: blockedReason }),
3221
+ issueMessage && !enabled && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: issueMessage }),
3222
+ enabled && /* @__PURE__ */ jsxs("details", { children: [
3223
+ /* @__PURE__ */ jsx("summary", { className: "cursor-pointer text-sm text-muted-foreground", children: "Options" }),
3224
+ /* @__PURE__ */ jsx("div", { className: "mt-3 grid gap-4 rounded-md bg-muted/40 p-3 sm:grid-cols-2", children: /* @__PURE__ */ jsx(
3225
+ StepOptions,
3226
+ {
3227
+ step,
3228
+ settings: readStep(value, step.key),
3229
+ disabled: !canWrite || blockedReason !== null,
3230
+ onPatch
3231
+ }
3232
+ ) })
3233
+ ] })
3234
+ ] });
3235
+ }
3236
+ function StepOptions({
3237
+ step,
3238
+ settings,
3239
+ disabled,
3240
+ onPatch
3241
+ }) {
3242
+ const model = stepString(settings, "model");
3243
+ const known = findModelOption(model);
3244
+ const [freeText, setFreeText] = useState(false);
3245
+ const showFreeText = freeText || model !== "" && !known;
3246
+ const ids = useIds(step.key);
3247
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
3248
+ /* @__PURE__ */ jsxs("div", { children: [
3249
+ /* @__PURE__ */ jsx("label", { htmlFor: ids.model, className: "mb-1 block text-sm font-medium", children: "Mod\xE8le" }),
3250
+ /* @__PURE__ */ jsx(
3251
+ Select,
3252
+ {
3253
+ "aria-label": `Mod\xE8le \u2014 ${step.label}`,
3254
+ value: showFreeText ? CUSTOM_MODEL_VALUE : known?.model ?? void 0,
3255
+ onValueChange: (next) => {
3256
+ if (next === CUSTOM_MODEL_VALUE) {
3257
+ setFreeText(true);
3258
+ return;
3259
+ }
3260
+ setFreeText(false);
3261
+ const option = findModelOption(next);
3262
+ if (!option) return;
3263
+ onPatch({ model: option.model, provider: option.provider });
3264
+ },
3265
+ items: [
3266
+ ...KNOWN_MODELS.map((option) => ({
3267
+ value: option.model,
3268
+ label: `${option.label} \u2014 ${option.hint}`
3269
+ })),
3270
+ { value: CUSTOM_MODEL_VALUE, label: "Autre \u2014 saisir un identifiant de mod\xE8le" }
3271
+ ],
3272
+ disabled
3273
+ }
3274
+ ),
3275
+ showFreeText && // The provider travels WITH the model: a free-text id typed after a
3276
+ // catalogue pick would otherwise keep the previous entry's provider
3277
+ // (`gpt-5.1` dispatched to Anthropic), and a provider outside the
3278
+ // catalogue would have no control at all — which is the whole point
3279
+ // of the escape hatch.
3280
+ /* @__PURE__ */ jsxs("div", { className: "mt-2 space-y-2", children: [
3281
+ /* @__PURE__ */ jsx(
3282
+ Input,
3283
+ {
3284
+ id: ids.model,
3285
+ "aria-label": `Identifiant de mod\xE8le \u2014 ${step.label}`,
3286
+ value: model,
3287
+ disabled,
3288
+ onChange: (e) => onPatch({ model: e.target.value })
3289
+ }
3290
+ ),
3291
+ /* @__PURE__ */ jsx(
3292
+ Input,
3293
+ {
3294
+ id: ids.provider,
3295
+ "aria-label": `Fournisseur \u2014 ${step.label}`,
3296
+ value: stepString(settings, "provider") || DEFAULT_LLM_PROVIDER,
3297
+ disabled,
3298
+ onChange: (e) => onPatch({ provider: e.target.value })
3299
+ }
3300
+ ),
3301
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Identifiant du mod\xE8le et fournisseur (\xAB openai \xBB, \xAB anthropic \xBB\u2026), tels que l'API les attend." })
3302
+ ] })
3303
+ ] }),
3304
+ /* @__PURE__ */ jsxs("div", { children: [
3305
+ /* @__PURE__ */ jsx("label", { htmlFor: ids.reasoning, className: "mb-1 block text-sm font-medium", children: "Effort de raisonnement" }),
3306
+ /* @__PURE__ */ jsx(
3307
+ Select,
3308
+ {
3309
+ "aria-label": `Effort de raisonnement \u2014 ${step.label}`,
3310
+ value: stepReasoning(settings),
3311
+ onValueChange: (next) => onPatch({ reasoning: next }),
3312
+ items: REASONING_EFFORTS.map((effort) => ({ value: effort.value, label: effort.label })),
3313
+ disabled
3314
+ }
3315
+ )
3316
+ ] }),
3317
+ step.key === "draft" && /* @__PURE__ */ jsx(
3318
+ NumberField,
3319
+ {
3320
+ id: ids.maxToolCalls,
3321
+ label: "Nombre d'outils consultables par r\xE9ponse",
3322
+ value: stepNumber(settings, "maxToolCalls", DEFAULT_MAX_TOOL_CALLS),
3323
+ onChange: (next) => onPatch({ maxToolCalls: next }),
3324
+ disabled,
3325
+ min: 0,
3326
+ integer: true,
3327
+ hint: "Chaque consultation (commande, livraison\u2026) co\xFBte un appel suppl\xE9mentaire."
3328
+ }
3329
+ ),
3330
+ step.key === "evaluate" && /* @__PURE__ */ jsxs(Fragment, { children: [
3331
+ /* @__PURE__ */ jsx(
3332
+ NumberField,
3333
+ {
3334
+ id: ids.minConfidence,
3335
+ label: "Seuil de confiance (%)",
3336
+ value: Math.round(stepNumber(settings, "minConfidence", DEFAULT_MIN_CONFIDENCE) * PERCENT),
3337
+ onChange: (next) => onPatch({ minConfidence: next / PERCENT }),
3338
+ disabled,
3339
+ min: 0,
3340
+ max: PERCENT,
3341
+ integer: true,
3342
+ hint: "En dessous de ce seuil, la r\xE9ponse n'est jamais envoy\xE9e automatiquement."
3343
+ }
3344
+ ),
3345
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-sm sm:col-span-2", children: [
3346
+ /* @__PURE__ */ jsx(
3347
+ Switch,
3348
+ {
3349
+ "aria-label": "Autoriser l'escalade depuis l'\xE9valuation",
3350
+ checked: stepBoolean(settings, "escalationEnabled", DEFAULT_ESCALATION_ENABLED),
3351
+ onCheckedChange: (next) => onPatch({ escalationEnabled: next }),
3352
+ disabled
3353
+ }
3354
+ ),
3355
+ "Autoriser l'escalade \u2014 une \xE9valuation insuffisante est transmise \xE0 un humain"
3356
+ ] })
3357
+ ] })
3358
+ ] });
3359
+ }
3360
+ function useIds(stepKey) {
3361
+ const base2 = useId();
3362
+ return {
3363
+ model: `${base2}-${stepKey}-model`,
3364
+ provider: `${base2}-${stepKey}-provider`,
3365
+ reasoning: `${base2}-${stepKey}-reasoning`,
3366
+ maxToolCalls: `${base2}-${stepKey}-max-tool-calls`,
3367
+ minConfidence: `${base2}-${stepKey}-min-confidence`
3368
+ };
2933
3369
  }
2934
- function NodesField({ value, onChange }) {
3370
+ function NodesJsonField({
3371
+ value,
3372
+ onChange,
3373
+ disabled
3374
+ }) {
2935
3375
  const id = useId();
2936
- const [text, setText] = useState(() => JSON.stringify(value ?? null, null, 2));
3376
+ const serialized = stringify(value);
3377
+ const [text, setText] = useState(serialized);
2937
3378
  const [parseError, setParseError] = useState(null);
3379
+ const emittedRef = useRef(serialized);
3380
+ useEffect(() => {
3381
+ if (serialized === emittedRef.current) return;
3382
+ emittedRef.current = serialized;
3383
+ setText(serialized);
3384
+ setParseError(null);
3385
+ }, [serialized]);
2938
3386
  function handleChange(next) {
2939
3387
  setText(next);
2940
3388
  try {
2941
- onChange(JSON.parse(next));
3389
+ const parsed = JSON.parse(next);
3390
+ emittedRef.current = stringify(parsed);
3391
+ onChange(parsed);
2942
3392
  setParseError(null);
2943
3393
  } catch {
2944
3394
  setParseError("JSON invalide \u2014 la derni\xE8re valeur valide est conserv\xE9e tant que ce texte ne parse pas.");
@@ -2953,6 +3403,7 @@ function NodesField({ value, onChange }) {
2953
3403
  className: "font-mono text-xs",
2954
3404
  rows: 10,
2955
3405
  value: text,
3406
+ disabled,
2956
3407
  onChange: (e) => handleChange(e.target.value)
2957
3408
  }
2958
3409
  ),
@@ -2976,27 +3427,51 @@ function NodesField({ value, onChange }) {
2976
3427
  ] })
2977
3428
  ] });
2978
3429
  }
2979
- function NumberField({
2980
- id,
2981
- label,
2982
- value,
2983
- onChange
2984
- }) {
2985
- return /* @__PURE__ */ jsxs("div", { children: [
2986
- /* @__PURE__ */ jsx("label", { htmlFor: id, className: "mb-1 block text-sm font-medium", children: label }),
2987
- /* @__PURE__ */ jsx(
2988
- Input,
2989
- {
2990
- id,
2991
- type: "number",
2992
- value,
2993
- onChange: (e) => {
2994
- const parsed = Number(e.target.value);
2995
- if (e.target.value.trim() !== "" && Number.isFinite(parsed)) onChange(parsed);
2996
- }
2997
- }
2998
- )
2999
- ] });
3430
+ function stringify(value) {
3431
+ return JSON.stringify(value ?? null, null, 2);
3432
+ }
3433
+ var WHATSAPP_MODE_LABELS = {
3434
+ escalate_only: "Escalade uniquement",
3435
+ draft_only: "Brouillon uniquement",
3436
+ auto_reply: "R\xE9ponse automatique"
3437
+ };
3438
+ var WHATSAPP_MODE_OPTIONS = WHATSAPP_MODES.map((value) => ({ value, label: WHATSAPP_MODE_LABELS[value] }));
3439
+ function field(value) {
3440
+ return typeof value === "string" ? value : "";
3441
+ }
3442
+ function bool(value) {
3443
+ return value === true;
3444
+ }
3445
+ function num(value) {
3446
+ return typeof value === "number" ? value : 0;
3447
+ }
3448
+ function list(value) {
3449
+ return Array.isArray(value) ? value.join(", ") : "";
3450
+ }
3451
+ function parseList(value) {
3452
+ return value.split(",").map((v) => v.trim()).filter(Boolean);
3453
+ }
3454
+ function describeConnection(connections) {
3455
+ if (connections === void 0) return { text: "Chargement\u2026", tone: "muted" };
3456
+ if (connections === null) {
3457
+ return { text: "Ind\xE9termin\xE9e \u2014 les connexions de l\u2019instance n\u2019ont pas pu \xEAtre lues.", tone: "muted" };
3458
+ }
3459
+ if (connections.length === 0) {
3460
+ return {
3461
+ text: "Aucune connexion Gorgias sur l\u2019instance \u2014 le pipeline ne peut appeler Gorgias tant qu\u2019une connexion n\u2019est pas cr\xE9\xE9e.",
3462
+ tone: "error"
3463
+ };
3464
+ }
3465
+ const [only] = connections;
3466
+ if (connections.length === 1 && only) return { text: only.label, tone: "normal" };
3467
+ const fallback = connections.find((connection) => connection.isDefault);
3468
+ if (!fallback) {
3469
+ return {
3470
+ text: `${connections.length} connexions Gorgias, aucune par d\xE9faut \u2014 chaque appel Gorgias \xE9chouera tant que l\u2019une d\u2019elles n\u2019est pas marqu\xE9e par d\xE9faut.`,
3471
+ tone: "error"
3472
+ };
3473
+ }
3474
+ return { text: `${fallback.label} (par d\xE9faut, parmi ${connections.length} connexions)`, tone: "normal" };
3000
3475
  }
3001
3476
  function SettingsPage() {
3002
3477
  const { appSlug, role } = useAppContext();
@@ -3008,6 +3483,7 @@ function SettingsPage() {
3008
3483
  const [views, setViews] = useState([]);
3009
3484
  const [uncheckedAppSlugs, setUncheckedAppSlugs] = useState([]);
3010
3485
  const [installedAppsUnavailable, setInstalledAppsUnavailable] = useState(false);
3486
+ const [connections, setConnections] = useState(void 0);
3011
3487
  const formInitializedRef = useRef(false);
3012
3488
  useEffect(() => {
3013
3489
  if (settings && !formInitializedRef.current) {
@@ -3042,8 +3518,10 @@ function SettingsPage() {
3042
3518
  if (!cancelled) {
3043
3519
  setViews(result.views);
3044
3520
  setUncheckedAppSlugs(result.uncheckedAppSlugs);
3521
+ setConnections(result.connections);
3045
3522
  }
3046
3523
  } catch {
3524
+ if (!cancelled) setConnections(null);
3047
3525
  }
3048
3526
  })();
3049
3527
  return () => {
@@ -3054,16 +3532,19 @@ function SettingsPage() {
3054
3532
  setForm((prev) => ({ ...prev, [key]: value }));
3055
3533
  }
3056
3534
  if (isLoading) {
3057
- return /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center py-12", children: [
3535
+ return /* @__PURE__ */ jsx(PageShell, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center py-12", children: [
3058
3536
  /* @__PURE__ */ jsx(Spinner, {}),
3059
3537
  " ",
3060
3538
  /* @__PURE__ */ jsx("span", { className: "ml-2 text-sm text-muted-foreground", children: "Chargement\u2026" })
3061
- ] });
3539
+ ] }) });
3062
3540
  }
3541
+ const connection = describeConnection(connections);
3063
3542
  const sourceViewId = field(form.sourceViewId);
3064
3543
  const claimedView = views.find((v) => v.id === sourceViewId);
3065
3544
  const claimUnverifiable = installedAppsUnavailable || uncheckedAppSlugs.length > 0;
3066
3545
  const issues = validateSettings(form);
3546
+ const nodesIssue = issues.find((issue) => issue.key === "nodes");
3547
+ const summaryIssues = issues.filter((issue) => issue !== nodesIssue);
3067
3548
  const guardrailsActive = Array.isArray(form.guardrailsActive) ? form.guardrailsActive : [];
3068
3549
  function toggleGuardrail(id, checked) {
3069
3550
  set(
@@ -3071,24 +3552,20 @@ function SettingsPage() {
3071
3552
  checked ? [.../* @__PURE__ */ new Set([...guardrailsActive, id])] : guardrailsActive.filter((g) => g !== id)
3072
3553
  );
3073
3554
  }
3074
- return /* @__PURE__ */ jsxs("div", { className: "max-w-3xl space-y-6", children: [
3075
- /* @__PURE__ */ jsxs("div", { children: [
3076
- /* @__PURE__ */ jsx("h1", { className: "text-lg font-semibold", children: "Param\xE8tres" }),
3077
- /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Configuration du pipeline de support." })
3078
- ] }),
3555
+ return /* @__PURE__ */ jsxs(PageShell, { className: "max-w-3xl", children: [
3556
+ /* @__PURE__ */ jsx(PageHeader, { title: "Param\xE8tres", description: "Configuration du pipeline de support." }),
3079
3557
  /* @__PURE__ */ jsx(Card, { id: "source", children: /* @__PURE__ */ jsxs(CardContent, { className: "space-y-3 p-4", children: [
3080
3558
  /* @__PURE__ */ jsx("h2", { className: "font-medium", children: "Source" }),
3081
3559
  /* @__PURE__ */ jsxs("div", { children: [
3082
- /* @__PURE__ */ jsx("label", { htmlFor: "gorgiasConnectionId", className: "mb-1 block text-sm font-medium", children: "Connexion Gorgias" }),
3560
+ /* @__PURE__ */ jsx("span", { className: "mb-1 block text-sm font-medium", children: "Connexion Gorgias" }),
3083
3561
  /* @__PURE__ */ jsx(
3084
- Input,
3562
+ "p",
3085
3563
  {
3086
- id: "gorgiasConnectionId",
3087
- value: field(form.gorgiasConnectionId),
3088
- onChange: (e) => set("gorgiasConnectionId", e.target.value),
3089
- disabled: !canWrite
3564
+ className: connection.tone === "error" ? "text-sm text-destructive" : connection.tone === "muted" ? "text-sm text-muted-foreground" : "text-sm",
3565
+ children: connection.text
3090
3566
  }
3091
- )
3567
+ ),
3568
+ /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: "Cette application utilise la connexion Gorgias de l\u2019instance ; elle se r\xE8gle dans les int\xE9grations de la plateforme, pas ici." })
3092
3569
  ] }),
3093
3570
  /* @__PURE__ */ jsxs("div", { children: [
3094
3571
  /* @__PURE__ */ jsx("label", { htmlFor: "sourceViewId", className: "mb-1 block text-sm font-medium", children: "Vue Gorgias source" }),
@@ -3151,7 +3628,10 @@ function SettingsPage() {
3151
3628
  id: "batchLimit",
3152
3629
  label: "Taille de lot",
3153
3630
  value: num(form.batchLimit),
3154
- onChange: (v) => set("batchLimit", v)
3631
+ onChange: (v) => set("batchLimit", v),
3632
+ disabled: !canWrite,
3633
+ min: 1,
3634
+ integer: true
3155
3635
  }
3156
3636
  ),
3157
3637
  /* @__PURE__ */ jsx(
@@ -3160,7 +3640,10 @@ function SettingsPage() {
3160
3640
  id: "triageIntervalMinutes",
3161
3641
  label: "Intervalle de triage (minutes)",
3162
3642
  value: num(form.triageIntervalMinutes),
3163
- onChange: (v) => set("triageIntervalMinutes", v)
3643
+ onChange: (v) => set("triageIntervalMinutes", v),
3644
+ disabled: !canWrite,
3645
+ min: 1,
3646
+ integer: true
3164
3647
  }
3165
3648
  ),
3166
3649
  /* @__PURE__ */ jsx(
@@ -3169,7 +3652,10 @@ function SettingsPage() {
3169
3652
  id: "responseTtlMinutes",
3170
3653
  label: "Dur\xE9e de vie des r\xE9ponses (minutes)",
3171
3654
  value: num(form.responseTtlMinutes),
3172
- onChange: (v) => set("responseTtlMinutes", v)
3655
+ onChange: (v) => set("responseTtlMinutes", v),
3656
+ disabled: !canWrite,
3657
+ min: 1,
3658
+ integer: true
3173
3659
  }
3174
3660
  )
3175
3661
  ] }) }),
@@ -3358,8 +3844,16 @@ function SettingsPage() {
3358
3844
  ] })
3359
3845
  ] }) }),
3360
3846
  /* @__PURE__ */ jsx(Card, { id: "pipeline-avance", children: /* @__PURE__ */ jsxs(CardContent, { className: "space-y-3 p-4", children: [
3361
- /* @__PURE__ */ jsx("h2", { className: "font-medium", children: "Pipeline (avanc\xE9)" }),
3362
- /* @__PURE__ */ jsx(NodesField, { value: form.nodes, onChange: (v) => set("nodes", v) }),
3847
+ /* @__PURE__ */ jsx("h2", { className: "font-medium", children: "Traitement automatique" }),
3848
+ /* @__PURE__ */ jsx(
3849
+ PipelineNodesForm,
3850
+ {
3851
+ value: form.nodes,
3852
+ onChange: (v) => set("nodes", v),
3853
+ canWrite,
3854
+ issueMessage: nodesIssue ? settingsIssueLabel(nodesIssue.key, nodesIssue.message) : null
3855
+ }
3856
+ ),
3363
3857
  /* @__PURE__ */ jsx(Link, { href: `/espace/${appSlug}/graph-canvas`, children: "Visualiser dans Graphe" })
3364
3858
  ] }) }),
3365
3859
  /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsxs(CardContent, { className: "space-y-3 p-4", children: [
@@ -3367,7 +3861,7 @@ function SettingsPage() {
3367
3861
  /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Les agents support sont des utilisateurs plateforme \u2014 donnez-leur acc\xE8s \xE0 cette application depuis la gestion des membres." }),
3368
3862
  /* @__PURE__ */ jsx(Link, { href: "/parametres/membres", children: "G\xE9rer les acc\xE8s" })
3369
3863
  ] }) }),
3370
- issues.length > 0 && /* @__PURE__ */ jsx("div", { className: "rounded-md border border-status-pending bg-status-pending/10 p-3 text-sm", children: issues.map((issue) => /* @__PURE__ */ jsx("p", { children: settingsIssueLabel(issue.key, issue.message) }, issue.key)) }),
3864
+ summaryIssues.length > 0 && /* @__PURE__ */ jsx("div", { className: "rounded-md border border-status-pending bg-status-pending/10 p-3 text-sm", children: summaryIssues.map((issue) => /* @__PURE__ */ jsx("p", { children: settingsIssueLabel(issue.key, issue.message) }, issue.key)) }),
3371
3865
  canWrite && /* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(Button, { onClick: () => void save(form), disabled: isSaving || issues.length > 0, children: isSaving ? "Enregistrement\u2026" : "Enregistrer" }) })
3372
3866
  ] })
3373
3867
  ] });
@@ -3669,11 +4163,8 @@ function GraphCanvasPage() {
3669
4163
  );
3670
4164
  const isLoading = settingsLoading || categoriesLoading;
3671
4165
  const isUnavailable = !isLoading && (settingsError !== void 0 || categoriesError !== void 0 || !result);
3672
- return /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
3673
- /* @__PURE__ */ jsxs("div", { children: [
3674
- /* @__PURE__ */ jsx("h1", { className: "text-lg font-semibold", children: "Graphe" }),
3675
- /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Le parcours d'un ticket \xE0 travers les 9 n\u0153uds du pipeline, et ce qui, dans les r\xE9glages actuels, rend chaque n\u0153ud atteignable ou non." })
3676
- ] }),
4166
+ return /* @__PURE__ */ jsxs(PageShell, { children: [
4167
+ /* @__PURE__ */ jsx(PageHeader, { title: "Graphe", description: "Le parcours d'un ticket \xE0 travers les 9 n\u0153uds du pipeline, et ce qui, dans les r\xE9glages actuels, rend chaque n\u0153ud atteignable ou non." }),
3677
4168
  isLoading ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center py-12", children: [
3678
4169
  /* @__PURE__ */ jsx(Spinner, {}),
3679
4170
  " ",
@@ -3981,14 +4472,15 @@ function SharedPromptsPage() {
3981
4472
  },
3982
4473
  { key: "latestVersion", header: "Derni\xE8re version", align: "right", cell: (row) => `v${row.latestVersion}` }
3983
4474
  ];
3984
- return /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
3985
- /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-4", children: [
3986
- /* @__PURE__ */ jsxs("div", { children: [
3987
- /* @__PURE__ */ jsx("h1", { className: "text-lg font-semibold", children: "Prompts partag\xE9s" }),
3988
- /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "La biblioth\xE8que des prompts \xAB shared/* \xBB et leur composition." })
3989
- ] }),
3990
- canWrite && /* @__PURE__ */ jsx(Button, { onClick: () => setIsCreateOpen(true), children: "+ Nouveau prompt partag\xE9" })
3991
- ] }),
4475
+ return /* @__PURE__ */ jsxs(PageShell, { children: [
4476
+ /* @__PURE__ */ jsx(
4477
+ PageHeader,
4478
+ {
4479
+ title: "Prompts partag\xE9s",
4480
+ description: "La biblioth\xE8que des prompts \xAB shared/* \xBB et leur composition.",
4481
+ actions: canWrite && /* @__PURE__ */ jsx(Button, { onClick: () => setIsCreateOpen(true), children: "+ Nouveau prompt partag\xE9" })
4482
+ }
4483
+ ),
3992
4484
  /* @__PURE__ */ jsx("div", { className: "rounded-md border border-status-warning/40 bg-status-warning/10 p-3 text-sm text-status-warning", children: "Ressource commune \xE0 toute l'entreprise : sous D-LF il n'existe qu'un seul prompt Langfuse par nom \xAB shared/* \xBB, partag\xE9 par toutes les apps support. Modifier ou promouvoir une version ici change ce que TOUTES les apps utilisant ce prompt envoient \u2014 pas seulement celle-ci." }),
3993
4485
  /* @__PURE__ */ jsx(
3994
4486
  DataTable,
@@ -4206,7 +4698,7 @@ function DryRunResultView({ result, langfuseConfig, knownTags, tagSettings }) {
4206
4698
  ] }),
4207
4699
  result.guardrailHits.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
4208
4700
  /* @__PURE__ */ jsx("p", { className: "mb-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Garde-fous d\xE9clench\xE9s" }),
4209
- /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1", children: result.guardrailHits.map((hit, i) => /* @__PURE__ */ jsx(Badge, { variant: "warning", children: hit }, `${hit}-${i}`)) })
4701
+ /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1", children: result.guardrailHits.map((hit, i) => /* @__PURE__ */ jsx(Badge, { variant: "warning", children: guardrailHitLabel(hit) }, `${hit}-${i}`)) })
4210
4702
  ] }),
4211
4703
  /* @__PURE__ */ jsxs("div", { className: "rounded-md border border-dashed p-4", children: [
4212
4704
  /* @__PURE__ */ jsx("p", { className: "text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Ce qui n'a pas eu lieu" }),
@@ -4234,6 +4726,14 @@ var TRI_STATE_OPTIONS = [
4234
4726
  { value: "on", label: "Forcer actif" },
4235
4727
  { value: "off", label: "Forcer inactif" }
4236
4728
  ];
4729
+ var SOURCE_OPTIONS = [
4730
+ { value: "gorgias", label: "Ticket Gorgias existant" },
4731
+ { value: "inline", label: "Ticket saisi \xE0 la main" }
4732
+ ];
4733
+ var CHANNEL_OPTIONS = [
4734
+ { value: "email", label: "Email" },
4735
+ { value: "whatsapp", label: "WhatsApp" }
4736
+ ];
4237
4737
  function triStateToOverride(value) {
4238
4738
  if (value === "on") return true;
4239
4739
  if (value === "off") return false;
@@ -4263,7 +4763,11 @@ function describeOverrides(overrides) {
4263
4763
  }
4264
4764
  function SingleTicketTab({ langfuseConfig, agents, categories, knownTags, tagSettings }) {
4265
4765
  const api = useAppApi();
4766
+ const [source, setSource] = useState("gorgias");
4266
4767
  const [ticketId, setTicketId] = useState("");
4768
+ const [body, setBody] = useState("");
4769
+ const [subject, setSubject] = useState("");
4770
+ const [channel, setChannel] = useState("email");
4267
4771
  const [agentId, setAgentId] = useState("");
4268
4772
  const [categoryId, setCategoryId] = useState("");
4269
4773
  const [evaluateOverride, setEvaluateOverride] = useState("");
@@ -4275,6 +4779,10 @@ function SingleTicketTab({ langfuseConfig, agents, categories, knownTags, tagSet
4275
4779
  const [result, setResult] = useState(null);
4276
4780
  const [resultOverrides, setResultOverrides] = useState(null);
4277
4781
  const ticketIdInputId = useId();
4782
+ const bodyInputId = useId();
4783
+ const subjectInputId = useId();
4784
+ const isInline = source === "inline";
4785
+ const canRun = isInline ? body.trim() !== "" : ticketId.trim() !== "";
4278
4786
  const agentOptions = [{ value: "", label: "Agent du profil (d\xE9faut)" }, ...agents.map((a) => ({ value: a.id, label: a.name }))];
4279
4787
  const categoryOptions = [{ value: "", label: "Cat\xE9gorie du triage (d\xE9faut)" }, ...categories.map((c) => ({ value: c.id, label: c.name }))];
4280
4788
  async function run() {
@@ -4289,7 +4797,7 @@ function SingleTicketTab({ langfuseConfig, agents, categories, knownTags, tagSet
4289
4797
  ...autoSendOverride ? { autoSend: true } : {}
4290
4798
  };
4291
4799
  const payload = {
4292
- ticketId: ticketId.trim(),
4800
+ ...isInline ? { inlineTicket: { body: body.trim(), ...subject.trim() ? { subject: subject.trim() } : {}, channel } } : { ticketId: ticketId.trim() },
4293
4801
  ...agentId.trim() ? { agentId: agentId.trim() } : {},
4294
4802
  ...categoryId.trim() ? { categoryId: categoryId.trim() } : {},
4295
4803
  ...Object.keys(overrides).length > 0 ? { overrides } : {}
@@ -4309,9 +4817,32 @@ function SingleTicketTab({ langfuseConfig, agents, categories, knownTags, tagSet
4309
4817
  }
4310
4818
  }
4311
4819
  return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
4312
- /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Rejoue le graphe complet pour UN ticket, sans jamais r\xE9pondre, taguer ni \xE9crire de record (\xA70). Les n\u0153uds forc\xE9s \xAB inactif \xBB ou \xAB actif \xBB ne s'appliquent qu'\xE0 cette ex\xE9cution \u2014 les r\xE9glages de l'app ne changent pas." }),
4820
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Rejoue le graphe complet pour UN ticket, sans jamais r\xE9pondre, taguer ni \xE9crire de record (\xA70). Les n\u0153uds forc\xE9s \xAB inactif \xBB ou \xAB actif \xBB ne s'appliquent qu'\xE0 cette ex\xE9cution \u2014 les r\xE9glages de l'app ne changent pas. Un ticket saisi \xE0 la main ne touche aucun endpoint Gorgias : le graphe tourne en entier (triage, r\xE9daction, garde-fous, appels LLM r\xE9els) sur le texte fourni." }),
4313
4821
  /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-3 sm:grid-cols-3", children: [
4314
4822
  /* @__PURE__ */ jsxs("div", { children: [
4823
+ /* @__PURE__ */ jsx("p", { className: "mb-1 block text-sm font-medium", children: "Source du ticket" }),
4824
+ /* @__PURE__ */ jsx(
4825
+ Select,
4826
+ {
4827
+ "aria-label": "Source du ticket",
4828
+ items: SOURCE_OPTIONS,
4829
+ value: source,
4830
+ onValueChange: (next) => setSource(next)
4831
+ }
4832
+ )
4833
+ ] }),
4834
+ isInline ? /* @__PURE__ */ jsxs("div", { children: [
4835
+ /* @__PURE__ */ jsx("p", { className: "mb-1 block text-sm font-medium", children: "Canal" }),
4836
+ /* @__PURE__ */ jsx(
4837
+ Select,
4838
+ {
4839
+ "aria-label": "Canal",
4840
+ items: CHANNEL_OPTIONS,
4841
+ value: channel,
4842
+ onValueChange: (next) => setChannel(next)
4843
+ }
4844
+ )
4845
+ ] }) : /* @__PURE__ */ jsxs("div", { children: [
4315
4846
  /* @__PURE__ */ jsx("label", { htmlFor: ticketIdInputId, className: "mb-1 block text-sm font-medium", children: "ID du ticket" }),
4316
4847
  /* @__PURE__ */ jsx(Input, { id: ticketIdInputId, value: ticketId, onChange: (e) => setTicketId(e.target.value), placeholder: "12345" })
4317
4848
  ] }),
@@ -4324,6 +4855,25 @@ function SingleTicketTab({ langfuseConfig, agents, categories, knownTags, tagSet
4324
4855
  /* @__PURE__ */ jsx(Select, { "aria-label": "Cat\xE9gorie forc\xE9e (optionnel)", items: categoryOptions, value: categoryId, onValueChange: setCategoryId, placeholder: "Cat\xE9gorie du triage (d\xE9faut)" })
4325
4856
  ] })
4326
4857
  ] }),
4858
+ isInline && /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
4859
+ /* @__PURE__ */ jsxs("div", { children: [
4860
+ /* @__PURE__ */ jsx("label", { htmlFor: subjectInputId, className: "mb-1 block text-sm font-medium", children: "Sujet (optionnel)" }),
4861
+ /* @__PURE__ */ jsx(Input, { id: subjectInputId, value: subject, onChange: (e) => setSubject(e.target.value), placeholder: "O\xF9 est ma commande ?" })
4862
+ ] }),
4863
+ /* @__PURE__ */ jsxs("div", { children: [
4864
+ /* @__PURE__ */ jsx("label", { htmlFor: bodyInputId, className: "mb-1 block text-sm font-medium", children: "Message du client" }),
4865
+ /* @__PURE__ */ jsx(
4866
+ Textarea,
4867
+ {
4868
+ id: bodyInputId,
4869
+ value: body,
4870
+ onChange: (e) => setBody(e.target.value),
4871
+ rows: 6,
4872
+ placeholder: "Bonjour, j'ai command\xE9 il y a dix jours et je n'ai toujours rien re\xE7u\u2026"
4873
+ }
4874
+ )
4875
+ ] })
4876
+ ] }),
4327
4877
  /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-3 sm:grid-cols-4", children: [
4328
4878
  /* @__PURE__ */ jsx(OverrideSelect, { label: "N\u0153ud \xE9valuation", value: evaluateOverride, onChange: setEvaluateOverride }),
4329
4879
  /* @__PURE__ */ jsx(OverrideSelect, { label: "N\u0153ud r\xE9vision", value: reviseOverride, onChange: setReviseOverride }),
@@ -4337,7 +4887,7 @@ function SingleTicketTab({ langfuseConfig, agents, categories, knownTags, tagSet
4337
4887
  }
4338
4888
  ) })
4339
4889
  ] }),
4340
- /* @__PURE__ */ jsx(Button, { onClick: () => void run(), disabled: ticketId.trim() === "" || isRunning, children: isRunning ? "Test en cours\u2026" : "Lancer le test" }),
4890
+ /* @__PURE__ */ jsx(Button, { onClick: () => void run(), disabled: !canRun || isRunning, children: isRunning ? "Test en cours\u2026" : "Lancer le test" }),
4341
4891
  error && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: error }),
4342
4892
  result && /* @__PURE__ */ jsxs("div", { className: "rounded-md border p-4", children: [
4343
4893
  /* @__PURE__ */ jsx("p", { className: "mb-3 text-xs font-medium text-muted-foreground", "data-testid": "single-ticket-result-overrides", children: describeOverrides(resultOverrides ?? {}) }),
@@ -4345,117 +4895,21 @@ function SingleTicketTab({ langfuseConfig, agents, categories, knownTags, tagSet
4345
4895
  ] })
4346
4896
  ] });
4347
4897
  }
4348
- function BenchTab({ langfuseConfig, agents, knownTags, tagSettings }) {
4349
- const api = useAppApi();
4350
- const [viewId, setViewId] = useState("");
4351
- const [ticketIds, setTicketIds] = useState("");
4352
- const [agentId, setAgentId] = useState("");
4353
- const [limit, setLimit] = useState("");
4354
- const [isRunning, setIsRunning] = useState(false);
4355
- const [error, setError] = useState(null);
4356
- const [response, setResponse] = useState(null);
4357
- const [selected, setSelected] = useState(null);
4358
- const viewIdInputId = useId();
4359
- const ticketIdsInputId = useId();
4360
- const limitInputId = useId();
4361
- const agentOptions = [{ value: "", label: "Chaque ticket, agent r\xE9el de sa cat\xE9gorie" }, ...agents.map((a) => ({ value: a.id, label: a.name }))];
4362
- async function run() {
4363
- setIsRunning(true);
4364
- setError(null);
4365
- setResponse(null);
4366
- const parsedIds = ticketIds.split(",").map((id) => id.trim()).filter(Boolean);
4367
- const parsedLimit = Number(limit);
4368
- const payload = {
4369
- ...viewId.trim() ? { viewId: viewId.trim() } : {},
4370
- ...parsedIds.length > 0 ? { ticketIds: parsedIds } : {},
4371
- ...agentId.trim() ? { agentId: agentId.trim() } : {},
4372
- ...limit.trim() !== "" && Number.isFinite(parsedLimit) ? { limit: parsedLimit } : {}
4373
- };
4374
- try {
4375
- const result = await api.invoke(
4376
- "test-agents",
4377
- payload,
4378
- { idempotencyKey: idempotencyKeyFor("test-agents", payload) }
4379
- );
4380
- setResponse(result);
4381
- } catch (err) {
4382
- setError(describeInvokeError(err));
4383
- } finally {
4384
- setIsRunning(false);
4385
- }
4386
- }
4387
- const columns = [
4388
- { key: "ticketId", header: "Ticket", cell: (row) => row.ticketId },
4389
- { key: "outcome", header: "Issue", cell: (row) => /* @__PURE__ */ jsx(Badge, { variant: row.outcome === "sent" ? "success" : "neutral", children: outcomeLabel(row.outcome) }) },
4390
- { key: "guardrails", header: "Garde-fous", cell: (row) => row.guardrailHits.length > 0 ? row.guardrailHits.map(guardrailHitLabel).join(", ") : "\u2014" },
4391
- { key: "completions", header: "Appels LLM", align: "right", cell: (row) => String(row.completions.length) },
4392
- { key: "error", header: "Erreur", cell: (row) => row.error ? /* @__PURE__ */ jsx(Badge, { variant: "danger", children: row.error }) : "\u2014" }
4393
- ];
4394
- const canSubmit = (viewId.trim() !== "" || ticketIds.trim() !== "") && !isRunning;
4395
- return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
4396
- /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Rejoue le graphe complet, sans \xE9criture, sur plusieurs tickets d'une vue Gorgias ou d'une liste d'ids \u2014 aucune de leurs cat\xE9gories n'est r\xE9ellement lue pour l'envoi automatique : le banc force \xAB Envoi auto \xBB actif pour chaque ticket afin d'observer le chemin complet (voir le bandeau ci-dessous)." }),
4397
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-3 sm:grid-cols-4", children: [
4398
- /* @__PURE__ */ jsxs("div", { children: [
4399
- /* @__PURE__ */ jsx("label", { htmlFor: viewIdInputId, className: "mb-1 block text-sm font-medium", children: "Vue Gorgias (id)" }),
4400
- /* @__PURE__ */ jsx(Input, { id: viewIdInputId, value: viewId, onChange: (e) => setViewId(e.target.value) })
4401
- ] }),
4402
- /* @__PURE__ */ jsxs("div", { children: [
4403
- /* @__PURE__ */ jsx("label", { htmlFor: ticketIdsInputId, className: "mb-1 block text-sm font-medium", children: "Ou ids de tickets (s\xE9par\xE9s par une virgule)" }),
4404
- /* @__PURE__ */ jsx(Input, { id: ticketIdsInputId, value: ticketIds, onChange: (e) => setTicketIds(e.target.value) })
4405
- ] }),
4406
- /* @__PURE__ */ jsxs("div", { children: [
4407
- /* @__PURE__ */ jsx("p", { className: "mb-1 block text-sm font-medium", children: "Agent (optionnel)" }),
4408
- /* @__PURE__ */ jsx(Select, { "aria-label": "Agent (optionnel)", items: agentOptions, value: agentId, onValueChange: setAgentId, placeholder: "Chaque ticket, agent r\xE9el de sa cat\xE9gorie" })
4409
- ] }),
4410
- /* @__PURE__ */ jsxs("div", { children: [
4411
- /* @__PURE__ */ jsx("label", { htmlFor: limitInputId, className: "mb-1 block text-sm font-medium", children: "Limite (d\xE9faut 20, max 100)" }),
4412
- /* @__PURE__ */ jsx(Input, { id: limitInputId, type: "number", value: limit, onChange: (e) => setLimit(e.target.value) })
4413
- ] })
4414
- ] }),
4415
- /* @__PURE__ */ jsx(Button, { onClick: () => void run(), disabled: !canSubmit, children: isRunning ? "Banc en cours\u2026" : "Lancer le banc" }),
4416
- error && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: error }),
4417
- response && /* @__PURE__ */ jsxs(Fragment, { children: [
4418
- /* @__PURE__ */ jsx("div", { className: "rounded-md border border-status-warning/40 bg-status-warning/10 p-3 text-sm text-status-warning", children: "Envoi automatique forc\xE9 pour ce banc : chaque ticket est \xE9valu\xE9 comme si sa cat\xE9gorie avait \xAB Envoi auto \xBB activ\xE9, quel que soit son r\xE9glage r\xE9el \u2014 voir la colonne Issue pour ce que le graphe aurait fait dans ce cas." }),
4419
- /* @__PURE__ */ jsx(
4420
- DataTable,
4421
- {
4422
- columns,
4423
- rows: response.results,
4424
- rowId: (row) => row.ticketId,
4425
- manual: true,
4426
- onRowClick: (row) => setSelected(row),
4427
- empty: "Aucun ticket dans cette fen\xEAtre."
4428
- }
4429
- )
4430
- ] }),
4431
- selected && /* @__PURE__ */ jsx(SidePanel, { open: true, onClose: () => setSelected(null), title: `Ticket ${selected.ticketId}`, children: /* @__PURE__ */ jsx("div", { "data-testid": "dry-run-detail", children: /* @__PURE__ */ jsx(DryRunResultView, { result: selected, langfuseConfig, knownTags, tagSettings }) }) })
4432
- ] });
4433
- }
4434
- function TestTabs() {
4898
+ function TestControls() {
4435
4899
  const { config: langfuseConfig } = useLangfuseConfig();
4436
4900
  const { settings } = useAppSettings();
4437
4901
  const { rows: allAgents } = useRecordList("agent", { limit: 500 }, toAgent);
4438
4902
  const { rows: categories } = useRecordList("category", { limit: 500 }, toCategory);
4439
4903
  const agents = useMemo(() => allAgents.filter((agent) => agent.status !== "archived"), [allAgents]);
4440
4904
  const knownTags = useMemo(() => categories.map((category) => category.tagName), [categories]);
4441
- return /* @__PURE__ */ jsxs(Tabs, { defaultValue: "single", children: [
4442
- /* @__PURE__ */ jsxs(TabsList, { children: [
4443
- /* @__PURE__ */ jsx(TabsTrigger, { value: "single", children: "Test unitaire" }),
4444
- /* @__PURE__ */ jsx(TabsTrigger, { value: "bench", children: "Banc d'essai" })
4445
- ] }),
4446
- /* @__PURE__ */ jsx(TabsContent, { value: "single", children: /* @__PURE__ */ jsx(SingleTicketTab, { langfuseConfig, agents, categories, knownTags, tagSettings: settings }) }),
4447
- /* @__PURE__ */ jsx(TabsContent, { value: "bench", children: /* @__PURE__ */ jsx(BenchTab, { langfuseConfig, agents, knownTags, tagSettings: settings }) })
4448
- ] });
4905
+ return /* @__PURE__ */ jsx(SingleTicketTab, { langfuseConfig, agents, categories, knownTags, tagSettings: settings });
4449
4906
  }
4450
4907
  function TestPage() {
4451
4908
  const { role } = useAppContext();
4452
4909
  const canRun = canWriteForRole(role);
4453
- return /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
4454
- /* @__PURE__ */ jsxs("div", { children: [
4455
- /* @__PURE__ */ jsx("h1", { className: "text-lg font-semibold", children: "Banc de test" }),
4456
- /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Rejoue le graphe sans jamais agir sur un vrai ticket (\xA70)." })
4457
- ] }),
4458
- !canRun ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Acc\xE8s en lecture seule \u2014 lancer un test n\xE9cessite le r\xF4le EDITOR (chaque ex\xE9cution consomme du budget LLM)." }) : /* @__PURE__ */ jsx(TestTabs, {})
4910
+ return /* @__PURE__ */ jsxs(PageShell, { children: [
4911
+ /* @__PURE__ */ jsx(PageHeader, { title: "Banc de test", description: "Rejoue le graphe sans jamais agir sur un vrai ticket (\xA70)." }),
4912
+ !canRun ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Acc\xE8s en lecture seule \u2014 lancer un test n\xE9cessite le r\xF4le EDITOR (chaque ex\xE9cution consomme du budget LLM)." }) : /* @__PURE__ */ jsx(TestControls, {})
4459
4913
  ] });
4460
4914
  }
4461
4915