Skip to content

Conversation

@Julusian
Copy link
Member

@Julusian Julusian commented Jan 27, 2026

About the Contributor

This pull request is posted on behalf of Superfly

Type of Contribution

This is a: Code improvement

Current Behavior

There is some duplicated logic/'hack' aroung using useOverrideOpHelper for a simple object (not a Record<string, T>)

This tidies it up by creating a new helper to handle this complexity in one place and avoid it being repeated everywhere

Testing

  • I have added one or more unit tests for this PR
  • I have updated the relevant unit tests
  • No unit test changes are needed for this PR

Affected areas

Time Frame

Other Information

Status

  • PR is ready to be reviewed.
  • The functionality has been tested by the author.
  • Relevant unit tests has been added / updated.
  • Relevant documentation (code comments, system documentation) has been added / updated.

Summary

This PR reduces code duplication across the settings UI by introducing a new helper function useOverrideOpHelperForSimpleObject that centralizes the handling of override operations for simple objects (non-Record types).

Changes

New Helper (packages/webui/src/client/ui/Settings/util/OverrideOpHelper.tsx)

  • Added useOverrideOpHelperForSimpleObject<T>() that encapsulates the pattern of:
    • Wrapping a simple object with override paths prefixed with "0."
    • Computing the current value via applyAndValidateOverrides
    • Creating and returning both the wrapped item and override helper
  • Exported for reuse across the codebase

Refactored Components

  • BlueprintConfigSchema/index.tsx: Replaced manual wrapping logic and override helper construction with useOverrideOpHelperForSimpleObject, eliminating intermediate wrappedItem, wrappedConfigObject, and prefixed path handling
  • Studio/Generic.tsx: Simplified StudioSettings by replacing multi-step memo-based wrapping with useOverrideOpHelperForSimpleObject call
  • SystemManagement.tsx: Removed custom in-component wrapping logic and manual override helper setup in favor of the new helper
  • Studio/Devices/IngestSubDevices.tsx, InputSubDevices.tsx, PlayoutSubDevices.tsx: Added type annotations using ObjectWithOverrides generic on useMemo calls to strengthen type safety

Impact

  • Reduces code duplication by centralizing a repeated pattern into a reusable helper
  • Improves maintainability by having override handling logic in one place
  • Strengthens type safety in several device configuration files
  • No changes to public API or component signatures
  • No unit test changes required

Files Changed

  • 6 modified files across settings UI components
  • Net change: +81 / -108 lines (reduction in overall code)

@Julusian Julusian requested a review from a team as a code owner January 27, 2026 11:30
@coderabbitai
Copy link

coderabbitai bot commented Jan 27, 2026

Walkthrough

Refactors the UI Settings components to centralize override-handling logic into a new useOverrideOpHelperForSimpleObject helper. Multiple settings components replace their manual wrapping and override management with this unified utility, while device sub-settings components receive stronger type annotations for consistency.

Changes

Cohort / File(s) Summary
New Override Helper Utility
packages/webui/src/client/ui/Settings/util/OverrideOpHelper.tsx
Added public useOverrideOpHelperForSimpleObject hook that consolidates override handling by wrapping raw config objects, applying overrides via applyAndValidateOverrides, and returning both the wrapped item and override helper.
Settings Components – Major Refactoring
packages/webui/src/client/ui/Settings/BlueprintConfigSchema/index.tsx, packages/webui/src/client/ui/Settings/Studio/Generic.tsx, packages/webui/src/client/ui/Settings/SystemManagement.tsx
Replaced multi-step manual wrapping and override handling (using useOverrideOpHelper, WrappedOverridableItemNormal, applyAndValidateOverrides) with calls to the new simplified helper; removed intermediate wrapping logic and manual path prefixing.
Device Sub-Settings Type Refinements
packages/webui/src/client/ui/Settings/Studio/Devices/IngestSubDevices.tsx, packages/webui/src/client/ui/Settings/Studio/Devices/InputSubDevices.tsx, packages/webui/src/client/ui/Settings/Studio/Devices/PlayoutSubDevices.tsx
Added ObjectWithOverrides import and annotated memoized baseSettings values with precise generic types (ObjectWithOverrides<Record<string, DeviceType>>); no runtime behavior changes, strengthens type safety.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • jstarpl
  • chandrashekar-nallamilli

Poem

🐰 With helpers so neat, the rabbit does hop,
Through tangled overrides, complexity stops!
No wrapping, no prefixing—just simple and clean,
The settings now flow like they've never been seen! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.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
Title check ✅ Passed The title clearly and concisely summarizes the main change: reducing duplication when using useOverrideOpHelper for simple objects, which is the core intent across all modified files.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

@Julusian
Copy link
Member Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Jan 27, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@codecov
Copy link

codecov bot commented Jan 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link

@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

🤖 Fix all issues with AI agents
In `@packages/webui/src/client/ui/Settings/util/OverrideOpHelper.tsx`:
- Line 13: The import for literal at the top of OverrideOpHelper.tsx uses the
source path ('@sofie-automation/corelib/src/lib') which is inconsistent with the
other imports; update that import to use the compiled module path
('@sofie-automation/corelib/dist/lib') so it matches the other imports in this
file and avoids bundler/resolution issues—modify the import statement that
references literal accordingly.

@Julusian Julusian force-pushed the fix/overrides-duplication branch from 2065514 to f379959 Compare January 27, 2026 11:40
@Saftret Saftret added the Contribution from SuperFly.tv Contributions sponsored by SuperFly.tv label Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Contribution from SuperFly.tv Contributions sponsored by SuperFly.tv

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants