fix(tray): log tray icon failures instead of panicking#1355
Open
rsanheim wants to merge 1 commit into
Open
Conversation
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.
Owner
|
Thanks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before Submitting This PR
Please confirm you have done the following:
If this is a feature or change that was previously closed/rejected:
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" traytray_recordingset_icon trayRelated but not duplicate:
Community Feedback
n/a
Testing
Automated local checks run:
cargo fmt -- --checkpassed.cargo test tray::tests::tray_icon_resolution_failure_is_reported_instead_of_panickingpassed.cargo testpassed: 66 tests passed, 0 failed.bun run lintpassed.bun run check:translationspassed.bun run buildpassed with the existing Vite large chunk warning../node_modules/.bin/prettier --check PR_DRAFT.md CONTRIBUTING_TASKS.mdpassed.Checks with caveats:
cargo clippy --all-targets --all-features -- -D warningsran, but failed on existing unrelated warnings outsidesrc-tauri/src/tray.rs.bun run format:checkran, but failed before Rust formatting because Prettier found existing formatting issues inAGENTS.mdand untrackedtools/macos-audio-perf/.build/artifacts.Screenshots/Videos (if applicable)
n/a
AI Assistance
If AI was used: