Skip to content

fix(windows): 缺失托盘图标时继续启动#72

Merged
appergb merged 1 commit into
Open-Less:mainfrom
Cooper-X-Oak:codex/windows-tray-icon-guard-pr
Apr 30, 2026
Merged

fix(windows): 缺失托盘图标时继续启动#72
appergb merged 1 commit into
Open-Less:mainfrom
Cooper-X-Oak:codex/windows-tray-icon-guard-pr

Conversation

@Cooper-X-Oak
Copy link
Copy Markdown
Contributor

@Cooper-X-Oak Cooper-X-Oak commented Apr 30, 2026

摘要

Fixes #无(不再新增 upstream issue)。

关联 fork 验证:Cooper-X-Oak#12

本 PR 是从 fork/dev 已验证批次拆出的启动稳定性维护项:当 Tauri 默认窗口图标缺失时,不再 unwrap() 直接让应用启动失败,而是记录 warning 并跳过托盘图标创建。

修复 / 新增 / 改进

  • app.default_window_icon().unwrap() 改为 if let Some(icon) 分支。
  • 图标缺失时输出 [startup] default window icon missing; tray icon disabled
  • 主窗口、coordinator 和热键监听继续初始化,避免资源缺失放大成 Windows “无法启动”。

兼容

  • 不包含:功能逻辑重构、托盘菜单行为变更、图标资产变更。
  • 对现有用户 / 本地环境 / 构建流程的影响:只有图标资源异常缺失时改变行为;正常有图标时托盘行为不变。

测试计划

  • 命令:git diff --check -- openless-all/app/src-tauri/src/lib.rs
  • 结果:通过。
  • 命令:cargo check --manifest-path openless-all/app/src-tauri/Cargo.toml
  • 结果:本机 MSVC/Windows SDK 环境失败,原因是 kernel32.lib 缺失;不是本次代码改动触发。完整编译以 GitHub Windows Tauri checks 为准。
  • 证据路径:等待 GitHub Actions。

Summary by Sourcery

Bug Fixes:

  • Prevent application startup from failing when the default window icon is missing by skipping tray icon creation and continuing initialization.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Apr 30, 2026

Reviewer's Guide

Handles missing default window icon more defensively so the Windows app can still start without a tray icon, instead of panicking during tray setup, and logs a startup warning when this happens.

File-Level Changes

Change Details Files
Make tray icon initialization tolerant to missing default window icon so startup no longer panics on Windows when the icon asset is absent.
  • Replace direct unwrap() of app.default_window_icon() with an if-let Some(icon) guard around tray creation.
  • Keep the existing TrayIconBuilder configuration and callbacks unchanged when an icon is available.
  • When the icon is missing, skip tray icon creation and emit a warning log message indicating the tray icon is disabled, while allowing the rest of the app initialization to proceed.
openless-all/app/src-tauri/src/lib.rs

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

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • When skipping tray creation due to a missing default window icon, consider logging at a higher level (e.g., error! or including the expected asset path) so that misconfigured builds are more visible during diagnostics rather than just a warning in normal logs.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- When skipping tray creation due to a missing default window icon, consider logging at a higher level (e.g., `error!` or including the expected asset path) so that misconfigured builds are more visible during diagnostics rather than just a warning in normal logs.

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.

@appergb appergb merged commit b8988c3 into Open-Less:main Apr 30, 2026
2 checks passed
appergb pushed a commit that referenced this pull request Apr 30, 2026
包含本轮所有合并:
- Codex 终审两条 HIGH (cancel race) 修复 (PR #79)
- 6 个 Cooper-X-Oak/Codex bot PRs 自动合并 (#44 #49 #53 #68 #72 #73)
- 2 个有冲突 PR 本地 rebase 后合并 (#66 cancel + 空转写并存 / #67 Windows docs)
- README 破图修复 (PR #80)
- workflow-scope 受限的 #48 + #75 由用户在 GitHub UI 直接合并

3 处版本字段同步:package.json + tauri.conf.json + Cargo.toml
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.

2 participants