Repository navigation
fix(prompt-templates): merge a template into the prompt and copy from the merged view - #10427
Conversation
…lected A click in the read-only merged view used to return to editing, so the template's words could not be dragged over and copied. A click now leaves the view only when the gesture selected nothing; the positive and negative prompt boxes share the rule.
… merged view The merged view turned Add prompt trigger off by marking it open, which set aria-expanded and painted it pressed. It is now a disabled button in both prompt boxes.
…plates popover The popover's header names the applied template and holds Preview, Merge into prompt and Stop using; the toolbar's eye button is gone and the Templates button shows an eye while the merged view is on. Merge writes the merged text into the prompt and negative prompt, stops using the template and offers an Undo; Generate reads the negative prompt after flushing drafts. The applied template's name shrinks before the toolbar's other actions in a narrow panel.
Pfannkuchensack
left a comment
There was a problem hiding this comment.
Thanks, this works as described. I found no blockers. The merge goes through commitWithUndo as a whole, so one Undo restores the positive and negative prompts, the template and the view mode together. Generate now flushes its drafts before it reads the negative prompt, as Upscale already did. All the new en.json keys are used, clearApplied has no references left, and the prompting guide matches the code.
Locally tsc --noEmit and oxlint on promptFields are clean. The browser tests pass: 34 in the four changed files and 98 in all of promptFields.
Medium
The Generate merge has no test. The only merge test is in UpscaleSharedPrompt.browser.test.tsx. The fix in GeneratePromptFields.tsx (flushGenerateDrafts() and then a fresh readGenerateValues for the negative prompt) can be reverted without any test failing. Scenario: someone types in the negative prompt and clicks Merge into prompt within the debounce window. A Generate-side test that does exactly that, plus one with a template that has no negative text (the negative prompt has to stay as it is), would cover it.
Low
- Untested paths:
- Applying a second template after a merge. This works only because
promptTemplateisnullafter the merge. - The new
onExitMergedViewpath inNegativePromptField. The click logic is only tested throughPositivePromptField.
- Applying a second template after a merge. This works only because
- Leaving Preview with the keyboard now takes more steps. The eye button moved into the popover. A keyboard user has to Tab to Templates, open it and choose to go back to editing. Enter in the read-only textarea fires no click. That is acceptable, and focus does return to the prompt, but the one-Tab toggle is gone.
Nits
flattenPromptTemplateflushes the drafts twice: once explicitly and again insidecommitWithUndo. It is harmless.- Re-dragging exactly the same range in the merged view also leaves Preview, because
handleClickonly compares the selection with the one at mousedown.
Not checked: Firefox/WebKit, touch long-press selection, and long translated labels in the popover header.
… a template without negative text Merging such a template appended a trailing space to the negative prompt; it now leaves it unchanged, as the merged view shows it. Covers Generate's merge reading negative-prompt typing the debounce still holds, and regenerates the docs search index for the prompting guide.
|
Thanks for the review. Addressed in 1e1540c. Medium: Generate merge test. Added to The no-negative-text case you suggested turned up a bug: The commit also regenerates Low and nits, left as is:
Checked on macOS: |
This comment has been minimized.
This comment has been minimized.
…n it The virtualized list mounts before it measures its viewport, so on a slow runner the test read the list while it held no rows.
Pfannkuchensack
left a comment
There was a problem hiding this comment.
Rechecked 1e1540c and f3de08e. The new Generate test covers the Medium: negative typing still held by the debounce ends up in the merged prompt. A template without negative text now leaves the negative prompt as typed, and a unit test covers it. The notifications test now waits for a real row, and CI is green. Approving.
The two untested paths from my last comment (a second template after a merge, onExitMergedView in the negative field) are still open. They don't block this.
Summary
User feedback: in the legacy UI you could copy a template's text into the prompt box, then edit it or stack another template on top. Here you could only look at the merged prompt, and clicking it anywhere left the view.
Related Issues / Discussions
User feedback; no GitHub issue.
QA Instructions
In Generate (the Upscale panel's Detail guidance shares the same field):
Toolbar with a template applied:
Templates popover with the applied template's header:
Merged view, with the eye on the Templates button and + disabled:
Checks run locally (Node 22.14,
invokeai/frontend/webv2),pnpm check:release:src/platform/ui/Menu.browser.test.tsx(a pointer-hover timeout in a file this PR does not touch); that file passes 25/25 when run alone.Manually exercised in headless Chromium against the mock backend, Generate panel only. Not checked by hand: Firefox and WebKit, touch input, long or translated button labels wrapping in the popover header, and the Upscale panel (covered by
UpscaleSharedPrompt.browser.test.tsx).Review
Resolved: a click on already-selected text did not return to editing (the browser collapses the selection only after the click); the Generate merge could overwrite very recent negative-prompt typing; the Templates button could shrink below its icon; the popover's actions did not name the template for assistive technology; merge had no Undo coverage.
Remaining limits:
Checklist
What's Newcopy (if doing a release after this PR)Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.