feat(ui-rewrite): add prompt edit flow and fix prompt form/card UI#5675
feat(ui-rewrite): add prompt edit flow and fix prompt form/card UI#5675marekdano wants to merge 3 commits into
Conversation
|
Tested and it seems to work as expected 🙌 LLM feedback on a potentially blocking issue: Federated prompt edits to description / title / visibility get silently clobbered on next federation refresh. gateway_service._process_gateway_prompts (gateway_service.py:5493-5527) overwrites description, template, argument_schema, title, and (with update_visibility=True) visibility back to upstream on every re-sync. This means an user edits a federated prompt's description, sees the success toast, then loses the change the next time the gateway polls. tags, custom_name, display_name, and team_id are preserved, so those edits are safe. |
|
@a-effort - thanks for testing this and for the sharp catch on the federation clobber — I dug into it and you're right, so I've reworked the federated edit behaviour. Confirmed the finding. Which fields actually persist across re-sync: What I changed in this PR (frontend-only):
Added unit + Playwright coverage for the federated case (disabled fields + notice, plus a rename round-trip) |
| teamId?: string; | ||
| } | ||
|
|
||
| export interface PromptFormInitialValues { |
There was a problem hiding this comment.
Could we omit description, template, and arguments entirely when editing a federated prompt? Disabling these inputs prevents user interaction, but getUpdateData() still submits their prefilled values. A rename, visibility, or tag-only edit can therefore overwrite newer upstream data with stale form state; a null template is also converted to "". Please add coverage asserting these properties are absent from federated PUT payloads.
There was a problem hiding this comment.
Good catch! You're right that disabling the inputs didn't stop getUpdateData() from still submitting their prefilled values, so a name/visibility/tag-only edit could overwrite newer upstream data (and null template → "").
Fixed: the form now passes a federated flag to usePromptForm, and getUpdateData() omits description, template, and arguments entirely for federated prompts — only name, visibility/team, and tags are sent. Added coverage asserting those properties are absent from the federated PUT payload (usePromptForm.test.ts and PromptForm.test.tsx, plus the federated edit case in e2e/prompts.spec.ts).
| const { prompt } = schema.parse(getFormValues()); | ||
| return { | ||
| name: prompt.name, | ||
| description: prompt.description ?? null, |
There was a problem hiding this comment.
An empty description becomes null here, but the backend update service treats null as “field not provided” and only updates descriptions when the value is non-null. The request succeeds while the old description remains. Could we use an explicit supported clear value/operation and add a regression test that edits a non-empty description to empty?
There was a problem hiding this comment.
Agreed — the update service only writes the description when it's non-null (prompt_service.py), so an empty description was silently a no-op.
Fixed: for local prompts an empty description is now sent as "" (explicit clear) rather than null. Added a regression test that edits a non-empty description to empty and asserts the PUT carries description: "".
Signed-off-by: Marek Dano <Marek.Dano@ibm.com>
…t form for federated prompts only Signed-off-by: Marek Dano <Marek.Dano@ibm.com>
…pdates Signed-off-by: Marek Dano <Marek.Dano@ibm.com>
5e1dad7 to
d9abae2
Compare
Summary
Enable editing prompts from the details panel and fix related form, card, and team-scoping issues surfaced along the way.
Features
Edit a prompt from the details panel
promptsApi.update(id, data)→PUT /prompts/{id}(validated + encoded id)usePromptFormaccepts{ promptId?, initialValues?, templateRequired? }; with apromptIdit updates via PUT instead of creating, tracksisUpdating, keeps the form on success, and uses theprompts.edit.errorfallbackPromptFormgains apromptprop → edit mode: prefilled fields (arguments → JSON, tags joined), "Edit prompt" heading, "Save changes" buttonCancel/Back returns to the Definition tab
PromptDetailsPanelinitialTabprop, honored on openTemplate required only for REST prompts
prompts/get); the required asterisk andaria-requiredfollow thisFixes
titletooltip so the full name stays discoverable on hover.teamprompt keeps its own team (seeded fromprompt.teamId) — no longer blocked without a sidebar selection or reassigned to a different selected team. Create-mode unchanged.i18n
Added
prompts.edit.{pageTitle, button.submit, success, error}to en-US, es-ES, and pt-BR.Tests
initialTab, cancel→Definition, template required vs optional-for-federated, and team-preservation on edit.e2e/prompts.spec.ts— truncation, create, edit + see update, preview (Try it tab), add tag; plus truncation tests added totools.spec.tsandresources.spec.ts.