FE-1669: Share Petrinaut snapshots through self-contained URLs - #9680
FE-1669: Share Petrinaut snapshots through self-contained URLs#9680kube wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
| ): Uint8Array => { | ||
| if (hash.length > maxSnapshotHashLength) throw new SnapshotError("too-large"); | ||
| if (!hash.startsWith(prefix)) { | ||
| throw new SnapshotError(/^v\d+\./u.test(hash) ? "unsupported" : "invalid"); |
There was a problem hiding this comment.
Semgrep identified an issue in your code:
Ensure that the regex used to compare with user supplied input is safe from regular expression denial of service.
To resolve this comment:
🔧 No guidance has been designated for this issue. Fix according to your organization's approved methods.
💬 Ignore this finding
Reply with Semgrep commands to ignore this finding.
/fp <comment>for false positive/ar <comment>for acceptable risk/other <comment>for all other reasons
Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by regex_dos.
You can view more details about this finding in the Semgrep AppSec Platform.
| ): Uint8Array => { | ||
| if (hash.length > maxSnapshotHashLength) throw new SnapshotError("too-large"); | ||
| if (!hash.startsWith(prefix)) { | ||
| throw new SnapshotError(/^v\d+\./u.test(hash) ? "unsupported" : "invalid"); |
PR SummaryMedium Risk Overview Snapshot data is canonical JSON, Brotli-compressed in a dedicated worker ( Read-only example and snapshot UIs are consolidated in Reviewed by Cursor Bugbot for commit a47a5f7. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
🟡 Changes recommended
Clipboard completion can report a stale URL as copied, and the critical oversized-snapshot download fallback is not exercised.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds self-contained, read-only Petrinaut snapshot sharing with optional editor-view restoration, local copying, and file fallback.
Changes:
- Adds versioned Brotli snapshot encoding through cancellable workers.
- Adds sharing UI,
/sharerouting, local-copy behavior, and Sentry redaction. - Adds comprehensive documentation, tests, dependency updates, and changesets.
File summaries
| File | Description |
|---|---|
yarn.lock |
Locks the Brotli dependency. |
libs/@hashintel/petrinaut/src/ui/views/Editor/panels/ai-assistant-panel/petrinaut-docs-content.ts |
Registers sharing documentation. |
libs/@hashintel/petrinaut/docs/sharing.md |
Documents snapshot sharing. |
libs/@hashintel/petrinaut/docs/README.md |
Links the sharing guide. |
libs/@hashintel/petrinaut-core/src/ai.ts |
Exposes sharing documentation to AI. |
apps/petrinaut-website/src/sharing/snapshot.ts |
Serializes and validates snapshots. |
apps/petrinaut-website/src/sharing/snapshot.test.ts |
Tests snapshot codec behavior. |
apps/petrinaut-website/src/sharing/snapshot-worker.ts |
Runs Brotli operations in a worker. |
apps/petrinaut-website/src/sharing/snapshot-worker-protocol.ts |
Defines worker messages. |
apps/petrinaut-website/src/sharing/snapshot-codec.ts |
Implements bounded Brotli encoding. |
apps/petrinaut-website/src/sharing/snapshot-client.ts |
Manages worker lifecycle and URLs. |
apps/petrinaut-website/src/sharing/snapshot-client.test.ts |
Tests cancellation and failures. |
apps/petrinaut-website/src/sharing/share-snapshot-button.tsx |
Adds the sharing dialog. |
apps/petrinaut-website/src/sharing/share-snapshot-button.test.tsx |
Tests sharing interactions. |
apps/petrinaut-website/src/sentry/strip-snapshot-links.ts |
Redacts snapshot payloads. |
apps/petrinaut-website/src/sentry/strip-snapshot-links.test.ts |
Tests telemetry redaction. |
apps/petrinaut-website/src/sentry/instrument.ts |
Applies redaction to Sentry hooks. |
apps/petrinaut-website/src/routes/share.tsx |
Adds the snapshot route. |
apps/petrinaut-website/src/routes/-share.test.tsx |
Tests snapshot navigation and copying. |
apps/petrinaut-website/src/main/app/readonly-document-page.tsx |
Extracts shared read-only document UI. |
apps/petrinaut-website/src/main/app/local-storage-demo/local-storage-demo-app.tsx |
Adds sharing to local documents. |
apps/petrinaut-website/src/examples/full-example-page.tsx |
Reuses the read-only document page. |
apps/petrinaut-website/README.md |
Documents snapshot architecture. |
apps/petrinaut-website/package.json |
Adds brotli-wasm. |
.changeset/snapshot-sharing-guide.md |
Records the Petrinaut documentation change. |
.changeset/snapshot-sharing-doc-catalog.md |
Records the core catalog change. |
Review details
- Files reviewed: 25/26 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| const copy = async () => { | ||
| if (url === null) return; | ||
| try { | ||
| await navigator.clipboard.writeText(url); | ||
| setCopyState("copied"); | ||
| } catch { | ||
| setCopyState("failed"); | ||
| } |
| expect(screen.getByRole("button", { name: "Download file" })).toHaveProperty( | ||
| "disabled", | ||
| false, | ||
| ); |
Summary
Local document URLs identify files saved in one browser. This adds Share to create a link containing a fixed copy of the complete net, with an option to include the current editor view.
Recipients open the snapshot read-only and can make an editable local copy. Later edits to the sender's document do not change the link.
Links
Blocked by
Changes
/share#v1.br.<payload>fragmentTest coverage
How to test