Skip to content

feat: Add cancel button for fast mode chat messages - #6

Merged
mo-tunn merged 1 commit into
mo-tunn:mainfrom
melut42:feature/chat-cancel-button
Apr 21, 2026
Merged

feat: Add cancel button for fast mode chat messages#6
mo-tunn merged 1 commit into
mo-tunn:mainfrom
melut42:feature/chat-cancel-button

Conversation

@melut42

@melut42 melut42 commented Apr 18, 2026

Copy link
Copy Markdown
Contributor

Summary

When using the chat interface (especially in "fast mode"), users previously did not have a way to cancel an ongoing AI generation. This PR introduces a stop/cancel button that replaces the send button while the AI is streaming a response, allowing users to safely abort long-running or stuck requests.

User-Visible Changes

  • UI: A new Stop button (◼) appears in place of the Send button (➤) when a message generation is in progress.
  • Behavior: Clicking the Stop button aborts the ongoing AI stream immediately and resets the chat input UI to its idle state.

Implementation Details

  • Added .stop-btn to index.html and implemented its styles/hover states in style.css.
  • Modified messaging.js to toggle visibility between the send-btn and stop-btn based on the streaming state.
  • Exposed a cancelMessage function in messaging.js which triggers the abort-message IPC call.
  • Bound the click event for the new stop button in bootstrap.js.

@mo-tunn mo-tunn left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the stop button UX — the direction is good. However, I don’t think this is safe to merge yet due to a few blocking issues:

  1. Streaming state is still force-reset without guaranteed backend cancellation (high impact)
    In renderer/js/panel/bootstrap.js, the textarea focus handler forcefully resets isStreaming and re-enables controls without ensuring the in-flight request is aborted. This can allow overlapping requests and inconsistent UI/session state.

  2. 60s timeout has the same race condition (high impact)
    In renderer/js/panel/messaging.js, the safety timeout sets the UI back to idle and re-enables send, but it does not guarantee the active request is actually cancelled. A slow but valid response can still be running while users send another message.

  3. Multi-monitor panel positioning remains incorrect for negative coordinates (medium impact)
    In main.js:getPanelPosition(), saved x/y < 0 values are treated as invalid. This breaks common layouts where secondary displays are positioned to the left/top of the primary display.

  4. PR scope is too broad for a cancel-button feature (medium impact)
    This PR includes unrelated carry-over changes (multi-monitor, AssemblyAI/PTT, prompt updates, .gitignore) from earlier commits. Please keep this PR focused to the cancel-button behavior so it can be reviewed and merged safely.

Please address the blockers above and I’ll re-review quickly.

@mo-tunn mo-tunn added the bug Something isn't working label Apr 19, 2026
@melut42
melut42 force-pushed the feature/chat-cancel-button branch from 3f6534c to a569731 Compare April 20, 2026 12:42
@melut42

melut42 commented Apr 20, 2026

Copy link
Copy Markdown
Contributor Author

Added AbortController and api.invoke("abort-message") for real backend cancellation.

Fixed race conditions by moving state resets to onAIDone and onAIError.

Synchronized UI (Send/Stop buttons) using a dedicated cancelMessage function.

Cleaned up the scope; no unrelated changes included.

@melut42
melut42 requested a review from mo-tunn April 20, 2026 12:48
@mo-tunn
mo-tunn merged commit aa4913d into mo-tunn:main Apr 21, 2026
4 checks passed
@melut42
melut42 deleted the feature/chat-cancel-button branch April 21, 2026 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants