Skip to content

fix(playground): use router.push instead of window.location.href for dashboard navigation#465

Open
nyxsky404 wants to merge 1 commit into
piyushdotcomm:mainfrom
nyxsky404:fix/playground-header-client-nav
Open

fix(playground): use router.push instead of window.location.href for dashboard navigation#465
nyxsky404 wants to merge 1 commit into
piyushdotcomm:mainfrom
nyxsky404:fix/playground-header-client-nav

Conversation

@nyxsky404

@nyxsky404 nyxsky404 commented Jun 3, 2026

Copy link
Copy Markdown

Summary

  • Replaced window.location.href = '/dashboard' with router.push('/dashboard') using Next.js App Router
  • Added useRouter import from next/navigation
  • Initialised router at the component's top level following React Hook rules

Type of change

  • Bug fix

Related issue

Closes #461

Validation

  • npm run lint
  • npm test
  • npm run build

Additional manual verification:

  • Clicked "Back to Dashboard" from the playground — navigation now transitions client-side with no full-page reload and no blank-screen flash
  • Network tab shows no full document re-request on navigation
  • Confirmed useRouter is imported from next/navigation (App Router), not next/router (Pages Router)
  • Confirmed the window.location.origin reference on line 153 (used to build the collab link URL, not for navigation) is intentionally left untouched

Pre-existing useAI.test.ts failure is unrelated to this change (reproducible on unmodified main).

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

  • I kept this PR focused on one primary change
  • I updated documentation if behavior changed
  • I did not commit secrets, local logs, or scratch files
  • I am requesting review on the correct scope

Root cause: window.location.href bypasses 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. Using router.push() performs a client-side transition, preserving loaded assets across the navigation.

Summary by CodeRabbit

  • Refactor
    • Improved the "Back to Dashboard" button navigation with client-side routing for a smoother transition experience.

…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
@nyxsky404 nyxsky404 requested a review from piyushdotcomm as a code owner June 3, 2026 17:52
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9950a687-3ca0-4dc2-8017-5b3307af6233

📥 Commits

Reviewing files that changed from the base of the PR and between f12b223 and ea413d2.

📒 Files selected for processing (1)
  • modules/playground/components/playground-header.tsx

Walkthrough

The PlaygroundHeader component is updated to use Next.js App Router for client-side navigation. The "Back to Dashboard" button now calls router.push('/dashboard') instead of window.location.href, eliminating full-page reloads and preserving the SPA session.

Changes

Client-Side Navigation Fix

Layer / File(s) Summary
Client-side routing implementation
modules/playground/components/playground-header.tsx
useRouter hook is imported and instantiated, then the "Back to Dashboard" button click handler is updated to call router.push('/dashboard') instead of assigning to window.location.href, enabling smooth client-side navigation without page reload.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Poem

🐰 A hop, not a reload!
The dashboard calls near,
No white-flash detour,
Just router.push() cheer!
SPA sessions preserved. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: replacing window.location.href with router.push for dashboard navigation in the playground component.
Description check ✅ Passed The pull request description is comprehensive and follows the template with all required sections completed, including summary, type of change, related issue, validation steps with checkmarks, manual verification details, and checklist items all marked complete.
Linked Issues check ✅ Passed The pull request fully addresses issue #461 by replacing window.location.href with router.push, adding useRouter import, ensuring client-side navigation without full-page reload, and preserving SPA state as required.
Out of Scope Changes check ✅ Passed All changes are directly related to the stated objective of replacing window.location.href with router.push navigation. The modification of playground-header.tsx is the single, focused change required by issue #461 with no extraneous alterations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown

👋 Thanks for opening a PR, @nyxsky404!

Your PR has entered the 🚦 PR Review Pipeline.

Standard PR detected — your PR will follow the standard review pipeline.


What happens next

Stage Reviewer Checks
Stage 1 — Automated Validation 🤖 Bot DCO · Format · AI/Slop · Duplicate
Stage 2 — Human Review 👥 Maintainer Code + Quality Review
Stage 3 — PA / Maintainer Review 🔑 Project Admin Final Merge Decision

A pipeline status comment will appear below and update automatically as your PR progresses.


While you wait

  • Sign all commits (git commit -s)
  • Link your issue (Closes #123)
  • Use a feature branch (not main)
  • Avoid unrelated changes

This comment is posted only once.

@nyxsky404

Copy link
Copy Markdown
Author

@piyushdotcomm Could you please review it when you get a chance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: window.location.href in playground-header causes full-page reload instead of client-side navigation

1 participant