Skip to content

feat(app-sdk): give ChatEmbed a stop button for a running turn - #19898

Merged
buluoray merged 2 commits into
mainfrom
feat/embed-stop-button
Oct 15, 2026
Merged

buluoray merged 2 commits into
mainfrom
feat/embed-stop-button

Conversation

@buluoray

@buluoray buluoray commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

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 ChatPane share 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 to stopping={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

  • Changing the embed's send path, queue display, poll error handling or any other ChatEmbed audit item.
  • Dropping the killing-state "taking longer than expected" escape hatch: this PR keeps the main composer's 15s hatch in the embed on purpose (amended by the owner). The shared StopControls draws killing as a disabled spinner, so without the hatch a stalled stop would leave nothing to press.
  • Any change to the stop endpoint or the backend stop machine itself.
  • Any change to the main chat's stop behaviour: ChatPane moves onto the shared hook with the same protocol, and its existing stop tests are the proof. ChatPage, Redux (requestStop) and SideChat are untouched.

What changed (motivation → approach → change)

  • Symptom → cause: the embed rendered no Stop, and its only state source (the slot-detail poll) did not carry the stop phase, so even a stop pressed elsewhere could not be reflected.
  • Approach: reuse the main chat's press protocol and its control rather than invent either. handleStopPress / isEscalationState (utils/stopDebounce) decide soft vs force vs ignored double-tap, as ChatPane does. The embed has no Redux store, so it calls POST /api/chat/slots/{slot}/stop[?force=true] through its own scoped API instead of the requestStop thunk.
  • 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 of BusySendControls, which now renders them through it. Same markup and test ids. The composer.stop find_ui marker moves with the armed button into StopControls.tsx (gen-ui-index needs the spread written on the JSX element), behind a guideTarget prop that defaults to on: the dashboard composer keeps the guide target, and ChatEmbed passes guideTarget={false} so an embed inside an app never registers a second composer.stop target (that location lives on the chat page). composer.locations.test.ts now pins the marker's source to StopControls.tsx instead of busySend.tsx.
  • website/src/app-sdk/useEmbedStop.ts (new): the press hook — arming stamp, an optimistic soft_pending held 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: while running and the draft is empty, StopControls takes the send button's place (a draft mid-turn still shows Send, which queues it, as in the main composer), with useStopEscapeHatch for the killing state. While a stop is under way the header and placeholder follow the footer ("Stopping…", then "Killing…" once the force stop runs). StopControls renders with inlineHints={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 an ErrorNotice there. ChatFooter reads stopping and stopState instead of false.
  • src/kiro_crew/dashboard/chat_api/slot_detail.py: the response adds stop_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/chat grant the embed already requires covers it (no new allowedApiPaths entry).

Compaction-stop repair on 5abc3b4544

The rebase preserves main's shared Composer, ComposerEditor, and ComposerSend, including the queued-send path. It is not conflict-only: the second commit also fixes the compaction-stop finding.

  • A declined stop clears optimistic Stopping and shows the existing warning that another press restarts the session. The press still respects the double-tap window and is sent without force; the backend decides whether compaction still requires a reset.
  • The slot-detail read adds stop_declined, using the same stop_declined_armed helper 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.
  • A refused or unanswered reset press keeps the reset warning beside the error. Late decline replies cannot re-arm a different slot visit or a finished turn. Shared force-stop and 15s escape controls remain.
  • Known limit: the local warning can outlive compaction until its bounded window ends. This over-warns; the backend still chooses an ordinary soft stop when compaction is over.

Turn-scoped stop state and reset wording (owner's choice, 2026-10-14)

  • Cause: the Opus lane found that the embed's optimistic soft_pending cleared only on running: false or 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.
  • Fix (embed only): useEmbedStop takes the slot read's turn identity (turn_gen + turn, already returned by slot_detail.py on 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 new turn_gen with 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 to ChatPane, Redux, the stop endpoint or the backend stop machine.
  • UX BLOCK: the compaction reset warning is now the embed's own 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-XA regenerated.

Shared stop protocol (owner's choice, 2026-10-14 22:52Z)

After six rounds of embed-only stop fixes, the embed's private useEmbedStop is deleted. Earlier references to useEmbedStop.ts above describe history; the behaviour now lives here:

  • website/src/chat-core/stop/useStopPress.ts (new): the press protocol ChatPane already had, lifted verbatim and made store-free. The host hands in only sendStop(force) → ok | declined | refused | lost. Soft first; an optimistic soft_pending over the transport lag; a lost press keeps the pending state, so the retry is a deliberate force (GPT round 8); a refused press resets it; a reply for a slot no longer shown is dropped (GPT round 9).
  • Two opt-in extensions only the embed passes: turnScoped + turnKey (the turn handoff above), and the compaction decline (declined outcome plus serverStopDeclined). 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 Redux requestStop thunk and the same fetch|network|load failed rule for "lost". ChatPane.tsx only swaps setStopError('') for dismissStopError.
  • 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).
  • GPT finding on 3b4bfeac5f: a lost soft press keeps soft_pending, so the next press is a force stop that drops the queue, but the network error hid that warning. ChatEmbed now 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 backend stop_state/stopping drive the button and the footer's "Stopping…"; killing shows the disabled spinner and a "Killing…" placeholder, and after KILLING_ESCAPE_MS the 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.tsx also: the embed's Stop carries no data-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 keeps soft_pending so 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's killing and clears when the turn ends; the slot key is URL-encoded. Brings useEmbedStop.ts to 100% lines (Coverage Gate had it at 77.5%).
  • Mutation checks: removing the network-error return, the reject branch's slot guard, guideTarget={false}, or the showStop gate on the hint each turns exactly one of these tests red.
  • The existing composer stop tests (ChatPane.stopEscalation, composer.locations, and every test asserting stop-button-* test ids, 10 files) pass against the extracted StopControls; composer.locations with its source pin moved to StopControls.tsx.
  • Mutation checks: forcing showStop = false reddens 4 embed tests; dropping stopState/stopping from ChatFooter reddens "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 the stop_state field reddens all 3 backend cases.
  • Ran: npx tsc --noEmit, eslint on the changed files, vitest on the 15 related files (437 passed), pytest on the new test plus test_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 new turn_gen with 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.
  • Mutations, each restored by path: making the turn-change effect always return reddened 5 tests (1 render, 4 hook); dropping serverTurn from 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.
  • Rebased on main eaad034872. Ran vitest on src/test/ChatEmbed*, src/test/useEmbedStop*, src/uiLocations, src/i18n, src/app-sdk: 70 files, 1324 tests passed. That includes ChatEmbed.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. Also npx tsc --noEmit, eslint on changed files, npm run i18n:check, the comment-history gate, and pytest test/test_slot_detail_stop_state.py (6 passed). No full suite ran.

Shared-protocol validation (head after this push)

  • useEmbedStop.test.ts is now useStopPress.test.ts, driving the shared hook through embedStopTransport with the embed's options (29 tests, same cases).
  • ChatEmbed.stop.test.tsx new: "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.
  • Main chat unchanged: ChatPane.stopEscalation (15), stopButtonEscalation (6), stopDebounce (16), ChatPage.stoppingInput (3) pass unmodified.
  • Mutations, each restored: hiding the hint beside an error reddens the GPT test; dropping the per-turn stale guard reddens 8 (the render late-failure test plus 7 hook tests); dropping the declined mapping reddens 3 compaction tests; mapping ChatPane's network failure to refused reddens 2 ChatPane.stopEscalation tests.
  • Rebased on main fbca1a17e2 (ChatPane split). Ran: vitest src/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 on useChatPaneTurnControl.ts: 2 ChatPane.stopEscalation tests 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.

before, dark, 640px

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.

after, dark-640, running
after, dark-640, pending
after, dark-640, killing
after, dark-640, escape
after, dark-640, error

Light theme and 340px width

after, light-640, pending
after, light-640, escape
after, light-340, running
after, light-340, pending
after, light-340, escape
after, light-340, error
after, dark-340, killing
after, dark-340, escape

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.

Old turn stopping, narrow dark
Next turn, narrow dark
Old turn stopping, desktop light
Next turn, desktop light

Compaction decline and reset warning:

Compaction declined, narrow dark
Return to armed slot before any press, narrow dark
Return to armed slot, desktop light
Reset press refused, narrow light
Reset reply lost, desktop dark

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:

Further follow-ups from the review on 2a70cb5dc4:

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

2-declined-narrow-dark

4-reset-failed-narrow-light

5-reentry-declined-narrow-light

6-reset-lost-narrow-dark

5-reentry-declined-desktop-dark

6-reset-lost-desktop-light

7-lost-press-narrow-dark

7-lost-press-desktop-light

@buluoray
buluoray requested review from a team and KiroCrewCaptain as code owners October 13, 2026 19:16
@buluoray
buluoray requested a review from mbriones98 October 13, 2026 19:16
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 13, 2026
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 69c7641adccc26031a5650ef704154e46a9fa912 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Check that ChatPane's stop tests ran unchanged against the shared useStopPress, since they are the stated proof that the main chat's stop behaviour did not change.

Suggestions

  • The "What changed" section still describes website/src/app-sdk/useEmbedStop.ts, but the diff ships chat-core/stop/useStopPress.ts plus embedStopTransport.ts. Reword that bullet so it describes the shared hook that actually landed.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — 🟡 CONCERNS

Premise-level review of 69c7641adccc26031a5650ef704154e46a9fa912 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

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

  • Item 4 — duplicate of components.chatInput.click_again_to_force_stop_resets_session (busySend.tsx:281): the PR adds appSdk.chatEmbed.stop_restarts_session because "click again" "was wrong for a reader who opened the embed after a press elsewhere". ChatPage and CrewChatWindow both read stop_declined too, so that same reader still gets the old wording there. That leaves 1 unfixed sibling (grepped stopDeclinedArmed and stop_declined). The two strings also contradict each other about one backend action: "your messages stay" versus "queued messages are dropped".
    Clears when: the description says which of the two claims is true of the reset, and that the main composer's string stays as a deferred sibling.

What this change ships

Inventory (7 items) — 6 justified

Intent: let a user watching an embedded chat stop the running turn. This is an ADDITION.

  1. The embed shows Stop in place of Send while a turn runs and the draft is empty — justified
  2. A second press force-stops, and the force-stop/escape-hatch hints sit above the embed composer — justified
  3. The embed's header and footer read "Stopping…"/"Killing…" during a stop — justified
  4. The embed shows its own compaction reset warning — duplicate of click_again_to_force_stop_resets_session
  5. A stop belongs to one turn, so the next queued turn shows an unpressed Stop — justified
  6. The slot-detail read returns stop_state and stop_declined — justified
  7. ChatPane's Stop now runs on the shared useStopPress hook, with no behaviour change — justified

[FIRST-PRINCIPLES-REVIEWED] 69c7641

Description read

[DESCRIPTION-READ] aaf64d2608bfbecd2a8a58076e2b938311e3a46e32a5ed612671afc89107b990

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — 🟡 CONCERNS

UX-level review of 69c7641adccc26031a5650ef704154e46a9fa912 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

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

  • Failure and "Stopping…" at the same time. When a press gets no answer, soft_pending stays on. So stopUnderWay keeps the header and ChatFooter red "Stopping…" next to stop_did_not_go_through. The blind reader asked "it is stopping and has failed at the same time? -> no idea which is true" (shots 23, 27, 30, 31). This happens on every lost or unanswered press, and it leaves the user unsure whether pressing again is safe. Fix: when the stop request had no answer, change the header/footer label to say the stop is unconfirmed (for example "Stop not confirmed") instead of "Stopping…".
  • Backend text in refusal errors. sendEmbedStop passes reply.error || reply.code || 'stop refused' straight into the notice. The reader saw "(the crew that owns this session is not reachable)" and "(crew unreachable)" and said "'crew' means nothing to me" (shots 06, 25). The user is told to retry without knowing why it failed. Fix: map each refusal kind to wording a user knows ("The agent's host can't be reached right now. Press Stop again.").
  • The killing-state escape hatch is unclear. "Click again to force stop · taking longer than expected" appears while the screen already says "Killing…". The reader: "no idea what is left to stop once it's already killing… Is there something even stronger?" (shot-05). It's a rare state, but it's the only way out of a stalled stop. Fix: name the outcome for this state, for example "Taking longer than expected · Click to force stop again".

Suggestions

  • Placeholder: while a stop is under way, the composer placeholder agent_is_working contradicts the header's "Stopping…". The reader called it "mixed signals" (shots 15, 17, 30). Use stopLabel there, or blank the placeholder.
  • Some screenshots show earlier wording: the "Stopping…" placeholder in shot-03, and "Click again to force stop (restarts the session…)" in shots 24, 26 and 28. Replace them with captures from this HEAD so the human reviewer sees the copy that ships.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 69c7641adccc26031a5650ef704154e46a9fa912 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 69c7641

Verdict parsed from the review's SHA-scoped output markers for commit 69c7641adccc26031a5650ef704154e46a9fa912.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 69c7641adccc26031a5650ef704154e46a9fa912: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 69c7641adccc26031a5650ef704154e46a9fa912 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 69c7641

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 69c7641adccc26031a5650ef704154e46a9fa912: <one-sentence reason>

@buluoray

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#19898]: dispositions for the e85d05e review round, all addressed in a31309a.

  • UX BLOCK — force-stop cost hidden in a tooltip: fixed. The hint above the composer now reads "Click again to force stop · Force kill — discards in-progress work and queued messages" (existing catalog strings, so every locale is covered). Pinned by ChatEmbed.stop.test.tsx (the press test reddens when the cost text is removed).
  • UX watch — three contradictory statuses: fixed. While a stop is under way the header label and placeholder read "Stopping…" with the footer.
  • UX watch — pending vs idle buttons look alike: not changed here. The embed now renders the dashboard composer's own control, so restyling it is a change to the main chat's Stop as well; the hint line above the composer is the embed's distinguishing cue.
  • UX evidence gaps (killing state, stop-failure notice): captured; see the killing and error shots in the description (dark/light, 640px/340px).
  • First Principles — EmbedStopButton duplicates BusySendControls: fixed by extraction rather than by importing BusySendControls (its module imports the chat store, and ChatEmbed carries no Redux). The three states moved verbatim into a store-free components/chat-input/StopControls.tsx; BusySendControls and the embed both render it, and the embed's own button is deleted. The composer's markup, test ids and composer.stop find_ui marker are unchanged (10 existing stop test files pass). This also gives the embed the composer's 15s killing escape hatch, so the description's frozen "Not a goal" bullet about that timer no longer describes the diff — left untouched because that section is frozen.

@buluoray
buluoray force-pushed the feat/embed-stop-button branch from a31309a to e648a77 Compare October 13, 2026 20:05
@buluoray

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#19898]: e648a77 answers the rest of the e85d05e/a31309a892 round.

  • Opus BLOCKING — stop-error ErrorNotice records no hand-off decision: fixed. The notice now carries {/* No hand-off: … */} naming the composer draft the hand-off's navigation would discard (the same reason as the embed's earlier-messages pager).
  • Build Wheel / Build Desktop red on a31309a (caused by my diff): gen-ui-index refused uiLocation('composer.stop') passed as a prop instead of spread on the element. The marker now sits directly on the armed Stop inside StopControls.tsx; areas/composer.ts and composer.locations.test.ts name that file as its source. gen-ui-index --check, tsc -p tsconfig.app.json and the 15 related vitest files (437 tests) pass locally.

@buluoray
buluoray force-pushed the feat/embed-stop-button branch from e648a77 to 942cd53 Compare October 13, 2026 20:44
@buluoray

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#19898]: UX round on e648a77, answered in 942cd53.

  • BLOCK — no escape-hatch evidence: captured (dark/light, 640px/340px). The capture confirmed the layout risk the lane named: at 340px the nowrap "taking longer than expected" beside the button squeezed the textarea. Fixed: StopControls takes inlineHints={false} in the embed, so the escape-hatch hint ("Force reset — taking longer than expected") and the force-stop hint both sit above the composer. Test: the killing case now asserts the hint is above the composer and not beside the button (reddens if the hints are drawn inline).
  • Watch — header/placeholder say Stopping… while the footer says Killing…: fixed; both follow the footer and read "Killing…" in the killing state.
  • Watch — failure copy uses backend wording: not changed here. The text is the shared components.chatPane.stop_failed string the main chat pane shows for the same failure, so rewording it changes that surface too and needs new strings in every locale; that belongs in its own change.
  • Suggestion — "force stop" vs "Force kill": not changed, for the same reason: both are existing shared catalog strings (the second is the composer's own Stop tooltip).

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 13, 2026
@buluoray
buluoray force-pushed the feat/embed-stop-button branch from 942cd53 to bb64db9 Compare October 13, 2026 21:48
@buluoray

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#19898]: dispositions for the lanes on 942cd53762, fixed in bb64db9ff8.

Coverage Gate (red, my diff): useEmbedStop.ts was at 77.5%. New useEmbedStop.test.ts covers the no-answer, HTTP-error, late-reply-after-slot-switch and optimistic-retire branches (100% lines). Mutating the network-error return or the reject branch's slot guard turns one test red each.

Design + First Principles item 9 (marker): fixed in code, not only in the text. StopControls takes guideTarget (default on). BusySendControls keeps the composer.stop target. ChatEmbed passes guideTarget={false}, so an app's embed no longer registers a second target for a chat-page location. A test asserts the embed's Stop has no data-ui-location, and removing the prop turns it red. The description now says the marker moved to StopControls.tsx and that composer.locations repins its source.

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 ## Not a goal): kept on purpose. That Not-a-goal line assumed a press during killing re-sends the force stop. Since the embed now draws the composer's shared control, killing is a disabled spinner, so without the 15s escape hatch a stalled kill would leave the user no press at all. Whether to amend the frozen Not-a-goal line is the owner's call. I did not edit it.

UX items 1 and 3 (Stop tooltip copy, raw backend error text): not changed here. Both are the main composer's shared strings (stop_generation, stop_failed). Rewording them changes every chat surface and every locale, which is wider than this item.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 13, 2026
@buluoray

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#19898]: dispositions for the advisory CONCERNS on bb64db9ff8. No push for these: none is a BLOCK, and a push would restart every lane.

First Principles item 3 (escape hatch vs frozen ## Not a goal): same point as the last round, and the lane now confirms the reason itself: the shared StopControls draws killing as a disabled spinner, so removing the hatch would leave a stalled stop with nothing to press. Amending the frozen Not-a-goal line is the owner's decision.

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 stop_failed: the main composer shares that string; out of scope here, as answered last round.

UX suggestion, soft-pending hint synonyms: the second half is the main composer's own string (force_kill_discards_in_progress_work_and_queued), reused on purpose so both surfaces name the cost the same way.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 13, 2026
@buluoray

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#19898]: the owner (Ray) asked for an amendment to the frozen ## Not a goal section, made at 22:51Z. The bullet that excluded the killing-state "taking longer than expected" escape hatch now says this PR keeps that hatch in the embed on purpose.

Why: the embed draws the main composer's shared StopControls, which renders killing as a disabled spinner. Without the 15s hatch, a stalled stop would leave the user nothing to press. This resolves First Principles item 3, which named exactly this amendment as its clear condition.

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 bb64db9ff8.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision labels Oct 13, 2026
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 13, 2026
@buluoray
buluoray enabled auto-merge (squash) October 15, 2026 02:48
CrysisDeu
CrysisDeu previously approved these changes Oct 15, 2026

@CrysisDeu CrysisDeu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_stop to pass source= so an app-token stop is not audited as dashboard. 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)

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: passed Eligible automated validation passed for the current revision labels Oct 15, 2026
@buluoray

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#19898]: @CrysisDeu, re your review 5527812227 on 2a70cb5dc4: the source= gap is filed as #20874 and linked under Related Issues.

Confirmed on origin/main: api_chat_slot_stop (now in src/kiro_crew/dashboard/chat_api/turn_stop.py, after main split the handlers) calls stop_slot_turn(...) with no source, and stop_slot_turn defaults it to "dashboard", which lands in SEL metadata as via. The issue carries your proposed source=f"app:{request_app}" fix and asks for a backend test asserting metadata.via. It also notes that several of those SEL calls pass their own hard-coded source="dashboard" argument besides via, so the fix should decide whether those follow the caller too.

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 (AppApiPermissionError mapped to lost; no embed test for Stop while an approval is pending) are not addressed in this PR.

@buluoray

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#19898]: @iamwhatever, re review 5529726275 on 2a70cb5dc4, both items now have tracking issues linked under Related Issues:

No code was pushed: the head is still 2a70cb5dc4, and only the PR body's Related Issues section changed (Goal / Why / Not a goal untouched). Your review is yours to clear; I have not dismissed it. The human-maintainer review you flagged is not something this pipeline can supply.

@buluoray
buluoray requested a review from iamwhatever October 15, 2026 15:44
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 15, 2026
@buluoray
buluoray disabled auto-merge October 15, 2026 16:47
@buluoray
buluoray force-pushed the feat/embed-stop-button branch from 2a70cb5 to 801f496 Compare October 15, 2026 16:49
@buluoray

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#19898]: conflict-only rebase onto origin/main 6d4f287 (head 2a70cb5 -> 801f496). The conflict was in busySend.tsx, where #20784 retinted the stop buttons (text-danger-text on the pulsing force-stop, hover:text-danger-text on the armed Stop). This PR moves those buttons into StopControls.tsx, so the same two class changes now live there. git range-diff shows commit 1 unchanged and commit 2 differing only by those two classes. tsc, eslint, gen-ui-index --check and 263 related vitest tests pass locally. Auto-merge was turned off before the push and will be re-armed once the new head is green.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Security Scope Review -- 🔴 could not complete (fails closed)

No scope verdict for 801f49687935db3cc53dac213b9bba971304c7fc (the candidate stage failed). This lane fails CLOSED: an unmeasured tightening must not read as "nothing newly refused". See the job logs, then re-run -- or record /ai-review override scope 801f49687935db3cc53dac213b9bba971304c7fc: <reason> if a human has judged the scope by hand.

@buluoray
buluoray enabled auto-merge (squash) October 15, 2026 17:01
@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 15, 2026
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.
@buluoray

Copy link
Copy Markdown
Contributor Author

🤖 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; git range-diff shows both commits =. This push also replaces the stale event base (10e53cc) that made PR Hygiene count 137 commits and internal-content-scan flag test/test_dashboard_chat.py on the previous head. Local: tsc, gen-ui-index --check, 263 related vitest and test_acp_bindings.py pass.

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.
@buluoray

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#19898]: dispositions for the lanes on ad61cb4364, fixed at 69c7641adc.

GPT 6.1 BLOCKING (useStopPress.ts:109, double-tap guard cleared on a turn change): fixed. The finding holds. startOver() zeroed softStopAtRef on a turn change too, and the press's own catch-up read is often the one that names the queued successor, already soft_pending. A second tap 200 ms later then went out as force=true and dropped the queue. Now a turn change keeps the last press's time (startOver(true)); a slot change still clears it. New test ignores a double-tap whose second tap lands after the read that names the next turn sends one request with the fix and two with the old startOver() (mutation checked). Spec app-kit-platform.md now says the press time is the one thing a new turn keeps, and why.

First Principles CONCERNS (local 60 s decline timer duplicates stop_declined): not changed. The local flag covers the gap between the declined press and the next slot read, and the reset press itself while it is unanswered. Dropping it on the first read would hide the warning whenever that read misses the marker. The over-warning the description names is bounded by the same 60 s window the backend uses.

UX CONCERNS: not changed in this PR. The placeholder, the cost wording (stop_restarts_session vs click_again_to_force_stop_resets_session), the Force kill/Force stop verbs, and the stop_failed text are shared with the main chat composer. Changing them means new strings in every locale for both surfaces, which is outside this PR's goal. These were raised and answered on earlier heads.

The amend also resets the second commit's author to the public identity. Local: tsc, eslint, 687 related vitest pass.

@buluoray

Copy link
Copy Markdown
Contributor Author

🤖 Kiro Crew Auto-Pipeline [operator: buluoray#19898]: advisory CONCERNS on 69c7641adc, no push for these (GPT, Opus and Design pass; nothing blocks).

First Principles, stop_restarts_session vs click_again_to_force_stop_resets_session: kept as a separate string. The composer's string tells someone who just pressed Stop to press again. The embed shows its warning to anyone who opens a slot where the backend marker is armed, including after a press made in another tab, so "Click again" would describe a press this reader never made. Aligning the two sentences on what survives a reset means changing the main composer's shared string in every locale, which is outside this PR's goal.

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 soft_pending on purpose: the request may have armed the cancel, so the next press is a real force stop and the header must not claim the stop is over. The refusal text and the hint are the main chat's shared strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants