FE-1660: Explain blocked edits in read-only Petrinaut documents - #9662
FE-1660: Explain blocked edits in read-only Petrinaut documents#9662kube wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
PR SummaryLow Risk Overview Hosts can pass Feedback is wired through Docs and a patch changeset for Reviewed by Cursor Bugbot for commit 69fc391. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4c24941. 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

Summary
Trying to drag a node or use an editing shortcut on a read-only document shows a brief neutral notice. Repeated attempts reuse the same notice, and normal selection, panning, and zooming stay quiet.
On published examples, Make a local copy in the notice opens an editable copy using the local document URLs from the preceding PR. Other restrictions explain whether to switch to Edit or reset the simulation.
Links
Blocked by
Changes
readOnlyActionfor hosts and connect example pages to their local-copy action@hashintel/petrinautTest coverage
How to test
/examples/sir-epidemic-modelon the website preview