@apotech-os/support-kit 3.0.1 → 3.0.2

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.cjs CHANGED
@@ -1822,6 +1822,16 @@ function applyPreset(value, preset, restore) {
1822
1822
  }
1823
1823
  return next;
1824
1824
  }
1825
+
1826
+ // src/ui/shared/quality-href.ts
1827
+ function qualityHref(appSlug, agent) {
1828
+ const base2 = `/espace/${appSlug}/quality`;
1829
+ if (!agent) return base2;
1830
+ const params = new URLSearchParams({ promptName: agent.promptName });
1831
+ if (agent.promptVersion !== null) params.set("promptVersion", String(agent.promptVersion));
1832
+ params.set("agentId", agent.id);
1833
+ return `${base2}?${params.toString()}`;
1834
+ }
1825
1835
  function usePromptCatalogue() {
1826
1836
  const { appSlug } = uiSdk.useAppContext();
1827
1837
  const api = uiSdk.useAppApi();
@@ -2162,7 +2172,14 @@ function AgentFormModal({
2162
2172
  children: /* @__PURE__ */ jsxRuntime.jsxs("form", { className: "space-y-3", onSubmit: (e) => void submit(e), children: [
2163
2173
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2164
2174
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: nameId, className: "mb-1 block text-sm font-medium", children: "Nom" }),
2165
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Input, { id: nameId, value: form.name, onChange: (e) => setForm({ ...form, name: e.target.value }) })
2175
+ /* @__PURE__ */ jsxRuntime.jsx(
2176
+ uiSdk.Input,
2177
+ {
2178
+ id: nameId,
2179
+ value: form.name,
2180
+ onChange: (e) => setForm({ ...form, name: e.target.value })
2181
+ }
2182
+ )
2166
2183
  ] }),
2167
2184
  agent !== "new" && agent.status !== "default" && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2168
2185
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-1 text-sm font-medium", children: "Statut" }),
@@ -2232,7 +2249,12 @@ function AgentFormModal({
2232
2249
  value: showPromptFreeText ? CUSTOM_PROMPT_VALUE : knownPrompt ? form.promptName : agent === "new" ? DERIVED_PROMPT_VALUE : void 0,
2233
2250
  onValueChange: pickPrompt,
2234
2251
  items: [
2235
- ...agent === "new" ? [{ value: DERIVED_PROMPT_VALUE, label: "Nouveau prompt \u2014 agent/<g\xE9n\xE9r\xE9 automatiquement>" }] : [],
2252
+ ...agent === "new" ? [
2253
+ {
2254
+ value: DERIVED_PROMPT_VALUE,
2255
+ label: "Nouveau prompt \u2014 agent/<g\xE9n\xE9r\xE9 automatiquement>"
2256
+ }
2257
+ ] : [],
2236
2258
  ...prompts.map((entry) => ({ value: entry.name, label: entry.name })),
2237
2259
  { value: CUSTOM_PROMPT_VALUE, label: "Autre \u2014 saisir un nom de prompt" }
2238
2260
  ],
@@ -2291,6 +2313,7 @@ function PromptVersionsPanel({
2291
2313
  canWrite,
2292
2314
  onClose
2293
2315
  }) {
2316
+ const { appSlug } = uiSdk.useAppContext();
2294
2317
  const { versions, error, refresh, promote, deleteVersion, createVersion } = usePromptVersions(
2295
2318
  agent.promptName
2296
2319
  );
@@ -2336,7 +2359,11 @@ function PromptVersionsPanel({
2336
2359
  await promote(version);
2337
2360
  toast({ title: `Version ${version} promue en production.`, variant: "success" });
2338
2361
  } catch (err) {
2339
- toast({ title: "\xC9chec de la promotion", description: describeApiError(err), variant: "error" });
2362
+ toast({
2363
+ title: "\xC9chec de la promotion",
2364
+ description: describeApiError(err),
2365
+ variant: "error"
2366
+ });
2340
2367
  }
2341
2368
  }
2342
2369
  async function runCreateVersion() {
@@ -2346,7 +2373,11 @@ function PromptVersionsPanel({
2346
2373
  setNewVersionContent("");
2347
2374
  toast({ title: "Nouvelle version cr\xE9\xE9e.", variant: "success" });
2348
2375
  } catch (err) {
2349
- toast({ title: "\xC9chec de la cr\xE9ation", description: describeApiError(err), variant: "error" });
2376
+ toast({
2377
+ title: "\xC9chec de la cr\xE9ation",
2378
+ description: describeApiError(err),
2379
+ variant: "error"
2380
+ });
2350
2381
  } finally {
2351
2382
  setIsCreatingVersion(false);
2352
2383
  }
@@ -2358,7 +2389,11 @@ function PromptVersionsPanel({
2358
2389
  await deleteVersion(version);
2359
2390
  toast({ title: `Version ${version} supprim\xE9e.`, variant: "success" });
2360
2391
  } catch (err) {
2361
- toast({ title: "\xC9chec de la suppression", description: describeApiError(err), variant: "error" });
2392
+ toast({
2393
+ title: "\xC9chec de la suppression",
2394
+ description: describeApiError(err),
2395
+ variant: "error"
2396
+ });
2362
2397
  } finally {
2363
2398
  setDeletingVersion(null);
2364
2399
  }
@@ -2373,13 +2408,7 @@ function PromptVersionsPanel({
2373
2408
  children: [
2374
2409
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto", children: [
2375
2410
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
2376
- /* @__PURE__ */ jsxRuntime.jsx(
2377
- uiSdk.Link,
2378
- {
2379
- href: `/qualite?promptName=${encodeURIComponent(agent.promptName)}${agent.promptVersion !== null ? `&promptVersion=${agent.promptVersion}` : ""}&agentId=${encodeURIComponent(agent.id)}`,
2380
- children: "Voir dans Qualit\xE9"
2381
- }
2382
- ),
2411
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Link, { href: qualityHref(appSlug, agent), children: "Voir dans Qualit\xE9" }),
2383
2412
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2", children: [
2384
2413
  versions.length >= 2 && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", onClick: openCompare, children: "Comparer" }),
2385
2414
  canWrite && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", onClick: () => void suggest(), disabled: isSuggesting, children: isSuggesting ? "Suggestion en cours\u2026" : "Sugg\xE9rer une am\xE9lioration" })
@@ -2407,7 +2436,15 @@ function PromptVersionsPanel({
2407
2436
  ] }),
2408
2437
  canWrite && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2", children: [
2409
2438
  /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", size: "sm", onClick: () => void runPromote(v.version), children: "Promouvoir" }),
2410
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", size: "sm", onClick: () => setDeletingVersion(v.version), children: "Supprimer la version" })
2439
+ /* @__PURE__ */ jsxRuntime.jsx(
2440
+ uiSdk.Button,
2441
+ {
2442
+ variant: "outline",
2443
+ size: "sm",
2444
+ onClick: () => setDeletingVersion(v.version),
2445
+ children: "Supprimer la version"
2446
+ }
2447
+ )
2411
2448
  ] })
2412
2449
  ] }),
2413
2450
  /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "mt-2 whitespace-pre-wrap text-xs text-muted-foreground", children: v.content })
@@ -2474,15 +2511,27 @@ function AgentsPage() {
2474
2511
  await api.patch(recordPath(agent.id), { data: { status } });
2475
2512
  await refresh();
2476
2513
  } catch (err) {
2477
- toast({ title: "\xC9chec de la mise \xE0 jour", description: describeApiError(err), variant: "error" });
2514
+ toast({
2515
+ title: "\xC9chec de la mise \xE0 jour",
2516
+ description: describeApiError(err),
2517
+ variant: "error"
2518
+ });
2478
2519
  }
2479
2520
  }
2480
2521
  async function setDefault(agent) {
2481
2522
  try {
2482
- await api.invoke("set-default-agent", { agentId: agent.id }, { idempotencyKey: crypto.randomUUID() });
2523
+ await api.invoke(
2524
+ "set-default-agent",
2525
+ { agentId: agent.id },
2526
+ { idempotencyKey: crypto.randomUUID() }
2527
+ );
2483
2528
  await refresh();
2484
2529
  } catch (err) {
2485
- toast({ title: "\xC9chec de la promotion par d\xE9faut", description: describeInvokeError(err), variant: "error" });
2530
+ toast({
2531
+ title: "\xC9chec de la promotion par d\xE9faut",
2532
+ description: describeInvokeError(err),
2533
+ variant: "error"
2534
+ });
2486
2535
  }
2487
2536
  }
2488
2537
  async function confirmDelete() {
@@ -2493,7 +2542,11 @@ function AgentsPage() {
2493
2542
  await refresh();
2494
2543
  toast({ title: `Agent \xAB ${agent.name} \xBB supprim\xE9.`, variant: "success" });
2495
2544
  } catch (err) {
2496
- toast({ title: "\xC9chec de la suppression", description: describeApiError(err), variant: "error" });
2545
+ toast({
2546
+ title: "\xC9chec de la suppression",
2547
+ description: describeApiError(err),
2548
+ variant: "error"
2549
+ });
2497
2550
  } finally {
2498
2551
  setDeletingAgent(null);
2499
2552
  }
@@ -2610,7 +2663,14 @@ function AgentsPage() {
2610
2663
  onSave: save
2611
2664
  }
2612
2665
  ),
2613
- versionsAgent && /* @__PURE__ */ jsxRuntime.jsx(PromptVersionsPanel, { agent: versionsAgent, canWrite, onClose: () => setVersionsAgent(null) }),
2666
+ versionsAgent && /* @__PURE__ */ jsxRuntime.jsx(
2667
+ PromptVersionsPanel,
2668
+ {
2669
+ agent: versionsAgent,
2670
+ canWrite,
2671
+ onClose: () => setVersionsAgent(null)
2672
+ }
2673
+ ),
2614
2674
  deletingAgent && /* @__PURE__ */ jsxRuntime.jsx(
2615
2675
  ConfirmModal,
2616
2676
  {
@@ -3303,11 +3363,6 @@ var MATCH_BADGE_CLASS = (pct) => {
3303
3363
  return "border-destructive/25 bg-destructive/10 text-destructive";
3304
3364
  };
3305
3365
  var VERSION_LINE_COLORS = 8;
3306
- function qualityHref(agent) {
3307
- if (!agent) return "/qualite";
3308
- const version = agent.promptVersion !== null ? `&promptVersion=${agent.promptVersion}` : "";
3309
- return `/qualite?promptName=${encodeURIComponent(agent.promptName)}${version}&agentId=${encodeURIComponent(agent.id)}`;
3310
- }
3311
3366
  function tokensFor(row) {
3312
3367
  return row.diff ?? computeWordDiff(row.generatedText, row.sentText);
3313
3368
  }
@@ -3327,39 +3382,80 @@ function DetailPanel4({
3327
3382
  onClose
3328
3383
  }) {
3329
3384
  const tokens = tokensFor(row);
3330
- return /* @__PURE__ */ jsxRuntime.jsx(uiSdk.SidePanel, { open: true, onClose, title: `Ticket ${row.ticketId ?? "\u2014"}`, description: agentName, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4 text-sm", children: [
3331
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
3332
- /* @__PURE__ */ jsxRuntime.jsx(MatchBadge, { row }),
3333
- row.ticketUrl && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Link, { href: row.ticketUrl, target: "_blank", rel: "noopener noreferrer", className: "text-xs", children: "Ouvrir le ticket" })
3334
- ] }),
3335
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-3 sm:grid-cols-2", children: [
3336
- /* @__PURE__ */ jsxRuntime.jsx(WordDiffView, { title: "G\xE9n\xE9r\xE9 par l'IA", tokens, keep: "delete", hideEqual: diffOnly }),
3337
- /* @__PURE__ */ jsxRuntime.jsx(WordDiffView, { title: "Envoy\xE9 par l'agent", tokens, keep: "insert", hideEqual: diffOnly })
3338
- ] }),
3339
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground", children: [
3340
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
3341
- "Captur\xE9 le ",
3342
- formatDate(row.capturedAt)
3343
- ] }),
3344
- row.promptName && /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
3345
- "Prompt : ",
3346
- /* @__PURE__ */ jsxRuntime.jsx("code", { children: row.promptName }),
3347
- row.promptVersion !== null ? ` v${row.promptVersion}` : ""
3385
+ return /* @__PURE__ */ jsxRuntime.jsx(
3386
+ uiSdk.SidePanel,
3387
+ {
3388
+ open: true,
3389
+ onClose,
3390
+ title: `Ticket ${row.ticketId ?? "\u2014"}`,
3391
+ description: agentName,
3392
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4 text-sm", children: [
3393
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
3394
+ /* @__PURE__ */ jsxRuntime.jsx(MatchBadge, { row }),
3395
+ row.ticketUrl && /* @__PURE__ */ jsxRuntime.jsx(
3396
+ uiSdk.Link,
3397
+ {
3398
+ href: row.ticketUrl,
3399
+ target: "_blank",
3400
+ rel: "noopener noreferrer",
3401
+ className: "text-xs",
3402
+ children: "Ouvrir le ticket"
3403
+ }
3404
+ )
3405
+ ] }),
3406
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-3 sm:grid-cols-2", children: [
3407
+ /* @__PURE__ */ jsxRuntime.jsx(
3408
+ WordDiffView,
3409
+ {
3410
+ title: "G\xE9n\xE9r\xE9 par l'IA",
3411
+ tokens,
3412
+ keep: "delete",
3413
+ hideEqual: diffOnly
3414
+ }
3415
+ ),
3416
+ /* @__PURE__ */ jsxRuntime.jsx(
3417
+ WordDiffView,
3418
+ {
3419
+ title: "Envoy\xE9 par l'agent",
3420
+ tokens,
3421
+ keep: "insert",
3422
+ hideEqual: diffOnly
3423
+ }
3424
+ )
3425
+ ] }),
3426
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground", children: [
3427
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
3428
+ "Captur\xE9 le ",
3429
+ formatDate(row.capturedAt)
3430
+ ] }),
3431
+ row.promptName && /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
3432
+ "Prompt : ",
3433
+ /* @__PURE__ */ jsxRuntime.jsx("code", { children: row.promptName }),
3434
+ row.promptVersion !== null ? ` v${row.promptVersion}` : ""
3435
+ ] })
3436
+ ] }),
3437
+ (row.langfuseTraceId || row.langfuseObservationId) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
3438
+ /* @__PURE__ */ jsxRuntime.jsx(
3439
+ LangfuseTraceLink,
3440
+ {
3441
+ traceId: row.langfuseTraceId,
3442
+ config: langfuseConfig,
3443
+ label: "Trace g\xE9n\xE9ration"
3444
+ }
3445
+ ),
3446
+ /* @__PURE__ */ jsxRuntime.jsx(
3447
+ LangfuseTraceLink,
3448
+ {
3449
+ traceId: row.langfuseTraceId,
3450
+ observationId: row.langfuseObservationId,
3451
+ config: langfuseConfig,
3452
+ label: "Trace \xE9valuation"
3453
+ }
3454
+ )
3455
+ ] })
3348
3456
  ] })
3349
- ] }),
3350
- (row.langfuseTraceId || row.langfuseObservationId) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
3351
- /* @__PURE__ */ jsxRuntime.jsx(LangfuseTraceLink, { traceId: row.langfuseTraceId, config: langfuseConfig, label: "Trace g\xE9n\xE9ration" }),
3352
- /* @__PURE__ */ jsxRuntime.jsx(
3353
- LangfuseTraceLink,
3354
- {
3355
- traceId: row.langfuseTraceId,
3356
- observationId: row.langfuseObservationId,
3357
- config: langfuseConfig,
3358
- label: "Trace \xE9valuation"
3359
- }
3360
- )
3361
- ] })
3362
- ] }) });
3457
+ }
3458
+ );
3363
3459
  }
3364
3460
  function CorrectionsPage() {
3365
3461
  const { role, appSlug } = uiSdk.useAppContext();
@@ -3406,27 +3502,40 @@ function CorrectionsPage() {
3406
3502
  },
3407
3503
  toResponseComparison
3408
3504
  );
3409
- const visibleRows = react.useMemo(() => diffOnly ? comparisons.filter(isTextChanged) : comparisons, [comparisons, diffOnly]);
3505
+ const visibleRows = react.useMemo(
3506
+ () => diffOnly ? comparisons.filter(isTextChanged) : comparisons,
3507
+ [comparisons, diffOnly]
3508
+ );
3410
3509
  const { rows: agents } = useRecordList("agent", { limit: 500 }, toAgent);
3411
3510
  const agentNames = react.useMemo(() => toNameMap(agents), [agents]);
3412
3511
  const selectedAgent = agents.find((a) => a.id === agentFilter);
3413
3512
  const { versions: promptVersions } = usePromptVersions(selectedAgent?.promptName ?? null);
3414
3513
  const versionOptions = [
3415
3514
  { value: "", label: "Toutes les versions" },
3416
- ...promptVersions.map((v) => ({ value: String(v.version), label: `v${v.version}${v.labels.includes("production") ? " (active)" : ""}` }))
3515
+ ...promptVersions.map((v) => ({
3516
+ value: String(v.version),
3517
+ label: `v${v.version}${v.labels.includes("production") ? " (active)" : ""}`
3518
+ }))
3417
3519
  ];
3418
- const {
3419
- rows: diffAnalyses,
3420
- refresh: refreshDiffAnalyses
3421
- } = useRecordList(
3520
+ const { rows: diffAnalyses, refresh: refreshDiffAnalyses } = useRecordList(
3422
3521
  "diff-analysis",
3423
3522
  { filter: agentFilter ? { agentId: { eq: agentFilter } } : void 0, limit: 50 },
3424
3523
  toDiffAnalysis
3425
3524
  );
3426
- const sortedAnalyses = react.useMemo(() => [...diffAnalyses].sort((a, b) => b.promptVersion - a.promptVersion), [diffAnalyses]);
3427
- const rewriteRate = react.useMemo(() => computeRewriteRateByVersion(comparisons, timezone), [comparisons, timezone]);
3525
+ const sortedAnalyses = react.useMemo(
3526
+ () => [...diffAnalyses].sort((a, b) => b.promptVersion - a.promptVersion),
3527
+ [diffAnalyses]
3528
+ );
3529
+ const rewriteRate = react.useMemo(
3530
+ () => computeRewriteRateByVersion(comparisons, timezone),
3531
+ [comparisons, timezone]
3532
+ );
3428
3533
  const rewriteRateSeries = react.useMemo(
3429
- () => rewriteRate.versions.map((version, index) => ({ key: versionSeriesKey(version), label: `v${version}`, colorIndex: index % VERSION_LINE_COLORS })),
3534
+ () => rewriteRate.versions.map((version, index) => ({
3535
+ key: versionSeriesKey(version),
3536
+ label: `v${version}`,
3537
+ colorIndex: index % VERSION_LINE_COLORS
3538
+ })),
3430
3539
  [rewriteRate.versions]
3431
3540
  );
3432
3541
  const agentOptions = [
@@ -3438,11 +3547,17 @@ function CorrectionsPage() {
3438
3547
  setIsAnalyzing(true);
3439
3548
  const payload = { agentId: agentFilter, limit: 50 };
3440
3549
  try {
3441
- await api.invoke("run-diff-analysis", payload, { idempotencyKey: idempotencyKeyFor("run-diff-analysis", payload) });
3550
+ await api.invoke("run-diff-analysis", payload, {
3551
+ idempotencyKey: idempotencyKeyFor("run-diff-analysis", payload)
3552
+ });
3442
3553
  toast({ title: "Analyse lanc\xE9e \u2014 les nouveaux points sont ci-dessous.", variant: "success" });
3443
3554
  await refreshDiffAnalyses();
3444
3555
  } catch (err) {
3445
- toast({ title: "\xC9chec de l'analyse", description: describeInvokeError(err), variant: "error" });
3556
+ toast({
3557
+ title: "\xC9chec de l'analyse",
3558
+ description: describeInvokeError(err),
3559
+ variant: "error"
3560
+ });
3446
3561
  } finally {
3447
3562
  setIsAnalyzing(false);
3448
3563
  }
@@ -3457,7 +3572,11 @@ function CorrectionsPage() {
3457
3572
  await refresh();
3458
3573
  toast({ title: "Comparaison supprim\xE9e.", variant: "success" });
3459
3574
  } catch (err) {
3460
- toast({ title: "\xC9chec de la suppression", description: describeApiError(err), variant: "error" });
3575
+ toast({
3576
+ title: "\xC9chec de la suppression",
3577
+ description: describeApiError(err),
3578
+ variant: "error"
3579
+ });
3461
3580
  } finally {
3462
3581
  setIsDeleting(false);
3463
3582
  setPendingDeleteRow(null);
@@ -3470,7 +3589,11 @@ function CorrectionsPage() {
3470
3589
  await refresh();
3471
3590
  toast({ title: "Comparaisons supprim\xE9es.", variant: "success" });
3472
3591
  } catch (err) {
3473
- toast({ title: "\xC9chec de la suppression", description: describeApiError(err), variant: "error" });
3592
+ toast({
3593
+ title: "\xC9chec de la suppression",
3594
+ description: describeApiError(err),
3595
+ variant: "error"
3596
+ });
3474
3597
  } finally {
3475
3598
  setIsDeleting(false);
3476
3599
  setPendingDeleteAll(false);
@@ -3480,9 +3603,22 @@ function CorrectionsPage() {
3480
3603
  {
3481
3604
  key: "ticketId",
3482
3605
  header: "Ticket",
3483
- cell: (row) => row.ticketUrl ? /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Link, { href: row.ticketUrl, target: "_blank", rel: "noopener noreferrer", onClick: (e) => e.stopPropagation(), children: row.ticketId ?? "\u2014" }) : row.ticketId ?? "\u2014"
3606
+ cell: (row) => row.ticketUrl ? /* @__PURE__ */ jsxRuntime.jsx(
3607
+ uiSdk.Link,
3608
+ {
3609
+ href: row.ticketUrl,
3610
+ target: "_blank",
3611
+ rel: "noopener noreferrer",
3612
+ onClick: (e) => e.stopPropagation(),
3613
+ children: row.ticketId ?? "\u2014"
3614
+ }
3615
+ ) : row.ticketId ?? "\u2014"
3616
+ },
3617
+ {
3618
+ key: "agent",
3619
+ header: "Agent",
3620
+ cell: (row) => row.agentId && agentNames.get(row.agentId) || "\u2014"
3484
3621
  },
3485
- { key: "agent", header: "Agent", cell: (row) => row.agentId && agentNames.get(row.agentId) || "\u2014" },
3486
3622
  {
3487
3623
  key: "changed",
3488
3624
  header: "R\xE9sultat",
@@ -3549,12 +3685,29 @@ function CorrectionsPage() {
3549
3685
  children: diffOnly ? "Afficher toutes les lignes" : "Masquer les lignes identiques"
3550
3686
  }
3551
3687
  ),
3552
- canWrite && agentFilter && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", size: "sm", onClick: () => setPendingDeleteAll(true), disabled: isDeleting, children: "Tout supprimer" })
3688
+ canWrite && agentFilter && /* @__PURE__ */ jsxRuntime.jsx(
3689
+ uiSdk.Button,
3690
+ {
3691
+ variant: "outline",
3692
+ size: "sm",
3693
+ onClick: () => setPendingDeleteAll(true),
3694
+ disabled: isDeleting,
3695
+ children: "Tout supprimer"
3696
+ }
3697
+ )
3553
3698
  ] }),
3554
3699
  /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Card, { children: /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.CardContent, { className: "p-4", children: [
3555
3700
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-1 text-sm font-medium", children: "Taux de r\xE9\xE9criture" }),
3556
3701
  /* @__PURE__ */ jsxRuntime.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." }),
3557
- rewriteRate.points.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Aucune donn\xE9e de r\xE9\xE9criture pour cette s\xE9lection." }) : /* @__PURE__ */ jsxRuntime.jsx(uiSdk.LineChart, { data: rewriteRate.points, x: "day", series: rewriteRateSeries, formatValue: (v) => `${v}%` })
3702
+ rewriteRate.points.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Aucune donn\xE9e de r\xE9\xE9criture pour cette s\xE9lection." }) : /* @__PURE__ */ jsxRuntime.jsx(
3703
+ uiSdk.LineChart,
3704
+ {
3705
+ data: rewriteRate.points,
3706
+ x: "day",
3707
+ series: rewriteRateSeries,
3708
+ formatValue: (v) => `${v}%`
3709
+ }
3710
+ )
3558
3711
  ] }) }),
3559
3712
  agentFilter && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Card, { children: /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.CardContent, { className: "space-y-3 p-4", children: [
3560
3713
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
@@ -3566,7 +3719,7 @@ function CorrectionsPage() {
3566
3719
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: "Patterns r\xE9currents extraits par le LLM \xE0 partir des corrections non identiques." })
3567
3720
  ] }),
3568
3721
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
3569
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Link, { href: qualityHref(selectedAgent), children: "Voir dans Qualit\xE9" }),
3722
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Link, { href: qualityHref(appSlug, selectedAgent), children: "Voir dans Qualit\xE9" }),
3570
3723
  canWrite && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { onClick: () => void runAnalysis(), disabled: isAnalyzing, children: isAnalyzing ? "Analyse en cours\u2026" : "Lancer l'analyse" })
3571
3724
  ] })
3572
3725
  ] }),
@@ -4142,6 +4295,84 @@ function useIds(stepKey) {
4142
4295
  minConfidence: `${base2}-${stepKey}-min-confidence`
4143
4296
  };
4144
4297
  }
4298
+ function normalize(text) {
4299
+ return text.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase();
4300
+ }
4301
+ var MAX_RESULTS = 12;
4302
+ function SearchableSelect({
4303
+ id,
4304
+ options,
4305
+ value,
4306
+ onChange,
4307
+ disabled = false,
4308
+ labels
4309
+ }) {
4310
+ const [search, setSearch] = react.useState("");
4311
+ if (options.length === 0) {
4312
+ return /* @__PURE__ */ jsxRuntime.jsx(
4313
+ uiSdk.Input,
4314
+ {
4315
+ id,
4316
+ "aria-label": labels.fallbackAriaLabel,
4317
+ value,
4318
+ onChange: (e) => onChange(e.target.value),
4319
+ disabled
4320
+ }
4321
+ );
4322
+ }
4323
+ const term = normalize(search.trim());
4324
+ const matches = term === "" ? options : options.filter(
4325
+ (option) => normalize(`${option.label} ${option.keywords ?? ""}`).includes(term)
4326
+ );
4327
+ const shown = matches.slice(0, MAX_RESULTS);
4328
+ const current = options.find((option) => option.value === value);
4329
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
4330
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: current ? labels.current(current.label) : labels.none }),
4331
+ /* @__PURE__ */ jsxRuntime.jsx(
4332
+ uiSdk.Input,
4333
+ {
4334
+ id,
4335
+ "aria-label": labels.searchAriaLabel,
4336
+ placeholder: labels.searchPlaceholder,
4337
+ value: search,
4338
+ onChange: (e) => setSearch(e.target.value),
4339
+ disabled
4340
+ }
4341
+ ),
4342
+ shown.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: labels.noMatch }) : /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "flex flex-wrap gap-2", children: shown.map((option) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsx(
4343
+ uiSdk.Button,
4344
+ {
4345
+ variant: option.value === value ? "default" : "outline",
4346
+ size: "sm",
4347
+ disabled,
4348
+ onClick: () => onChange(option.value),
4349
+ children: option.label
4350
+ }
4351
+ ) }, option.value)) }),
4352
+ matches.length > shown.length && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: labels.truncated(options.length) })
4353
+ ] });
4354
+ }
4355
+ function SourceViewField({ views, value, onChange, disabled }) {
4356
+ return /* @__PURE__ */ jsxRuntime.jsx(
4357
+ SearchableSelect,
4358
+ {
4359
+ id: "sourceViewId",
4360
+ options: views.map((view) => ({ value: view.id, label: view.name, keywords: view.id })),
4361
+ value,
4362
+ onChange,
4363
+ disabled,
4364
+ labels: {
4365
+ fallbackAriaLabel: "Vue Gorgias source",
4366
+ searchAriaLabel: "Chercher une vue Gorgias",
4367
+ searchPlaceholder: "Taper une partie du nom de la vue\u2026",
4368
+ current: (name) => `Vue actuelle : ${name}`,
4369
+ none: "Aucune vue choisie.",
4370
+ noMatch: "Aucune vue ne correspond.",
4371
+ truncated: (total) => `${total} vues au total \u2014 affine la recherche pour voir les autres.`
4372
+ }
4373
+ }
4374
+ );
4375
+ }
4145
4376
  var WHATSAPP_MODE_LABELS = {
4146
4377
  escalate_only: "Escalade uniquement",
4147
4378
  draft_only: "Brouillon uniquement",
@@ -4290,21 +4521,12 @@ function SettingsPage() {
4290
4521
  ] }),
4291
4522
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4292
4523
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "sourceViewId", className: "mb-1 block text-sm font-medium", children: "Vue Gorgias source" }),
4293
- views.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
4294
- uiSdk.Select,
4295
- {
4296
- "aria-label": "Vue Gorgias source",
4297
- value: sourceViewId || void 0,
4298
- onValueChange: (v) => set("sourceViewId", v),
4299
- items: views.map((v) => ({ value: v.id, label: v.name })),
4300
- disabled: !canWrite
4301
- }
4302
- ) : /* @__PURE__ */ jsxRuntime.jsx(
4303
- uiSdk.Input,
4524
+ /* @__PURE__ */ jsxRuntime.jsx(
4525
+ SourceViewField,
4304
4526
  {
4305
- id: "sourceViewId",
4527
+ views,
4306
4528
  value: sourceViewId,
4307
- onChange: (e) => set("sourceViewId", e.target.value),
4529
+ onChange: (v) => set("sourceViewId", v),
4308
4530
  disabled: !canWrite
4309
4531
  }
4310
4532
  )
@@ -4438,9 +4660,8 @@ function SettingsPage() {
4438
4660
  ["unknownTag", "Tag inconnu"],
4439
4661
  ["handledTag", "Tag trait\xE9"],
4440
4662
  ["escalationTag", "Tag d'escalade"],
4441
- ["needsHumanTag", "Tag besoin humain"],
4442
4663
  ["autoRepliedTag", "Tag r\xE9pondu automatiquement"],
4443
- ["needsReviewTag", "Tag \xE0 revoir"],
4664
+ ["needsReviewTag", "Tag \xE0 revoir avant envoi"],
4444
4665
  ["followupTag", "Tag suivi requis"]
4445
4666
  ].map(([key, label]) => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4446
4667
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: key, className: "mb-1 block text-sm font-medium", children: label }),
@@ -5665,6 +5886,1155 @@ function TestPage() {
5665
5886
  !canRun ? /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsx(TestControls, {})
5666
5887
  ] });
5667
5888
  }
5889
+ function readParam(name) {
5890
+ if (typeof window === "undefined") return null;
5891
+ return new URLSearchParams(window.location.search).get(name);
5892
+ }
5893
+ function useQueryParam(name) {
5894
+ const [value, setState] = react.useState(() => readParam(name));
5895
+ react.useEffect(() => {
5896
+ const sync = () => setState(readParam(name));
5897
+ sync();
5898
+ window.addEventListener("popstate", sync);
5899
+ return () => window.removeEventListener("popstate", sync);
5900
+ }, [name]);
5901
+ const setValue = react.useCallback(
5902
+ (next) => {
5903
+ const params = new URLSearchParams(window.location.search);
5904
+ if (next === null) params.delete(name);
5905
+ else params.set(name, next);
5906
+ const query = params.toString();
5907
+ window.history.pushState({}, "", `${window.location.pathname}${query ? `?${query}` : ""}`);
5908
+ setState(next);
5909
+ },
5910
+ [name]
5911
+ );
5912
+ return { value, setValue };
5913
+ }
5914
+ function ExperimentStatusBadge({ experiment }) {
5915
+ if (experiment.status === "done" && experiment.succeeded) {
5916
+ return /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: "success", children: "Termin\xE9" });
5917
+ }
5918
+ if (experiment.status === "done" && !experiment.succeeded) {
5919
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-0.5", children: [
5920
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: "warning", children: "Termin\xE9 partiellement" }),
5921
+ experiment.note && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-status-pending", children: experiment.note })
5922
+ ] });
5923
+ }
5924
+ if (experiment.status === "failed") {
5925
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-0.5", children: [
5926
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: "danger", children: "\xC9chec" }),
5927
+ experiment.error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-status-blocked", children: experiment.error })
5928
+ ] });
5929
+ }
5930
+ if (experiment.status === "running") return /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: "info", children: "En cours" });
5931
+ return /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: "outline", children: "En attente" });
5932
+ }
5933
+
5934
+ // src/ui/quality/quality-error.ts
5935
+ var QUALITY_ERROR_MESSAGES = {
5936
+ LANGFUSE_UNCONFIGURED: "Langfuse est injoignable ou mal configur\xE9 \u2014 r\xE9essayez plus tard.",
5937
+ DATASET_NOT_FOUND: "Ce dataset n'existe pas dans Langfuse \u2014 v\xE9rifiez son nom.",
5938
+ DATASET_STORE_REQUEST_REJECTED: "Langfuse a rejet\xE9 la requ\xEAte sur ce dataset (identifiants ou quota) \u2014 le nom du dataset n'est pas forc\xE9ment en cause.",
5939
+ PROMPT_VERSION_NOT_FOUND: "Cette version de prompt n'existe pas dans Langfuse.",
5940
+ PROMPT_VERSION_STORE_REQUEST_REJECTED: "Langfuse a rejet\xE9 la requ\xEAte sur ce prompt (identifiants ou quota) \u2014 le nom ou la version ne sont pas forc\xE9ment en cause.",
5941
+ EXPERIMENT_NOT_FOUND: "Une ou plusieurs exp\xE9riences s\xE9lectionn\xE9es sont introuvables.",
5942
+ INVALID_REVIEW_SELECTION: "S\xE9lection invalide pour cr\xE9er une revue.",
5943
+ REVIEW_NOT_FOUND: "Cette revue est introuvable.",
5944
+ UNKNOWN_RUN_NAME: "Ce run ne fait pas partie de la revue.",
5945
+ UNKNOWN_DATASET_ITEM: "Cet item ne fait pas partie de la revue.",
5946
+ RUN_RESULTS_MISSING: "Un des runs s\xE9lectionn\xE9s n'a pas de r\xE9sultats persist\xE9s.",
5947
+ PROMPT_NOT_FOUND: "Ce prompt est introuvable dans Langfuse.",
5948
+ PROMPT_STORE_REQUEST_REJECTED: "Langfuse a rejet\xE9 la promotion (identifiants ou quota).",
5949
+ PROMPT_STORE_UNAVAILABLE: "Langfuse est injoignable \u2014 r\xE9essayez plus tard."
5950
+ };
5951
+ function apiErrorBody(err) {
5952
+ return err?.response?.data;
5953
+ }
5954
+ function qualityErrorMessage(err) {
5955
+ const body = apiErrorBody(err);
5956
+ if (body?.code && body.code in QUALITY_ERROR_MESSAGES) {
5957
+ return QUALITY_ERROR_MESSAGES[body.code];
5958
+ }
5959
+ return body?.message ?? "Une erreur inattendue est survenue.";
5960
+ }
5961
+ function isSelectable(experiment) {
5962
+ return experiment.status === "done";
5963
+ }
5964
+ function ExperimentsTable({
5965
+ experiments,
5966
+ isPending,
5967
+ isError,
5968
+ error,
5969
+ canSelect,
5970
+ selectedIds,
5971
+ /** Once true, every checkbox NOT already selected is disabled — the 2-3 cap must reject a 4th pick visibly, not silently no-op it. */
5972
+ atSelectionCap,
5973
+ onToggleSelect
5974
+ }) {
5975
+ if (isPending) return /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Chargement\u2026" });
5976
+ if (isError) return /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive", children: qualityErrorMessage(error) });
5977
+ if (experiments.length === 0) {
5978
+ return /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Aucune exp\xE9rience pour ce dataset." });
5979
+ }
5980
+ return /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Table, { children: [
5981
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.TableHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.TableRow, { children: [
5982
+ canSelect && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.TableHead, {}),
5983
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.TableHead, { children: "Nom" }),
5984
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.TableHead, { children: "Prompt" }),
5985
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.TableHead, { children: "Statut" }),
5986
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.TableHead, { children: "Progression" })
5987
+ ] }) }),
5988
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.TableBody, { children: experiments.map((experiment) => /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.TableRow, { children: [
5989
+ canSelect && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.TableCell, { children: /* @__PURE__ */ jsxRuntime.jsx(
5990
+ uiSdk.Checkbox,
5991
+ {
5992
+ "aria-label": `S\xE9lectionner ${experiment.name}`,
5993
+ checked: selectedIds.includes(experiment.id),
5994
+ disabled: !isSelectable(experiment) || atSelectionCap && !selectedIds.includes(experiment.id),
5995
+ onCheckedChange: () => onToggleSelect(experiment.id)
5996
+ }
5997
+ ) }),
5998
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.TableCell, { children: experiment.name }),
5999
+ /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.TableCell, { children: [
6000
+ experiment.promptName,
6001
+ " v",
6002
+ experiment.promptVersion
6003
+ ] }),
6004
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.TableCell, { children: /* @__PURE__ */ jsxRuntime.jsx(ExperimentStatusBadge, { experiment }) }),
6005
+ /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.TableCell, { children: [
6006
+ experiment.progress.done,
6007
+ "/",
6008
+ experiment.progress.total
6009
+ ] })
6010
+ ] }, experiment.id)) })
6011
+ ] });
6012
+ }
6013
+ function useAsyncData(load, fallback) {
6014
+ const [data, setData] = react.useState(fallback);
6015
+ const [isLoading, setIsLoading] = react.useState(true);
6016
+ const [error, setError] = react.useState(void 0);
6017
+ const requestIdRef = react.useRef(0);
6018
+ const isMountedRef = react.useRef(true);
6019
+ const run = react.useCallback(async () => {
6020
+ const requestId = ++requestIdRef.current;
6021
+ const isCurrent = () => requestId === requestIdRef.current && isMountedRef.current;
6022
+ setIsLoading(true);
6023
+ try {
6024
+ const result = await load();
6025
+ if (!isCurrent()) return;
6026
+ setData(result);
6027
+ setError(void 0);
6028
+ } catch (err) {
6029
+ if (!isCurrent()) return;
6030
+ setError(err);
6031
+ } finally {
6032
+ if (requestId === requestIdRef.current) setIsLoading(false);
6033
+ }
6034
+ }, [load]);
6035
+ react.useEffect(() => {
6036
+ isMountedRef.current = true;
6037
+ void run();
6038
+ return () => {
6039
+ isMountedRef.current = false;
6040
+ requestIdRef.current += 1;
6041
+ };
6042
+ }, [run]);
6043
+ return { data, isLoading, error, refresh: run };
6044
+ }
6045
+ function useDatasetCatalogue() {
6046
+ const { appSlug } = uiSdk.useAppContext();
6047
+ const api = uiSdk.useAppApi();
6048
+ const apiRef = react.useRef(api);
6049
+ apiRef.current = api;
6050
+ const load = react.useCallback(
6051
+ () => apiRef.current.get(`/data/apps/${appSlug}/langfuse/datasets`),
6052
+ [appSlug]
6053
+ );
6054
+ return useAsyncData(load, []);
6055
+ }
6056
+ function useExperiments(datasetName) {
6057
+ const { appSlug } = uiSdk.useAppContext();
6058
+ const api = uiSdk.useAppApi();
6059
+ const apiRef = react.useRef(api);
6060
+ apiRef.current = api;
6061
+ const trimmed = datasetName.trim();
6062
+ const load = react.useCallback(async () => {
6063
+ if (trimmed.length === 0) return [];
6064
+ const params = new URLSearchParams({ datasetName: trimmed });
6065
+ return apiRef.current.get(
6066
+ `/data/apps/${appSlug}/quality/experiments?${params.toString()}`
6067
+ );
6068
+ }, [appSlug, trimmed]);
6069
+ return useAsyncData(load, []);
6070
+ }
6071
+ function useReview(reviewId) {
6072
+ const { appSlug } = uiSdk.useAppContext();
6073
+ const api = uiSdk.useAppApi();
6074
+ const apiRef = react.useRef(api);
6075
+ apiRef.current = api;
6076
+ const load = react.useCallback(async () => {
6077
+ if (!reviewId) return null;
6078
+ return apiRef.current.get(`/data/apps/${appSlug}/quality/reviews/${reviewId}`);
6079
+ }, [appSlug, reviewId]);
6080
+ return useAsyncData(load, null);
6081
+ }
6082
+ function useQualityActions() {
6083
+ const { appSlug } = uiSdk.useAppContext();
6084
+ const api = uiSdk.useAppApi();
6085
+ const apiRef = react.useRef(api);
6086
+ apiRef.current = api;
6087
+ return react.useMemo(() => {
6088
+ const base2 = `/data/apps/${appSlug}/quality`;
6089
+ return {
6090
+ launchExperiment: (input) => apiRef.current.post(`${base2}/experiments`, input),
6091
+ createReview: (input) => apiRef.current.post(`${base2}/reviews`, input),
6092
+ putItemReview: (reviewId, datasetItemId, patch) => apiRef.current.put(
6093
+ `${base2}/reviews/${reviewId}/items/${datasetItemId}`,
6094
+ patch
6095
+ ),
6096
+ generateSummary: (reviewId) => apiRef.current.post(`${base2}/reviews/${reviewId}/summary`),
6097
+ exportReview: (reviewId) => apiRef.current.get(`${base2}/reviews/${reviewId}/export`),
6098
+ /** Which version currently holds `label` — `{ version: null }` when none does, which is not an error. */
6099
+ promptLabelVersion: (name, label) => {
6100
+ const params = new URLSearchParams({ name, label });
6101
+ return apiRef.current.get(
6102
+ `${base2}/prompts/label?${params.toString()}`
6103
+ );
6104
+ },
6105
+ /**
6106
+ * Promotion goes through the PROMPTS primitive, not the quality one:
6107
+ * `/quality/prompts/promote` was a second door onto the same
6108
+ * company-wide write and was removed with the platform section.
6109
+ */
6110
+ promotePrompt: (name, version, label) => apiRef.current.post(`/data/apps/${appSlug}/prompts/promote`, {
6111
+ name,
6112
+ version,
6113
+ label
6114
+ })
6115
+ };
6116
+ }, [appSlug]);
6117
+ }
6118
+ function parsePositiveInteger(value) {
6119
+ const n = Number(value);
6120
+ return Number.isInteger(n) && n > 0 ? n : null;
6121
+ }
6122
+ function LaunchExperimentForm({
6123
+ datasetName,
6124
+ initialPromptName,
6125
+ initialPromptVersion,
6126
+ initialAgentId,
6127
+ onLaunched
6128
+ }) {
6129
+ const toast = uiSdk.useToast();
6130
+ const actions = useQualityActions();
6131
+ const [isLaunching, setIsLaunching] = react.useState(false);
6132
+ const [name, setName] = react.useState("");
6133
+ const [agentId, setAgentId] = react.useState(initialAgentId ?? "");
6134
+ const [promptName, setPromptName] = react.useState(initialPromptName ?? "");
6135
+ const initialPromptVersionParsed = initialPromptVersion ? parsePositiveInteger(initialPromptVersion) : null;
6136
+ const [promptVersion, setPromptVersion] = react.useState(
6137
+ initialPromptVersionParsed !== null ? String(initialPromptVersionParsed) : ""
6138
+ );
6139
+ const parsedPromptVersion = parsePositiveInteger(promptVersion);
6140
+ const canSubmit = datasetName.trim().length > 0 && name.trim().length > 0 && agentId.trim().length > 0 && promptName.trim().length > 0 && parsedPromptVersion !== null;
6141
+ const onSubmit = async (event) => {
6142
+ event.preventDefault();
6143
+ if (!canSubmit || parsedPromptVersion === null) return;
6144
+ setIsLaunching(true);
6145
+ try {
6146
+ const experiment = await actions.launchExperiment({
6147
+ datasetName: datasetName.trim(),
6148
+ name: name.trim(),
6149
+ agentId: agentId.trim(),
6150
+ promptName: promptName.trim(),
6151
+ promptVersion: parsedPromptVersion
6152
+ });
6153
+ toast({ title: "Exp\xE9rience lanc\xE9e", description: experiment.name });
6154
+ setName("");
6155
+ onLaunched(experiment);
6156
+ } catch (err) {
6157
+ toast({
6158
+ title: "Lancement impossible",
6159
+ description: qualityErrorMessage(err),
6160
+ variant: "error"
6161
+ });
6162
+ } finally {
6163
+ setIsLaunching(false);
6164
+ }
6165
+ };
6166
+ return /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Card, { children: [
6167
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardTitle, { children: "Lancer une exp\xE9rience" }) }),
6168
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardContent, { children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: (e) => void onSubmit(e), className: "grid gap-3 sm:grid-cols-2", children: [
6169
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-muted-foreground sm:col-span-2", children: [
6170
+ "Dataset : ",
6171
+ /* @__PURE__ */ jsxRuntime.jsx("code", { className: "font-mono", children: datasetName.trim() || "\u2014" })
6172
+ ] }),
6173
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
6174
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "quality-launch-name", className: "block text-sm font-medium", children: "Nom" }),
6175
+ /* @__PURE__ */ jsxRuntime.jsx(
6176
+ uiSdk.Input,
6177
+ {
6178
+ id: "quality-launch-name",
6179
+ value: name,
6180
+ onChange: (e) => setName(e.target.value),
6181
+ placeholder: "ex. triage v3 vs v4"
6182
+ }
6183
+ )
6184
+ ] }),
6185
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
6186
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "quality-launch-agent", className: "block text-sm font-medium", children: "Identifiant de l'agent" }),
6187
+ /* @__PURE__ */ jsxRuntime.jsx(
6188
+ uiSdk.Input,
6189
+ {
6190
+ id: "quality-launch-agent",
6191
+ value: agentId,
6192
+ onChange: (e) => setAgentId(e.target.value),
6193
+ "aria-describedby": "quality-launch-agent-help",
6194
+ placeholder: "ex. 7f3c1a2e-\u2026"
6195
+ }
6196
+ ),
6197
+ /* @__PURE__ */ jsxRuntime.jsx("p", { id: "quality-launch-agent-help", className: "text-xs text-muted-foreground", children: "Visible sur la page Agents de l'app \u2014 le lien \xAB Qualit\xE9 \xBB de cette page le pr\xE9-remplit." })
6198
+ ] }),
6199
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
6200
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "quality-launch-prompt", className: "block text-sm font-medium", children: "Prompt" }),
6201
+ /* @__PURE__ */ jsxRuntime.jsx(
6202
+ uiSdk.Input,
6203
+ {
6204
+ id: "quality-launch-prompt",
6205
+ value: promptName,
6206
+ onChange: (e) => setPromptName(e.target.value),
6207
+ placeholder: "ex. triage"
6208
+ }
6209
+ )
6210
+ ] }),
6211
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
6212
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "quality-launch-version", className: "block text-sm font-medium", children: "Version" }),
6213
+ /* @__PURE__ */ jsxRuntime.jsx(
6214
+ uiSdk.Input,
6215
+ {
6216
+ id: "quality-launch-version",
6217
+ type: "number",
6218
+ min: 1,
6219
+ value: promptVersion,
6220
+ onChange: (e) => setPromptVersion(e.target.value)
6221
+ }
6222
+ )
6223
+ ] }),
6224
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sm:col-span-2", children: /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { type: "submit", disabled: !canSubmit || isLaunching, children: isLaunching ? "Lancement\u2026" : "Lancer" }) })
6225
+ ] }) })
6226
+ ] });
6227
+ }
6228
+ var MAX_REVIEW_EXPERIMENTS = 3;
6229
+ function toggleSelection(selected, id) {
6230
+ if (selected.includes(id)) return selected.filter((existing) => existing !== id);
6231
+ if (selected.length >= MAX_REVIEW_EXPERIMENTS) return selected;
6232
+ return [...selected, id];
6233
+ }
6234
+ function ExperimentsView({
6235
+ canEdit,
6236
+ onReviewCreated
6237
+ }) {
6238
+ const toast = uiSdk.useToast();
6239
+ const actions = useQualityActions();
6240
+ const promptName = useQueryParam("promptName").value;
6241
+ const promptVersion = useQueryParam("promptVersion").value;
6242
+ const agentId = useQueryParam("agentId").value;
6243
+ const [datasetName, setDatasetName] = react.useState("");
6244
+ const [selectedIds, setSelectedIds] = react.useState([]);
6245
+ const [reviewName, setReviewName] = react.useState("");
6246
+ const [isCreating, setIsCreating] = react.useState(false);
6247
+ const datasets = useDatasetCatalogue();
6248
+ const experiments = useExperiments(datasetName);
6249
+ const canCreateReview = canEdit && selectedIds.length >= 2 && selectedIds.length <= MAX_REVIEW_EXPERIMENTS && reviewName.trim().length > 0;
6250
+ const onCreateReview = async () => {
6251
+ setIsCreating(true);
6252
+ try {
6253
+ const review = await actions.createReview({
6254
+ name: reviewName.trim(),
6255
+ experimentIds: selectedIds
6256
+ });
6257
+ onReviewCreated(review.id);
6258
+ } catch (err) {
6259
+ toast({
6260
+ title: "Cr\xE9ation de la revue impossible",
6261
+ description: qualityErrorMessage(err),
6262
+ variant: "error"
6263
+ });
6264
+ } finally {
6265
+ setIsCreating(false);
6266
+ }
6267
+ };
6268
+ return /* @__PURE__ */ jsxRuntime.jsxs(PageShell, { children: [
6269
+ /* @__PURE__ */ jsxRuntime.jsx(PageHeader, { title: "Qualit\xE9" }),
6270
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "max-w-md space-y-1.5", children: [
6271
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "quality-dataset", className: "block text-sm font-medium", children: "Dataset" }),
6272
+ /* @__PURE__ */ jsxRuntime.jsx(
6273
+ SearchableSelect,
6274
+ {
6275
+ id: "quality-dataset",
6276
+ options: datasets.data.map((dataset) => ({
6277
+ value: dataset.name,
6278
+ label: dataset.name,
6279
+ keywords: dataset.description ?? ""
6280
+ })),
6281
+ value: datasetName,
6282
+ onChange: (next) => {
6283
+ setDatasetName(next);
6284
+ setSelectedIds([]);
6285
+ },
6286
+ disabled: datasets.isLoading,
6287
+ labels: {
6288
+ fallbackAriaLabel: "Dataset",
6289
+ searchAriaLabel: "Chercher un dataset",
6290
+ searchPlaceholder: "Taper une partie du nom du dataset\u2026",
6291
+ current: (name) => `Dataset actuel : ${name}`,
6292
+ none: "Aucun dataset choisi.",
6293
+ noMatch: "Aucun dataset ne correspond.",
6294
+ truncated: (total) => `${total} datasets au total \u2014 affine la recherche pour voir les autres.`
6295
+ }
6296
+ }
6297
+ ),
6298
+ datasets.error !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: "Catalogue Langfuse indisponible \u2014 saisissez le nom du dataset \xE0 la main." })
6299
+ ] }),
6300
+ canEdit && /* @__PURE__ */ jsxRuntime.jsx(
6301
+ LaunchExperimentForm,
6302
+ {
6303
+ datasetName,
6304
+ initialPromptName: promptName ?? void 0,
6305
+ initialPromptVersion: promptVersion ?? void 0,
6306
+ initialAgentId: agentId ?? void 0,
6307
+ onLaunched: () => void experiments.refresh()
6308
+ }
6309
+ ),
6310
+ /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Card, { children: [
6311
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardTitle, { children: "Runs" }) }),
6312
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardContent, { className: "space-y-4", children: datasetName.trim().length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Choisissez un dataset pour voir ses runs." }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6313
+ canEdit && experiments.data.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: "S\xE9lectionnez 2 \xE0 3 runs termin\xE9s pour cr\xE9er une revue." }),
6314
+ /* @__PURE__ */ jsxRuntime.jsx(
6315
+ ExperimentsTable,
6316
+ {
6317
+ experiments: experiments.data,
6318
+ isPending: experiments.isLoading,
6319
+ isError: experiments.error !== void 0,
6320
+ error: experiments.error,
6321
+ canSelect: canEdit,
6322
+ selectedIds,
6323
+ atSelectionCap: selectedIds.length >= MAX_REVIEW_EXPERIMENTS,
6324
+ onToggleSelect: (id) => setSelectedIds((prev) => toggleSelection(prev, id))
6325
+ }
6326
+ ),
6327
+ canEdit && experiments.data.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-end gap-2", children: [
6328
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
6329
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "quality-review-name", className: "block text-sm font-medium", children: "Nom de la revue" }),
6330
+ /* @__PURE__ */ jsxRuntime.jsx(
6331
+ uiSdk.Input,
6332
+ {
6333
+ id: "quality-review-name",
6334
+ value: reviewName,
6335
+ onChange: (e) => setReviewName(e.target.value),
6336
+ placeholder: "ex. triage v3 vs v4"
6337
+ }
6338
+ )
6339
+ ] }),
6340
+ /* @__PURE__ */ jsxRuntime.jsx(
6341
+ uiSdk.Button,
6342
+ {
6343
+ disabled: !canCreateReview || isCreating,
6344
+ onClick: () => void onCreateReview(),
6345
+ children: isCreating ? "Cr\xE9ation\u2026" : "Cr\xE9er la revue"
6346
+ }
6347
+ )
6348
+ ] })
6349
+ ] }) })
6350
+ ] })
6351
+ ] });
6352
+ }
6353
+
6354
+ // src/ui/quality/quality-role.ts
6355
+ function canEditQuality(platformRole) {
6356
+ return platformRole === "EDITOR" || platformRole === "ADMIN";
6357
+ }
6358
+ function ExportReviewButton({ reviewId }) {
6359
+ const toast = uiSdk.useToast();
6360
+ const actions = useQualityActions();
6361
+ const [busy, setBusy] = react.useState(false);
6362
+ const onExport = async () => {
6363
+ setBusy(true);
6364
+ try {
6365
+ const payload = await actions.exportReview(reviewId);
6366
+ uiSdk.downloadBlob(
6367
+ new Blob([JSON.stringify(payload, null, 2)], { type: "application/json" }),
6368
+ `revue-${reviewId}.json`
6369
+ );
6370
+ } catch (err) {
6371
+ toast({
6372
+ title: "Export impossible",
6373
+ description: qualityErrorMessage(err),
6374
+ variant: "error"
6375
+ });
6376
+ } finally {
6377
+ setBusy(false);
6378
+ }
6379
+ };
6380
+ return /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", size: "sm", onClick: onExport, disabled: busy, children: busy ? "Export\u2026" : "Exporter" });
6381
+ }
6382
+
6383
+ // src/ui/quality/quality-format.ts
6384
+ function formatScore(value) {
6385
+ return value.toFixed(2);
6386
+ }
6387
+ var CHART_COLOR_CLASSES = [
6388
+ { stroke: "stroke-chart-1", fill: "fill-chart-1" },
6389
+ { stroke: "stroke-chart-2", fill: "fill-chart-2" },
6390
+ { stroke: "stroke-chart-3", fill: "fill-chart-3" },
6391
+ { stroke: "stroke-chart-4", fill: "fill-chart-4" },
6392
+ { stroke: "stroke-chart-5", fill: "fill-chart-5" }
6393
+ ];
6394
+ function colorClassesAt(index) {
6395
+ return CHART_COLOR_CLASSES[index % CHART_COLOR_CLASSES.length];
6396
+ }
6397
+ function axisPoint(index, count, radius, cx, cy) {
6398
+ const angle = -Math.PI / 2 + index * 2 * Math.PI / count;
6399
+ return { x: cx + radius * Math.cos(angle), y: cy + radius * Math.sin(angle) };
6400
+ }
6401
+ function polygonPoints(values, maxValue, radius, cx, cy) {
6402
+ return values.map((value, index) => {
6403
+ const clamped = Math.max(0, Math.min(value / maxValue, 1));
6404
+ const point = axisPoint(index, values.length, radius * clamped, cx, cy);
6405
+ return `${point.x},${point.y}`;
6406
+ }).join(" ");
6407
+ }
6408
+ function seriesPoints(values, maxValue, radius, cx, cy) {
6409
+ return values.map((value, index) => {
6410
+ if (value === null) return null;
6411
+ const clamped = Math.max(0, Math.min(value / maxValue, 1));
6412
+ return axisPoint(index, values.length, radius * clamped, cx, cy);
6413
+ });
6414
+ }
6415
+ function seriesPathD(points) {
6416
+ const n = points.length;
6417
+ if (n === 0) return "";
6418
+ const commands = [];
6419
+ let drawing = false;
6420
+ for (let i = 0; i <= n; i++) {
6421
+ const point = points[i % n];
6422
+ if (!point) {
6423
+ drawing = false;
6424
+ continue;
6425
+ }
6426
+ commands.push(`${drawing ? "L" : "M"}${point.x},${point.y}`);
6427
+ drawing = true;
6428
+ }
6429
+ return commands.join(" ");
6430
+ }
6431
+ var GRID_RINGS = [0.25, 0.5, 0.75, 1];
6432
+ function ScoreRadarChart({
6433
+ axes,
6434
+ series,
6435
+ maxValue = 1,
6436
+ size = 260,
6437
+ className
6438
+ }) {
6439
+ const cx = size / 2;
6440
+ const cy = size / 2;
6441
+ const radius = size / 2 - 32;
6442
+ const label = series.map((s) => s.label).join(", ") || "Aucun run s\xE9lectionn\xE9";
6443
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: uiSdk.cn("w-full max-w-80", className), children: [
6444
+ /* @__PURE__ */ jsxRuntime.jsxs(
6445
+ "svg",
6446
+ {
6447
+ role: "img",
6448
+ "aria-label": `Radar de scores \u2014 ${label}`,
6449
+ viewBox: `0 0 ${size} ${size}`,
6450
+ className: "w-full",
6451
+ children: [
6452
+ axes.length > 0 && GRID_RINGS.map((ring) => /* @__PURE__ */ jsxRuntime.jsx(
6453
+ "polygon",
6454
+ {
6455
+ points: polygonPoints(
6456
+ axes.map(() => maxValue),
6457
+ maxValue * ring,
6458
+ radius,
6459
+ cx,
6460
+ cy
6461
+ ),
6462
+ className: "fill-none stroke-border",
6463
+ strokeWidth: 1
6464
+ },
6465
+ ring
6466
+ )),
6467
+ axes.map((axis, index) => {
6468
+ const tip = axisPoint(index, axes.length, radius, cx, cy);
6469
+ const labelPoint = axisPoint(index, axes.length, radius + 18, cx, cy);
6470
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
6471
+ /* @__PURE__ */ jsxRuntime.jsx(
6472
+ "line",
6473
+ {
6474
+ x1: cx,
6475
+ y1: cy,
6476
+ x2: tip.x,
6477
+ y2: tip.y,
6478
+ className: "stroke-border",
6479
+ strokeWidth: 1
6480
+ }
6481
+ ),
6482
+ /* @__PURE__ */ jsxRuntime.jsx(
6483
+ "text",
6484
+ {
6485
+ x: labelPoint.x,
6486
+ y: labelPoint.y,
6487
+ textAnchor: "middle",
6488
+ dominantBaseline: "middle",
6489
+ className: "fill-muted-foreground text-[9px]",
6490
+ children: axis
6491
+ }
6492
+ )
6493
+ ] }, axis);
6494
+ }),
6495
+ series.map((entry) => {
6496
+ const colors = colorClassesAt(entry.colorIndex);
6497
+ const isComplete = entry.values.every((value) => value !== null);
6498
+ const points = seriesPoints(entry.values, maxValue, radius, cx, cy);
6499
+ return /* @__PURE__ */ jsxRuntime.jsx(
6500
+ "path",
6501
+ {
6502
+ "data-series": entry.key,
6503
+ d: seriesPathD(points),
6504
+ className: uiSdk.cn(
6505
+ colors.stroke,
6506
+ isComplete ? uiSdk.cn(colors.fill, "fill-opacity-15") : "fill-none"
6507
+ ),
6508
+ strokeWidth: 2
6509
+ },
6510
+ entry.key
6511
+ );
6512
+ })
6513
+ ]
6514
+ }
6515
+ ),
6516
+ series.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "mt-2 flex flex-wrap gap-x-4 gap-y-1", children: series.map((entry) => {
6517
+ const colors = colorClassesAt(entry.colorIndex);
6518
+ return /* @__PURE__ */ jsxRuntime.jsxs(
6519
+ "li",
6520
+ {
6521
+ className: "flex items-center gap-1.5 text-xs text-muted-foreground",
6522
+ children: [
6523
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": true, className: uiSdk.cn("size-2.5 rounded-sm", colors.fill) }),
6524
+ entry.label
6525
+ ]
6526
+ },
6527
+ entry.key
6528
+ );
6529
+ }) })
6530
+ ] });
6531
+ }
6532
+ function formatScoreWithDenominator(value, scoredCount, itemCount) {
6533
+ return `${formatScore(value)} (${scoredCount}/${itemCount})`;
6534
+ }
6535
+ function coverageLabel(run) {
6536
+ const worstCoverage = run.scores.length > 0 ? Math.min(...run.scores.map((s) => s.scoredCount)) : 0;
6537
+ return `${run.label} (${worstCoverage}/${run.itemCount})`;
6538
+ }
6539
+ function collectCriteria(histogram) {
6540
+ const seen = /* @__PURE__ */ new Set();
6541
+ for (const run of histogram) {
6542
+ for (const score of run.scores) seen.add(score.criterion);
6543
+ }
6544
+ return [...seen];
6545
+ }
6546
+ function toRadarSeries(histogram, axes) {
6547
+ return histogram.map((run, index) => ({
6548
+ key: run.runName,
6549
+ label: coverageLabel(run),
6550
+ colorIndex: index,
6551
+ values: axes.map((axis) => run.scores.find((score) => score.criterion === axis)?.value ?? null)
6552
+ }));
6553
+ }
6554
+ function ReviewHistogram({
6555
+ histogram,
6556
+ runs
6557
+ }) {
6558
+ if (histogram.length === 0) {
6559
+ return /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Pas encore de scores." });
6560
+ }
6561
+ const axes = collectCriteria(histogram);
6562
+ const succeededByRunName = new Map(runs.map((run) => [run.runName, run.succeeded]));
6563
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
6564
+ /* @__PURE__ */ jsxRuntime.jsx(ScoreRadarChart, { axes, series: toRadarSeries(histogram, axes) }),
6565
+ /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "w-full text-sm", children: [
6566
+ /* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: "text-xs text-muted-foreground", children: [
6567
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "py-1 pr-2 text-left font-medium", children: "Crit\xE8re" }),
6568
+ histogram.map((run) => /* @__PURE__ */ jsxRuntime.jsxs("th", { className: "px-2 py-1 text-left font-medium", children: [
6569
+ run.label,
6570
+ succeededByRunName.get(run.runName) === false && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-0.5 font-normal", children: /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: "warning", children: "Termin\xE9 partiellement" }) })
6571
+ ] }, run.runName))
6572
+ ] }) }),
6573
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: axes.map((axis) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: "border-t", children: [
6574
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "py-1.5 pr-2 font-mono text-xs text-muted-foreground", children: axis }),
6575
+ histogram.map((run) => {
6576
+ const score = run.scores.find((s) => s.criterion === axis);
6577
+ return /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-2 py-1.5 tabular-nums", children: score ? formatScoreWithDenominator(score.value, score.scoredCount, run.itemCount) : "\u2014" }, run.runName);
6578
+ })
6579
+ ] }, axis)) })
6580
+ ] })
6581
+ ] });
6582
+ }
6583
+ function ItemListEntry({
6584
+ item,
6585
+ isSelected,
6586
+ onSelect
6587
+ }) {
6588
+ return /* @__PURE__ */ jsxRuntime.jsxs(
6589
+ "button",
6590
+ {
6591
+ type: "button",
6592
+ onClick: onSelect,
6593
+ className: uiSdk.cn(
6594
+ "flex w-full items-center justify-between gap-2 rounded-md px-3 py-1.5 text-left text-sm",
6595
+ isSelected ? "bg-muted font-medium text-foreground" : "text-muted-foreground hover:bg-muted/60"
6596
+ ),
6597
+ children: [
6598
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate font-mono text-xs", children: item.datasetItemId }),
6599
+ item.review.bestRunName && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: "brand", children: item.review.bestRunName })
6600
+ ]
6601
+ }
6602
+ );
6603
+ }
6604
+ function OutputCard({
6605
+ output,
6606
+ isBest,
6607
+ canEdit,
6608
+ onPickBest
6609
+ }) {
6610
+ return /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Card, { children: [
6611
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardTitle, { className: "text-sm", children: output.label }) }),
6612
+ /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.CardContent, { className: "space-y-2", children: [
6613
+ output.hasResult ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6614
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "whitespace-pre-wrap text-sm", children: output.output ?? "\u2014" }),
6615
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-1.5", children: output.scores.map((score) => /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Badge, { variant: "outline", children: [
6616
+ score.criterion,
6617
+ ": ",
6618
+ formatScore(score.value)
6619
+ ] }, score.criterion)) })
6620
+ ] }) : (
6621
+ // D1 — a run that crashed on this item or never saw it (dataset
6622
+ // grew after this run launched) must never read as "this run
6623
+ // answered with nothing", which is a model-quality signal. It also
6624
+ // must never be offered as the best answer: the best-run
6625
+ // distribution feeding the synthesis would then be polled on a run
6626
+ // that produced no output at all.
6627
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm italic text-muted-foreground", children: "Aucun r\xE9sultat pour ce run." })
6628
+ ),
6629
+ canEdit && output.hasResult && /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Button, { size: "sm", variant: isBest ? "default" : "outline", onClick: onPickBest, children: [
6630
+ "Meilleure r\xE9ponse \u2014 ",
6631
+ output.label
6632
+ ] })
6633
+ ] })
6634
+ ] });
6635
+ }
6636
+ function ItemDetail({
6637
+ reviewId,
6638
+ item,
6639
+ canEdit,
6640
+ onSaved
6641
+ }) {
6642
+ const toast = uiSdk.useToast();
6643
+ const actions = useQualityActions();
6644
+ const [isSaving, setIsSaving] = react.useState(false);
6645
+ const [bestRunName, setBestRunName] = react.useState(item.review.bestRunName);
6646
+ const [comment, setComment] = react.useState(item.review.comment);
6647
+ react.useEffect(() => {
6648
+ setBestRunName(item.review.bestRunName);
6649
+ setComment(item.review.comment);
6650
+ }, [item.datasetItemId, item.review.bestRunName, item.review.comment]);
6651
+ const onSave = async () => {
6652
+ setIsSaving(true);
6653
+ try {
6654
+ const saved = await actions.putItemReview(reviewId, item.datasetItemId, {
6655
+ bestRunName,
6656
+ comment
6657
+ });
6658
+ onSaved(item.datasetItemId, saved);
6659
+ toast({ title: "Revue enregistr\xE9e" });
6660
+ } catch (err) {
6661
+ toast({
6662
+ title: "Enregistrement impossible",
6663
+ description: qualityErrorMessage(err),
6664
+ variant: "error"
6665
+ });
6666
+ } finally {
6667
+ setIsSaving(false);
6668
+ }
6669
+ };
6670
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
6671
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid gap-3 sm:grid-cols-2", children: item.outputs.map((output) => /* @__PURE__ */ jsxRuntime.jsx(
6672
+ OutputCard,
6673
+ {
6674
+ output,
6675
+ isBest: bestRunName === output.runName,
6676
+ canEdit,
6677
+ onPickBest: () => setBestRunName(output.runName)
6678
+ },
6679
+ output.runName
6680
+ )) }),
6681
+ item.review.judgeVerdicts.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-1.5", children: item.review.judgeVerdicts.map((verdict) => /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Badge, { variant: "outline", children: [
6682
+ verdict.runName,
6683
+ " : ",
6684
+ verdict.verdict
6685
+ ] }, verdict.runName)) }),
6686
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
6687
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "quality-item-comment", className: "block text-sm font-medium", children: "Commentaire" }),
6688
+ /* @__PURE__ */ jsxRuntime.jsx(
6689
+ uiSdk.Textarea,
6690
+ {
6691
+ id: "quality-item-comment",
6692
+ value: comment,
6693
+ disabled: !canEdit,
6694
+ onChange: (e) => setComment(e.target.value)
6695
+ }
6696
+ )
6697
+ ] }),
6698
+ canEdit && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { onClick: () => void onSave(), disabled: isSaving, children: isSaving ? "Enregistrement\u2026" : "Enregistrer" })
6699
+ ] });
6700
+ }
6701
+ function ReviewItemsPanel({
6702
+ reviewId,
6703
+ items,
6704
+ canEdit,
6705
+ onItemSaved
6706
+ }) {
6707
+ const [selectedId, setSelectedId] = react.useState(items[0]?.datasetItemId);
6708
+ const selected = items.find((item) => item.datasetItemId === selectedId) ?? items[0];
6709
+ if (items.length === 0) {
6710
+ return /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Aucun item \xE0 revoir." });
6711
+ }
6712
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-4 md:grid-cols-[220px_1fr]", children: [
6713
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-0.5", children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
6714
+ ItemListEntry,
6715
+ {
6716
+ item,
6717
+ isSelected: item.datasetItemId === selected?.datasetItemId,
6718
+ onSelect: () => setSelectedId(item.datasetItemId)
6719
+ },
6720
+ item.datasetItemId
6721
+ )) }),
6722
+ selected && /* @__PURE__ */ jsxRuntime.jsx(ItemDetail, { reviewId, item: selected, canEdit, onSaved: onItemSaved })
6723
+ ] });
6724
+ }
6725
+ function useCurrentLabelHolder(promptName, label) {
6726
+ const actions = useQualityActions();
6727
+ const [version, setVersion] = react.useState(null);
6728
+ const [isLoading, setIsLoading] = react.useState(false);
6729
+ react.useEffect(() => {
6730
+ if (!label) {
6731
+ setVersion(null);
6732
+ return;
6733
+ }
6734
+ let cancelled = false;
6735
+ setIsLoading(true);
6736
+ actions.promptLabelVersion(promptName, label).then((result) => {
6737
+ if (!cancelled) setVersion(result.version);
6738
+ }).catch(() => {
6739
+ if (!cancelled) setVersion(null);
6740
+ }).finally(() => {
6741
+ if (!cancelled) setIsLoading(false);
6742
+ });
6743
+ return () => {
6744
+ cancelled = true;
6745
+ };
6746
+ }, [actions, promptName, label]);
6747
+ return { version, isLoading };
6748
+ }
6749
+ var KNOWN_PROMPT_LABELS = ["production", "staging"];
6750
+ var CUSTOM_LABEL_OPTION = "__custom__";
6751
+ function PromoteRunDialog({
6752
+ run,
6753
+ open,
6754
+ onClose
6755
+ }) {
6756
+ const toast = uiSdk.useToast();
6757
+ const actions = useQualityActions();
6758
+ const [selectedOption, setSelectedOption] = react.useState(KNOWN_PROMPT_LABELS[0]);
6759
+ const [customLabel, setCustomLabel] = react.useState("");
6760
+ const [isPromoting, setIsPromoting] = react.useState(false);
6761
+ const label = selectedOption === CUSTOM_LABEL_OPTION ? customLabel.trim() : selectedOption;
6762
+ const currentHolder = useCurrentLabelHolder(run.promptName, label);
6763
+ const onConfirm = async () => {
6764
+ if (!label) return;
6765
+ setIsPromoting(true);
6766
+ try {
6767
+ await actions.promotePrompt(run.promptName, run.promptVersion, label);
6768
+ toast({
6769
+ title: "Version promue",
6770
+ description: `${run.promptName} v${run.promptVersion} \u2192 ${label}`
6771
+ });
6772
+ onClose();
6773
+ } catch (err) {
6774
+ toast({
6775
+ title: "Promotion impossible",
6776
+ description: qualityErrorMessage(err),
6777
+ variant: "error"
6778
+ });
6779
+ } finally {
6780
+ setIsPromoting(false);
6781
+ }
6782
+ };
6783
+ return /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Modal, { open, onClose, title: `Promouvoir ${run.label}`, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
6784
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-muted-foreground", children: [
6785
+ run.promptName,
6786
+ " v",
6787
+ run.promptVersion
6788
+ ] }),
6789
+ !run.succeeded && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-0.5", children: [
6790
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: "warning", children: "Termin\xE9 partiellement" }),
6791
+ run.note && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-status-pending", children: run.note })
6792
+ ] }),
6793
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-muted-foreground", children: [
6794
+ "Cette action est ",
6795
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium text-foreground", children: "irr\xE9versible" }),
6796
+ " et s'applique imm\xE9diatement \xE0",
6797
+ " ",
6798
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium text-foreground", children: "toutes les apps" }),
6799
+ " qui r\xE9solvent",
6800
+ " ",
6801
+ /* @__PURE__ */ jsxRuntime.jsxs("code", { className: "font-mono", children: [
6802
+ run.promptName,
6803
+ "@",
6804
+ label || "\u2026"
6805
+ ] }),
6806
+ " ",
6807
+ "\u2014 les noms de prompts ne sont pas cloisonn\xE9s par app."
6808
+ ] }),
6809
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
6810
+ /* @__PURE__ */ jsxRuntime.jsx("label", { id: "quality-promote-label-group", className: "block text-sm font-medium", children: "Label" }),
6811
+ /* @__PURE__ */ jsxRuntime.jsxs(
6812
+ "div",
6813
+ {
6814
+ role: "radiogroup",
6815
+ "aria-labelledby": "quality-promote-label-group",
6816
+ className: "space-y-1.5",
6817
+ children: [
6818
+ KNOWN_PROMPT_LABELS.map((known) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2 text-sm", children: [
6819
+ /* @__PURE__ */ jsxRuntime.jsx(
6820
+ "input",
6821
+ {
6822
+ type: "radio",
6823
+ name: "quality-promote-label",
6824
+ value: known,
6825
+ checked: selectedOption === known,
6826
+ onChange: () => setSelectedOption(known)
6827
+ }
6828
+ ),
6829
+ known
6830
+ ] }, known)),
6831
+ /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex items-center gap-2 text-sm", children: [
6832
+ /* @__PURE__ */ jsxRuntime.jsx(
6833
+ "input",
6834
+ {
6835
+ type: "radio",
6836
+ name: "quality-promote-label",
6837
+ value: CUSTOM_LABEL_OPTION,
6838
+ checked: selectedOption === CUSTOM_LABEL_OPTION,
6839
+ onChange: () => setSelectedOption(CUSTOM_LABEL_OPTION)
6840
+ }
6841
+ ),
6842
+ "Autre"
6843
+ ] }),
6844
+ selectedOption === CUSTOM_LABEL_OPTION && /* @__PURE__ */ jsxRuntime.jsx(
6845
+ uiSdk.Input,
6846
+ {
6847
+ "aria-label": "Label personnalis\xE9",
6848
+ value: customLabel,
6849
+ onChange: (e) => setCustomLabel(e.target.value),
6850
+ className: "ml-6 w-auto"
6851
+ }
6852
+ )
6853
+ ]
6854
+ }
6855
+ )
6856
+ ] }),
6857
+ label && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: currentHolder.isLoading ? "V\xE9rification de la version actuelle\u2026" : currentHolder.version != null ? `Actuellement : ${run.promptName} v${currentHolder.version} porte le label \xAB ${label} \xBB.` : `Aucune version ne porte actuellement le label \xAB ${label} \xBB.` }),
6858
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
6859
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", size: "sm", onClick: onClose, children: "Annuler" }),
6860
+ /* @__PURE__ */ jsxRuntime.jsx(
6861
+ uiSdk.Button,
6862
+ {
6863
+ variant: "destructive",
6864
+ size: "sm",
6865
+ onClick: () => void onConfirm(),
6866
+ disabled: isPromoting || !label,
6867
+ children: isPromoting ? "Promotion\u2026" : "Promouvoir d\xE9finitivement"
6868
+ }
6869
+ )
6870
+ ] })
6871
+ ] }) });
6872
+ }
6873
+ function ReviewRunsSummary({ runs, canEdit }) {
6874
+ const [promoting, setPromoting] = react.useState(null);
6875
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap gap-3", children: [
6876
+ runs.map((run) => /* @__PURE__ */ jsxRuntime.jsxs(
6877
+ "div",
6878
+ {
6879
+ "data-testid": `review-run-${run.runName}`,
6880
+ className: "flex items-center gap-3 rounded-md border px-3 py-2",
6881
+ children: [
6882
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
6883
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium", children: run.label }),
6884
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-muted-foreground", children: [
6885
+ run.promptName,
6886
+ " v",
6887
+ run.promptVersion
6888
+ ] })
6889
+ ] }),
6890
+ run.succeeded ? /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: "success", children: "Termin\xE9" }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-0.5", children: [
6891
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: "warning", children: "Termin\xE9 partiellement" }),
6892
+ run.note && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-status-pending", children: run.note })
6893
+ ] }),
6894
+ canEdit && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { size: "sm", variant: "outline", onClick: () => setPromoting(run), children: "Promouvoir" })
6895
+ ]
6896
+ },
6897
+ run.runName
6898
+ )),
6899
+ promoting && /* @__PURE__ */ jsxRuntime.jsx(PromoteRunDialog, { run: promoting, open: true, onClose: () => setPromoting(null) })
6900
+ ] });
6901
+ }
6902
+ function formatGeneratedAt(iso) {
6903
+ const date = new Date(iso);
6904
+ return Number.isNaN(date.getTime()) ? iso : date.toLocaleString("fr-FR");
6905
+ }
6906
+ function ReviewSummaryCard({
6907
+ reviewId,
6908
+ summary,
6909
+ canEdit,
6910
+ onGenerated
6911
+ }) {
6912
+ const toast = uiSdk.useToast();
6913
+ const actions = useQualityActions();
6914
+ const [isGenerating, setIsGenerating] = react.useState(false);
6915
+ const onGenerate = async () => {
6916
+ setIsGenerating(true);
6917
+ try {
6918
+ onGenerated(await actions.generateSummary(reviewId));
6919
+ } catch (err) {
6920
+ toast({
6921
+ title: "Synth\xE8se impossible",
6922
+ description: qualityErrorMessage(err),
6923
+ variant: "error"
6924
+ });
6925
+ } finally {
6926
+ setIsGenerating(false);
6927
+ }
6928
+ };
6929
+ return /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Card, { children: [
6930
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardTitle, { children: "Synth\xE8se" }) }),
6931
+ /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.CardContent, { className: "space-y-3", children: [
6932
+ summary ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
6933
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "whitespace-pre-wrap text-sm", children: summary.text }),
6934
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "mt-2 text-xs text-muted-foreground", children: [
6935
+ summary.modelId,
6936
+ " \u2014 ",
6937
+ formatGeneratedAt(summary.generatedAt)
6938
+ ] })
6939
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Aucune synth\xE8se pour le moment." }),
6940
+ canEdit && /* @__PURE__ */ jsxRuntime.jsx(
6941
+ uiSdk.Button,
6942
+ {
6943
+ variant: "outline",
6944
+ size: "sm",
6945
+ disabled: isGenerating,
6946
+ onClick: () => void onGenerate(),
6947
+ children: isGenerating ? "G\xE9n\xE9ration\u2026" : "G\xE9n\xE9rer la synth\xE8se"
6948
+ }
6949
+ )
6950
+ ] })
6951
+ ] });
6952
+ }
6953
+ function ReviewView({
6954
+ reviewId,
6955
+ canEdit,
6956
+ onBack
6957
+ }) {
6958
+ const loaded = useReview(reviewId);
6959
+ const [review, setReview] = react.useState(loaded.data);
6960
+ react.useEffect(() => {
6961
+ setReview(loaded.data);
6962
+ }, [loaded.data]);
6963
+ const back = /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "ghost", size: "sm", className: "w-fit px-0 text-muted-foreground", onClick: onBack, children: "\u2190 Qualit\xE9" });
6964
+ if (loaded.isLoading) {
6965
+ return /* @__PURE__ */ jsxRuntime.jsxs(PageShell, { children: [
6966
+ back,
6967
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Chargement\u2026" })
6968
+ ] });
6969
+ }
6970
+ if (loaded.error !== void 0) {
6971
+ return /* @__PURE__ */ jsxRuntime.jsxs(PageShell, { children: [
6972
+ back,
6973
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: qualityErrorMessage(loaded.error) })
6974
+ ] });
6975
+ }
6976
+ if (!review) {
6977
+ return /* @__PURE__ */ jsxRuntime.jsxs(PageShell, { children: [
6978
+ back,
6979
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Revue introuvable." })
6980
+ ] });
6981
+ }
6982
+ return /* @__PURE__ */ jsxRuntime.jsxs(PageShell, { children: [
6983
+ back,
6984
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start justify-between gap-4", children: [
6985
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
6986
+ /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-2xl font-semibold", children: review.name }),
6987
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-muted-foreground", children: [
6988
+ "Dataset : ",
6989
+ review.datasetName
6990
+ ] })
6991
+ ] }),
6992
+ /* @__PURE__ */ jsxRuntime.jsx(ExportReviewButton, { reviewId: review.id })
6993
+ ] }),
6994
+ /* @__PURE__ */ jsxRuntime.jsx(ReviewRunsSummary, { runs: review.runs, canEdit }),
6995
+ /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Card, { children: [
6996
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardTitle, { children: "Scores" }) }),
6997
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardContent, { children: /* @__PURE__ */ jsxRuntime.jsx(ReviewHistogram, { histogram: review.histogram, runs: review.runs }) })
6998
+ ] }),
6999
+ /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Card, { children: [
7000
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardTitle, { children: "Revue item par item" }) }),
7001
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardContent, { children: /* @__PURE__ */ jsxRuntime.jsx(
7002
+ ReviewItemsPanel,
7003
+ {
7004
+ reviewId: review.id,
7005
+ items: review.items,
7006
+ canEdit,
7007
+ onItemSaved: (datasetItemId, saved) => setReview(
7008
+ (current) => current ? {
7009
+ ...current,
7010
+ items: current.items.map(
7011
+ (item) => item.datasetItemId === datasetItemId ? { ...item, review: saved } : item
7012
+ )
7013
+ } : current
7014
+ )
7015
+ }
7016
+ ) })
7017
+ ] }),
7018
+ /* @__PURE__ */ jsxRuntime.jsx(
7019
+ ReviewSummaryCard,
7020
+ {
7021
+ reviewId: review.id,
7022
+ summary: review.summary,
7023
+ canEdit,
7024
+ onGenerated: (summary) => setReview((current) => current ? { ...current, summary } : current)
7025
+ }
7026
+ )
7027
+ ] });
7028
+ }
7029
+ function QualityPage() {
7030
+ const { platformRole } = uiSdk.useAppContext();
7031
+ const canEdit = canEditQuality(platformRole);
7032
+ const { value: reviewId, setValue: setReviewId } = useQueryParam("revue");
7033
+ if (reviewId) {
7034
+ return /* @__PURE__ */ jsxRuntime.jsx(ReviewView, { reviewId, canEdit, onBack: () => setReviewId(null) });
7035
+ }
7036
+ return /* @__PURE__ */ jsxRuntime.jsx(ExperimentsView, { canEdit, onReviewCreated: setReviewId });
7037
+ }
5668
7038
 
5669
7039
  exports.AgentsPage = AgentsPage;
5670
7040
  exports.CategoriesPage = CategoriesPage;
@@ -5673,6 +7043,7 @@ exports.DashboardPage = DashboardPage;
5673
7043
  exports.EscalationsPage = EscalationsPage;
5674
7044
  exports.GraphCanvasPage = GraphCanvasPage;
5675
7045
  exports.PipelinePage = PipelinePage;
7046
+ exports.QualityPage = QualityPage;
5676
7047
  exports.SettingsPage = SettingsPage;
5677
7048
  exports.SharedPromptsPage = SharedPromptsPage;
5678
7049
  exports.TestPage = TestPage;