Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
d2207067
Commit
d2207067
authored
Jul 07, 2025
by
Jiachi Liu
Committed by
RobPruzan
Jul 07, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix render files and update snapshot
parent
06bef45f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
26 deletions
+56
-26
segment-boundary-trigger.tsx
...-overlay/components/overview/segment-boundary-trigger.tsx
+7
-9
segment-explorer.tsx
...ools/dev-overlay/components/overview/segment-explorer.tsx
+12
-4
create-component-tree.tsx
...ages/next/src/server/app-render/create-component-tree.tsx
+9
-5
segment-explorer-path.ts
packages/next/src/server/app-render/segment-explorer-path.ts
+7
-1
segment-explorer.test.ts
...lopment/app-dir/segment-explorer/segment-explorer.test.ts
+21
-7
No files found.
packages/next/src/next-devtools/dev-overlay/components/overview/segment-boundary-trigger.tsx
View file @
d2207067
...
@@ -120,7 +120,7 @@ export function SegmentBoundaryTrigger({
...
@@ -120,7 +120,7 @@ export function SegmentBoundaryTrigger({
const
hasBoundaries
=
Object
.
values
(
boundaries
).
some
(
const
hasBoundaries
=
Object
.
values
(
boundaries
).
some
(
(
boundary
)
=>
boundary
!==
null
(
boundary
)
=>
boundary
!==
null
)
)
const
isPage
File
=
fileType
===
'page'
const
isPage
OrBoundary
=
fileType
&&
!
isBoundaryFile
(
fileType
)
const
openInEditor
=
useCallback
(({
filePath
}:
{
filePath
:
string
})
=>
{
const
openInEditor
=
useCallback
(({
filePath
}:
{
filePath
:
string
})
=>
{
const
params
=
new
URLSearchParams
({
const
params
=
new
URLSearchParams
({
...
@@ -158,7 +158,10 @@ export function SegmentBoundaryTrigger({
...
@@ -158,7 +158,10 @@ export function SegmentBoundaryTrigger({
)
)
// For non-page files, just render a simple button to open in editor
// For non-page files, just render a simple button to open in editor
if
(
fileType
!==
'page'
&&
!
fileType
.
startsWith
(
'boundary:'
))
{
if
(
!
(
fileType
===
'page'
||
fileType
===
'default'
)
&&
!
isBoundaryFile
(
fileType
)
)
{
return
(
return
(
<
button
<
button
className=
"segment-boundary-trigger"
className=
"segment-boundary-trigger"
...
@@ -172,11 +175,6 @@ export function SegmentBoundaryTrigger({
...
@@ -172,11 +175,6 @@ export function SegmentBoundaryTrigger({
)
)
}
}
// Don't render the dropdown if there are no boundaries and no page file
if
(
!
hasBoundaries
&&
!
isPageFile
)
{
return
null
}
const
Trigger
=
(
const
Trigger
=
(
triggerProps
:
React
.
ComponentProps
<
'button'
>
&
{
triggerProps
:
React
.
ComponentProps
<
'button'
>
&
{
ref
?:
React
.
Ref
<
HTMLButtonElement
>
ref
?:
React
.
Ref
<
HTMLButtonElement
>
...
@@ -187,7 +185,7 @@ export function SegmentBoundaryTrigger({
...
@@ -187,7 +185,7 @@ export function SegmentBoundaryTrigger({
return
(
return
(
<
button
{
...
triggerProps
}
ref=
{
mergedRef
}
type=
"button"
>
<
button
{
...
triggerProps
}
ref=
{
mergedRef
}
type=
"button"
>
<
span
className=
"segment-boundary-trigger-text"
>
<
span
className=
"segment-boundary-trigger-text"
>
{
isPage
File
{
isPage
OrBoundary
?
pageFileName
?
pageFileName
:
boundaryType
===
null
:
boundaryType
===
null
?
// TODO(pran): improve the UX of the default boundary selector
?
// TODO(pran): improve the UX of the default boundary selector
...
@@ -206,7 +204,7 @@ export function SegmentBoundaryTrigger({
...
@@ -206,7 +204,7 @@ export function SegmentBoundaryTrigger({
<
Menu
.
Trigger
<
Menu
.
Trigger
className=
{
cx
(
className=
{
cx
(
'segment-boundary-trigger'
,
'segment-boundary-trigger'
,
!
isPage
File
&&
'segment-boundary-trigger--boundary'
,
!
isPage
OrBoundary
&&
'segment-boundary-trigger--boundary'
,
isOverridden
&&
'segment-boundary-trigger--overridden'
isOverridden
&&
'segment-boundary-trigger--overridden'
)
}
)
}
data
-
nextjs
-
dev
-
overlay
-
segment
-
boundary
-
trigger
-
button
data
-
nextjs
-
dev
-
overlay
-
segment
-
boundary
-
trigger
-
button
...
...
packages/next/src/next-devtools/dev-overlay/components/overview/segment-explorer.tsx
View file @
d2207067
...
@@ -11,7 +11,9 @@ import {
...
@@ -11,7 +11,9 @@ import {
import
{
Tooltip
}
from
'../../../components/tooltip'
import
{
Tooltip
}
from
'../../../components/tooltip'
import
{
useRef
,
useState
,
useCallback
,
useMemo
}
from
'react'
import
{
useRef
,
useState
,
useCallback
,
useMemo
}
from
'react'
import
{
import
{
BOUNDARY_PREFIX
,
BUILTIN_PREFIX
,
BUILTIN_PREFIX
,
isBoundaryFile
,
normalizeBoundaryFilename
,
normalizeBoundaryFilename
,
}
from
'../../../../server/app-render/segment-explorer-path'
}
from
'../../../../server/app-render/segment-explorer-path'
...
@@ -43,7 +45,7 @@ function countActiveBoundaries(node: SegmentTrieNode): number {
...
@@ -43,7 +45,7 @@ function countActiveBoundaries(node: SegmentTrieNode): number {
if
(
if
(
node
.
value
?.
setBoundaryType
&&
node
.
value
?.
setBoundaryType
&&
node
.
value
.
boundaryType
!==
null
&&
node
.
value
.
boundaryType
!==
null
&&
!
node
.
value
.
type
.
startsWith
(
'boundary:'
)
!
isBoundaryFile
(
node
.
value
.
type
)
)
{
)
{
count
++
count
++
}
}
...
@@ -178,6 +180,12 @@ function PageSegmentTreeLayerPresentation({
...
@@ -178,6 +180,12 @@ function PageSegmentTreeLayerPresentation({
if
(
aType
===
'template'
&&
bType
!==
'template'
)
return
-
1
if
(
aType
===
'template'
&&
bType
!==
'template'
)
return
-
1
if
(
aType
!==
'template'
&&
bType
===
'template'
)
return
1
if
(
aType
!==
'template'
&&
bType
===
'template'
)
return
1
// non boundary files are prioritized than boundary files
if
(
aType
&&
bType
)
{
if
(
isBoundaryFile
(
aType
)
&&
!
isBoundaryFile
(
bType
))
return
1
if
(
!
isBoundaryFile
(
aType
)
&&
isBoundaryFile
(
bType
))
return
-
1
}
// If both are the same type, sort by pagePath
// If both are the same type, sort by pagePath
const
aFilePath
=
node
.
children
[
a
]?.
value
?.
pagePath
||
''
const
aFilePath
=
node
.
children
[
a
]?.
value
?.
pagePath
||
''
const
bFilePath
=
node
.
children
[
b
]?.
value
?.
pagePath
||
''
const
bFilePath
=
node
.
children
[
b
]?.
value
?.
pagePath
||
''
...
@@ -225,7 +233,7 @@ function PageSegmentTreeLayerPresentation({
...
@@ -225,7 +233,7 @@ function PageSegmentTreeLayerPresentation({
filesChildrenKeys
.
forEach
((
childKey
)
=>
{
filesChildrenKeys
.
forEach
((
childKey
)
=>
{
const
childNode
=
node
.
children
[
childKey
]
const
childNode
=
node
.
children
[
childKey
]
if
(
!
childNode
||
!
childNode
.
value
)
return
if
(
!
childNode
||
!
childNode
.
value
)
return
if
(
childNode
.
value
.
type
.
startsWith
(
'boundary:'
))
{
if
(
isBoundaryFile
(
childNode
.
value
.
type
))
{
const
boundaryType
=
childNode
.
value
.
type
.
split
(
':'
)[
1
]
as
const
boundaryType
=
childNode
.
value
.
type
.
split
(
':'
)[
1
]
as
|
'not-found'
|
'not-found'
|
'loading'
|
'loading'
...
@@ -243,7 +251,7 @@ function PageSegmentTreeLayerPresentation({
...
@@ -243,7 +251,7 @@ function PageSegmentTreeLayerPresentation({
if
(
!
childNode
||
!
childNode
.
value
)
return
true
if
(
!
childNode
||
!
childNode
.
value
)
return
true
const
type
=
childNode
.
value
.
type
const
type
=
childNode
.
value
.
type
const
selectedBoundaryType
=
firstChild
?.
value
?.
type
?.
replace
(
const
selectedBoundaryType
=
firstChild
?.
value
?.
type
?.
replace
(
'boundary:'
,
BOUNDARY_PREFIX
,
''
''
)
)
if
(
if
(
...
@@ -294,7 +302,7 @@ function PageSegmentTreeLayerPresentation({
...
@@ -294,7 +302,7 @@ function PageSegmentTreeLayerPresentation({
}
}
// If it's boundary node, which marks the existence of the boundary not the rendered status,
// If it's boundary node, which marks the existence of the boundary not the rendered status,
// we don't need to present in the rendered files.
// we don't need to present in the rendered files.
if
(
childNode
.
value
.
type
.
startsWith
(
'boundary:'
))
{
if
(
isBoundaryFile
(
childNode
.
value
.
type
))
{
return
null
return
null
}
}
// If it's a page file, don't show it as a separate label since it's represented by the dropdown button
// If it's a page file, don't show it as a separate label since it's represented by the dropdown button
...
...
packages/next/src/server/app-render/create-component-tree.tsx
View file @
d2207067
...
@@ -26,7 +26,11 @@ import type {
...
@@ -26,7 +26,11 @@ import type {
UseCachePageComponentProps
,
UseCachePageComponentProps
,
}
from
'../use-cache/use-cache-wrapper'
}
from
'../use-cache/use-cache-wrapper'
import
{
DEFAULT_SEGMENT_KEY
}
from
'../../shared/lib/segment'
import
{
DEFAULT_SEGMENT_KEY
}
from
'../../shared/lib/segment'
import
{
getConventionPathByType
}
from
'./segment-explorer-path'
import
{
BOUNDARY_PREFIX
,
BOUNDARY_SUFFIX
,
getConventionPathByType
,
}
from
'./segment-explorer-path'
/**
/**
* Use the provided loader tree to create the React Component tree.
* Use the provided loader tree to create the React Component tree.
...
@@ -562,24 +566,24 @@ async function createComponentTreeInternal({
...
@@ -562,24 +566,24 @@ async function createComponentTreeInternal({
// Add a suffix to avoid conflict with the segment view node representing rendered file.
// Add a suffix to avoid conflict with the segment view node representing rendered file.
// existence: not-found.tsx@boundary
// existence: not-found.tsx@boundary
// rendered: not-found.tsx
// rendered: not-found.tsx
const
fileNameSuffix
=
'@boundary'
const
fileNameSuffix
=
BOUNDARY_SUFFIX
const
segmentViewBoundaries
=
isSegmentViewEnabled
?
(
const
segmentViewBoundaries
=
isSegmentViewEnabled
?
(
<>
<>
{
notFoundFilePath
&&
(
{
notFoundFilePath
&&
(
<
SegmentViewNode
<
SegmentViewNode
type=
{
'boundary:not-found'
}
type=
{
`${BOUNDARY_PREFIX}not-found`
}
pagePath=
{
notFoundFilePath
+
fileNameSuffix
}
pagePath=
{
notFoundFilePath
+
fileNameSuffix
}
/>
/>
)
}
)
}
{
loadingFilePath
&&
(
{
loadingFilePath
&&
(
<
SegmentViewNode
<
SegmentViewNode
type=
{
'boundary:loading'
}
type=
{
`${BOUNDARY_PREFIX}loading`
}
pagePath=
{
loadingFilePath
+
fileNameSuffix
}
pagePath=
{
loadingFilePath
+
fileNameSuffix
}
/>
/>
)
}
)
}
{
errorFilePath
&&
(
{
errorFilePath
&&
(
<
SegmentViewNode
<
SegmentViewNode
type=
{
'boundary:error'
}
type=
{
`${BOUNDARY_PREFIX}error`
}
pagePath=
{
errorFilePath
+
fileNameSuffix
}
pagePath=
{
errorFilePath
+
fileNameSuffix
}
/>
/>
)
}
)
}
...
...
packages/next/src/server/app-render/segment-explorer-path.ts
View file @
d2207067
...
@@ -30,10 +30,16 @@ export function normalizeConventionFilePath(
...
@@ -30,10 +30,16 @@ export function normalizeConventionFilePath(
return
relativePath
return
relativePath
}
}
export
const
BOUNDARY_SUFFIX
=
'@boundary'
export
function
normalizeBoundaryFilename
(
filename
:
string
)
{
export
function
normalizeBoundaryFilename
(
filename
:
string
)
{
return
filename
return
filename
.
replace
(
new
RegExp
(
`^
${
BUILTIN_PREFIX
}
`
),
''
)
.
replace
(
new
RegExp
(
`^
${
BUILTIN_PREFIX
}
`
),
''
)
.
replace
(
/@boundary$/
,
''
)
.
replace
(
new
RegExp
(
`
${
BOUNDARY_SUFFIX
}
$`
),
''
)
}
export
const
BOUNDARY_PREFIX
=
'boundary:'
export
function
isBoundaryFile
(
fileType
:
string
)
{
return
fileType
.
startsWith
(
BOUNDARY_PREFIX
)
}
}
export
function
getConventionPathByType
(
export
function
getConventionPathByType
(
...
...
test/development/app-dir/segment-explorer/segment-explorer.test.ts
View file @
d2207067
...
@@ -28,15 +28,16 @@ describe('segment-explorer', () => {
...
@@ -28,15 +28,16 @@ describe('segment-explorer', () => {
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
"app/
"app/
layout.tsx
layout.tsx
boundary
parallel-routes/
parallel-routes/
layout.tsx
layout.tsx
page.tsx
page.tsx
@bar/
@bar/
layout.tsx
layout.tsx
page.tsx
boundary
@foo/
@foo/
layout.tsx
layout.tsx
page.tsx
"
boundary
"
`
)
`
)
})
})
...
@@ -45,6 +46,7 @@ describe('segment-explorer', () => {
...
@@ -45,6 +46,7 @@ describe('segment-explorer', () => {
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
"app/
"app/
layout.tsx
layout.tsx
boundary
parallel-routes-edge/
parallel-routes-edge/
layout.tsx
layout.tsx
page.tsx
page.tsx
...
@@ -62,6 +64,7 @@ describe('segment-explorer', () => {
...
@@ -62,6 +64,7 @@ describe('segment-explorer', () => {
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
"app/
"app/
layout.tsx
layout.tsx
boundary
(v2)/
(v2)/
layout.tsx
layout.tsx
blog / (team)/
blog / (team)/
...
@@ -79,6 +82,7 @@ describe('segment-explorer', () => {
...
@@ -79,6 +82,7 @@ describe('segment-explorer', () => {
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
"app/
"app/
layout.tsx
layout.tsx
boundary
soft-navigation / a/
soft-navigation / a/
page.tsx"
page.tsx"
`
)
`
)
...
@@ -91,6 +95,7 @@ describe('segment-explorer', () => {
...
@@ -91,6 +95,7 @@ describe('segment-explorer', () => {
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
"app/
"app/
layout.tsx
layout.tsx
boundary
soft-navigation / b/
soft-navigation / b/
page.tsx"
page.tsx"
`
)
`
)
...
@@ -101,6 +106,7 @@ describe('segment-explorer', () => {
...
@@ -101,6 +106,7 @@ describe('segment-explorer', () => {
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
"app/
"app/
layout.tsx
layout.tsx
boundary
(all) / file-segments/
(all) / file-segments/
layout.tsx
layout.tsx
template.tsx
template.tsx
...
@@ -137,27 +143,32 @@ describe('segment-explorer', () => {
...
@@ -137,27 +143,32 @@ describe('segment-explorer', () => {
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
"app/
"app/
layout.tsx
layout.tsx
boundary
boundary/
boundary/
layout.tsx
layout.tsx
not-found.tsx
"
boundary
"
`
)
`
)
await
browser
.
loadPage
(
`
${
next
.
url
}
/boundary?name=forbidden`
)
await
browser
.
loadPage
(
`
${
next
.
url
}
/boundary?name=forbidden`
)
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
"app/
"app/
layout.tsx
layout.tsx
boundary
boundary/
boundary/
layout.tsx
layout.tsx
forbidden.tsx"
forbidden.tsx
boundary"
`
)
`
)
await
browser
.
loadPage
(
`
${
next
.
url
}
/boundary?name=unauthorized`
)
await
browser
.
loadPage
(
`
${
next
.
url
}
/boundary?name=unauthorized`
)
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
"app/
"app/
layout.tsx
layout.tsx
boundary
boundary/
boundary/
layout.tsx
layout.tsx
unauthorized.tsx"
unauthorized.tsx
boundary"
`
)
`
)
})
})
...
@@ -174,9 +185,10 @@ describe('segment-explorer', () => {
...
@@ -174,9 +185,10 @@ describe('segment-explorer', () => {
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
"app/
"app/
layout.tsx
layout.tsx
boundary
search/
search/
layout.tsx
layout.tsx
loading.tsx
"
boundary
"
`
)
`
)
})
})
...
@@ -185,8 +197,9 @@ describe('segment-explorer', () => {
...
@@ -185,8 +197,9 @@ describe('segment-explorer', () => {
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
"app/
"app/
layout.tsx
layout.tsx
boundary
runtime-error / boundary/
runtime-error / boundary/
error.tsx
"
boundary
"
`
)
`
)
})
})
...
@@ -195,6 +208,7 @@ describe('segment-explorer', () => {
...
@@ -195,6 +208,7 @@ describe('segment-explorer', () => {
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
"app/
"app/
layout.tsx
layout.tsx
boundary
parallel-default/
parallel-default/
layout.tsx
layout.tsx
default.tsx
default.tsx
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment