fix: route info segment overrides not updating in dev overlay - #96968
Open
mezotv wants to merge 1 commit into
Open
fix: route info segment overrides not updating in dev overlay#96968mezotv wants to merge 1 commit into
mezotv wants to merge 1 commit into
Conversation
The segment explorer trie mutated nodes in place and only shallow-copied the root, so consumers memoizing on node.children never saw insertions until remount. This made boundary overrides in the Route Info panel render stale state: toggled boundaries didn't appear, and the boundary picker disappeared after toggling or clearing overrides. Insert/remove now copy the nodes along the mutated path so changed nodes get fresh identities while untouched subtrees stay shared.
mezotv
marked this pull request as ready for review
August 8, 2026 10:41
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Previously, when using the built-in route segment override in the Next.js dev tools (Route Info panel), the UI was not updating: after toggling a boundary (e.g.
loading.jsornot-found.js) you couldn't switch back unless you closed the modal and reopened it, which slowed down my workflow. It's not a huge issue, but I thought I'd fix it.The cause was the segment explorer trie mutating nodes in place, so the panel's memoized view never picked up insertions until remount. Trie updates now copy the nodes along the mutated path (copy-on-write) so changed nodes get fresh identities while untouched subtrees stay shared.
Before
Switching from one override to another works, but the UI doesn't update — you have to close and reopen the panel.
Screen.Recording.2026-08-08.at.12.38.10.mov
After
Setting an override updates the DevTools UI immediately — no need to close and reopen the panel.
Screen.Recording.2026-08-08.at.12.35.33.mov
Verification
pnpm jest packages/next/src/next-devtools/dev-overlay/segment-explorer-trie.test.tsxpnpm test-dev-turbo test/development/app-dir/segment-explorer/segment-explorer.test.ts