Skip to content

fix(vue): keep attachment sources structuredClone-safe - #5933

Merged
BenTaylorDev merged 1 commit into
CopilotKit:mainfrom
enekesabel:fix/vue-attachment-structured-clone
Jul 20, 2026
Merged

BenTaylorDev merged 1 commit into
CopilotKit:mainfrom
enekesabel:fix/vue-attachment-structured-clone

Conversation

@enekesabel

@enekesabel enekesabel commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes a Vue DataCloneError that occurred when uploaded attachment sources crossed the structuredClone boundary in core. Vue’s deep ref() conversion wrapped nested attachment sources in reactive proxies; useAttachments now keeps the attachment container shallow with shallowRef(), preserving externally supplied sources as raw cloneable values before they reach AG-UI/core payloads.

The change is intentionally Vue-only: core and React are untouched because the defect is caused by Vue’s reactivity behavior at the framework boundary. Focused regressions cover both the attachment hook and CopilotChat submission path, including non-reactivity and successful structuredClone behavior.

Related PRs and Issues

Verification

  • pnpm nx run @copilotkit/vue:check-types — passed.
  • pnpm nx run @copilotkit/vue:test -- src/v2/hooks/__tests__/use-attachments.test.ts src/v2/components/chat/__tests__/CopilotChat.attachments.test.ts — passed, 18 tests in 2 files.
  • pnpm nx run @copilotkit/vue:build — passed.
  • Pre-commit package gate (test-and-check-packages) — passed: 1073 tests, publint, and attw.
  • pnpm nx run @copilotkit/vue:lint — remains blocked by 171 pre-existing errors across unrelated Vue files; no lint errors were introduced in the changed files.
  • git diff --check upstream/main...HEAD — passed.

Scope and exclusions

  • Changed files are limited to packages/vue/src/v2/hooks/use-attachments.ts, its focused hook and CopilotChat tests, and the related packages/vue/PARITY.md and packages/vue/AGENTS.md guidance.
  • No core, React, workflow, or package-wide lint cleanup is included.
  • The PARITY.md change removes accidental table-format churn and retains only the meaningful attachment parity note.

Checklist

  • I have read the Contribution Guide
  • If the PR changes or adds functionality, I have updated the relevant documentation
  • "Allow edits by maintainers" is checked (lets us help iterate on your PR directly — faster turnaround for everyone)

@enekesabel
enekesabel force-pushed the fix/vue-attachment-structured-clone branch from fc2b2d6 to 4f29932 Compare July 13, 2026 09:35
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

An error occurred during the review process. Please try again later.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@enekesabel
enekesabel marked this pull request as ready for review July 13, 2026 09:38
@NathanTarbert

NathanTarbert commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

ref → shallowRef on attachments stops the proxy wrapping before it ever happens, so nested fields never end up reactive either. Traced the other consumer (CopilotChat.vue) to make sure nothing bypasses it, looks fine.

Tests actually call the real structuredClone, not a mock, so they'd catch a regression.

@BenTaylorDev

Copy link
Copy Markdown
Contributor

Adversarial review — verdict: MERGE-WORTHY

I reviewed this against current main (branch is 260 commits behind but has zero drift on the touched file — merge-base is byte-identical to current main) and tried to break the fix from several angles. It held up, and the underlying bug is empirically confirmed.

Mechanism confirmed empirically. Running both paths against the workspace [email protected]:

  • deep ref() → attachment.source is a reactive Proxy → structuredClone throws DOMException: … could not be cloned.
  • shallowRef() → source stays raw → clones cleanly.

So the DataCloneError is real and this fixes it. The test assertions (isProxy === false, structuredClone(...).not.toThrow()) are valid regression guards — a revert to ref() would flip isProxy to true and re-throw, failing them.

What I checked:

  • ✅ No reactivity regression from shallowRef — all updates go through setAttachments/updateAttachments, which replace the array immutably ([...previous]/.map/.filter), never mutate in place.
  • ✅ Complete across sites — both Attachment[] containers converted; no other ref<Attachment[]> in the package; CopilotChat.vue reads attachment.source at submission with no downstream re-wrap.
  • ✅ Integration test mounts the real CopilotChat.vue and exercises the real submission path.
  • ✅ Scope is clean (fix + focused tests + germane PARITY/AGENTS docs).

@pkg-pr-new

pkg-pr-new Bot commented Jul 20, 2026

Copy link
Copy Markdown

Open in StackBlitz

@copilotkit/a2ui-renderer

pnpm add https://pkg.pr.new/@copilotkit/a2ui-renderer@5933

@copilotkit/agentcore-runner

pnpm add https://pkg.pr.new/@copilotkit/agentcore-runner@5933

@copilotkit/angular

pnpm add https://pkg.pr.new/@copilotkit/angular@5933

@copilotkit/channels

pnpm add https://pkg.pr.new/@copilotkit/channels@5933

@copilotkit/channels-discord

pnpm add https://pkg.pr.new/@copilotkit/channels-discord@5933

@copilotkit/channels-intelligence

pnpm add https://pkg.pr.new/@copilotkit/channels-intelligence@5933

@copilotkit/channels-slack

pnpm add https://pkg.pr.new/@copilotkit/channels-slack@5933

@copilotkit/channels-teams

pnpm add https://pkg.pr.new/@copilotkit/channels-teams@5933

@copilotkit/channels-telegram

pnpm add https://pkg.pr.new/@copilotkit/channels-telegram@5933

@copilotkit/channels-ui

pnpm add https://pkg.pr.new/@copilotkit/channels-ui@5933

@copilotkit/channels-whatsapp

pnpm add https://pkg.pr.new/@copilotkit/channels-whatsapp@5933

@copilotkit/core

pnpm add https://pkg.pr.new/@copilotkit/core@5933

@copilotkit/react-core

pnpm add https://pkg.pr.new/@copilotkit/react-core@5933

@copilotkit/react-native

pnpm add https://pkg.pr.new/@copilotkit/react-native@5933

@copilotkit/react-textarea

pnpm add https://pkg.pr.new/@copilotkit/react-textarea@5933

@copilotkit/react-ui

pnpm add https://pkg.pr.new/@copilotkit/react-ui@5933

@copilotkit/runtime

pnpm add https://pkg.pr.new/@copilotkit/runtime@5933

@copilotkit/runtime-client-gql

pnpm add https://pkg.pr.new/@copilotkit/runtime-client-gql@5933

@copilotkit/sdk-js

pnpm add https://pkg.pr.new/@copilotkit/sdk-js@5933

@copilotkit/shared

pnpm add https://pkg.pr.new/@copilotkit/shared@5933

@copilotkit/sqlite-runner

pnpm add https://pkg.pr.new/@copilotkit/sqlite-runner@5933

@copilotkit/voice

pnpm add https://pkg.pr.new/@copilotkit/voice@5933

@copilotkit/vue

pnpm add https://pkg.pr.new/@copilotkit/vue@5933

@copilotkit/web-components

pnpm add https://pkg.pr.new/@copilotkit/web-components@5933

@copilotkit/web-inspector

pnpm add https://pkg.pr.new/@copilotkit/web-inspector@5933

commit: 4f29932

@BenTaylorDev
BenTaylorDev merged commit 7fb0abf into CopilotKit:main Jul 20, 2026
34 checks passed
@enekesabel
enekesabel deleted the fix/vue-attachment-structured-clone branch July 21, 2026 06:59
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.

3 participants