fix(platform): restrict file uploads to agent's enabled document tools (#651)#672
Conversation
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
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
📝 WalkthroughWalkthroughThis PR implements file type restrictions for agent test chat uploads based on enabled tools. It introduces shared utility functions ( Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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 | 🟠 MajorDisable drag-and-drop when file uploads are not enabled.
The
FileUpload.DropZonecomponent supports adisabledprop that properly prevents drag-and-drop file handling. Currently, it renders without this prop, allowing users to drag files into the zone even whenfileUploadEnabledisfalse(i.e., when the agent has no document tools).Add the
disabledprop 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
📒 Files selected for processing (5)
services/platform/app/features/custom-agents/components/test-chat-panel.tsxservices/platform/app/features/custom-agents/components/test-chat-panel/test-chat-input.tsxservices/platform/app/features/custom-agents/hooks/use-test-chat.tsservices/platform/lib/shared/__tests__/file-types-tool-mapping.test.tsservices/platform/lib/shared/file-types.ts
Summary
file-types.tswith utility functions that map an agent'stoolNamesto accepted file extensions and MIME typesacceptstring to the test chat file input so the OS file picker only shows supported typesTest plan
Closes #651
Summary by CodeRabbit
Release Notes
New Features
Tests