Skip to content

Add Ctrl+C to stop generation mid-stream#22

Merged
IreneXY merged 1 commit intomainfrom
031802
Mar 19, 2026
Merged

Add Ctrl+C to stop generation mid-stream#22
IreneXY merged 1 commit intomainfrom
031802

Conversation

@IreneXY
Copy link
Copy Markdown
Member

@IreneXY IreneXY commented Mar 19, 2026

Summary

  • Add StopGenerationRequested event to ChatBloc
  • Switch from emit.forEach to StreamSubscription for mid-stream cancellation support
  • Ctrl+C during generation: stops output, keeps partial response as assistant message, prints [✋ interrupted]
  • Ctrl+C at prompt: unchanged double-press exit logic
  • Refactor ChatBloc into smaller private methods (_handleChatEvent, _completeSubscription, _cancelSubscription)

Test plan

  • dart analyze passes for chat_adapter and skewr_cli
  • dart format --set-exit-if-changed . passes
  • dart test — chat_adapter 5 tests passed (including stop generation test), skewr_cli 10 tests passed
  • Manual test: Ctrl+C during generation stops output, returns to prompt
  • Manual test: double Ctrl+C at prompt exits

🤖 Generated with Claude Code

Co-Authored-By: Claude Code noreply@anthropic.com

- Add StopGenerationRequested event to ChatBloc
- Switch from emit.forEach to StreamSubscription for cancellation support
- Ctrl+C during generation stops output and keeps partial response
- Ctrl+C at prompt still uses double-press exit logic
- Print [✋ interrupted] when generation is stopped
- Refactor ChatBloc into smaller private methods

Co-Authored-By: Claude Code <noreply@anthropic.com>
@IreneXY IreneXY merged commit 14a2ec7 into main Mar 19, 2026
2 checks passed
@IreneXY IreneXY deleted the 031802 branch March 19, 2026 02:47
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.

2 participants