Skip to content

fix: implement deterministic pause/resume and optimize deep link handling#1713

Open
Angelebeats wants to merge 14 commits intoCapSoftware:mainfrom
Angelebeats:feat/tomahawk-deeplink-fix-final
Open

fix: implement deterministic pause/resume and optimize deep link handling#1713
Angelebeats wants to merge 14 commits intoCapSoftware:mainfrom
Angelebeats:feat/tomahawk-deeplink-fix-final

Conversation

@Angelebeats
Copy link
Copy Markdown

@Angelebeats Angelebeats commented Apr 6, 2026

Resolves deep link action corruption and implements deterministic pause and resume handlers for the cap:// protocol. This ensures reliable remote control from external tools like Raycast and optimizes the notification experience by preventing audio alerts during deep link execution.

Greptile Summary

This PR introduces a new cap:// deep link scheme for deterministic recording control (pause, resume, toggle-pause, stop, start) alongside the existing cap-desktop:// scheme, and registers it in tauri.conf.json. URL sanitization before logging and ok_or_else for lazy allocation are welcome improvements. All three remaining findings are P2 style/UX concerns — no blocking issues were found.

Confidence Score: 5/5

Safe to merge — all findings are P2 style/UX concerns with no blocking correctness or security issues

All three findings are P2: the send_always bypass is a minor UX concern, the pre-action notification is cosmetic, and the _send_notification naming is pure style. None affect data integrity or security. Per the confidence guidance, PRs with only P2 findings default to 5/5.

notifications.rs deserves a second look around send_always and the _send_notification naming before the next refactor

Important Files Changed

Filename Overview
apps/desktop/src-tauri/src/deeplink_actions.rs Adds cap:// parsing for five new actions with good URL sanitization; notification fires before action outcome is confirmed
apps/desktop/src-tauri/src/notifications.rs Introduces send_always() that bypasses user notification preference and a misleadingly-named private helper _send_notification
apps/desktop/src-tauri/tauri.conf.json Adds 'cap' alongside 'cap-desktop' in desktop deep-link schemes; straightforward config change

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[cap:// URL received] --> B[try_from URL]
    B -->|scheme == cap| C{match host/path}
    C -->|record| D[StartDefaultRecording]
    C -->|stop| E[StopRecording]
    C -->|pause| F[PauseRecording]
    C -->|resume| G[ResumeRecording]
    C -->|toggle-pause| H[TogglePauseRecording]
    C -->|unknown| I[ActionParseFromUrlError::Invalid]
    B -->|scheme == cap-desktop| J{domain == action?}
    J -->|yes| K[Parse JSON value param]
    K --> L[StartRecording / OpenSettings / etc.]
    D & E & F & G & H & L --> M[execute]
    M --> N[DeepLinkTriggered.send_always BEFORE action]
    N --> O{action result}
    O -->|Ok| P[Success]
    O -->|Err| Q[error! log]
    style N fill:#f96,color:#000
Loading
Prompt To Fix All With AI
This is a comment left during a code review.
Path: apps/desktop/src-tauri/src/notifications.rs
Line: 96-98

Comment:
**`send_always` bypasses the user's notification preference**

`send_always` sets `always = true`, short-circuiting the `enable_notifications` guard at line 110 regardless of user settings. Deep links are commonly triggered programmatically (e.g., Raycast, scripts) at high frequency, so unexpected notifications on every action are especially disruptive to users who have opted out. The notification sound is already suppressed via the `skip_sound` match on `DeepLinkTriggered``send_always` is not needed to achieve the PR's stated goal of preventing audio alerts.

```suggestion
    pub fn send_always(self, app: &tauri::AppHandle) {
        send_notification(app, self);
    }
```

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: apps/desktop/src-tauri/src/deeplink_actions.rs
Line: 139-149

Comment:
**Notification fires before action executes — false confirmation on no-op**

`DeepLinkTriggered.send_always(app)` is called unconditionally before the action runs. Both `pause_recording` and `resume_recording` return `Ok(())` silently when no recording is active, so the user receives "Action Triggered" even though nothing changed. Moving the notification after a confirmed successful result avoids this misleading feedback.

```rust
let result = match self {
    // ... existing arms ...
};
if result.is_ok() {
    crate::notifications::NotificationType::DeepLinkTriggered.send(app);
}
result
```

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: apps/desktop/src-tauri/src/notifications.rs
Line: 109

Comment:
**Misleading leading-underscore on an actively-used private function**

In Rust, a `_` prefix conventionally marks an item as intentionally unused (suppressing dead-code lints). `_send_notification` is called from two places and is not unused. A name like `send_notification_inner` or `send_notification_impl` communicates the intent more clearly.

```suggestion
fn send_notification_inner(app: &tauri::AppHandle, notification_type: NotificationType, always: bool) {
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix: resolve deep link corruption and im..." | Re-trigger Greptile

Greptile also left 3 inline comments on this PR.

Context used:

  • Context used - CLAUDE.md (source)

Comment on lines +96 to +98
pub fn send_always(self, app: &tauri::AppHandle) {
send_notification_always(app, self);
}
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.

P2 send_always bypasses the user's notification preference

send_always sets always = true, short-circuiting the enable_notifications guard at line 110 regardless of user settings. Deep links are commonly triggered programmatically (e.g., Raycast, scripts) at high frequency, so unexpected notifications on every action are especially disruptive to users who have opted out. The notification sound is already suppressed via the skip_sound match on DeepLinkTriggeredsend_always is not needed to achieve the PR's stated goal of preventing audio alerts.

Suggested change
pub fn send_always(self, app: &tauri::AppHandle) {
send_notification_always(app, self);
}
pub fn send_always(self, app: &tauri::AppHandle) {
send_notification(app, self);
}
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src-tauri/src/notifications.rs
Line: 96-98

Comment:
**`send_always` bypasses the user's notification preference**

`send_always` sets `always = true`, short-circuiting the `enable_notifications` guard at line 110 regardless of user settings. Deep links are commonly triggered programmatically (e.g., Raycast, scripts) at high frequency, so unexpected notifications on every action are especially disruptive to users who have opted out. The notification sound is already suppressed via the `skip_sound` match on `DeepLinkTriggered``send_always` is not needed to achieve the PR's stated goal of preventing audio alerts.

```suggestion
    pub fn send_always(self, app: &tauri::AppHandle) {
        send_notification(app, self);
    }
```

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +139 to +149
match &self {
DeepLinkAction::StartRecording { .. }
| DeepLinkAction::StartDefaultRecording
| DeepLinkAction::StopRecording
| DeepLinkAction::ResumeRecording
| DeepLinkAction::PauseRecording
| DeepLinkAction::TogglePauseRecording => {
crate::notifications::NotificationType::DeepLinkTriggered.send_always(app);
}
_ => {}
}
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.

P2 Notification fires before action executes — false confirmation on no-op

DeepLinkTriggered.send_always(app) is called unconditionally before the action runs. Both pause_recording and resume_recording return Ok(()) silently when no recording is active, so the user receives "Action Triggered" even though nothing changed. Moving the notification after a confirmed successful result avoids this misleading feedback.

let result = match self {
    // ... existing arms ...
};
if result.is_ok() {
    crate::notifications::NotificationType::DeepLinkTriggered.send(app);
}
result
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src-tauri/src/deeplink_actions.rs
Line: 139-149

Comment:
**Notification fires before action executes — false confirmation on no-op**

`DeepLinkTriggered.send_always(app)` is called unconditionally before the action runs. Both `pause_recording` and `resume_recording` return `Ok(())` silently when no recording is active, so the user receives "Action Triggered" even though nothing changed. Moving the notification after a confirmed successful result avoids this misleading feedback.

```rust
let result = match self {
    // ... existing arms ...
};
if result.is_ok() {
    crate::notifications::NotificationType::DeepLinkTriggered.send(app);
}
result
```

How can I resolve this? If you propose a fix, please make it concise.

_send_notification(app, notification_type, true);
}

fn _send_notification(app: &tauri::AppHandle, notification_type: NotificationType, always: bool) {
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.

P2 Misleading leading-underscore on an actively-used private function

In Rust, a _ prefix conventionally marks an item as intentionally unused (suppressing dead-code lints). _send_notification is called from two places and is not unused. A name like send_notification_inner or send_notification_impl communicates the intent more clearly.

Suggested change
fn _send_notification(app: &tauri::AppHandle, notification_type: NotificationType, always: bool) {
fn send_notification_inner(app: &tauri::AppHandle, notification_type: NotificationType, always: bool) {
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src-tauri/src/notifications.rs
Line: 109

Comment:
**Misleading leading-underscore on an actively-used private function**

In Rust, a `_` prefix conventionally marks an item as intentionally unused (suppressing dead-code lints). `_send_notification` is called from two places and is not unused. A name like `send_notification_inner` or `send_notification_impl` communicates the intent more clearly.

```suggestion
fn send_notification_inner(app: &tauri::AppHandle, notification_type: NotificationType, always: bool) {
```

How can I resolve this? If you propose a fix, please make it concise.

@Angelebeats
Copy link
Copy Markdown
Author

Updated the PR to address Greptile bot's P2 suggestions (renamed functions, fixed notification logic). Ready for re-review.

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