Skip to content

dropdown type safety#1079

Open
ruszabarov wants to merge 3 commits intocjpais:mainfrom
ruszabarov:unload-setting-typesafety
Open

dropdown type safety#1079
ruszabarov wants to merge 3 commits intocjpais:mainfrom
ruszabarov:unload-setting-typesafety

Conversation

@ruszabarov
Copy link
Copy Markdown

Before Submitting This PR

Human Written Description

Improving type safety of dropdowns with a generic on DropdownOption, allowing option to be typed instead of plain strings.

Related Issues/Discussions

#1071 (comment)

Testing

Tested all dropdowns for interactivity. Tested some of simple options like overlay position -- works correctly. Biggest risks are the Whisper acceleration option (wasn't able to find it in the settings) and the clipboard options since I had to change rust code for those.

AI Assistance

  • AI was used (please describe below)

Used codex 5.4 for get_available_accelerators() rust function and to add the generic parameter T to DropdownOption in typescript.

@ruszabarov ruszabarov force-pushed the unload-setting-typesafety branch from c51deae to f65da42 Compare March 17, 2026 16:06
@ruszabarov ruszabarov changed the title Dropdown Typesafety dropdown type safety Mar 17, 2026
@ruszabarov ruszabarov force-pushed the unload-setting-typesafety branch 2 times, most recently from b3300d5 to b3b8e7f Compare March 17, 2026 16:16
@cjpais
Copy link
Copy Markdown
Owner

cjpais commented Mar 18, 2026

Whisper acceleration option is in experimental settings, must toggle it on in advanced

@ruszabarov
Copy link
Copy Markdown
Author

Tested on M1 Pro. Works correctly when switching between CPU and GPU.

@ruszabarov ruszabarov force-pushed the unload-setting-typesafety branch 2 times, most recently from 3016654 to 18652f5 Compare March 18, 2026 03:33
@ruszabarov
Copy link
Copy Markdown
Author

ruszabarov commented Mar 18, 2026

Updated retention history serialization to use lowercase. Previously, a mix of styles was used: lowercase for day3, week2, etc and snake_case for preserve_limit. I had to add a rename to preserve backwards compatibility.

An alternative solution would be to use snake_case everywhere and add aliases for lowercase to retain backwards compatibility. Depends on the migration path you want to take.

@cjpais
Copy link
Copy Markdown
Owner

cjpais commented Mar 19, 2026

#1085 will go in first then we will update this

I will take a look and test and decide the best path forward. Thanks for the cleanup in general, it's much appreciated, just needs a solid testing. Don't want to break things in the name of cleanup

@VirenMohindra
Copy link
Copy Markdown
Contributor

VirenMohindra commented Mar 19, 2026

@ruszabarov we just merged #1085, good to rebase now, ping me when you need some testers!

@cjpais
Copy link
Copy Markdown
Owner

cjpais commented Mar 19, 2026

@ruszabarov, could you do a test. mainly what I want to know, is does this change wipe out existing user settings

if you could, go to the current release build, change a bunch of settings and then run this. just making sure everything is backwards compatible. ideally we change as little as possible with regards to the current string names.

@cjpais cjpais closed this Mar 19, 2026
@cjpais cjpais reopened this Mar 19, 2026
@ruszabarov
Copy link
Copy Markdown
Author

@cjpais I set the following settings in the release version, then launched this dev version and the settings were preserved. I used the following values

  • Overlay Position: Bottom
  • Unload Model: After 5 minutes
  • Paste Method: Direct
  • Clipboard Handing: Copy to Clipboard
  • Auto Submit: Enter
  • Auto-Delete Recordings: After 3 days
  • Keyboard Implementation: Handy Keys
  • Whisper Acceleration: GPU
    (Microphone and Output Device were untouched)

Also checked the raw settings_store.json and the current release version stores values like min5, days3, and preserve_limit, so the new serialization should be compatible.

Backwards compatibility is something I paid close attention to when making these changes. That is why I went with lowercase serialization instead of snake_case. This ensures backwards compatibility but breaks style (snake_case is used almost everywhere else).

@ruszabarov
Copy link
Copy Markdown
Author

@VirenMohindra I could use another set of eyes on the Whisper Accelerator and Ort Accelerator option 🙂

Copy link
Copy Markdown
Contributor

@VirenMohindra VirenMohindra left a comment

Choose a reason for hiding this comment

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

LGTM, nice work

Comment on lines +110 to +112
commands.updateRecordingRetentionPeriod(value ?? "never"),
model_unload_timeout: (value) =>
commands.setModelUnloadTimeout(value ?? "min5"),
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.

nit: is it possible to pull these out and share them? if we ever deviate from never and min5 as defaults, we should have a single source of truth

Copy link
Copy Markdown
Author

@ruszabarov ruszabarov Mar 21, 2026

Choose a reason for hiding this comment

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

I decided to Exclude all the undefined values from AppSettings. undefined is not a legal option for value. The behavior should stay effectively the same since we were doing as boolean, as string, ?? "never", etc before

Comment on lines +789 to +793
let whisper_options = vec![
WhisperAcceleratorSetting::Auto,
WhisperAcceleratorSetting::Cpu,
WhisperAcceleratorSetting::Gpu,
];
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.

nit: if WhisperAcceleratorSetting gains a new variant (like CoreMl), this list won't update and the compiler won't warn. worth either mirroring the ort pattern or adding a comment explaining why these three are always the full set

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Added a comment

@ruszabarov ruszabarov force-pushed the unload-setting-typesafety branch from f4aff38 to 58022bf Compare March 21, 2026 18:27
@ruszabarov ruszabarov force-pushed the unload-setting-typesafety branch from 58022bf to efe4979 Compare March 27, 2026 05:25
@ruszabarov
Copy link
Copy Markdown
Author

ruszabarov commented Mar 27, 2026

@cjpais just rebased and fixed all the conflicts. Since we are building a combined list Auto, [GPU devices...], CPU, we can no longer enforce a strict type on that dropdown, so I had to downgrade it to just string. Please check and merge if you have a chance 🙂

@ruszabarov ruszabarov force-pushed the unload-setting-typesafety branch from efe4979 to c348e91 Compare March 27, 2026 05:31
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.

3 participants