发布

  • [OPIK-5772][FE]: remove prompts and update blueprints for v2; (#6237)

    frostbyte_neo 发布于 2026-04-15 15:16:09 +00:00

    • [OPIK-5772]: remove prompts from nav;

    • [OPIK-5772] [FE] Add BlueprintPromptsSelectBox for playground

    Selector that lists PROMPT-typed values from a project's latest
    agent configuration blueprint, returning a {blueprintId, key, commitId}
    ref for downstream loading. Will replace PromptsSelectBox in the
    playground in a follow-up.

    Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

    • [OPIK-5772] [FE] Support blueprint prompt refs in useLoadChatPrompt

    Adds BlueprintPromptRef type and an optional loadedBlueprintRef field
    on PlaygroundPromptType. useLoadChatPrompt now branches on whether a
    blueprint ref is provided and resolves via usePromptByCommit, keeping
    the existing prompt-library codepath intact for v1 and Optimizations
    callers.

    Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

    • [OPIK-5772] [FE] Hydrate playground metadata via blueprint commit

    Adds useFetchPromptByCommit and a blueprint-ref branch to v2
    useHydratePromptMetadata so that prompts loaded from agent config
    blueprints get their PromptLibraryMetadata resolved through the
    pinned commit instead of the (no-longer-set) prompt library ID.

    Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

    • [OPIK-5772] [FE] Accept blueprintRef in v2 useLoadPlayground

    Threads an optional BlueprintPromptRef through LoadPlaygroundOptions
    and createPromptFromContent so navigations into the playground that
    originate from an agent configuration set loadedBlueprintRef on the
    new playground prompt.

    Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

    • [OPIK-5772] [FE] Wire blueprint prompt selector into v2 playground

    Replaces PromptsSelectBox in v2 PlaygroundPrompt with the new
    BlueprintPromptsSelectBox: prompts are now sourced from the project's
    latest agent configuration blueprint and pinned by commit. The save
    flow refreshes loadedBlueprintRef with the new commit and invalidates
    the agent config cache so the selector reflects the auto-updated
    blueprint.

    Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

    • [OPIK-5772] [FE] Refactor: split blueprint loading into its own hook
    • Reverts useLoadChatPrompt to its original library-only form (kept
      unchanged for v1 playground and Optimizations callers).
    • Introduces useLoadBlueprintPrompt, a focused hook that resolves a
      prompt by blueprint commit ref with a small, single-purpose API.
    • v2 PlaygroundPrompt switches to the new hook and extracts the
      save-version handler out of the JSX.
    • Tightens useHydratePromptMetadata by extracting the chat-template
      comparison helper.
    • BlueprintPromptsSelectBox: extracts the loaded-state subview.

    No behavior change.

    Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

    • [OPIK-5772] [FE] Fix: fetch full blueprint to populate playground selector

    The blueprints/history endpoint returns a summary that omits PROMPT-typed
    values, so the dropdown was always empty. Mirror AgentConfigurationDetailView
    by reading the latest blueprint id from the history list and then loading
    the full blueprint via useAgentConfigById to filter PROMPT values.

    Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

    • [OPIK-5772] [FE] Replace library save flow with config-aware save dialogs

    Drops AddNewPromptVersionDialog from the playground prompt and
    replaces it with two focused dialogs:

    • SaveExistingPromptDialog: shown when the prompt was loaded from a
      blueprint. Asks for an optional change description and saves a new
      prompt version. The backend auto-publishes a new blueprint version
      pinning the new commit.

    • SaveAsNewBlueprintFieldDialog: shown when no blueprint prompt is
      loaded. Asks for a single field name (used for both the prompt name
      and the blueprint key), then creates the prompt and publishes a new
      blueprint version that appends the new PROMPT-typed value alongside
      all existing values. If the project has no blueprint yet, it creates
      the first one with this single value.

    Save logic lives in useSavePromptToBlueprint, which centralizes the
    prompt + blueprint mutations and cache invalidation.

    Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

    • [OPIK-5772] [FE] Use POST for first-time config creation, PATCH for updates

    Adds useAgentConfigPostMutation (POST /blueprints) and uses it in
    useSavePromptToBlueprint when the project has no agent configuration
    yet. PATCH (the existing useAgentConfigCreateMutation) is used to
    append a new field to an existing configuration.

    Backend: POST creates and 409s if a config already exists; PATCH
    updates and 404s if there's no config. The choice is driven by whether
    useAgentConfigById returned a blueprint for the project.

    Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

    • remove prompts from v2;

    • [OPIK-5772] [FE] Always send full value set when patching agent config

    The PATCH payload now includes every value from the loaded blueprint
    instead of only changed ones. PROMPT-typed entries use the newly
    created commit if one was saved this round, otherwise the existing
    commit; scalar entries use the draft value if edited, otherwise the
    original. This makes the new blueprint version self-contained rather
    than a delta over the previous version.

    Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

    • [OPIK-5772] [FE] Add/remove fields while editing an agent configuration
    • Each existing field gets a Remove/Restore action; removed fields are
      visibly marked and omitted from the saved blueprint version.
    • New "Add field" button appends a NewBlueprintFieldEditor row that
      captures key, type (string/integer/float/boolean/prompt) and an
      initial value (a system-message starter for prompts).
    • useAgentConfigurationSave now validates new fields (key format,
      uniqueness against current and sibling keys), materializes new
      PROMPT fields by creating brand-new prompts via
      usePromptCreateMutation, and builds a payload that omits removed
      keys and appends new entries.
    • The diff dialog reflects the resulting set of values.

    Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

    • [OPIK-5772] [FE] Use a chat editor when adding new prompt fields

    Replaces the single textarea in NewBlueprintFieldEditor with the
    shared LLMPromptMessages editor when type === PROMPT, so users can
    add multiple roles and messages just like everywhere else in the app.
    The new field draft now carries a messages: LLMMessage[] field that
    is serialized to a chat template at save time.

    Validation requires at least one non-empty message before saving.

    Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

    • [OPIK-5772] [FE] Show added/removed prompts in agent config diff view
    • AgentConfigurationEditView snapshots in-memory messages for new
      PROMPT fields into diffPromptTemplates so the diff dialog has
      content to render (those prompts have no commit yet).
    • BlueprintDiffRow uses PromptDiffPair when either side has a value
      or a snapshotted template, instead of requiring both sides.
    • PromptDiffPair renders a side from a template even when the
      corresponding commit is empty, and only shows the commit tag when
      one exists.

    Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

    • [OPIK-5772] [FE] Inline value validation for new blueprint fields

    Extracts the per-type field schemas into blueprintFieldValidation and
    runs them while editing a new field, so users see "Must be an
    integer" / "Must be a valid number" / etc. as soon as they type
    instead of only at save time. PROMPT fields show "Add at least one
    message" or "Messages must not be empty" inline once they are dirty.

    Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

    • [OPIK-5772] [FE] Refactor agent config save pipelines for clarity

    useAgentConfigurationSave: split the 130-line validateAndBuildPayload
    monolith into four small, single-responsibility callbacks:
    collectValidationErrors, saveDirtyPromptVersions, materializeNewFields,
    and buildBlueprintValues. The orchestrator is now a short, linear
    read. validateNewField uses .every() for the empty-message check and
    returns the value-validation result directly instead of via a
    temporary.

    useSavePromptToBlueprint: tightens types (drops the
    UseSavePromptToBlueprintReturn indirection on each callback), inlines
    the saving guards, and renames stripValueForPayload to
    stripBlueprintValue for accuracy.

    No behavior change.

    Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

    • [OPIK-5772] [FE] Load/save config prompts in optimization studio

    Adds agent-config blueprint prompt support to the v2 new-optimization
    page:

    Load: BlueprintPromptsSelectBox next to the "Prompt" label lets users
    pick a PROMPT field from the project's latest agent config. Selecting
    resolves the commit via usePromptByCommit and populates the messages
    editor. Clearing detaches without losing edits.

    Save: A save button next to the selector opens
    SaveExistingPromptDialog (if a config field is loaded) or
    SaveAsNewBlueprintFieldDialog (if not). Both delegate to
    useSavePromptToBlueprint for the prompt + blueprint mutations.

    All state (BlueprintPromptRef, commit dedup, template serialization)
    lives in useOptimizationsNewFormHandlers, passed to the prompt section
    as props.

    Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

    • [OPIK-5772] [FE] Code review fixes: centralize pattern, safer access
    • Centralizes BLUEPRINT_FIELD_NAME_PATTERN into blueprintFieldValidation
      (was duplicated across NewBlueprintFieldEditor, SaveAsNewBlueprintFieldDialog,
      and useAgentConfigurationSave).
    • Adds optional chaining + fallback in validateBlueprintFieldValue to
      guard against an empty issues array.
    • Removes non-null assertion on text! in BlueprintDiffRow renderCell;
      checks for undefined instead.

    Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

    • [OPIK-5772] [FE] Show unsaved-changes indicator on optimization prompt

    Adds hasUnsavedBlueprintChanges to the optimization new page: compares
    the current form messages against the loaded commit template and passes
    the flag to BlueprintPromptsSelectBox, which shows its orange dot when
    the prompt has been edited since loading from config.

    Also tightens the gap between the Prompt label, config selector, and
    save icon from gap-1 to gap-0.5.

    Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

    • [OPIK-5772] [FE] Per-message TEXT prompt load/save from agent config

    Adds message-level blueprint prompt support: each message in the
    LLMPromptMessages editor can individually load and save TEXT-typed
    prompts from the project's agent configuration.

    • Adds MessageBlueprintRef to LLMMessage type (parallel to promptId).
    • Rewrites v2 LLMPromptMessageActions to use BlueprintPromptsSelectBox
      instead of PromptsSelectBox, resolving TEXT commits via
      usePromptByCommit and tracking unsaved changes.
    • Save uses SaveExistingPromptDialog / SaveAsNewBlueprintFieldDialog
      via useSavePromptToBlueprint, same as the chat-level flow.
    • Removes the now-unused onReplaceWithChatPrompt and
      onClearOtherPromptLinks props from the v2 message components.
    • Adds onOpenChange prop to BlueprintPromptsSelectBox for the
      hold-actions-visible pattern.

    Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

    • [OPIK-5772] [FE] Filter config prompts by template structure (CHAT/TEXT)

    BlueprintPromptsSelectBox now accepts a filterByTemplateStructure
    prop. When set, it resolves every PROMPT-typed commit in parallel via
    useQueries and filters the dropdown to only show prompts matching the
    requested structure.

    Call sites:

    • Playground + optimization chat-level selector: CHAT only
    • Per-message selector (LLMPromptMessageActions): TEXT only

    This prevents chat prompts from appearing in the message-level
    selector and vice versa.

    Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

    • [OPIK-5772] [FE] Clean up: deduplicate blueprint ref type, simplify actions
    • Removes MessageBlueprintRef from llm.ts (was identical to
      BlueprintPromptRef in playground.ts). LLMMessage.blueprintRef is
      now an inline type matching the same shape, removing the cast.
    • Merges the two improve-prompt button conditionals into one block
      that swaps the icon based on hasContent.
    • Removes redundant object spread in handleSaveNewField — newRef
      already matches the expected shape.

    Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

    • [OPIK-5772] [FE] Remove autogenerated blueprint descriptions

    Removes generateBlueprintDescription and its "Changed x to y"
    fallback from the agent configuration detail view and history
    timeline. The description line is now only shown when the user
    explicitly entered one in the save dialog.

    Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

    • update decsription;

    • eslint;

    • [OPIK-5772] [FE] Remove autogenerated descriptions from version picker

    Missed during rebase: the version picker dropdown in
    AgentConfigurationTab also used generateBlueprintDescription.
    Replaced with conditional rendering of item.description.

    Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

    • [OPIK-5772] [FE] Extract shared serializeChatTemplate utility

    Four places independently implemented JSON.stringify(messages.map({role,content})).
    Extracted into lib/chatTemplate.ts and replaced all call sites:

    • useAgentConfigurationSave (buildChatTemplateFromMessages)
    • useLoadBlueprintPrompt (messagesToTemplate)
    • useOptimizationsNewFormHandlers (getBlueprintTemplate)
    • AgentConfigurationEditView (handleOpenSaveDialog)

    Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

    • [OPIK-5772] [FE] Save message-level prompts as TEXT, not CHAT

    useSavePromptToBlueprint now accepts an optional templateStructure
    parameter (defaults to CHAT for backward compatibility).

    LLMPromptMessageActions passes PROMPT_TEMPLATE_STRUCTURE.TEXT and
    saves the raw text content (via getTextFromMessageContent) instead
    of a JSON-wrapped messages array. This ensures per-message prompts
    are stored as TEXT-typed prompts in the library, while the whole-
    prompt-level save (playground, optimization) continues to use CHAT.

    Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

    • [OPIK-5772] [FE] Fix: explicitly publish blueprint when saving prompt version

    saveExistingVersion was only creating a new prompt version and
    assuming the backend would auto-publish a new blueprint. It doesn't.
    Now after creating the version, it explicitly PATCHes (or POSTs if
    no config exists) the blueprint with the full set of values, replacing
    the old commit for the updated key.

    Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

    • fixes;

    • code improvements;

    • eslint fixes + buz fixes;

    • fix a bug with description;

    • dependency fixes;

    • review fixes;

    • fix conflicts resoved not well;

    • disable editing for non latest versions;

    • review comments;

    • eslint fixes;

    • update styles;

    • add field update;

    • fix test;


    Co-authored-by: aadereiko aliaksandr@comet.com
    Co-authored-by: Claude Opus 4.6 (1M context) noreply@anthropic.com

    下载附件