Skip to content

feat: cancel hands-free recording with Escape#143

Open
aliaksandrsen wants to merge 2 commits into
amicalhq:mainfrom
aliaksandrsen:feat/escape-cancel-hands-free
Open

feat: cancel hands-free recording with Escape#143
aliaksandrsen wants to merge 2 commits into
amicalhq:mainfrom
aliaksandrsen:feat/escape-cancel-hands-free

Conversation

@aliaksandrsen

@aliaksandrsen aliaksandrsen commented May 3, 2026

Copy link
Copy Markdown

Summary

  • Add Escape as a global cancel action while hands-free recording is active
  • Discard the active recording via the existing cancellation path instead of stopping/submitting it
  • Debounce Escape detection so holding the key only triggers one cancel event

Closes #141

Test plan

  • pnpm type:check
  • pnpm lint (passes with existing warnings)
  • Manual desktop verification: start hands-free recording, press Escape, confirm recording is discarded and app returns to idle

Summary by CodeRabbit

  • New Features
    • Pressing Escape now reliably cancels an active hands-free recording: the session ends immediately, buffered audio is discarded, and the recording is reported as cancelled (no automatic save).

Copilot AI review requested due to automatic review settings May 3, 2026 16:31
@coderabbitai

coderabbitai Bot commented May 3, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6f7aba10-356c-4612-b8c0-c64f5cd37c56

📥 Commits

Reviewing files that changed from the base of the PR and between 13f4bbb and f5f33ac.

📒 Files selected for processing (1)
  • apps/desktop/src/main/managers/shortcut-manager.ts

📝 Walkthrough

Walkthrough

This PR adds Escape-key cancellation for hands-free recording: ShortcutManager detects an exact Escape press and emits escape-triggered; RecordingManager listens and calls cancelHandsFreeRecording(), which ends the recording with termination code "escape" and triggers the existing cancellation flow.

Changes

Escape Key Cancellation for Hands-Free Recording

Layer / File(s) Summary
Data Shape
apps/desktop/src/main/managers/recording-manager.ts, apps/desktop/src/main/managers/shortcut-manager.ts
TerminationCode now includes "escape"; exactMatchState gains escape: false to track Escape shortcut transitions.
Escape Detection
apps/desktop/src/main/managers/shortcut-manager.ts
New isEscapePressed() helper returns true only when exactly one active key maps to Escape; checkShortcuts() computes escapeMatch, emits escape-triggered on transition, and updates exactMatchState.escape.
Recording Handler & Integration
apps/desktop/src/main/managers/recording-manager.ts, apps/desktop/src/main/managers/shortcut-manager.ts
setupShortcutListeners wires escape-triggered to cancelHandsFreeRecording(); new public cancelHandsFreeRecording() calls endRecording("escape") when in hands-free recording mode to trigger the cancellation path.

Sequence Diagram

sequenceDiagram
    participant User
    participant ShortcutManager as Shortcut Manager
    participant RecordingManager as Recording Manager

    User->>ShortcutManager: Press Escape key
    activate ShortcutManager
    ShortcutManager->>ShortcutManager: isEscapePressed() checks exact match
    ShortcutManager->>ShortcutManager: emit escape-triggered (on transition)
    deactivate ShortcutManager

    ShortcutManager->>RecordingManager: escape-triggered event
    activate RecordingManager
    RecordingManager->>RecordingManager: cancelHandsFreeRecording()
    RecordingManager->>RecordingManager: endRecording("escape")
    RecordingManager->>RecordingManager: Discard buffered audio / trigger cancellation flow
    RecordingManager->>User: Emit recording-cancelled / exit hands-free mode
    deactivate RecordingManager
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🐰 A key, a hop, and down it goes,
Escape clears the tracks and bows,
Hands-free hush in just one press,
Softly gone — no more distress 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: cancel hands-free recording with Escape' directly and clearly summarizes the main change: adding Escape key functionality to cancel hands-free recording.
Linked Issues check ✅ Passed The code changes fulfill all key requirements from issue #141: Escape key cancels active recording [#141], discards captured audio [#141], exits hands-free mode [#141], and returns app to idle state [#141].
Out of Scope Changes check ✅ Passed All changes are directly scoped to issue #141: recording-manager and shortcut-manager modifications implement Escape detection and cancellation logic without introducing unrelated features or alterations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@aliaksandrsen aliaksandrsen changed the title Cancel hands-free recording with Escape feat: cancel hands-free recording with Escape May 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds an Escape-key cancellation path for hands-free recording in the desktop app, allowing users to discard an in-progress hands-free session and return to idle.

Changes:

  • Detect Escape key presses in ShortcutManager and emit an escape-triggered event with basic debouncing.
  • Handle escape-triggered in RecordingManager by cancelling an active hands-free recording via endRecording("escape").
  • Extend termination codes to include "escape".

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
apps/desktop/src/main/managers/shortcut-manager.ts Adds Escape detection + debounced event emission for cancellation.
apps/desktop/src/main/managers/recording-manager.ts Listens for Escape event and cancels hands-free recordings using a new termination code.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/desktop/src/main/managers/shortcut-manager.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/desktop/src/main/managers/shortcut-manager.ts`:
- Line 16: ESCAPE_KEY_CODES currently mixes macOS and Windows keycodes causing
the Minus key to be treated as Escape; change the constant construction to be
platform-specific (e.g., use process.platform === 'darwin' to include 53 only on
macOS and include 0x1b only on non-macOS/Windows as appropriate) so
isEscapePressed() checks the correct set for the running OS; update the
declaration of ESCAPE_KEY_CODES and any related logic that references it
(ESCAPE_KEY_CODES and isEscapePressed) to use the platform-gated set.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7a5214b7-910c-4a5c-92d5-994bd4d5f5b9

📥 Commits

Reviewing files that changed from the base of the PR and between 3dc2afc and 13f4bbb.

📒 Files selected for processing (2)
  • apps/desktop/src/main/managers/recording-manager.ts
  • apps/desktop/src/main/managers/shortcut-manager.ts

Comment thread apps/desktop/src/main/managers/shortcut-manager.ts Outdated
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.

Feature Request: Add "Escape" Key to Cancel Hands-Free Recording Mode

2 participants