-
Notifications
You must be signed in to change notification settings - Fork 32
Omega minor fixes #71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This makes future updates simpler. Also I believe the blacklist should be removed from models itself, not "preferred_models", as we created preferred_models.
WalkthroughUpdates model selection logic to use whitelist/blacklist with stable preferred-first sorting, adds High DPI attributes in the main widget startup, removes redundant DPI setup from the code editor window, and converts regex patterns in the syntax highlighter to raw strings without changing behavior. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor U as User
participant M as main()
participant Qt as Qt Application
participant W as Widget init
participant ML as Model list builder
U->>M: Launch application
activate M
M->>Qt: Set AA_UseHighDpiPixmaps (if available)
M->>Qt: Set AA_EnableHighDpiScaling (if available)
M->>Qt: Create QApplication
deactivate M
M->>W: Initialize widget
activate W
W->>ML: Prepare model_list
note over ML: Start with available models
ML->>ML: Remove blacklist entries
ML->>ML: Identify preferred via whitelist substrings
ML->>ML: Stable sort: preferred first
ML-->>W: Return ordered list
W-->>U: Populate UI with models
deactivate W
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (4)
src/napari_chatgpt/_widget.py (3)
165-168: Whitelist/blacklist approach: OK; minor nit and future-proofing suggestionThe switch to explicit allow/deny lists fixes the macOS breakage risk. Two small nits:
- The method name is misspelled (_prefered_models). Consider renaming to _preferred_models for clarity (low priority since it's private).
- Consider hoisting whitelist/blacklist to module-level constants so they’re easier to audit and tweak.
169-173: Make “preferred-first” ordering truly stable and speed up membership checksCurrent sort key (x not in preferred_models, x) re-sorts each group lexicographically, which is not stable relative to the incoming order. Also, membership checks against a list are O(n). Use a set and rely on Python’s stable sort with a single boolean key.
Apply this diff:
- # Add models containing any whitelist string - preferred_models = [ - model for model in model_list if any(w in model for w in whitelist) - ] + # Add models containing any whitelist string + preferred_set = { + model for model in model_list if any(w in model for w in whitelist) + } @@ - # Sort the model list stably to have preferred models first: - model_list.sort(key=lambda x: (x not in preferred_models, x)) + # Stable sort: keep original order within groups, preferred first + model_list.sort(key=lambda x: x not in preferred_set)Please verify the visual ordering in the dropdown matches prior expectations when the upstream model enumeration order changes (e.g., add/remove a model at runtime).
Also applies to: 181-183
174-180: Replace try/except/pass with contextlib.suppress for cleaner intentSilence-only exception handling is clearer with suppress and satisfies static analysis (SIM105).
Apply this diff:
- for b in blacklist: - try: - model_list.remove(b) - except ValueError: - pass + for b in blacklist: + with suppress(ValueError): + model_list.remove(b)And add the import (outside this hunk):
+from contextlib import suppresssrc/napari_chatgpt/microplugin/code_editor/python_syntax_highlighting.py (1)
87-109: Raw string regexes for operators: good; consider adding missing Python 3 operatorsThe conversion to raw strings removes double-escaping pitfalls. As a nice-to-have, include additional Python 3 operators for completeness:
- Walrus operator := and its in-place variant doesn’t exist, but include :=.
- Matrix multiply @ and @=.
Example patch:
# In-place r"\+=", "-=", r"\*=", "/=", r"\%=", + # Assignment expression and matrix multiply + r":=", + r"@", + r"@=",
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
src/napari_chatgpt/_widget.py(2 hunks)src/napari_chatgpt/microplugin/code_editor/code_snippet_editor_window.py(0 hunks)src/napari_chatgpt/microplugin/code_editor/python_syntax_highlighting.py(1 hunks)
💤 Files with no reviewable changes (1)
- src/napari_chatgpt/microplugin/code_editor/code_snippet_editor_window.py
🧰 Additional context used
🧬 Code graph analysis (1)
src/napari_chatgpt/_widget.py (1)
src/napari_chatgpt/utils/openai/model_list.py (2)
postprocess_openai_model_list(83-149)get_openai_model_list(8-80)
🪛 Ruff (0.12.2)
src/napari_chatgpt/_widget.py
176-179: Use contextlib.suppress(ValueError) instead of try-except-pass
Replace with contextlib.suppress(ValueError)
(SIM105)
🔇 Additional comments (2)
src/napari_chatgpt/_widget.py (1)
571-575: High-DPI attributes set before QApplication creation — good moveSetting AA_UseHighDpiPixmaps and AA_EnableHighDpiScaling before instantiating QApplication is correct and should prevent blurry rendering on macOS Retina displays.
src/napari_chatgpt/microplugin/code_editor/python_syntax_highlighting.py (1)
113-119: Raw string regexes for braces — LGTMEscaping braces/parens/brackets with raw strings is correct and clearer.
The main fix that was breaking Omega on mac was the hard-coded preferred model list generation failing. This was resolved by moving to a black/white list of models that we only update if the models actually exist.
The syntax highlighting fix improved my experience but is only tested on mac and may need to be platform-dependent
Finally, high DPI scaling has to be done earlier before GUI initialization.
Summary by CodeRabbit
New Features
Bug Fixes
Refactor