Skip to content

fix(platform): restrict file uploads to agent's enabled document tools (#651)#672

Merged
Israeltheminer merged 2 commits into
mainfrom
fix/651-file-upload-tool-restrictions
Mar 4, 2026
Merged

fix(platform): restrict file uploads to agent's enabled document tools (#651)#672
Israeltheminer merged 2 commits into
mainfrom
fix/651-file-upload-tool-restrictions

Conversation

@Israeltheminer
Copy link
Copy Markdown
Collaborator

@Israeltheminer Israeltheminer commented Mar 4, 2026

Summary

  • Adds file-types.ts with utility functions that map an agent's toolNames to accepted file extensions and MIME types
  • Passes the filtered accept string to the test chat file input so the OS file picker only shows supported types
  • Hides the attach button entirely when the agent has no document tools configured

Test plan

  • Agent with no document tools → attach button is hidden
  • Agent with only text tools → file picker accepts text files only
  • Attempting to upload an unsupported type via drag-and-drop is rejected

Closes #651

Summary by CodeRabbit

Release Notes

  • New Features

    • File uploads in the chat interface now dynamically enable based on custom agent capabilities and tool configuration.
    • File upload inputs intelligently filter to accepted file types per agent's enabled tools.
  • Tests

    • Added comprehensive test coverage for file type and tool mapping utilities.

The test chat file picker allowed all file types regardless of which
document tools the agent had enabled. Add utility functions that map
agent toolNames to accepted file extensions and MIME types, pass the
filtered accept string to the file input, and hide the attach button
when no document tools are configured.

Closes #651
Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 4, 2026

📝 Walkthrough

Walkthrough

This PR implements file type restrictions for agent test chat uploads based on enabled tools. It introduces shared utility functions (getAcceptForTools, getAllowedMimeTypesForTools, hasFileTools) that map tool names to accepted file extensions and MIME types. The useTestChat hook is updated to derive file upload capabilities from the current agent's tools and expose these as fileUploadEnabled and fileAccept. These values are then propagated through TestChatPanelContent to TestChatInput, which conditionally renders the file upload UI only when the agent has enabled file-supporting tools. Comprehensive test coverage is added for the new utility functions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: restricting file uploads based on the agent's enabled document tools.
Linked Issues check ✅ Passed The PR fully addresses the linked issue #651 by implementing tool-based file restriction through utility functions that map toolNames to accepted file types.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing file upload restrictions based on agent tools, with no out-of-scope modifications.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/651-file-upload-tool-restrictions

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@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.

Caution

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

⚠️ Outside diff range comments (1)
services/platform/app/features/custom-agents/components/test-chat-panel/test-chat-input.tsx (1)

75-78: ⚠️ Potential issue | 🟠 Major

Disable drag-and-drop when file uploads are not enabled.

The FileUpload.DropZone component supports a disabled prop that properly prevents drag-and-drop file handling. Currently, it renders without this prop, allowing users to drag files into the zone even when fileUploadEnabled is false (i.e., when the agent has no document tools).

Add the disabled prop to prevent this bypass:

Fix
         <FileUpload.DropZone
           className="border-muted mx-2 shrink-0 rounded-t-3xl border-8 border-b-0"
           onFilesSelected={uploadFiles}
           clickable={false}
+          disabled={!fileUploadEnabled}
         >
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@services/platform/app/features/custom-agents/components/test-chat-panel/test-chat-input.tsx`
around lines 75 - 78, The DropZone currently allows drag-and-drop even when
uploads are not allowed; update the FileUpload.DropZone component (where
FileUpload.DropZone is rendered with onFilesSelected={uploadFiles} and
clickable={false}) to pass the disabled prop tied to the fileUploadEnabled flag
(e.g., disabled={!fileUploadEnabled}) so drag-and-drop is prevented when file
uploads are not enabled.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In
`@services/platform/app/features/custom-agents/components/test-chat-panel/test-chat-input.tsx`:
- Around line 75-78: The DropZone currently allows drag-and-drop even when
uploads are not allowed; update the FileUpload.DropZone component (where
FileUpload.DropZone is rendered with onFilesSelected={uploadFiles} and
clickable={false}) to pass the disabled prop tied to the fileUploadEnabled flag
(e.g., disabled={!fileUploadEnabled}) so drag-and-drop is prevented when file
uploads are not enabled.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 58070f0e-4217-4cf8-b858-6474f7e7a0a8

📥 Commits

Reviewing files that changed from the base of the PR and between add230e and 2989d2a.

📒 Files selected for processing (5)
  • services/platform/app/features/custom-agents/components/test-chat-panel.tsx
  • services/platform/app/features/custom-agents/components/test-chat-panel/test-chat-input.tsx
  • services/platform/app/features/custom-agents/hooks/use-test-chat.ts
  • services/platform/lib/shared/__tests__/file-types-tool-mapping.test.ts
  • services/platform/lib/shared/file-types.ts

@Israeltheminer Israeltheminer merged commit e348f0a into main Mar 4, 2026
16 checks passed
@Israeltheminer Israeltheminer deleted the fix/651-file-upload-tool-restrictions branch March 4, 2026 20:20
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.

Bug: Agent allows unsupported file types despite tool restrictions

1 participant