feat(camera): add committed $camera signal and Layer.onCameraChange hook#303
Merged
Conversation
Reviewer's GuideImplements a committed camera state signal graph.$camera, updates CameraService and Graph to maintain it, switches Layer and multiple layers/utilities from camera-change event subscriptions to the committed signal via a new Layer.onCameraChange hook, adds a React useSignalLayoutEffect hook and migrates React integrations to use committed camera state, and documents/tests the proposed vs committed camera model. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/components/canvas/layers/graphLayer/GraphLayer.ts" line_range="118-120" />
<code_context>
+ super.afterInit(); // subscribes to $camera and calls onCameraChange()
+ }
+
+ protected onCameraChange(camera: TCameraState): void {
+ this.handleCameraChange(camera);
}
</code_context>
<issue_to_address>
**issue (bug_risk):** GraphLayer no longer triggers performRender on camera changes, which may drop visual updates.
Before, this layer subscribed to `camera-change` and called `this.performRender()` on each update. Now, via `$camera`, `Layer` routes camera changes to `handleCommittedCameraChange`, which only calls `applyCameraTransform` and `onCameraChange` and doesn’t trigger `performRender`. This override only forwards the camera to `handleCameraChange`, so camera changes might no longer cause the graph canvas to re-render. Please either invoke `this.performRender()` from `onCameraChange` here, or confirm that rendering is driven from another explicit camera-based mechanism.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Contributor
|
Preview is ready. |
Separate proposed camera state (camera-change event) from committed state (graph.$camera signal). Layers and React hooks react to applied changes; camera-change remains for interception via preventDefault(). Co-authored-by: Cursor <cursoragent@cursor.com>
e8757ef to
e930a47
Compare
Remove nonexistent graph.cameraState from camera docs and sync the overlay via useSceneChange instead of camera-change events. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
graph.$camerasignal as the source of committed camera state, updated only after a non-preventedcamera-changeeventLayer.onCameraChange()hook — baseLayersubscribes to$cameraand applies built-in transforms before calling the overrideuseSignalLayoutEffectReact hook; migrateuseSceneChange, internal layers, and camera auto-panning sync to committed statecamera-changeevent vs$camera/cameraService) and add e2e tests for the contractTest plan
useSignal.test.ts(includinguseSignalLayoutEffect)e2e/tests/camera/camera-change-signal.spec.tspreventDefault()oncamera-changecancels commit and keeps$cameraunchangeduseSignal(graph.$camera)Made with Cursor
Summary by Sourcery
Introduce a committed camera signal and hook layers and React utilities into it for camera-driven updates.
New Features:
Enhancements:
Tests: