@apotech-os/support-kit 6.0.0 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ui/index.cjs CHANGED
@@ -2351,6 +2351,131 @@ function ConfirmModal({
2351
2351
  ] })
2352
2352
  ] }) });
2353
2353
  }
2354
+ var PROMPT_PANEL_CLASS = "w-[min(92vw,64rem)] max-w-none";
2355
+ var PRODUCTION_LABEL = "production";
2356
+ var PromptTextarea = react.forwardRef(
2357
+ function PromptTextarea2({ value, className, rows = 14, ...props }, ref) {
2358
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2359
+ /* @__PURE__ */ jsxRuntime.jsx(
2360
+ uiSdk.Textarea,
2361
+ {
2362
+ ref,
2363
+ value,
2364
+ rows,
2365
+ className: uiSdk.cn("font-mono text-xs leading-relaxed", className),
2366
+ ...props
2367
+ }
2368
+ ),
2369
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "mt-1 text-right text-xs text-muted-foreground", children: [
2370
+ value.length.toLocaleString("fr-FR"),
2371
+ " caract\xE8re",
2372
+ value.length > 1 ? "s" : ""
2373
+ ] })
2374
+ ] });
2375
+ }
2376
+ );
2377
+ function defaultExpandedVersion(versions) {
2378
+ const production = versions.find((v) => v.labels.includes(PRODUCTION_LABEL));
2379
+ if (production) return production.version;
2380
+ return versions.reduce(
2381
+ (max, v) => max === null || v.version > max ? v.version : max,
2382
+ null
2383
+ );
2384
+ }
2385
+ function excerptOf(content) {
2386
+ return content.slice(0, 1e3).split("\n").find((line) => line.trim() !== "") ?? "";
2387
+ }
2388
+ function VersionCard({
2389
+ version,
2390
+ defaultOpen,
2391
+ onEditFrom,
2392
+ onPromote,
2393
+ onDelete
2394
+ }) {
2395
+ const [isOpen, setIsOpen] = react.useState(defaultOpen);
2396
+ const hasActions = onEditFrom !== void 0 || onPromote !== void 0 || onDelete !== void 0;
2397
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-md border", children: [
2398
+ /* @__PURE__ */ jsxRuntime.jsxs(
2399
+ "button",
2400
+ {
2401
+ type: "button",
2402
+ "aria-expanded": isOpen,
2403
+ onClick: () => setIsOpen((open) => !open),
2404
+ className: "flex w-full items-center gap-3 rounded-md p-3 text-left hover:bg-accent/50",
2405
+ children: [
2406
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex min-w-0 flex-1 items-center gap-2", children: [
2407
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "shrink-0 text-sm font-medium", children: [
2408
+ "v",
2409
+ version.version
2410
+ ] }),
2411
+ version.label && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: "brand", children: version.label }),
2412
+ !isOpen && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate font-mono text-xs text-muted-foreground", children: excerptOf(version.content) })
2413
+ ] }),
2414
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "shrink-0 text-xs text-muted-foreground", children: [
2415
+ "Cr\xE9\xE9e le ",
2416
+ formatDate(version.createdAt)
2417
+ ] })
2418
+ ]
2419
+ }
2420
+ ),
2421
+ isOpen && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2 border-t p-3", children: [
2422
+ hasActions && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap justify-end gap-2", children: [
2423
+ onEditFrom && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", size: "sm", onClick: onEditFrom, children: "Modifier cette version" }),
2424
+ onPromote && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", size: "sm", onClick: onPromote, children: "Promouvoir" }),
2425
+ onDelete && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", size: "sm", onClick: onDelete, children: "Supprimer la version" })
2426
+ ] }),
2427
+ /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "whitespace-pre-wrap font-mono text-xs text-muted-foreground", children: version.content })
2428
+ ] })
2429
+ ] });
2430
+ }
2431
+ function useNewVersionDraft() {
2432
+ const [content, setContent] = react.useState("");
2433
+ const [pendingPrefill, setPendingPrefill] = react.useState(null);
2434
+ const editorRef = react.useRef(null);
2435
+ function loadIntoEditor(versionContent) {
2436
+ setContent(versionContent);
2437
+ setTimeout(() => {
2438
+ editorRef.current?.focus();
2439
+ editorRef.current?.scrollIntoView?.({ block: "center" });
2440
+ }, 0);
2441
+ }
2442
+ function prefill(versionContent) {
2443
+ if (content.trim() !== "" && content !== versionContent) {
2444
+ setPendingPrefill(versionContent);
2445
+ return;
2446
+ }
2447
+ loadIntoEditor(versionContent);
2448
+ }
2449
+ function confirmPrefill() {
2450
+ if (pendingPrefill !== null) loadIntoEditor(pendingPrefill);
2451
+ setPendingPrefill(null);
2452
+ }
2453
+ return {
2454
+ content,
2455
+ setContent,
2456
+ editorRef,
2457
+ prefill,
2458
+ pendingPrefill,
2459
+ confirmPrefill,
2460
+ cancelPrefill: () => setPendingPrefill(null)
2461
+ };
2462
+ }
2463
+ function ReplaceDraftConfirmModal({
2464
+ onConfirm,
2465
+ onCancel
2466
+ }) {
2467
+ return /* @__PURE__ */ jsxRuntime.jsx(
2468
+ ConfirmModal,
2469
+ {
2470
+ title: "Remplacer le brouillon ?",
2471
+ description: "Le texte d\xE9j\xE0 saisi dans \xAB Nouvelle version \xBB sera remplac\xE9 par le contenu de cette version.",
2472
+ confirmLabel: "Remplacer",
2473
+ busyLabel: "Remplacement\u2026",
2474
+ onConfirm,
2475
+ onCancel
2476
+ }
2477
+ );
2478
+ }
2354
2479
  function usePromptVersions(promptName) {
2355
2480
  const { appSlug } = uiSdk.useAppContext();
2356
2481
  const api = uiSdk.useAppApi();
@@ -2508,7 +2633,7 @@ function formFromAgent(agent) {
2508
2633
  var DERIVED_PROMPT_VALUE = "__derived__";
2509
2634
  var CUSTOM_PROMPT_VALUE = "__custom-prompt__";
2510
2635
  var DEFAULT_LABEL_VALUE = "__production__";
2511
- function AgentFormModal({
2636
+ function AgentFormPanel({
2512
2637
  agent,
2513
2638
  prompts,
2514
2639
  promptsLoading,
@@ -2532,13 +2657,17 @@ function AgentFormModal({
2532
2657
  const knownPrompt = prompts.find((entry) => entry.name === form.promptName);
2533
2658
  const showPromptFreeText = freeTextPrompt || agent !== "new" && form.promptName !== "" && !knownPrompt && !promptsLoading;
2534
2659
  const promptLabels = knownPrompt?.labels ?? [];
2660
+ const previewName = agent === "new" && !showPromptFreeText && form.promptName !== "" ? form.promptName : null;
2661
+ const { versions: previewVersions } = usePromptVersions(previewName);
2662
+ const previewContent = previewVersions.find((v) => v.version === defaultExpandedVersion(previewVersions))?.content ?? "";
2663
+ const effectiveSnapshot = previewName !== null ? previewContent : form.systemPromptSnapshot;
2535
2664
  const isValid = form.name.trim() !== "" && form.modelId.trim() !== "" && (agent === "new" || form.promptName.trim() !== "");
2536
2665
  async function submit(event) {
2537
2666
  event.preventDefault();
2538
2667
  if (isSaving || !isValid) return;
2539
2668
  setIsSaving(true);
2540
2669
  try {
2541
- await onSave(form);
2670
+ await onSave({ ...form, systemPromptSnapshot: effectiveSnapshot });
2542
2671
  } finally {
2543
2672
  setIsSaving(false);
2544
2673
  }
@@ -2552,161 +2681,170 @@ function AgentFormModal({
2552
2681
  setForm({ ...form, promptName: next === DERIVED_PROMPT_VALUE ? "" : next, promptLabel: "" });
2553
2682
  }
2554
2683
  return /* @__PURE__ */ jsxRuntime.jsx(
2555
- uiSdk.Modal,
2684
+ uiSdk.SidePanel,
2556
2685
  {
2557
2686
  open: true,
2558
2687
  onClose,
2559
2688
  title: agent === "new" ? "Nouvel agent" : `Modifier ${form.name}`,
2560
- children: /* @__PURE__ */ jsxRuntime.jsxs("form", { className: "space-y-3", onSubmit: (e) => void submit(e), children: [
2561
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2562
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: nameId, className: "mb-1 block text-sm font-medium", children: "Nom" }),
2563
- /* @__PURE__ */ jsxRuntime.jsx(
2564
- uiSdk.Input,
2565
- {
2566
- id: nameId,
2567
- value: form.name,
2568
- onChange: (e) => setForm({ ...form, name: e.target.value })
2569
- }
2570
- )
2571
- ] }),
2572
- agent !== "new" && agent.status !== "default" && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2573
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-1 text-sm font-medium", children: "Statut" }),
2574
- /* @__PURE__ */ jsxRuntime.jsx(
2575
- uiSdk.Select,
2576
- {
2577
- "aria-label": "Statut",
2578
- value: form.status,
2579
- onValueChange: (next) => setForm({ ...form, status: next }),
2580
- items: [
2581
- { value: "available", label: STATUS_LABELS.available },
2582
- { value: "archived", label: STATUS_LABELS.archived }
2583
- ]
2584
- }
2585
- )
2586
- ] }),
2587
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2588
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-1 text-sm font-medium", children: "Mod\xE8le" }),
2589
- /* @__PURE__ */ jsxRuntime.jsx(
2590
- uiSdk.Select,
2591
- {
2592
- "aria-label": "Mod\xE8le",
2593
- value: showModelFreeText ? CUSTOM_MODEL_VALUE : form.modelId,
2594
- onValueChange: (next) => {
2595
- if (next === CUSTOM_MODEL_VALUE) {
2596
- setFreeTextModel(true);
2597
- return;
2598
- }
2599
- setFreeTextModel(false);
2600
- setForm({ ...form, modelId: next, provider: DEFAULT_STEP_PROVIDER });
2601
- },
2602
- items: [
2603
- // The stored model, listed so the trigger can print it while the
2604
- // provider's own list is still loading.
2605
- ...!showModelFreeText && form.modelId !== "" && !knownModel ? [{ value: form.modelId, label: form.modelId }] : [],
2606
- ...models.map((name) => ({ value: name, label: name })),
2607
- { value: CUSTOM_MODEL_VALUE, label: "Autre \u2014 saisir un identifiant de mod\xE8le" }
2608
- ],
2609
- disabled: modelsLoading
2610
- }
2611
- ),
2612
- showModelFreeText && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2 space-y-2", children: [
2613
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: modelInputId, className: "mb-1 block text-sm font-medium", children: "Identifiant de mod\xE8le" }),
2614
- /* @__PURE__ */ jsxRuntime.jsx(
2615
- uiSdk.Input,
2616
- {
2617
- id: modelInputId,
2618
- value: form.modelId,
2619
- onChange: (e) => setForm({ ...form, modelId: e.target.value })
2620
- }
2621
- ),
2622
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: providerInputId, className: "mb-1 block text-sm font-medium", children: "Fournisseur" }),
2689
+ className: PROMPT_PANEL_CLASS,
2690
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-h-0 flex-1 flex-col overflow-y-auto pr-1", children: [
2691
+ /* @__PURE__ */ jsxRuntime.jsxs("form", { className: "space-y-3", onSubmit: (e) => void submit(e), children: [
2692
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2693
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: nameId, className: "mb-1 block text-sm font-medium", children: "Nom" }),
2623
2694
  /* @__PURE__ */ jsxRuntime.jsx(
2624
2695
  uiSdk.Input,
2625
2696
  {
2626
- id: providerInputId,
2627
- value: form.provider,
2628
- onChange: (e) => setForm({ ...form, provider: e.target.value })
2697
+ id: nameId,
2698
+ value: form.name,
2699
+ onChange: (e) => setForm({ ...form, name: e.target.value })
2629
2700
  }
2630
2701
  )
2631
- ] })
2632
- ] }),
2633
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2634
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-1 text-sm font-medium", children: "Prompt Langfuse" }),
2635
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-2 sm:grid-cols-2", children: [
2702
+ ] }),
2703
+ agent !== "new" && agent.status !== "default" && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2704
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-1 text-sm font-medium", children: "Statut" }),
2636
2705
  /* @__PURE__ */ jsxRuntime.jsx(
2637
2706
  uiSdk.Select,
2638
2707
  {
2639
- "aria-label": "Prompt Langfuse",
2640
- value: showPromptFreeText ? CUSTOM_PROMPT_VALUE : agent === "new" && form.promptName === "" ? DERIVED_PROMPT_VALUE : form.promptName,
2641
- onValueChange: pickPrompt,
2708
+ "aria-label": "Statut",
2709
+ value: form.status,
2710
+ onValueChange: (next) => setForm({ ...form, status: next }),
2642
2711
  items: [
2643
- ...agent === "new" ? [
2644
- {
2645
- value: DERIVED_PROMPT_VALUE,
2646
- label: "Nouveau prompt \u2014 agent/<g\xE9n\xE9r\xE9 automatiquement>"
2647
- }
2648
- ] : [],
2649
- // The agent's stored prompt, listed so the trigger can print it
2650
- // while the catalogue is still loading.
2651
- ...!showPromptFreeText && form.promptName !== "" && !knownPrompt ? [{ value: form.promptName, label: form.promptName }] : [],
2652
- ...prompts.map((entry) => ({ value: entry.name, label: entry.name })),
2653
- { value: CUSTOM_PROMPT_VALUE, label: "Autre \u2014 saisir un nom de prompt" }
2654
- ],
2655
- disabled: promptsLoading
2712
+ { value: "available", label: STATUS_LABELS.available },
2713
+ { value: "archived", label: STATUS_LABELS.archived }
2714
+ ]
2656
2715
  }
2657
- ),
2716
+ )
2717
+ ] }),
2718
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2719
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-1 text-sm font-medium", children: "Mod\xE8le" }),
2658
2720
  /* @__PURE__ */ jsxRuntime.jsx(
2659
2721
  uiSdk.Select,
2660
2722
  {
2661
- "aria-label": "Tag du prompt",
2662
- value: form.promptLabel === "" ? DEFAULT_LABEL_VALUE : form.promptLabel,
2663
- onValueChange: (next) => setForm({ ...form, promptLabel: next === DEFAULT_LABEL_VALUE ? "" : next }),
2723
+ "aria-label": "Mod\xE8le",
2724
+ value: showModelFreeText ? CUSTOM_MODEL_VALUE : form.modelId,
2725
+ onValueChange: (next) => {
2726
+ if (next === CUSTOM_MODEL_VALUE) {
2727
+ setFreeTextModel(true);
2728
+ return;
2729
+ }
2730
+ setFreeTextModel(false);
2731
+ setForm({ ...form, modelId: next, provider: DEFAULT_STEP_PROVIDER });
2732
+ },
2664
2733
  items: [
2665
- { value: DEFAULT_LABEL_VALUE, label: "production (par d\xE9faut)" },
2666
- ...promptLabels.filter((label) => label !== DEFAULT_PROMPT_LABEL).map((label) => ({ value: label, label })),
2667
- ...form.promptLabel !== "" && !promptLabels.includes(form.promptLabel) ? [{ value: form.promptLabel, label: form.promptLabel }] : []
2734
+ // The stored model, listed so the trigger can print it while the
2735
+ // provider's own list is still loading.
2736
+ ...!showModelFreeText && form.modelId !== "" && !knownModel ? [{ value: form.modelId, label: form.modelId }] : [],
2737
+ ...models.map((name) => ({ value: name, label: name })),
2738
+ { value: CUSTOM_MODEL_VALUE, label: "Autre \u2014 saisir un identifiant de mod\xE8le" }
2668
2739
  ],
2669
- disabled: promptsLoading || form.promptName === "" && !showPromptFreeText
2740
+ disabled: modelsLoading
2670
2741
  }
2671
- )
2742
+ ),
2743
+ showModelFreeText && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2 space-y-2", children: [
2744
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: modelInputId, className: "mb-1 block text-sm font-medium", children: "Identifiant de mod\xE8le" }),
2745
+ /* @__PURE__ */ jsxRuntime.jsx(
2746
+ uiSdk.Input,
2747
+ {
2748
+ id: modelInputId,
2749
+ value: form.modelId,
2750
+ onChange: (e) => setForm({ ...form, modelId: e.target.value })
2751
+ }
2752
+ ),
2753
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: providerInputId, className: "mb-1 block text-sm font-medium", children: "Fournisseur" }),
2754
+ /* @__PURE__ */ jsxRuntime.jsx(
2755
+ uiSdk.Input,
2756
+ {
2757
+ id: providerInputId,
2758
+ value: form.provider,
2759
+ onChange: (e) => setForm({ ...form, provider: e.target.value })
2760
+ }
2761
+ )
2762
+ ] })
2672
2763
  ] }),
2673
- showPromptFreeText && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2", children: [
2674
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: promptInputId, className: "mb-1 block text-sm font-medium", children: "Nom du prompt Langfuse" }),
2764
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2765
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mb-1 text-sm font-medium", children: "Prompt Langfuse" }),
2766
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-2 sm:grid-cols-2", children: [
2767
+ /* @__PURE__ */ jsxRuntime.jsx(
2768
+ uiSdk.Select,
2769
+ {
2770
+ "aria-label": "Prompt Langfuse",
2771
+ value: showPromptFreeText ? CUSTOM_PROMPT_VALUE : agent === "new" && form.promptName === "" ? DERIVED_PROMPT_VALUE : form.promptName,
2772
+ onValueChange: pickPrompt,
2773
+ items: [
2774
+ ...agent === "new" ? [
2775
+ {
2776
+ value: DERIVED_PROMPT_VALUE,
2777
+ label: "Nouveau prompt \u2014 agent/<g\xE9n\xE9r\xE9 automatiquement>"
2778
+ }
2779
+ ] : [],
2780
+ // The agent's stored prompt, listed so the trigger can print it
2781
+ // while the catalogue is still loading.
2782
+ ...!showPromptFreeText && form.promptName !== "" && !knownPrompt ? [{ value: form.promptName, label: form.promptName }] : [],
2783
+ ...prompts.map((entry) => ({ value: entry.name, label: entry.name })),
2784
+ { value: CUSTOM_PROMPT_VALUE, label: "Autre \u2014 saisir un nom de prompt" }
2785
+ ],
2786
+ disabled: promptsLoading
2787
+ }
2788
+ ),
2789
+ /* @__PURE__ */ jsxRuntime.jsx(
2790
+ uiSdk.Select,
2791
+ {
2792
+ "aria-label": "Tag du prompt",
2793
+ value: form.promptLabel === "" ? DEFAULT_LABEL_VALUE : form.promptLabel,
2794
+ onValueChange: (next) => setForm({ ...form, promptLabel: next === DEFAULT_LABEL_VALUE ? "" : next }),
2795
+ items: [
2796
+ { value: DEFAULT_LABEL_VALUE, label: "production (par d\xE9faut)" },
2797
+ ...promptLabels.filter((label) => label !== DEFAULT_PROMPT_LABEL).map((label) => ({ value: label, label })),
2798
+ ...form.promptLabel !== "" && !promptLabels.includes(form.promptLabel) ? [{ value: form.promptLabel, label: form.promptLabel }] : []
2799
+ ],
2800
+ disabled: promptsLoading || form.promptName === "" && !showPromptFreeText
2801
+ }
2802
+ )
2803
+ ] }),
2804
+ showPromptFreeText && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2", children: [
2805
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: promptInputId, className: "mb-1 block text-sm font-medium", children: "Nom du prompt Langfuse" }),
2806
+ /* @__PURE__ */ jsxRuntime.jsx(
2807
+ uiSdk.Input,
2808
+ {
2809
+ id: promptInputId,
2810
+ value: form.promptName,
2811
+ onChange: (e) => setForm({ ...form, promptName: e.target.value })
2812
+ }
2813
+ )
2814
+ ] }),
2815
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: "Laisser sur \xAB Nouveau prompt \xBB pour en cr\xE9er un ; choisir un prompt existant pour y rattacher l'agent. Le nom est \xE9crit tel quel, sans normalisation." })
2816
+ ] }),
2817
+ agent === "new" && !showPromptFreeText && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2818
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: snapshotId, className: "mb-1 block text-sm font-medium", children: "Prompt de l'agent" }),
2675
2819
  /* @__PURE__ */ jsxRuntime.jsx(
2676
- uiSdk.Input,
2820
+ PromptTextarea,
2677
2821
  {
2678
- id: promptInputId,
2679
- value: form.promptName,
2680
- onChange: (e) => setForm({ ...form, promptName: e.target.value })
2822
+ id: snapshotId,
2823
+ value: effectiveSnapshot,
2824
+ onChange: (e) => setForm({ ...form, systemPromptSnapshot: e.target.value }),
2825
+ readOnly: previewName !== null,
2826
+ className: "min-h-[40vh]"
2681
2827
  }
2682
- )
2828
+ ),
2829
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: previewName !== null ? "Contenu actuel du prompt s\xE9lectionn\xE9 \u2014 l\u2019agent l\u2019utilisera tel quel ; ses versions se g\xE8rent apr\xE8s la cr\xE9ation." : "Devient la premi\xE8re version du nouveau prompt Langfuse, promue en production \xE0 la cr\xE9ation." })
2683
2830
  ] }),
2684
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: "Laisser sur \xAB Nouveau prompt \xBB pour en cr\xE9er un ; choisir un prompt existant pour y rattacher l'agent. Le nom est \xE9crit tel quel, sans normalisation." })
2685
- ] }),
2686
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2687
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: snapshotId, className: "mb-1 block text-sm font-medium", children: "Prompt de secours (niveau 3)" }),
2688
- /* @__PURE__ */ jsxRuntime.jsx(
2689
- uiSdk.Textarea,
2690
- {
2691
- id: snapshotId,
2692
- value: form.systemPromptSnapshot,
2693
- onChange: (e) => setForm({ ...form, systemPromptSnapshot: e.target.value })
2694
- }
2695
- )
2831
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2 border-t pt-3", children: [
2832
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { type: "button", variant: "outline", onClick: onClose, children: "Annuler" }),
2833
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { type: "submit", disabled: isSaving || !isValid, children: isSaving ? "Enregistrement\u2026" : "Enregistrer" })
2834
+ ] })
2696
2835
  ] }),
2697
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2 pt-2", children: [
2698
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { type: "button", variant: "outline", onClick: onClose, children: "Annuler" }),
2699
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { type: "submit", disabled: isSaving || !isValid, children: isSaving ? "Enregistrement\u2026" : "Enregistrer" })
2836
+ agent !== "new" && /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "mt-6 space-y-4 border-t pt-4", children: [
2837
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2838
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-sm font-semibold", children: "Versions du prompt Langfuse" }),
2839
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: agent.promptName })
2840
+ ] }),
2841
+ /* @__PURE__ */ jsxRuntime.jsx(PromptVersionsSection, { agent, canWrite: true })
2700
2842
  ] })
2701
2843
  ] })
2702
2844
  }
2703
2845
  );
2704
2846
  }
2705
- function PromptVersionsPanel({
2706
- agent,
2707
- canWrite,
2708
- onClose
2709
- }) {
2847
+ function PromptVersionsSection({ agent, canWrite }) {
2710
2848
  const { appSlug } = uiSdk.useAppContext();
2711
2849
  const { versions, error, refresh, promote, deleteVersion, createVersion } = usePromptVersions(
2712
2850
  agent.promptName
@@ -2714,7 +2852,7 @@ function PromptVersionsPanel({
2714
2852
  const [suggestMessage, setSuggestMessage] = react.useState(null);
2715
2853
  const [isSuggesting, setIsSuggesting] = react.useState(false);
2716
2854
  const isSuggestingRef = react.useRef(false);
2717
- const [newVersionContent, setNewVersionContent] = react.useState("");
2855
+ const draft = useNewVersionDraft();
2718
2856
  const [isCreatingVersion, setIsCreatingVersion] = react.useState(false);
2719
2857
  const [deletingVersion, setDeletingVersion] = react.useState(null);
2720
2858
  const [isComparing, setIsComparing] = react.useState(false);
@@ -2723,6 +2861,7 @@ function PromptVersionsPanel({
2723
2861
  const newVersionId = react.useId();
2724
2862
  const api = uiSdk.useAppApi();
2725
2863
  const toast = uiSdk.useToast();
2864
+ const expandedVersion = defaultExpandedVersion(versions);
2726
2865
  function openCompare() {
2727
2866
  const sorted = [...versions].sort((a, b) => a.version - b.version);
2728
2867
  setCompareLeft(sorted[0]?.version ?? null);
@@ -2763,8 +2902,8 @@ function PromptVersionsPanel({
2763
2902
  async function runCreateVersion() {
2764
2903
  setIsCreatingVersion(true);
2765
2904
  try {
2766
- await createVersion(newVersionContent);
2767
- setNewVersionContent("");
2905
+ await createVersion(draft.content);
2906
+ draft.setContent("");
2768
2907
  toast({ title: "Nouvelle version cr\xE9\xE9e.", variant: "success" });
2769
2908
  } catch (err) {
2770
2909
  toast({
@@ -2792,94 +2931,93 @@ function PromptVersionsPanel({
2792
2931
  setDeletingVersion(null);
2793
2932
  }
2794
2933
  }
2795
- return /* @__PURE__ */ jsxRuntime.jsxs(
2934
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2935
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
2936
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
2937
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Link, { href: qualityHref(appSlug, agent), children: "Voir dans Qualit\xE9" }),
2938
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2", children: [
2939
+ versions.length >= 2 && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", onClick: openCompare, children: "Comparer" }),
2940
+ canWrite && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", onClick: () => void suggest(), disabled: isSuggesting, children: isSuggesting ? "Suggestion en cours\u2026" : "Sugg\xE9rer une am\xE9lioration" })
2941
+ ] })
2942
+ ] }),
2943
+ suggestMessage && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: suggestMessage }),
2944
+ error !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive", children: "Erreur lors du chargement des versions." }),
2945
+ versions.length > 0 && !versions.some((v) => v.labels.includes(PRODUCTION_LABEL)) && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "rounded-md border border-status-warning/40 bg-status-warning/10 p-2 text-sm text-status-warning", children: "Aucune version active \u2014 aucune version ne porte le label \xAB production \xBB. Promouvez-en une pour que l'agent l'utilise." }),
2946
+ isComparing && compareLeft !== null && compareRight !== null && /* @__PURE__ */ jsxRuntime.jsx(
2947
+ VersionCompareView,
2948
+ {
2949
+ versions,
2950
+ leftVersion: compareLeft,
2951
+ rightVersion: compareRight,
2952
+ onSelectLeft: setCompareLeft,
2953
+ onSelectRight: setCompareRight
2954
+ }
2955
+ ),
2956
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-3", children: versions.map((v) => /* @__PURE__ */ jsxRuntime.jsx(
2957
+ VersionCard,
2958
+ {
2959
+ version: v,
2960
+ defaultOpen: v.version === expandedVersion,
2961
+ onEditFrom: canWrite ? () => draft.prefill(v.content) : void 0,
2962
+ onPromote: canWrite ? () => void runPromote(v.version) : void 0,
2963
+ onDelete: canWrite ? () => setDeletingVersion(v.version) : void 0
2964
+ },
2965
+ v.version
2966
+ )) }),
2967
+ canWrite && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2 border-t pt-3", children: [
2968
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: newVersionId, className: "block text-sm font-medium", children: "Nouvelle version" }),
2969
+ /* @__PURE__ */ jsxRuntime.jsx(
2970
+ PromptTextarea,
2971
+ {
2972
+ id: newVersionId,
2973
+ ref: draft.editorRef,
2974
+ value: draft.content,
2975
+ onChange: (e) => draft.setContent(e.target.value)
2976
+ }
2977
+ ),
2978
+ /* @__PURE__ */ jsxRuntime.jsx(
2979
+ uiSdk.Button,
2980
+ {
2981
+ onClick: () => void runCreateVersion(),
2982
+ disabled: draft.content.trim() === "" || isCreatingVersion,
2983
+ children: isCreatingVersion ? "Cr\xE9ation\u2026" : "Cr\xE9er la version"
2984
+ }
2985
+ )
2986
+ ] })
2987
+ ] }),
2988
+ draft.pendingPrefill !== null && /* @__PURE__ */ jsxRuntime.jsx(ReplaceDraftConfirmModal, { onConfirm: draft.confirmPrefill, onCancel: draft.cancelPrefill }),
2989
+ deletingVersion !== null && /* @__PURE__ */ jsxRuntime.jsx(
2990
+ ConfirmModal,
2991
+ {
2992
+ title: "Supprimer la version ?",
2993
+ description: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2994
+ "La version ",
2995
+ deletingVersion,
2996
+ " de ",
2997
+ /* @__PURE__ */ jsxRuntime.jsx("code", { children: agent.promptName }),
2998
+ " sera supprim\xE9e d\xE9finitivement. Impossible si elle porte le label \xAB production \xBB ou s'il s'agit de la derni\xE8re version restante."
2999
+ ] }),
3000
+ confirmLabel: "Supprimer la version",
3001
+ onConfirm: confirmDeleteVersion,
3002
+ onCancel: () => setDeletingVersion(null)
3003
+ }
3004
+ )
3005
+ ] });
3006
+ }
3007
+ function PromptVersionsPanel({
3008
+ agent,
3009
+ canWrite,
3010
+ onClose
3011
+ }) {
3012
+ return /* @__PURE__ */ jsxRuntime.jsx(
2796
3013
  uiSdk.SidePanel,
2797
3014
  {
2798
3015
  open: true,
2799
3016
  onClose,
2800
3017
  title: `Versions du prompt \u2014 ${agent.name}`,
2801
3018
  description: agent.promptName,
2802
- children: [
2803
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto", children: [
2804
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
2805
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Link, { href: qualityHref(appSlug, agent), children: "Voir dans Qualit\xE9" }),
2806
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2", children: [
2807
- versions.length >= 2 && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", onClick: openCompare, children: "Comparer" }),
2808
- canWrite && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", onClick: () => void suggest(), disabled: isSuggesting, children: isSuggesting ? "Suggestion en cours\u2026" : "Sugg\xE9rer une am\xE9lioration" })
2809
- ] })
2810
- ] }),
2811
- suggestMessage && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: suggestMessage }),
2812
- error !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive", children: "Erreur lors du chargement des versions." }),
2813
- isComparing && compareLeft !== null && compareRight !== null && /* @__PURE__ */ jsxRuntime.jsx(
2814
- VersionCompareView,
2815
- {
2816
- versions,
2817
- leftVersion: compareLeft,
2818
- rightVersion: compareRight,
2819
- onSelectLeft: setCompareLeft,
2820
- onSelectRight: setCompareRight
2821
- }
2822
- ),
2823
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-3", children: versions.map((v) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-md border p-3", children: [
2824
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
2825
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-sm font-medium", children: [
2826
- "v",
2827
- v.version,
2828
- " ",
2829
- v.label && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: "brand", children: v.label })
2830
- ] }),
2831
- canWrite && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2", children: [
2832
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", size: "sm", onClick: () => void runPromote(v.version), children: "Promouvoir" }),
2833
- /* @__PURE__ */ jsxRuntime.jsx(
2834
- uiSdk.Button,
2835
- {
2836
- variant: "outline",
2837
- size: "sm",
2838
- onClick: () => setDeletingVersion(v.version),
2839
- children: "Supprimer la version"
2840
- }
2841
- )
2842
- ] })
2843
- ] }),
2844
- /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "mt-2 whitespace-pre-wrap text-xs text-muted-foreground", children: v.content })
2845
- ] }, v.version)) }),
2846
- canWrite && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2 border-t pt-3", children: [
2847
- /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: newVersionId, className: "block text-sm font-medium", children: "Nouvelle version" }),
2848
- /* @__PURE__ */ jsxRuntime.jsx(
2849
- uiSdk.Textarea,
2850
- {
2851
- id: newVersionId,
2852
- value: newVersionContent,
2853
- onChange: (e) => setNewVersionContent(e.target.value)
2854
- }
2855
- ),
2856
- /* @__PURE__ */ jsxRuntime.jsx(
2857
- uiSdk.Button,
2858
- {
2859
- onClick: () => void runCreateVersion(),
2860
- disabled: newVersionContent.trim() === "" || isCreatingVersion,
2861
- children: isCreatingVersion ? "Cr\xE9ation\u2026" : "Cr\xE9er la version"
2862
- }
2863
- )
2864
- ] })
2865
- ] }),
2866
- deletingVersion !== null && /* @__PURE__ */ jsxRuntime.jsx(
2867
- ConfirmModal,
2868
- {
2869
- title: "Supprimer la version ?",
2870
- description: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2871
- "La version ",
2872
- deletingVersion,
2873
- " de ",
2874
- /* @__PURE__ */ jsxRuntime.jsx("code", { children: agent.promptName }),
2875
- " sera supprim\xE9e d\xE9finitivement. Impossible si elle porte le label \xAB production \xBB ou s'il s'agit de la derni\xE8re version restante."
2876
- ] }),
2877
- confirmLabel: "Supprimer la version",
2878
- onConfirm: confirmDeleteVersion,
2879
- onCancel: () => setDeletingVersion(null)
2880
- }
2881
- )
2882
- ]
3019
+ className: PROMPT_PANEL_CLASS,
3020
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-h-0 flex-1 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(PromptVersionsSection, { agent, canWrite }) })
2883
3021
  }
2884
3022
  );
2885
3023
  }
@@ -2969,7 +3107,6 @@ function AgentsPage() {
2969
3107
  name: form.name,
2970
3108
  modelId: form.modelId,
2971
3109
  provider: form.provider,
2972
- systemPromptSnapshot: form.systemPromptSnapshot,
2973
3110
  promptName: form.promptName.trim(),
2974
3111
  promptLabel: form.promptLabel.trim() || null,
2975
3112
  ...formAgent.status !== "default" ? { status: form.status } : {}
@@ -3048,14 +3185,15 @@ function AgentsPage() {
3048
3185
  }
3049
3186
  ),
3050
3187
  formAgent && /* @__PURE__ */ jsxRuntime.jsx(
3051
- AgentFormModal,
3188
+ AgentFormPanel,
3052
3189
  {
3053
3190
  agent: formAgent,
3054
3191
  prompts,
3055
3192
  promptsLoading,
3056
3193
  onClose: () => setFormAgent(null),
3057
3194
  onSave: save
3058
- }
3195
+ },
3196
+ formAgent === "new" ? "new" : formAgent.id
3059
3197
  ),
3060
3198
  versionsAgent && /* @__PURE__ */ jsxRuntime.jsx(
3061
3199
  PromptVersionsPanel,
@@ -3063,7 +3201,8 @@ function AgentsPage() {
3063
3201
  agent: versionsAgent,
3064
3202
  canWrite,
3065
3203
  onClose: () => setVersionsAgent(null)
3066
- }
3204
+ },
3205
+ versionsAgent.promptName
3067
3206
  ),
3068
3207
  deletingAgent && /* @__PURE__ */ jsxRuntime.jsx(
3069
3208
  ConfirmModal,
@@ -5682,13 +5821,12 @@ function useSharedPrompts() {
5682
5821
  }, [load]);
5683
5822
  return { prompts, isLoading, error, refresh: load };
5684
5823
  }
5685
- var PRODUCTION_LABEL = "production";
5686
5824
  var SHARED_PREFIX2 = "shared/";
5687
5825
  var SLUG_RE = /^[a-z0-9-]{1,64}$/;
5688
5826
  var SLUG_ERROR = "Le nom doit contenir 1 \xE0 64 minuscules, chiffres ou tirets.";
5689
5827
  function VersionsPanel({ name, canWrite, onClose }) {
5690
5828
  const { versions, error, promote, deleteVersion, refresh } = usePromptVersions(name);
5691
- const [newContent, setNewContent] = react.useState("");
5829
+ const draft = useNewVersionDraft();
5692
5830
  const [isCreating, setIsCreating] = react.useState(false);
5693
5831
  const [createError, setCreateError] = react.useState(null);
5694
5832
  const [deletingVersion, setDeletingVersion] = react.useState(null);
@@ -5700,6 +5838,7 @@ function VersionsPanel({ name, canWrite, onClose }) {
5700
5838
  const api = uiSdk.useAppApi();
5701
5839
  const toast = uiSdk.useToast();
5702
5840
  const sorted = [...versions].sort((a, b) => b.version - a.version);
5841
+ const expandedVersion = defaultExpandedVersion(versions);
5703
5842
  const hasActiveVersion = versions.some((v) => v.labels.includes(PRODUCTION_LABEL));
5704
5843
  function openCompare() {
5705
5844
  const byVersionAsc = [...versions].sort((a, b) => a.version - b.version);
@@ -5737,14 +5876,14 @@ function VersionsPanel({ name, canWrite, onClose }) {
5737
5876
  async function runCreateVersion() {
5738
5877
  setIsCreating(true);
5739
5878
  setCreateError(null);
5740
- const payload = { name, content: newContent };
5879
+ const payload = { name, content: draft.content };
5741
5880
  try {
5742
5881
  await api.invoke(
5743
5882
  "create-shared-prompt-version",
5744
5883
  payload,
5745
5884
  { idempotencyKey: idempotencyKeyFor("create-shared-prompt-version", payload) }
5746
5885
  );
5747
- setNewContent("");
5886
+ draft.setContent("");
5748
5887
  await refresh();
5749
5888
  } catch (err) {
5750
5889
  setCreateError(describeInvokeError(err));
@@ -5752,7 +5891,7 @@ function VersionsPanel({ name, canWrite, onClose }) {
5752
5891
  setIsCreating(false);
5753
5892
  }
5754
5893
  }
5755
- return /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.SidePanel, { open: true, onClose, title: name, description: "Ressource commune \xE0 l'entreprise \u2014 toute nouvelle version s'applique \xE0 toutes les apps qui utilisent ce prompt.", children: [
5894
+ return /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.SidePanel, { open: true, onClose, title: name, description: "Ressource commune \xE0 l'entreprise \u2014 toute nouvelle version s'applique \xE0 toutes les apps qui utilisent ce prompt.", className: PROMPT_PANEL_CLASS, children: [
5756
5895
  /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-testid": "shared-prompt-versions", className: "flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto", children: [
5757
5896
  error !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive", children: "Erreur lors du chargement des versions." }),
5758
5897
  versions.length > 0 && !hasActiveVersion && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "rounded-md border border-status-warning/40 bg-status-warning/10 p-2 text-sm text-status-warning", children: "Aucune version active \u2014 aucune version ne porte le label \xAB production \xBB." }),
@@ -5768,34 +5907,35 @@ function VersionsPanel({ name, canWrite, onClose }) {
5768
5907
  }
5769
5908
  ),
5770
5909
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
5771
- sorted.map((v) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-md border p-3", children: [
5772
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
5773
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-sm font-medium", children: [
5774
- "v",
5775
- v.version,
5776
- " ",
5777
- v.label && /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Badge, { variant: "brand", children: v.label })
5778
- ] }),
5779
- canWrite && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2", children: [
5780
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", size: "sm", onClick: () => setPromotingVersion(v.version), children: "Promouvoir" }),
5781
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { variant: "outline", size: "sm", onClick: () => setDeletingVersion(v.version), children: "Supprimer la version" })
5782
- ] })
5783
- ] }),
5784
- /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "mt-1 text-xs text-muted-foreground", children: [
5785
- "Cr\xE9\xE9e le ",
5786
- formatDate(v.createdAt)
5787
- ] }),
5788
- /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "mt-2 whitespace-pre-wrap text-xs text-muted-foreground", children: v.content })
5789
- ] }, v.version)),
5910
+ sorted.map((v) => /* @__PURE__ */ jsxRuntime.jsx(
5911
+ VersionCard,
5912
+ {
5913
+ version: v,
5914
+ defaultOpen: v.version === expandedVersion,
5915
+ onEditFrom: canWrite ? () => draft.prefill(v.content) : void 0,
5916
+ onPromote: canWrite ? () => setPromotingVersion(v.version) : void 0,
5917
+ onDelete: canWrite ? () => setDeletingVersion(v.version) : void 0
5918
+ },
5919
+ v.version
5920
+ )),
5790
5921
  sorted.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Aucune version pour l'instant." })
5791
5922
  ] }),
5792
5923
  canWrite && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2 border-t pt-3", children: [
5793
5924
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: newVersionId, className: "block text-sm font-medium", children: "Nouvelle version" }),
5794
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Textarea, { id: newVersionId, value: newContent, onChange: (e) => setNewContent(e.target.value), rows: 8 }),
5925
+ /* @__PURE__ */ jsxRuntime.jsx(
5926
+ PromptTextarea,
5927
+ {
5928
+ id: newVersionId,
5929
+ ref: draft.editorRef,
5930
+ value: draft.content,
5931
+ onChange: (e) => draft.setContent(e.target.value)
5932
+ }
5933
+ ),
5795
5934
  createError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive", children: createError }),
5796
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { onClick: () => void runCreateVersion(), disabled: newContent.trim() === "" || isCreating, children: isCreating ? "Cr\xE9ation\u2026" : "Cr\xE9er la version" })
5935
+ /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Button, { onClick: () => void runCreateVersion(), disabled: draft.content.trim() === "" || isCreating, children: isCreating ? "Cr\xE9ation\u2026" : "Cr\xE9er la version" })
5797
5936
  ] })
5798
5937
  ] }),
5938
+ draft.pendingPrefill !== null && /* @__PURE__ */ jsxRuntime.jsx(ReplaceDraftConfirmModal, { onConfirm: draft.confirmPrefill, onCancel: draft.cancelPrefill }),
5799
5939
  promotingVersion !== null && /* @__PURE__ */ jsxRuntime.jsx(
5800
5940
  ConfirmModal,
5801
5941
  {
@@ -5880,7 +6020,7 @@ function NewSharedPromptModal({ onClose, onCreated }) {
5880
6020
  setIsCreating(false);
5881
6021
  }
5882
6022
  }
5883
- return /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Modal, { open: true, onClose, title: "Nouveau prompt partag\xE9", children: /* @__PURE__ */ jsxRuntime.jsxs("form", { className: "space-y-3", onSubmit: (e) => void handleSubmit(e), children: [
6023
+ return /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Modal, { open: true, onClose, title: "Nouveau prompt partag\xE9", className: "max-h-[85vh] max-w-2xl overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("form", { className: "space-y-3", onSubmit: (e) => void handleSubmit(e), children: [
5884
6024
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
5885
6025
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: nameId, className: "mb-1 block text-sm font-medium", children: "Nom" }),
5886
6026
  /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Input, { id: nameId, value: slug, onChange: (e) => handleSlugChange(e.target.value), placeholder: "tone-of-voice" }),
@@ -5892,7 +6032,7 @@ function NewSharedPromptModal({ onClose, onCreated }) {
5892
6032
  ] }),
5893
6033
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
5894
6034
  /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: contentId, className: "mb-1 block text-sm font-medium", children: "Contenu" }),
5895
- /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Textarea, { id: contentId, value: content, onChange: (e) => setContent(e.target.value), rows: 8 })
6035
+ /* @__PURE__ */ jsxRuntime.jsx(PromptTextarea, { id: contentId, value: content, onChange: (e) => setContent(e.target.value), rows: 12 })
5896
6036
  ] }),
5897
6037
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: "La premi\xE8re version est activ\xE9e imm\xE9diatement (production)." }),
5898
6038
  error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive", children: error }),
@@ -5943,7 +6083,7 @@ function SharedPromptsPage() {
5943
6083
  empty: "Aucun prompt \xAB shared/* \xBB accessible depuis cette app."
5944
6084
  }
5945
6085
  ),
5946
- selected && /* @__PURE__ */ jsxRuntime.jsx(VersionsPanel, { name: selected, canWrite, onClose: () => setSelected(null) }),
6086
+ selected && /* @__PURE__ */ jsxRuntime.jsx(VersionsPanel, { name: selected, canWrite, onClose: () => setSelected(null) }, selected),
5947
6087
  isCreateOpen && /* @__PURE__ */ jsxRuntime.jsx(
5948
6088
  NewSharedPromptModal,
5949
6089
  {