From 0eaf95110e8d375f6fb216bd6c39ca98cfe54686 Mon Sep 17 00:00:00 2001 From: allonli Date: Thu, 27 Nov 2025 13:19:16 +0800 Subject: [PATCH] feat: Quick Assistant add 'Open Main Window' button; IPC App_ShowMainWindow; keep Quick Assistant available on mac when closing main window --- packages/shared/IpcChannel.ts | 1 + src/main/ipc.ts | 1 + src/main/services/WindowService.ts | 14 +++++++------- src/preload/index.ts | 1 + .../src/windows/mini/home/components/Footer.tsx | 10 ++++++++++ .../selection/action/components/WindowFooter.tsx | 4 ++++ 6 files changed, 24 insertions(+), 7 deletions(-) diff --git a/packages/shared/IpcChannel.ts b/packages/shared/IpcChannel.ts index 67bd137b8e..9e20e87d67 100644 --- a/packages/shared/IpcChannel.ts +++ b/packages/shared/IpcChannel.ts @@ -47,6 +47,7 @@ export enum IpcChannel { App_MacRequestProcessTrust = 'app:mac-request-process-trust', App_QuoteToMain = 'app:quote-to-main', + App_ShowMainWindow = 'app:show-main-window', App_SetDisableHardwareAcceleration = 'app:set-disable-hardware-acceleration', Notification_Send = 'notification:send', diff --git a/src/main/ipc.ts b/src/main/ipc.ts index e537b85261..1eb26b4ce3 100644 --- a/src/main/ipc.ts +++ b/src/main/ipc.ts @@ -865,6 +865,7 @@ export function registerIpc(mainWindow: BrowserWindow, app: Electron.App) { SelectionService.registerIpcHandler() ipcMain.handle(IpcChannel.App_QuoteToMain, (_, text: string) => windowService.quoteToMainWindow(text)) + ipcMain.handle(IpcChannel.App_ShowMainWindow, () => windowService.showMainWindow()) ipcMain.handle(IpcChannel.App_SetDisableHardwareAcceleration, (_, isDisable: boolean) => { configManager.setDisableHardwareAcceleration(isDisable) diff --git a/src/main/services/WindowService.ts b/src/main/services/WindowService.ts index 63eaaba995..e23637f79e 100644 --- a/src/main/services/WindowService.ts +++ b/src/main/services/WindowService.ts @@ -375,15 +375,15 @@ export class WindowService { mainWindow.hide() - //for mac users, should hide dock icon if close to tray if (isMac && isTrayOnClose) { - app.dock?.hide() + const quickAssistantEnabled = configManager.getEnableQuickAssistant() + if (!quickAssistantEnabled) { + app.dock?.hide() - mainWindow.once('show', () => { - //restore the window can hide by cmd+h when the window is shown again - // https://github.com/electron/electron/pull/47970 - app.dock?.show() - }) + mainWindow.once('show', () => { + app.dock?.show() + }) + } } }) diff --git a/src/preload/index.ts b/src/preload/index.ts index 92f44075aa..2521a8a22f 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -464,6 +464,7 @@ const api = { }) => ipcRenderer.invoke(IpcChannel.AgentToolPermission_Response, payload) }, quoteToMainWindow: (text: string) => ipcRenderer.invoke(IpcChannel.App_QuoteToMain, text), + openMainWindow: () => ipcRenderer.invoke(IpcChannel.App_ShowMainWindow), setDisableHardwareAcceleration: (isDisable: boolean) => ipcRenderer.invoke(IpcChannel.App_SetDisableHardwareAcceleration, isDisable), trace: { diff --git a/src/renderer/src/windows/mini/home/components/Footer.tsx b/src/renderer/src/windows/mini/home/components/Footer.tsx index 04b4164404..c31f96d56b 100644 --- a/src/renderer/src/windows/mini/home/components/Footer.tsx +++ b/src/renderer/src/windows/mini/home/components/Footer.tsx @@ -64,6 +64,16 @@ const Footer: FC = ({ : t('miniwindow.footer.esc_back') })} + { + window.api.openMainWindow() + window.api.miniWindow.hide() + }}> + 打开主窗口 + {route === 'home' && !canUseBackspace && ( = ({ )} + window.api?.openMainWindow?.()} $isWindowFocus={isWindowFocus}> + + 打开主窗口 + {onRegenerate && (