Skip to content

fix: cancel in-flight generation when starting a new session#289

Merged
quiet-node merged 1 commit into
mainfrom
claude/practical-panini-90a544
Jul 1, 2026
Merged

fix: cancel in-flight generation when starting a new session#289
quiet-node merged 1 commit into
mainfrom
claude/practical-panini-90a544

Conversation

@quiet-node

Copy link
Copy Markdown
Owner

Description

Starting a new session now stops the in-flight backend generation instead of only clearing the frontend view. Previously the old stream kept running and held the engine's single decode slot, so a message sent in the new session queued behind the old one until it finished.

Key changes

  • reset() (new chat via +, summon) and loadMessages() (loading a conversation from history) now signal cancel_generation when a generation is active, routed through the same pendingCancelRef plumbing the pause button uses so the next ask() awaits the cancel round-trip before starting a new turn.
  • Extracted a shared requestBackendCancel() helper used by cancel(), reset(), and loadMessages().
  • search_pipeline shares the same GenerationState, so an in-flight /search turn is stopped on a new session as well.

Testing

  • Added unit tests: reset() and loadMessages() cancel the backend when a generation is mid-stream, and do not fire a cancel when idle.
  • useModel.ts stays at 100% coverage; full frontend suite green.

Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>
@quiet-node quiet-node merged commit da432fa into main Jul 1, 2026
5 checks passed
@quiet-node quiet-node deleted the claude/practical-panini-90a544 branch July 1, 2026 22:55
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