Skip to content

Studio: let Allow microphone recover from a saved "Don't allow" on Windows - #9006

Merged
shimmyshimmer merged 2 commits into
mainfrom
studio/webview-microphone-permission-9001
Aug 17, 2026
Merged

shimmyshimmer merged 2 commits into
mainfrom
studio/webview-microphone-permission-9001

Conversation

@shimmyshimmer

Copy link
Copy Markdown
Member

Fixes #9001.

What happens

The reporter clicked "Don't allow" on the microphone prompt and could not find a way back. They are right that this is ours rather than Windows.

The desktop app runs on WebView2, and WebView2 saves the answer to a permission prompt in its profile. Once "Don't allow" is stored, nothing in Unsloth undoes it:

  • We never handled the permission event, so the saved deny is the only state there is. PermissionRequested, SetPermissionState and ICoreWebView2Profile appear nowhere in src-tauri.
  • WebView2 has no site-settings UI, so the toast telling people to "allow microphone access for this Unsloth page" describes something the desktop app cannot show.
  • Reinstalling does not help. clear_webview_caches deliberately clears only Cache, Code Cache, GPUCache and Service Worker, keeping storage, and the profile lives in %LOCALAPPDATA%\ai.unsloth.studio\EBWebView which the uninstaller does not touch.
  • The app is absent from Windows privacy settings because the denial happens inside WebView2, so the request never reaches the OS and Windows never records the app as having asked.

macOS and Linux do not have this trap: WKWebView defers to the system permission, which System Settings exposes, and webkit2gtk asks per session.

The change

  • New reset_microphone_permission command. On Windows it calls ICoreWebView2Profile4::SetPermissionState(MICROPHONE, origin, DEFAULT), which erases the saved answer. It never grants anything, so consent still comes from the prompt the next request raises. It is a no-op elsewhere.
  • Allow microphone clears the saved answer before calling getUserMedia, so the button does what it says on the first click instead of being refused from stored state.
  • Best effort by design. A browser tab has no command to call, and a WebView2 runtime older than the permission APIs has nothing to clear. Neither rejects, because getUserMedia is still worth attempting.
  • The blocked-microphone messages stop pointing desktop users at browser site permissions and name Settings > Voice instead. Off the desktop app the browser wording is unchanged.
  • The origin comes from the window URL rather than the renderer, so there is no input to validate, and permission_origin refuses URLs that SetPermissionState would reject with E_INVALIDARG.

Verification

The Windows path cannot run on the machine I develop on, so I verified it in the two places that carry the risk:

  • The COM body compiles for x86_64-pc-windows-msvc against the pinned webview2-com 0.38, which checks the interface casts, the completion-handler closure type, &HSTRING as the PCWSTR argument and the enum constants. The app's full Windows cross-check is not possible here because aws-lc-sys needs a Windows C toolchain.
  • Everything except the COM call is platform independent and compiles on macOS: the URL handling, the with_webview hop, the channel and the timeout.
  • webview.controller() returning ICoreWebView2Controller is already relied on by setup_windows_browser_guards, so that junction is not new.

Tests: 2 Rust cases for origin derivation, 6 frontend cases covering the desktop reset, the browser no-op, a rejecting runtime, ordering of the reset before the request, the message change, and command registration. The four that can regress silently fail when the fix is reverted. cargo test 356 passed, frontend suite 2882 passed, i18n:check:strict and typecheck clean, and the two eslint errors in the dictation adapter are pre-existing on main.

Worth a follow-up

Camera and notification prompts have the same shape and the same missing handler, so the next one of those to be added will land users in the same dead end.

…ndows

WebView2 saves a denied microphone prompt in its profile and ships no site-settings
UI, so one accidental "Don't allow" blocked dictation permanently. The profile
survives reinstalls, and because the request never reaches the OS, Windows privacy
settings never list the app to toggle either, which leaves the user with nothing to
undo it (#9001).

Allow microphone now clears that saved answer before it asks. The reset only erases
the stored decision, never grants access: the next getUserMedia raises the same
prompt the first one did. It is best effort, since a browser tab has no command to
call and a WebView2 runtime older than the permission APIs has nothing to clear, and
in both cases the request is still worth attempting.

The blocked-microphone messages also stop pointing desktop users at browser site
permissions, which the desktop WebView has no UI for.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8aafa6ae0d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread studio/frontend/src/i18n/locales/en.ts Outdated
Comment on lines +284 to +285
micAccessBlocked:
"Microphone access was blocked. Allow microphone access for this Unsloth page, then try again.",
"Microphone access was blocked. Click Allow microphone to be asked again.",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep browser denial recovery instructions

In a normal browser tab, resetMicrophonePermission() immediately returns because isTauri is false, so a saved denial remains in effect and clicking Allow microphone generally rejects again without showing a prompt. Since this shared message is also rendered outside the desktop app, replacing the previous site-permission guidance misdirects browser users; keep the original browser wording or select the message based on isTauri.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Right, and fixed in 832effb. The premise holds: resetMicrophonePermission returns at if (!isTauri) return;, so a browser tab keeps its saved deny and clicking the button rejects again with no prompt. Telling those users they will be asked again was wrong, and Studio runs in a browser tab as often as it runs in the desktop app.

There was a second problem in the same change that the comment surfaces indirectly: I had only reworded en.ts, so English disagreed with all eleven other locales, which still carried the page-permission wording. micAccessBlocked now goes back to that wording everywhere, and a new micAccessBlockedDesktop covers the desktop build, selected on isTauri at the call site the way the dictation adapter already does.

I worded the desktop message as the retry plus the system privacy settings rather than naming the WebView2 prompt, because the reset is a deliberate no-op on macOS and Linux: WKWebView defers to the system permission and webkit2gtk asks per session. So the one string holds on all three desktop platforms.

Added to all twelve locales, since i18n:check:strict fails on an en-only key. Three new tests, each mutation checked: collapsing the toast back to one message fails the selection test, restoring the desktop wording on the shared key fails the browser-copy test, and dropping the key from a single locale fails the coverage test and the parity check.

micAccessBlocked is shown in Settings > Voice on the desktop app and in a
browser tab, and the reset behind Allow microphone only exists on the
desktop: resetMicrophonePermission returns early when isTauri is false. So
a browser keeps its saved deny, clicking the button rejects again with no
prompt, and telling those users they will be asked again is wrong.

The shared key goes back to the page-permission wording every other locale
already carried, and a new micAccessBlockedDesktop covers the desktop
build. Its text names the retry and the system privacy settings, so it also
holds on macOS and Linux, where the reset is a deliberate no-op.

Added to all twelve locales, since strict parity fails on an en-only key.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 832effbf1e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@shimmyshimmer
shimmyshimmer merged commit 6453075 into main Aug 17, 2026
38 of 39 checks passed
@shimmyshimmer
shimmyshimmer deleted the studio/webview-microphone-permission-9001 branch August 17, 2026 09:56
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.

[Bug] Unsloth does not activate the microphone after having blocked it.

1 participant