Files
windmill/frontend/src/lib/components/copilot
114c41251a feat(frontend): improve AI chat cancel and interrupted-turn handling (#9539)
* feat(frontend): improve AI chat cancel and interrupted-turn handling

- Escape stops the in-flight generation when focus is on the chat
  (composer, messages, panel) — capture-phase listener so neither the
  session Monaco editor nor mounted-but-closed modals swallow the key
- When a turn yields no output (or is cancelled before any), roll it
  back and restore the message to the composer
- When a turn is cancelled or fails mid-way, keep the completed
  tool-paired steps and the partial answer text as context so a
  follow-up like "continue" picks up from there
- Animate the thinking-block collapse like tool boxes (slide 150ms)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(frontend): address review findings on interrupted-turn handling

- Guard the catch in sendRequest so a post-commit throw (e.g. saveChat)
  cannot commit the turn a second time or mis-flag the user message
- Delete the persisted chat entry when rolling back a first turn empties
  the transcript (saveChat no-ops on empty, leaving a stale entry)
- restoreInstructions skips when the user already typed a new draft
- Use stopImmediatePropagation so one Escape on body focus cannot cancel
  several mounted chat panels at once

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* chore(frontend): tighten comments and dedupe tests in AI chat changes

Keep each invariant comment once at the place it would be broken; drop
narration and repeated rationale. Remove near-duplicate test cases
(chatLoop boundary permutations, cancel-before-output subset).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* docs: add comment policy to AGENTS.md core principles

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* docs: comments must describe current code, not PR drafting history

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(frontend): treat completed reasoning-only turns as unsent

A turn that finishes without abort but emits only reasoning produced a
display bubble, so the empty-turn rollback (keyed on display output)
skipped it and the user message was silently swallowed. Key the
decision off usable output instead. Also trim comment blocks to the
AGENTS.md 4-line norm, splitting rationale to its break-site.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Ruben Fiszel <ruben@windmill.dev>
2026-06-12 17:27:36 +02:00
..
2025-11-20 15:06:00 +00:00
2026-05-28 16:52:26 +00:00