Repository navigation
fix(mobile): open editor for disconnected hosts - #12575
Conversation
📝 WalkthroughWalkthroughMobile host edit navigation now observes navigation state instead of using an animation frame. It replaces the host route only after the matching route commits, supports cancellation, and cleans up listeners on completion or errors. A new React hook manages pending navigation and unmount cleanup. The home screen uses the hook directly for the action sheet edit callback. Tests cover route matching, cancellation, errors, and callback wiring. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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)
mobile/src/transport/host-edit-navigation.test.ts (1)
60-75: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover automatic stale-transition cleanup.
This test invokes
controller.cancel(), so it only covers explicit cancellation. Add a transition from an unrelatedhroute to a non-hroute, then emit the requested host route. Assert that the listener is unsubscribed andreplaceis not called.Proposed test coverage
+ it('cancels a stale pending replacement after navigation leaves the host flow', () => { + const harness = navigationHarness({ index: 0, routes: [{ name: 'index' }] }) + const replace = vi.fn() + + navigateToMobileHostEdit(harness.navigation, { push: vi.fn(), replace }, 'host-1') + harness.setState({ index: 0, routes: [{ name: 'h', params: { hostId: 'host-2' } }] }) + harness.setState({ index: 0, routes: [{ name: 'index' }] }) + harness.setState({ index: 0, routes: [{ name: 'h', params: { hostId: 'host-1' } }] }) + + expect(harness.unsubscribeState).toHaveBeenCalledOnce() + expect(replace).not.toHaveBeenCalled() + })
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 5f58e47f-a9db-4575-a8e7-63667e420b79
📒 Files selected for processing (5)
mobile/app/index.tsxmobile/src/home-host-edit-navigation-source.test.tsmobile/src/transport/host-edit-navigation.test.tsmobile/src/transport/host-edit-navigation.tsmobile/src/transport/use-open-mobile-host-edit.ts
Summary
Fix mobile host editing when the target host is disconnected. The edit action now waits for the root navigator to commit the expected host route before replacing it with the editor, and cancels stale pending transitions on repeat navigation or unmount.
Added regression coverage for the committed-route transition, unrelated host routes, cancellation, and synchronous navigation failures.
Screenshots
Disconnected host opens its populated editor:
Testing
pnpm lint— mobile packagepnpm typecheck— mobile packagepnpm test— full suite not run; 13 focused mobile tests passedpnpm build— not run; mobile-only navigation changeAI Review Report
Reviewed the navigation state synchronization, pending-transition lifecycle, host ID handling, failure cleanup, and regression tests. The review found the previous
requestAnimationFramereplacement could run before Expo Router committed the nested host route; this PR replaces that timing assumption with a committed-state listener and verifies cleanup paths.Cross-platform compatibility was explicitly checked for macOS, Linux, and Windows. The change uses platform-neutral Expo navigation and does not touch shortcuts, shortcut labels, filesystem paths, shell behavior, or Electron-specific behavior. SSH and folder-workspace behavior are unaffected.
Security Audit
Reviewed route input handling and lifecycle cleanup. Host IDs are encoded for the mounted host URL and passed as route params for the edit route. The change adds no command execution, filesystem access, authentication changes, secrets, dependencies, IPC, or new external input surfaces.
Notes
This changes navigation behavior only; the existing edit-host UI and styling are unchanged.