feat: 超级面板支持文件位置快捷跳转#532
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a file location quick-jump feature to the SuperPanel, allowing users to quickly navigate file manager windows and file dialogs on Windows and macOS. Key changes include adding native window management APIs, updating IPC handlers, and enhancing the SuperPanel UI to display jump targets. Feedback on these changes highlights critical issues where synchronous dialog APIs were incorrectly refactored to be asynchronous, which breaks IPC return values. Additionally, a potential runtime crash was identified in the system commands due to a missing null-check on the optional application name, and a leftover debug log in the SuperPanel component should be removed.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| windowManager | ||
| .withBlurHideSuppressed(() => dialog.showSaveDialog(targetWindow, options)) | ||
| .then((data: Electron.SaveDialogReturnValue) => { | ||
| event.returnValue = data.canceled ? undefined : data.filePath | ||
| }) | ||
| .catch((error: Error) => { | ||
| console.error('[PluginDialog] 显示文件保存对话框失败:', error) | ||
| event.returnValue = undefined | ||
| }) |
There was a problem hiding this comment.
在 PluginDialogAPI 中,show-save-dialog 是通过同步 IPC(渲染进程使用 sendSync)调用的。主进程必须同步地为 event.returnValue 赋值。
在当前修改中,您使用了异步的 withBlurHideSuppressed 和 dialog.showSaveDialog,并在 .then() 回调中异步设置 event.returnValue。这会导致主进程在 Promise 解析之前就结束了同步事件处理,渲染进程会立即收到 undefined 返回值,而不会等待用户在对话框中选择文件,从而导致保存文件对话框功能完全失效。
为了保持同步 API 的正确行为,必须恢复使用同步的 withBlurHideSuppressedSync 和 dialog.showSaveDialogSync。
const result = windowManager.withBlurHideSuppressedSync(() =>
dialog.showSaveDialogSync(targetWindow, options)
)
event.returnValue = result| windowManager | ||
| .withBlurHideSuppressed(() => dialog.showOpenDialog(targetWindow, options)) | ||
| .then((data: Electron.OpenDialogReturnValue) => { | ||
| event.returnValue = data.canceled ? [] : data.filePaths | ||
| }) | ||
| .catch((error: Error) => { | ||
| console.error('[PluginDialog] 显示文件打开对话框失败:', error) | ||
| event.returnValue = [] | ||
| }) |
There was a problem hiding this comment.
与 show-save-dialog 类似,show-open-dialog 也是通过同步 IPC(渲染进程使用 sendSync)调用的。
使用异步的 withBlurHideSuppressed 和 dialog.showOpenDialog 会导致渲染进程在对话框弹出时立即收到空数组 [] 返回值,而不会等待用户选择文件。
必须恢复使用同步的 withBlurHideSuppressedSync 和 dialog.showOpenDialogSync 以确保同步返回选中的文件路径。
const result = windowManager.withBlurHideSuppressedSync(() =>
dialog.showOpenDialogSync(targetWindow, options)
)
event.returnValue = result || []| const appName = winInfo.app | ||
|
|
There was a problem hiding this comment.
由于 WindowActivationInfo 和 previousActiveWindow 中的 app 属性现在被改为了可选属性(app?: string),winInfo.app 有可能为 undefined。
如果 appName 为 undefined,直接调用 appName.toLowerCase() 将会抛出 TypeError: Cannot read properties of undefined (reading 'toLowerCase') 运行时崩溃。
建议在获取 appName 后进行非空校验,如果为空则安全返回。
| const appName = winInfo.app | |
| const appName = winInfo.app | |
| if (!appName) { | |
| return { success: false, error: '无法获取应用名称' } | |
| } |
| const info = currentWindowInfo.value | ||
| console.log('object', info); | ||
| if (!info) return null |
关联 native 提交:#10
resolve #450,resolve #81
20260606_205654.mp4