fix(playground): use router.push instead of window.location.href for dashboard navigation#465
Conversation
…dashboard navigation window.location.href = '/dashboard' triggered a full browser page reload, destroying the WebContainer, Monaco, and Yjs sessions unnecessarily. Replacing with router.push() from next/navigation keeps navigation within the Next.js App Router for a client-side transition. Fixes piyushdotcomm#461
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
WalkthroughThe ChangesClient-Side Navigation Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 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 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 |
👋 Thanks for opening a PR, @nyxsky404!Your PR has entered the 🚦 PR Review Pipeline.
What happens next
A pipeline status comment will appear below and update automatically as your PR progresses. While you wait
This comment is posted only once. |
|
@piyushdotcomm Could you please review it when you get a chance? |
Summary
window.location.href = '/dashboard'withrouter.push('/dashboard')using Next.js App RouteruseRouterimport fromnext/navigationrouterat the component's top level following React Hook rulesType of change
Related issue
Closes #461
Validation
npm run lintnpm testnpm run buildAdditional manual verification:
useRouteris imported fromnext/navigation(App Router), notnext/router(Pages Router)window.location.originreference on line 153 (used to build the collab link URL, not for navigation) is intentionally left untouchedPre-existing
useAI.test.tsfailure is unrelated to this change (reproducible on unmodifiedmain).Screenshots or recordings
No visual change to the UI. The difference is observable in the browser's Network tab: before, every click triggered a full document request; after, only data fetches occur.
Checklist
Root cause:
window.location.hrefbypasses the Next.js App Router entirely, causing a full browser navigation. This is particularly costly on the playground page which boots a WebContainer, Monaco Editor, Yjs WebSocket, and loads AI state — all of which are thrown away and re-initialised on every hard reload. Usingrouter.push()performs a client-side transition, preserving loaded assets across the navigation.Summary by CodeRabbit