Skip to content

refactor(ui): inline ImGuiLayer callback type aliases#144

Merged
K1ngst0m merged 1 commit intomainfrom
dev/refactor-imgui
Mar 25, 2026
Merged

refactor(ui): inline ImGuiLayer callback type aliases#144
K1ngst0m merged 1 commit intomainfrom
dev/refactor-imgui

Conversation

@K1ngst0m
Copy link
Copy Markdown
Collaborator

@K1ngst0m K1ngst0m commented Mar 25, 2026

Summary by CodeRabbit

  • Refactor
    • Improved internal callback API architecture by standardizing implementation patterns and removing intermediate type definitions.
    • Updated filter chain component integration.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 25, 2026

📝 Walkthrough

Walkthrough

Updated callback type aliases in ImGuiLayer to use inline std::function signatures directly instead of public type aliases. Eight callback setters and their implementations were refactored to use explicit parameter types, and corresponding test assertions were removed.

Changes

Cohort / File(s) Summary
Callback API Refactoring
src/ui/imgui_layer.hpp, src/ui/imgui_layer.cpp
Removed eight public callback type aliases (ParameterChangeCallback, ParameterResetCallback, PreChainChangeCallback, PreChainParameterCallback, PreChainScaleModeCallback, SurfaceSelectCallback, SurfaceFilterToggleCallback, TargetFpsChangeCallback) and replaced all setter method signatures with inline std::function instantiations with explicit parameter types.
Test Updates
tests/render/test_filter_boundary_contracts.cpp
Removed three compile-time contract assertions that verified the removed callback type aliases matched their expected std::function signatures.
Submodule Update
filter-chain
Updated submodule commit reference from 6d96a36e2cf9a1f39d643fd6c1049fb41aed0391 to d053e43fdd7f55ebe68edb04975fcd3d1eefa541.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

Review effort 3/5, Failed compliance check

Poem

🐰 Type aliases fade like morning dew,
Inline functions keep the flow true,
Callbacks dance with std::function's grace,
Tests adjust to find their place,
Simpler API, cleaner space! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: removing callback type aliases from ImGuiLayer and inlining them as std::function types in method signatures.

✏️ 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 dev/refactor-imgui

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.

@qodo-code-review
Copy link
Copy Markdown

ⓘ You are approaching your monthly quota for Qodo. Upgrade your plan

Review Summary by Qodo

Inline ImGuiLayer callback type aliases into method signatures

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Remove callback type aliases from ImGuiLayer header
• Inline std::function types directly in method signatures
• Update member variable declarations to use inlined types
• Remove related type alias assertions from test file
Diagram
flowchart LR
  A["Type Aliases<br/>ParameterChangeCallback<br/>ParameterResetCallback<br/>etc."] -->|"Remove from header"| B["Inlined std::function<br/>in method signatures"]
  B -->|"Update declarations"| C["Member variables<br/>use std::function directly"]
  D["Test assertions<br/>on type aliases"] -->|"Remove"| E["Cleaner test file"]
Loading

Grey Divider

File Changes

1. src/ui/imgui_layer.hpp Refactoring +18/-27

Remove callback type aliases and inline std::function

• Removed 8 callback type alias definitions (ParameterChangeCallback, ParameterResetCallback,
 PreChainChangeCallback, etc.)
• Updated all setter method signatures to use inlined std::function types instead of aliases
• Updated member variable declarations to use inlined std::function types directly

src/ui/imgui_layer.hpp


2. src/ui/imgui_layer.cpp Refactoring +11/-8

Update method signatures to use inlined std::function

• Updated all setter method implementations to use inlined std::function types
• Replaced type alias references with explicit std::function signatures in method parameters
• Maintained callback functionality while removing alias indirection

src/ui/imgui_layer.cpp


3. tests/render/test_filter_boundary_contracts.cpp 🧪 Tests +0/-6

Remove type alias validation assertions

• Removed 3 static_assert statements that validated callback type aliases
• Cleaned up test file by removing assertions on now-inlined types

tests/render/test_filter_boundary_contracts.cpp


View more (1)
4. filter-chain Dependencies +1/-1

Update filter-chain submodule commit

• Updated submodule commit reference from 6d96a36e2cf9a1f39d643fd6c1049fb41aed0391 to
 d053e43fdd7f55ebe68edb04975fcd3d1eefa541

filter-chain


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review bot commented Mar 25, 2026

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0) 📎 Requirement gaps (0) 📐 Spec deviations (0)

Grey Divider


Action required

1. Public callback aliases removed 🐞 Bug ⚙ Maintainability
Description
Deleting the public callback type aliases in goggles::ui will break any downstream code that
referenced goggles::ui::{ParameterChangeCallback, ...} even though the underlying std::function
signatures are unchanged. This is a source/ABI-facing API break because the header is exposed via
the goggles_ui target’s PUBLIC include directories.
Code

src/ui/imgui_layer.hpp[L82-91]

-using ParameterChangeCallback =
-    std::function<void(goggles::fc::FilterControlId control_id, float value)>;
-using ParameterResetCallback = std::function<void()>;
-using PreChainChangeCallback = std::function<void(uint32_t width, uint32_t height)>;
-using PreChainParameterCallback =
-    std::function<void(goggles::fc::FilterControlId control_id, float value)>;
-using PreChainScaleModeCallback = std::function<void(ScaleMode mode, uint32_t integer_scale)>;
-using SurfaceSelectCallback = std::function<void(uint32_t surface_id)>;
-using SurfaceFilterToggleCallback = std::function<void(uint32_t surface_id, bool enabled)>;
-using TargetFpsChangeCallback = std::function<void(uint32_t target_fps)>;
Evidence
imgui_layer.hpp is part of the consumable interface of the goggles_ui library: it is in a PUBLIC
include directory, so external consumers can include it and use its exported types. The PR removes
the using ...Callback = std::function<...> aliases entirely, so any consumer code naming those
aliases will fail to compile after this change.

src/ui/CMakeLists.txt[1-16]
src/ui/imgui_layer.hpp[1-120]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The PR removes the public callback type aliases (e.g., `goggles::ui::ParameterChangeCallback`) from `src/ui/imgui_layer.hpp`. Any downstream code that referenced these names will now fail to compile.

### Issue Context
Even if you prefer inline `std::function` types in method signatures/members, you can keep the aliases purely as compatibility shims.

### Fix Focus Areas
- src/ui/imgui_layer.hpp[70-120]
 - Reintroduce the removed `using ...Callback = std::function<...>;` aliases in `namespace goggles::ui` (optionally mark them `[[deprecated]]` with a clear message).
 - Keep the new inline `std::function` signatures if that’s the refactor goal; the aliases can remain unused internally but preserve downstream compatibility.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Callback contract asserts dropped 🐞 Bug ⚙ Maintainability
Description
The boundary contract test removed compile-time assertions for the UI callback contract without
adding equivalent assertions for the ImGuiLayer setter signatures. This reduces coverage that the
UI boundary still expects the exact callback shapes (now expressed inline as std::function).
Code

tests/render/test_filter_boundary_contracts.cpp[L87-92]

-    static_assert(std::is_same_v<goggles::ui::ParameterChangeCallback,
-                                 std::function<void(FilterControlId, float)>>);
-    static_assert(std::is_same_v<goggles::ui::PreChainParameterCallback,
-                                 std::function<void(FilterControlId, float)>>);
-    static_assert(
-        std::is_same_v<goggles::ui::TargetFpsChangeCallback, std::function<void(uint32_t)>>);
Evidence
The test previously asserted that the callback aliases matched specific std::function signatures;
those assertions are removed. After the alias removal, this check can be preserved by asserting the
signatures of the corresponding ImGuiLayer::set_*_callback member functions directly, but the test
currently does not add such replacement checks.

tests/render/test_filter_boundary_contracts.cpp[68-105]
src/ui/imgui_layer.hpp[101-129]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`tests/render/test_filter_boundary_contracts.cpp` removed `static_assert`s that validated UI callback contract shapes. With the callback aliases gone, there is no longer a compile-time check that the `ImGuiLayer` callback setter signatures remain stable.

### Issue Context
You can keep the intent of the test by asserting the member function pointer types for the setters (or `decltype(&ImGuiLayer::set_...)` comparisons).

### Fix Focus Areas
- tests/render/test_filter_boundary_contracts.cpp[68-105]
 - Add `using` declarations for the expected member function pointer types, e.g.:
   - `using SetParamCbSig = void (goggles::ui::ImGuiLayer::*)(std::function<void(FilterControlId, float)>);`
   - `static_assert(std::is_same_v<decltype(&goggles::ui::ImGuiLayer::set_parameter_change_callback), SetParamCbSig>);`
 - Repeat for `set_prechain_parameter_callback` and `set_target_fps_change_callback` (and optionally the surface callback setters).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

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 `@filter-chain`:
- Line 1: Update the PR description to document the scope of the filter-chain
submodule bump: summarize the functional changes introduced between commits
6d96a36e2cf9a1f39d643fd6c1049fb41aed0391 and
d053e43fdd7f55ebe68edb04975fcd3d1eefa541, list any breaking or API-impacting
changes (public method/signature changes, removed or renamed interfaces,
behavioral changes), and explain why the bump was necessary and how it supports
this PR’s goal so reviewers can assess impact despite the submodule being
private.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8e8278ce-47d9-4454-9fc1-8a1aa737fbd5

📥 Commits

Reviewing files that changed from the base of the PR and between 6fe4a50 and c811a94.

📒 Files selected for processing (4)
  • filter-chain
  • src/ui/imgui_layer.cpp
  • src/ui/imgui_layer.hpp
  • tests/render/test_filter_boundary_contracts.cpp
💤 Files with no reviewable changes (1)
  • tests/render/test_filter_boundary_contracts.cpp

@@ -1 +1 @@
Subproject commit 6d96a36e2cf9a1f39d643fd6c1049fb41aed0391
Subproject commit d053e43fdd7f55ebe68edb04975fcd3d1eefa541
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
set -euo pipefail

echo "== Submodule mapping from .gitmodules =="
if [ -f .gitmodules ]; then
  git config -f .gitmodules --get-regexp '^submodule\..*\.(path|url)$' || true
else
  echo ".gitmodules not found"
fi

echo
echo "== Gitlink recorded in current HEAD for filter-chain =="
git ls-tree HEAD filter-chain || true

echo
echo "== Expected commit range from review context =="
OLD_COMMIT="6d96a36e2cf9a1f39d643fd6c1049fb41aed0391"
NEW_COMMIT="d053e43fdd7f55ebe68edb04975fcd3d1eefa541"
echo "OLD=${OLD_COMMIT}"
echo "NEW=${NEW_COMMIT}"

echo
if [ -d filter-chain/.git ] || [ -f filter-chain/.git ]; then
  echo "== Local submodule log between old and new =="
  git -C filter-chain log --oneline --no-merges "${OLD_COMMIT}..${NEW_COMMIT}" || true
  echo
  echo "== Changed files in submodule range =="
  git -C filter-chain diff --name-status "${OLD_COMMIT}..${NEW_COMMIT}" || true
else
  echo "Submodule working tree is not initialized in this environment."
  echo "Run: git submodule update --init --recursive"
fi

Repository: goggles-dev/Goggles

Length of output: 596


🌐 Web query:

goggles-filter-chain repository commits 6d96a36e2cf9a1f39d643fd6c1049fb41aed0391 d053e43fdd7f55ebe68edb04975fcd3d1eefa541

💡 Result:

No public Git repository named "goggles-filter-chain" exists, and the specific commit hashes 6d96a36e2cf9a1f39d643fd6c1049fb41aed0391 and d053e43fdd7f55ebe68edb04975fcd3d1eefa541 do not appear in any indexed sources. Searches across GitHub, general web, company sites, and people profiles yielded no matches for this exact combination. Related projects like chadrem/filter_chain (Ruby gem), K1ngst0m/Goggles (frame streaming), steveoro/goggles_api (swimming API), and Brave Search Goggles exist, but none match the repository name or commits.

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Try to use git ls-remote to get info about the remote repository
echo "== Remote info for filter-chain submodule =="
git ls-remote --heads --tags git@github.com:goggles-dev/goggles-filter-chain.git | head -20 || true

echo
echo "== Attempting to fetch commit messages from remote (if accessible) =="
# Try to fetch the specific commits' info if accessible
OLD_COMMIT="6d96a36e2cf9a1f39d643fd6c1049fb41aed0391"
NEW_COMMIT="d053e43fdd7f55ebe68edb04975fcd3d1eefa541"

# Try git fetch-pack to get information about specific commits
echo "OLD_COMMIT=${OLD_COMMIT}"
echo "NEW_COMMIT=${NEW_COMMIT}"

# Alternative: check if any remote is configured that might have filter-chain history
echo
echo "== Configured remotes =="
git remote -v || true

Repository: goggles-dev/Goggles

Length of output: 609


Document the scope of the filter-chain submodule bump in the PR description.

The filter-chain submodule repository is not publicly accessible, making it impossible to review what changed between the old and new commits directly from GitHub. Because of this access restriction, it is essential to include in this PR's description:

  • A summary of what changed in the filter-chain submodule (commit 6d96a36e2cf9a1f39d643fd6c1049fb41aed0391d053e43fdd7f55ebe68edb04975fcd3d1eefa541)
  • Any breaking or API-impact changes
  • Why this bump was necessary and how it relates to the PR objective

This ensures traceability and allows reviewers to understand the impact of vendored dependency updates.

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

In `@filter-chain` at line 1, Update the PR description to document the scope of
the filter-chain submodule bump: summarize the functional changes introduced
between commits 6d96a36e2cf9a1f39d643fd6c1049fb41aed0391 and
d053e43fdd7f55ebe68edb04975fcd3d1eefa541, list any breaking or API-impacting
changes (public method/signature changes, removed or renamed interfaces,
behavioral changes), and explain why the bump was necessary and how it supports
this PR’s goal so reviewers can assess impact despite the submodule being
private.

PreChainState prechain;
};

using ParameterChangeCallback =
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Public callback aliases removed 🐞 Bug ⚙ Maintainability

Deleting the public callback type aliases in goggles::ui will break any downstream code that
referenced goggles::ui::{ParameterChangeCallback, ...} even though the underlying std::function
signatures are unchanged. This is a source/ABI-facing API break because the header is exposed via
the goggles_ui target’s PUBLIC include directories.
Agent Prompt
### Issue description
The PR removes the public callback type aliases (e.g., `goggles::ui::ParameterChangeCallback`) from `src/ui/imgui_layer.hpp`. Any downstream code that referenced these names will now fail to compile.

### Issue Context
Even if you prefer inline `std::function` types in method signatures/members, you can keep the aliases purely as compatibility shims.

### Fix Focus Areas
- src/ui/imgui_layer.hpp[70-120]
  - Reintroduce the removed `using ...Callback = std::function<...>;` aliases in `namespace goggles::ui` (optionally mark them `[[deprecated]]` with a clear message).
  - Keep the new inline `std::function` signatures if that’s the refactor goal; the aliases can remain unused internally but preserve downstream compatibility.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@K1ngst0m K1ngst0m merged commit 2bdb712 into main Mar 25, 2026
5 checks passed
@K1ngst0m K1ngst0m deleted the dev/refactor-imgui branch March 25, 2026 12:46
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