Repository navigation
Conversation
A tenth control after the presets opens gpui-kit's color picker, so the keys can take any RGB color the config already stores. A palette pick or a hex commit is written at once; a slider drag is written once, when the picker closes.
[Medium impact] The change affects custom color selection in the keyboard lighting workflow. The remaining requirement to test an actual slider drag should be satisfied before merging. Findings
|
| cx.update(|window, cx| { | ||
| picker.update(cx, |picker, cx| { | ||
| picker.set_open(true, cx); | ||
| picker.update_color(rgb(0x11_2233).into(), window, cx); | ||
| picker.update_color(rgb(CUSTOM.packed()).into(), window, cx); | ||
| }); | ||
| }); | ||
| cx.run_until_parked(); | ||
| assert_eq!(current(cx), before, "a drag writes nothing"); | ||
| assert_eq!(lighting_writes(&mut receiver), 0); | ||
| cx.update(|_, cx| picker.update(cx, |picker, cx| picker.set_open(false, cx))); |
There was a problem hiding this comment.
These tests render LightingPanel but call select_color, update_color, and set_open directly. The repository requires GUI interaction tests to use user actions, not handler calls. A broken trigger, hex-field commit, or outside-click dismissal would leave these tests green.
Before merging, add tests that click the trigger, pick or type a color, drag, and dismiss the picker. Include the required minimum-window check at 125% scale.
Rule Used: Severity: medium. A GUI interaction test renders the real view as a window root and drives it the way the user does (click, wheel, focus change) instead of calling the handler. A desktop test that renders localized text or changes the locale holds `L... (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Fixed in 3f9baa7. The tests now:
- click the control to open the picker
- type a hex color into its field and press Enter
- click outside to dismiss it
- move focus to the control the way Tab does, then Enter opens the picker and Escape closes it
- check that the control wraps inside a 360 px column at 125%
gpui-kit v0.8.1 gives the popover's palette swatches and sliders no debug selector, so a test can't target them. The drag test still sends the slider reports through the picker state, but it opens and dismisses the picker with real clicks. The PickerEdit transitions behind it have their own unit tests.
| ColorPicker::new(&self.picker) | ||
| .with_size(Size::Size(px(SWATCH))) | ||
| .featured_colors( | ||
| PALETTE | ||
| .iter() | ||
| .map(|color| Hsla::from(rgb(color.packed()))) | ||
| .collect(), | ||
| ) | ||
| .accessibility_label(label) | ||
| .when(custom.is_none(), |picker| picker.icon(IconName::Palette)), |
There was a problem hiding this comment.
The new control never calls focus_ring(pal), unlike the neighboring swatches. The repository requires that shared style on every focusable control.
Apply it to the picker trigger in both its icon and custom-color states, and add a keyboard-focus test before merging. This is a missing shared style, not a claim that the library draws no focus indicator.
Rule Used: Severity: low. Every focusable control calls the shared focus_ring(pal) from crates/openlogi-desktop/src/ui/theme.rs in all its states, and text painted over accent_tint stays text_primary. A control whose change cannot be applied (device off... (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Fixed in 3f9baa7. The picker's trigger owns the focus handle, so the frame around it draws focus_ring(pal) under the same keyboard-only rule as focus_visible. The keyboard test focuses it and checks the input modality.
| if picker.read(cx).is_open() { | ||
| this.pending = Some(color); | ||
| } else { | ||
| this.pending = None; | ||
| commit_color(color, cx); | ||
| } | ||
| }); | ||
| let close = cx.observe(&picker, |this, picker, cx| { | ||
| if !picker.read(cx).is_open() | ||
| && let Some(color) = this.pending.take() | ||
| { | ||
| commit_color(color, cx); |
There was a problem hiding this comment.
Picker phases have separate writers
LightingPanel::picker's open status and LightingPanel::pending together encode the edit phase. One callback writes pending; another consumes it after checking the open status again. This violates the repository's requirement for one explicit state and transition owner.
Replace this coordination with one enum, such as Closed, OpenClean, OpenDirty(Rgb), and Closing(Rgb), owned by one transition method. Test that it refuses a dirty draft in Closed and changes from an already-finished session. No harmful invalid combination was established as reachable, so the design concern is non-blocking on behavior; the repository requirement still needs resolution before merging.
Context Used: Implicit state machines Flag any change that introduces or extends an implicit state machine: a lifecycle, phase, or mode that the code tracks through a combination of independent fields instead of one enum with one transition function. Report it as... (source)
There was a problem hiding this comment.
Fixed in 3f9baa7. One PickerEdit { Closed, Open, Dragged(Rgb) } and one next(open, color) transition now own the phase, and one handler moves it. Its unit tests cover the cases you named: a finished drag isn't written twice, and closing without a drag writes nothing.
The picker's open state and the dragged color now live in one PickerEdit with one transition, and the custom control draws the shared focus ring when the keyboard focuses its trigger. Tests drive the control as a user does: a click opens the picker, typed hex commits once, a click outside dismisses, focus traversal and Enter/Escape work, and the control wraps inside a narrow card at 125%.
Summary
The Lighting card offers nine preset colors, but the config (
color = "RRGGBB") and the keyboards take any RGB color. This adds a tenth control after the presets that opens gpui-kit'sColorPicker(palette, HSLA sliders and a hex field), so a custom color no longer means editing the TOML.AppState::commit_lighting, like a swatch click, so there are no agent, IPC or config changes. The picker's alpha is ignored, because the keys have none.lighting.custom_colorin every locale. The translations are best effort, for Crowdin to refine.This touches
keyboard_rgb.rs, which #2023 (lighting effects) also changes. The overlap is the swatch row andLightingPanel::new, so whichever lands second needs a small rebase.Testing
features/lighting/keyboard_rgb/tests.rs:PickerEdittransitionRUSTFLAGS="-D warnings":cargo fmt --all -- --checkcargo clippy --workspace --all-targets -- -D warningscargo test -p openlogi-desktop -p openlogi-uicargo doc046d:c339, wired,0x8070), with a release build:0x8070write per pick and none while dragging