feat: improve mac dock behavior (#15334)

#### PR Dependency Tree


* **PR #15334** 👈

This tree was auto-generated by
[Charcoal](https://github.com/danerwilliams/charcoal)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Enhancements**
* Improved main-window restoration for deep links, second-instance
launches, tray/menu actions, and when recordings finish.
* Refined macOS Dock show/hide behavior with throttling for smoother
window visibility.
* Updated close-to-tray/close-to-background handling to better manage
the app’s window lifecycle.
* Ensured popup/dock visibility is consistent when opening new windows.
* Updated window behavior settings display so tray-related options
render correctly across platforms.
* **Localization**
* Updated Simplified Chinese wording for menubar window behavior title.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
DarkSky
2026-07-23 23:25:55 +08:00
committed by GitHub
parent 8001451fd5
commit 0d889bc643
9 changed files with 219 additions and 133 deletions
@@ -7,7 +7,6 @@ import { logger } from './logger';
import { uiSubjects } from './ui';
import {
addTabWithUrl,
getMainWindow,
loadUrlInActiveTab,
openUrlInHiddenWindow,
showMainWindow,
@@ -74,13 +73,8 @@ export function setupDeepLink(app: App) {
// on windows & linux, we need to listen for the second-instance event
app.on('second-instance', (event, commandLine) => {
getMainWindow()
.then(window => {
if (!window) {
logger.error('main window is not ready');
return;
}
window.show();
showMainWindow()
.then(() => {
const url = commandLine.pop();
if (url?.startsWith(`${protocol}://`)) {
event.preventDefault();
@@ -149,11 +143,12 @@ async function handleAffineUrl(url: string) {
? await openUrlInHiddenWindow(urlObj)
: await loadUrlInActiveTab(url);
const main = await getMainWindow();
if (main && hiddenWindow) {
if (hiddenWindow) {
// when hidden window closed, the main window will be hidden somehow
hiddenWindow.on('close', () => {
main.show();
void showMainWindow().catch(e => {
logger.error('Failed to restore main window:', e);
});
});
}
}