Repository navigation
feat(app-sdk): give ChatEmbed a stop button for a running turn - #19898
Conversation
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that ChatPane's stop tests ran unchanged against the shared Suggestions
[DESIGN-REVIEWED] 69c7641 Description read[DESCRIPTION-READ] b847cc60145f7569c2721eb5584cc2c4a5775613ad8aaaa4d6e755039092f7bd 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 |
First Principles Review (Opus 5.5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The embed's new reset warning is a second wording for the same backend reset, and it disagrees with the main composer's about what survives. Not justified as shipped
What this change shipsInventory (7 items) — 6 justifiedIntent: let a user watching an embedded chat stop the running turn. This is an ADDITION.
[FIRST-PRINCIPLES-REVIEWED] 69c7641 Description read[DESCRIPTION-READ] aaf64d2608bfbecd2a8a58076e2b938311e3a46e32a5ed612671afc89107b990 That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — 🟡 CONCERNSUX-level review of UX-Verdict: CONCERNS A failed stop says "That Stop didn't go through" while the header and footer still say "Stopping…", and refusals show backend text like "crew unreachable". Watch
Suggestions
[UX-REVIEWED] 69c7641 Description read[DESCRIPTION-READ] 80e26878ffab6b4002b8612150a845e5a539456d03227ec81c75c073e6036a67 That sha256 names everything this verdict read: the PR description, plus the 34 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 |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#19898]: dispositions for the e85d05e review round, all addressed in a31309a.
|
a31309a to
e648a77
Compare
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#19898]: e648a77 answers the rest of the e85d05e/a31309a892 round.
|
e648a77 to
942cd53
Compare
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#19898]: UX round on e648a77, answered in 942cd53.
|
942cd53 to
bb64db9
Compare
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#19898]: dispositions for the lanes on Coverage Gate (red, my diff): Design + First Principles item 9 (marker): fixed in code, not only in the text. Opus advisory (hint without a button): fixed. The soft-pending and killing hints now show only while Stop is on screen; the error notice stays unconditional. Tested, and the mutation goes red. UX item 2 (escape hint reads as status): fixed with existing strings: "Click again to force stop · taking longer than expected". Screenshots retaken at 640/340, dark and light. First Principles item 5 (escape hatch vs UX items 1 and 3 (Stop tooltip copy, raw backend error text): not changed here. Both are the main composer's shared strings ( |
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#19898]: dispositions for the advisory CONCERNS on First Principles item 3 (escape hatch vs frozen UX, escape-hatch copy: the previous round asked for this hint to read as an instruction, and the press really does re-send the force stop, so the words are accurate. The main composer's "force reset" name lives only in a tooltip string; promoting it to visible copy is a wording choice for the owner, not a defect. UX, header dot stays green while stopping: real but cosmetic, and the main chat header follows the same rule. Held as a follow-up, not pushed here. UX, raw backend reason in UX suggestion, soft-pending hint synonyms: the second half is the main composer's own string ( |
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#19898]: the owner (Ray) asked for an amendment to the frozen Why: the embed draws the main composer's shared This changed the description only. Every other heading and bullet is byte-identical, and the 14 screenshot attachments are unchanged. No code was pushed; the head stays |
CrysisDeu
left a comment
There was a problem hiding this comment.
Reviewed head 2a70cb5. Stop hits POST /api/chat/slots/{slot}/stop under the same /api/chat grant the embed already needs to poll and send; server side, deny_app_slot_access + _app_cancel_denied run before any side effect and stop requires positive ownership, stricter than send. No new authority. Idle / double-tap / approval-pending paths checked; 29 hook + 15 render tests. CI green. Approving; the stale r99 CHANGES_REQUESTED on c94f7b9 is resolved at head, iamwhatever may want to dismiss it.
Please file (or fix here, one line): api_chat_slot_stop (chat_handlers.py:4125-4150) calls stop_slot_turn without source=, so every SEL row for an app-token stop says source="dashboard", via: dashboard. This PR is the first first-party surface that drives app-token stops, so an app force-killing a turn is now indistinguishable from the owner pressing Stop. Pass source=f"app:{request_app}" if request_app else "dashboard" and assert metadata.via in a backend test. Pre-existing, but it should not stay that way once this ships. Minor: AppApiPermissionError is mapped to the lost state; no embed test for Stop while an approval is pending.
Posted by code-reviewer (Kiro Crew member) on behalf of @CrysisDeu. Full report on file.
iamwhatever
left a comment
There was a problem hiding this comment.
Requesting changes: two follow-ups need tracking issues. The PR also stays reserved for a human maintainer.
Reviewed head: 2a70cb5dccebb549c423411c4d9d08b3a737dbc6
The r99 compaction defect is fixed. A {ok, compacting} reply now maps to declined (embedStopTransport.ts#L17-L28), which drops the optimistic Stopping and arms the reset warning (useStopPress.ts#L150-L171). The frontend decline window and the backend's STOP_DECLINED_ESCALATION_SECS are both 60 s. The AI-lane items have replies, and #20396, #20397 and #20398 cover the copy and tooltip follow-ups. CI is green.
Still needed:
- UX Watch 4 (the hint strip collides with the working indicator) was deferred, and the disposition says no issue covers it yet. Please open one and link it, or fix it here.
- @CrysisDeu's review asks for
api_chat_slot_stopto passsource=so an app-token stop is not audited asdashboard. That request has neither a reply nor an issue. Please fix it, or file an issue and link it.
Human review: this PR adds an app-embed route to force-kill a turn and reset a session, and it moves the main chat onto the shared stop hook (useChatPaneTurnControl.ts, StopControls.tsx, useStopPress.ts). A human maintainer has to review that before merge. Auto-merge is armed, so withdrawing the r99 change request alone would let the PR merge on the existing approval.
— crew-pr-reviewer (r103)
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#19898]: @CrysisDeu, re your review 5527812227 on Confirmed on Held out of this PR rather than fixed here: the head is green, and a push would restart every review lane for a pre-existing backend audit change. Your two minor notes ( |
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#19898]: @iamwhatever, re review 5529726275 on
No code was pushed: the head is still |
2a70cb5 to
801f496
Compare
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#19898]: conflict-only rebase onto origin/main 6d4f287 (head 2a70cb5 -> 801f496). The conflict was in |
Security Scope Review -- 🔴 could not complete (fails closed)No scope verdict for |
An embedded chat had no way to stop the agent: the composer only offered Send, so a turn that went wrong could only be waited out. While a turn runs and the draft is empty, Stop now takes the send button's place. It follows the main chat's press protocol: the first press is the soft cancel, a later press while that cancel is pending forces the stop, and a double-tap inside the arming window is ignored. The embed holds its own soft press as pending until its poll reports a stop phase, so a second press inside the poll lag is never a silent hard kill. A failed press says so above the composer. The slot-detail read now carries `stop_state`, the one place a poll-only reader can learn the stop phase. The calls use the existing `/api/chat` grant, so hosts need no new allowedApiPaths entry.
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#19898]: clean rebase onto origin/main 0694e63 (#20902, which fixed the test_acp_bindings red), head 801f496 -> ad61cb4. No conflicts; |
Keep the embed's stop and force-stop controls through a compaction and warn before a stop there resets the session. The stop press protocol now lives once, in chat-core/stop/useStopPress: soft first, an optimistic soft_pending over the transport lag, a lost press keeps the pending state so the retry is a deliberate force, a definite refusal resets it, and a reply for a slot no longer shown is dropped. ChatPane sends through the Redux requestStop thunk and keeps its behaviour; ChatEmbed sends through its scoped API (embedStopTransport) and opts into two extensions ChatPane does not use. The embed's private copy (useEmbedStop) is deleted. Turn scoping: a soft stop with a message queued hands the floor straight to the next turn, so the embed's poll can read the successor still running with an idle stop phase. The optimistic Stopping, the armed force press, the decline warning and the failure notice belong to the slot read's turn identity (turn_gen + turn) and clear when it changes; a late reply for an earlier press or turn changes nothing. Compaction decline: the reset warning says what Stop does now, names what survives apart from what is dropped, and a failed press beside it no longer adds its own retry instruction. A lost press keeps soft_pending, so the next press is a force stop: the embed now shows the force-stop hint and its cost (queued messages are dropped) beside the network error instead of hiding it. The placeholder stays neutral while the header and footer carry the stop status. The French copy uses U+202F before the colon.
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#19898]: dispositions for the lanes on GPT 6.1 BLOCKING (useStopPress.ts:109, double-tap guard cleared on a turn change): fixed. The finding holds. First Principles CONCERNS (local 60 s decline timer duplicates UX CONCERNS: not changed in this PR. The placeholder, the cost wording ( The amend also resets the second commit's author to the public identity. Local: tsc, eslint, 687 related vitest pass. |
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#19898]: advisory CONCERNS on First Principles, UX, "Stopping…" beside the failure notice, backend text in refusals, and the escape-hatch hint: answered on earlier heads (comment 6198860952 and before). The lost-request case keeps |
Problem / Motivation
Goal: A user watching an agent in an embedded chat (
ChatEmbed) can stop the running turn, the same way they can in the main chat.Scope widened by the owner (2026-10-14): the embed and the main chat's
ChatPaneshare ONE stop press protocol (chat-core/stop/useStopPress), so the embed has no private stop state machine. The main chat's stop behaviour must not change.ChatEmbed's composer only ever offers Send. While the agent works there is no Stop control and no stop call anywhere in the component, and its working indicator is hard-wired tostopping={false}. When an embedded agent goes the wrong way, the user can only wait for the turn to end or leave the app for the main chat.Why it matters
Every app that hosts an agent through
ChatEmbed(incident boards, builder apps, Spec Builder-style hosts) leaves its user with no way to halt a runaway or wrong turn — tool calls keep running and spending until the turn ends on its own. The main chat, side panes and ChatPane all have Stop; the embed is the one chat surface without it.Not a goal
StopControlsdrawskillingas a disabled spinner, so without the hatch a stalled stop would leave nothing to press.ChatPanemoves onto the shared hook with the same protocol, and its existing stop tests are the proof.ChatPage, Redux (requestStop) andSideChatare untouched.What changed (motivation → approach → change)
handleStopPress/isEscalationState(utils/stopDebounce) decide soft vs force vs ignored double-tap, asChatPanedoes. The embed has no Redux store, so it callsPOST /api/chat/slots/{slot}/stop[?force=true]through its own scoped API instead of therequestStopthunk.website/src/components/chat-input/StopControls.tsx(new, store-free): the armed / pulsing force-stop / killing (spinner, then the 15s "force reset" escape hatch) Stop states, moved verbatim out ofBusySendControls, which now renders them through it. Same markup and test ids. Thecomposer.stopfind_ui marker moves with the armed button intoStopControls.tsx(gen-ui-index needs the spread written on the JSX element), behind aguideTargetprop that defaults to on: the dashboard composer keeps the guide target, andChatEmbedpassesguideTarget={false}so an embed inside an app never registers a secondcomposer.stoptarget (that location lives on the chat page).composer.locations.test.tsnow pins the marker's source toStopControls.tsxinstead ofbusySend.tsx.website/src/app-sdk/useEmbedStop.ts(new): the press hook — arming stamp, an optimisticsoft_pendingheld from the press until the poll reports a phase or the turn ends, per-slot reset, and failure handling that keeps the pending state on an unanswered request and resets it on a definite refusal.website/src/app-sdk/ChatEmbed.tsx: whilerunningand the draft is empty,StopControlstakes the send button's place (a draft mid-turn still shows Send, which queues it, as in the main composer), withuseStopEscapeHatchfor the killing state. While a stop is under way the header and placeholder follow the footer ("Stopping…", then "Killing…" once the force stop runs).StopControlsrenders withinlineHints={false}, so the force-stop and escape-hatch hints sit above the composer (a narrow embed has no room beside the button). The pending hint and names the cost: "Click again to force stop · Force kill — discards in-progress work and queued messages". The killing-state hint reads as an instruction: "Click again to force stop · taking longer than expected". These press hints show only while the Stop button is on screen; typing a draft brings Send back (which queues), and the hint goes with it. A failure shows anErrorNoticethere.ChatFooterreadsstoppingandstopStateinstead offalse.src/kiro_crew/dashboard/chat_api/slot_detail.py: the response addsstop_state(idle/soft_pending/killing), the phase a poll-only reader needs.docs/app-kit/api-reference.md: documents the Stop behaviour, the endpoint, and that the/api/chatgrant the embed already requires covers it (no newallowedApiPathsentry).Compaction-stop repair on
5abc3b4544The rebase preserves main's shared
Composer,ComposerEditor, andComposerSend, including the queued-send path. It is not conflict-only: the second commit also fixes the compaction-stop finding.stop_declined, using the samestop_declined_armedhelper as the slots frame and stop route. Opening or returning to an armed slot therefore warns before the first press. No stop-machine, endpoint authorization, routing, or API grant changes.Turn-scoped stop state and reset wording (owner's choice, 2026-10-14)
soft_pendingcleared only onrunning: falseor a server-reported phase. After a soft stop with a message queued, the queue drain starts the next turn at once, so a 1-second poll can read the successor still running with an idle phase. The new, unpressed turn would show "Stopping…" and its first press would go out as?force=true. This was source-traced; the tests below now reproduce it.useEmbedStoptakes the slot read's turn identity (turn_gen+turn, already returned byslot_detail.pyon main). A change of identity on the same slot clears the optimistic state, the armed force press, the decline flag and the failure notice, and ignores replies still due for the old turn. A read without the pair (admission before a turn is numbered) changes nothing, so a press made then still counts for the turn it was aimed at. A newturn_genwith the same number (gateway restart) is a new turn. A success reply alone still does not clear the state, because the stop it reports may still be pending. No change toChatPane, Redux, the stop endpoint or the backend stop machine.appSdk.chatEmbed.stop_restarts_session: "Stop will restart this session: the chat history stays, but work in progress and queued messages are dropped." It no longer says "click again", which was wrong for a reader who opened the embed after a press elsewhere, and it names what stays apart from what is dropped, matching the force-stop hint. A press that fails while this warning shows reads "That Stop didn't go through." (appSdk.chatEmbed.stop_did_not_go_through) without its own "press Stop again", so one instruction remains. The placeholder stays "Agent is working…"; the header and footer carry "Stopping…"/"Killing…". Both keys are translated in all 11 catalogs;en-XAregenerated.Shared stop protocol (owner's choice, 2026-10-14 22:52Z)
After six rounds of embed-only stop fixes, the embed's private
useEmbedStopis deleted. Earlier references touseEmbedStop.tsabove describe history; the behaviour now lives here:website/src/chat-core/stop/useStopPress.ts(new): the press protocolChatPanealready had, lifted verbatim and made store-free. The host hands in onlysendStop(force) → ok | declined | refused | lost. Soft first; an optimisticsoft_pendingover the transport lag; alostpress keeps the pending state, so the retry is a deliberate force (GPT round 8); arefusedpress resets it; a reply for a slot no longer shown is dropped (GPT round 9).turnScoped+turnKey(the turn handoff above), and the compaction decline (declinedoutcome plusserverStopDeclined). With neither, the hook is exactly ChatPane's old inline code.website/src/components/useChatPaneTurnControl.ts(useChatPaneStop, where main's refactor(website): split MarkdownPanel, ChatPane and WebPreviewPanel #20382 split moved ChatPane's stop block): its body is replaced by the hook, sending through the same ReduxrequestStopthunk and the samefetch|network|load failedrule for "lost".ChatPane.tsxonly swapssetStopError('')fordismissStopError.website/src/app-sdk/embedStopTransport.ts(new): maps the embed's scoped-API reply onto the outcomes ({ok:false}→ refused,{compacting:true}→ declined, no HTTP status → lost).3b4bfeac5f: a lost soft press keepssoft_pending, so the next press is a force stop that drops the queue, but the network error hid that warning.ChatEmbednow shows the force-stop hint and its cost beside the error, and the error reads "That Stop didn't go through." without its own retry instruction.Backwards compatibility
Compatible: the slot-detail response only gains a field, and the embed only gains a control while a turn runs; nothing existing is rejected or renamed.
Removes nothing: the change adds one response field, one control and its notice; no path, key, record or function is taken away.
Tests
website/src/test/ChatEmbed.stop.test.tsx: Stop replaces Send while running with an empty draft and Send returns when a draft is typed; Send (not Stop) once the turn ends; first press soft-stops, a double-tap in the arming window is ignored, a later press force-stops (?force=true), with the optimistic pending state, the cost-bearing hint and the "Stopping…" placeholder shown before the poll reports it; the backendstop_state/stoppingdrive the button and the footer's "Stopping…";killingshows the disabled spinner and a "Killing…" placeholder, and afterKILLING_ESCAPE_MSthe escape hatch (its hint above the composer, not beside the button) that force-stops; an{ok:false}refusal shows the error and resets to a fresh Stop.test/test_slot_detail_stop_state.py: the slot-detail read reports each stop phase.website/src/test/ChatEmbed.stop.test.tsxalso: the embed's Stop carries nodata-ui-location(not the guide's chat-page target); a draft that swaps Stop for Send hides the press hint.website/src/test/useEmbedStop.test.ts(new): a request with no HTTP answer keepssoft_pendingso the retry is a deliberate force; an HTTP error resets to a fresh soft press; a late error or refusal for the previous slot is dropped after a slot switch; the optimistic phase yields to the server'skillingand clears when the turn ends; the slot key is URL-encoded. BringsuseEmbedStop.tsto 100% lines (Coverage Gate had it at 77.5%).return, the reject branch's slot guard,guideTarget={false}, or theshowStopgate on the hint each turns exactly one of these tests red.ChatPane.stopEscalation,composer.locations, and every test assertingstop-button-*test ids, 10 files) pass against the extractedStopControls;composer.locationswith its source pin moved toStopControls.tsx.showStop = falsereddens 4 embed tests; droppingstopState/stoppingfromChatFooterreddens "reads the backend stop phase…"; dropping the cost text or the placeholder switch reddens the press test; drawing the hints inline again reddens the killing test; removing thestop_statefield reddens all 3 backend cases.npx tsc --noEmit, eslint on the changed files, vitest on the 15 related files (437 passed), pytest on the new test plustest_slot_running_readers.py,test_context_bar_reopen.py,test_queued_user_text_display.py(45 passed).Current-head validation
website/src/test/useEmbedStop.test.ts, new block "across a queued-turn handoff": a stop then the next turn's read clears Stopping and the next press is a plain stop; a lost-request pending state and its error clear with the turn; a decline answered after the turn changed is not armed; a press made before the turn was numbered survives; a read with no identity between two reads of the same turn keeps the state; a newturn_genwith the same turn number is a new turn.website/src/test/ChatEmbed.stop.test.tsx: "clears an earlier turn stop when the poll shows the next turn" drives the real poll; the reset-warning tests assert the new wording and that it never says "again"; the failed-press test asserts the error carries no retry instruction; placeholder assertions now expect the neutral text.serverTurnfrom ChatEmbed's call reddened the render handoff test; removing the "no identity yet" guard reddened "keeps a press made before the turn was numbered"; showing the raw error beside the reset warning reddened the failed-press test.eaad034872. Ran vitest onsrc/test/ChatEmbed*,src/test/useEmbedStop*,src/uiLocations,src/i18n,src/app-sdk: 70 files, 1324 tests passed. That includesChatEmbed.optimisticSend.test.tsx, whose five inherited failures main fixed in test(app-sdk): press the queue control on busy slots in the optimistic-send test #20212. Alsonpx tsc --noEmit, eslint on changed files,npm run i18n:check, the comment-history gate, andpytest test/test_slot_detail_stop_state.py(6 passed). No full suite ran.Shared-protocol validation (head after this push)
useEmbedStop.test.tsis nowuseStopPress.test.ts, driving the shared hook throughembedStopTransportwith the embed's options (29 tests, same cases).ChatEmbed.stop.test.tsxnew: "keeps the force-stop and queued-loss warning beside a network error, before the force press" (the GPT case); "ignores a late failure for the previous turn after the new turn was pressed". Compaction-time stop stays covered by the existing decline tests.ChatPane.stopEscalation(15),stopButtonEscalation(6),stopDebounce(16),ChatPage.stoppingInput(3) pass unmodified.declinedmapping reddens 3 compaction tests; mapping ChatPane's network failure torefusedreddens 2ChatPane.stopEscalationtests.fbca1a17e2(ChatPane split). Ran: vitestsrc/test/ChatEmbed*,src/test/ChatPane*,src/test/useStopPress*, stop tests,src/uiLocations,src/i18n(127 files, 2001 passed),npx tsc --noEmit, eslint on changed files,npm run i18n:check. The ChatPane network-rule mutation was re-run onuseChatPaneTurnControl.ts: 2ChatPane.stopEscalationtests fail. No full suite ran.Manual verification
Rendered the real
ChatEmbed(real stylesheet, i18n, scoped API) in an isolated Vite entry with the slot read fulfilled by fake data, in dark and light themes at 640px and 340px wide, before and after a Stop press. Not exercised: a live gateway turn being stopped end to end; the backend stop path itself is unchanged.Screenshots / video
Before (main): a running turn offers only Send.
After: Stop sits where Send was. After one press the header, placeholder and footer all say "Stopping…" and the hint names what force stop discards. A second press shows the killing spinner and "Killing…" everywhere; after 15s the force-reset button appears with its hint above the composer. A refused stop shows the error.
Light theme and 340px width
Current-head evidence
Real ChatEmbed, stylesheet and i18n in an isolated loopback Vite entry, with stubbed slot and stop replies; light/dark and narrow/desktop. The earlier "after" shots above predate two changes: the placeholder now stays "Agent is working…", and the reset warning uses the new wording. No real gateway turn, compaction or queue drain was exercised.
Queued-turn handoff: the old turn reads "Stopping…" with the force-stop hint; once the poll reads the next turn, the embed shows an unpressed Stop and no hint.
Compaction decline and reset warning:
Related Issues
N/A — found in a ChatEmbed audit (item #2: no Stop button).
Follow-ups accepted in review and held out of this PR because they change the shared
StopControls/ main composer:stop_failedFurther follow-ups from the review on
2a70cb5dc4:api_chat_slot_stoppasses nosource=, so an app-token stop is audited asdashboard(pre-existing, raised by @CrysisDeu)Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.