fix: don't override loadGraphData viewport on cache miss#10810
fix: don't override loadGraphData viewport on cache miss#10810artokun wants to merge 2 commits intoComfy-Org:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughOn viewport restore cache miss, the store now conditionally calls Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🎭 Playwright: ⏳ Running... |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/stores/subgraphNavigationStore.ts (1)
144-144: Redundant variable assignment.
expectedGraphIdis identical tographId. The parameter is aconstand doesn't change within the function scope.♻️ Suggested fix
- const expectedGraphId = graphId requestAnimationFrame(() => { - if (getActiveGraphId() !== expectedGraphId) return + if (getActiveGraphId() !== graphId) return🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/stores/subgraphNavigationStore.ts` at line 144, The variable expectedGraphId is a redundant alias of the parameter graphId in the function (remove the unnecessary assignment). Replace usages of expectedGraphId with graphId and delete the const expectedGraphId = graphId line (locate the assignment and any references to expectedGraphId in the same function or scope and update them to use graphId directly, e.g., inside methods that reference expectedGraphId).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/stores/subgraphNavigationStore.ts`:
- Around line 149-150: The code directly accesses canvas.graph._nodes; replace
that with the public getter canvas.graph.nodes to avoid touching internal
properties—locate the usage in subgraphNavigationStore where nodes is assigned
(currently using canvas.graph._nodes) and change it to use canvas.graph.nodes so
it matches other modules like appModeStore.ts and litegraphUtil.ts.
---
Nitpick comments:
In `@src/stores/subgraphNavigationStore.ts`:
- Line 144: The variable expectedGraphId is a redundant alias of the parameter
graphId in the function (remove the unnecessary assignment). Replace usages of
expectedGraphId with graphId and delete the const expectedGraphId = graphId line
(locate the assignment and any references to expectedGraphId in the same
function or scope and update them to use graphId directly, e.g., inside methods
that reference expectedGraphId).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 44eb8fac-5f8a-418a-892e-631837f630f0
📒 Files selected for processing (1)
src/stores/subgraphNavigationStore.ts
restoreViewport() called fitView() on cache miss via rAF, which raced with loadGraphData's own viewport restore (extra.ds or template fitView). This caused templates like LTX2.3 to load with a broken viewport. Now checks if any nodes are already visible before calling fitView(), so we only intervene when the viewport is genuinely empty. Fixes regression from Comfy-Org#10247
df7c4c5 to
224e0c8
Compare

Summary
Fix regression from #10247 where template workflows (e.g. LTX2.3) loaded with a broken viewport.
Problem
restoreViewport()calledfitView()on every cache miss via rAF. This raced withloadGraphData's own viewport restore (extra.dsfor saved workflows, or its ownfitView()for templates at line 1266 of app.ts). The secondfitView()overwrote the correct viewport, causing templates with subgraphs to display incorrectly.Fix
On cache miss, check if any nodes are already visible in the current viewport before calling
fitView(). IfloadGraphDataalready positioned things correctly, we don't override it. Only intervene when the viewport is genuinely empty (first visit to a subgraph with no prior cached state AND no loadGraphData restore).Review Focus
Single-file change in
subgraphNavigationStore.ts. The visibility check mirrors the same pattern used inapp.ts:1272-1281where loadGraphData itself checks for visible nodes.E2E Regression Test
The existing Playwright tests in
browser_tests/tests/subgraphViewport.spec.ts(added in #10247) already cover viewport restoration after subgraph navigation. The specific regression (template load viewport race) is not practically testable in E2E because:loadGraphData's viewport restore and the rAF-deferredrestoreViewport— Playwright cannot reliably reproduce frame-level timing racesAlternative to #10790
This can replace the full revert in #10790 — it preserves the viewport persistence feature while fixing the template regression.
Fixes regression from #10247