Skip to content

fix(bots): stop a running bot reply from the chat - #465

Merged
nixuuu merged 1 commit into
devfrom
fix/bot-stop
Nov 10, 2026
Merged

nixuuu merged 1 commit into
devfrom
fix/bot-stop

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 10, 2026

Copy link
Copy Markdown
Member

When a bot is replying, Stop now occupies the send button on web/desktop and mobile, including while the next message is being drafted. It retains the received partial reply with “Stopped by you”, interrupts the worker harness, and accepts the next message immediately.

The RPC and linked-home routing already existed. The web control lived in the header, and mobile hid Stop as soon as the draft contained text. Gateway interruption changed the logical turn without atomically persisting worker cancellation or retaining its streamed text. Worker ACK could precede harness shutdown; Claude's SDK abort returns before process exit, and Grok's ACP cancellation can leave a blocked prompt alive.

Behavior and durability

  • Stop affects one current visible reply, including a reply waiting for a worker or approval. With no running visible reply, it stops the oldest queued visible message. Other queued messages, future routines and reminders remain. Hidden routines are affected only when waiting for a visible approval/question.
  • One owner-scoped transaction saves the partial answer, marks the turn and harness interrupted, expires that turn's pending cards, invalidates its lease, and persists cancellation in the worker outbox. Late output is acknowledged without changing the saved reply or authorizing tools.
  • Cancellation survives gateway disconnection/restart. Worker admission honors cancellation that overtakes a replayed run. ACK waits for harness shutdown; the next reply waits for that ACK, avoiding BUSY races. Claude uses the existing process-tree spawn hook, Codex retains scoped app-server teardown, and Grok disposes its isolated ACP process on abort.
  • Existing RunBotTurn/InterruptBotTurn and bot_harness_v1 remain the compatibility boundary. No proto, migration or native mobile changes. Stop cannot undo effects completed before cancellation.

Mobile coordination: the only shared thread-composer change is an optional stopWhileRunning prop in ComposerBox.tsx, defaulting to false. Bot composer wiring opts in; the thread composer keeps its existing behavior. Please preserve this prop when combining the separate mobile thread-composer work.

Validation

  • Regression reproduced against the original gateway interruption: the expected partial answer and stopped marker were absent. bots-stop.test.ts: 6 pass covering Claude/Codex/Grok, process exit, immediate next input, queued input, late replay, owner scoping, offline cancellation and gateway/worker restart.
  • bots-harness.test.ts: 24 pass; Claude round-trip/approval tests rerun after the process teardown change: 2 pass. bot-adapters-stop.test.ts: 3 pass with blocked fake CLIs, process exit before resolution and already-aborted admission. Worker journal tests: 10 pass, including cancellation before admission across reopen.
  • Linked-home Stop test: 1 pass; existing questions/restart/interrupt test: 1 pass. Multi-gateway files ran separately. Only fake provider harnesses were used for the new coverage; no UI test suites were added.
  • bun install, bun run typecheck, bun run lint, bun run format:check, bun run gen:check, and bun run --filter @canopy/web build passed. Full local check:tmp intentionally omitted per task; CI is the full-suite gate.
  • Real browser: light/dark at 1280×800 and 390×844, short/typical/long bot names, empty/nonempty drafts, reachable Stop, stopped marker, preserved draft and restored Send. The private fixture waits for an eligible worker; provider shutdown is verified by integration/adapter tests.

Production fingerprints generated using bunx [email protected] fingerprint:generate --platform <ios|android> --build-profile production --json --non-interactive match current dev (9355f128) exactly:

Platform dev and branch hash
iOS 6ddec9ef559ee0095ac33e94ff9418a942053b17
Android 5f6eae3ab278f1cd543e9ed763f923a319b65ec9

Copy audit — docs/copy.md §8

Before After Reason
Header “Stop”; mobile Stop hidden with a draft Composer control labelled “Stop reply” on web; existing mobile “Stop” Verb-led, accessible action in the send position, always reachable during a reply.
No durable stopped note/partial answer “Stopped by you” following the retained partial answer Names the completed action and its actor without a failure message.
“Could not stop the bot” / mobile “Could not stop the bot. Check the connection and retry.” “Could not stop the reply. Check the connection and retry.” States what failed and one recovery action; consistent across clients.

Audit passed: sentence case, concise existing glossary terms, no new jargon, no repeated status fact or new empty state, no decorative sentences. Labels are available to assistive technology and through the existing tooltip/control text. Short, typical and long names were checked at desktop and phone widths.

Related: #97
Related: #104

Persist cancellation with the interrupted turn, retain streamed output, and wait for harness shutdown before admitting the next reply.

Related: #97

Related: #104
@nixuuu
nixuuu merged commit 76ebd31 into dev Nov 10, 2026
15 of 17 checks passed
@nixuuu
nixuuu deleted the fix/bot-stop branch November 10, 2026 06:41
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.

1 participant