Repository navigation
feat(workbench): restore the macOS app icon picker - #7502
Conversation
Generated-by: Maka (OpenAI Codex)
Generated-by: Maka
There was a problem hiding this comment.
English
Thanks for bringing the macOS app icon picker back! The overall structure is clean and restrained—sharing SettingsPreset with the Theme editor, enforcing strict custom-icon validation/limits (valid_stem, read_capped, image::Limits, atomic persist_noclobber), and focusing the tests on observable state/recovery behavior all read nicely.
A few concrete items worth addressing before merge (alongside rebasing onto main for the locales/*.json conflict with #7504):
-
build.rsincremental rebuild cost & missing per-filererun-if-changed(products/maka/workbench/build.rs:128-153)cargo:rerun-if-changedis only emitted for theassets/app-iconsdirectory, not each PNG file, so editing an existing PNG in place won't re-runbuild.rs.- Because
build.rsalso watches workbench UI entries andlocales/*.json, any unrelated UI or copy edit triggersembed_app_iconsto decode, resize, and re-encode all 40 × 1024×1024 PNGs in an unoptimized dev build script (opt-level = 0) and overwrite everyOUT_DIR/app-icon-*.pngmtime. - Suggestion: emit
cargo:rerun-if-changedper PNG path, and skip regeneratingthumbwhen it already exists and its mtime is >= the source PNG's mtime.
-
Graceful fallback when a saved
custom:*icon file is missing or unreadable (products/maka/workbench/app/appIcons.ts:61-95,products/maka/workbench/src/bindings/app_icons.rs:197-226)list()already skips missing/corrupt custom files, butapply()fails hard with a raw OS error (No such file or directory).- If a previously selected custom file disappears (e.g.,
storage.jsoncarried over withoutapp-icons/, or file deleted/corrupted), startupfollow()leaves an unrecoverable error banner with aRetrybutton that can never succeed, switching light/dark gets stuck on the previous Dock icon, and toggling "Use a different icon in dark mode" (split(true)) fails outright when the currently active slot points to the missing file. - Suggestion: fall back to
skywhen applying a missing/unreadablecustom:*icon (similar to the Electron implementation'sappIconLoadOrder), so startup, appearance switching, and the split toggle keep working.
-
Initial edit slot in Dark mode doesn't match the General settings row (
products/maka/workbench/app/AppIconSettings.tsx:58)const target = signal<IconMode>('light')is hardcoded to'light'.- When the app is in dark mode with split icons enabled (e.g., Light = Sky, Dark = Ink), the General row displays
Ink, but opening App icon lands on the Light tab highlightingSky. Clicking a tile then updates the inactive light slot with no visible change in the Dock. - Suggestion: initialize
targetfrom the current scheme:signal<IconMode>(colorScheme() === 'dark' ? 'dark' : 'light').
-
Unused i18n keys across all 12 locale files (
products/maka/workbench/locales/*.json)appIcon.descriptionandappIcon.importHelpare added to all 12 locale catalogs (24 entries) but aren't referenced anywhere in code.- Suggestion: while resolving the locale rebase conflict, either wire
appIcon.importHelpinto the Import row'sdescription(AppIconSettings.tsx:117-122) or remove the unused keys.
Note (non-blocking): In scripts/ci/suites.mjs, macos-desktop filters to package(=maka-desktop-shell) only, so the new #[cfg(target_os = "macos")] unit test ships_the_official_dock_catalog_with_thumbnails in maka-workbench won't run in CI unless it is added to the macos-desktop filter (similar to windows-desktop).
简体中文
感谢把 macOS 应用图标选择器恢复回来!整体结构很清爽克制:复用主题页的 SettingsPreset、自定义图标边界校验严谨(valid_stem、read_capped、image::Limits、persist_noclobber 原子落盘),行为测试也都聚焦在重启恢复、删除顺序、落盘回滚和并发切换上。
合入前建议顺手收口以下 4 个具体问题(同时 rebase 到最新 main 解掉和 #7504 在 locales/*.json 上的冲突):
-
build.rs增量构建重算 40 张大图,且缺少单文件rerun-if-changed(products/maka/workbench/build.rs:128-153)- 目前只对
assets/app-icons目录输出了cargo:rerun-if-changed,原地替换已有 PNG 不会触发重编。 - 由于
build.rs同时监控 workbench 前端入口和locales/*.json,平时改任意 TSX 或文案都会触发embed_app_icons在未优化的 dev build script(opt-level = 0)下把 40 张 1024×1024 PNG 全部重新解码、缩放、重编码,并覆盖全部OUT_DIR/app-icon-*.png的 mtime。 - 建议: 为每张 PNG 路径单独输出
cargo:rerun-if-changed;若thumb已存在且 mtime 不早于源 PNG,直接跳过重新生成。
- 目前只对
-
已保存的自定义图标文件缺失或损坏时缺少降级回退(
products/maka/workbench/app/appIcons.ts:61-95、products/maka/workbench/src/bindings/app_icons.rs:197-226)list()已经对损坏/缺失文件做了容错跳过,但apply()会直接抛出原始 OS 错误(No such file or directory)。- 如果之前选中的
custom:*文件丢失(例如只迁移了storage.json或文件被删除/损坏),启动时follow()会挂出一条点再多次也无法恢复的Retry错误横幅,浅/深色切换会卡在旧图标上,甚至在当前槽位指向缺失文件时去拨 「深色模式使用不同图标」 开关(split(true))也会直接失败卡死。 - 建议: 对缺失或不可读的
custom:*文件在应用时优雅回退到sky(类似原 Electron 版appIconLoadOrder的降级策略),保证启动、外观切换和分设开关不受阻断。
-
深色模式下进入「应用图标」页,默认编辑槽位与入口行不一致(
products/maka/workbench/app/AppIconSettings.tsx:58)const target = signal<IconMode>('light')写死了'light'。- 当用户处于深色模式且已开启分设图标(例如亮色
Sky、暗色Ink)时,通用设置行显示的是当前生效的Ink,点进来却停在 浅色 标签并高亮Sky;顺手点新图标改的是未生效的浅色槽位,Dock 不会变化,容易困惑。 - 建议: 按当前外观初始化:
signal<IconMode>(colorScheme() === 'dark' ? 'dark' : 'light')。
-
12 份 locale 文件包含 2 个未使用的翻译键(
products/maka/workbench/locales/*.json)appIcon.description和appIcon.importHelp加进了全部 12 份 locale 文件,但代码中没有任何引用。- 建议: rebase 解冲突时一并清理——可以把
appIcon.importHelp挂到导入行的description(AppIconSettings.tsx:117-122),用不上的键直接删除。
补充说明(非阻塞): scripts/ci/suites.mjs 中 macos-desktop 的 filter 目前只包含 package(=maka-desktop-shell),因此本 PR 在 maka-workbench 中新增的 #[cfg(target_os = "macos")] 单测 ships_the_official_dock_catalog_with_thumbnails 在 CI 上暂时不会执行;如需纳入 CI 回归,可参考 windows-desktop 的写法把它加进 macos-desktop filter。
|
Thanks for the thorough review, @M4n5ter! Merged latest
|
M4n5ter
left a comment
There was a problem hiding this comment.
English
Re-reviewed a51050ba40 and the main merge—all four items are cleanly addressed (per-file rerun-if-changed + mtime-gated thumbnail cache in build.rs, sky fallback for missing/corrupt/unknown icons in both Rust and JS with regression tests, dark-mode initial edit slot, and clean locale resolution across all 12 files).
Also pushed a small follow-up commit (a447d1e5b0) to add -p maka-workbench to native-macos.cargoScope in scripts/ci/suites.mjs, since scoped workers run with worker.cargoScope rather than suites['macos-desktop'].cargoArgs and would otherwise skip compiling/running bindings::app_icons::tests:: in CI.
LGTM—merging once checks pass!
简体中文
已复审 a51050ba40 及合并 main 的冲突解决:上一轮 4 项问题全部修到位(build.rs 单文件 rerun-if-changed 与 mtime 缩略图缓存、Rust/JS 双侧缺失或损坏图标回退 sky 及对应测试、深色模式默认编辑槽位、12 份 locale 清理与同步)。
另外顺手补了一个小提交(a447d1e5b0),在 scripts/ci/suites.mjs 的 native-macos.cargoScope 中加入 -p maka-workbench——因为带 cargoScope 的 worker 实际执行时用的是 worker.cargoScope 而非 suites['macos-desktop'].cargoArgs,否则 bindings::app_icons::tests:: 在 macOS CI 里仍会被跳过。
LGTM,等检查绿灯后直接合并!
Summary
macOS users can now select the running app’s Dock icon in Settings → General → Appearance & language → App icon. Clicking a preset saves it immediately. Sky is the initial choice. Users can choose a separate dark icon, import a PNG or JPEG, or remove imported artwork. The picker shares the Theme editor’s native preset grid.
The 40 bundled PNGs retain the artwork, IDs and 12 groups from the official Electron implementation. The Classic tile comes from the old desktop assets/icon.png. The other 39 come from its app-icons directory.
Verification
AI use
Maka with OpenAI Codex contributed to the implementation, tests, localization, native verification and PR description.
Checklist
Does this PR entail a breaking change or persisted-data migration?
Does this PR entail a change in behavior?