fix(chat): copy workspace resources as portable links - #6956
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Unresolved files stay plain text (never a broken link). If the file list is stale, copy starts immediately with that fallback and, when Chip labels with Reviewed by Cursor Bugbot for commit e7ffc07. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryThe PR makes copied assistant messages preserve workspace resources as portable
Confidence Score: 5/5The PR appears safe to merge, with no concrete changed-code failure or security issue identified. The portable-link codec round-trips encoded identifiers consistently, unresolved file metadata has an explicit refresh and plain-text fallback path, and both chat surfaces provide the workspace identity needed by the copy flow.
|
| Filename | Overview |
|---|---|
| apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/copyable-markdown.ts | Resolves structured workspace-resource tags into portable links and defers copying when file metadata must be refreshed. |
| packages/emcn/src/hooks/use-copy-to-clipboard.ts | Adds a deferred clipboard-content contract while preserving immediate string-copy behavior and fallback support. |
| apps/sim/lib/copilot/sim-link.ts | Centralizes encoding and decoding of portable resource identifiers and Markdown labels. |
| apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/chip-clipboard-codec.ts | Adopts the shared link codec so copied and pasted chips safely round-trip delimiter-bearing identifiers. |
| apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/mention/mention-node.ts | Uses the shared codec for rich-editor mention parsing, rendering, and input-rule conversion. |
| apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/mothership-chat.tsx | Supplies workspace metadata and query-backed refresh callbacks to assistant-message copy actions. |
Sequence Diagram
sequenceDiagram
participant U as User
participant A as MessageActions
participant S as Resource serializer
participant Q as Workspace-file query
participant C as Clipboard API
U->>A: Click Copy
A->>S: Prepare message Markdown
alt All resources resolve
S-->>A: Portable sim: Markdown
A->>C: writeText(markdown)
else File metadata is unresolved
S-->>A: Deferred content + plain-text fallback
A->>C: write ClipboardItem immediately
C->>Q: Resolve promised text
Q-->>C: Refreshed portable Markdown
end
Reviews (1): Last reviewed commit: "fix(chat): copy workspace resources as p..." | Re-trigger Greptile
Summary
Copying an assistant message now serializes rendered workspace-resource tags as portable Sim Markdown links (
[label](sim:type/id)). Pasting those links back into Sim reconstructs the corresponding file, table, or workflow chip instead of losing the resource reference.Files that only have a path are resolved from the workspace-file cache. If a file is not cached, the copy operation refreshes that query while preserving clipboard user activation; if it still cannot be resolved, the visible label is copied as safe plain text. Portable chip labels also escape and restore Markdown-sensitive characters.
This is the second PR in the stack and depends on #6903, which provides orchestrator-only Markdown copying. There are no visual changes.
Type of Change
Testing
copyable-markdowntests passed for resource serialization, spacing, file resolution, refresh, and fallback behavioruse-copy-to-clipboardtests passed for immediate, deferred, and fallback clipboard writesbun run type-checkpassed across all 26 packagesbun run lint:checkpassed across all 26 packagesReviewers should focus on escaped resource labels, path-only files that require a copy-time metadata refresh, and the plain-text fallback for unresolved files.
Checklist
Screenshots/Videos
Not applicable. The rendered resource chips are unchanged; this PR changes only their clipboard representation.