fix: clear previous provider highlight on new selection#60
Open
Pavankumar07s wants to merge 1 commit intomofa-org:mainfrom
Open
fix: clear previous provider highlight on new selection#60Pavankumar07s wants to merge 1 commit intomofa-org:mainfrom
Pavankumar07s wants to merge 1 commit intomofa-org:mainfrom
Conversation
Author
|
@BH3GEI please take a look! |
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.
📋 Summary
Fix the "sticky highlights" bug in the providers panel where clicking multiple provider items (e.g., OpenAI → DeepSeek → NVIDIA) accumulated highlight states instead of showing only the currently selected provider. The root cause was that select_provider_internal() and update_dark_mode() were not setting the shader's instance selected variable, which the ProviderItem pixel shader reads to render the selected background color. This PR adds selected: 0.0 / selected: 1.0 to the relevant apply_over() calls, ensuring only one provider is visually highlighted at a time.
🔗 Related Issues
Closes #58
Related to #58
🧠 Context
The ProviderItem widget uses a custom Makepad shader with instance selected, instance hover, and instance dark_mode variables. The shader's pixel() function computes the background color from these instance variables:
However, select_provider_internal() was only setting draw_bg: { color: (...) } — a property the shader never reads. This meant the shader's selected instance variable was never cleared on previously-selected items, causing all clicked items to stay highlighted. Custom provider items were already correctly using selected: 0.0/1.0, so only the four built-in providers (OpenAI, DeepSeek, Alibaba Cloud, NVIDIA) were affected.
🛠️ Changes
-Added selected: 0.0, hover: 0.0 to the reset loop in select_provider_internal() so all built-in items have their shader state cleared before the new selection
-Added selected: 1.0 to each built-in provider's selection branch so the shader renders the selected background
-Added selected: (selected_val) to the update_dark_mode() loop so dark mode toggling preserves correct selection state
-Added 3 unit tests for the ProvidersPanelAction enum (follows existing #[cfg(test)] module pattern)
🧪 How you Tested
Click OpenAI → only OpenAI highlights
Click DeepSeek → only DeepSeek highlights, OpenAI clears
Click NVIDIA → only NVIDIA highlights, DeepSeek clears
Toggle dark mode → selected provider stays correctly highlighted
📸 Screenshots / Logs (if applicable)
Screencast.From.2026-03-05.00-25-45.webm
If breaking:
🧹 Checklist
Code Quality
cargo fmtruncargo clippypasses without warningsTesting
cargo testpasses locally without any errorDocumentation
PR Hygiene
main🚀 Deployment Notes (if applicable)
No migrations, config changes, or environment variable changes required. Drop-in fix.
🧩 Additional Notes for Reviewers
The fix preserves all existing color logic (color: (normal_color) / color: (selected_color)) exactly as-is. The only additions are the selected and hover instance variables in the same apply_over() calls, which the shader's pixel() function actually reads. This is the minimal change needed to fix the glitch without altering any design decisions around colors or theming.