Repository navigation
feat(store): copy the state and a change's diff - #269
Conversation
Getting store state out of the panel meant selecting text in the State block by hand, and a change's diff could not be copied at all, which made it slow to paste a state or a diff into a bug report or a test. The Store tab now has a Copy button next to the State heading and one next to the State diff of the selected entry. State copies the same formatted, already redacted text the panel shows; the diff copies that entry's diff entries. A polite status message says "Copied." or "The clipboard is not available here." when the clipboard is missing or refuses the write. Each button's accessible name says what it copies. The NgRx Store docs page describes both buttons and the clipboard message.
The copy buttons put the panel's formatted text on the clipboard, the same text the State block shows, which is not strict JSON (simple keys are unquoted and values like Date or Map are shown in a readable form). Accessible names that said "as JSON" promised a format the copy does not have. The buttons are now named "Copy state" and "Copy the state diff of #N", the docs say the copy is the state as shown in the panel, and the tests assert the new names.
🚀 Deploying Preview to Cloudflare 🚀Preview Deployments by commit
|
There was a problem hiding this comment.
🔇 Additional comments (6)
extension/ui/index.html (1)
12-12: LGTM!extension/ui/assets/browser-agent-rpc-BXhoSh1z-BV8Vv7MW.js (1)
1-1: LGTM!app/src/__tests__/store-inspector.test.ts (1)
199-278: LGTM!apps/docs/src/content/inspectors/ngrx-store.md (1)
35-35: LGTM!Also applies to: 48-48, 191-194
app/src/pages/store-inspector.ts (2)
1937-1939: 🔒 Security & Privacy | 🛡️ Detected with Advanced TierVerify that the diff producer redacts
beforeandaftervalues. ThecopyDiffaction passesentry.diffdirectly topretty, which performs no redaction. The producer must redact both diff values before storing or exposing the entry.
1941-1948: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.Surface clipboard failures to the caller or do not swallow them silently.
copyTextcatches every error and sets one message.navigator.clipboardcan beundefined, andwriteTextcan reject. Both cases produce the same text. ThecopyState()andcopyDiff()methods return the promise, but it always resolves, so callers cannot observe a failure.The UI feedback is present, so the user impact is small. Keep the message. Consider logging the error or returning a boolean result. A result lets callers and tests tell success from failure without reading the DOM.
Based on learnings: "async utility functions (e.g., a clipboard-copy helper) should not silently catch and swallow errors internally."
Source: Learnings
ℹ️ Review info
⚙️ Run configuration
- Configuration used: defaults
- Review profile: CHILL
- Plan: Advanced
- Run ID:
b6056345-119a-40ca-952c-f6686dcdf1fa
⛔ Files ignored due to path filters (1)
extension/ui/assets/index-BPdZd4IT.jsis excluded by!**/assets/index-[0-9a-z_-][0-9a-z_-][0-9a-z_-][0-9a-z_-][0-9a-z_-][0-9a-z_-][0-9a-z_-][0-9a-z_-].js
📒 Files selected for processing (5)
app/src/__tests__/store-inspector.test.tsapp/src/pages/store-inspector.tsapps/docs/src/content/inspectors/ngrx-store.mdextension/ui/assets/browser-agent-rpc-BXhoSh1z-BV8Vv7MW.jsextension/ui/index.html
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
# Conflicts: # extension/ui/assets/browser-agent-rpc-BXhoSh1z-BV8Vv7MW.js # extension/ui/assets/browser-agent-rpc-BXhoSh1z-C_twCiPD.js # extension/ui/assets/browser-agent-rpc-BXhoSh1z-Ca92cyCz.js # extension/ui/assets/index-B4-Q9-Lj.js # extension/ui/assets/index-BEfrZ0QX.js # extension/ui/assets/index-BPdZd4IT.js # extension/ui/index.html
What and why
The NgRx Store tab had no way to get state out of the panel except selecting text by hand in the State block, and a change's diff could not be copied at all. That made it slow to paste a state or a diff into a bug report or a test.
role="status"message: "Copied.", or "The clipboard is not available here." whennavigator.clipboardis missing or rejects. This matches the try/catch pattern in the Router and Forms copy buttons.How it was verified
pnpm commit:check: 2 commit messages OKpnpm format:check: all files passpnpm typecheck: exit 0, noerror TSorerror NGpnpm test:panel: 29 files, 169 tests passed, including 5 copy tests: the state copy equals the panel text; the diff copy for a selected entry; no diff button for an entry with no change; the message when the clipboard is missing; the message when the write is rejectedinspectors/ngrx-store.md) andpnpm docs:buildpassespnpm extension:build: rebuiltextension/uicommittedpnpm test:axecould not launch its pinned Chromium, soscripts/panel-axe.mjswas run against the installed Chromium 1194 on the same static report: 0 violations on every tab and view in dark and light. The buttons were also checked with live data from the SSR demo (/examples/store, panel at/__devframes/pangular/?view=ngrx) in dark and light at 1280px and 360px. Both copies said "Copied.", the copied state matched the panel text, axe found 0 violations with the change detail open, and there was no horizontal overflow. The second commit only renames the accessible names and was not rerun in the browser.Notes for reviewers
pretty()output the State block shows), not strictJSON.stringifyoutput. This keeps the copy identical to what is on screen, already redacted, with Date, Map, Set and similar values readable. The labels and docs say "as shown in the panel" instead of "JSON" for that reason.--control-hbut above the 24px minimum target size.selectedChangeSeq,selectedEventSeq,confirmSeq) are untouched, so this should not conflict with fix: reset stale selections and armed actions when the inspected page changes #253.Summary by CodeRabbit