Skip to content

fix: makes action title follow the flow name after editing to old title#8293

Merged
lucaseduoli merged 3 commits into
mainfrom
fix/mcp_removed_action_title
Jun 2, 2025
Merged

fix: makes action title follow the flow name after editing to old title#8293
lucaseduoli merged 3 commits into
mainfrom
fix/mcp_removed_action_title

Conversation

@lucaseduoli
Copy link
Copy Markdown
Collaborator

@lucaseduoli lucaseduoli commented May 30, 2025

This pull request refactors the string parsing logic in the ToolsTable component and enhances the parseString utility function to handle edge cases more robustly. The changes improve code clarity and ensure consistent behavior when processing empty or blank strings.

Refactoring in ToolsTable component:

  • Refactored the logic for processing name and display_name fields in ToolsTable to improve readability and ensure that name and display_name are parsed separately before comparison. Updated the processedValue and processedDescription logic to handle cases where fields are empty or identical, with additional consideration for the isAction flag. (src/frontend/src/modals/toolsModal/components/toolsTable/index.tsx, src/frontend/src/modals/toolsModal/components/toolsTable/index.tsxL83-R107)

Enhancements to parseString utility:

  • Enhanced the parseString function to return an empty string if the input string is empty or if the no_blank parser is included and the string contains only whitespace. This ensures more robust handling of edge cases during string manipulation. (src/frontend/src/utils/stringManipulation.ts, src/frontend/src/utils/stringManipulation.tsR81-R88)

Summary by CodeRabbit

  • Refactor
    • Improved the handling and normalization of name and description fields in the tools modal for more accurate display and selection logic.
  • Bug Fixes
    • Enhanced string parsing to better handle empty or blank values, preventing unintended errors or display issues when processing input fields.

@lucaseduoli lucaseduoli self-assigned this May 30, 2025
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label May 30, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 30, 2025

Walkthrough

The changes update the logic for processing name, display_name, description, and display_description fields in the tools modal table component. The parseString utility is enhanced to handle empty strings and the "no_blank" parser more robustly, returning early when appropriate. No public API signatures were altered.

Changes

File(s) Change Summary
src/frontend/src/modals/toolsModal/components/toolsTable/index.tsx Refactored field processing logic for name, display_name, description, and display_description with additional normalization, conditional checks, and handling of the isAction flag.
src/frontend/src/utils/stringManipulation.ts Updated parseString to return early for empty strings and when "no_blank" is specified with blanks.

Poem

In the fields of names and blanks,
The rabbits hop and give their thanks.
Strings parsed neat, no blanks to see,
Descriptions clear as they can be.
With every hop, the code refines—
Modal magic in tidy lines!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9b345cc and c45f247.

📒 Files selected for processing (2)
  • src/frontend/src/modals/toolsModal/components/toolsTable/index.tsx (1 hunks)
  • src/frontend/src/utils/stringManipulation.ts (1 hunks)
🔇 Additional comments (3)
src/frontend/src/utils/stringManipulation.ts (1)

85-87:

Details

❓ Verification inconclusive

Fix type handling and verify behavioral change.

There's a critical bug in the type handling: parsers.includes("no_blank") assumes parsers is always an array, but according to the function signature, parsers can be either FieldParserType[] or FieldParserType (a single string). When parsers is a string, .includes() will perform substring matching instead of array element matching.

Additionally, this early exit fundamentally changes the behavior of the "no_blank" parser. Previously, it would throw an error for blank strings (as seen in the noBlank function), but now it silently returns an empty string, which may break existing code that expects an error to be thrown.

Apply this fix to handle the type correctly:

-  if (parsers.includes("no_blank") && result.trim() === "") {
+  const parsersArray = typeof parsers === "string" ? [parsers] : parsers;
+  if (parsersArray.includes("no_blank") && result.trim() === "") {
     return "";
   }

Please verify that this behavioral change (returning empty string instead of throwing error for blank strings) is intentional and won't break existing consumers of the parseString function.


I need to verify how parsers is handled in parseString and the existing noBlank behavior.


🏁 Script executed:

#!/bin/bash
# Locate parseString signature and initial handling of parsers
rg -n 'function parseString' -A5 -B5 src/frontend/src/utils/stringManipulation.ts

# Check FieldParserType definition
rg -n 'export type FieldParserType' -A2 -B2 src/frontend/src/utils/stringManipulation.ts

# Inspect noBlank implementation
rg -n 'function noBlank' -A5 -B5 src/frontend/src/utils/stringManipulation.ts

# See if parsers is normalized (e.g., wrapped into an array)
rg -n 'Array.isArray' -A5 -B5 src/frontend/src/utils/stringManipulation.ts

Length of output: 845


I still need to see the full parseString implementation to confirm if parsers is ever normalized to an array or handled differently. Let me pull the body around the early-exit logic:


🏁 Script executed:

#!/bin/bash
# Extract the full parseString implementation
sed -n '75,150p' src/frontend/src/utils/stringManipulation.ts

# Inspect the early-exit around "no_blank"
rg -n 'no_blank' -A5 -B5 src/frontend/src/utils/stringManipulation.ts

# Check if parsers is reassigned or normalized anywhere
rg -n 'parsers =' -A3 -B3 src/frontend/src/utils/stringManipulation.ts

Length of output: 2646


Normalize parsers before checking and confirm no_blank early‐exit behavior

To avoid using .includes() on a value that might be a string (leading to substring checks) and to preserve the original noBlank error behavior, you should:

• Pre-normalize parsers into an array immediately after you set result.
• Use the normalized parsersArray when checking for "no_blank".
• Double-check that silently returning "" for blank inputs (instead of throwing in noBlank) is the intended change.

Example diff:

 export function parseString(
   str: string,
   parsers: FieldParserType[] | FieldParserType,
 ): string {
   let result = str;
+  const parsersArray =
+    typeof parsers === "string" ? [parsers] : parsers;

   if (result === "") {
     return "";
   }

-  if (parsers.includes("no_blank") && result.trim() === "") {
+  if (parsersArray.includes("no_blank") && result.trim() === "") {
     return "";
   }
 
   // …rest of loop over parsersArray…

Please verify that overriding noBlank’s error-throw with an empty-string return is intentional and won’t break existing consumers.

src/frontend/src/modals/toolsModal/components/toolsTable/index.tsx (2)

83-99: Well-structured refactoring with improved readability.

The refactoring nicely separates the parsing logic from the conditional logic, making the code more readable and maintainable. The conditional logic correctly handles different scenarios:

  1. Uses the parsed name when it's non-empty and differs from display_name
  2. Appropriately handles the isAction flag by using empty strings when needed
  3. Falls back to display_name for non-action cases

However, this code depends on the parseString function which has a type handling bug that should be fixed first (see previous comment).


102-107: Consistent logic for description processing.

The description processing follows the same well-structured pattern as the name processing, maintaining consistency in the codebase. The conditional logic appropriately handles the differences between description and display_description fields based on the isAction flag.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions Bot added bug Something isn't working and removed bug Something isn't working labels May 30, 2025
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label May 30, 2025
@ogabrielluiz ogabrielluiz added this pull request to the merge queue Jun 2, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 2, 2025
@lucaseduoli lucaseduoli added this pull request to the merge queue Jun 2, 2025
Merged via the queue into main with commit 3bb0779 Jun 2, 2025
33 of 34 checks passed
@lucaseduoli lucaseduoli deleted the fix/mcp_removed_action_title branch June 2, 2025 18:49
ogabrielluiz pushed a commit to bkatya2001/langflow that referenced this pull request Jun 24, 2025
…le (langflow-ai#8293)

* Set names and descriptions as empty to get from flow name when empty instead of assigning the immediate name

* Changed to compare already parsed values

* changed parseString to return empty when the string is empty or have only spaces
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants