Repository navigation
refactor: replace agent frame assertions with a record guard - #18825
vansh-nagar wants to merge 1 commit into
Conversation
|
🎉 Thank you for your contribution, we really appreciate it! 🎉 Like many open source projects, we require contributors to sign our Contributor License Agreement (CLA). A CLA makes the ownership of contributions explicit, so contributors and the project share a clear understanding of how the code can be used. By signing, you:
CLAs are standard practice across major open source projects including those under the Apache Software Foundation and the Linux Foundation. Ours is based on the Apache Software Foundation's CLA. Most importantly, it would enable us to relicense the project under a more permissive license in the future, giving the project and its community greater flexibility. ✍ To sign, please post a new comment on this PR with exactly the following text: ✍ I have read and agree to the Contributor License Agreement You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
❌ ErrorsYour PR has failed checks. Please review the issues below and take necessary action before merging. 🚦 1 Pipeline job failed
Useful? React with 👍 / 👎 This comment will be updated automatically if new data arrives.🔗 Commit SHA: 0deddfd | Docs | View more details | Give us feedback! |
🎭 Playwright: ⏳ Running...🎨 Storybook: 🚧 Building... |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: Comfy-Org/ComfyUI_frontend/.coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughAdds a shared record type guard and uses it to validate agent fixture frames. Updates the reconnect regression test to assert subscription retry timing, state-vector reuse, and node appearance. ChangesAgent browser-test validation
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~8 minutes Change: Refactor Suggested reviewers: Merge Risk: ⚪ Minimal · up to This change only centralizes existing record checks and reuses the guard in the test. The inspected changes do not alter runtime behavior, so no material merge-readiness risk is identified. Architecture SummaryArchitecture risk: 🟡 Medium · up to The change affects 1 system. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
Reliability and maintainability
🚥 Pre-merge checks | ✅ 7✅ Passed checks (7 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Comment |
|
Closing this duplicate because its remaining |
…omfy-Org#21995) ## Summary The agent follower browser fixtures each hand-rolled the same `typeof x === 'object' && x !== null` check before reading a parsed `doc_*` frame. This replaces the two remaining copies with one guard under `browser_tests/fixtures/utils/`, plus a unit test for it. This carries the surviving part of [Comfy-Org#18816](Comfy-Org#18816) (the same consolidation, by @chiliec, which also absorbed Comfy-Org#18825). That PR is conflicting against `main` on a fork branch and has been open since September, so this is the same change re-authored on current `main` where it can land. Two non-obvious differences, both deliberate: **The guard excludes arrays.** `value is Record<string, unknown>` is false for an array, so admitting one lets a caller index it by string key with no complaint from the compiler, and three sibling guards in `browser_tests/fixtures/customNode/` already exclude them. A shared helper under `fixtures/utils/` is the one future callers will import, so it should not mean the opposite of its neighbours. Both call sites already reject an array one line later, because `type` and `op` read as `undefined`, so no valid frame changes outcome. The only behaviour difference is that an array `data` now returns `null` instead of being handed back typed as a record. **`agentGraphOpLostOnDisconnect.spec.ts` is untouched.** Comfy-Org#18816 also removed a local copy of the guard from that spec. That copy went away upstream along with the `subscriptionFrameOf` helper that used it, so there is no longer a duplicate there to remove. ## Verification - `pnpm vitest run browser_tests/fixtures/utils/isRecord.test.ts` passes, and the array cases fail against the array-accepting version, so the tightening is actually covered rather than assumed. - `pnpm typecheck` and `pnpm typecheck:browser` are clean, which is what covers the two fixture call sites narrowing correctly. - `oxfmt --check` and `oxlint` clean on the four files. - Not run locally: the agent Playwright specs that consume these fixtures. They need a cloud-distribution dev server, and the change is behaviour-preserving for every valid frame, so CI is the right place for that leg.
Summary
Replace unchecked record assertions in agent browser-test frames with a shared runtime guard.
Changes
isRecordguard and used it in the follower host socket, wire-frame parser, and disconnect regression spec.Review Focus
The guard preserves the existing runtime acceptance rules while letting TypeScript verify property access and returned frame data.
Fixes #18805