Skip to content

FE-504: Add Copy, Paste and Select All to Petrinaut editor#8533

Merged
kube merged 4 commits intomainfrom
cf/petrinaut-copy-paste
Mar 17, 2026
Merged

FE-504: Add Copy, Paste and Select All to Petrinaut editor#8533
kube merged 4 commits intomainfrom
cf/petrinaut-copy-paste

Conversation

@kube
Copy link
Collaborator

@kube kube commented Mar 12, 2026

🌟 What is the purpose of this PR?

Add clipboard support and selection shortcuts to the petrinaut editor, enabling users to copy, paste, and select all items in the SDCPN canvas.

🔗 Related links

🔍 What does this change?

  • Copy (Cmd/Ctrl+C): Serializes selected items (places, transitions, token types, differential equations, parameters) to clipboard as a versioned JSON format (petrinaut-sdcpn v1). Arcs between selected nodes are preserved within their transitions; arcs to unselected nodes are stripped.
  • Paste (Cmd/Ctrl+V): Deserializes clipboard data, generates new UUIDs for all items, deduplicates names with numeric suffixes, remaps internal references (arc→place, place→colorId/differentialEquationId, equation→colorId), and offsets pasted nodes by 50px. Newly pasted items are automatically selected.
  • Select All (Cmd/Ctrl+A): Selects all canvas nodes (places and transitions).
  • Escape to deselect: Clears selection in addition to switching to cursor mode.
  • Clipboard format: Versioned payload validated with zod, includes source document ID for future cross-document reconciliation.
  • zod added as a dependency for clipboard payload validation.

Pre-Merge Checklist 🚀

🚢 Has this modified a publishable library?

This PR:

  • modifies an npm-publishable library and I have added a changeset file(s)

📜 Does this require a change to the docs?

The changes in this PR:

  • are internal and do not require a docs change

🕸️ Does this require a change to the Turbo Graph?

The changes in this PR:

  • do not affect the execution graph

🐾 Next steps

  • Cross-document paste with dependency reconciliation (copy from one document, paste into another — may need to bring referenced types/equations along)
  • Cut (Cmd/Ctrl+X) support

🛡 What tests cover this?

  • 77 unit tests across 3 test files:
    • deduplicate-name.test.ts — name suffix logic (12 tests)
    • serialize.test.ts — serialization, arc stripping, payload parsing with zod validation (32 tests)
    • paste.test.ts — ID generation, name deduplication, position offset, arc remapping, reference remapping, data preservation (33 tests)

❓ How to test this?

  1. Checkout the branch
  2. Open the petrinaut editor with a net containing places, transitions, types, equations, and parameters
  3. Select items and press Cmd+C, then Cmd+V — confirm duplicates appear with new names and offset positions
  4. Press Cmd+A — confirm all canvas nodes are selected
  5. Press Escape — confirm selection is cleared
  6. Copy items from one document and paste into another — confirm they paste as independent copies

@vercel
Copy link

vercel bot commented Mar 12, 2026

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

Project Deployment Actions Updated (UTC)
hash Ready Ready Preview, Comment Mar 17, 2026 6:13pm
petrinaut Ready Ready Preview, Comment Mar 17, 2026 6:13pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
hashdotdesign Ignored Ignored Preview Mar 17, 2026 6:13pm
hashdotdesign-tokens Ignored Ignored Preview Mar 17, 2026 6:13pm

@github-actions github-actions bot added area/deps Relates to third-party dependencies (area) area/libs Relates to first-party libraries/crates/packages (area) type/eng > frontend Owned by the @frontend team labels Mar 12, 2026
Copy link
Collaborator Author

kube commented Mar 12, 2026

@kube kube changed the title Make TopBar title input fill available space FE-504: Add copy/paste and select all to petrinaut editor Mar 12, 2026
@github-actions github-actions bot added the area/infra Relates to version control, CI, CD or IaC (area) label Mar 12, 2026
@kube kube changed the base branch from cf/fe-512-create-filterablelistsubview-component to graphite-base/8533 March 12, 2026 22:38
@kube kube force-pushed the cf/petrinaut-copy-paste branch from 97b4e36 to 7889b18 Compare March 12, 2026 22:38
@kube kube force-pushed the graphite-base/8533 branch from 39823b5 to 44fe283 Compare March 12, 2026 22:38
@kube kube changed the base branch from graphite-base/8533 to main March 12, 2026 22:38
@kube kube marked this pull request as ready for review March 13, 2026 00:39
@cursor
Copy link

cursor bot commented Mar 13, 2026

PR Summary

Medium Risk
Adds new clipboard serialization/parsing and paste-mutation logic plus global editor keyboard handlers; main risk is unintended selection/mutation or invalid clipboard handling affecting editor state.

Overview
Adds clipboard copy/paste support for Petrinaut selections by introducing a versioned petrinaut-sdcpn payload, validated with zod, plus helpers to serialize current selection to JSON and parse it back.

Implements paste behavior that generates new IDs, deduplicates names, remaps references/arcs, and offsets pasted node positions, returning newly created item IDs for auto-selection.

Updates editor keyboard handling to support Cmd/Ctrl+C, Cmd/Ctrl+V (disabled in read-only), Cmd/Ctrl+A (select all places/transitions), and Escape now clears selection; includes a changeset and adds zod as a dependency.

Written by Cursor Bugbot for commit 2f0f041. This will update automatically on new commits. Configure here.

@augmentcode
Copy link

augmentcode bot commented Mar 13, 2026

🤖 Augment PR Summary

Summary: Adds clipboard + selection keyboard shortcuts to the Petrinaut SDCPN editor, enabling users to copy/paste selections and quickly select/deselect canvas items.

Changes:

  • Introduces a versioned clipboard payload format (petrinaut-sdcpn v1) with Zod validation.
  • Adds selection serialization (including arc-stripping rules) and parsing helpers.
  • Implements paste logic that generates new UUIDs, remaps internal references, deduplicates names/variable names, and offsets pasted nodes.
  • Wires up Cmd/Ctrl+C, Cmd/Ctrl+V, Cmd/Ctrl+A, and Escape-to-deselect in the editor keyboard shortcut handler.
  • Adds extensive unit test coverage for deduplication, serialization/parsing, and paste behaviors.
  • Refactors left-sidebar lists to a shared “filterable list” subview and centralizes entity icon definitions; updates subview headers/tooltips styling.
  • Adds a changeset and introduces zod as a dependency.

Technical Notes: Clipboard payload is explicitly versioned, and paste performs ID remapping and reference preservation/remapping for types, equations, parameters, places, transitions, and arcs.

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

@kube kube changed the base branch from main to graphite-base/8533 March 14, 2026 19:32
@kube kube force-pushed the cf/petrinaut-copy-paste branch from 7889b18 to 1a404fc Compare March 14, 2026 19:32
@kube kube changed the base branch from graphite-base/8533 to cf/fe-512-create-filterablelistsubview-component March 14, 2026 19:32
@graphite-app graphite-app bot requested a review from a team March 14, 2026 19:48
@graphite-app graphite-app bot changed the base branch from cf/fe-512-create-filterablelistsubview-component to graphite-base/8533 March 15, 2026 23:00
@kube kube force-pushed the cf/petrinaut-copy-paste branch from 927d425 to 70f9a7e Compare March 16, 2026 09:34
@kube kube force-pushed the graphite-base/8533 branch from 956fe86 to c4cda77 Compare March 16, 2026 09:34
Copy link
Member

@CiaranMn CiaranMn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On pasting, can we automatically select the pasted elements?

Usually the first thing users will want to do is to move pasted things elsewhere.

@kube kube force-pushed the cf/petrinaut-copy-paste branch from 70f9a7e to 8fcc710 Compare March 17, 2026 00:26
@kube kube force-pushed the graphite-base/8533 branch from c4cda77 to 90c92c9 Compare March 17, 2026 00:26
@kube kube changed the base branch from graphite-base/8533 to cf/fe-512-create-filterablelistsubview-component March 17, 2026 00:26
Copy link
Collaborator Author

kube commented Mar 17, 2026

On pasting, can we automatically select the pasted elements?

Usually the first thing users will want to do is to move pasted things elsewhere.

​This actually works in Storybook, but not after integration into the website.

Maybe a race-condition.

Let's create another ticket for fixing all this, but would be better IMO to do that after integrating Automerge. So we can start consolidating all the mess.

@kube kube requested a review from CiaranMn March 17, 2026 01:29
@kube kube changed the base branch from cf/fe-512-create-filterablelistsubview-component to graphite-base/8533 March 17, 2026 11:31
@graphite-app
Copy link
Contributor

graphite-app bot commented Mar 17, 2026

Merge activity

  • Mar 17, 3:09 PM UTC: This pull request can not be added to the Graphite merge queue. Please try rebasing and resubmitting to merge when ready.
  • Mar 17, 3:09 PM UTC: Graphite disabled "merge when ready" on this PR due to: a merge conflict with the target branch; resolve the conflict and try again..

kube and others added 4 commits March 17, 2026 18:59
Implement clipboard support with a versioned JSON format (petrinaut-sdcpn v1)
validated by zod. Copy serializes selected items (places, transitions, token
types, differential equations, parameters) with arc preservation. Paste
duplicates items with new UUIDs, deduplicates names, remaps internal references,
and offsets node positions. Cmd+A selects all canvas nodes, Escape clears
selection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kube kube force-pushed the graphite-base/8533 branch from 90c92c9 to 9cf2392 Compare March 17, 2026 18:00
@kube kube force-pushed the cf/petrinaut-copy-paste branch from 8fcc710 to 2f0f041 Compare March 17, 2026 18:00
@kube kube changed the base branch from graphite-base/8533 to main March 17, 2026 18:00
@kube kube added this pull request to the merge queue Mar 17, 2026
Merged via the queue into main with commit feb318b Mar 17, 2026
59 of 82 checks passed
@kube kube deleted the cf/petrinaut-copy-paste branch March 17, 2026 19:19
@hashdotai hashdotai mentioned this pull request Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/deps Relates to third-party dependencies (area) area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) type/eng > frontend Owned by the @frontend team

Development

Successfully merging this pull request may close these issues.

2 participants