Skip to content

fix(ui): fix attachment logic on queued mothership messages - #4191

Merged
TheodoreSpeaks merged 3 commits into
stagingfrom
fix/ui-queueing
Apr 16, 2026
Merged

fix(ui): fix attachment logic on queued mothership messages#4191
TheodoreSpeaks merged 3 commits into
stagingfrom
fix/ui-queueing

Conversation

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator

Summary

Editing queued messages would lose both the attached resource tags and files. Fixed this and added nice ui to display what attachment is used. Also up arrow key now edits the previous queued message.

Also cleaned up some useEffects by switching to a useImperativeHandle to directly add to the user input component.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

  • Tested with lots of resources, lots of attachments, editing when there's multiple queued messages, etc.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Screenshots/Videos

image

@vercel

vercelBot commented Apr 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
ProjectDeploymentActionsUpdated (UTC)
docsSkippedSkippedApr 16, 2026 1:27am

Request Review

@cursor

cursorBot commented Apr 16, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Moderate UI/state refactor around chat input and attachment/context restoration; mistakes could cause regressions in sending/editing queued messages or file attachment payloads.

Overview
Fixes queued-message editing by switching from passing editValue props to an imperative UserInputHandle.loadQueuedMessage() API, so editing a queued item restores its text, selected contexts, and attached files (including path).

Improves the queued-message list preview by rendering context mentions inline (new UserMessageContentplainMentions/className) and showing attached-file info with a responsive paperclip badge. Adds an input shortcut: ArrowUp on an empty composer loads the most recent queued message for editing, and removes now-unneeded edit state plumbing from home.tsx and the workflow panel.tsx.

Reviewed by Cursor Bugbot for commit 5a031ef. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes attachment handling when editing queued Mothership messages by replacing a prop-drilling approach (editValue / onEditValueConsumed) with a forwardRef + useImperativeHandle pattern. The loadQueuedMessage imperative method now correctly restores text content, file attachments, and context mentions together when a queued message is edited. It also adds ArrowUp-to-edit-tail UX and file attachment chips in the queued message list.

Confidence Score: 5/5

Safe to merge — the core bug fix is correct and the refactor is clean; only a P2 UX polish item remains.

All remaining findings are P2 (missing focus / cursor placement after loadQueuedMessage). The bug fix itself — correctly round-tripping fileAttachments and contexts through the queue edit flow — is sound, and the forwardRef/useImperativeHandle approach is cleaner than the previous prop-based pattern.

user-input.tsx — loadQueuedMessage could gain a requestAnimationFrame focus+cursor call for the button-click edit path.

Important Files Changed

FilenameOverview
apps/sim/app/workspace/[workspaceId]/home/components/user-input/user-input.tsxCore refactor: converted to forwardRef with useImperativeHandle; loadQueuedMessage restores text, files, and contexts but does not focus the textarea or position the cursor at the end of the loaded text.
apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/mothership-chat.tsxCorrectly wires the UserInputHandle ref and the handleEditQueued / handleEditQueuedTail callbacks; removes stale editValue prop pair.
apps/sim/app/workspace/[workspaceId]/home/components/queued-messages/queued-messages.tsxAdds file attachment chip display (Paperclip icon + filename + overflow count) and switches plain text to UserMessageContent for context mention rendering in the queue list.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/hooks/use-file-attachments.tsAdds restoreAttachedFiles: properly revokes previous preview URLs before replacing state with a restored set.
apps/sim/app/workspace/[workspaceId]/home/home.tsxRemoves editingInputValue state and related handlers, passing editQueuedMessage directly; clean simplification.
apps/sim/app/workspace/[workspaceId]/home/types.tsAdds optional path field to FileAttachmentForApi so restored attachments can round-trip their storage path.

Sequence Diagram

sequenceDiagram
actor User
participant QM as QueuedMessages
participant MC as MothershipChat
participant UI as UserInput (forwardRef)
participant FA as useFileAttachments
Note over User,FA: Edit via pencil button
User->>QM: click ✏️ on message
QM->>MC: onEdit(id)
MC->>MC: editQueuedMessage(id) → QueuedMessage
MC->>UI: userInputRef.loadQueuedMessage(msg)
UI->>UI: setValue(msg.content)
UI->>FA: restoreAttachedFiles(restored)
FA->>FA: revokeObjectURL(prev previews)
FA->>FA: setAttachedFiles(restored)
UI->>UI: setSelectedContexts(msg.contexts)
Note over User,FA: Edit via ArrowUp key
User->>UI: ArrowUp (input empty)
UI->>MC: onEditQueuedTail()
MC->>MC: tail = messageQueue[last]
MC->>MC: editQueuedMessage(tail.id) → QueuedMessage
MC->>UI: userInputRef.loadQueuedMessage(msg)
UI->>UI: setValue / restoreFiles / setContexts
Loading

Reviews (1): Last reviewed commit: "fix(ui): fix attachment logic on queued ..." | Re-trigger Greptile

@TheodoreSpeaks
TheodoreSpeaks merged commit ba6bc91 into stagingApr 16, 2026
14 checks passed
@TheodoreSpeaks
TheodoreSpeaks deleted the fix/ui-queueing branch April 16, 2026 01:42
Sign up for freeto 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

@TheodoreSpeaks@icecrasher321