fix(infra): 接入 tauri-plugin-single-instance 防双实例双插入 (closes #50)#71
Merged
Conversation
closes #50 现象:/Applications/OpenLess.app 与 dev build 同时存在时,两个进程各自注册 macOS CGEventTap 监听全局热键。用户按 Right Option 一次: - A 实例捕获 → ASR session 1 → polish → Cmd+V - B 实例同时捕获 → ASR session 2 → polish → Cmd+V 结果:用户口述被插入两份。 修复: - Cargo.toml: 加入 tauri-plugin-single-instance v2 - lib.rs: builder 第一个 plugin 即注册它;第二个进程启动时回调聚焦已有主窗口 激活信号通过 plugin 内部 socket 传递,无需额外 IPC 设计。
Reviewer's guide (collapsed on small PRs)Reviewer's GuideIntegrates the tauri-plugin-single-instance to enforce a single running instance of the Tauri app and focus the existing main window when a second instance is launched, preventing duplicated hotkey handling and double text insertion, along with the necessary dependency wiring in Cargo.toml/lock. Sequence diagram for handling a second OpenLess instance launchsequenceDiagram
actor User
participant macOS
participant SecondInstance
participant SingleInstancePlugin
participant FirstInstance
participant MainWindow
User->>macOS: Launch OpenLess second instance
macOS->>SecondInstance: Start process
SecondInstance->>SingleInstancePlugin: Initialize single instance lock
SingleInstancePlugin-->>SecondInstance: Detect existing running instance
SingleInstancePlugin->>FirstInstance: Send activation signal
FirstInstance->>MainWindow: Call show_main_window
MainWindow-->>User: Existing main window focused
SingleInstancePlugin->>SecondInstance: Instruct immediate exit
SecondInstance-->>macOS: Terminate process
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
问题
两份 OpenLess (`/Applications/OpenLess.app` + dev build) 同时跑时,两进程各自抓全局热键 → 按一次键被识别两次 → 文本插入两份。
修复
`tauri-plugin-single-instance` v2 + 二进程启动回调聚焦已有主窗口。
Test plan
关联
closes #50
Summary by Sourcery
Enforce single-instance behavior for the Tauri desktop app to prevent duplicate processing when multiple builds are running simultaneously.
New Features:
Bug Fixes:
Build: