Skip to content

fix(web): remove router.refresh() after router.push() to fix Next.js 16 navigation#974

Merged
brendan-kellam merged 2 commits intomainfrom
brendan/fix-router-refresh-next16
Mar 2, 2026
Merged

fix(web): remove router.refresh() after router.push() to fix Next.js 16 navigation#974
brendan-kellam merged 2 commits intomainfrom
brendan/fix-router-refresh-next16

Conversation

@brendan-kellam
Copy link
Contributor

@brendan-kellam brendan-kellam commented Mar 2, 2026

Summary

  • In Next.js 16, the prefetch cache and navigation system was completely rewritten, causing router.refresh() called immediately after router.push() to race and interrupt the in-flight navigation — leaving the page stuck or not loading
  • Removed the redundant router.refresh() calls from useCreateNewChatThread.ts, chatName.tsx, chatSidePanel.tsx, and inviteMemberCard.tsx
  • Documents this pattern in CLAUDE.md to prevent future regressions

Test plan

  • Create a new chat thread and verify navigation to the chat page succeeds
  • Delete a chat and verify navigation back to /chat succeeds
  • Rename a chat in the side panel and verify no navigation issues
  • Invite a member and verify redirect to ?tab=invites works correctly

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Fixed page navigation issues following the Next.js 16 upgrade.
  • Documentation

    • Added guidance on Next.js router navigation best practices for developers.

…16 navigation

In Next.js 16, the prefetch cache and navigation system was completely
rewritten. Calling router.refresh() immediately after router.push() creates
a race condition where the cache invalidation interrupts the in-flight
navigation, causing the page to not load.

Removed the router.refresh() calls from:
- useCreateNewChatThread.ts
- chatName.tsx
- chatSidePanel.tsx
- inviteMemberCard.tsx

Also documents this pattern in CLAUDE.md to prevent future regressions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

This comment has been minimized.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4004933 and 9b21103.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • CLAUDE.md
  • packages/web/src/app/[domain]/chat/components/chatName.tsx
  • packages/web/src/app/[domain]/chat/components/chatSidePanel.tsx
  • packages/web/src/app/[domain]/settings/members/components/inviteMemberCard.tsx
  • packages/web/src/features/chat/useCreateNewChatThread.ts
💤 Files with no reviewable changes (4)
  • packages/web/src/features/chat/useCreateNewChatThread.ts
  • packages/web/src/app/[domain]/chat/components/chatName.tsx
  • packages/web/src/app/[domain]/settings/members/components/inviteMemberCard.tsx
  • packages/web/src/app/[domain]/chat/components/chatSidePanel.tsx

Walkthrough

Removes router.refresh() calls immediately after router.push() operations across multiple files to fix navigation behavior after Next.js 16 upgrade. Adds documentation and changelog entry detailing the race condition issue and providing usage guidance.

Changes

Cohort / File(s) Summary
Documentation
CHANGELOG.md, CLAUDE.md
Added entries documenting the fix for router.refresh() calls after router.push() in Next.js 16, including usage examples and guidance on alternative approaches.
Chat Features
packages/web/src/app/[domain]/chat/components/chatName.tsx, packages/web/src/app/[domain]/chat/components/chatSidePanel.tsx, packages/web/src/features/chat/useCreateNewChatThread.ts
Removed router.refresh() calls after successful chat operations and navigation, eliminating forced route refreshes.
Settings Features
packages/web/src/app/[domain]/settings/members/components/inviteMemberCard.tsx
Removed router.refresh() call after successful invite submission.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: removing router.refresh() calls after router.push() to fix a Next.js 16 navigation issue, which aligns with all the code changes across four files.
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 docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch brendan/fix-router-refresh-next16

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.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@brendan-kellam brendan-kellam merged commit 65cceec into main Mar 2, 2026
8 checks passed
@brendan-kellam brendan-kellam deleted the brendan/fix-router-refresh-next16 branch March 2, 2026 20:22
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