Skip to content

make linux tray failing to start a non-critical error#1081

Open
scosman wants to merge 2 commits intomainfrom
scosman/linux_tray_optional
Open

make linux tray failing to start a non-critical error#1081
scosman wants to merge 2 commits intomainfrom
scosman/linux_tray_optional

Conversation

@scosman
Copy link
Collaborator

@scosman scosman commented Feb 22, 2026

See #1080

Summary by CodeRabbit

  • Bug Fixes
    • System tray initialization is more resilient: the app now continues on Linux if tray startup fails, while treating failures as fatal on macOS and Windows to surface critical issues.
    • Improved diagnostic logging during startup to aid troubleshooting and surface errors more clearly.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @scosman, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the application's robustness by preventing crashes when the system tray fails to start. It introduces platform-specific error handling for tray initialization, allowing the application to continue running on Linux even if the tray component encounters an issue, while maintaining critical failure behavior for macOS and Windows.

Highlights

  • Error Handling: Implemented a try-except block around the KilnTray.run_detached() call to gracefully handle potential failures during system tray initialization.
  • Platform-Specific Behavior: Modified the error handling to re-raise exceptions for tray startup failures only on macOS and Windows, allowing the application to proceed on Linux even if the tray fails to initialize.
  • Logging: Added logging for errors encountered during system tray startup to provide better diagnostic information.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • app/desktop/desktop.py
    • Imported the logging module.
    • Initialized a logger for the module.
    • Wrapped the tray initialization in a try-except block.
    • Added conditional re-raising of exceptions based on the operating system.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 22, 2026

No actionable comments were generated in the recent review. 🎉


Walkthrough

Module-level logger added to app/desktop/desktop.py. Tray startup (tray.run_detached()) is wrapped in a try/except: exceptions are logged; on Darwin/Windows they are re-raised, on other platforms self.tray is set to None to allow continued startup.

Changes

Cohort / File(s) Summary
Tray Initialization Hardening
app/desktop/desktop.py
Added logging.getLogger(__name__) as logger. Wrapped tray.run_detached() in try/except; logs exceptions and re-raises on Darwin/Windows, sets self.tray = None on other platforms to continue startup.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A logger nibble, soft and keen,
I catch the errors, keep things seen,
On macOS and Windows I shout "no go!",
On Linux I wink and let it flow. 🥕✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is incomplete, referencing only an issue link without filling out the required template sections like objectives, related issues details, or contributor agreement confirmation. Complete the PR description using the template: add a 'What does this PR do?' section explaining the changes, confirm the CLA, and check the verification checklist items.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: making Linux tray startup failures non-critical, which aligns with the code modifications in the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch scosman/linux_tray_optional

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request makes the application more resilient on Linux by treating a failure to start the system tray as a non-critical error. The change involves wrapping the tray initialization in a try-except block, logging any exceptions, and only re-raising them on macOS and Windows. This is a good improvement for Linux users who might not have a graphical environment fully set up. My review includes a minor suggestion to clean up the platform detection logic for better clarity and correctness.

except Exception:
logger.error("Error running tray", exc_info=True)
# Tray not starting on MacOS or Windows is critical. Let Linux continue to start the app.
if sys.platform in ["darwin", "Windows", "win32"]:
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

While this check works, the value "Windows" is not a standard value for sys.platform. On Windows, sys.platform is 'win32'. Including "Windows" is redundant and could be confusing for future maintainers. It would be cleaner to remove it for better code clarity. I see this pattern is used elsewhere in the file, but it would be good to correct it here to avoid propagating it.

Suggested change
if sys.platform in ["darwin", "Windows", "win32"]:
if sys.platform in ["darwin", "win32"]:

@github-actions
Copy link

github-actions bot commented Feb 22, 2026

📊 Coverage Report

Overall Coverage: 91%

Diff: origin/main...HEAD

  • app/desktop/desktop.py (44.4%): Missing lines 131-132,135-136,138

Summary

  • Total: 9 lines
  • Missing: 5 lines
  • Coverage: 44%

Line-by-line

View line-by-line diff coverage

app/desktop/desktop.py

Lines 127-142

  127 
  128         try:
  129             # running detached since we use tk mainloop to get events from dock icon
  130             self.tray.run_detached()
! 131         except Exception:
! 132             logger.error("Error running tray", exc_info=True)
  133             # Tray not starting on MacOS or Windows is critical.
  134             # Let Linux continue to start the app as tray is more fragmented there and requires system deps.
! 135             if sys.platform in ["darwin", "win32"]:
! 136                 raise
  137             else:
! 138                 self.tray = None
  139 
  140     def close_splash(self):
  141         try:
  142             import pyi_splash  # type: ignore


Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/desktop/desktop.py`:
- Around line 128-135: If run_detached() fails on Linux we must clear the
partially-initialised KilnTray instance so later quit_app() doesn't call stop()
on a broken tray; in the except block for the self.tray.run_detached() call,
after logging the error and before continuing for Linux, set self.tray = None
(or otherwise reset the KilnTray reference) so quit_app()'s unconditional
self.tray.stop() guard won't attempt to stop an unstarted tray; reference
self.tray, run_detached(), KilnTray and quit_app() to locate where to add this
reset.
- Line 134: The platform check list includes the invalid value "Windows"; update
the sys.platform checks (the one using if sys.platform in ["darwin", "Windows",
"win32"] and the other similar occurrence) to remove "Windows" so they read if
sys.platform in ["darwin", "win32"], ensuring only valid sys.platform values are
used ("darwin" and "win32").

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.

1 participant