Skip to content

fix(desktop): restore macOS fullscreen after showing window - #2600

Open
tiammomo wants to merge 2 commits into
makecindy:mainfrom
tiammomo:tiammomo/desktop/fix-macos-fullscreen-restore
Open

fix(desktop): restore macOS fullscreen after showing window#2600
tiammomo wants to merge 2 commits into
makecindy:mainfrom
tiammomo:tiammomo/desktop/fix-macos-fullscreen-restore

Conversation

@tiammomo

@tiammomo tiammomo commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

这次改了什么

摘要

Restore saved macOS fullscreen only after the main window is visible. Add a trusted in-app Exit Full Screen fallback.

变更类型

  • feat 新功能
  • fix 缺陷修复
  • refactor / perf 重构或性能优化
  • docs / test / chore 文档、测试或工程维护
  • 其他:

范围

Remote and mobile adaptation

  • SSH remote workspaces: Not affected.
  • Device link: No channel or protocol change.
  • Mobile: Not affected.

UI 变化

macOS fullscreen adds an Exit Full Screen item to the existing application menu. No screenshot is available because macOS hardware was not used.

  • 引用的设计规范:DESIGN.md §4 Buttons, §8 Desktop Window, and §15.15 titlebar hover-token discipline. The fallback reuses the existing menu and leaves ChromeActions geometry unchanged.

怎么验证的

自动验证

pnpm --filter desktop exec vitest run src/main/__tests__/mainWindowFullscreenStartup.test.ts src/renderer/components/layout/__tests__/ChromeActions.fullscreen.test.tsx
Result: 2 files, 9 tests passed.

pnpm test:unit
Result: passed.

NODE_OPTIONS=--max-old-space-size=6144 pnpm --filter desktop run --if-present typecheck
Result: passed.

pnpm check:dco
Result: passed.

手工验证

Not run.

未执行的验证

macOS 26/27, multi-display, notch-screen, Dock, and Space validation require physical macOS hardware.

风险

风险分类

  • 无已知风险
  • SQLite / migration
  • system prompt
  • 协议兼容
  • 权限 / 安全 / 用户数据
  • 存量插件兼容(批准状态 / 指纹 / manifest 校验 / 安装布局 / 包格式)
  • 原生层 / fingerprint / OTA
  • 跨平台差异
  • 其他:

影响与回滚

  • Impact: macOS state restoration no longer calls setFullScreen(true) while the window is hidden. Windows and Linux retain the state manager's existing behavior.
  • Risk: native traffic-light behavior still needs physical macOS validation.
  • Rollback: revert this commit. No migration or data cleanup is required.

提交前检查

  • 已 review 完整 diff
  • 每个 commit 都带 DCO 签名(git commit -s,见 DCO
  • UI 改动已在「UI 变化」注明引用的设计规范章节(不涉及 UI 则跳过)
  • 未提交凭证、令牌或授权文件
  • 已补充必要文档
  • 已确认测试结果或说明未执行原因

Signed-off-by: tiammomo <pearfl@qq.com>
@tiammomo
tiammomo marked this pull request as ready for review August 13, 2026 04:33
@tiammomo
tiammomo requested a review from a team as a code owner August 13, 2026 04:33
@greptile-apps

greptile-apps Bot commented Aug 13, 2026

Copy link
Copy Markdown

Greptile Summary

此 PR 调整 macOS 主窗口的全屏恢复时序,并新增与发送窗口绑定的应用内退出全屏入口。

  • 主窗口显示后再异步恢复已保存的 macOS 全屏状态
  • 主窗口和普通副窗口使用统一的全屏状态广播逻辑
  • preload 与主进程新增受信任发送方限定的退出全屏 IPC
  • macOS 全屏状态下的菜单新增本地化“退出全屏”操作及测试覆盖

Confidence Score: 5/5

当前没有仍需阻止合并的已确认故障,PR 看起来可以安全合并。

未发现仍然存在的阻塞性故障。

Important Files Changed

Filename Overview
apps/desktop/src/main/bootstrap-electron.ts 调整主窗口全屏恢复时序,提前安装全屏状态监听,并增加发送方绑定的查询和退出 IPC。
apps/desktop/src/main/mainWindowFullscreenStartup.ts 封装显示后恢复全屏、读取窗口全屏状态及向对应 renderer 广播状态的逻辑。
apps/desktop/src/main/secondary-windows.ts 为普通副窗口安装相同的窗口级全屏状态广播。
apps/desktop/src/preload/preload.ts 向 renderer 暴露退出当前窗口全屏的受限 IPC 方法。
apps/desktop/src/renderer/components/layout/ChromeActions.tsx 在 macOS 全屏状态下向菜单传入退出全屏操作。
apps/desktop/src/renderer/components/title-bar/MenuButton.tsx 按需渲染本地化的“退出全屏”菜单项。
apps/desktop/src/main/tests/mainWindowFullscreenStartup.test.ts 覆盖全屏恢复顺序、平台分支、窗口销毁保护及窗口级状态广播。
apps/desktop/src/renderer/components/layout/tests/ChromeActions.fullscreen.test.tsx 覆盖 macOS 全屏退出入口的显示条件与调用行为。

Sequence Diagram

sequenceDiagram
  participant State as window-state
  participant Main as Electron 主进程
  participant Window as BrowserWindow
  participant Renderer as Renderer
  State-->>Main: 已保存的全屏状态
  Window->>Main: ready-to-show
  Main->>Window: show()
  Main->>Window: setFullScreen(true)
  Window->>Main: enter/leave-full-screen
  Main->>Renderer: fullscreen-change
  Renderer->>Main: window-exit-fullscreen
  Main->>Window: 按发送方窗口退出全屏
Loading

Reviews (2): Last reviewed commit: "fix(desktop): scope fullscreen fallback ..." | Re-trigger Greptile

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 02296bf593

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/desktop/src/renderer/components/layout/ChromeActions.tsx Outdated
Comment thread apps/desktop/src/renderer/components/layout/ChromeActions.tsx Outdated
Signed-off-by: tiammomo <pearfl@qq.com>
@MagicLizi MagicLizi added touches:core 改动碰到架构核心路径(review-pr 自动维护,仅展示) touches:product-ui 改动碰到产品 / UI 面(review-pr 自动维护,仅展示) awaiting-discussion 等待维护者讨论(review-pr) labels Aug 13, 2026
@tiammomo

Copy link
Copy Markdown
Contributor Author

The Windows 1/2 shard failed in customProviderDialogPresetLocale.test.tsx, which is outside this PR; Linux, the other Windows shard, focused tests, and the local full unit suite pass. I cannot rerun Actions on this repository. Could a maintainer rerun the failed job?

@MagicLizi

Copy link
Copy Markdown
Contributor

命中 UI 路径(apps/desktop/src/renderer/components/layout/ChromeActions.tsx / apps/desktop/src/renderer/components/title-bar/MenuButton.tsx)但 description 未附界面效果证据——建议补充改动后效果:截图/录屏,或改动后界面的 HTML 页面(```html 代码块、.html 附件或在线预览链接),便于确认界面符合 DESIGN.md 设计规范

@MagicLizi

Copy link
Copy Markdown
Contributor

这条 PR 给全屏状态加了菜单退出入口,已开维护者确认。同意请 Approve;要改请 Request Changes。讨论:#2734

@MagicLizi

Copy link
Copy Markdown
Contributor

@tiammomo 👋 这个 PR 目前与 main 有合并冲突,auto-review 因此暂时跳过、没法继续审查 / 合并。

请在本地 merge 最新的 origin/main 解决冲突后推送;冲突解除后,下一轮 auto-review 会自动重新处理这个 PR。

@MagicLizi MagicLizi added awaiting-discussion 等待维护者讨论(review-pr) and removed awaiting-discussion 等待维护者讨论(review-pr) labels Aug 17, 2026
@MagicLizi

Copy link
Copy Markdown
Contributor

@tiammomo 👋 这个 PR 现在在等维护者确认,确认之前流程不会合并它 —— 不是卡住了,也不是在等你再改一版(你推的改动流程都读到了,判的就是最新一版代码)。

  • 在拦的是:维护者确认门(产品 / UI 变更)。
  • 讨论 issue:维护者确认:#2600 全屏菜单增加退出入口 #2734
  • 通过方式只有一个:维护者在本 PR 上 Approve。维护者觉得要改会直接 Request Changes,那时候球才回到你手里。
  • 这期间如果还有 review 意见没处理完、CI 没过,照常修就行,不影响这条等待。

这条是流程自动发的状态提醒(同一版代码只发一次),不用回复。

@MagicLizi

Copy link
Copy Markdown
Contributor

@tiammomo 👋 这个 PR 目前与 main 有合并冲突,auto-review 因此暂时跳过、没法继续审查 / 合并。

请在本地 merge 最新的 origin/main 解决冲突后推送;冲突解除后,下一轮 auto-review 会自动重新处理这个 PR。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-discussion 等待维护者讨论(review-pr) touches:core 改动碰到架构核心路径(review-pr 自动维护,仅展示) touches:product-ui 改动碰到产品 / UI 面(review-pr 自动维护,仅展示)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(desktop): macOS 冷启动恢复全屏后原生窗口按钮可能消失,无法用鼠标退出全屏

2 participants