Skip to content

No Stop button: #25's stream-cancel backend has no frontend wire-up — users can't stop a streaming response #147

Description

@matthewod11-stack

Description

Issue #25 shipped the full backend cancel apparatus (StreamRegistry, CancellationToken, connection-drop-stops-billing, cancel_stream command), but the frontend never wired it up — there is no Stop button, and the frontend doesn't pass a stream_id to send_chat_message_streaming (the command comment explicitly calls this out as a pending follow-up). Users watching a long/wrong response stream in have no way to stop it, and abandoned streams bill to completion. Found during #112 manual QA (2026-07-09): the cancelled-audit-row path could not be exercised from the UI.

Current State

Suggested Fix

  • Frontend generates a UUID stream_id per send; pass through sendChatMessageStreaming
  • Show a Stop button while streaming (replace/augment the send button); onClick → cancel_stream(stream_id)
  • Also call cancel_stream on conversation switch/unmount (the command is safe on unknown ids)
  • Frontend handles the existing chat-stream-cancelled event (reset streaming UI state)
  • vitest: pure-function tests for any extracted stream-state logic; manual QA confirms a cancelled audit row lands

Verification

  • cargo test + npm test pass
  • Manual: start a long response, hit Stop → stream halts, UI resets, audit_log gains a cancelled row with partial char count

Automation Hints

scope: src/contexts/ConversationContext.tsx, src/lib/tauri-commands.ts, src/components/chat/
do-not-touch: src-tauri/ (backend is complete)
approach: extract-and-move
risk: low
max-files-changed: 6
blocked-by: none
bail-if: requires backend signature changes beyond making stream_id required

Priority

Medium — user-facing control gap + token cost on abandoned streams; also unblocks manual QA of the cancelled-row path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    tech-debtEligible for automated overnight fixing

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions