refactor: simplify native tab bridge#2
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds SimDeck-driven iOS E2E test and CI wiring; refactors utils/native-tabs to use UIKit view context (ctx) for delegate and accessory wiring, removing the ObjC retainer/target bridge. ChangesE2E Testing and Native Tabs
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
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)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
utils/native-tabs.ts (1)
114-129:⚠️ Potential issue | 🟠 Major | ⚡ Quick winSync controlled
selectedIndexupdates after the first render.After
nativeSelectedIndexis initialized, this branch stops applying later in-rangeprops.selectedIndexchanges, so JS-driven tab switches no longer propagate toUITabBarController. That's a controlled-state regression.Proposed fix
if (props.items.length > 0) { const selectedIndex = clampSelectedIndex( props.selectedIndex, props.items.length, ); - const needsNativeSelection = - didRebuildItems || - controller.nativeSelectedIndex === undefined || - controller.nativeSelectedIndex >= props.items.length; + const needsNativeSelection = + didRebuildItems || controller.nativeSelectedIndex !== selectedIndex; if (needsNativeSelection && controller.selectedIndex !== selectedIndex) { controller.selectedIndex = selectedIndex; } if (needsNativeSelection) { controller.nativeSelectedIndex = selectedIndex; } }🤖 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 `@utils/native-tabs.ts` around lines 114 - 129, The branch currently only updates controller.selectedIndex when needsNativeSelection is true, which prevents later in-range props.selectedIndex changes from propagating; change the logic so that after computing selectedIndex (via clampSelectedIndex), you always sync controller.selectedIndex when it differs from selectedIndex (regardless of needsNativeSelection) and only set controller.nativeSelectedIndex when the existing native selection truly needs initialization or repair (i.e., keep the existing needsNativeSelection check for assigning controller.nativeSelectedIndex); update the block around clampSelectedIndex/needsNativeSelection to first compare and assign controller.selectedIndex if different, then conditionally assign controller.nativeSelectedIndex when needsNativeSelection.
🤖 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.
Outside diff comments:
In `@utils/native-tabs.ts`:
- Around line 114-129: The branch currently only updates
controller.selectedIndex when needsNativeSelection is true, which prevents later
in-range props.selectedIndex changes from propagating; change the logic so that
after computing selectedIndex (via clampSelectedIndex), you always sync
controller.selectedIndex when it differs from selectedIndex (regardless of
needsNativeSelection) and only set controller.nativeSelectedIndex when the
existing native selection truly needs initialization or repair (i.e., keep the
existing needsNativeSelection check for assigning
controller.nativeSelectedIndex); update the block around
clampSelectedIndex/needsNativeSelection to first compare and assign
controller.selectedIndex if different, then conditionally assign
controller.nativeSelectedIndex when needsNativeSelection.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 90d4eac9-40e0-41bf-828d-b84d7ce5a26f
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (4)
.github/workflows/ci.ymle2e/native-tabs.simdeck.test.mjspackage.jsonutils/native-tabs.ts
Summary
ctx.delegate()andctx.targetAction()Validation
npm testnpm run build:ios:ciSIMDECK_UDID=7321BC96-CD84-42E8-B183-3F8D40B0A482 npm run test:e2eSummary by CodeRabbit
Tests
Refactor
Chores