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({
const
hasBoundaries
=
Object
.
values
(
boundaries
).
some
(
(
boundary
)
=>
boundary
!==
null
)
const
isPage
File
=
fileType
===
'page'
const
isPage
OrBoundary
=
fileType
&&
!
isBoundaryFile
(
fileType
)
const
openInEditor
=
useCallback
(({
filePath
}:
{
filePath
:
string
})
=>
{
const
params
=
new
URLSearchParams
({
...
...
@@ -158,7 +158,10 @@ export function SegmentBoundaryTrigger({
)
// 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
(
<
button
className=
"segment-boundary-trigger"
...
...
@@ -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
=
(
triggerProps
:
React
.
ComponentProps
<
'button'
>
&
{
ref
?:
React
.
Ref
<
HTMLButtonElement
>
...
...
@@ -187,7 +185,7 @@ export function SegmentBoundaryTrigger({
return
(
<
button
{
...
triggerProps
}
ref=
{
mergedRef
}
type=
"button"
>
<
span
className=
"segment-boundary-trigger-text"
>
{
isPage
File
{
isPage
OrBoundary
?
pageFileName
:
boundaryType
===
null
?
// TODO(pran): improve the UX of the default boundary selector
...
...
@@ -206,7 +204,7 @@ export function SegmentBoundaryTrigger({
<
Menu
.
Trigger
className=
{
cx
(
'segment-boundary-trigger'
,
!
isPage
File
&&
'segment-boundary-trigger--boundary'
,
!
isPage
OrBoundary
&&
'segment-boundary-trigger--boundary'
,
isOverridden
&&
'segment-boundary-trigger--overridden'
)
}
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 {
import
{
Tooltip
}
from
'../../../components/tooltip'
import
{
useRef
,
useState
,
useCallback
,
useMemo
}
from
'react'
import
{
BOUNDARY_PREFIX
,
BUILTIN_PREFIX
,
isBoundaryFile
,
normalizeBoundaryFilename
,
}
from
'../../../../server/app-render/segment-explorer-path'
...
...
@@ -43,7 +45,7 @@ function countActiveBoundaries(node: SegmentTrieNode): number {
if
(
node
.
value
?.
setBoundaryType
&&
node
.
value
.
boundaryType
!==
null
&&
!
node
.
value
.
type
.
startsWith
(
'boundary:'
)
!
isBoundaryFile
(
node
.
value
.
type
)
)
{
count
++
}
...
...
@@ -178,6 +180,12 @@ function PageSegmentTreeLayerPresentation({
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
const
aFilePath
=
node
.
children
[
a
]?.
value
?.
pagePath
||
''
const
bFilePath
=
node
.
children
[
b
]?.
value
?.
pagePath
||
''
...
...
@@ -225,7 +233,7 @@ function PageSegmentTreeLayerPresentation({
filesChildrenKeys
.
forEach
((
childKey
)
=>
{
const
childNode
=
node
.
children
[
childKey
]
if
(
!
childNode
||
!
childNode
.
value
)
return
if
(
childNode
.
value
.
type
.
startsWith
(
'boundary:'
))
{
if
(
isBoundaryFile
(
childNode
.
value
.
type
))
{
const
boundaryType
=
childNode
.
value
.
type
.
split
(
':'
)[
1
]
as
|
'not-found'
|
'loading'
...
...
@@ -243,7 +251,7 @@ function PageSegmentTreeLayerPresentation({
if
(
!
childNode
||
!
childNode
.
value
)
return
true
const
type
=
childNode
.
value
.
type
const
selectedBoundaryType
=
firstChild
?.
value
?.
type
?.
replace
(
'boundary:'
,
BOUNDARY_PREFIX
,
''
)
if
(
...
...
@@ -294,7 +302,7 @@ function PageSegmentTreeLayerPresentation({
}
// 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.
if
(
childNode
.
value
.
type
.
startsWith
(
'boundary:'
))
{
if
(
isBoundaryFile
(
childNode
.
value
.
type
))
{
return
null
}
// 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 {
UseCachePageComponentProps
,
}
from
'../use-cache/use-cache-wrapper'
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.
...
...
@@ -562,24 +566,24 @@ async function createComponentTreeInternal({
// Add a suffix to avoid conflict with the segment view node representing rendered file.
// existence: not-found.tsx@boundary
// rendered: not-found.tsx
const
fileNameSuffix
=
'@boundary'
const
fileNameSuffix
=
BOUNDARY_SUFFIX
const
segmentViewBoundaries
=
isSegmentViewEnabled
?
(
<>
{
notFoundFilePath
&&
(
<
SegmentViewNode
type=
{
'boundary:not-found'
}
type=
{
`${BOUNDARY_PREFIX}not-found`
}
pagePath=
{
notFoundFilePath
+
fileNameSuffix
}
/>
)
}
{
loadingFilePath
&&
(
<
SegmentViewNode
type=
{
'boundary:loading'
}
type=
{
`${BOUNDARY_PREFIX}loading`
}
pagePath=
{
loadingFilePath
+
fileNameSuffix
}
/>
)
}
{
errorFilePath
&&
(
<
SegmentViewNode
type=
{
'boundary:error'
}
type=
{
`${BOUNDARY_PREFIX}error`
}
pagePath=
{
errorFilePath
+
fileNameSuffix
}
/>
)
}
...
...
packages/next/src/server/app-render/segment-explorer-path.ts
View file @
d2207067
...
...
@@ -30,10 +30,16 @@ export function normalizeConventionFilePath(
return
relativePath
}
export
const
BOUNDARY_SUFFIX
=
'@boundary'
export
function
normalizeBoundaryFilename
(
filename
:
string
)
{
return
filename
.
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
(
...
...
test/development/app-dir/segment-explorer/segment-explorer.test.ts
View file @
d2207067
...
...
@@ -28,15 +28,16 @@ describe('segment-explorer', () => {
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
"app/
layout.tsx
boundary
parallel-routes/
layout.tsx
page.tsx
@bar/
layout.tsx
page.tsx
boundary
@foo/
layout.tsx
page.tsx
"
boundary
"
`
)
})
...
...
@@ -45,6 +46,7 @@ describe('segment-explorer', () => {
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
"app/
layout.tsx
boundary
parallel-routes-edge/
layout.tsx
page.tsx
...
...
@@ -62,6 +64,7 @@ describe('segment-explorer', () => {
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
"app/
layout.tsx
boundary
(v2)/
layout.tsx
blog / (team)/
...
...
@@ -79,6 +82,7 @@ describe('segment-explorer', () => {
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
"app/
layout.tsx
boundary
soft-navigation / a/
page.tsx"
`
)
...
...
@@ -91,6 +95,7 @@ describe('segment-explorer', () => {
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
"app/
layout.tsx
boundary
soft-navigation / b/
page.tsx"
`
)
...
...
@@ -101,6 +106,7 @@ describe('segment-explorer', () => {
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
"app/
layout.tsx
boundary
(all) / file-segments/
layout.tsx
template.tsx
...
...
@@ -137,27 +143,32 @@ describe('segment-explorer', () => {
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
"app/
layout.tsx
boundary
boundary/
layout.tsx
not-found.tsx
"
boundary
"
`
)
await
browser
.
loadPage
(
`
${
next
.
url
}
/boundary?name=forbidden`
)
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
"app/
layout.tsx
boundary
boundary/
layout.tsx
forbidden.tsx"
forbidden.tsx
boundary"
`
)
await
browser
.
loadPage
(
`
${
next
.
url
}
/boundary?name=unauthorized`
)
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
"app/
layout.tsx
boundary
boundary/
layout.tsx
unauthorized.tsx"
unauthorized.tsx
boundary"
`
)
})
...
...
@@ -174,9 +185,10 @@ describe('segment-explorer', () => {
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
"app/
layout.tsx
boundary
search/
layout.tsx
loading.tsx
"
boundary
"
`
)
})
...
...
@@ -185,8 +197,9 @@ describe('segment-explorer', () => {
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
"app/
layout.tsx
boundary
runtime-error / boundary/
error.tsx
"
boundary
"
`
)
})
...
...
@@ -195,6 +208,7 @@ describe('segment-explorer', () => {
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
"app/
layout.tsx
boundary
parallel-default/
layout.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