refactor(export): add native static route plan#556
Conversation
📝 WalkthroughWalkthroughThis PR introduces a static layout export route planner that selects between CUDA, D3D11, and FFmpeg based on capability probe data. The implementation includes type contracts for routes and decisions, along with comprehensive tests verifying all routing scenarios. ChangesStatic Layout Export Route Planning
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
electron/ipc/export/nativeStaticLayoutRoutePlan.test.ts (1)
152-165: ⚡ Quick winMake the proxy-metadata assertion mutation-safe.
This assertion reuses the same object passed into the planner, so an in-place mutation could still pass. Snapshot expected metadata before the call and assert against that snapshot.
Suggested test hardening
it("preserves proxy source metadata for route diagnostics", () => { const proxiedSource = { inputCodec: "vp9", proxyCodec: "h264", proxyCreated: true, }; + const expectedSource = { ...proxiedSource }; - expect( - planNativeStaticLayoutRoutes({ - cuda: cudaProbe, - d3d11: d3d11Probe, - source: proxiedSource, - }).source, - ).toEqual(proxiedSource); + const plan = planNativeStaticLayoutRoutes({ + cuda: cudaProbe, + d3d11: d3d11Probe, + source: proxiedSource, + }); + + expect(plan.source).toEqual(expectedSource); + expect(proxiedSource).toEqual(expectedSource); });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@electron/ipc/export/nativeStaticLayoutRoutePlan.test.ts` around lines 152 - 165, The test currently passes the proxiedSource object directly to planNativeStaticLayoutRoutes and then asserts the returned .source equals the same object, which won't catch in-place mutations; to harden it, clone or snapshot the expected metadata before calling planNativeStaticLayoutRoutes (e.g., const expectedSource = { ...proxiedSource } or deep clone) and then call planNativeStaticLayoutRoutes({ cuda: cudaProbe, d3d11: d3d11Probe, source: proxiedSource }) and assert that result.source strictly equals the saved expectedSource (not the original proxiedSource), ensuring planNativeStaticLayoutRoutes did not mutate the input; reference the proxiedSource variable and planNativeStaticLayoutRoutes function in the test.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@electron/ipc/export/nativeStaticLayoutRoutePlan.test.ts`:
- Around line 152-165: The test currently passes the proxiedSource object
directly to planNativeStaticLayoutRoutes and then asserts the returned .source
equals the same object, which won't catch in-place mutations; to harden it,
clone or snapshot the expected metadata before calling
planNativeStaticLayoutRoutes (e.g., const expectedSource = { ...proxiedSource }
or deep clone) and then call planNativeStaticLayoutRoutes({ cuda: cudaProbe,
d3d11: d3d11Probe, source: proxiedSource }) and assert that result.source
strictly equals the saved expectedSource (not the original proxiedSource),
ensuring planNativeStaticLayoutRoutes did not mutate the input; reference the
proxiedSource variable and planNativeStaticLayoutRoutes function in the test.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 7c5ad696-a47a-49c3-ae44-553ca15b149c
📒 Files selected for processing (2)
electron/ipc/export/nativeStaticLayoutRoutePlan.test.tselectron/ipc/export/nativeStaticLayoutRoutePlan.ts
Summary
Verification
npm test -- electron/ipc/export/nativeStaticLayoutRoutePlan.test.tsnpx tsc --noEmitnpx biome check --formatter-enabled=false electron/ipc/export/nativeStaticLayoutRoutePlan.ts electron/ipc/export/nativeStaticLayoutRoutePlan.test.tsgit diff --checkNotes
Summary by CodeRabbit
Tests
New Features