Skip to content

fix(desktop): prevent crash when using "Screenshot area picker" shortcut#1697

Open
BenjaVR wants to merge 1 commit intoCapSoftware:mainfrom
BenjaVR:patch-1
Open

fix(desktop): prevent crash when using "Screenshot area picker" shortcut#1697
BenjaVR wants to merge 1 commit intoCapSoftware:mainfrom
BenjaVR:patch-1

Conversation

@BenjaVR
Copy link
Copy Markdown

@BenjaVR BenjaVR commented Mar 30, 2026

Any shortcut assigned to the "Screenshot area picker" setting did not open the area picker and silently failed. This PR fixes this failure and correctly opens the picker again.

Reason was for example systemAudio did not have a (default) value when performing this action, so deserialization of the store failed (with undefined as value). However, with default it now initializes these with a default value.

Greptile Summary

This PR fixes a crash/silent failure when triggering the "Screenshot area picker" shortcut by adding #[serde(default)] to RecordingSettingsStore. The fix ensures that any fields missing from the persisted store JSON (e.g. systemAudio, which was added after some users had already written a store entry) fall back to their Default values rather than causing deserialization to fail.

Key changes:

  • Added default to the #[serde(...)] attribute on RecordingSettingsStore, making all fields optional during deserialization (missing bool fields default to false, missing Option<T> fields default to None)
  • This is a backward-compatible, forward-compatible fix that also benefits any future fields added to the struct

Confidence Score: 5/5

  • Safe to merge — minimal, targeted fix with no risk of regressions.
  • The change is a single attribute addition that correctly addresses the root cause. All field defaults (false for system_audio, None for Option fields) are semantically appropriate. The fix also improves forward compatibility for any future fields added to the struct.
  • No files require special attention.

Important Files Changed

Filename Overview
apps/desktop/src-tauri/src/recording_settings.rs Adds default to the serde attribute on RecordingSettingsStore, so missing fields (e.g. systemAudio) fall back to their Default value instead of causing a deserialization error.

Sequence Diagram

sequenceDiagram
    participant User
    participant Shortcut as Shortcut Handler
    participant Store as Tauri Store
    participant Serde as serde_json
    participant Picker as Area Picker

    User->>Shortcut: Press "Screenshot area picker" shortcut
    Shortcut->>Store: app.store("store").get("recording_settings")
    Store-->>Serde: JSON value (may be missing fields e.g. systemAudio)
    Note over Serde: Before fix: Error on missing fields<br/>After fix: Missing fields use Default values
    Serde-->>Shortcut: Ok(RecordingSettingsStore) with defaults applied
    Shortcut->>Picker: Open area picker
    Picker-->>User: Area picker displayed
Loading

Reviews (1): Last reviewed commit: "fix(desktop): prevent crash when using "..." | Re-trigger Greptile

(2/5) Greptile learns from your feedback when you react with thumbs up/down!

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