Skip to content

feat(paste): arbitrate clipboard text, HTML and images as one paste - #486

Merged
mtskf merged 10 commits into
mainfrom
chore/paste-03-clipboard-arbitration
Nov 10, 2026
Merged

mtskf merged 10 commits into
mainfrom
chore/paste-03-clipboard-arbitration

Conversation

@mtskf

@mtskf mtskf commented Nov 10, 2026

Copy link
Copy Markdown
Owner

Summary

Clipboard text, HTML and image files are now arbitrated as one paste operation. A paste that carries a caption, table or rich content together with files inserts the text and every accepted image link in a single undoable transaction, at the original target, in clipboard order.

Changes

  • src/webview/cm/paste/paste-operation.ts (new): a pure StateField holds pending-operation metadata (id, mapped target, cancelled). A per-editor coordinator owns file reads, reply slots, deadlines, notices and the final dispatch.
  • src/webview/cm/paste/clipboard-paste.ts (new): one DOM paste entry snapshots the clipboard. It applies text decisions with table → URL → list → rich → plain precedence, then registers the operation before any I/O.
  • The table, URL, list-reindent and rich-HTML transforms now return {from, to, render} decisions instead of dispatching themselves. Image paste feeds the coordinator.
  • Removed the legacy pending-anchor paths and the per-feature paste handlers.
  • Settlement re-checks write capability and CM read-only state. If the document went read-only, nothing is inserted and any written but unlinked files are logged.
  • A successful undo or redo while a paste is pending cancels that paste, so Redo is preserved. Caret moves keep the original target.
  • Insertion failure appears in the existing notice slot and never pre-empts a stronger notice.
  • The browser suite serves a fresh in-memory production webview bundle and pins the production paths in real Chromium.

Related TODO

PASTE-03 PR1. Explicit plain paste (Cmd/Ctrl+Shift+V routing) is deferred to PASTE-03 PR2. Post-commit sync visibility is tracked as SYNC-01.

Test plan

  • pnpm compile
  • pnpm test:unit: 289 files, 6164 tests
  • pnpm test:browser: 17 files, 92 tests
  • pnpm lint
  • Revert-checks for the 10 production browser pins. Each goes red under its targeted mutation and green once restored.
  • pnpm package and the vsix audit, plus a local install

🤖 Generated with Claude Code

https://claude.ai/code/session_01XMxzpbtpRHCeu7iKdR8Yc9

mtskf added 10 commits November 10, 2026 08:10
…etadata

Split table/URL/list/rich paste into pure decisions returning a
replacement range plus render, and add the immutable pending-operation
StateField (mapping, conflict cancellation, history/reseed cancel,
delegated-paste supersession). Not yet wired into production.
Verify registration before any I/O, settle File slots in clipboard
order, compose one replacement, and dispatch the filtered transaction
once; filter vetoes, deadlines and dispose terminate the operation
without inserting.
Extract File transport behind a temporary legacy adapter, capture every
obtainable File candidate, and route table/URL/list/rich decisions
through the coordinator with live URL-syntax revalidation.
Rich code-context fallback, caption-on-rejection and pre/post-commit
failure handling: an empty composed replacement terminates the
operation without deleting the selection, and an adopted insertion is
never retried.
Remove the legacy pending-anchor paths, guard settlement against a
read-only flip, and surface insertion failures in the notice slot.
Serve a fresh production webview bundle to the browser suite and pin
table/File, reply order, captions, undo, selection, CRLF, read-only and
plain paste against it.
…nt of metadata cleanup

Bind and log the causes of the bare catches in the coordinator and the image transport, run clearMetadata through a non-throwing helper so onUnlinkedPath/onFailure always fire, ignore a reader load after cancel, and pin the lost-operation arm and cancel closure.
@mtskf
mtskf merged commit 7c88142 into main Nov 10, 2026
2 checks passed
@mtskf
mtskf deleted the chore/paste-03-clipboard-arbitration branch November 10, 2026 00:30
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