fix(live-voice): keep the microphone policy out of unrelated permissions - #1280
Merged
Merged
Conversation
installLiveMicrophonePermissionHandlers runs on session.defaultSession, which also carries the main renderer. Installing a permission handler replaces the platform default for every permission on that session, so limiting the policy to `media` was never what actually happened: everything else was denied too. clipboard-sanitized-write was denied with them, which made every navigator.clipboard.writeText in the UI reject with "Write permission denied" — the transcript copy button, the table copy button and the session id copy all failed silently, and the failure looked like a clipboard problem rather than a permission-scope one. Non-media permissions now keep the platform default; `media` stays gated to the trusted main frame with an active microphone lease. The Live Voice permission test asserts the clipboard permission so the shadowing cannot come back.
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
应用自带的复制按钮全部失效:消息复制、表格复制、会话 ID 复制等都只给出「复制失败」,控制台报
根因
installLiveMicrophonePermissionHandlers(apps/desktop/electron/main/index.ts)被装到了session.defaultSession上,而主界面 renderer 用的正是这个会话。给会话安装
setPermissionRequestHandler/setPermissionCheckHandler会覆盖该会话上所有权限的默认决定,而策略本身只按
media判断:于是
clipboard-sanitized-write一并被拒,渲染层里全部navigator.clipboard.writeText()失败(
Markdown.tsx、MarkdownTable.tsx、Sidebar.tsx、TranscriptMenu.tsx、PluginInstallDialog.tsx、ProviderHeadersEditor.tsx、OAuthLoginDialog.tsx、StartupRecovery.tsx、use-preview-target.ts)。失败表现为「复制按钮坏了」,掩盖了真正的原因。
影响范围:
v0.16.0-beta.1与当前main均受影响;v0.15.10正式版没有这个文件(复制正常)。改动
microphone-permissions.ts:两个处理器只接管media,其余权限保持平台默认;麦克风仍要求可信主frame + 有效租约,判定逻辑本身未改。
live-voice-permission.test.mjs:补上clipboard-sanitized-write的回归断言(原先断言notifications为false的用例改为true,即"非 media 权限不被本策略覆盖")。验证
node --test apps/desktop/test/live-voice-permission.test.mjs:改前AssertionError失败 →改后通过(先把原文件放回去跑出红,再恢复修复跑出绿)。
navigator.clipboard.writeText()(document.hasFocus() === true)→ 改前Write permission denied,改后写入成功。
tsc的结果与未改动的基线逐项相同(tests 2134 / pass 1921 / fail 208;tsc 1209 行),故无回归;完整
pnpm test由 CI 执行。pnpm check:agent-policy、pnpm check:pr-base通过。复现(修复前)
打开应用,点聊天内容里的复制按钮(或表格上的复制),或在渲染层直接执行: