🐞fix(desktopLyrics/window): 修复 macOS 桌面歌词启动死锁;优化桌面歌词焦点夺取问题#897
Conversation
Pissofdvpe
commented
Feb 18, 2026
- 修复 macOS 桌面歌词启动时卡在“歌词加载中”的问题:
- 修正 LyricManager.ts 中残留的旧 IPC 频道名 update-desktop-lyric-data 为 desktop-lyric:update-data,确保歌词未变场景下的状态正确同步。
- 优化窗口焦点管理,解决启动时主窗口失去焦点导致本地快捷键失效的问题:
- 修改 lyric-window.ts,在 ready-to-show 事件中改用 showInactive() 显示窗口,防止静默启动时抢占焦点。
- 优化 ipc-lyric.ts 的切换显示逻辑,统一使用 showInactive(),并补全了窗口创建时的初始锁定状态应用逻辑。
- 在 useInit.ts 初始化流程末尾增加延时聚焦主窗口的逻辑(win-show-main),确保程序启动后主窗口稳获最终焦点。
- 修复 macOS 桌面歌词启动时卡在“歌词加载中”的问题: - 修正 LyricManager.ts 中残留的旧 IPC 频道名 update-desktop-lyric-data 为 desktop-lyric:update-data,确保歌词未变场景下的状态正确同步。 - 优化窗口焦点管理,解决启动时主窗口失去焦点导致本地快捷键失效的问题: - 修改 lyric-window.ts,在 ready-to-show 事件中改用 showInactive() 显示窗口,防止静默启动时抢占焦点。 - 优化 ipc-lyric.ts 的切换显示逻辑,统一使用 showInactive(),并补全了窗口创建时的初始锁定状态应用逻辑。 - 在 useInit.ts 初始化流程末尾增加延时聚焦主窗口的逻辑(win-show-main),确保程序启动后主窗口稳获最终焦点。
Summary of ChangesHello @Pissofdvpe, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 此拉取请求旨在解决 macOS 上桌面歌词功能相关的两个主要问题:一是修复了桌面歌词启动时可能出现的“歌词加载中”卡死现象,通过修正 IPC 频道名确保歌词状态正确同步;二是改进了窗口焦点管理机制,防止桌面歌词窗口启动时抢占主窗口焦点,从而确保本地快捷键的正常使用。这些改动提升了用户体验和应用的稳定性。 Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
本次代码变更修复了 macOS 桌面歌词的启动死锁问题,并优化了窗口焦点管理。整体来看,代码修改方向正确,逻辑清晰。
主要改进包括:
- 在
LyricManager.ts中修正了错误的 IPC 频道名称,解决了状态同步的 bug。 - 在
ipc-lyric.ts和lyric-window.ts中统一使用showInactive()来显示歌词窗口,有效避免了启动时抢占焦点的问题。 - 在
ipc-lyric.ts中补充了窗口创建时的初始锁定状态,增强了逻辑的完整性。
有一点可以改进:在 useInit.ts 中使用了 setTimeout 来确保主窗口最后获得焦点。虽然这是一种常见的解决方案,但其可靠性依赖于固定的延迟时间,可能存在潜在的竞态条件。
总体而言,这是一次高质量的修复和优化。
- 在 useInit.ts 初始化流程末尾增加基于 FINAL_FOCUS_DELAY_MS 常量的延时聚焦逻辑(win-show-main),并仅在桌面歌词开启时触发,确保程序启动后主窗口稳获最终焦点,同时提升代码可维护性。