Skip to content

feat(workbench): restore the macOS app icon picker - #7502

Merged
M4n5ter merged 5 commits into
apache:mainfrom
ARE404:restore/electron-icon-picker
Dec 2, 2026
Merged

M4n5ter merged 5 commits into
apache:mainfrom
ARE404:restore/electron-icon-picker

Conversation

@ARE404

@ARE404 ARE404 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

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

  • On macOS, opened the picker from General in an isolated app bundle and profile. Selected Sky and Ink and observed the running app’s Dock tile change. Tested different light and dark selections.
  • Imported a PNG using the native file dialog and confirmed the same artwork after quitting and relaunching. Cancelling preserved the current icon. Deleting the selected import removed the profile copy and restored Sky. Native tests cover JPEG decoding, cropping, bounds and reuse of existing custom artwork IDs.
  • Passed 399 workbench JS tests, TypeScript against generated native bindings, Biome, and Rust formatting. The isolated macOS desktop build and three focused native tests passed during feature verification.
Native picker with Sky selected Theme presets used as the design reference
macOS app icon picker macOS theme presets
Sky in the Dock Ink in the Dock
Sky Dock tile Ink Dock tile

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Maka with OpenAI Codex contributed to the implementation, tests, localization, native verification and PR description.

Checklist

  • Tests cover the change and fail without it
  • Format, typecheck and the affected suites pass locally

Does this PR entail a breaking change or persisted-data migration?

  • Yes
  • No

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

Generated-by: Maka (OpenAI Codex)
@github-actions github-actions Bot added the effort/XL Under 2500 readable lines label Dec 1, 2026

@M4n5ter M4n5ter left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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):

  1. build.rs incremental rebuild cost & missing per-file rerun-if-changed (products/maka/workbench/build.rs:128-153)

    • cargo:rerun-if-changed is only emitted for the assets/app-icons directory, not each PNG file, so editing an existing PNG in place won't re-run build.rs.
    • Because build.rs also watches workbench UI entries and locales/*.json, any unrelated UI or copy edit triggers embed_app_icons to decode, resize, and re-encode all 40 × 1024×1024 PNGs in an unoptimized dev build script (opt-level = 0) and overwrite every OUT_DIR/app-icon-*.png mtime.
    • Suggestion: emit cargo:rerun-if-changed per PNG path, and skip regenerating thumb when it already exists and its mtime is >= the source PNG's mtime.
  2. 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, but apply() fails hard with a raw OS error (No such file or directory).
    • If a previously selected custom file disappears (e.g., storage.json carried over without app-icons/, or file deleted/corrupted), startup follow() leaves an unrecoverable error banner with a Retry button 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 sky when applying a missing/unreadable custom:* icon (similar to the Electron implementation's appIconLoadOrder), so startup, appearance switching, and the split toggle keep working.
  3. 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 highlighting Sky. Clicking a tile then updates the inactive light slot with no visible change in the Dock.
    • Suggestion: initialize target from the current scheme: signal<IconMode>(colorScheme() === 'dark' ? 'dark' : 'light').
  4. Unused i18n keys across all 12 locale files (products/maka/workbench/locales/*.json)

    • appIcon.description and appIcon.importHelp are 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.importHelp into the Import row's description (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 上的冲突):

  1. 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,直接跳过重新生成。
  2. 已保存的自定义图标文件缺失或损坏时缺少降级回退(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 的降级策略),保证启动、外观切换和分设开关不受阻断。
  3. 深色模式下进入「应用图标」页,默认编辑槽位与入口行不一致(products/maka/workbench/app/AppIconSettings.tsx:58)

    • const target = signal<IconMode>('light') 写死了 'light'。
    • 当用户处于深色模式且已开启分设图标(例如亮色 Sky、暗色 Ink)时,通用设置行显示的是当前生效的 Ink,点进来却停在 浅色 标签并高亮 Sky;顺手点新图标改的是未生效的浅色槽位,Dock 不会变化,容易困惑。
    • 建议: 按当前外观初始化:signal<IconMode>(colorScheme() === 'dark' ? 'dark' : 'light')。
  4. 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。

@ARE404

ARE404 commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review, @M4n5ter! Merged latest main to resolve the locales/zh-HK.json conflict and addressed all items in a51050ba40:

  1. build.rs caching & per-file watch: emitted cargo:rerun-if-changed for each official PNG and skipped thumbnail regeneration when the existing OUT_DIR/app-icon-*.png is non-empty and has mtime >= the source PNG.
  2. Graceful fallback for missing/corrupt custom:* icons: added sky fallback in app_icons::resolve_dock_png (validating with read_capped + decode, while still rejecting unsafe custom:* traversal IDs) and defensive fallback in appIcons.ts, with Rust and JS regression tests covering startup, appearance switches, and toggling split mode.
  3. Initial edit slot in Dark mode: initialized target in AppIconSettings.tsx from colorScheme() === 'dark' ? 'dark' : 'light'.
  4. Unused i18n keys: wired appIcon.importHelp to the Import row's description and removed the unused appIcon.description across all 12 locale files.
  5. macos-desktop CI filter: included maka-workbench's bindings::app_icons::tests:: in scripts/ci/suites.mjs so the macOS catalog/thumbnail test runs in CI as well.

@M4n5ter M4n5ter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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,等检查绿灯后直接合并!

@M4n5ter
M4n5ter merged commit 75f4250 into apache:main Dec 2, 2026
3 checks passed
@ARE404
ARE404 deleted the restore/electron-icon-picker branch December 2, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/XL Under 2500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants