Skip to content

fix(chat): copy workspace resources as portable links - #6956

Merged
j15z merged 2 commits into
fix/chat-code-not-copied-inlinefrom
fix/chat-resource-links-copy
Aug 23, 2026
Merged

fix(chat): copy workspace resources as portable links#6956
j15z merged 2 commits into
fix/chat-code-not-copied-inlinefrom
fix/chat-resource-links-copy

Conversation

@j15z

@j15z j15z commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

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

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

Testing

  • 9 copyable-markdown tests passed for resource serialization, spacing, file resolution, refresh, and fallback behavior
  • 3 use-copy-to-clipboard tests passed for immediate, deferred, and fallback clipboard writes
  • bun run type-check passed across all 26 packages
  • bun run lint:check passed across all 26 packages
  • API validation, import specifier, monorepo boundary, React Query, client boundary, and tool-registry boundary checks passed

Reviewers 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

  • 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

Not applicable. The rendered resource chips are unchanged; this PR changes only their clipboard representation.

@vercel

vercel Bot commented Aug 22, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 22, 2026 11:57pm

Request Review

@cursor

cursor Bot commented Aug 22, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches clipboard write behavior and resource-id resolution on copy. Wrong IDs or failed fallbacks could paste broken mentions, but the change is client-only and unresolved files degrade to plain text.

Overview
Copying a chat message now serializes workspace-resource chips as portable [label](sim:kind/id) Markdown so paste reconstructs the same file/table/workflow mention.

Unresolved files stay plain text (never a broken link). If the file list is stale, copy starts immediately with that fallback and, when ClipboardItem is available, refreshes workspace files before writing the real sim:file/… link.

Chip labels with [ / ] / \ are escaped on serialize and unescaped on parse. useCopyToClipboard now accepts deferred clipboard content so the async refresh still happens under user activation.

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

@greptile-apps

greptile-apps Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR makes copied assistant messages preserve workspace resources as portable sim: Markdown links and centralizes delimiter-safe encoding for links shared by chat chips and rich-markdown mentions.

  • Adds workspace-resource resolution and deferred file-metadata refresh during message copy.
  • Extends the shared clipboard hook to support promise-backed clipboard content with an immediate fallback.
  • Consolidates sim: link encoding, decoding, and Markdown-label escaping.
  • Wires workspace identity and file metadata into both full-page and workflow-panel chat surfaces.
  • Adds coverage for resource copying, encoded identifiers, mention round trips, and deferred clipboard writes.

Confidence Score: 5/5

The 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.

Important Files Changed

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
Loading

Reviews (1): Last reviewed commit: "fix(chat): copy workspace resources as p..." | Re-trigger Greptile

@j15z
j15z merged commit bb07925 into staging Aug 23, 2026
29 checks passed
@j15z
j15z deleted the fix/chat-resource-links-copy branch August 23, 2026 00:12
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.

1 participant