feat: add Copy, Paste, Select All commands to Edit menu#8954
feat: add Copy, Paste, Select All commands to Edit menu#8954christian-byrne merged 3 commits intoComfy-Org:mainfrom
Conversation
Add standard clipboard commands to the Edit menu for mobile/touch users and accessibility. Uses LiteGraph internal clipboard. Fixes Comfy-Org#2892 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
📝 WalkthroughWalkthroughAdds three canvas commands— Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
|
Playwright: ✅ 510 passed, 0 failed · 8 flaky 📊 Browser Reports
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/composables/useCoreCommands.test.ts (1)
315-320: Redundant individualmockClear()calls — the outerbeforeEachalready handles this.The outer
beforeEachat line 233 callsvi.clearAllMocks(), which resets call history on all mock functions, includingcopyToClipboard,pasteFromClipboard, andselectItems. Lines 317–319 are therefore no-ops; only theselectedItemsreset at line 316 is uniquely necessary.♻️ Proposed simplification
beforeEach(() => { app.canvas.selectedItems = new Set() - vi.mocked(app.canvas.copyToClipboard).mockClear() - vi.mocked(app.canvas.pasteFromClipboard).mockClear() - vi.mocked(app.canvas.selectItems).mockClear() })🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/composables/useCoreCommands.test.ts` around lines 315 - 320, In the beforeEach block that resets state for tests, remove the redundant vi.mocked(...).mockClear() calls for app.canvas.copyToClipboard, app.canvas.pasteFromClipboard, and app.canvas.selectItems because the outer beforeEach already calls vi.clearAllMocks(); keep only the unique reset of app.canvas.selectedItems (and any other non-mock resets) in this beforeEach to simplify the test setup.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/composables/useCoreCommands.test.ts`:
- Around line 344-348: The test for the 'Comfy.Canvas.SelectAll' command is only
asserting that app.canvas.selectItems was called; update the assertion to verify
the actual arguments passed so the test fails if selectItems is invoked as a
no-op. After invoking findCommand('Comfy.Canvas.SelectAll').function(), assert
that app.canvas.selectItems was called with the expected selection array (e.g.,
the ids of app.canvas.items) by comparing to app.canvas.items.map(item =>
item.id) or using an array matcher like expect.any(Array) plus a length check;
reference the selectItems call and the SelectAll command invocation when making
the change.
In `@src/composables/useCoreCommands.ts`:
- Around line 888-890: Replace raw label string literals in the command
definitions with vue-i18n lookups using the imported t() function: add keys
"canvas.copySelected", "canvas.pasteFromClipboard", and "canvas.selectAll" to
src/locales/en/main.json (values "Copy", "Paste", "Select All"), then update the
label fields for the commands with ids 'Comfy.Canvas.CopySelected',
'Comfy.Canvas.PasteFromClipboard', and 'Comfy.Canvas.SelectAll' to use
t('canvas.copySelected'), t('canvas.pasteFromClipboard'), and
t('canvas.selectAll') respectively (t is already imported at the top of
useCoreCommands.ts).
---
Nitpick comments:
In `@src/composables/useCoreCommands.test.ts`:
- Around line 315-320: In the beforeEach block that resets state for tests,
remove the redundant vi.mocked(...).mockClear() calls for
app.canvas.copyToClipboard, app.canvas.pasteFromClipboard, and
app.canvas.selectItems because the outer beforeEach already calls
vi.clearAllMocks(); keep only the unique reset of app.canvas.selectedItems (and
any other non-mock resets) in this beforeEach to simplify the test setup.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
📦 Bundle: 4.27 MB gzip 🟢 -47.2 kBDetailsSummary
Category Glance App Entry Points — 21.7 kB (baseline 21.4 kB) • 🔴 +329 BMain entry bundles and manifests
Status: 1 added / 1 removed Graph Workspace — 914 kB (baseline 936 kB) • 🟢 -21.7 kBGraph editor runtime, canvas, workflow orchestration
Status: 1 added / 1 removed Views & Navigation — 69 kB (baseline 68.6 kB) • 🔴 +475 BTop-level views, pages, and routed surfaces
Status: 11 added / 11 removed Panels & Settings — 427 kB (baseline 430 kB) • 🟢 -3.25 kBConfiguration panels, inspectors, and settings screens
Status: 22 added / 22 removed User & Accounts — 16.1 kB (baseline 16 kB) • 🔴 +158 BAuthentication, profile, and account management bundles
Status: 7 added / 7 removed Editors & Dialogs — 785 B (baseline 706 B) • 🔴 +79 BModals, dialogs, drawers, and in-app editors
Status: 1 added / 1 removed UI Components — 42.5 kB (baseline 43.2 kB) • 🟢 -613 BReusable component library chunks
Status: 11 added / 11 removed Data & Services — 2.17 MB (baseline 2.47 MB) • 🟢 -300 kBStores, services, APIs, and repositories
Status: 15 added / 14 removed Utilities & Hooks — 237 kB (baseline 57.6 kB) • 🔴 +180 kBHelpers, composables, and utility bundles
Status: 20 added / 18 removed Vendor & Third-Party — 8.69 MB (baseline 8.86 MB) • 🟢 -169 kBExternal libraries and shared vendor chunks
Status: 11 added / 11 removed Other — 7.42 MB (baseline 7.38 MB) • 🔴 +38.8 kBBundles that do not match a named category
Status: 122 added / 112 removed |
There was a problem hiding this comment.
Nice, this looks good. Can you switch to lucide icons which is the library we are migrating towards. Some possible equivalents:
Copy: icon-[lucide--copy]
Paste: icon-[lucide--clipboard-paste]
Select All: icon-[lucide--lasso-select] or icon-[lucide--group]
Also we are using canvasStore.getCanvas or app.canvas in the rest of the file, so I wonder if we can align on style
Switch Copy/Paste/Select All icons to lucide library and align canvas access pattern with the rest of the file. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
applied both code and screenshot in description |
There was a problem hiding this comment.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@src/composables/useCoreCommands.ts`:
- Line 890: In useCoreCommands.ts replace raw label strings for the command
objects (e.g., the label: 'Copy', 'Paste', and 'Select All' entries in the
command definitions inside useCoreCommands) with vue-i18n lookups using t('...')
and add corresponding keys to src/locales/en/main.json (for example
"commands.copy", "commands.paste", "commands.selectAll"); ensure the code
imports/uses the t function from vue-i18n where the command objects are defined
(or uses the existing i18n instance) and update all three label properties to
t('commands.copy') / t('commands.paste') / t('commands.selectAll').
## Summary - Add Copy, Paste, and Select All commands to the Edit menu for mobile/touch users and accessibility - Menu-based copy uses LiteGraph internal clipboard; existing Ctrl+C/V behavior is unchanged ## Changes - `useCoreCommands.ts`: Register three new commands (`CopySelected`, `PasteFromClipboard`, `SelectAll`) - `coreMenuCommands.ts`: Add menu entries under Edit (between Undo/Redo and Clear Workflow) - `useCoreCommands.test.ts`: Add unit tests for the new commands ### AS IS <img width="260" height="176" alt="스크린샷 2026-02-18 오후 5 44 14" src="https://github.com/user-attachments/assets/8c9c86e1-55cc-411b-9d42-429001e04630" /> ### TO BE <img width="516" height="497" alt="스크린샷 2026-02-19 오후 5 07 28" src="https://github.com/user-attachments/assets/a2047541-582f-4520-a08f-98c6e532d29f" /> ## Test plan - [x] Verify Copy/Paste/Select All appear in Edit menu - [x] Select nodes → Edit > Copy → Edit > Paste → nodes duplicated - [x] Edit > Select All → all canvas items selected - [x] Copy with no selection → no-op (no error) - [x] Existing Ctrl+C/V keyboard shortcuts still work Fixes #2892 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8954-feat-add-Copy-Paste-Select-All-commands-to-Edit-menu-30b6d73d365081ec9270ed2a562eaf0b) by [Unito](https://www.unito.io) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

Summary
Changes
useCoreCommands.ts: Register three new commands (CopySelected,PasteFromClipboard,SelectAll)coreMenuCommands.ts: Add menu entries under Edit (between Undo/Redo and Clear Workflow)useCoreCommands.test.ts: Add unit tests for the new commandsAS IS
TO BE
Test plan
Fixes #2892
┆Issue is synchronized with this Notion page by Unito