Skip to content

fix(tray): log tray icon failures instead of panicking#1355

Open
rsanheim wants to merge 1 commit into
cjpais:mainfrom
rsanheim:fix/tray-icon-resource-panic
Open

fix(tray): log tray icon failures instead of panicking#1355
rsanheim wants to merge 1 commit into
cjpais:mainfrom
rsanheim:fix/tray-icon-resource-panic

Conversation

@rsanheim
Copy link
Copy Markdown
Contributor

@rsanheim rsanheim commented Apr 30, 2026

Before Submitting This PR

Please confirm you have done the following:

If this is a feature or change that was previously closed/rejected:

  • I have explained in the description below why this should be reconsidered
  • I have gathered community feedback (link to discussion below)

Human Written Description

I was doing perf testing against Handy with agents, and agents like to create worktrees. Sometimes agents like to build a full mac app locally inside a worktree and run it for their own testing loops...and then leave that sad dev build of Handy running w/ a tray icon pointing to a worktree path.

Then the worktree was cleaned up, and Handy exploded gloriously 😀 .

So, this adds error handling around the tray icon code to ensure that errors there don't panic and blow up the main thread....I know the worktree use-case is probably a dev-only edge case. But I can think of of other ways that the icon resource path could get broken (file corruption, permissions, misbehaving updates). And being able to use worktrees for dev/test is nice too.

Oh, added some tests.

Related Issues/Discussions

Fixes #
Discussion: No exact matching issue or PR found in targeted searches for:

  • "tray icon" panic
  • "failed to resolve" tray
  • tray_recording
  • set_icon tray

Related but not duplicate:

Community Feedback

n/a

Testing

Automated local checks run:

  • cargo fmt -- --check passed.
  • cargo test tray::tests::tray_icon_resolution_failure_is_reported_instead_of_panicking passed.
  • cargo test passed: 66 tests passed, 0 failed.
  • bun run lint passed.
  • bun run check:translations passed.
  • bun run build passed with the existing Vite large chunk warning.
  • ./node_modules/.bin/prettier --check PR_DRAFT.md CONTRIBUTING_TASKS.md passed.

Checks with caveats:

  • cargo clippy --all-targets --all-features -- -D warnings ran, but failed on existing unrelated warnings outside src-tauri/src/tray.rs.
  • bun run format:check ran, but failed before Rust formatting because Prettier found existing formatting issues in AGENTS.md and untracked tools/macos-audio-perf/.build/ artifacts.

Screenshots/Videos (if applicable)

n/a

AI Assistance

  • No AI was used in this PR
  • AI was used (please describe below)

If AI was used:

  • Tools used: Codex and Claude Code
  • How extensively: Plenty -- Lots - helped isolate the issue after the fact, and draft the fix. Then helped me refactor to something w/ less LOC. Helped w/ the tests. I pointed it at the worktree prune as a cause, tho, so I got that going for me.

Replace .expect() calls in change_tray_icon with logged errors so a
missing or unreadable resource does not crash the app. Extract
load_tray_icon helper so the error path can be exercised in tests.
@cjpais
Copy link
Copy Markdown
Owner

cjpais commented May 3, 2026

Thanks

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