Repository navigation
fix: restore download button when file type is selected in agent message - #17184
Conversation
When an agent Message component has file type checkboxes enabled, the backend emits attachment/download info via message_end events, but the SSE relay filters workflow_finished outputs (keeping only usage). The frontend previously read attachments solely from workflow_finished, causing the download button to disappear. Changes: - Extend IMessageEndData interface to support attachment and downloads - Fall back to reading attachment/downloads from the last message_end event when workflow_finished.outputs is unavailable - Include downloads in _build_message_end on the Python backend side - Remove stale commented-out attachment download code from next-message-item
📝 WalkthroughWalkthroughMessage-end payloads now include non-empty downloads. Frontend message-end data makes related fields optional, and agent message reconstruction falls back to the latest message-end event when workflow outputs lack attachment or download data. Obsolete commented download UI code was removed. ChangesMessage download propagation
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
web/src/pages/agent/chat/use-send-agent-message.ts (1)
86-88: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueUse
findLastto avoid unnecessary array cloning and reversing.Cloning and reversing the
eventListarray incurs unnecessary memory allocation and time complexity. Please consider using Lodash'sfindLast(or nativeArray.prototype.findLastif the compilation target supports it). As per coding guidelines, use Lodash for general utility operations when appropriate.♻️ Proposed refactor using Lodash
First, add the import at the top of the file:
import findLast from 'lodash/findLast';Then apply the fix:
- const messageEndEvent = [...eventList] - .reverse() - .find((x) => x.event === MessageEventType.MessageEnd) as IMessageEndEvent; + const messageEndEvent = findLast( + eventList, + (x) => x.event === MessageEventType.MessageEnd + ) as IMessageEndEvent;🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@web/src/pages/agent/chat/use-send-agent-message.ts` around lines 86 - 88, Update the messageEndEvent lookup in the send-agent message flow to use Lodash’s findLast (adding its import) instead of cloning eventList with spread and reverse. Preserve the existing MessageEventType.MessageEnd predicate and IMessageEndEvent cast.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@web/src/pages/agent/chat/use-send-agent-message.ts`:
- Around line 86-88: Update the messageEndEvent lookup in the send-agent message
flow to use Lodash’s findLast (adding its import) instead of cloning eventList
with spread and reverse. Preserve the existing MessageEventType.MessageEnd
predicate and IMessageEndEvent cast.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b7d3b99c-4fee-4ef9-bcca-05cc847bf525
📒 Files selected for processing (4)
agent/canvas.pyweb/src/components/next-message-item/index.tsxweb/src/hooks/use-send-message.tsweb/src/pages/agent/chat/use-send-agent-message.ts
💤 Files with no reviewable changes (1)
- web/src/components/next-message-item/index.tsx
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #17184 +/- ##
==========================================
- Coverage 94.56% 90.65% -3.91%
==========================================
Files 10 10
Lines 717 717
Branches 118 118
==========================================
- Hits 678 650 -28
- Misses 25 39 +14
- Partials 14 28 +14 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
wangq8
left a comment
There was a problem hiding this comment.
LGTM. Multi-layer fix is well-coordinated: backend adds downloads to message_end, frontend falls back to reading attachment/downloads from the last message_end event when workflow_finished outputs are unavailable, and stale commented-out code is cleaned up. The fallback chain in findMessageFromList is correctly ordered.
Summary
When an agent Message component has file type checkboxes enabled (e.g., Markdown), the backend emits attachment and download information via
message_endevents. However, the SSE relay in agent chat sessions filtersworkflow_finishedoutputs (keeping onlyusage), and the frontend previously read attachments solely fromworkflow_finished, causing the download button to disappear even when file types were correctly configured.Changes
use-send-message.ts): ExtendIMessageEndDatainterface to supportattachmentanddownloadsfieldsuse-send-agent-message.ts): Fall back to readingattachment/downloadsfrom the lastmessage_endevent whenworkflow_finished.outputsis unavailablecanvas.py): Includedownloadsin_build_message_endso they survive the SSE relay that strips outputs fromworkflow_finishednext-message-item/index.tsx): Remove stale commented-out attachment download code