Skip to content

Conversation

usnavy13
Copy link
Contributor

@usnavy13 usnavy13 commented Sep 7, 2025

Summary

Fix agent-specific gating for file upload options in Chat:

  • Attach menu and drag-and-drop now correctly show only the options enabled for the selected agent’s tools and endpoint capabilities.
  • Image upload (and OCR, when enabled) remains available even if Run Code or File Search are disabled.
  • On refresh or when switching agents, options no longer flash incorrectly or disappear; we now fetch the selected agent via useGetAgentByIdQuery and gate once tools are known.

Closes: #9497

Updated files:

  • client/src/components/Chat/Input/Files/AttachFileMenu.tsx

  • client/src/components/Chat/Input/Files/DragDropModal.tsx

  • client/src/hooks/Files/useDragHelpers.ts

  • client/src/components/Chat/Input/Files/DragDropWrapper.tsx

  • client/vite.config.ts : This PR addresses the windows frontend test build failure using the same vite.config.tsx changes used in an earlier PR ✨ feat(agents): persist Marketplace agents via per-user Favorites in Model dropdown #9488 If there’s a preferred alternative, I'm happy to make changes.

No backend changes.

Change Type

  • Bug fix (non-breaking change which fixes an issue)

Testing

Steps:

  1. Create three agents with different tool configurations:
    • A: Run Code only
    • B: File Search only
    • C: Neither (OCR enabled/disabled as desired)
  2. For each agent, open a chat:
    • Paperclip menu shows:
      • A: “Upload Code Files”, Image, OCR (if enabled); no “Upload for File Search”.
      • B: “Upload for File Search”, Image, OCR (if enabled); no “Upload Code Files”.
      • C: Image only (and OCR if enabled).
  3. Drag-and-drop:
    • Images always prompt Image (and OCR if enabled).
    • Non-image files only show options allowed by the agent’s tools; otherwise upload falls back or shows no tool-specific options.
  4. Refresh the page and revisit each agent:
    • Options remain correct (no “show everything” on load).
  5. Switch between agents without saving:
    • Options update to the newly selected agent accurately.
  6. Toggle agent tools in the builder and Save:
    • Options reflect the new settings immediately.

Checklist

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • I have commented in any complex areas of my code
  • My changes do not introduce new warnings
  • Local unit tests pass with my changes
image image image

* Integrated agent-specific checks for file search and code execution capabilities in AttachFileMenu and DragDropModal components.
* Updated useDragHelpers to conditionally show modal based on agent permissions for file search and code execution.
* Improved handling of agent tools to ensure proper functionality based on selected agent's capabilities.
* Updated Vite configuration to normalize paths for better chunking logic.
* Refactored AttachFileMenu, DragDropModal, and useDragHelpers to streamline agent tool checks for file search and code execution capabilities.
* Improved readability and maintainability of the code by consolidating conditional logic for agent permissions.
…ropModal

* Streamlined the logic for retrieving agent tools in AttachFileMenu and DragDropModal components for improved readability.
* Removed unnecessary line breaks to enhance code clarity while maintaining functionality.
…nu and DragDropModal

* Added a line break for improved code readability in AttachFileMenu and DragDropModal components.
* Maintained existing functionality while enhancing the clarity of the code structure.
@usnavy13 usnavy13 closed this Sep 7, 2025
@usnavy13 usnavy13 reopened this Sep 7, 2025
* Added line breaks to enhance readability of the agent tool retrieval logic in AttachFileMenu and DragDropModal components.
* Maintained existing functionality while improving code clarity.
@usnavy13 usnavy13 marked this pull request as ready for review September 7, 2025 19:34
@danny-avila
Copy link
Owner

Thanks for the PR, please see my comments if you can address them. If not, I can address them soon.

@danny-avila danny-avila marked this pull request as draft September 8, 2025 18:44
@danny-avila
Copy link
Owner

@usnavy13 I moved the vite part to its own PR since it was affecting other PRs in progress, thanks for your input here

#9513

… Tool Checks

* Refactored chunking logic in vite.config.ts to remove unnecessary normalization of module paths.
* Updated DragDropModal and useDragHelpers to utilize useMemo for agent tool checks, improving performance and readability.
* Enhanced dependency tracking in DragDropModal options to include new memoized values.
* Removed unnecessary boolean checks in agent tool retrieval logic for improved readability.
* Maintained existing functionality while streamlining the code structure.
@usnavy13 usnavy13 closed this Sep 8, 2025
@usnavy13 usnavy13 reopened this Sep 8, 2025
@usnavy13
Copy link
Contributor Author

usnavy13 commented Sep 8, 2025

Thanks for the PR, please see my comments if you can address them. If not, I can address them soon.

Thanks for the fast review! Just updated to use bools and useMemo

@usnavy13 usnavy13 marked this pull request as ready for review September 8, 2025 21:00
@danny-avila
Copy link
Owner

Thanks for looking into this, I had to clean up some of the code and wanted to get this in so completed here: #9532

@danny-avila danny-avila closed this Sep 9, 2025
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.

2 participants