Skip to content

feat: add InputFile customization#9233

Merged
Cristhianzl merged 2 commits intomainfrom
cz/custom-inputFile
Jul 29, 2025
Merged

feat: add InputFile customization#9233
Cristhianzl merged 2 commits intomainfrom
cz/custom-inputFile

Conversation

@Cristhianzl
Copy link
Member

@Cristhianzl Cristhianzl commented Jul 29, 2025

This pull request refactors the ParameterRenderComponent in the frontend codebase to introduce a customized file input component and streamline imports. The most significant changes include replacing the InputFileComponent with a new CustomInputFileComponent, adding the implementation for the custom component, and cleaning up unused imports.

Refactoring and Customization:

Code Cleanup:

Minor Adjustments:

Summary by CodeRabbit

  • New Features
    • Introduced a new custom file input component for handling file uploads.
    • Updated file input fields to use the new custom component, ensuring consistent behavior and appearance.

…put component in parameter render component for better flexibility and customization. Remove InputFileComponent from parameter render component and replace it with CustomInputFileComponent.
@Cristhianzl Cristhianzl requested a review from lucaseduoli July 29, 2025 16:56
@Cristhianzl Cristhianzl self-assigned this Jul 29, 2025
@SonicDMG SonicDMG temporarily deployed to cz/custom-inputFile - langflow-manual-install PR #9233 July 29, 2025 16:56 — with Render Destroyed
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 29, 2025

Walkthrough

The changes replace the use of a standard file input component with a new custom wrapper component for file inputs in the parameter rendering logic. A new CustomInputFileComponent is introduced, which wraps and forwards props to the original file input component with a modified id prop.

Changes

Cohort / File(s) Change Summary
Parameter Render Component Refactor
src/frontend/src/components/core/parameterRenderComponent/index.tsx
Replaces import and usage of InputFileComponent with CustomInputFileComponent for file input rendering.
Custom File Input Component Addition
src/frontend/src/customization/components/custom-input-file.tsx
Adds new CustomInputFileComponent that wraps InputFileComponent, forwarding all props and modifying the id.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested labels

size:S, lgtm, refactor

Suggested reviewers

  • mfortman11
  • lucaseduoli
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cz/custom-inputFile

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
🪧 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 generate unit tests to generate unit tests for 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.

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 the enhancement New feature or request label Jul 29, 2025
@SonicDMG SonicDMG temporarily deployed to cz/custom-inputFile - langflow-manual-install PR #9233 July 29, 2025 16:57 — with Render Destroyed
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jul 29, 2025
@sonarqubecloud
Copy link

@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Jul 29, 2025
Copy link
Contributor

@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

🔭 Outside diff range comments (1)
src/frontend/src/components/core/parameterRenderComponent/index.tsx (1)

172-180: Remove the redundant inputfile_ prefix to avoid duplicated IDs

Because CustomInputFileComponent already prefixes the ID, this call produces inputfile_inputfile_xyz.
Pass the base ID instead:

-          <CustomInputFileComponent
-            {...baseInputProps}
-            fileTypes={templateData.fileTypes}
-            file_path={templateData.file_path}
-            isList={templateData.list ?? false}
-            tempFile={templateData.temp_file ?? true}
-            id={`inputfile_${id}`}
-          />
+          <CustomInputFileComponent
+            {...baseInputProps}
+            fileTypes={templateData.fileTypes}
+            file_path={templateData.file_path}
+            isList={templateData.list ?? false}
+            tempFile={templateData.temp_file ?? true}
+            id={id}
+          />

This guarantees a single, predictable DOM ID.

🧹 Nitpick comments (1)
src/frontend/src/customization/components/custom-input-file.tsx (1)

7-17: Prefer passing the entire props object and avoid manual de-structuring to keep the wrapper future-proof

By eagerly destructuring every single prop, the wrapper becomes brittle: if InputProps later gains a new optional field, this component will silently drop it.
A safer pattern is to accept props (or ...rest) wholesale and forward everything, overriding only what you need (id).

-export default function CustomInputFileComponent({
-  value,
-  file_path,
-  handleOnNewValue,
-  disabled,
-  fileTypes,
-  isList,
-  tempFile = true,
-  editNode = false,
-  id,
-}: InputProps<string, FileComponentType>): JSX.Element {
-  return (
-    <InputFileComponent
-      value={value}
-      file_path={file_path}
-      handleOnNewValue={handleOnNewValue}
-      disabled={disabled}
-      fileTypes={fileTypes}
-      isList={isList}
-      tempFile={tempFile}
-      editNode={editNode}
-      id={`inputfile_${id}`}
-    />
-  );
-}
+export default function CustomInputFileComponent(
+  props: InputProps<string, FileComponentType>,
+): JSX.Element {
+  const { id, ...rest } = props;
+  return <InputFileComponent {...rest} id={`inputfile_${id}`} />;
+}

This cuts duplication and keeps the wrapper aligned with any future prop additions.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 575cb7f and 13565ca.

📒 Files selected for processing (2)
  • src/frontend/src/components/core/parameterRenderComponent/index.tsx (2 hunks)
  • src/frontend/src/customization/components/custom-input-file.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
src/frontend/src/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit Inference Engine (.cursor/rules/frontend_development.mdc)

src/frontend/src/**/*.{ts,tsx,js,jsx}: All frontend TypeScript and JavaScript code should be located under src/frontend/src/ and organized into components, pages, icons, stores, types, utils, hooks, services, and assets directories as per the specified directory layout.
Use React 18 with TypeScript for all UI components in the frontend.
Format all TypeScript and JavaScript code using the make format_frontend command.
Lint all TypeScript and JavaScript code using the make lint command.

Files:

  • src/frontend/src/components/core/parameterRenderComponent/index.tsx
  • src/frontend/src/customization/components/custom-input-file.tsx
src/frontend/src/components/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit Inference Engine (.cursor/rules/frontend_development.mdc)

All components should be styled using Tailwind CSS utility classes.

Files:

  • src/frontend/src/components/core/parameterRenderComponent/index.tsx
src/frontend/src/@(components|hooks)/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit Inference Engine (.cursor/rules/frontend_development.mdc)

Implement dark mode support in components and hooks where needed.

Files:

  • src/frontend/src/components/core/parameterRenderComponent/index.tsx
🧠 Learnings (3)
📓 Common learnings
Learnt from: ogabrielluiz
PR: langflow-ai/langflow#0
File: :0-0
Timestamp: 2025-06-26T19:43:18.260Z
Learning: In langflow custom components, the `module_name` parameter is now propagated through template building functions to add module metadata and code hashes to frontend nodes for better component tracking and debugging.
src/frontend/src/components/core/parameterRenderComponent/index.tsx (11)

Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/frontend_development.mdc:0-0
Timestamp: 2025-07-18T18:27:12.609Z
Learning: Applies to src/frontend/src/**/*.{ts,tsx,js,jsx} : Use React 18 with TypeScript for all UI components in the frontend.

Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/frontend/**/*.@(test|spec).{ts,tsx,js,jsx} : Validate input/output behavior and test component initialization and configuration in frontend test files.

Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/frontend_development.mdc:0-0
Timestamp: 2025-07-18T18:27:12.609Z
Learning: Applies to src/frontend/src/@(components|hooks)/**/*.{ts,tsx,js,jsx} : Implement dark mode support in components and hooks where needed.

Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/frontend_development.mdc:0-0
Timestamp: 2025-07-18T18:27:12.609Z
Learning: Applies to src/frontend/src/components//@(FlowGraph|nodes)//*.{ts,tsx,js,jsx} : Use React Flow for flow graph visualization components.

Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/frontend/**/*.@(test|spec).{ts,tsx,js,jsx} : Mock external dependencies appropriately in frontend test files to isolate unit tests from external services.

Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/frontend_development.mdc:0-0
Timestamp: 2025-06-23T12:46:42.048Z
Learning: Custom React Flow node types should be implemented as memoized components, using Handle components for connection points and supporting optional icons and labels.

Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/icons.mdc:0-0
Timestamp: 2025-06-23T12:46:52.420Z
Learning: Export custom icon components in React using React.forwardRef to ensure proper ref forwarding and compatibility with parent components.

Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/frontend_development.mdc:0-0
Timestamp: 2025-07-18T18:27:12.609Z
Learning: Applies to src/frontend/src/hooks/**/*.{ts,tsx,js,jsx} : All custom React hooks should be placed in the hooks directory.

Learnt from: dolfim-ibm
PR: #8394
File: src/frontend/src/icons/Docling/index.tsx:4-6
Timestamp: 2025-06-16T11:14:04.200Z
Learning: The Langflow codebase consistently uses React.PropsWithChildren<{}> as the prop type for all icon components using forwardRef, rather than React.SVGProps<SVGSVGElement>. This is an established pattern across hundreds of icon files in src/frontend/src/icons/.

Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/frontend_development.mdc:0-0
Timestamp: 2025-07-18T18:27:12.609Z
Learning: Applies to src/frontend/src/icons/**/*.{ts,tsx,js,jsx} : Use Lucide React for icons in the frontend.

Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/frontend_development.mdc:0-0
Timestamp: 2025-07-18T18:27:12.609Z
Learning: Applies to src/frontend/src/components/**/*.{ts,tsx,js,jsx} : All components should be styled using Tailwind CSS utility classes.

src/frontend/src/customization/components/custom-input-file.tsx (10)

Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/frontend_development.mdc:0-0
Timestamp: 2025-07-18T18:27:12.609Z
Learning: Applies to src/frontend/src/**/*.{ts,tsx,js,jsx} : Use React 18 with TypeScript for all UI components in the frontend.

Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/frontend/**/*.@(test|spec).{ts,tsx,js,jsx} : Validate input/output behavior and test component initialization and configuration in frontend test files.

Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/icons.mdc:0-0
Timestamp: 2025-07-28T15:56:47.865Z
Learning: Applies to src/frontend/src/icons/*/index.tsx : Create an index.tsx in your icon directory that exports your icon using forwardRef and passes the isDark prop.

Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/icons.mdc:0-0
Timestamp: 2025-06-23T12:46:52.420Z
Learning: Export custom icon components in React using React.forwardRef to ensure proper ref forwarding and compatibility with parent components.

Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/frontend_development.mdc:0-0
Timestamp: 2025-07-18T18:27:12.609Z
Learning: Applies to src/frontend/src/@(components|hooks)/**/*.{ts,tsx,js,jsx} : Implement dark mode support in components and hooks where needed.

Learnt from: dolfim-ibm
PR: #8394
File: src/frontend/src/icons/Docling/index.tsx:4-6
Timestamp: 2025-06-16T11:14:04.200Z
Learning: The Langflow codebase consistently uses React.PropsWithChildren<{}> as the prop type for all icon components using forwardRef, rather than React.SVGProps<SVGSVGElement>. This is an established pattern across hundreds of icon files in src/frontend/src/icons/.

Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/icons.mdc:0-0
Timestamp: 2025-07-28T15:56:47.865Z
Learning: Applies to src/frontend/src/icons//.@(js|jsx|ts|tsx) : Create a new directory for your icon in src/frontend/src/icons/YourIconName/ and add your SVG as a React component (e.g., YourIconName.jsx). The SVG component must use the isDark prop to support both light and dark mode.

Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/frontend_development.mdc:0-0
Timestamp: 2025-07-18T18:27:12.609Z
Learning: Applies to src/frontend/src/components//@(FlowGraph|nodes)//*.{ts,tsx,js,jsx} : Use React Flow for flow graph visualization components.

Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/frontend_development.mdc:0-0
Timestamp: 2025-07-18T18:27:12.609Z
Learning: Applies to src/frontend/src/hooks/**/*.{ts,tsx,js,jsx} : All custom React hooks should be placed in the hooks directory.

Learnt from: CR
PR: langflow-ai/langflow#0
File: .cursor/rules/frontend_development.mdc:0-0
Timestamp: 2025-07-18T18:27:12.609Z
Learning: Applies to src/frontend/src/components/**/*.{ts,tsx,js,jsx} : All components should be styled using Tailwind CSS utility classes.

🔇 Additional comments (1)
src/frontend/src/components/core/parameterRenderComponent/index.tsx (1)

8-8: Import path looks good

Switching to the new wrapper keeps concerns separated – nice.

Comment on lines +18 to +29
return (
<InputFileComponent
value={value}
file_path={file_path}
handleOnNewValue={handleOnNewValue}
disabled={disabled}
fileTypes={fileTypes}
isList={isList}
tempFile={tempFile}
editNode={editNode}
id={`inputfile_${id}`}
/>
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Double inputfile_ prefix will be produced

ParameterRenderComponent already prefixes the id with inputfile_ before passing it down.
Adding another inputfile_ here results in IDs such as inputfile_inputfile_myfield, breaking CSS selectors and automated tests.

Fix one side (wrapper or caller) to apply the prefix exactly once.
I recommend keeping the prefix logic in this wrapper (as above) and changing the call-site to pass the raw id. See the accompanying diff in parameterRenderComponent.

🤖 Prompt for AI Agents
In src/frontend/src/customization/components/custom-input-file.tsx around lines
18 to 29, the id prop is being prefixed with "inputfile_" although the caller
ParameterRenderComponent already adds this prefix, causing duplicate prefixes
like "inputfile_inputfile_". To fix this, remove the "inputfile_" prefix from
the id in the caller so that this wrapper receives the raw id and applies the
prefix exactly once, ensuring consistent and correct id values.

Copy link
Collaborator

@lucaseduoli lucaseduoli left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions github-actions bot added the lgtm This PR has been approved by a maintainer label Jul 29, 2025
@Cristhianzl Cristhianzl added lgtm This PR has been approved by a maintainer and removed lgtm This PR has been approved by a maintainer labels Jul 29, 2025
@Cristhianzl Cristhianzl enabled auto-merge July 29, 2025 17:55
@github-actions
Copy link
Contributor

Frontend Unit Test Coverage Report

Coverage Summary

Lines Statements Branches Functions
Coverage: 82%
81.44% (373/458) 64.82% (223/344) 67.69% (44/65)

Unit Test Results

Tests Skipped Failures Errors Time
116 0 💤 0 ❌ 0 🔥 3.194s ⏱️

@codecov
Copy link

codecov bot commented Jul 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 52.72%. Comparing base (575cb7f) to head (13565ca).
⚠️ Report is 1 commits behind head on main.

❌ Your project status has failed because the head coverage (52.72%) is below the target coverage (60.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #9233   +/-   ##
=======================================
  Coverage   52.72%   52.72%           
=======================================
  Files         634      634           
  Lines       43605    43605           
  Branches      125      125           
=======================================
  Hits        22991    22991           
  Misses      20564    20564           
  Partials       50       50           
Flag Coverage Δ
frontend 69.41% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Cristhianzl Cristhianzl added this pull request to the merge queue Jul 29, 2025
Merged via the queue into main with commit 96b35e0 Jul 29, 2025
75 of 77 checks passed
@Cristhianzl Cristhianzl deleted the cz/custom-inputFile branch July 29, 2025 18:17
2getsandesh pushed a commit to 2getsandesh/langflow-IBM that referenced this pull request Aug 6, 2025
* ✨ (frontend): introduce CustomInputFileComponent to customize file input component in parameter render component for better flexibility and customization. Remove InputFileComponent from parameter render component and replace it with CustomInputFileComponent.

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
@MustafaDUT
Copy link

With this feature, after version 1.6.0, when we enable the file option in the chat input area, the CustomInputFileComponent will kick in, right? That way, while sending the chat input’s ID with a tweak, we upload the file to Langflow and pass its ID here — in the background, the Docling system will process the file? Did I get that right?

If so, how will we run the Docling process in the background?
If not, could you explain this structure more clearly?
Thank u

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants