Skip to content

feat(agentflow): add field visibility engine with show/hide conditions#5890

Merged
jocelynlin-wd merged 5 commits intomainfrom
feat/agentflow-field-visibility
Mar 4, 2026
Merged

feat(agentflow): add field visibility engine with show/hide conditions#5890
jocelynlin-wd merged 5 commits intomainfrom
feat/agentflow-field-visibility

Conversation

@jocelynlin-wd
Copy link
Copy Markdown
Contributor

@jocelynlin-wd jocelynlin-wd commented Mar 4, 2026

FLOWISE-233
Add InputParam show/hide condition support that controls field visibility based on current input values. Includes regex, array, boolean, and nested path matching with parity to upstream genericHelper.js.

  • Add fieldVisibility utility (evaluateFieldVisibility, stripHiddenFieldValues)
  • Add show/hide fields to InputParam type
  • Integrate visibility into EditNodeDialog (re-evaluate on change, preserve hidden values in state)
  • Update useOpenNodeEditor to fall back to node.data.inputs when API schema is unavailable
  • Move connectionValidation from utils/ to validation/
  • Skip hidden params in validateNode required-input checks
  • Add CustomNodeExample demo with live visibility state panel
  • Update ARCHITECTURE.md and TESTS.md
agentflow-field-visibility.mov

Add InputParam show/hide condition support that controls field visibility
based on current input values. Includes regex, array, boolean, and nested
path matching with parity to upstream genericHelper.js.

- Add fieldVisibility utility (evaluateFieldVisibility, stripHiddenFieldValues)
- Add show/hide fields to InputParam type
- Integrate visibility into EditNodeDialog (re-evaluate on change, preserve
  hidden values in state)
- Update useOpenNodeEditor to fall back to node.data.inputs when API schema
  is unavailable
- Move connectionValidation from utils/ to validation/
- Skip hidden params in validateNode required-input checks
- Add CustomNodeExample demo with live visibility state panel
- Update ARCHITECTURE.md and TESTS.md

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the Agentflow UI by introducing a robust field visibility engine. This allows for dynamic and conditional rendering of input parameters within node editors, improving the user experience by presenting only relevant fields. It also refines how node input schemas are handled, ensuring flexibility for custom nodes, and updates validation logic to respect field visibility, leading to more accurate flow validation.

Highlights

  • Field Visibility Engine: Introduced a new field visibility engine that allows InputParams to define show and hide conditions based on current input values. This supports regex, array, boolean, and nested path matching.
  • Dynamic Node Editing: Integrated the field visibility logic into the EditNodeDialog, enabling dynamic display of input fields. Hidden field values are now preserved in the state, only being stripped on save/export, not on every keystroke.
  • Input Schema Fallback: The useOpenNodeEditor hook was updated to fall back to node.data.inputs if the API schema for a node is unavailable, ensuring custom nodes can define their own input parameters.
  • Validation Enhancement: Modified the validateNode function to skip required input checks for parameters that are currently hidden by visibility conditions.
  • New Example Demo: Added a CustomNodeExample demo that showcases live field visibility state with a custom node defining its own input parameters and show/hide conditions.
  • Codebase Refactoring: The connectionValidation utility and its tests were moved from the utils/ directory to the validation/ directory for better logical grouping.
Changelog
  • packages/agentflow/ARCHITECTURE.md
    • Updated directory structure to reflect the move of connectionValidation.ts from utils/ to validation/.
  • packages/agentflow/TESTS.md
    • Modified test documentation to reflect the new location of isValidConnectionAgentflowV2 and added details for useOpenNodeEditor's fallback behavior.
  • packages/agentflow/examples/src/App.tsx
    • Imported and registered the new CustomNodeExample.
  • packages/agentflow/examples/src/demos/AllNodeTypesExample.tsx
    • Changed the readOnly prop to false for the Agentflow component.
  • packages/agentflow/examples/src/demos/CustomNodeExample.tsx
    • Added a new example demonstrating custom nodes with self-contained InputParam definitions and show/hide conditions, including a live visibility state panel.
  • packages/agentflow/examples/src/demos/index.ts
    • Exported the new CustomNodeExample.
  • packages/agentflow/src/core/types/index.ts
    • Added show and hide properties to the InputParam interface to support conditional visibility.
  • packages/agentflow/src/core/utils/fieldVisibility.test.ts
    • Added comprehensive unit tests for the conditionMatches, evaluateParamVisibility, evaluateFieldVisibility, and stripHiddenFieldValues functions.
  • packages/agentflow/src/core/utils/fieldVisibility.ts
    • Implemented core logic for field visibility, including conditionMatches for value comparison, evaluateParamVisibility for single parameter evaluation, evaluateFieldVisibility for all parameters, and stripHiddenFieldValues to remove hidden fields from input values.
  • packages/agentflow/src/core/utils/index.ts
    • Removed the export for isValidConnectionAgentflowV2 and added exports for the new field visibility utilities (evaluateFieldVisibility, evaluateParamVisibility, stripHiddenFieldValues).
  • packages/agentflow/src/core/validation/connectionValidation.test.ts
    • Moved the test file for connection validation from utils/ to validation/.
  • packages/agentflow/src/core/validation/connectionValidation.ts
    • Moved the connectionValidation utility file from utils/ to validation/.
  • packages/agentflow/src/core/validation/flowValidation.ts
    • Imported evaluateParamVisibility and updated validateNode to conditionally check required inputs, skipping those that are hidden.
  • packages/agentflow/src/core/validation/index.ts
    • Added the export for isValidConnectionAgentflowV2.
  • packages/agentflow/src/features/canvas/hooks/useOpenNodeEditor.test.tsx
    • Added new test cases to verify the useOpenNodeEditor hook's behavior, specifically its fallback to node.data.inputs and prioritization of API schema inputs.
  • packages/agentflow/src/features/canvas/hooks/useOpenNodeEditor.ts
    • Modified useOpenNodeEditor to prioritize API schema inputs but fall back to node.data.inputs if no API schema is found for a node.
  • packages/agentflow/src/features/node-editor/EditNodeDialog.test.tsx
    • Updated tests to include scenarios for field visibility conditions and to confirm that hidden field values are preserved in the dialog's state.
  • packages/agentflow/src/features/node-editor/EditNodeDialog.tsx
    • Integrated evaluateFieldVisibility to dynamically update the displayed input parameters and ensured that inputValues in the state retain values for hidden fields.
  • packages/agentflow/src/index.ts
    • Exported the new field visibility utilities (evaluateFieldVisibility, evaluateParamVisibility, stripHiddenFieldValues) for external use.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a field visibility engine for input parameters. The review highlights a potential Regular Expression Denial of Service (ReDoS) vulnerability in the conditionMatches utility due to the use of untrusted input for RegExp construction. Additionally, a code review comment suggests refactoring duplicated logic and optimizing loops in the evaluateParamVisibility function to improve readability and maintainability.

@jocelynlin-wd
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a field visibility engine based on show/hide conditions in InputParam, which is a great enhancement for creating dynamic node property forms. However, a critical security vulnerability related to Regular Expression Denial of Service (ReDoS) was identified in the safeRegexTest utility. This function lacks a timeout mechanism when executing user-provided regex patterns, which could be exploited to cause a Denial of Service if the validation logic is executed on the server. It is recommended to implement a timeout or use a safer regex execution method. Additionally, there is a suggestion to improve the maintainability of the new visibility engine.

initialFlow={allNodesFlow}
showDefaultHeader={false}
readOnly={true}
readOnly={false}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is intentional, make it easier to view the edit dialog on all node types

@jocelynlin-wd jocelynlin-wd requested a review from j-sanaa March 4, 2026 01:54
@jocelynlin-wd
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a field visibility engine, allowing input parameters to be shown or hidden based on other input values. However, the current regex validation logic for this engine is incomplete and can be bypassed by sophisticated ReDoS patterns, potentially leading to a Denial of Service (DoS) if a malicious flow is imported. It is recommended to use a more robust ReDoS detection library or a non-backtracking regex engine. Additionally, the required input validation logic needs improvement to correctly handle values like 0 and false.

…heck

- Replace regex-based nested quantifier detection with a character-by-character
  parser that catches bypass patterns like (a|aa)+ and (a+ )+
- Fix required-input validation to use nullish check (== null || === '')
  instead of falsy check (!value), allowing 0 and false as valid inputs

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@jocelynlin-wd
Copy link
Copy Markdown
Contributor Author

/gemeni review

@mmattu-wd mmattu-wd self-requested a review March 4, 2026 17:08
Copy link
Copy Markdown

@mmattu-wd mmattu-wd left a comment

Choose a reason for hiding this comment

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

lgtm!

...overrides
})

describe('conditionMatches', () => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

if (
!param.optional &&
evaluateParamVisibility(param, inputValues) &&
(inputValues[param.name] == null || inputValues[param.name] === '')
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nb: can we just make this !inputValues[param.name]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

!inputValues[param.name] will treat all falsy values as missing: undefined, null, '', false, 0, NaN. But here we only treat undefined, null and '' as missing.

@jocelynlin-wd jocelynlin-wd merged commit 3ef1495 into main Mar 4, 2026
7 checks passed
@jocelynlin-wd jocelynlin-wd deleted the feat/agentflow-field-visibility branch March 19, 2026 17:39
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.

3 participants