Skip to content

feat(gui): pick a custom keyboard lighting color - #2666

Open
Ariazonaa wants to merge 3 commits into
AprilNEA:masterfrom
Ariazonaa:feat/lighting-custom-color
Open

Ariazonaa wants to merge 3 commits into
AprilNEA:masterfrom
Ariazonaa:feat/lighting-custom-color

Conversation

@Ariazonaa

@Ariazonaa Ariazonaa commented Nov 26, 2026 •

Copy link
Copy Markdown

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's ColorPicker (palette, HSLA sliders and a hex field), so a custom color no longer means editing the TOML.

  • With a preset or the lighting off, the control shows a palette icon. With a custom color, it shows that color and carries the same selection ring as the swatches.
  • The nine presets are the picker's featured colors. The preset row itself is unchanged.
  • A palette pick or a hex commit closes the picker and is written at once. A slider drag only remembers the color, and it is written once, when the picker closes, so dragging doesn't stream lighting writes to the keyboard. Picking the color the keys already have writes nothing.
  • The write goes through 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.
  • New string lighting.custom_color in every locale. The translations are best effort, for Crowdin to refine.
Picker open Custom color selected
The color picker open from the custom-color control A custom color shown and selected on the tenth control

This touches keyboard_rgb.rs, which #2023 (lighting effects) also changes. The overlap is the swatch row and LightingPanel::new, so whichever lands second needs a small rebase.

Testing

  • features/lighting/keyboard_rgb/tests.rs:
    • unit tests for preset vs. custom selection, alpha-free conversion and every PickerEdit transition
    • window tests that click the control, type a hex color, dismiss by clicking outside, use the keyboard (focus, Enter, Escape), and check the 125% layout
  • Rust 1.100, RUSTFLAGS="-D warnings":
    • cargo fmt --all -- --check
    • cargo clippy --workspace --all-targets -- -D warnings
    • cargo test -p openlogi-desktop -p openlogi-ui
    • non-GUI cargo doc
  • On hardware (Windows 11, PRO Gaming Keyboard 046d:c339, wired, 0x8070), with a release build:
    • preset, palette, slider and hex picks all reach the keyboard
    • the agent log shows one 0x8070 write per pick and none while dragging

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.
@greptile-apps

greptile-apps Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Confidence Score: 4/5 · The remaining requirement to test an actual slider drag should be satisfied before merging.RetriggerView in GreptileConfidence Score: 4/5

[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

  1. P1 Tests bypass picker controls ▶

Summary

Adds a custom keyboard-lighting color picker beside the nine presets.

  • The keyboard Lighting card lets people pick a custom color.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    Closed -->|Open picker| Open
    Open -->|Change slider color| Dragged
    Dragged -->|Change slider color| Dragged
    Open -->|Close without change| Closed
    Dragged -->|Close and commit last color| Closed
    Open -->|Pick palette or commit hex| Closed
    Dragged -->|Pick palette or commit hex| Closed
Loading

Reviews (2) · Last reviewed commit: "docs: describe the custom keyboard light..." · Reviewed by Greptile

Comment on lines +147 to +157
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)));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Tests bypass picker controls

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!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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.

Comment on lines +173 to +182
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)),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Shared focus style is missing

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!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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.

Comment on lines +126 to +137
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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 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)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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%.

This branch has not been deployed

No deployments
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