Skip to content

Port application appearance override and const HSLA constructors - #6

Merged
freefcw merged 4 commits into
develop/0.9from
cursor/appearance-override-color-09ea
Aug 29, 2026
Merged

Port application appearance override and const HSLA constructors#6
freefcw merged 4 commits into
develop/0.9from
cursor/appearance-override-color-09ea

Conversation

@freefcw

@freefcw freefcw commented Aug 29, 2026

Copy link
Copy Markdown
Owner

Port two deferred Zed GPUI items that need a core/platform contract, plus the small const-color nicety. Not a wholesale sync.

Rebased onto develop/0.9 at 2ce2baf01d0efea99b0efea1471248539cc8a232 (PR #3).

Ports

  1. Application appearance override (8e4e5a39eed932d943cb7a3e7078885b75d1ea54)

    • Local: e18c1a9
    • App::set_window_appearance(Option<WindowAppearance>) paired with the existing getter
    • Platform::set_window_appearance default, wired through core, test, visual-test, macOS, Linux, and Windows
    • macOS sets NSApplication.appearance so native chrome matches a forced theme
    • Linux/Windows/test store the override so window_appearance() reports it (tray/daemon apps can force light/dark)
    • Facade compile surface covers the App method via pub use gpui_core::*
  2. Deferred appearance callbacks (a11083f9a79495e9c7ddee0c5782f22d07695c31)

    • Local: f092aaa
    • Window appearance observers run on the foreground executor to avoid re-entrant App borrows
    • Test window can simulate appearance changes
    • Regression: observers stay quiet during cx.update and fire after run_until_parked
  3. Const color API (63b52a7ee354741a7485e8a20ab087a485fcb8a1)

    • Local: 00e8c1e
    • hsla and opaque_grey are const fn

Follow-up

  • 5519e7d — macOS to_native now reads NSAppearanceName* extern statics inside unsafe. That was a real compile failure on the macOS CI jobs (error[E0133]).

Skipped hunks

  • Zed product init_app_appearance in crates/zed (editor-only)
  • Zed window_appearance example — not in the upstream commit payload
  • macOS view_did_change_effective_appearance comment/traffic-light tweak: local callback already differs and does not call move_traffic_light there
  • Linux/Windows native chrome forcing is still not implemented (Zed also left those as no-ops for chrome); only the getter override is stored

Authorship

Author and committer: Jun He <freefcw@gmail.com>

One commit per topic, each with a full Zed-Origin trailer. QuitMode and Adabraka desktop APIs are untouched.

Open in Web Open in Cursor 

Sourcery 摘要

支持强制设置应用程序窗口外观、安全地安排外观变更通知,并启用 const 颜色构造函数。

新功能:

  • 添加应用程序级别的窗口外观覆盖设置,并在 macOS、Linux、Windows、测试和视觉测试后端中提供平台支持及获取器报告。
  • 将窗口外观观察器回调延迟到前台执行器,以避免应用程序更新重入。

错误修复:

  • 确保在应用程序更新完成后通知外观观察器,而不是在更新过程中通知。

增强功能:

  • 使 HSLA 和不透明灰色颜色构造函数可用于常量表达式。

测试:

  • 增加对外观覆盖报告和延迟外观变更通知的测试覆盖。
Original summary in English

Sourcery 摘要

支持应用程序外观覆盖,安全地延迟外观通知,并支持 const 颜色构造函数。

新功能:

  • 添加应用程序级窗口外观覆盖,并提供平台支持以及跨受支持后端的 getter 报告。
  • 将窗口外观观察者通知延迟到前台执行器运行时触发。

错误修复:

  • 防止外观观察者回调在应用程序更新期间重入执行。

增强功能:

  • 使 HSLA 和不透明灰色颜色构造函数可用于常量表达式。

测试:

  • 添加对外观覆盖报告和延迟外观通知的测试覆盖。
Original summary in English

Sourcery 摘要

支持应用程序外观覆盖,安全地延迟外观通知,并启用 const 颜色构造函数。

新功能:

  • 添加应用程序级窗口外观覆盖,并提供平台支持,使受支持后端能够通过 getter 报告该设置。
  • 将窗口外观观察者通知延迟到前台执行器运行时,以防止应用程序更新发生重入。

错误修复:

  • 确保外观观察者在应用程序更新之后收到通知,而不是在更新期间收到通知。

增强功能:

  • 使 HSLA 和不透明灰色颜色构造函数可用于常量表达式。

测试:

  • 增加对外观覆盖报告和延迟外观变化通知的测试覆盖。
Original summary in English

Sourcery 摘要

支持应用程序外观覆盖,安全地延迟外观通知,并启用 const 颜色构造函数。

新功能:

  • 添加应用程序级窗口外观覆盖,并支持在各平台和测试后端获取外观覆盖报告。
  • 将窗口外观观察者通知延迟到前台执行器运行时再发送。

错误修复:

  • 防止外观观察者回调在应用程序更新期间重入执行。

增强功能:

  • 使 HSLA 和不透明灰色构造函数可用于常量表达式。

测试:

  • 增加对外观覆盖报告、延迟外观通知和常量颜色构造的测试覆盖。
Original summary in English

Sourcery 总结

支持应用程序外观覆盖,安全地延迟外观通知,并启用 const 颜色构造函数。

新功能:

  • 添加应用程序级窗口外观覆盖,可在所有受支持的平台后端上进行设置、清除和查询。
  • 将窗口外观观察者通知延迟到前台执行器运行时,以防止应用程序更新重新进入。

错误修复:

  • 确保外观观察者在应用程序更新完成后收到通知,而不是在更新过程中收到通知。

增强功能:

  • 使 HSLA 和不透明灰色颜色构造函数可用于常量表达式。

测试:

  • 增加对外观覆盖报告和延迟外观变更通知的测试覆盖。
Original summary in English

Summary by Sourcery

Support application appearance overrides, safely defer appearance notifications, and enable const color constructors.

New Features:

  • Add an application-level window appearance override that can be set, cleared, and queried across supported platform backends.
  • Defer window appearance observer notifications until the foreground executor runs to prevent re-entrant application updates.

Bug Fixes:

  • Ensure appearance observers are notified after an application update completes rather than during it.

Enhancements:

  • Make HSLA and opaque grey color constructors usable in constant expressions.

Tests:

  • Add coverage for reporting appearance overrides and deferred appearance change notifications.

@sourcery-ai

sourcery-ai Bot commented Aug 29, 2026

Copy link
Copy Markdown

审查者指南

通过 GPUI 的公共、平台和测试接口传递应用程序外观覆盖设置和延迟外观回调,并支持 macOS 原生窗口装饰及回归测试覆盖;同时使 HSLA 颜色构造函数兼容 const

延迟窗口外观通知的时序图

sequenceDiagram
    participant App as App update
    participant TestWindow
    participant ForegroundExecutor
    participant WindowObserver

    App->>TestWindow: simulate_appearance_change(WindowAppearance::Dark)
    TestWindow->>ForegroundExecutor: spawn deferred appearance update
    App-->>App: cx.update completes
    ForegroundExecutor->>WindowObserver: appearance_changed
    WindowObserver-->>WindowObserver: observe_window_appearance callback
Loading

文件级变更

变更 详情 文件
在公共 API 和平台后端中添加应用程序级窗口外观覆盖设置。
  • 公开 App::set_window_appearance,并添加对应的 Platform 钩子,默认不执行任何操作。
  • 在 Linux、Windows、测试和视觉测试后端中报告已存储的覆盖设置。
  • 在 macOS 上应用原生 NSApplication.appearance 覆盖设置,包括清除覆盖并恢复系统跟踪。
  • 为新 API 扩展兼容性测试和 getter 测试。
crates/gpui/src/app.rs
crates/gpui/src/platform.rs
crates/gpui-linux/src/linux/platform.rs
crates/gpui-macos/src/mac/platform.rs
crates/gpui-macos/src/mac/window_appearance.rs
crates/gpui-windows/src/windows/platform.rs
crates/gpui/src/platform/test/platform.rs
crates/gpui/src/platform/test/visual.rs
crates/gpui-compat/tests/application_compat.rs
将窗口外观观察者通知延迟到前台执行器上,以防止应用程序更新发生重入。
  • 异步调度外观回调,而不是以内联方式更新窗口状态。
  • 添加测试窗口外观状态和模拟支持。
  • 验证观察者在 cx.update 期间保持静默,并在 run_until_parked 之后运行。
crates/gpui/src/window.rs
crates/gpui/src/platform/test/window.rs
使常用颜色构造函数可用于编译时表达式。
  • hslaopaque_grey 修改为 const fn
  • 添加编译时构造检查。
crates/gpui/src/color.rs
记录已移植变更的上游同步状态。
  • 更新上游审计元数据。
docs/sync/upstream-audit.json

提示和命令

与 Sourcery 交互

  • 触发新的审查: 在拉取请求中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub issue: 回复审查评论,请 Sourcery 根据该评论创建 issue。你也可以回复审查评论并使用 @sourcery-ai issue,从该评论创建 issue。
  • 生成拉取请求标题: 在拉取请求标题中的任意位置写入 @sourcery-ai,即可随时生成标题。你也可以在拉取请求中评论 @sourcery-ai title,以随时生成或重新生成标题。
  • 生成拉取请求摘要: 在拉取请求正文中的任意位置写入 @sourcery-ai summary,即可在指定位置随时生成 PR 摘要。你也可以在拉取请求中评论 @sourcery-ai summary,以随时生成或重新生成摘要。
  • 生成审查者指南: 在拉取请求中评论 @sourcery-ai guide,即可随时生成或重新生成审查者指南。
  • 解决所有 Sourcery 评论: 在拉取请求中评论 @sourcery-ai resolve,即可解决所有 Sourcery 评论。如果你已经处理完所有评论且不想再看到它们,此功能非常有用。
  • 忽略所有 Sourcery 审查: 在拉取请求中评论 @sourcery-ai dismiss,即可忽略所有现有的 Sourcery 审查。如果你想从新的审查开始,这尤其有用——别忘了评论 @sourcery-ai review 来触发新的审查!

自定义你的体验

访问你的控制面板以:

  • 启用或禁用审查功能,例如 Sourcery 生成的拉取请求摘要、审查者指南等。
  • 更改审查语言。
  • 添加、删除或编辑自定义审查说明。
  • 调整其他审查设置。

获取帮助

Original review guide in English

Reviewer's Guide

Ports application appearance overrides and deferred appearance callbacks through GPUI’s public, platform, and test surfaces, with macOS native chrome support and regression coverage; also makes HSLA color constructors const-compatible.

Sequence diagram for deferred window appearance notification

sequenceDiagram
    participant App as App update
    participant TestWindow
    participant ForegroundExecutor
    participant WindowObserver

    App->>TestWindow: simulate_appearance_change(WindowAppearance::Dark)
    TestWindow->>ForegroundExecutor: spawn deferred appearance update
    App-->>App: cx.update completes
    ForegroundExecutor->>WindowObserver: appearance_changed
    WindowObserver-->>WindowObserver: observe_window_appearance callback
Loading

File-Level Changes

Change Details Files
Add an application-level window appearance override across the public API and platform backends.
  • Expose App::set_window_appearance and add the corresponding Platform hook with a default no-op.
  • Report stored overrides on Linux, Windows, test, and visual-test backends.
  • Apply native NSApplication.appearance overrides on macOS, including clearing back to system tracking.
  • Extend the compatibility and getter tests for the new API.
crates/gpui/src/app.rs
crates/gpui/src/platform.rs
crates/gpui-linux/src/linux/platform.rs
crates/gpui-macos/src/mac/platform.rs
crates/gpui-macos/src/mac/window_appearance.rs
crates/gpui-windows/src/windows/platform.rs
crates/gpui/src/platform/test/platform.rs
crates/gpui/src/platform/test/visual.rs
crates/gpui-compat/tests/application_compat.rs
Defer window appearance observer notifications onto the foreground executor to prevent re-entrant application updates.
  • Schedule appearance callbacks asynchronously instead of updating window state inline.
  • Add test-window appearance state and simulation support.
  • Verify observers remain silent during cx.update and run after run_until_parked.
crates/gpui/src/window.rs
crates/gpui/src/platform/test/window.rs
Make common color constructors usable in compile-time expressions.
  • Change hsla and opaque_grey to const fn.
  • Add compile-time construction checks.
crates/gpui/src/color.rs
Record the upstream synchronization status for the ported changes.
  • Update the upstream audit metadata.
docs/sync/upstream-audit.json

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@cursor
cursor Bot force-pushed the cursor/appearance-override-color-09ea branch from 3131209 to 4354dec Compare August 29, 2026 09:34
@freefcw
freefcw marked this pull request as ready for review August 29, 2026 09:40
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-29T09:43:05.337698Z 4354dec Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@sourcery-ai sourcery-ai 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.

嘿——我已经审阅了你的更改,看起来很棒!


Sourcery 对开源项目免费——如果你喜欢我们的审查结果,请考虑分享给他人 ✨
请帮我变得更有用!请在每条评论上点击 👍 或 👎,我会利用这些反馈来改进审查结果。
Original comment in English

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Add App::set_window_appearance so tray and daemon apps can force light or dark independently of the OS. macOS sets NSApplication.appearance for native chrome; Linux, Windows, and the test platform store the override so window_appearance() reports it. The facade compile surface covers the new App method.

Zed-Origin: 8e4e5a39eed932d943cb7a3e7078885b75d1ea54

Co-authored-by: freefcw <freefcw@gmail.com>
Run Window::appearance_changed on the foreground executor so AppKit (or a test simulation) can notify appearance observers without re-entering an in-progress App borrow. Teach the test window to record and replay appearance changes, and add a regression that asserts observers fire only after the current update ends.

Zed-Origin: a11083f9a79495e9c7ddee0c5782f22d07695c31

Co-authored-by: freefcw <freefcw@gmail.com>
Mark hsla and opaque_grey as const fn so colors can be constructed in const contexts. Existing color tests plus a compile-time const check cover the change.

Zed-Origin: 63b52a7ee354741a7485e8a20ab087a485fcb8a1

Co-authored-by: freefcw <freefcw@gmail.com>
macOS CI failed to compile to_native: NSAppearanceName* are extern statics and must be read inside unsafe. Keep appearanceNamed itself in safe code.

Co-authored-by: freefcw <freefcw@gmail.com>
@cursor
cursor Bot force-pushed the cursor/appearance-override-color-09ea branch from 4cb72b3 to 5519e7d Compare August 29, 2026 12:06
@freefcw
freefcw merged commit 97bc239 into develop/0.9 Aug 29, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant