Skip to content

refactor(fl/ui): split UI elements into per-element headers - #2414

Merged
zackees merged 7 commits into
masterfrom
refactor/fl-ui-folder
Apr 28, 2026
Merged

zackees merged 7 commits into
masterfrom
refactor/fl-ui-folder

Conversation

@zackees

@zackees zackees commented Apr 25, 2026 •

Copy link
Copy Markdown
Member

Summary

Refactors the monolithic fl/ui.h into per-element headers under fl/ui/, plus assorted earlier refactor work that landed on this branch.

Commits

  • `refactor(fl/ui): scaffold per-element split + fix rx template lint`
  • `fix(fl/ui): address CodeRabbit feedback on per-element UI scaffold`
  • `refactor(fl/ui): finish per-element split, drop migration guard`
  • `fix(fl/ui): include fl/system/log.h for FL_WARN in audio.h`
  • `refactor(fl/channels): relocate id_tracker and RxDevice impl into channels API`
  • `fix(ci/tools): force UTF-8 decoding in coderabbit_addressor gh wrapper`
  • `style(ci): apply ruff format to Python CI scripts`

Test plan

  • `bash test --cpp` passes locally
  • `bash lint` passes
  • CI green

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added dedicated UIButton callback removals: removeChangedCallback(), removePressedCallback(), removeReleasedCallback(), plus removeClickedCallback() alias.
  • Bug Fixes

    • UISlider now invokes callbacks only when the post-clamp value actually changes.
    • UIDropdown frame/update logic improved for consistent option advancement and notifications.
  • Breaking Changes

    • UIButton::addRealButton() now accepts an IButtonInput interface; removed removeCallback().
  • Chores

    • Internal headers and build units reorganized; include paths updated.

@coderabbitai

coderabbitai Bot commented Apr 25, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7c5c862c-e5bd-46ec-825d-c51b456c1178

📥 Commits

Reviewing files that changed from the base of the PR and between 5f365ff and 408c79c.

📒 Files selected for processing (1)
  • src/fl/ui/button.h

📝 Walkthrough

Walkthrough

Reorganizes header locations and unity-build aggregation (assets, tests, math, system), updates include paths across the codebase, adds two unity build entry-point files, and makes targeted UI behavior and API changes (UIButton, UISlider, UIDropdown, UITitle).

Changes

Cohort / File(s) Summary
Unity build aggregation & entry points
src/fl/_build.cpp.hpp, src/fl/build/fl.cpp, src/fl/asset/_build.cpp.hpp, src/fl/test/_build.cpp.hpp, src/fl/math/_build.cpp.hpp, src/fl/system/_build.cpp.hpp, src/fl/build/fl.asset+.cpp, src/fl/build/fl.test+.cpp, ci/lint_cpp/test_unity_build.py
Adds subdirectory unity headers and two new unity translation units; updates root unity includes to use subdirectory aggregators; extends lint expected build filenames.
Header relocations — math/time_alpha
src/fl/math/time_alpha.cpp.hpp, src/fl/math/_build.cpp.hpp, examples/... (examples/Audio/simple/fx_audio.h, examples/Audio/simple/simple.h, examples/Downscale/Downscale.h, examples/Fx/FxWave2d/wavefx.cpp, examples/XYPath/*), src/fl/sensors/pir.h, tests/fl/math/time_alpha.hpp, README.md
Moves time_alpha into fl/math/ and updates all include paths and README link references accordingly.
Header relocations — system/trace & timeout
src/fl/system/trace.cpp.hpp, src/fl/system/_build.cpp.hpp, src/FastLED.cpp.hpp, src/fl/channels/..., src/fl/task/task.h, src/platforms/..., tests/fl/system/trace.hpp, tests/...
Replaces fl/trace.h/fl/timeout.h includes with fl/system/trace.h/fl/system/timeout.h across sources and tests.
Header relocations — asset & test
src/fl/asset/asset.cpp.hpp, src/fl/asset/asset.h, ci/compiler/asset_scanner.py, ci/tests/test_asset_scanner.py, examples/AudioUrl/AudioUrl.ino, tests/fl/asset/asset.cpp, src/fl/test/fltest.cpp.hpp, src/fl/test/fltest.h, tests/fl/...
Moves asset and fltest headers into fl/asset/ and fl/test/, updates includes and generated scanner output; adjusts test includes/docs.
UIButton API & integration
src/fl/ui/button.h, src/fl/sensors/ui_button_integration.cpp.hpp
Changes addRealButton() to accept shared_ptr<IButtonInput>; replaces single removeCallback(int) with per-list removers (removeChangedCallback, removeClickedCallback, removePressedCallback, removeReleasedCallback).
UISlider behavior
src/fl/ui/slider.cpp.hpp
Always applies underlying set/clamp then reads back observable value; callbacks fire only when post-clamp value changes.
UIDropdown control flow
src/fl/ui/dropdown.cpp.hpp
Seeds last-frame value before next-button handling, removes staging variable, ensures value comparison/callback runs after potential advancement.
UITitle adjustments
src/fl/ui/title.cpp.hpp, src/fl/ui/title.h
For JSON UI, construct mImpl with (name, text) both from fl::string(name); mark non-WASM stub ctor and setGroup as FL_NOEXCEPT.
Platform / clockless doc paths
src/platforms/clockless.h, src/platforms/shared/clockless_blocking.h
Updates documentation include paths to fl/chipsets/... for clockless controller implementation.
Misc. test include migrations
tests/fl/... (various test files listed in diff)
Updates multiple tests to new include locations (fl/test/fltest.h, fl/system/*, fl/math/*, fl/asset/*).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰
Files hop to folders, neat and spry,
Headers find new homes—oh my!
Unity builds gather in a row,
Buttons, sliders learn to grow,
I nibble bugs and say: "Bravo!" 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the primary refactoring objective: splitting UI elements from a monolithic header into per-element headers, which aligns with the extensive file reorganization throughout the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/fl-ui-folder

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🧹 Nitpick comments (15)
src/fl/ui/title.h (1)

34-39: Stale comment.

The comment "if it has the method (WASM platforms)" suggests setGroup is conditionally present, but the stub at line 23 always defines it, and the call at line 38 is unconditional. Reword to reflect the actual contract (every UITitleImpl must provide setGroup).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/ui/title.h` around lines 34 - 39, The comment above the override
incorrectly implies conditional availability of setGroup; instead state that
UITitleImpl is required to implement setGroup and that this override calls
UIElement::setGroup and then unconditionally forwards the groupName to the
implementation via mImpl.setGroup(groupName). Update the comment to reflect this
contract and remove the conditional "if it has the method (WASM platforms)"
phrasing.
src/fl/ui/group.cpp.hpp (1)

6-6: Minor: passing c_str() discards length and forces a re-scan downstream.

If UIGroupImpl only accepts const char*, consider overloading it to also accept const fl::string& to avoid an unnecessary strlen inside mImpl. Not blocking — flagging for consistency with how other UI elements that accept names are implemented.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/ui/group.cpp.hpp` at line 6, The constructor UIGroup::UIGroup
currently passes groupName.c_str() into mImpl which forces downstream
re-scan/strlen; add an overload to UIGroupImpl that accepts const fl::string&
(or const std::string& if appropriate) and update UIGroup::UIGroup to forward
the fl::string directly to mImpl (or alternatively change mImpl's constructor
signature) so the length is preserved and no extra c_str()/strlen is required;
reference UIGroup::UIGroup, mImpl, and UIGroupImpl when making the change.
src/fl/sensors/button.h (1)

67-99: Push the mutable down into ButtonLowLevel instead of marking mButton mutable.

mutable ButtonLowLevel mButton is a workaround because ButtonLowLevel::isPressed() (line 39) is non-const. The justification in the comment ("hardware probing/toggling from a logically-const query") actually applies to ButtonLowLevel itself, not to Button. A cleaner fix is to make ButtonLowLevel::isPressed() and highLowFloating() const, marking only the genuinely-mutated members (e.g., the pin mode/level cache) mutable inside ButtonLowLevel. That way:

  • Button::mButton can stay non-mutable (better default).
  • The "logical const" boundary is encoded at the layer that actually owns the mutation, not propagated upward.
Sketch
 class ButtonLowLevel {
   public:
-    bool isPressed();
-    bool highLowFloating();
+    bool isPressed() const FL_NOEXCEPT;
+    bool highLowFloating() const FL_NOEXCEPT;
   private:
-    fl::DigitalPin mPin;
+    mutable fl::DigitalPin mPin;  // toggled during probe
     ButtonStrategy mStrategy = ButtonStrategy::kHighLowFloating;
 };
-    mutable ButtonLowLevel mButton;
+    ButtonLowLevel mButton;

Note setStrategy (line 63) is correctly non-const, so no impact there.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/sensors/button.h` around lines 67 - 99, The field mButton should not
be mutable on Button; instead make the mutation-local to ButtonLowLevel by
marking ButtonLowLevel::isPressed() and ButtonLowLevel::highLowFloating() const
and moving the mutable qualifier to the internal members that actually change
(e.g., pin mode/level cache) inside ButtonLowLevel; then remove mutable from
Button::mButton and ensure setStrategy remains non-const and all callers
(Button::isPressed, Listener, tests) still call isPressed() without changes.
src/fl/ui/number_field.cpp.hpp (1)

5-7: Optional: scope the float-equal suppression to the comparison sites.

Disabling -Wfloat-equal at file scope hides future legitimate warnings if more code is added below. Consider wrapping just the value != owner.mLastFrameValue site (line 25) with FL_DISABLE_WARNING_PUSH/POP, similar to how it's done in slider.cpp.hpp (where it's also file-wide — same comment applies there).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/ui/number_field.cpp.hpp` around lines 5 - 7, Currently the file-wide
FL_DISABLE_WARNING(float-equal) is too broad; instead remove the file-scope
float-equal suppression and wrap only the floating-point equality check site
(the comparison "value != owner.mLastFrameValue") with a scoped suppression:
surround that specific comparison expression with FL_DISABLE_WARNING_PUSH,
FL_DISABLE_WARNING(float-equal), and FL_DISABLE_WARNING_POP so only the equality
check is silenced and other future warnings remain enabled.
src/fl/ui/slider.cpp.hpp (1)

28-40: Nit: use *this-style consistency.

Line 24 invokes mCallbacks.invoke(*this) while line 37 uses mCallbacks.invoke(*mOwner). They're equivalent here, but pick one. Minor.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/ui/slider.cpp.hpp` around lines 28 - 40, In
UISlider::Listener::onBeginFrame, make the callback invocation consistent with
the other usage by replacing mCallbacks.invoke(*mOwner) with
mCallbacks.invoke(*this) (referencing UISlider::Listener::onBeginFrame,
mCallbacks.invoke and mOwner) so the same `*this`-style is used throughout the
Listener code.
src/fl/ui/help.h (1)

18-18: Redundant FASTLED_UNUSED — the parameter is already used.

markdownContent is consumed by mContent(markdownContent) in the init list, so FASTLED_UNUSED(markdownContent) is dead code (and slightly misleading when reading the stub vs. the real impl).

-    UIHelpImpl(const char *markdownContent) : mContent(markdownContent) { FASTLED_UNUSED(markdownContent); }
+    UIHelpImpl(const char *markdownContent) : mContent(markdownContent) {}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/ui/help.h` at line 18, The constructor UIHelpImpl(const char
*markdownContent) currently calls FASTLED_UNUSED(markdownContent) even though
markdownContent is used in the member initializer mContent(markdownContent);
remove the FASTLED_UNUSED(markdownContent) call from the constructor body to
avoid the redundant/deceptive macro and rely on the initializer list to consume
the parameter (update UIHelpImpl constructor accordingly).
src/fl/ui/element.h (1)

8-10: Minor asymmetry: FL_NOEXCEPT on a deleted assignment operator is a no-op.

= delete makes the function unusable, so FL_NOEXCEPT adds nothing here, and the copy ctor on the line above is left without it. Consider dropping it for symmetry (purely cosmetic):

 `#define` FL_NO_COPY(CLASS)                                                      \
     CLASS(const CLASS &) = delete;                                             \
-    CLASS &operator=(const CLASS &) FL_NOEXCEPT = delete;
+    CLASS &operator=(const CLASS &) = delete;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/ui/element.h` around lines 8 - 10, The FL_NO_COPY macro includes
FL_NOEXCEPT on the deleted copy-assignment but not on the deleted
copy-constructor; remove the FL_NOEXCEPT token from the assignment operator
declaration inside the FL_NO_COPY macro so both deleted functions are written
symmetrically (i.e., keep CLASS(const CLASS &) = delete; and CLASS
&operator=(const CLASS &) = delete;)—refer to the FL_NO_COPY macro definition
and the FL_NOEXCEPT symbol when making the edit.
src/fl/ui/number_field.h (1)

81-85: Optional: move the callback into the list to avoid a copy.

callback is taken by value; mCallbacks.add(callback) then copies it again. If function_list::add accepts an rvalue, std::move (or fl::move) avoids a needless copy, especially relevant for capturing lambdas:

-    void onChanged(function<void(UINumberField &)> callback) FL_NOEXCEPT {
-        mCallbacks.add(callback);
+    void onChanged(function<void(UINumberField &)> callback) FL_NOEXCEPT {
+        mCallbacks.add(fl::move(callback));
         mListener.addToEngineEventsOnce();
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/ui/number_field.h` around lines 81 - 85, The onChanged method
currently takes callback by value and then passes it to mCallbacks.add, causing
an extra copy; modify onChanged (the parameter named callback and the call
mCallbacks.add(callback)) to forward/move the callback into mCallbacks.add
(e.g., use std::move or fl::move when calling mCallbacks.add) so the captured
lambda isn't duplicated, leaving mListener.addToEngineEventsOnce() unchanged.
src/fl/ui/group.h (2)

49-52: Null-pointer dereference in addControl.

addControl(T* control) calls control->setGroup(...) without guarding against nullptr. A defensive early-return would be cheap insurance, especially since this is part of a public API surface.

🛡️ Proposed guard
     template<typename T>
     void addControl(T* control) FL_NOEXCEPT {
+        if (!control) {
+            return;
+        }
         control->setGroup(name());
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/ui/group.h` around lines 49 - 52, The template method addControl(T*
control) may dereference a null pointer when calling control->setGroup(name());
add a defensive null check at the start of addControl to return early if control
is nullptr. Locate the template<typename T> void addControl(T* control)
FL_NOEXCEPT and guard it (e.g., if (!control) return;) before calling
control->setGroup(name()) so public callers cannot trigger a null-pointer
dereference.

19-21: Redundant FASTLED_UNUSED(name).

name is consumed by the mGroupName(name) initializer, so the unused-marker is dead and a bit misleading.

♻️ Proposed cleanup
-    UIGroupImpl(const char *name) FL_NOEXCEPT : mGroupName(name) {
-        FASTLED_UNUSED(name);
-    }
+    UIGroupImpl(const char *name) FL_NOEXCEPT : mGroupName(name) {}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/ui/group.h` around lines 19 - 21, The constructor UIGroupImpl(const
char *name) FL_NOEXCEPT initializes mGroupName(name) so FASTLED_UNUSED(name) is
redundant and should be removed; update the UIGroupImpl constructor to drop the
FASTLED_UNUSED(name) call and keep mGroupName(name) initializer only, leaving no
unused-marker for the parameter.
src/fl/ui/dropdown.h (2)

122-122: Consider fl::span<const fl::string> for the options parameter.

The constructor only copies elements out of the span, so a read-only view is more accurate and lets callers pass spans over const data. Purely an API hygiene tweak.

♻️ Proposed signature
-    UIDropdown(const char *name, fl::span<fl::string> options) FL_NOEXCEPT;
+    UIDropdown(const char *name, fl::span<const fl::string> options) FL_NOEXCEPT;

(The matching UIDropdownImpl ctor at line 51 would need the same change.)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/ui/dropdown.h` at line 122, Change the UIDropdown constructor
signature to take a read-only span (fl::span<const fl::string>) instead of
fl::span<fl::string>, and make the corresponding change to the UIDropdownImpl
constructor so both declaration and implementation accept fl::span<const
fl::string>; this reflects that the constructors only copy data out of the span,
allows callers to pass spans over const data, and requires updating the matching
function signatures and any places that call these constructors to use the new
span type.

150-154: nextOption() performs a modulo by getOptionCount() without guarding against zero.

The non-WASM UIDropdownImpl ctors all push a "No options" fallback so the count is currently ≥ 1, but the public UIDropdown doesn't enforce that invariant itself. If a future backend (e.g. WASM impl with FASTLED_HAS_UI_DROPDOWN=1) ever leaves mOptions empty, this is a divide-by-zero / UB. Cheap to harden.

🛡️ Proposed guard
     void nextOption() FL_NOEXCEPT {
-        int currentIndex = as_int();
-        int nextIndex = (currentIndex + 1) % static_cast<int>(getOptionCount());
-        setSelectedIndex(nextIndex);
+        const int count = static_cast<int>(getOptionCount());
+        if (count <= 0) {
+            return;
+        }
+        int currentIndex = as_int();
+        setSelectedIndex((currentIndex + 1) % count);
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/ui/dropdown.h` around lines 150 - 154, nextOption() currently does
(currentIndex + 1) % getOptionCount() which can divide by zero if there are no
options; update nextOption() in UIDropdown/UIDropdownImpl to first retrieve
optionCount = getOptionCount() and if optionCount == 0 simply return (or
setSelectedIndex(0) if you prefer a defined state) to avoid the modulo by zero;
use the existing helpers as_int() and setSelectedIndex() and keep the rest of
the logic unchanged.
src/fl/ui/slider.h (1)

37-39: Type-prefix inconsistency between UISliderImpl and UISlider.

UISliderImpl::operator u16() (line 38) uses the bare name while UISlider::operator fl::u16() (line 84) uses the fully-qualified fl::u16. Both compile inside namespace fl, but the asymmetry is needless; pick one and apply uniformly (preferring fl::u16 per project convention).

♻️ Proposed normalization
-    operator u8() const { return static_cast<u8>(mValue); }
-    operator u16() const { return static_cast<u16>(mValue); }
+    operator fl::u8() const { return static_cast<fl::u8>(mValue); }
+    operator fl::u16() const { return static_cast<fl::u16>(mValue); }

Also applies to: 82-85

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/ui/slider.h` around lines 37 - 39, The operators in UISliderImpl
(operator u8/ u16/ int) use unqualified type names while UISlider uses
fully-qualified fl::u16, causing inconsistent style; update UISliderImpl's
operator declarations (e.g., UISliderImpl::operator u16()) to use the
project-preferred fully-qualified names (fl::u8, fl::u16, fl::int or fl::i32 as
appropriate) matching UISlider::operator fl::u16(), and ensure the static_cast
target types reference fl::... (and mirror the same change for the corresponding
operators around lines 82-85) so both classes use the same fl:: type-prefix
convention while still casting mValue the same way.
src/fl/ui/audio.h (1)

36-44: FL_WARN will spam logs on every call.

In a typical render/audio loop these stubs will be called every frame (or every audio buffer) on any non-WASM platform that doesn't define FASTLED_HAS_UI_AUDIO, flooding output. Consider a warn-once gate or downgrade to a debug-level log.

🪵 One-shot warn pattern
     audio::Sample next() {
-        FL_WARN("Audio sample not implemented");
+        static bool warned = false;
+        if (!warned) { FL_WARN("UIAudio::next() not implemented on this platform"); warned = true; }
         return audio::Sample();
     }

     bool hasNext() {
-        FL_WARN("Audio sample not implemented");
+        static bool warned = false;
+        if (!warned) { FL_WARN("UIAudio::hasNext() not implemented on this platform"); warned = true; }
         return false;
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/ui/audio.h` around lines 36 - 44, The FL_WARN calls in audio::Sample
next() and bool hasNext() will spam logs each frame; change them to either a
debug-level log (use FL_DEBUG instead of FL_WARN) or implement a one-shot gate:
add a static bool (e.g., warned_audio_ui) checked and set so FL_WARN is emitted
only once, and reuse that gate in both next() and hasNext() to avoid per-frame
warnings while keeping a single informative message.
src/fl/ui/checkbox.h (1)

69-73: API asymmetry vs. other UI widgets.

UICheckbox::onChanged returns void and there is no per-id removeCallback, while UIButton, UISlider, and UIDropdown all return an int id and (for UIButton) provide removeCallback(int). This makes selectively removing a single callback impossible on UICheckbox. Consider matching the sibling widgets for API symmetry.

♻️ Proposed alignment
-    void onChanged(function<void(UICheckbox &)> callback) FL_NOEXCEPT {
-        mCallbacks.add(callback);
-        mListener.addToEngineEventsOnce();
-    }
-    void clearCallbacks() FL_NOEXCEPT { mCallbacks.clear(); }
+    int onChanged(function<void(UICheckbox &)> callback) FL_NOEXCEPT {
+        int id = mCallbacks.add(callback);
+        mListener.addToEngineEventsOnce();
+        return id;
+    }
+    void removeCallback(int id) FL_NOEXCEPT { mCallbacks.remove(id); }
+    void clearCallbacks() FL_NOEXCEPT { mCallbacks.clear(); }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/ui/checkbox.h` around lines 69 - 73, UICheckbox::onChanged currently
returns void and only offers clearCallbacks(), causing API asymmetry with
UIButton/UISlider/UIDropdown; change onChanged(function<void(UICheckbox &)>
callback) to return an int callback id (like other widgets), wire that id into
mCallbacks so callers can later remove a single callback, and add a
removeCallback(int id) method that forwards to mCallbacks.remove(id); keep the
mListener.addToEngineEventsOnce() call in onChanged and preserve
clearCallbacks() behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/fl/channels/rx.h`:
- Around line 428-436: The explicit specializations declared as template <>
fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::...>(int pin)
FL_NOEXCEPT in rx.h must have matching exception specifications in their
definitions in src/fl/channels/rx.cpp.hpp; update every definition of
RxDevice::create for RxDeviceType::PLATFORM_DEFAULT, ::RMT, ::ISR, and ::FLEXPWM
across the FL_IS_ESP32, FL_IS_TEENSY_4X, and fallback blocks to append
FL_NOEXCEPT so they match the declarations (and the primary template) exactly.

In `@src/fl/ui/button.h`:
- Around line 78-115: The current removeCallback(int id) removes the given id
from all three function_list instances (mCallbacks, mPressCallbacks,
mReleaseCallbacks) which is incorrect because each list has its own mIdCounter
and ids collide; change the API to provide per-list removers: add
removeChangedCallback(int id) that calls mCallbacks.remove(id),
removePressedCallback(int id) that calls mPressCallbacks.remove(id), and
removeReleasedCallback(int id) that calls mReleaseCallbacks.remove(id); update
any callers to use the corresponding per-list remover (or keep removeCallback as
deprecated/removed) and leave clearCallbacks() as-is to clear all lists.
- Line 67: The addRealButton signature is too specific (takes
fl::shared_ptr<Button>) but the class stores buttons as
fl::shared_ptr<IButtonInput>; change the addRealButton parameter to accept
fl::shared_ptr<IButtonInput> to match the member type and avoid unnecessary
coupling to the concrete Button class (update any callers to pass an
IButtonInput shared_ptr and include element.h as needed); ensure the function
body uses IButtonInput methods and the member variable
(fl::shared_ptr<IButtonInput>) without implicit conversions.

In `@src/fl/ui/dropdown.cpp.hpp`:
- Around line 29-43: The first-frame advance via nextOption() is mutating the
value before mLastFrameValue is initialized, which causes the mCallbacks change
notification to be skipped; modify the onBeginFrame logic in the dropdown class
so you set owner.mLastFrameValue = owner.as_int() and owner.mLastFrameValueValid
= true before calling owner.nextOption(), then keep the existing
comparison/notification (owner.mCallbacks.invoke(owner)) afterwards so a
nextOption() triggered on the very first frame still produces the change
callback.

In `@src/fl/ui/slider.cpp.hpp`:
- Around line 15-26: The change detection in UISlider::setValue currently
compares the input value to oldValue and can fire callbacks even when mImpl
clamps back to the same observable value; fix by comparing the post-clamp value
instead: call mImpl.setValue(value), read float newValue = mImpl.value(), and
only update mLastFrameValue/mLastFrameValueValid and call
mCallbacks.invoke(*this) when newValue != oldValue; keep the readback assignment
and callback invocation guarded by that post-clamp comparison to avoid spurious
notifications.

In `@src/fl/ui/title.cpp.hpp`:
- Around line 6-10: The UITitle constructor currently constructs two distinct
fl::string temporaries in the JSON path (mImpl(fl::string(name),
fl::string(name))) which is likely unintended or inefficient; update UITitle
(the UITitle::UITitle(const char*) initializer) so it only creates one
fl::string for the default text instead of two (e.g., construct a single
fl::string variable and pass it for both name/text or call the JsonTitleImpl
constructor overload that accepts a single fl::string when text should default
to name), and adjust the call to mImpl (JsonTitleImpl constructor) accordingly
so name and text are provided as intended.

In `@src/fl/ui/title.h`:
- Around line 17-24: The stub class UITitleImpl must match the noexcept contract
of UITitle: mark the constructor UITitleImpl(const char *name) and the method
void setGroup(const fl::string& groupName) as FL_NOEXCEPT, and update the
non-stub (WASM) implementation of UITitleImpl::setGroup (and its constructor if
present) to also be FL_NOEXCEPT so that UITitle::setGroup (declared FL_NOEXCEPT
override) does not cross a throwing boundary; ensure all declarations and
definitions for UITitleImpl::UITitleImpl and UITitleImpl::setGroup use
FL_NOEXCEPT consistently.

---

Nitpick comments:
In `@src/fl/sensors/button.h`:
- Around line 67-99: The field mButton should not be mutable on Button; instead
make the mutation-local to ButtonLowLevel by marking ButtonLowLevel::isPressed()
and ButtonLowLevel::highLowFloating() const and moving the mutable qualifier to
the internal members that actually change (e.g., pin mode/level cache) inside
ButtonLowLevel; then remove mutable from Button::mButton and ensure setStrategy
remains non-const and all callers (Button::isPressed, Listener, tests) still
call isPressed() without changes.

In `@src/fl/ui/audio.h`:
- Around line 36-44: The FL_WARN calls in audio::Sample next() and bool
hasNext() will spam logs each frame; change them to either a debug-level log
(use FL_DEBUG instead of FL_WARN) or implement a one-shot gate: add a static
bool (e.g., warned_audio_ui) checked and set so FL_WARN is emitted only once,
and reuse that gate in both next() and hasNext() to avoid per-frame warnings
while keeping a single informative message.

In `@src/fl/ui/checkbox.h`:
- Around line 69-73: UICheckbox::onChanged currently returns void and only
offers clearCallbacks(), causing API asymmetry with
UIButton/UISlider/UIDropdown; change onChanged(function<void(UICheckbox &)>
callback) to return an int callback id (like other widgets), wire that id into
mCallbacks so callers can later remove a single callback, and add a
removeCallback(int id) method that forwards to mCallbacks.remove(id); keep the
mListener.addToEngineEventsOnce() call in onChanged and preserve
clearCallbacks() behavior.

In `@src/fl/ui/dropdown.h`:
- Line 122: Change the UIDropdown constructor signature to take a read-only span
(fl::span<const fl::string>) instead of fl::span<fl::string>, and make the
corresponding change to the UIDropdownImpl constructor so both declaration and
implementation accept fl::span<const fl::string>; this reflects that the
constructors only copy data out of the span, allows callers to pass spans over
const data, and requires updating the matching function signatures and any
places that call these constructors to use the new span type.
- Around line 150-154: nextOption() currently does (currentIndex + 1) %
getOptionCount() which can divide by zero if there are no options; update
nextOption() in UIDropdown/UIDropdownImpl to first retrieve optionCount =
getOptionCount() and if optionCount == 0 simply return (or setSelectedIndex(0)
if you prefer a defined state) to avoid the modulo by zero; use the existing
helpers as_int() and setSelectedIndex() and keep the rest of the logic
unchanged.

In `@src/fl/ui/element.h`:
- Around line 8-10: The FL_NO_COPY macro includes FL_NOEXCEPT on the deleted
copy-assignment but not on the deleted copy-constructor; remove the FL_NOEXCEPT
token from the assignment operator declaration inside the FL_NO_COPY macro so
both deleted functions are written symmetrically (i.e., keep CLASS(const CLASS
&) = delete; and CLASS &operator=(const CLASS &) = delete;)—refer to the
FL_NO_COPY macro definition and the FL_NOEXCEPT symbol when making the edit.

In `@src/fl/ui/group.cpp.hpp`:
- Line 6: The constructor UIGroup::UIGroup currently passes groupName.c_str()
into mImpl which forces downstream re-scan/strlen; add an overload to
UIGroupImpl that accepts const fl::string& (or const std::string& if
appropriate) and update UIGroup::UIGroup to forward the fl::string directly to
mImpl (or alternatively change mImpl's constructor signature) so the length is
preserved and no extra c_str()/strlen is required; reference UIGroup::UIGroup,
mImpl, and UIGroupImpl when making the change.

In `@src/fl/ui/group.h`:
- Around line 49-52: The template method addControl(T* control) may dereference
a null pointer when calling control->setGroup(name()); add a defensive null
check at the start of addControl to return early if control is nullptr. Locate
the template<typename T> void addControl(T* control) FL_NOEXCEPT and guard it
(e.g., if (!control) return;) before calling control->setGroup(name()) so public
callers cannot trigger a null-pointer dereference.
- Around line 19-21: The constructor UIGroupImpl(const char *name) FL_NOEXCEPT
initializes mGroupName(name) so FASTLED_UNUSED(name) is redundant and should be
removed; update the UIGroupImpl constructor to drop the FASTLED_UNUSED(name)
call and keep mGroupName(name) initializer only, leaving no unused-marker for
the parameter.

In `@src/fl/ui/help.h`:
- Line 18: The constructor UIHelpImpl(const char *markdownContent) currently
calls FASTLED_UNUSED(markdownContent) even though markdownContent is used in the
member initializer mContent(markdownContent); remove the
FASTLED_UNUSED(markdownContent) call from the constructor body to avoid the
redundant/deceptive macro and rely on the initializer list to consume the
parameter (update UIHelpImpl constructor accordingly).

In `@src/fl/ui/number_field.cpp.hpp`:
- Around line 5-7: Currently the file-wide FL_DISABLE_WARNING(float-equal) is
too broad; instead remove the file-scope float-equal suppression and wrap only
the floating-point equality check site (the comparison "value !=
owner.mLastFrameValue") with a scoped suppression: surround that specific
comparison expression with FL_DISABLE_WARNING_PUSH,
FL_DISABLE_WARNING(float-equal), and FL_DISABLE_WARNING_POP so only the equality
check is silenced and other future warnings remain enabled.

In `@src/fl/ui/number_field.h`:
- Around line 81-85: The onChanged method currently takes callback by value and
then passes it to mCallbacks.add, causing an extra copy; modify onChanged (the
parameter named callback and the call mCallbacks.add(callback)) to forward/move
the callback into mCallbacks.add (e.g., use std::move or fl::move when calling
mCallbacks.add) so the captured lambda isn't duplicated, leaving
mListener.addToEngineEventsOnce() unchanged.

In `@src/fl/ui/slider.cpp.hpp`:
- Around line 28-40: In UISlider::Listener::onBeginFrame, make the callback
invocation consistent with the other usage by replacing
mCallbacks.invoke(*mOwner) with mCallbacks.invoke(*this) (referencing
UISlider::Listener::onBeginFrame, mCallbacks.invoke and mOwner) so the same
`*this`-style is used throughout the Listener code.

In `@src/fl/ui/slider.h`:
- Around line 37-39: The operators in UISliderImpl (operator u8/ u16/ int) use
unqualified type names while UISlider uses fully-qualified fl::u16, causing
inconsistent style; update UISliderImpl's operator declarations (e.g.,
UISliderImpl::operator u16()) to use the project-preferred fully-qualified names
(fl::u8, fl::u16, fl::int or fl::i32 as appropriate) matching UISlider::operator
fl::u16(), and ensure the static_cast target types reference fl::... (and mirror
the same change for the corresponding operators around lines 82-85) so both
classes use the same fl:: type-prefix convention while still casting mValue the
same way.

In `@src/fl/ui/title.h`:
- Around line 34-39: The comment above the override incorrectly implies
conditional availability of setGroup; instead state that UITitleImpl is required
to implement setGroup and that this override calls UIElement::setGroup and then
unconditionally forwards the groupName to the implementation via
mImpl.setGroup(groupName). Update the comment to reflect this contract and
remove the conditional "if it has the method (WASM platforms)" phrasing.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 09f7ef3f-6f35-4994-b658-9e286ebee0e8

📥 Commits

Reviewing files that changed from the base of the PR and between 33e10ef and 4523b7f.

📒 Files selected for processing (35)
  • ci/lint_cpp/test_unity_build.py
  • ci/tools/coderabbit_addressor.py
  • src/fl/_build.cpp.hpp
  • src/fl/build/fl.cpp
  • src/fl/build/fl.ui+.cpp
  • src/fl/channels/rx.cpp.hpp
  • src/fl/channels/rx.h
  • src/fl/sensors/button.h
  • src/fl/ui.cpp.hpp
  • src/fl/ui.h
  • src/fl/ui/_build.cpp.hpp
  • src/fl/ui/audio.cpp.hpp
  • src/fl/ui/audio.h
  • src/fl/ui/button.cpp.hpp
  • src/fl/ui/button.h
  • src/fl/ui/checkbox.cpp.hpp
  • src/fl/ui/checkbox.h
  • src/fl/ui/description.cpp.hpp
  • src/fl/ui/description.h
  • src/fl/ui/dropdown.cpp.hpp
  • src/fl/ui/dropdown.h
  • src/fl/ui/element.cpp.hpp
  • src/fl/ui/element.h
  • src/fl/ui/group.cpp.hpp
  • src/fl/ui/group.h
  • src/fl/ui/help.cpp.hpp
  • src/fl/ui/help.h
  • src/fl/ui/number_field.cpp.hpp
  • src/fl/ui/number_field.h
  • src/fl/ui/slider.cpp.hpp
  • src/fl/ui/slider.h
  • src/fl/ui/title.cpp.hpp
  • src/fl/ui/title.h
  • src/fl/ui_impl.h
  • tests/fl/channels/rx.cpp
💤 Files with no reviewable changes (3)
  • src/fl/build/fl.cpp
  • src/fl/ui.cpp.hpp
  • src/fl/ui_impl.h

Comment thread src/fl/channels/rx.h
Comment on lines +428 to +436
// Explicit specialization declarations — definitions live in
// fl/channels/rx.cpp.hpp. Declaring them here prevents implicit
// instantiation of the primary template at call sites (e.g.,
// channel.cpp.hpp), which would otherwise collide with the explicit
// specializations when both live in the same translation unit.
template <> fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::PLATFORM_DEFAULT>(int pin) FL_NOEXCEPT;
template <> fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::RMT>(int pin) FL_NOEXCEPT;
template <> fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::ISR>(int pin) FL_NOEXCEPT;
template <> fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::FLEXPWM>(int pin) FL_NOEXCEPT;

@coderabbitai coderabbitai Bot Apr 25, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Show every explicit specialization signature in rx.cpp.hpp with surrounding context
rg -nP -C1 'RxDevice::create<RxDeviceType::' --type=cpp --type=h

Repository: FastLED/FastLED

Length of output: 7027


🌐 Web query:

In C++17, is it ill-formed to declare an explicit function template specialization with noexcept and then define it without noexcept (or vice versa)?

💡 Result:

Yes, in C++17 it is ill-formed to declare an explicit function template specialization with a noexcept specifier that differs from the one used in its definition (or vice versa), because all declarations of a function, including explicit specializations and their definitions, must have compatible exception specifications.

Citations:


Add FL_NOEXCEPT to all explicit specialization definitions in rx.cpp.hpp to match declarations.

The forward declarations at lines 433–436 all promise FL_NOEXCEPT, but the corresponding definitions in src/fl/channels/rx.cpp.hpp only apply FL_NOEXCEPT to the stub implementations (lines 155, 161, 167, 173). The FL_IS_ESP32 (88, 98, 108, 115), FL_IS_TEENSY_4X (123, 133, 140, 147), and fallback (181, 188, 195, 202) blocks omit it. In C++17, mismatched exception specifications between declaration and definition are ill-formed, so ESP32, Teensy, and fallback builds will fail to compile once these declarations become visible at the definition site. Since the primary template at line 278 is also FL_NOEXCEPT, adding FL_NOEXCEPT to all definitions restores consistency and will unblock non-stub platforms.

Proposed fix
// For all four specializations in FL_IS_ESP32, FL_IS_TEENSY_4X, and fallback blocks:
template <>
-fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::RMT>(int pin) {
+fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::RMT>(int pin) FL_NOEXCEPT {

Apply to each of the four specialization variants in each platform block.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/channels/rx.h` around lines 428 - 436, The explicit specializations
declared as template <> fl::shared_ptr<RxDevice>
RxDevice::create<RxDeviceType::...>(int pin) FL_NOEXCEPT in rx.h must have
matching exception specifications in their definitions in
src/fl/channels/rx.cpp.hpp; update every definition of RxDevice::create for
RxDeviceType::PLATFORM_DEFAULT, ::RMT, ::ISR, and ::FLEXPWM across the
FL_IS_ESP32, FL_IS_TEENSY_4X, and fallback blocks to append FL_NOEXCEPT so they
match the declarations (and the primary template) exactly.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Flagged for human review. The classifier routed this into the security-flag bucket because of the 'Critical' severity label, so the /address-reviews skill leaves the fix to a maintainer. The point is real: the FL_NOEXCEPT specifiers on the explicit specialization declarations in rx.h must match every definition in rx.cpp.hpp (currently only the FL_IS_STUB block applies FL_NOEXCEPT). This will cause compile failures on ESP32, Teensy 4.x, and the fallback platform until aligned.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧩 Analysis chain

Thanks for confirming, @zackees. Let me pull the exact definition signatures from rx.cpp.hpp to generate a precise fix.


🏁 Script executed:

#!/bin/bash
# Show the full content of rx.cpp.hpp to identify all specialization definitions
fd -t f 'rx.cpp.hpp' --exec cat {}

Length of output: 8112


@zackees — confirmed. The FL_IS_STUB block is already correct; the other three platform blocks all need FL_NOEXCEPT. Here is the complete fix for src/fl/channels/rx.cpp.hpp:

 // ESP32-specific explicit template specializations
 namespace fl {
 
 `#ifdef` FL_IS_ESP32
 
 // RMT device specialization for ESP32
 template <>
-fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::RMT>(int pin) {
+fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::RMT>(int pin) FL_NOEXCEPT {
     auto device = RmtRxChannel::create(pin);
     if (!device) {
         return fl::make_shared<DummyRxDevice>("RMT RX channel creation failed");
     }
     return device;
 }
 
 // ISR device specialization for ESP32
 template <>
-fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::ISR>(int pin) {
+fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::ISR>(int pin) FL_NOEXCEPT {
     auto device = GpioIsrRx::create(pin);
     if (!device) {
         return fl::make_shared<DummyRxDevice>("GPIO ISR RX creation failed");
     }
     return device;
 }
 
 // FLEXPWM not available on ESP32
 template <>
-fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::FLEXPWM>(int pin) {
+fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::FLEXPWM>(int pin) FL_NOEXCEPT {
     (void)pin;
     return fl::make_shared<DummyRxDevice>("FLEXPWM RX not supported on ESP32");
 }
 
 // DEFAULT maps to RMT on ESP32
 template <>
-fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::PLATFORM_DEFAULT>(int pin) {
+fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::PLATFORM_DEFAULT>(int pin) FL_NOEXCEPT {
     return RxDevice::create<RxDeviceType::RMT>(pin);
 }
 
 `#elif` defined(FL_IS_TEENSY_4X)
 
 // FLEXPWM device specialization for Teensy 4.x
 template <>
-fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::FLEXPWM>(int pin) {
+fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::FLEXPWM>(int pin) FL_NOEXCEPT {
     auto device = FlexPwmRxChannel::create(pin);
     if (!device) {
         return fl::make_shared<DummyRxDevice>("FlexPWM RX channel creation failed");
     }
     return device;
 }
 
 // RMT not available on Teensy
 template <>
-fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::RMT>(int pin) {
+fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::RMT>(int pin) FL_NOEXCEPT {
     (void)pin;
     return fl::make_shared<DummyRxDevice>("RMT RX not supported on Teensy");
 }
 
 // ISR not available on Teensy
 template <>
-fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::ISR>(int pin) {
+fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::ISR>(int pin) FL_NOEXCEPT {
     (void)pin;
     return fl::make_shared<DummyRxDevice>("ISR RX not supported on Teensy");
 }
 
 // DEFAULT maps to FLEXPWM on Teensy 4.x
 template <>
-fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::PLATFORM_DEFAULT>(int pin) {
+fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::PLATFORM_DEFAULT>(int pin) FL_NOEXCEPT {
     return RxDevice::create<RxDeviceType::FLEXPWM>(pin);
 }
 
 // ... (FL_IS_STUB block unchanged — already has FL_NOEXCEPT) ...
 
 `#else`
 
 // RMT device specialization (dummy for non-ESP32, non-stub)
 template <>
-fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::RMT>(int pin) {
+fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::RMT>(int pin) FL_NOEXCEPT {
     (void)pin;
     return RxDevice::createDummy();
 }
 
 // ISR device specialization (dummy for non-ESP32, non-stub)
 template <>
-fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::ISR>(int pin) {
+fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::ISR>(int pin) FL_NOEXCEPT {
     (void)pin;
     return RxDevice::createDummy();
 }
 
 // FLEXPWM device specialization (dummy for unsupported platforms)
 template <>
-fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::FLEXPWM>(int pin) {
+fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::FLEXPWM>(int pin) FL_NOEXCEPT {
     (void)pin;
     return RxDevice::createDummy();
 }
 
 // DEFAULT maps to RMT on unsupported platforms (returns dummy)
 template <>
-fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::PLATFORM_DEFAULT>(int pin) {
+fl::shared_ptr<RxDevice> RxDevice::create<RxDeviceType::PLATFORM_DEFAULT>(int pin) FL_NOEXCEPT {
     return RxDevice::create<RxDeviceType::RMT>(pin);
 }
 
 `#endif`

Summary: 12 definitions across 3 platform blocks (FL_IS_ESP32, FL_IS_TEENSY_4X, and #else fallback) need FL_NOEXCEPT appended before {. The FL_IS_STUB block is already correct. Without this fix, including rx.h in the same translation unit as any of these definitions (which is exactly what the unity build does) will produce an ill-formed program under C++17's matching exception-specification rule.


🧠 Learnings used
Learnt from: CR
Repo: FastLED/FastLED PR: 0
File: .cursorrules:0-0
Timestamp: 2026-04-11T06:15:07.646Z
Learning: Applies to **/*.{cpp,c,h,hpp} : DO NOT use try-catch blocks or C++ exception handling - use error codes or fl::optional<T> instead

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Flagging for human reviewer — this is a real correctness issue (the explicit specialization decls in rx.h are FL_NOEXCEPT but the platform-specific defs in rx.cpp.hpp are missing it for ESP32 / Teensy 4.x / fallback blocks, which is ill-formed in C++17 once both are visible). The /address-reviews skill classified this as security-flag (the 'Critical' badge triggered the classifier), so per skill rules I am deferring the auto-fix. The change itself is mechanical: append FL_NOEXCEPT to all four createRxDeviceType::*(int pin) definitions in each platform block of src/fl/channels/rx.cpp.hpp.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@zackees — agreed, this is a real C++17 correctness bug. I'll plan the mechanical fix now.

Task: Add FL_NOEXCEPT to all RxDevice::create<> definitions in src/fl/channels/rx.cpp.hpp

  • Add FL_NOEXCEPT to 4 definitions in the FL_IS_ESP32 block
  • Add FL_NOEXCEPT to 4 definitions in the FL_IS_TEENSY_4X block
  • Add FL_NOEXCEPT to 4 definitions in the #else fallback block
  • Leave the FL_IS_STUB block unchanged (already correct)

🧠 Learnings used
Learnt from: CR
Repo: FastLED/FastLED PR: 0
File: .cursorrules:0-0
Timestamp: 2026-04-11T06:15:07.646Z
Learning: Applies to **/*.{cpp,c,h,hpp} : DO NOT use try-catch blocks or C++ exception handling - use error codes or fl::optional<T> instead

  • 📌 Commit the changes to this branch

Comment thread src/fl/ui/button.h Resolved
Comment thread src/fl/ui/button.h Resolved
Comment thread src/fl/ui/dropdown.cpp.hpp Resolved
Comment thread src/fl/ui/slider.cpp.hpp Resolved
Comment thread src/fl/ui/title.cpp.hpp
Comment on lines +6 to +10
#if FASTLED_USE_JSON_UI
UITitle::UITitle(const char *name) FL_NOEXCEPT : mImpl(fl::string(name), fl::string(name)) {}
#else
UITitle::UITitle(const char *name) FL_NOEXCEPT : mImpl(name) {}
#endif

@coderabbitai coderabbitai Bot Apr 25, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find the UITitleImpl / mImpl ctor signature and the prior monolithic implementation
fd -e h -e hpp -e 'cpp.hpp' title
echo "---"
rg -nP -C3 'class\s+UITitleImpl|struct\s+UITitleImpl' 
echo "---"
# Check git history for the prior fl/ui.cpp.hpp UITitle ctor (if still in tree as deleted)
rg -nP -C3 'UITitle::UITitle'

Repository: FastLED/FastLED

Length of output: 972


🏁 Script executed:

cat -n src/platforms/shared/ui/json/title.h

Repository: FastLED/FastLED

Length of output: 1647


🏁 Script executed:

cat -n src/platforms/shared/ui/json/title.cpp.hpp

Repository: FastLED/FastLED

Length of output: 3551


Two identical fl::string temporaries passed to JsonTitleImpl constructor—verify if intentional.

The mImpl(fl::string(name), fl::string(name)) call creates two separate temporary fl::string objects from the same name input, both forwarded to a constructor expecting distinct name and text parameters. The JSON implementation stores these separately (name as identifier, text for display), making this behavior either unintended or inefficient. If text should default to name, pass a single fl::string(name) once and let the constructor copy internally; if text should differ, provide the appropriate value.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/ui/title.cpp.hpp` around lines 6 - 10, The UITitle constructor
currently constructs two distinct fl::string temporaries in the JSON path
(mImpl(fl::string(name), fl::string(name))) which is likely unintended or
inefficient; update UITitle (the UITitle::UITitle(const char*) initializer) so
it only creates one fl::string for the default text instead of two (e.g.,
construct a single fl::string variable and pass it for both name/text or call
the JsonTitleImpl constructor overload that accepts a single fl::string when
text should default to name), and adjust the call to mImpl (JsonTitleImpl
constructor) accordingly so name and text are provided as intended.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Acknowledged. JsonTitleImpl takes (name, text) by const-ref and stores them in distinct fields (name = identifier, text = display text). For the UITitle(const char*) ctor, defaulting text to name is intentional. The two short-lived fl::string temporaries are a minor allocation overhead at construction time only; refactoring to share a single string would require either guaranteed copy elision (not available pre-C++17 in our example builds) or a new single-arg JsonTitleImpl ctor in the platforms layer. Leaving as-is for now with a clarifying comment.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@zackees, thanks for the detailed explanation! That makes sense — the name (identifier) and text (display) distinction in JsonTitleImpl is the key context that makes the double construction intentional. Adding a clarifying comment there is a good call to document this for future readers.

(̂ ̮ ̂)


🧠 Learnings used
Learnt from: CR
Repo: FastLED/FastLED PR: 0
File: .cursorrules:0-0
Timestamp: 2026-04-11T06:15:07.646Z
Learning: Applies to **/*.{cpp,h,hpp} : Prefer ideal fl::json API for JSON operations instead of legacy fl::parseJson API

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Intentional — JsonTitleImpl takes (name, text) where text defaults to name for the const-char* UITitle ctor; both args are stored separately as fl::string. The two short-lived temporaries are explicitly documented in the inline comment above the ctor in title.cpp.hpp. This is a one-shot ctor cost, not a hot path.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@zackees, understood — the inline comment in title.cpp.hpp now documents the intent clearly. The concern is resolved. Thanks for the thorough explanation!


🧠 Learnings used
Learnt from: CR
Repo: FastLED/FastLED PR: 0
File: .cursorrules:0-0
Timestamp: 2026-04-11T06:15:07.646Z
Learning: Applies to **/*.{cpp,h,hpp} : Prefer ideal fl::json API for JSON operations instead of legacy fl::parseJson API

Comment thread src/fl/ui/title.h
Comment on lines +17 to +24
class UITitleImpl {
public:
UITitleImpl(const char *name) { FASTLED_UNUSED(name); }
~UITitleImpl() FL_NOEXCEPT {}

// Stub method for group setting (does nothing on non-WASM platforms)
void setGroup(const fl::string& groupName) { FASTLED_UNUSED(groupName); }
};

@coderabbitai coderabbitai Bot Apr 25, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Stub UITitleImpl should be FL_NOEXCEPT on its ctor and setGroup.

The destructor is marked FL_NOEXCEPT but the constructor and setGroup are not. UITitle::setGroup (line 35) is declared FL_NOEXCEPT override and calls mImpl.setGroup(groupName); if the non-stub (WASM) UITitleImpl::setGroup ever throws, the noexcept boundary on UITitle::setGroup will trigger std::terminate. Make the stub explicitly noexcept and impose the same contract on the platform impl.

Suggested change
-    UITitleImpl(const char *name) { FASTLED_UNUSED(name); }
+    UITitleImpl(const char *name) FL_NOEXCEPT { FASTLED_UNUSED(name); }
     ~UITitleImpl() FL_NOEXCEPT {}

-    // Stub method for group setting (does nothing on non-WASM platforms)
-    void setGroup(const fl::string& groupName) { FASTLED_UNUSED(groupName); }
+    // Stub method for group setting (does nothing on non-WASM platforms)
+    void setGroup(const fl::string& groupName) FL_NOEXCEPT { FASTLED_UNUSED(groupName); }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/ui/title.h` around lines 17 - 24, The stub class UITitleImpl must
match the noexcept contract of UITitle: mark the constructor UITitleImpl(const
char *name) and the method void setGroup(const fl::string& groupName) as
FL_NOEXCEPT, and update the non-stub (WASM) implementation of
UITitleImpl::setGroup (and its constructor if present) to also be FL_NOEXCEPT so
that UITitle::setGroup (declared FL_NOEXCEPT override) does not cross a throwing
boundary; ensure all declarations and definitions for UITitleImpl::UITitleImpl
and UITitleImpl::setGroup use FL_NOEXCEPT consistently.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in b8e1cab. Stub UITitleImpl ctor and setGroup are now FL_NOEXCEPT to honor the noexcept boundary on UITitle::setGroup.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@zackees, thanks for the fix! Confirmed — marking UITitleImpl(const char *name) and setGroup as FL_NOEXCEPT in commit b8e1cab correctly aligns the stub with the FL_NOEXCEPT contract on UITitle::setGroup, preventing any accidental std::terminate at the noexcept boundary.


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Already addressed in b8e1cab — UITitleImpl ctor and setGroup are both FL_NOEXCEPT in src/fl/ui/title.h.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/fl/ui/audio.h (1)

67-71: Optional: consider const-qualifying read-style queries.

hasNext() and audioInput() look like pure observers and could be const FL_NOEXCEPT (matching the const-correctness pass mentioned in the PR for Button). next() mutates state (consuming a sample), so leave it non-const. This would also let UIAudio be queried through a const reference without losing audio-input access.

If the underlying mImpl methods need to be made const to support this, that's a separate small change in both the WASM impl and the stub on lines 41 and 50.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/ui/audio.h` around lines 67 - 71, hasNext() and audioInput() are
observers and should be const-qualified to enable calling them on const UIAudio
references; change their declarations to "bool hasNext() FL_NOEXCEPT" -> "bool
hasNext() const FL_NOEXCEPT" and "fl::shared_ptr<audio::IInput> audioInput()
FL_NOEXCEPT" -> "fl::shared_ptr<audio::IInput> audioInput() const FL_NOEXCEPT",
and update the corresponding mImpl methods (and their WASM implementation and
the stub for mImpl) to be const as well so mImpl.hasNext() and
mImpl.audioInput() can be called from const methods. Ensure signatures of
audio::IInput-returning and hasNext methods on the impl types match the new
const correctness.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/fl/ui/audio.h`:
- Around line 67-71: hasNext() and audioInput() are observers and should be
const-qualified to enable calling them on const UIAudio references; change their
declarations to "bool hasNext() FL_NOEXCEPT" -> "bool hasNext() const
FL_NOEXCEPT" and "fl::shared_ptr<audio::IInput> audioInput() FL_NOEXCEPT" ->
"fl::shared_ptr<audio::IInput> audioInput() const FL_NOEXCEPT", and update the
corresponding mImpl methods (and their WASM implementation and the stub for
mImpl) to be const as well so mImpl.hasNext() and mImpl.audioInput() can be
called from const methods. Ensure signatures of audio::IInput-returning and
hasNext methods on the impl types match the new const correctness.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d6e6a4f3-d0de-4bea-a6b7-d8d2b3e3f146

📥 Commits

Reviewing files that changed from the base of the PR and between 4523b7f and 89b527e.

📒 Files selected for processing (52)
  • README.md
  • ci/compiler/asset_scanner.py
  • ci/lint_cpp/test_unity_build.py
  • ci/tests/test_asset_scanner.py
  • examples/Audio/simple/fx_audio.h
  • examples/Audio/simple/simple.h
  • examples/AudioUrl/AudioUrl.ino
  • examples/Downscale/Downscale.h
  • examples/Fx/FxWave2d/wavefx.cpp
  • examples/XYPath/complex.h
  • examples/XYPath/direct.h
  • examples/XYPath/simple.h
  • src/FastLED.cpp.hpp
  • src/fl/_build.cpp.hpp
  • src/fl/asset/_build.cpp.hpp
  • src/fl/asset/asset.cpp.hpp
  • src/fl/asset/asset.h
  • src/fl/build/fl.asset+.cpp
  • src/fl/build/fl.cpp
  • src/fl/build/fl.test+.cpp
  • src/fl/channels/channel.cpp.hpp
  • src/fl/channels/manager.cpp.hpp
  • src/fl/chipsets/clockless_controller_impl.h
  • src/fl/math/_build.cpp.hpp
  • src/fl/math/time_alpha.cpp.hpp
  • src/fl/math/time_alpha.h
  • src/fl/sensors/pir.h
  • src/fl/system/_build.cpp.hpp
  • src/fl/system/timeout.h
  • src/fl/system/trace.cpp.hpp
  • src/fl/system/trace.h
  • src/fl/task/task.h
  • src/fl/test/_build.cpp.hpp
  • src/fl/test/fltest.cpp.hpp
  • src/fl/test/fltest.h
  • src/fl/ui/_build.cpp.hpp
  • src/fl/ui/audio.h
  • src/fl/ui/string.cpp.hpp
  • src/platforms/clockless.h
  • src/platforms/esp/32/drivers/parlio/channel_driver_parlio.cpp.hpp
  • src/platforms/esp/32/drivers/rmt/rmt_5/channel_driver_rmt.cpp.hpp
  • src/platforms/esp/32/drivers/uart/channel_driver_uart.cpp.hpp
  • src/platforms/shared/clockless_blocking.h
  • tests/fl/asset/asset.cpp
  • tests/fl/channels/channel.cpp
  • tests/fl/math/time_alpha.hpp
  • tests/fl/math/xymap.cpp
  • tests/fl/system/log.cpp
  • tests/fl/system/pin.cpp
  • tests/fl/system/timeout.cpp
  • tests/fl/system/trace.hpp
  • tests/fl/test/fltest.cpp
💤 Files with no reviewable changes (1)
  • src/fl/build/fl.cpp
✅ Files skipped from review due to trivial changes (41)
  • examples/XYPath/direct.h
  • src/fl/math/_build.cpp.hpp
  • src/fl/test/_build.cpp.hpp
  • examples/AudioUrl/AudioUrl.ino
  • tests/fl/channels/channel.cpp
  • src/fl/system/_build.cpp.hpp
  • src/fl/asset/asset.cpp.hpp
  • examples/XYPath/simple.h
  • tests/fl/math/time_alpha.hpp
  • src/platforms/esp/32/drivers/uart/channel_driver_uart.cpp.hpp
  • examples/Audio/simple/simple.h
  • examples/Downscale/Downscale.h
  • src/fl/channels/channel.cpp.hpp
  • src/platforms/esp/32/drivers/rmt/rmt_5/channel_driver_rmt.cpp.hpp
  • src/fl/asset/_build.cpp.hpp
  • src/platforms/esp/32/drivers/parlio/channel_driver_parlio.cpp.hpp
  • src/fl/build/fl.test+.cpp
  • examples/Fx/FxWave2d/wavefx.cpp
  • src/fl/task/task.h
  • ci/tests/test_asset_scanner.py
  • examples/Audio/simple/fx_audio.h
  • src/fl/asset/asset.h
  • src/platforms/shared/clockless_blocking.h
  • tests/fl/system/pin.cpp
  • src/fl/math/time_alpha.cpp.hpp
  • tests/fl/math/xymap.cpp
  • src/fl/sensors/pir.h
  • src/fl/test/fltest.cpp.hpp
  • src/fl/build/fl.asset+.cpp
  • src/fl/ui/_build.cpp.hpp
  • examples/XYPath/complex.h
  • README.md
  • tests/fl/system/timeout.cpp
  • tests/fl/asset/asset.cpp
  • src/fl/test/fltest.h
  • tests/fl/system/log.cpp
  • src/fl/system/trace.cpp.hpp
  • src/fl/channels/manager.cpp.hpp
  • tests/fl/system/trace.hpp
  • src/FastLED.cpp.hpp
  • tests/fl/test/fltest.cpp
🚧 Files skipped from review as they are similar to previous changes (2)
  • ci/lint_cpp/test_unity_build.py
  • src/fl/_build.cpp.hpp

@zackees
zackees force-pushed the refactor/fl-ui-folder branch 2 times, most recently from 9a96f58 to b8e1cab Compare April 25, 2026 15:16

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (5)
src/fl/ui/slider.cpp.hpp (2)

30-42: Minor style inconsistency: prefer owner over *mOwner on line 39.

Line 31 binds UISlider &owner = *mOwner; and the rest of the function uses owner.…, except line 39 which dereferences mOwner again. Using owner here keeps the function consistent and slightly more readable.

Suggested tweak
-        owner.mCallbacks.invoke(*mOwner);
+        owner.mCallbacks.invoke(owner);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/ui/slider.cpp.hpp` around lines 30 - 42, In
UISlider::Listener::onBeginFrame, there's an inconsistent dereference: replace
the direct use of *mOwner in the owner.mCallbacks.invoke call with the
already-bound reference 'owner' (i.e., call owner.mCallbacks.invoke(...) instead
of dereferencing mOwner); this keeps usage consistent with the earlier binding
(UISlider &owner = *mOwner) and improves readability while referencing the
existing mOwner, owner, and owner.mCallbacks.invoke symbols.

5-6: Consider tightening the warning-suppression scope.

FL_DISABLE_WARNING(float-equal) is pushed at file scope and popped only at the very end, so it also covers code that doesn't perform float-equality comparisons (e.g., the constructor on lines 10–13). The float-equal warnings only need suppression around lines 22 and 38. Narrowing the push/pop pairs around just those comparisons would avoid masking accidental future float-equal comparisons elsewhere in this TU.

Also applies to: 46-46

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/ui/slider.cpp.hpp` around lines 5 - 6, The file currently pushes
FL_DISABLE_WARNING(float-equal) at file scope; narrow its scope by removing the
file-level FL_DISABLE_WARNING_PUSH/FL_DISABLE_WARNING(float-equal) and instead
wrap only the exact float-equality comparison sites with push/pop pairs: insert
FL_DISABLE_WARNING_PUSH then FL_DISABLE_WARNING(float-equal) immediately before
each problematic comparison expression and FL_DISABLE_WARNING_POP immediately
after (the comparisons flagged around the slider equality checks in this TU—the
float-equal comparisons near the two comparison locations and the additional one
noted at 46—46). This keeps the constructor and other code outside the
suppressed region while preserving suppression only around the specific
float-equal comparisons.
src/fl/ui/button.h (2)

139-151: Member naming inconsistency: added should be mAdded.

Within the same struct, mOwner, mClickedLastFrame, and mPressedLastFrame follow the mVariableName convention while added does not. As per coding guidelines, "Use mVariableName format for member variables in complex classes" — Listener carries owner pointers, lifecycle state, and frame-tracking state, so it's a complex member, not a "simple struct".

♻️ Proposed rename
         ~Listener() FL_NOEXCEPT {
-            if (added) {
+            if (mAdded) {
                 EngineEvents::removeListener(this);
             }
         }
         void addToEngineEventsOnce() FL_NOEXCEPT {
-            if (added) {
+            if (mAdded) {
                 return;
             }
             EngineEvents::addListener(this);
-            added = true;
+            mAdded = true;
         }
         void onBeginFrame() FL_NOEXCEPT override;

       private:
         UIButton *mOwner;
-        bool added = false;
+        bool mAdded = false;
         bool mClickedLastFrame = false;
         bool mPressedLastFrame = false;
     };
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/ui/button.h` around lines 139 - 151, Rename the Listener struct member
"added" to "mAdded" to follow the mVariableName convention used by other members
(mOwner, mClickedLastFrame, mPressedLastFrame); update all references to
Listener::added to Listener::mAdded, and adjust any constructors, initializers,
assignments, and uses in methods that touch the Listener instance so compilation
and behavior remain unchanged.

20-36: Optional: mark UIButtonImpl stub methods FL_NOEXCEPT for consistency.

The stub's constructor and methods aren't marked FL_NOEXCEPT, but UIButton's wrapping methods (isPressed, clicked, clickedCount, click, setGroup, ctor) are. If FL_NOEXCEPT resolves to noexcept, those wrappers will silently terminate on any unexpected throw from mImpl. The stubs are trivially non-throwing, so adding FL_NOEXCEPT would make the contract explicit and align the two layers.

♻️ Proposed annotation
-    UIButtonImpl(const char *name) : mName(name ? name : "") {}
+    UIButtonImpl(const char *name) FL_NOEXCEPT : mName(name ? name : "") {}
     ~UIButtonImpl() FL_NOEXCEPT {}
-    bool isPressed() const { return false; }
-    bool clicked() const { return false; }
-    int clickedCount() const { return 0; }
-    operator bool() const { return false; }
-    void click() {}
-    fl::string name() const { return mName; }
-
-    // Stub method for group setting (does nothing on non-WASM platforms)
-    void setGroup(const fl::string& groupName) { FASTLED_UNUSED(groupName); }
+    bool isPressed() const FL_NOEXCEPT { return false; }
+    bool clicked() const FL_NOEXCEPT { return false; }
+    int clickedCount() const FL_NOEXCEPT { return 0; }
+    operator bool() const FL_NOEXCEPT { return false; }
+    void click() FL_NOEXCEPT {}
+    fl::string name() const FL_NOEXCEPT { return mName; }
+
+    // Stub method for group setting (does nothing on non-WASM platforms)
+    void setGroup(const fl::string& groupName) FL_NOEXCEPT { FASTLED_UNUSED(groupName); }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/ui/button.h` around lines 20 - 36, The UIButtonImpl stub methods
should be marked FL_NOEXCEPT to match the noexcept contract of the outer
UIButton wrappers: update the constructor UIButtonImpl(const char *name), the
isPressed(), clicked(), clickedCount(), operator bool(), click(), name() and
setGroup(const fl::string&) declarations to include FL_NOEXCEPT (the destructor
already has it), ensuring the implementation remains trivial and non-throwing
while keeping the exception-safety contract consistent with the wrapper methods.
src/fl/sensors/ui_button_integration.cpp.hpp (1)

11-15: Signature change correctly aligns with mButtonInput member type.

The new fl::shared_ptr<IButtonInput> parameter matches the storage type and decouples the API from concrete Button. Optional micro-optimization: since button is a local by-value parameter, you can move it into the member to skip an atomic refcount bump.

♻️ Optional move-into-member
-void UIButton::addRealButton(fl::shared_ptr<IButtonInput> button) {
+void UIButton::addRealButton(fl::shared_ptr<IButtonInput> button) {
     // Stored directly; no concrete-type dependency. Caller may pass any
     // IButtonInput implementation (Button, mock, etc.).
-    mButtonInput = button;
+    mButtonInput = fl::move(button);
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/sensors/ui_button_integration.cpp.hpp` around lines 11 - 15, The
parameter type change is good; to avoid an extra atomic refcount bump, move the
by-value fl::shared_ptr<IButtonInput> into the member instead of copying it: in
UIButton::addRealButton take the existing local parameter `button` and assign it
into `mButtonInput` via move (e.g., use std::move/button-to-member move) so the
stored `mButtonInput` reuses the passed-in ownership without an extra refcount
increment.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/fl/ui/button.h`:
- Around line 45-65: The clickedCount() implementation is inconsistent with
isPressed()/clicked() because it returns only mImpl.clickedCount() and ignores
any real physical source in mButtonInput; update the code by adding a clear
comment above the clickedCount() method (and mention operator bool()/value()
behavior) stating that clickedCount() reports only the internal UIButtonImpl
counter and does not include clicks from IButtonInput added via
addRealButton(...), and note the recommended fix option (implement an
edge-detection counter by observing mButtonInput->clicked() transitions in
Listener::onBeginFrame() and incrementing a local counter, or accept the
documented caveat). Ensure the comment references mImpl, mButtonInput,
clickedCount(), Listener::onBeginFrame(), and addRealButton so callers and
future maintainers can find and address the asymmetry.
- Around line 84-111: The onClicked() API registers its wrapper into mCallbacks
(the same list used by onChanged()) but there is no removeClickedCallback,
forcing callers to use removeChangedCallback(id) implicitly; add a thin alias
method removeClickedCallback(int id) that forwards to
removeChangedCallback/remove(mCallbacks) and update the nearby comment to
mention that onClicked IDs map to removeClickedCallback (which delegates to
mCallbacks) so callers can use a matching-named remover; reference the
onClicked, mCallbacks, removeChangedCallback and
removePressedCallback/removeReleasedCallback symbols when making the change.
- Around line 146-151: The class has a destruction-order hazard: mButtonInput is
declared after mListener so mButtonInput is destroyed first while Listener
(whose destructor unregisters from EngineEvents) remains registered and may call
Listener::onBeginFrame() which dereferences mOwner and accesses mButtonInput
(via UIButton::isPressed()/clicked()) during shutdown; fix this by moving the
member declaration of mListener to the end of the private member list so
Listener is destroyed (and unregisters) before mButtonInput and other resources
are torn down, ensuring Listener::~Listener() runs first and preventing
onBeginFrame() from observing a half-destroyed UIButton.

---

Nitpick comments:
In `@src/fl/sensors/ui_button_integration.cpp.hpp`:
- Around line 11-15: The parameter type change is good; to avoid an extra atomic
refcount bump, move the by-value fl::shared_ptr<IButtonInput> into the member
instead of copying it: in UIButton::addRealButton take the existing local
parameter `button` and assign it into `mButtonInput` via move (e.g., use
std::move/button-to-member move) so the stored `mButtonInput` reuses the
passed-in ownership without an extra refcount increment.

In `@src/fl/ui/button.h`:
- Around line 139-151: Rename the Listener struct member "added" to "mAdded" to
follow the mVariableName convention used by other members (mOwner,
mClickedLastFrame, mPressedLastFrame); update all references to Listener::added
to Listener::mAdded, and adjust any constructors, initializers, assignments, and
uses in methods that touch the Listener instance so compilation and behavior
remain unchanged.
- Around line 20-36: The UIButtonImpl stub methods should be marked FL_NOEXCEPT
to match the noexcept contract of the outer UIButton wrappers: update the
constructor UIButtonImpl(const char *name), the isPressed(), clicked(),
clickedCount(), operator bool(), click(), name() and setGroup(const fl::string&)
declarations to include FL_NOEXCEPT (the destructor already has it), ensuring
the implementation remains trivial and non-throwing while keeping the
exception-safety contract consistent with the wrapper methods.

In `@src/fl/ui/slider.cpp.hpp`:
- Around line 30-42: In UISlider::Listener::onBeginFrame, there's an
inconsistent dereference: replace the direct use of *mOwner in the
owner.mCallbacks.invoke call with the already-bound reference 'owner' (i.e.,
call owner.mCallbacks.invoke(...) instead of dereferencing mOwner); this keeps
usage consistent with the earlier binding (UISlider &owner = *mOwner) and
improves readability while referencing the existing mOwner, owner, and
owner.mCallbacks.invoke symbols.
- Around line 5-6: The file currently pushes FL_DISABLE_WARNING(float-equal) at
file scope; narrow its scope by removing the file-level
FL_DISABLE_WARNING_PUSH/FL_DISABLE_WARNING(float-equal) and instead wrap only
the exact float-equality comparison sites with push/pop pairs: insert
FL_DISABLE_WARNING_PUSH then FL_DISABLE_WARNING(float-equal) immediately before
each problematic comparison expression and FL_DISABLE_WARNING_POP immediately
after (the comparisons flagged around the slider equality checks in this TU—the
float-equal comparisons near the two comparison locations and the additional one
noted at 46—46). This keeps the constructor and other code outside the
suppressed region while preserving suppression only around the specific
float-equal comparisons.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f6cfea79-3868-47d7-9db2-37810f69ec6b

📥 Commits

Reviewing files that changed from the base of the PR and between 89b527e and b8e1cab.

📒 Files selected for processing (6)
  • src/fl/sensors/ui_button_integration.cpp.hpp
  • src/fl/ui/button.h
  • src/fl/ui/dropdown.cpp.hpp
  • src/fl/ui/slider.cpp.hpp
  • src/fl/ui/title.cpp.hpp
  • src/fl/ui/title.h
✅ Files skipped from review due to trivial changes (1)
  • src/fl/ui/dropdown.cpp.hpp
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/fl/ui/title.cpp.hpp
  • src/fl/ui/title.h

Comment thread src/fl/ui/button.h
Comment on lines +45 to +65
bool isPressed() const FL_NOEXCEPT {
if (mImpl.isPressed()) {
return true;
}
if (mButtonInput) {
return mButtonInput->isPressed();
}
return false;
}
bool clicked() const FL_NOEXCEPT {
if (mImpl.clicked()) {
return true;
}
if (mButtonInput) {
return mButtonInput->clicked();
}
return false;
}
int clickedCount() const FL_NOEXCEPT { return mImpl.clickedCount(); }
operator bool() const FL_NOEXCEPT { return clicked(); }
bool value() const FL_NOEXCEPT { return clicked(); }

@coderabbitai coderabbitai Bot Apr 25, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Inconsistent override of physical-button input in clickedCount() / value().

isPressed() and clicked() consult mButtonInput as a fallback when mImpl returns false, but clickedCount() only reads from mImpl. As a result, when only a real IButtonInput is wired (e.g. on non-WASM where UIButtonImpl is the no-op stub), clicked() returns true on a press but clickedCount() stays at 0 forever. operator bool() and value() go through clicked(), so they're fine — only the count is asymmetric.

IButtonInput (per src/fl/ui/element.h:16-21) doesn't expose a count, so a full fix likely needs either:

  • a derived edge-detection counter inside UIButton (track mButtonInput->clicked() transitions in the existing Listener::onBeginFrame() and bump a local count), or
  • a documented caveat that clickedCount() ignores addRealButton(...) sources.

At minimum, please add a comment so callers don't get silently inconsistent semantics.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/ui/button.h` around lines 45 - 65, The clickedCount() implementation
is inconsistent with isPressed()/clicked() because it returns only
mImpl.clickedCount() and ignores any real physical source in mButtonInput;
update the code by adding a clear comment above the clickedCount() method (and
mention operator bool()/value() behavior) stating that clickedCount() reports
only the internal UIButtonImpl counter and does not include clicks from
IButtonInput added via addRealButton(...), and note the recommended fix option
(implement an edge-detection counter by observing mButtonInput->clicked()
transitions in Listener::onBeginFrame() and incrementing a local counter, or
accept the documented caveat). Ensure the comment references mImpl,
mButtonInput, clickedCount(), Listener::onBeginFrame(), and addRealButton so
callers and future maintainers can find and address the asymmetry.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Flagging for human reviewer — the address-reviews classifier flagged this as security (substring match on 'rce' inside innocent words in the body), but the actual finding is a Minor correctness asymmetry: clickedCount() reads only from mImpl while clicked()/isPressed() also fall back to mButtonInput. Suggest a follow-up that either documents the caveat or threads an edge-detected counter through Listener::onBeginFrame().

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@zackees, thanks for the clarification! The classifier false-positive aside, the correctness asymmetry is real and well-described. To summarize for the human reviewer:

  • isPressed() and clicked() correctly consult mButtonInput as a fallback when mImpl returns false.
  • clickedCount() silently ignores mButtonInput entirely — so if only a real IButtonInput is wired (e.g. on non-WASM where UIButtonImpl is a no-op stub), clicked() returns true but clickedCount() stays at 0 forever.

The two paths to fix it remain:

  1. Edge-detection counter — inside the existing Listener::onBeginFrame(), track transitions of mOwner->mButtonInput->clicked() and increment a local mRealButtonClickCount; expose that sum from clickedCount().
  2. Documented caveat — add a comment above clickedCount() stating it only reflects the internal UIButtonImpl counter and ignores sources added via addRealButton().

Would you like me to open a follow-up GitHub issue to track this so it doesn't get lost?

Comment thread src/fl/ui/button.h Resolved
Comment thread src/fl/ui/button.h
Comment on lines +146 to +151
private:
function_list<void(UIButton &)> mCallbacks;
function_list<void()> mPressCallbacks;
function_list<void()> mReleaseCallbacks;
Listener mListener;
fl::shared_ptr<IButtonInput> mButtonInput;

@coderabbitai coderabbitai Bot Apr 25, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Declare mListener last to fix destruction-order hazard.

Members are destroyed in reverse declaration order, so currently mButtonInput is destroyed first, then mListener. Listener::~Listener() is what unregisters from EngineEvents, meaning between mButtonInput's destruction and mListener's destruction the listener is still live and onBeginFrame() (which dereferences mOwner and reaches mButtonInput / callback lists via isPressed() / clicked()) can observe a half-destroyed UIButton. Move mListener to the very end of the member list so it deregisters first.

♻️ Proposed reorder
   private:
     function_list<void(UIButton &)> mCallbacks;
     function_list<void()> mPressCallbacks;
     function_list<void()> mReleaseCallbacks;
-    Listener mListener;
     fl::shared_ptr<IButtonInput> mButtonInput;
+    Listener mListener;  // Declared last so it is destroyed first and
+                         // removes itself from EngineEvents before any
+                         // dependent state is torn down.
 };
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/ui/button.h` around lines 146 - 151, The class has a destruction-order
hazard: mButtonInput is declared after mListener so mButtonInput is destroyed
first while Listener (whose destructor unregisters from EngineEvents) remains
registered and may call Listener::onBeginFrame() which dereferences mOwner and
accesses mButtonInput (via UIButton::isPressed()/clicked()) during shutdown; fix
this by moving the member declaration of mListener to the end of the private
member list so Listener is destroyed (and unregisters) before mButtonInput and
other resources are torn down, ensuring Listener::~Listener() runs first and
preventing onBeginFrame() from observing a half-destroyed UIButton.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Flagging for human reviewer — the address-reviews classifier flagged this as security (substring match on 'rce' in the body), but the actual finding is a real Minor destruction-order hazard: mListener should be declared last so its dtor unregisters from EngineEvents before mButtonInput is destroyed. The fix is a one-line member reorder in src/fl/ui/button.h. Deferring auto-fix per skill rules.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@zackees, thanks for the confirmation. The finding stands: with the current declaration order, mButtonInput is destroyed before mListener, leaving Listener::onBeginFrame() potentially live with a dangling reference to mButtonInput (accessed via UIButton::isPressed()/clicked()).

The minimal fix remains a one-line member swap in the private: block of src/fl/ui/button.h:

  private:
    function_list<void(UIButton &)> mCallbacks;
    function_list<void()> mPressCallbacks;
    function_list<void()> mReleaseCallbacks;
    fl::shared_ptr<IButtonInput> mButtonInput;
    Listener mListener;  // Declared last → destroyed first → unregisters from
                         // EngineEvents before mButtonInput and callback lists
                         // are torn down.

Would you like me to open a follow-up GitHub issue to track this fix, or would you prefer to address it directly in this PR?

zackees and others added 6 commits April 28, 2026 11:53
Relocates fl/timeout.h to fl/system/timeout.h alongside its
sibling system-level timing utilities (delay.h, yield.h).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Relocates fl/trace.{h,cpp.hpp} to fl/system/ alongside log.{h,cpp.hpp}
as siblings of the debug/observability subsystem. Updates unity-build
aggregators and all consumers.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…tr_ui

Three independent file moves into existing module subfolders, batched into
one commit since they're trivial and share the same mechanical sweep:

  - fl/time_alpha.{h,cpp.hpp}        -> fl/math/   (alongside math.h, ease.h)
  - fl/clockless_controller_impl.h   -> fl/chipsets/   (alongside other clockless types)
  - fl/str_ui.cpp.hpp                -> fl/ui/string.cpp.hpp   (UI-side bridge into fl::string)

Plus the matching test relocation per TestPathStructureChecker:
  - tests/fl/time_alpha.hpp -> tests/fl/math/time_alpha.hpp

Updates unity-build aggregators (src/fl/_build.cpp.hpp, src/fl/build/fl.cpp),
adds entries to the destination module's _build.cpp.hpp, and sweeps all
includes across src/, tests/, examples/, and README.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The v1 asset pipeline (FL_ASSET, fl::asset_detail, manifest resolution
for WASM/host) is a self-contained subsystem and now gets its own
module slot at fl/asset/.

- Moves fl/asset.h + fl/asset.cpp.hpp -> fl/asset/
- Adds fl/asset/_build.cpp.hpp (module unity-build aggregator)
- Adds src/fl/build/fl.asset+.cpp (per-module recursive aggregator)
- Removes flat asset includes from src/fl/_build.cpp.hpp and
  src/fl/build/fl.cpp; replaces with sub-directory aggregator pull
- Sweeps consumer includes from "fl/asset.h" to "fl/asset/asset.h"

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The portable test framework (FL_CHECK, FL_REQUIRE, FL_SUBCASE,
FL_TEST_CASE, FL_TEST_FILE) is a self-contained subsystem and now
gets its own module slot at fl/test/.

- Moves fl/fltest.{h,cpp.hpp} -> fl/test/
- Adds fl/test/_build.cpp.hpp (module unity-build aggregator)
- Adds src/fl/build/fl.test+.cpp (per-module recursive aggregator)
- Removes flat fltest includes from src/fl/_build.cpp.hpp and
  src/fl/build/fl.cpp; replaces with sub-directory aggregator pull
- Registers fl/build/fl.test+.cpp in EXPECTED_BUILD_FILES (lint check)
- Sweeps the small set of direct fl/fltest.h consumers (3 tests +
  internal self-include); most tests use tests/shared/fl_unittest.h
  which transitively includes fltest.h
- Relocates the framework's own test (tests/fl/fltest.cpp) under
  tests/fl/test/ to match TestPathStructureChecker

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
- button.h: addRealButton now accepts shared_ptr<IButtonInput>
  to match the member type and decouple the API from the concrete Button class
- button.h: split removeCallback into removeChangedCallback,
  removePressedCallback, removeReleasedCallback so per-list IDs no longer collide
- title.h: stub UITitleImpl ctor and setGroup are now FL_NOEXCEPT
  to honor the noexcept boundary on UITitle::setGroup
- dropdown.cpp.hpp: seed mLastFrameValue baseline before applying first-frame
  nextOption() so the change callback fires on the very first frame
- slider.cpp.hpp: setValue compares post-clamp value against oldValue to avoid
  spurious callbacks when an out-of-range value is clamped to the current value

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees force-pushed the refactor/fl-ui-folder branch from b8e1cab to 5f365ff Compare April 28, 2026 15:53
- Adds a thin alias that delegates to mCallbacks.remove(id) so callers
  using onClicked() can pair their registration with a same-named
  remover instead of having to know it shares the changed-callbacks
  list internally.
- Updates the per-list-remover comment to call out the onClicked()
  mapping explicitly.

Addresses CodeRabbit review feedback on PR #2414.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/fl/sensors/ui_button_integration.cpp.hpp`:
- Line 11: The out-of-class definition of UIButton::addRealButton must match the
exception specification on its declaration; update the function signature in
src/fl/sensors/ui_button_integration.cpp.hpp for UIButton::addRealButton to
include the same FL_NOEXCEPT qualifier as declared in src/fl/ui/button.h so the
declaration and definition match exactly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 499ebbc5-e060-4732-b1c7-5485bcc2f6fb

📥 Commits

Reviewing files that changed from the base of the PR and between b8e1cab and 5f365ff.

📒 Files selected for processing (58)
  • README.md
  • ci/compiler/asset_scanner.py
  • ci/lint_cpp/test_unity_build.py
  • ci/tests/test_asset_scanner.py
  • examples/Audio/simple/fx_audio.h
  • examples/Audio/simple/simple.h
  • examples/AudioUrl/AudioUrl.ino
  • examples/Downscale/Downscale.h
  • examples/Fx/FxWave2d/wavefx.cpp
  • examples/XYPath/complex.h
  • examples/XYPath/direct.h
  • examples/XYPath/simple.h
  • src/FastLED.cpp.hpp
  • src/fl/_build.cpp.hpp
  • src/fl/asset/_build.cpp.hpp
  • src/fl/asset/asset.cpp.hpp
  • src/fl/asset/asset.h
  • src/fl/build/fl.asset+.cpp
  • src/fl/build/fl.cpp
  • src/fl/build/fl.test+.cpp
  • src/fl/channels/channel.cpp.hpp
  • src/fl/channels/manager.cpp.hpp
  • src/fl/chipsets/clockless_controller_impl.h
  • src/fl/math/_build.cpp.hpp
  • src/fl/math/time_alpha.cpp.hpp
  • src/fl/math/time_alpha.h
  • src/fl/sensors/pir.h
  • src/fl/sensors/ui_button_integration.cpp.hpp
  • src/fl/system/_build.cpp.hpp
  • src/fl/system/timeout.h
  • src/fl/system/trace.cpp.hpp
  • src/fl/system/trace.h
  • src/fl/task/task.h
  • src/fl/test/_build.cpp.hpp
  • src/fl/test/fltest.cpp.hpp
  • src/fl/test/fltest.h
  • src/fl/ui/_build.cpp.hpp
  • src/fl/ui/audio.h
  • src/fl/ui/button.h
  • src/fl/ui/dropdown.cpp.hpp
  • src/fl/ui/slider.cpp.hpp
  • src/fl/ui/string.cpp.hpp
  • src/fl/ui/title.cpp.hpp
  • src/fl/ui/title.h
  • src/platforms/clockless.h
  • src/platforms/esp/32/drivers/parlio/channel_driver_parlio.cpp.hpp
  • src/platforms/esp/32/drivers/rmt/rmt_5/channel_driver_rmt.cpp.hpp
  • src/platforms/esp/32/drivers/uart/channel_driver_uart.cpp.hpp
  • src/platforms/shared/clockless_blocking.h
  • tests/fl/asset/asset.cpp
  • tests/fl/channels/channel.cpp
  • tests/fl/math/time_alpha.hpp
  • tests/fl/math/xymap.cpp
  • tests/fl/system/log.cpp
  • tests/fl/system/pin.cpp
  • tests/fl/system/timeout.cpp
  • tests/fl/system/trace.hpp
  • tests/fl/test/fltest.cpp
💤 Files with no reviewable changes (1)
  • src/fl/build/fl.cpp
✅ Files skipped from review due to trivial changes (44)
  • src/fl/math/time_alpha.cpp.hpp
  • src/platforms/esp/32/drivers/rmt/rmt_5/channel_driver_rmt.cpp.hpp
  • src/fl/system/trace.cpp.hpp
  • src/FastLED.cpp.hpp
  • src/platforms/esp/32/drivers/uart/channel_driver_uart.cpp.hpp
  • src/fl/asset/asset.cpp.hpp
  • src/fl/math/_build.cpp.hpp
  • src/fl/channels/channel.cpp.hpp
  • examples/Audio/simple/simple.h
  • src/fl/test/fltest.cpp.hpp
  • src/fl/channels/manager.cpp.hpp
  • examples/XYPath/direct.h
  • examples/Downscale/Downscale.h
  • tests/fl/system/log.cpp
  • src/platforms/shared/clockless_blocking.h
  • tests/fl/math/xymap.cpp
  • src/fl/sensors/pir.h
  • examples/XYPath/complex.h
  • ci/tests/test_asset_scanner.py
  • tests/fl/math/time_alpha.hpp
  • src/platforms/esp/32/drivers/parlio/channel_driver_parlio.cpp.hpp
  • src/fl/system/_build.cpp.hpp
  • ci/compiler/asset_scanner.py
  • examples/Fx/FxWave2d/wavefx.cpp
  • tests/fl/asset/asset.cpp
  • examples/Audio/simple/fx_audio.h
  • tests/fl/system/trace.hpp
  • examples/AudioUrl/AudioUrl.ino
  • src/fl/ui/audio.h
  • tests/fl/system/pin.cpp
  • src/fl/asset/_build.cpp.hpp
  • src/fl/build/fl.test+.cpp
  • ci/lint_cpp/test_unity_build.py
  • src/fl/asset/asset.h
  • tests/fl/test/fltest.cpp
  • README.md
  • src/fl/build/fl.asset+.cpp
  • tests/fl/system/timeout.cpp
  • tests/fl/channels/channel.cpp
  • examples/XYPath/simple.h
  • src/fl/ui/title.h
  • src/fl/test/_build.cpp.hpp
  • src/fl/test/fltest.h
  • src/fl/task/task.h
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/fl/ui/_build.cpp.hpp
  • src/platforms/clockless.h
  • src/fl/ui/title.cpp.hpp
  • src/fl/_build.cpp.hpp

void UIButton::addRealButton(fl::shared_ptr<Button> button) {
// Button inherits IButtonInput; shared_ptr implicit upcast captures the
// concrete deleter so fl.cpp never needs Button's destructor.
void UIButton::addRealButton(fl::shared_ptr<IButtonInput> button) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify declaration vs definition exception spec for UIButton::addRealButton.
rg -nP '\baddRealButton\s*\(.*IButtonInput.*\)' src/fl/ui/button.h src/fl/sensors/ui_button_integration.cpp.hpp
rg -nP '\baddRealButton\s*\(.*IButtonInput.*\)\s*FL_NOEXCEPT' src/fl/ui/button.h src/fl/sensors/ui_button_integration.cpp.hpp
# Expected:
# - First command finds both declaration and definition.
# - Second command should find both; currently it likely finds only the declaration.

Repository: FastLED/FastLED

Length of output: 365


Match declaration exception spec in the out-of-class definition.

addRealButton is declared FL_NOEXCEPT in src/fl/ui/button.h (Line 67), but this definition at Line 11 omits it. Declaration/definition exception-spec mismatch is a C++ correctness error.

Proposed fix
-void UIButton::addRealButton(fl::shared_ptr<IButtonInput> button) {
+void UIButton::addRealButton(fl::shared_ptr<IButtonInput> button) FL_NOEXCEPT {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
void UIButton::addRealButton(fl::shared_ptr<IButtonInput> button) {
void UIButton::addRealButton(fl::shared_ptr<IButtonInput> button) FL_NOEXCEPT {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fl/sensors/ui_button_integration.cpp.hpp` at line 11, The out-of-class
definition of UIButton::addRealButton must match the exception specification on
its declaration; update the function signature in
src/fl/sensors/ui_button_integration.cpp.hpp for UIButton::addRealButton to
include the same FL_NOEXCEPT qualifier as declared in src/fl/ui/button.h so the
declaration and definition match exactly.

@zackees
zackees merged commit bbc7d7b into master Apr 28, 2026
30 of 31 checks passed
zackees added a commit that referenced this pull request Apr 28, 2026
- rx.cpp.hpp: append FL_NOEXCEPT to all 12 RxDevice::create<> definitions
  in the FL_IS_ESP32, FL_IS_TEENSY_4X, and #else fallback blocks so the
  out-of-class definitions match the FL_NOEXCEPT-qualified declarations
  in rx.h. Stub block was already correct.

- button.h / button.cpp.hpp:
  - clickedCount() now also counts real-button rising edges via the
    Listener, so platforms where UIButtonImpl::clickedCount() is a
    no-op stub still report clicks from IButtonInput sources added
    through addRealButton().
  - Move mListener to the last private member so it is destroyed first
    and unregisters from EngineEvents before mButtonInput / callback
    lists are torn down (fixes destruction-order hazard in
    Listener::onBeginFrame()).

- ui_button_integration.cpp.hpp: append FL_NOEXCEPT to the
  UIButton::addRealButton and UIDropdown::addNextButton out-of-class
  definitions to match their declarations.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees deleted the refactor/fl-ui-folder branch August 21, 2026 19:16
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