Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
PR SummaryLow Risk Overview
Notifications gain optional Reviewed by Cursor Bugbot for commit d326e68. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
🟡 Changes recommended
Address the preview feedback behavior and preserve native undo when no history adapter is configured.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds read-only feedback for blocked Petrinaut edits, including deduplicated notices and optional local-copy actions.
Changes:
- Detects blocked drags, shortcuts, mutations, and commands.
- Adds notification actions, deduplication, and contextual messaging.
- Updates integrations, tests, documentation, README, and changeset.
File summaries
| File | Description |
|---|---|
libs/@hashintel/petrinaut/src/ui/views/SDCPN/use-canvas-interactions.ts |
Reports blocked canvas mutations. |
libs/@hashintel/petrinaut/src/ui/views/SDCPN/renderers/react-flow/react-flow-canvas/use-read-only-node-drag.ts |
Detects blocked node drags. |
libs/@hashintel/petrinaut/src/ui/views/SDCPN/renderers/react-flow/react-flow-canvas/use-read-only-node-drag.test.tsx |
Tests drag feedback behavior. |
libs/@hashintel/petrinaut/src/ui/views/SDCPN/renderers/react-flow/react-flow-canvas.tsx |
Installs drag handlers. |
libs/@hashintel/petrinaut/src/ui/views/Editor/components/BottomBar/use-keyboard-shortcuts.ts |
Explains blocked shortcuts. |
libs/@hashintel/petrinaut/src/ui/views/Editor/components/BottomBar/use-keyboard-shortcuts.test.tsx |
Tests shortcut feedback. |
libs/@hashintel/petrinaut/src/ui/petrinaut.tsx |
Exposes the read-only action prop. |
libs/@hashintel/petrinaut/src/react/state/read-only-action-context.ts |
Provides host action context. |
libs/@hashintel/petrinaut/src/react/notifications/toaster.tsx |
Renders notification actions. |
libs/@hashintel/petrinaut/src/react/notifications/provider.tsx |
Adds deduplication and informational tone mapping. |
libs/@hashintel/petrinaut/src/react/notifications/provider.test.tsx |
Tests notification behavior. |
libs/@hashintel/petrinaut/src/react/notifications/context.ts |
Extends notification input types. |
libs/@hashintel/petrinaut/src/react/hooks/use-read-only-feedback.ts |
Centralizes read-only notices. |
libs/@hashintel/petrinaut/src/react/hooks/use-petrinaut-mutations.ts |
Reports blocked mutations. |
libs/@hashintel/petrinaut/src/react/hooks/use-petrinaut-mutations.test.tsx |
Tests mutation feedback. |
libs/@hashintel/petrinaut/src/react/hooks/use-petrinaut-commands.ts |
Reports blocked commands. |
libs/@hashintel/petrinaut/README.md |
Documents the host action API. |
libs/@hashintel/petrinaut/docs/drawing-a-net.md |
Documents read-only behavior. |
apps/petrinaut-website/src/examples/full-example-page.tsx |
Connects the local-copy action. |
.changeset/smooth-readonly-feedback.md |
Adds the package changeset. |
Review details
Suppressed comments (2)
libs/@hashintel/petrinaut/src/react/hooks/use-petrinaut-commands.ts:35
- The new behavior in this guard is the notification, but the existing
use-petrinaut-commands.test.tsxcases only assert no-op return values and do not provide or inspectNotificationsContext.addNotification. A regression removingnotifyReadOnly()here (or at the analogous auto-layout guard on line 44) would therefore leave the command tests green; add blocked paste and auto-layout assertions for the notice.
if (isReadOnly) {
notifyReadOnly();
return { newItemIds: [] };
libs/@hashintel/petrinaut/src/react/hooks/use-read-only-feedback.ts:27
- The public
PetrinautPreviewdoes not provide a usable outcome for this shared feedback hook: withoutquickSimulation, it renders the canvas withoutNotificationsProvider(src/ui/preview/petrinaut-preview.tsx:311-345), so the defaultaddNotificationis a no-op; with Quick Simulation, the preview's mode issimulatebut it intentionally exposes no Edit mode control (src/ui/preview/petrinaut-preview.tsx:321-345,docs/preview.md:64-67), so this message tells users to switch to an unavailable mode. Supply preview-specific notification wiring/copy or keep this feedback scoped to the full editor.
const message =
reason.kind === "host-readonly"
? "This document is read-only."
: reason.kind === "simulation-active"
? "Reset the simulation to edit this net."
: "Switch to Edit to change this net.";
addNotification({
id: `read-only:${petriNetId}:${reason.kind}`,
message,
tone: "neutral",
durationMs: 4500,
action: reason.kind === "host-readonly" ? action : undefined,
- Files reviewed: 20/20 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if (isReadonly) { | ||
| notifyReadOnly(); | ||
| return; |
4c24941 to
69fc391
Compare
69fc391 to
482e2d5
Compare
482e2d5 to
8701a94
Compare
6761296 to
a7c8bcf
Compare
a7c8bcf to
ade6d39
Compare
ade6d39 to
47f6f87
Compare
A blocked node drag, editing shortcut, paste or delete shows one brief notice saying why: the host made the net read-only, a mode other than Edit is open, or a simulation holds the net. A host can add an action to the read-only notice through readOnlyAction, carried with the other host-owned net actions; published examples offer Make a local copy there. Neutral notifications now render: Ark shows only its own toast types, so a neutral tone maps to info.
Notifications live in a store shared by every editor on the page. The unmount cleanup dismissed them, and a dismissal animates out through each toast's own machine, which unmounts with the editor, so the next editor showed the toast again. Make a local copy in the read-only notice left "This document is read-only." on the editable copy. The cleanup now removes them at once.
a40196e to
d326e68
Compare
Summary
Before this PR, Petrinaut ignored edits on a read-only net without a word. A dragged node stayed put and editing shortcuts did nothing.
A blocked drag, shortcut, paste or delete now shows one brief notice saying why. Hosts can add a button to the read-only notice, and published examples on the website offer Make a local copy there.
9662.mp4
Links
Changes
Petrinaut
useReadOnlyFeedbackexplains a blocked editreadOnlyActionprop adds a button to the host read-only noticeidandactionWebsite
Test coverage
use-read-only-node-drag.test.tsx:use-keyboard-shortcuts.test.tsx:use-petrinaut-mutations.test.tsx:provider.test.tsx:How to test