fix(gtk): prompt enhance timeout + cancel button #155

Merged
charles merged 2 commits from fix/prompt-enhance-timeout into main 2026-04-16 12:30:40 +00:00
Collaborator

Summary

  • Add 120s timeout to execute_prompt_enhance — if the AI backend hangs, the job fails with "Prompt enhancement timed out" instead of spinning forever. Also covers EntityEnhance which reuses the same function.
  • Add a cancel button (stop icon) next to the spinner while enhancement is in progress. Clicking it restores the original prompt text and dismisses the spinner immediately.
  • Guard EnhanceResult handler: ignore late results that arrive after the user already cancelled, preventing the restored text from being overwritten.

Root cause

Three issues combined to create the stuck-spinner bug:

  1. bridge.enhance_prompt() had no timeout — a hung backend meant the future never completed
  2. No cancel affordance in the UI while enhancing — the user had no way to abort
  3. EnhanceResult didn't check whether enhancement was still active, so late arrivals could overwrite restored text

Test plan

  • cargo build -p loom-gtk
  • Manual: trigger prompt enhance with a working backend → verify spinner shows, result applies, spinner hides
  • Manual: trigger prompt enhance with unreachable backend → verify timeout fires after 120s, error toast shown, spinner hides
  • Manual: trigger prompt enhance, click cancel button → verify spinner hides, original text restored
  • Manual: trigger prompt enhance, cancel quickly, let backend respond later → verify late result is silently ignored

🤖 Generated with Claude Code

## Summary - Add 120s timeout to `execute_prompt_enhance` — if the AI backend hangs, the job fails with "Prompt enhancement timed out" instead of spinning forever. Also covers `EntityEnhance` which reuses the same function. - Add a cancel button (stop icon) next to the spinner while enhancement is in progress. Clicking it restores the original prompt text and dismisses the spinner immediately. - Guard `EnhanceResult` handler: ignore late results that arrive after the user already cancelled, preventing the restored text from being overwritten. ## Root cause Three issues combined to create the stuck-spinner bug: 1. `bridge.enhance_prompt()` had no timeout — a hung backend meant the future never completed 2. No cancel affordance in the UI while enhancing — the user had no way to abort 3. `EnhanceResult` didn't check whether enhancement was still active, so late arrivals could overwrite restored text ## Test plan - [x] `cargo build -p loom-gtk` - [ ] Manual: trigger prompt enhance with a working backend → verify spinner shows, result applies, spinner hides - [ ] Manual: trigger prompt enhance with unreachable backend → verify timeout fires after 120s, error toast shown, spinner hides - [ ] Manual: trigger prompt enhance, click cancel button → verify spinner hides, original text restored - [ ] Manual: trigger prompt enhance, cancel quickly, let backend respond later → verify late result is silently ignored 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(gtk): prompt enhancement — add timeout, cancel button, guard late results
Some checks failed
qa / qa (pull_request) Failing after 1m38s
1ff56bdb42
The prompt enhance spinner would persist forever if the AI backend hung
or the job was killed, because:
- No timeout on the bridge.enhance_prompt() call
- No cancel button in the UI while enhancing
- Late EnhanceResult could overwrite text after user cancelled

Fixes:
- Add 120s timeout to execute_prompt_enhance (also covers EntityEnhance)
- Add a cancel button next to the spinner during enhancement
- Guard EnhanceResult handler against late arrivals when already cancelled
- EnhanceCancelClicked restores original text and dismisses the spinner

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
style: apply cargo fmt to execute_prompt_enhance
All checks were successful
qa / qa (pull_request) Successful in 17m26s
3ad10dad4d
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/loom!155
No description provided.