Skip to content

feat: use PDF vector icon for crisp menubar rendering#43

Merged
prakersh merged 2 commits intoonllm-dev:mainfrom
jinquan-shi:feat/menubar_icon
Mar 28, 2026
Merged

feat: use PDF vector icon for crisp menubar rendering#43
prakersh merged 2 commits intoonllm-dev:mainfrom
jinquan-shi:feat/menubar_icon

Conversation

@jinquan-shi
Copy link
Copy Markdown
Contributor

  • Use PDF icon via systray.SetIcon for sharp 4K display support
  • Fall back to PNG template icons if PDF unavailable
  • Add thin space between icon and text in tray display
  • Add icon_test.go with PDF/PNG validation tests

- Use PDF icon via systray.SetIcon for sharp 4K display support
- Fall back to PNG template icons if PDF unavailable
- Add thin space between icon and text in tray display
- Add icon_test.go with PDF/PNG validation tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

@prakersh prakersh left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! The goal of crisp 4K rendering makes sense. A few observations:

Template icon regression

systray.SetIcon(pdfIcon) sets template=false internally, which means the icon won't adapt to macOS light/dark menu bar appearance. The original SetTemplateIcon call sets template=true, which is what makes the icon render correctly in both themes.

PDF format is not cross-platform

The systray library documents supported formats as .ico/.jpg/.png. PDF only works here because the macOS backend calls NSImage initWithData: which happens to support PDF natively - this is an undocumented implementation detail, not a guaranteed API contract. On Linux (D-Bus/StatusNotifierItem) and Windows (HICON), PDF won't work at all.

This is especially relevant since #35 is actively extending the menubar companion to Linux (and Windows is planned after that). Merging a macOS-only icon format now would create an immediate conflict with the cross-platform direction.

Suggestion: use higher-quality PNGs instead

The blurriness on 4K is likely from the source PNGs, not the format itself. A well-crafted PNG exported from the vector source at proper sizes should look crisp on Retina/4K. I'd suggest providing 64x64 or 128x128 hi-res PNGs - SetTemplateIcon will handle the scaling, and it works cross-platform out of the box with no build tags or undocumented behavior needed.

Dead fallback path

Since IconPDF is loaded via go:embed, len(pdfIcon) > 0 will always be true - the PNG fallback branch can never execute.

The thin space and tests are nice additions - happy to keep those parts. Would you be open to swapping the PDF approach for higher-quality PNGs?

macOS systray works better with PNG template/retina icons than PDF.
Remove PDF icon support and associated tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jinquan-shi
Copy link
Copy Markdown
Contributor Author

jinquan-shi commented Mar 28, 2026

Thanks for the review! @prakersh

Following the feedback regarding 4K rendering and macOS template support, I've updated the PR with the following changes:

  1. Reverted PDF to Ultra-High Res PNGs: While the PDF approach aimed for crispness, it was macOS-specific and broke the SetTemplateIcon functionality (causing issues with light/dark mode adaptation). I've replaced the PDF with ultra-high resolution PNGs:

  2. Restored SetTemplateIcon: The code in companion_darwin.go now uses systray.SetTemplateIcon again. This ensures that the icon correctly adapts its color when the user switches between light and dark macOS menu bar themes.

These changes achieve the goal of "crisp 4K rendering" without sacrificing cross-platform compatibility or native macOS behavior.

Copy link
Copy Markdown
Contributor

@prakersh prakersh left a comment

Choose a reason for hiding this comment

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

Thanks for the updates, @jinquan-shi! The revised approach looks great - ultra-high res PNGs for crisp 4K rendering while keeping SetTemplateIcon for proper light/dark mode adaptation. Clean and well-tested. Merging!

@prakersh prakersh merged commit 50c63d0 into onllm-dev:main Mar 28, 2026
3 checks passed
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