Repository navigation
fix(inject): GNOME 上自动插入文字时不再反复弹出「远程交互」授权 - #238
Merged
Merged
Conversation
私有 D-Bus 会话总线上的假远程桌面门户与假 EIS 键盘;在基线上三次粘贴都因为没有粘贴工具而失败,门户一次请求也没收到。
GNOME 没有虚拟键盘协议。没装 dotool / ydotool 时,粘贴键原来经 Xwayland 的 XTEST 发出, Xwayland 替每个 X11 连接向门户申请一次不记住的远程交互,十分钟没用或 Xwayland 重启后又要 重新授权。 现在 Voltip 自己经 xdg-desktop-portal 的 RemoteDesktop 接口申请只含键盘的远程交互 (persist_mode 2),用 libei 键盘按组合键,键码按 EIS 给的键盘布局查找;门户返回的 restore token 存进系统钥匙串(voltip.inject.remote-desktop),之后的粘贴和重启后都用它 恢复授权,不再弹窗。会话只在一次粘贴或语音编辑的复制期间打开。token 失效或被撤销时重新 申请一次;用户拒绝时文字留在剪贴板,结果卡片写「未获准远程交互,文字已复制」,下次粘贴再问。 GNOME 上的顺序:dotool → ydotool → 远程桌面门户 → enigo x11rb → xdotool。
两侧各在一个 ubuntu:26.04 容器里跑 headless GNOME Shell 50.1、带 -enable-ei-portal 的 Xwayland 与 xdg-desktop-portal-gnome;harness 走桌面壳的粘贴路径,answer.py 经 AT-SPI 回答「远程桌面」窗口并计数,verdict.sh 逐步比较预期并输出 PASS 或 FAIL。
平台说明请用户在「密码和密钥」里按这个名字查找并删除;新名字说明它属于粘贴。这一条目尚未随任何版本发布,不需要迁移。
平台说明写明 GNOME 第一次为什么请求「远程交互」、窗口怎么点、如何撤销,以及「仅复制到剪贴板」这个替代办法;§14.9 补上复现方法与结果:基线 11 次粘贴弹 4 次窗口,修复后只弹 1 次。
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 7 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Merged
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.
问题
修复 GitHub 上编号 235 的 issue:GNOME(Mutter)上自动插入文字时反复弹出「远程交互」授权。
Voltip 原来经 Xwayland 的 XTEST 按粘贴键。Xwayland 用
-enable-ei-portal时以自己的名义向远程桌面门户申请远程交互,不能记住授权,只按命令名把会话留 10 分钟。所以 Voltip 换路径启动(AppImage 每次挂载到新目录)、过了 10 分钟、重新登录之后,下一次粘贴都会再弹授权窗口。修法
voltip-inject新增门户后端(src/portal/)。一次粘贴(或语音编辑的一次复制)开一个org.freedesktop.portal.RemoteDesktop会话:CreateSession→SelectDevices(只要键盘,persist_mode2,有保存的 restore token 就带上)→Start→ConnectToEIS,经 libei 键盘(reis 0.7.1)按组合键,按完Session.Close。键码按 EIS 公布的 XKB 布局查找,Ctrl+V、Ctrl+Shift+V、Shift+Insert 照旧。dotool、ydotool、门户、(XWayland)enigo 的 XTEST、xdotool。dotool、ydotool不弹窗,只有用户装了才可用,所以排在前面;XTEST 会让 Xwayland 再次申请授权,所以排在门户后面,只在这个桌面没有这一接口时用到。KDE、wlroots 等其他桌面不变。dev.voltip.desktop,条目voltip.paste.remote-desktop)。启动时不读,第一次需要粘贴时才读;每拿到新 token 就替换。取消、未答复、授权被撤销或 token 失效时删除,下一次粘贴只再问一次。remote_denied,「未获准远程交互,文字已复制」。remote_unavailable,「远程交互不可用,文字已复制」。这时不再交给 XTEST。测试
crates/voltip-inject/tests/gnome_remote_desktop.rs:在私有 D-Bus 会话总线上起假门户和假 EIS,覆盖 token 复用、轮换、撤销、拒绝、门户不可用和键盘布局查找。regression_gnome_pastes_ask_for_remote_interaction_once:基线上 3 次粘贴授权 0 次,修复后 1 次。regression_a_portal_failing_after_its_check_is_broken_not_unavailableregression_a_paste_the_portal_cannot_take_stops_with_its_reasonregression_a_portal_gone_after_the_probe_stops_with_its_reasonscripts/repro-gnome-remote-desktop.sh在 Ubuntu 26.04 容器里起 GNOME 50(headless GNOME Shell 50.1、带-enable-ei-portal的 Xwayland 24.1.10、xdg-desktop-portal-gnome 50.0),用 AT-SPI 回答授权窗口并计数。同样 11 次粘贴,基线弹 4 次,修复后弹 1 次;修复后撤销授权会再问一次。验证
变基前(HEAD
94acd67f,基于20da96ef):make verify通过,Rust 行覆盖率 92.99%。gate test只有基线已有的两个失败(voltip-relay --test socket、voltip-transport --test link),gate clippy通过。变基到 #236 之后:
3d8c79b0(chore(deps): 合并 dependabot 11-08 的五组依赖升级并适配 zbus 6 #236 合并后的 main)。12 个提交原样重放,git range-diff显示每个补丁都和原来相同,没有文本冲突;docs/dictation.md两边的改动都保留。Cargo.lock:git 自动合并后文件不一致。main 上 zbus 5.19.0 和 6.2.1 并存,voltip-inject依赖列表里只写"zbus",cargo 无法确定指哪个版本。用cargo metadata在每个提交上重新生成,没有手改。结果是 main 的锁文件加上reis和voltip-inject的依赖列表,cargo metadata --locked通过。voltip-inject继续用zbus =5.19.0,钥匙串的 Secret Service 和 Tauri 插件用的也是这个版本。crates/voltip-inject/Cargo.toml里说明 zbus 5 现在由谁引入,voltip-focus 已改用 zbus 6。724a07e6上跑了下面这些检查,都通过:cargo fmt --all -- --check、cargo deny check bans licenses sourcescargo clippy -p voltip-inject -p voltip-desktop --all-targets(verify 用的特性,-D warnings)cargo test -p voltip-inject:单元测试 97 个,gnome_remote_desktop19 个voltip-core的 lib 测试 621 个;桌面壳的 lib 测试 83 个、tests/dictation.rs11 个UPDATE_IPC_FIXTURES=1 cargo test -p voltip-tauri-bridge --test contract,夹具没有变化@voltip/shared513 个、@voltip/desktop613 个 vitest 测试,以及两者的 typecheckmake verify,也没有重跑 GNOME 容器复现。文档
docs/site/{,zh/}reference/platforms.md「GNOME 的远程交互授权」:为什么会问、怎么回答、如何撤销,以及「仅复制到剪贴板」这个替代办法。docs/site/{,zh/}dictation/output.md:无法粘贴的原因表与结果卡片表。docs/site/{,zh/}privacy.md:钥匙串里多保存的这一项。docs/dictation.md§14.9:设计与出处。docs/acceptance.md:加一行。需要在真机上验证
dotool、ydotool:第一次听写弹出「远程桌面」窗口,允许并记住;之后连续听写、10 分钟后、重启 Voltip(.deb与 AppImage)、注销再登录,都不再弹。GDK_BACKEND=x11运行时同样只问一次;语音编辑读选区不额外弹窗。voltip.paste.remote-desktop:下次粘贴再问一次,之后不再问。