Skip to content

InputTOPP: add reactive option and split impl/fragment for conditional UI#398

Open
JKVISION1101 wants to merge 1 commit into
OpenMS:mainfrom
JKVISION1101:main
Open

InputTOPP: add reactive option and split impl/fragment for conditional UI#398
JKVISION1101 wants to merge 1 commit into
OpenMS:mainfrom
JKVISION1101:main

Conversation

@JKVISION1101

@JKVISION1101 JKVISION1101 commented Jul 15, 2026

Copy link
Copy Markdown

Summary: Adds a reactive parameter to input_TOPP and splits the implementation into _input_TOPP_impl and _input_TOPP_fragmented so callers can opt into immediate parent re-rendering when a parameter changes.

What changed: input_TOPP no longer decorated with @st.fragment; it accepts reactive: bool and delegates to either _input_TOPP_impl (direct rendering) or _input_TOPP_fragmented (fragmented wrapper).

+Also documents a new flag_parameters argument used to mark no-value TOPP flags.

Summary by CodeRabbit

  • New Features

    • Added an optional reactive mode for TOPP parameter controls.
    • When enabled, dependent interface elements can refresh automatically as TOPP settings change.
  • Compatibility

    • Existing behavior remains unchanged unless reactive mode is enabled.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

StreamlitUI.input_TOPP adds a reactive parameter and conditionally uses direct or fragmented rendering. Its documentation also describes no-value CLI flag parameters.

Changes

TOPP reactive rendering

Layer / File(s) Summary
Conditional TOPP rendering
src/workflow/StreamlitUI.py
input_TOPP accepts reactive=False, documents flag_parameters, removes the unconditional fragment decorator, and delegates to direct or fragmented rendering based on the flag.

Suggested reviewers: claude, copilot

Poem

I’m a rabbit watching widgets bloom,
TOPP hops through a refreshed room.
Reactive toggles lead the way,
Fragments rest or work today.
Hop, hop—clean inputs flow!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: adding a reactive option to InputTOPP and splitting the implementation for conditional rendering.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/workflow/StreamlitUI.py (1)

822-834: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Missing flag_parameters in the method signature causes a NameError.

The flag_parameters argument is documented in the docstring and passed to the internal implementation methods on lines 865 and 871, but it is missing from the method signature here. Because it is evaluated unconditionally in the method body, every call to input_TOPP will crash with a NameError.

🐛 Proposed fix
     def input_TOPP(
         self,
         topp_tool_name: str,
         num_cols: int = 4,
         exclude_parameters: List[str] = [],
         include_parameters: List[str] = [],
+        flag_parameters: List[str] = [],
         display_tool_name: bool = True,
         display_subsections: bool = True,
         display_subsection_tabs: bool = False,
         custom_defaults: dict = {},
         tool_instance_name: str = None,
         reactive: bool = False,
     ) -> None:
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/workflow/StreamlitUI.py` around lines 822 - 834, Add the documented
flag_parameters argument to the input_TOPP method signature, using the same type
and default expected by its internal implementation calls. Keep the existing
forwarding at the relevant internal method invocations so the parameter is
defined for every input_TOPP call.

Source: Linters/SAST tools

🧹 Nitpick comments (1)
src/workflow/StreamlitUI.py (1)

876-888: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Avoid using mutable defaults for arguments.

The newly added internal methods _input_TOPP_fragmented and _input_TOPP_impl (as well as input_TOPP) use mutable data structures ([], {}) for argument defaults. This can lead to unexpected behavior if the lists or dicts are mutated, as the changes will persist across function calls.

Consider replacing them with None and initializing them inside the function body.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/workflow/StreamlitUI.py` around lines 876 - 888, Replace the mutable
defaults in _input_TOPP_fragmented, _input_TOPP_impl, and input_TOPP with None,
then initialize each list or dict inside the corresponding function before use.
Preserve the existing defaults and behavior when callers omit these arguments.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/workflow/StreamlitUI.py`:
- Around line 895-907: Implement handling for flag_parameters within
_input_TOPP_impl so each listed parameter is rendered and submitted as a
no-value CLI flag rather than requiring an input value. Preserve the existing
behavior for parameters not included in flag_parameters, and ensure the argument
is applied consistently through the function’s parameter-processing path.

---

Outside diff comments:
In `@src/workflow/StreamlitUI.py`:
- Around line 822-834: Add the documented flag_parameters argument to the
input_TOPP method signature, using the same type and default expected by its
internal implementation calls. Keep the existing forwarding at the relevant
internal method invocations so the parameter is defined for every input_TOPP
call.

---

Nitpick comments:
In `@src/workflow/StreamlitUI.py`:
- Around line 876-888: Replace the mutable defaults in _input_TOPP_fragmented,
_input_TOPP_impl, and input_TOPP with None, then initialize each list or dict
inside the corresponding function before use. Preserve the existing defaults and
behavior when callers omit these arguments.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c50c6772-d29e-445c-90f2-1d9ecd6e5178

📥 Commits

Reviewing files that changed from the base of the PR and between 2b8cda2 and e86c238.

📒 Files selected for processing (1)
  • src/workflow/StreamlitUI.py

Comment on lines +895 to +907
def _input_TOPP_impl(
self,
topp_tool_name: str,
num_cols: int = 4,
exclude_parameters: List[str] = [],
include_parameters: List[str] = [],
flag_parameters: List[str] = [],
display_tool_name: bool = True,
display_subsections: bool = True,
display_subsection_tabs: bool = False,
custom_defaults: dict = {},
tool_instance_name: str = None,
) -> None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Missing implementation for flag_parameters.

The flag_parameters argument is passed into _input_TOPP_impl, but it is never used within the function body. The documented behavior of marking parameters as no-value CLI flags is currently a no-op.

🧰 Tools
🪛 Ruff (0.15.21)

[warning] 899-899: Do not use mutable data structures for argument defaults

Replace with None; initialize within function

(B006)


[warning] 900-900: Do not use mutable data structures for argument defaults

Replace with None; initialize within function

(B006)


[warning] 901-901: Do not use mutable data structures for argument defaults

Replace with None; initialize within function

(B006)


[warning] 905-905: Do not use mutable data structures for argument defaults

Replace with None; initialize within function

(B006)


[warning] 906-906: PEP 484 prohibits implicit Optional

Convert to T | None

(RUF013)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/workflow/StreamlitUI.py` around lines 895 - 907, Implement handling for
flag_parameters within _input_TOPP_impl so each listed parameter is rendered and
submitted as a no-value CLI flag rather than requiring an input value. Preserve
the existing behavior for parameters not included in flag_parameters, and ensure
the argument is applied consistently through the function’s parameter-processing
path.

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