Skip to content

fix(sidebar): remove fallback timer that caused full-page reloads#663

Merged
Kewton merged 1 commit intodevelopfrom
feature/651-worktree
Apr 14, 2026
Merged

fix(sidebar): remove fallback timer that caused full-page reloads#663
Kewton merged 1 commit intodevelopfrom
feature/651-worktree

Conversation

@Kewton
Copy link
Copy Markdown
Owner

@Kewton Kewton commented Apr 14, 2026

Summary

  • Removes the 500ms fallback timer (window.location.href) from handleBranchClick in Sidebar.tsx
  • Removes the associated useRef (fallbackTimerRef) and useEffect cleanup
  • Updates unit test to reflect the simplified behavior

Root cause

Next.js App Router calls window.history.pushState() inside a React effect (not synchronously with router.push()). This means window.location.pathname retains the old path until the React render cycle completes — which can be 500ms+ on slow RSC fetches.

The fallback timer was checking window.location.pathname !== targetPath at 500ms and triggering window.location.href = targetPath (a hard full-page reload) every time, because the URL hadn't updated yet.

Fix

Remove the fallback timer entirely. router.push() is the correct way to navigate in App Router and does not need a hard-nav fallback.

Test plan

  • All 334 unit test files pass (npm run test:unit)
  • Manual: sidebar click navigates softly without full-page reload

🤖 Generated with Claude Code

Next.js App Router defers history.pushState() to a React effect, so
window.location.pathname does not update synchronously with router.push().
The 500ms fallback timer was firing before the URL updated and calling
window.location.href, causing a full hard reload on every sidebar click.

Remove the fallback timer and useEffect cleanup entirely; router.push()
alone is sufficient for App Router navigation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Kewton Kewton merged commit b465337 into develop Apr 14, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant