Skip to content

Use host FileDropZone for agent chat drag-and-drop - #1267

Open
crspeller wants to merge 4 commits into
masterfrom
cursor/agent-chat-file-drop-4781
Open

crspeller wants to merge 4 commits into
masterfrom
cursor/agent-chat-file-drop-4781

Conversation

@crspeller

@crspeller crspeller commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Summary

Switches AgentChatDropZone in the Agents product view and RHS to delegate to the host's published window.WebappUtils.components.FileDropZone (shipped in Mattermost 12.3, with ZoneShell owning the plugin's flex layout), while keeping LegacyAgentChatDropZone as a fallback on Mattermost servers prior to 12.3.

Split out from #1230 as an independent PR. Pairs with mattermost/mattermost#40531.

Changes

  • Uses window.WebappUtils.components.FileDropZone when available (Mattermost 12.3+), delegating drag-and-drop and upload-policy enforcement to the host FileUpload.
  • Retains LegacyAgentChatDropZone (and HOST_COMPOSER_FILE_INPUT_SELECTOR) on servers prior to 12.3, with inline comments noting they can be removed once min_server_version moves past 12.3.
  • Covers both the 12.3+ host FileDropZone path and the <12.3 fallback in unit tests (agent_chat_page.test.tsx) and Playwright specs (agents-product-view.spec.ts, file-upload-drag-drop.spec.ts) without skipping CI tests.

Release Note

Switched Agents chat drag-and-drop file uploads to use the host's published FileDropZone component on Mattermost 12.3+, keeping the existing drop-zone fallback on older servers.
Open in Web Open in Cursor 

Summary by CodeRabbit

  • New Features
    • File drag-and-drop areas use the host application’s shared drop experience when available, with overlays positioned for agent chat and the side panel.
    • On hosts without the shared experience, file drag-and-drop continues to work through the existing fallback.
  • Bug Fixes
    • Drop overlays now appear when files are dragged into supported areas and clear after the files are dropped.

Co-authored-by: Christopher Speller <crspeller@users.noreply.github.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-01T16:36:18.644575Z 1cd1e20 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

AgentChatDropZone now uses the host FileDropZone when available and retains a legacy fallback. Agent chat and RHS set overlay placement. Unit and E2E tests cover host and fallback behaviour.

Changes: Host File Drop Zone Delegation

Layer / File(s) Summary
Host component contract and delegation
webapp/src/types/mattermost-webapp/index.d.ts, webapp/src/components/agent_chat/agent_chat_drop_zone.tsx, webapp/src/components/agent_chat/agent_chat_host_styles.ts
WebappUtils now optionally exposes FileDropZone. AgentChatDropZone passes the host component its className and overlayType when available. Otherwise, it renders LegacyAgentChatDropZone. The legacy drag-leave handler checks for file data and non-zero drag depth.
Overlay placement and path validation
webapp/src/components/agents/agent_chat_page.tsx, webapp/src/components/rhs/rhs.tsx, webapp/src/components/agents/agent_chat_page.test.tsx, e2e/tests/agents/agents-product-view.spec.ts, e2e/tests/rhs-core/file-upload-drag-drop.spec.ts, webapp/tests/fake_advanced_text_editor.tsx
Agent chat sets a centred overlay, and RHS sets a right overlay. Unit and E2E tests cover host availability, overlay visibility, and file forwarding through the legacy fallback.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AgentChatPage
  participant AgentChatDropZone
  participant WebappUtils
  participant FileDropZone
  participant LegacyAgentChatDropZone
  AgentChatPage->>AgentChatDropZone: Render with children and overlayType
  AgentChatDropZone->>WebappUtils: Check components.FileDropZone
  alt FileDropZone is available
    AgentChatDropZone->>FileDropZone: Render with className, overlayType, and children
  else FileDropZone is unavailable
    AgentChatDropZone->>LegacyAgentChatDropZone: Render with legacy drop handling
  end
Loading

Possibly related PRs

Merge Risk: Minimal · up to 9f670

Agent chat drag-and-drop now uses the host file drop zone on servers that provide it and keeps the legacy behavior on older servers. No concrete merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "Use host FileDropZone for agent chat drag-and-drop" matches the main change. The PR switches the Agents product view and RHS to the host's published window.WebappUtils.components.FileDropZo…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "Use host FileDropZone for agent chat drag-and-drop" matches the main change. The PR switches the Agents product view and RHS to the host's published window.WebappUtils.components.FileDropZone on Mattermost 12.3+. The diff adds the FileDropZone type declaration, updates AgentChatDropZone to delegate to the host component, and updates the unit and Playwright tests for both host and legacy paths. The title is specific and does not describe unrelated work. It does not mention the legacy fallback, but that detail is secondary.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: QUIET
  • Plan: Essentials
  • Run ID: ffe857a4-174d-4cd8-8154-802dd4f7e371
Commits

Reviewing files that changed from the base of the PR and between 2e58846 and 9f670ac.

Files selected for processing: 4

  • e2e/tests/agents/agents-product-view.spec.ts
  • e2e/tests/rhs-core/file-upload-drag-drop.spec.ts
  • webapp/src/components/agent_chat/agent_chat_drop_zone.tsx
  • webapp/src/components/agents/agent_chat_page.test.tsx

Included review availability: This review used your included allowance. 1 included review remains after this review. Your included PR review attempts over the past 7 days set your current allowance at 4 reviews per hour.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

… clean up tests

Co-authored-by: Christopher Speller <crspeller@users.noreply.github.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 254f5ef. Configure here.

… on both host versions

Co-authored-by: Christopher Speller <crspeller@users.noreply.github.com>
…Ds during RHS transitions

Co-authored-by: Christopher Speller <crspeller@users.noreply.github.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Risk: medium. Approved. Cursor Bugbot and Cursor Security Agent completed successfully with no unresolved findings that need human review.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver

This branch has not been deployed

No deployments
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