Repository navigation
fix(chat): let the user cancel an in-flight prompt optimize - #20004
Conversation
|
chore (non-blocking): please add the |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns. The abort handle is threaded through the existing mutation, the cancelled and late-result paths are dropped in onError and onSuccess, and the three committed screenshots cover the new control. Notes
[DESIGN-REVIEWED] 20f15ac Description read[DESCRIPTION-READ] 5c37bcbb0366f9035049e7916b1ca3ecb600bc365bfa0355e0018c4782448398 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
UX Review (Opus 5.5, fork) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing blocks. The committed screenshots show the desktop X, the mobile "Cancel" chip and the editable draft after cancel. This fork lane has no blind read, so nobody has cold-read these controls; pushing the branch to this repository runs that pass. [UX-REVIEWED] 20f15ac Description read[DESCRIPTION-READ] af367fc640f1f158f3edc4c2c9895140d696d89b64f9e3d7cba5ddfcbf1d8f15 That sha256 names everything this verdict read: the PR description, plus the 6 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing to check. Every item traces to #20003 or #22471. The abort mechanism is new: there was no What this change shipsInventory (9 items) — 9 justifiedIntent: a user who taps "Optimize prompt" by mistake can cancel it and get their draft back, editable, straight away. FIX.
[FIRST-PRINCIPLES-REVIEWED] 20f15ac Description read[DESCRIPTION-READ] 58bdd1288d43f2577851de3164ebe4835a99158eec17464bdcf30f00651c423a That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
c0c6dc6 to
1d79a43
Compare
|
issue (non-blocking): focus does not return to the composer after Cancel
|
|
thought (non-blocking): icon-only X with no first-time reader
|
|
suggestion (non-blocking): let Escape cancel while optimizing
|
|
chore (non-blocking): cross-session restore in the onError cancel branch is unreachable
|
|
issue (non-blocking): focus is lost after Cancel
|
|
note: answer to the Design punchline that a Cancel after resp.json() could still write the rewrite
|
|
chore (non-blocking): please rerun five checks on head 1d79a43. The fork account cannot rerun them because that needs admin rights. None of the five reached this PR's code:
|
1d79a43 to
b62a4fe
Compare
|
thought (non-blocking): the X may read as "dismiss and lose the draft" Not changing in this PR. Tapping the X does not discard anything: |
|
suggestion (non-blocking): visible "Cancel" text next to the X on touch screens Deferred to a follow-up. A visible label adds a new string to all 13 locale files and changes the pill's width on phones, so it needs fresh mobile screenshots and its own review. This PR fixes the mis-tap trap in #20003 with the smallest control that works, and the X already carries |
|
note: Rebased on main, no behaviour change. Head 81bdc23 replaces 01bff80. The rebase applied with no conflicts. Main had gained 18 commits, one of them in |
01bff80 to
81bdc23
Compare
|
thought (non-blocking): Escape does not cancel an optimize Not changing in this PR, same answer as at c0c6dc6, f68efb0 and 200c33b. The bug in #20003 is a phone mis-tap. Escape in the composer already routes to the mention and slash menus, so making it cancel an optimize needs its own precedence rule and tests. It is listed as a follow-up. |
|
thought (non-blocking): light theme is not shown Accepting the gap for this PR. The X uses the same |
|
suggestion (non-blocking): tooltip repeats the aria-label Keeping the tooltip. An earlier UX review on this PR asked to keep it so a mouse user can confirm what the X stops before clicking, and the two strings are the same on purpose so screen-reader and pointer users get one name for the action. |
|
question: Could a maintainer post a UX override for head 81bdc23? This fork account has no write access, so its CI is green and the label is /ai-review override ux 81bdc23: advisory UX items answered on the PR; Escape-to-cancel and a visible touch label with a light-theme still are deferred to a follow-up, none affects the #20003 fix. |
iamwhatever
left a comment
There was a problem hiding this comment.
Requesting changes on 81bdc23 for follow-up tracking only.
The cancel path is sound. Each request gets its own AbortController, an aborted signal makes onSuccess and onError return early, and cancelOptimize refocuses inside the tap while keeping a disabled host locked (
KiroCrew/website/src/components/chat-input/optimizer.ts
Lines 287 to 305 in 81bdc23
Your UX dispositions defer two items to a follow-up, but no issue tracks them:
- Escape on the composer cancels an in-flight optimize, with a precedence rule against the mention and slash menus.
- A visible Cancel label on touch screens, with fresh mobile and light-theme screenshots.
Please open one issue for each and link both in the description. Also update the description's What changed: the coarse-pointer size is now set in website/src/styles/chat-transcript.css, not website/src/index.css.
— crew-pr-reviewer (r112)
|
todo (non-blocking): follow-up tracking and the stale CSS path, both done Both deferred UX items now have issues, linked under Related Issues in the description:
They are on the fork because this account opens upstream issues only together with the PR that fixes them; each will be filed upstream with its PR. What changed now names |
|
Filed the two follow-up issues requested in the last review, since both are now trackable:
I don't have write access to this fork PR to edit the description directly, so here's the corrected text for the two spots @iamwhatever flagged — @Pearcekieser, could you apply these? Related Issues section, replace the two fork-local links with: ## Related Issues
Follow-ups deferred from this PR's UX review, now tracked on this repo:
- Escape cancels an in-flight optimize, with a precedence rule against the mention and slash menus: https://github.com/kirodotdev/KiroCrew/issues/22470
- Visible Cancel label on touch screens, with fresh mobile and light-theme screenshots: https://github.com/kirodotdev/KiroCrew/issues/22471What changed section, the sentence naming the coarse-pointer CSS file should read:
(dropping the stale @iamwhatever once those two land, could you take another look? Everything else in CI is green and all AI review lanes passed on the current head. |
|
note: Thanks @RohanK6. Related Issues now links #22470 and #22471 in place of the fork-local issues, which I've closed as duplicates. The coarse-pointer sentence in What changed already named |
|
note: Head fbf3971 is rebased on main and adds the visible touch Cancel. Pearce hit the missing control again on iPhone Safari on 2026-10-24. His installation runs main, which has no cancel control at all. The icon-only X in this PR also gave touch users nothing to read, because there is no tooltip on touch. Under |
|
question: Could a maintainer approve the 20 workflow runs held as |
|
note: Head 20f15ac fixes the one failure on fbf3971. Frontend Tests (3) failed |
|
@iamwhatever could you re-review at 20f15ac? Your r112 change request asked for follow-up tracking and a CSS path fix. Both are in: the description names |
iamwhatever
left a comment
There was a problem hiding this comment.
APPROVE at 20f15ac.
The cancel path is sound. Each optimize gets its own AbortController, and an aborted signal makes onSuccess and onError return early, so a late rewrite is dropped and no error notice shows (optimizer.ts#L128, L159). cancelOptimize refocuses inside the tap and keeps a disabled composer locked, which also covers the memory-mode draft lock (L286-L305).
Our r112 change request is met. Escape-to-cancel is tracked in #22470, the touch label from #22471 now ships here, and the description names website/src/styles/chat-transcript.css. Every AI lane passes on this head, every earlier finding has a disposition, and all checks are green.
Non-blocking: #22471 will stay open after merge because the description has no closing line for it. Add Closes #22471 or close it by hand. The fork UX lane had no blind cold-read of the new controls.
I read the code, tests and screenshots but did not run them.
— crew-pr-reviewer (r124)
Problem / Motivation
Goal: A user who starts "Optimize prompt" by mistake can cancel it and get their draft back, editable, right away.
On a phone the Optimize prompt button sits next to Send, so a mis-tap is common. While the optimize runs, the composer is read-only, Send is disabled, and the "Optimizing prompt..." overlay covers the input with no control on it. The only way out is to wait for
/api/optimizer/optimizeto answer, and if the request is slow or hangs, the composer stays locked.Why it matters
Anyone on the mobile dashboard who hits the sparkle instead of Send loses the composer until the optimizer returns. They cannot fix a typo, send what they wrote, or back out. Desktop users hit the same dead end when the optimizer is slow, though a mis-tap there is less likely.
Not a goal
What changed (motivation → approach → change)
The overlay showed no control and the request had no abort handle, so nothing could end the optimize early. In
website/src/components/chat-input/optimizer.ts,optimizePromptnow creates anAbortControllerper request and passes its signal through the mutation variables intofetch. A newcancelOptimizeaborts it.onErrorchecksvariables.signal.aborted. When it is set, it shows no error notice and writes nothing back, because the draft was read-only and unchanged for the whole request. The settled mutation clearsoptimizing, which drops the overlay and the read-only flag and enables Send again.onSuccessalso checks the signal, so a rewrite whose body was already read when Cancel landed is dropped instead of replacing the draft.cancelOptimizeputs focus back in the composer with the caret at the end, inside the tap. The Cancel button unmounts with the overlay, and a phone raises its keyboard only for a focus made during the user's gesture. Read-only has not been cleared by React yet at that point, so the handler clears it on the element first:readOnly = falseon the textarea,contentEditable = 'true'on the Lexical root. A non-editable Lexical root takes no focus at all, which a jsdom test confirmed on the earlier version of this change. When the host has setdisabledmeanwhile, both stay locked. The textarea keepsreadOnly, becausereadOnly={optimizing || disabled}stays true and React never rewrites it. The Lexical root stays non-editable, because Lexical'ssetEditable(false)does nothing on an editor that is already non-editable and would never undo the DOM write.In
website/src/components/ChatInput.tsx, the overlay pill now has an X button. It is the only element in the overlay that takes pointer events, and it carries the label "Cancel optimizing". With a mouse it is a 28 px icon with a "Cancel optimizing" tooltip. Underpointer: coarse, where there is no tooltip,website/src/styles/chat-transcript.cssturns it into a 44 px tall chip that shows the word "Cancel" next to the X, so a phone user can see what it does and hit it.css, so a finger can hit it. The button shows on every viewport, because the same lock happens on desktop when the optimizer is slow. The new stringscomponents.chatInput.cancel_optimizingandcancel_optimizing_shortare inen.manual.jsonand all 11 shipped locales (the short label reuses each locale's existing confirm-dialog "Cancel"), anden-XA` was regenerated.Backwards compatibility
Compatible: the optimizer request, its result handling and its error notice are unchanged unless the user presses the new button.
Removes nothing: the change only adds a button, an abort signal and one catalog key.
Tests
website/src/test/ChatInput.optimizeCancel.test.tsxholds the optimizer request open until it is aborted, clicks Optimize, then clicks "Cancel optimizing". It asserts that the request's signal is aborted, the textarea is writable again, the overlay and its button are gone, nooptimize-errornotice shows,onChangewas never called, and Optimize is enabled again. It fails onmain, where the overlay has no such button. Five more tests in the same file cover the review fixes, and each fails without its fix. One checks that focus and the caret return to the textarea. One checks that the Lexical root is editable whenfocus()is called and ends up focused. One checks that a rewrite read before Cancel is dropped. Two check that a host-disabled composer stays locked after Cancel: the Lexical root keepscontenteditable="false"and the textarea keepsreadOnly. The existingoptimizeWritebackandoptimizeSlotContexttests still pass.website/playwright/optimize-cancel-mobile.spec.tschecks in a real browser, which jsdom cannot, at 390x844 and at 390x480 (the height left above a soft keyboard) with touch. The overlay shows a Cancel button with the visible "Cancel" label, fully inside the viewport, at least 44x44 CSS px, and a hit test at its centre lands on it. A tap gives back the same draft, editable. A desktop case checks the 28 px icon-only X. The phone cases fail with the label rule removed.Manual verification
website/scripts/capture-optimize-cancel.mjsruns the built app in a 390x844 touch viewport with the dashboard API stubbed and the optimizer request never answered. It types a draft, taps Optimize, checks that exactly one optimize request went out, and measures the Cancel button at 44x44 CSS px. Then it taps Cancel, checks that the composer is no longer read-only, and types more text into it.Screenshots / video
Mobile, 390x844 with touch. The overlay with the labelled 44 px Cancel chip while the optimize runs, then the editable draft after the tap.
Desktop, 1280x800 with a mouse pointer. The 28 px Cancel inside the overlay pill.
Related Issues
Follow-ups deferred from this PR's UX review, tracked on this repo:
Pattern harvest
Not generalizable: this is a missing control on one overlay, not a code pattern a rule could catch.
Checklist
Fixes #20003