fix: restore memory graph canvas height blocked by CSP style-src-elem nonce#415
fix: restore memory graph canvas height blocked by CSP style-src-elem nonce#415Brixyy wants to merge 1 commit intobuilderz-labs:mainfrom
Conversation
2b7494b to
c218761
Compare
0xNyk
left a comment
There was a problem hiding this comment.
Review: REQUEST CHANGES
Summary
This PR makes justified CSP changes for reagraph compatibility and extends memory-graph fit timing. However, it has overlap with PR #413 and needs cleanup before merging.
Issues Found
-
Duplicate
getSkillRoots()— The workspace discovery logic in this PR is identical to what's in #413. Please extract to a shared module (e.g.,src/lib/skill-roots.ts) to avoid divergence. -
Memory-graph timing is heuristic — The 4 hardcoded timeouts (800, 2500, 5000, 8000ms) work but are fragile. Consider using a
MutationObserveror reagraph's ready callback if available, rather than hoping 8 seconds is enough. -
CSP approach is sound — Using
unsafe-inlineforstyle-srcis an acceptable tradeoff since reagraph injects<style>elements without nonce support.script-srcstill uses nonce + strict-dynamic, which is good. This is better than PR #397's broader approach. -
Tests needed — CSP test was updated (good), but workspace discovery and memory-graph timing have no test coverage.
-
Needs rebase — Branch has merge conflicts with main.
Requested Changes
- Rebase on main
- Extract shared
getSkillRoots()tosrc/lib/skill-roots.ts - Add unit tests for workspace discovery
- Run
pnpm typecheck && pnpm testand confirm passing
c3d537c to
c218761
Compare
… nonce reagraph dynamically injects <style> elements at runtime without a nonce. CSP Level 3 ignores unsafe-inline when a nonce is present in style-src-elem, causing the injected styles to be blocked. The reagraph canvas container (_canvas class) relies on position:absolute/inset:0 from these injected styles to fill its parent — without them it falls back to the browser default canvas height of 150px, so all graph nodes render in a tiny sliver at the top of the panel. Fix: remove nonce from style-src-elem so unsafe-inline takes effect, matching style-src and style-src-attr which already use unsafe-inline. Also extend fitNodesInView retry window to 8 s to cover the full d3-force convergence time (~300 ticks at 60 fps).
c218761 to
514c681
Compare
|
Addressed review points:
|
|
CI failure is pre-existing, not caused by this PR.
This PR only touches |
|
Hey @Brixyy — friendly ping on the requested changes from yesterday's review. Quick summary of what's needed:
Let me know if you'd like to discuss the approach — happy to help. |
|
Superseded by #425 |
Fixes #414
Summary
style-src-elemdirective included a per-request nonce. CSP Level 3 ignores'unsafe-inline'when a nonce is present, so reagraph's dynamic<style>injection (which has no nonce) was blocked by the browser. The reagraph canvas container uses injected CSS (position: absolute; inset: 0) to fill its parent — without it the element has no height, causing the<canvas>to fall back to the browser default of 150 px. All nodes then render in a 150 px sliver at the top of the panel.csp.ts: remove nonce fromstyle-src-elem, rely on'unsafe-inline'(matchingstyle-srcandstyle-src-attrwhich already used it).memory-graph.tsx: extendfitNodesInViewretry window from 2 s to 8 s — d3-force needs ~300 ticks (≈ 5 s at 60 fps) to fully converge before the camera fit produces a stable result.Test plan
canvas.clientHeightequals panel height (not 150)pnpm test— CSP unit test passes with updated assertion🤖 Generated with Claude Code