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
27250721
Unverified
Commit
27250721
authored
Jul 11, 2025
by
Jiachi Liu
Committed by
GitHub
Jul 11, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[segment explorer] redesign file pills and boundary trigger (#81302)
parent
f0241781
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
640 additions
and
219 deletions
+640
-219
tooltip.css
packages/next/src/next-devtools/components/tooltip.css
+0
-1
tooltip.tsx
packages/next/src/next-devtools/components/tooltip.tsx
+18
-7
utils.ts
...ev-overlay/components/errors/dev-tools-indicator/utils.ts
+8
-7
segment-boundary-trigger.css
...-overlay/components/overview/segment-boundary-trigger.css
+58
-24
segment-boundary-trigger.tsx
...-overlay/components/overview/segment-boundary-trigger.tsx
+183
-75
segment-explorer.css
...ools/dev-overlay/components/overview/segment-explorer.css
+92
-26
segment-explorer.tsx
...ools/dev-overlay/components/overview/segment-explorer.tsx
+229
-78
create-component-tree.tsx
...ages/next/src/server/app-render/create-component-tree.tsx
+2
-1
layout.tsx
.../segment-explorer/app/no-layout/framework/blog/layout.tsx
+11
-0
not-found.tsx
...gment-explorer/app/no-layout/framework/blog/not-found.tsx
+3
-0
page.tsx
...ir/segment-explorer/app/no-layout/framework/blog/page.tsx
+3
-0
layout.tsx
...p-dir/segment-explorer/app/no-layout/framework/layout.tsx
+11
-0
not-found.tsx
...ment/app-dir/segment-explorer/app/no-layout/not-found.tsx
+3
-0
error.tsx
...p-dir/segment-explorer/app/parallel-routes/@bar/error.tsx
+5
-0
segment-explorer.test.ts
...lopment/app-dir/segment-explorer/segment-explorer.test.ts
+14
-0
No files found.
packages/next/src/next-devtools/components/tooltip.css
View file @
27250721
...
...
@@ -10,7 +10,6 @@
border-radius
:
8px
;
font-size
:
14px
;
line-height
:
1.4
;
min-width
:
200px
;
pointer-events
:
none
;
}
...
...
packages/next/src/next-devtools/components/tooltip.tsx
View file @
27250721
import
{
forwardRef
}
from
'react'
import
{
forwardRef
,
useRef
,
useState
}
from
'react'
import
{
Tooltip
as
BaseTooltip
}
from
'@base-ui-components/react/tooltip'
import
{
cx
}
from
'../dev-overlay/utils/cx'
import
'./tooltip.css'
...
...
@@ -7,22 +7,22 @@ type TooltipDirection = 'top' | 'bottom' | 'left' | 'right'
interface
TooltipProps
{
children
:
React
.
ReactNode
title
:
string
title
:
string
|
null
direction
?:
TooltipDirection
container
?:
HTMLElement
|
React
.
RefObject
<
HTMLElement
>
arrowSize
?:
number
offset
?:
number
bgcolor
?:
string
color
?:
string
className
?:
string
}
export
const
Tooltip
=
forwardRef
<
HTMLDivElement
,
TooltipProps
>
(
function
Tooltip
(
{
className
,
children
,
title
,
direction
=
'top'
,
container
,
arrowSize
=
6
,
offset
=
8
,
bgcolor
=
'#000'
,
...
...
@@ -30,9 +30,18 @@ export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
},
ref
)
{
const
[
shadowRoot
]
=
useState
<
ShadowRoot
>
(()
=>
{
const
ownerDocument
=
document
const
portalNode
=
ownerDocument
.
querySelector
(
'nextjs-portal'
)
!
return
portalNode
.
shadowRoot
!
as
ShadowRoot
})
const
shadowRootRef
=
useRef
<
ShadowRoot
>
(
shadowRoot
)
if
(
!
title
)
{
return
children
}
return
(
<
BaseTooltip
.
Provider
>
<
BaseTooltip
.
Root
delay=
{
0
}
>
<
BaseTooltip
.
Root
delay=
{
40
0
}
>
<
BaseTooltip
.
Trigger
ref=
{
ref
}
render=
{
(
triggerProps
)
=>
{
...
...
@@ -40,7 +49,9 @@ export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
}
}
/>
<
BaseTooltip
.
Portal
{
...
(
container
&&
{
container
})}
>
{
/* x-ref: https://github.com/mui/base-ui/issues/2224 */
}
{
/* @ts-expect-error remove this expect-error once shadowRoot is supported as container */
}
<
BaseTooltip
.
Portal
container=
{
shadowRootRef
}
>
<
BaseTooltip
.
Positioner
side=
{
direction
}
sideOffset=
{
offset
+
arrowSize
}
...
...
@@ -53,7 +64,7 @@ export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
}
>
<
BaseTooltip
.
Popup
className=
"tooltip"
className=
{
cx
(
'tooltip'
,
className
)
}
style=
{
{
backgroundColor
:
bgcolor
,
...
...
packages/next/src/next-devtools/dev-overlay/components/errors/dev-tools-indicator/utils.ts
View file @
27250721
...
...
@@ -84,14 +84,15 @@ export function useClickOutside(
rootRef
:
React
.
RefObject
<
HTMLElement
|
null
>
,
triggerRef
:
React
.
RefObject
<
HTMLButtonElement
|
null
>
,
active
:
boolean
,
close
:
()
=>
void
close
:
()
=>
void
,
ownerDocument
?:
Document
)
{
useEffect
(()
=>
{
if
(
!
active
)
{
return
}
const
ownerDocument
=
rootRef
.
current
?.
ownerDocument
const
ownerDocument
El
=
ownerDocument
||
rootRef
.
current
?.
ownerDocument
function
handleClickOutside
(
event
:
MouseEvent
)
{
const
target
=
event
.
target
as
HTMLElement
...
...
@@ -124,15 +125,15 @@ export function useClickOutside(
}
}
ownerDocument
?.
addEventListener
(
'mousedown'
,
handleClickOutside
)
ownerDocument
?.
addEventListener
(
'keydown'
,
handleKeyDown
)
ownerDocument
El
?.
addEventListener
(
'mousedown'
,
handleClickOutside
)
ownerDocument
El
?.
addEventListener
(
'keydown'
,
handleKeyDown
)
return
()
=>
{
ownerDocument
?.
removeEventListener
(
'mousedown'
,
handleClickOutside
)
ownerDocument
?.
removeEventListener
(
'keydown'
,
handleKeyDown
)
ownerDocument
El
?.
removeEventListener
(
'mousedown'
,
handleClickOutside
)
ownerDocument
El
?.
removeEventListener
(
'keydown'
,
handleKeyDown
)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
},
[
active
])
},
[
active
,
rootRef
,
triggerRef
])
}
//////////////////////////////////////////////////////////////////////////////////////
...
...
packages/next/src/next-devtools/dev-overlay/components/overview/segment-boundary-trigger.css
View file @
27250721
.segment-boundary-trigger
{
margin-left
:
auto
;
gap
:
8px
;
}
.segment-boundary-trigger-button
{
width
:
24px
;
height
:
24px
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
gap
:
4px
;
padding
:
4px
6px
;
line-height
:
16px
;
font-weight
:
500
;
color
:
var
(
--color-gray-1000
);
border-radius
:
6px
;
background
:
transparent
;
border-radius
:
999px
;
border
:
none
;
font-size
:
var
(
--size-12
);
cursor
:
pointer
;
transition
:
background-color
0.15s
ease
;
}
.segment-boundary-trigger-text
{
font-size
:
var
(
--size-12
);
font-weight
:
500
;
user-select
:
none
;
display
:
inline-flex
;
align-items
:
center
;
justify-content
:
center
;
}
.segment-boundary-trigger-button
svg
{
width
:
20px
;
height
:
20px
;
.segment-boundary-trigger-text
.plus-icon
{
transition
:
transform
0.25s
ease
;
}
.segment-boundary-trigger-button
:hover
{
background
:
var
(
--color-gray-400
);
color
:
var
(
--color-gray-1000
);
.segment-boundary-trigger-text
:hover
.plus-icon
{
color
:
var
(
--color-gray-800
);
}
.segment-boundary-trigger
svg
{
width
:
14px
;
height
:
14px
;
flex-shrink
:
0
;
vertical-align
:
middle
;
}
.segment-boundary-trigger
:hover
svg
{
color
:
var
(
--color-gray-700
);
}
.segment-boundary-trigger
[
disabled
]
svg
,
.segment-boundary-trigger
[
disabled
]
:hover
svg
{
color
:
var
(
--color-gray-400
);
cursor
:
not-allowed
;
}
.segment-boundary-trigger--boundary
{
background
:
var
(
--color-background-100
);
box-shadow
:
inset
0
0
0
1px
var
(
--color-gray-400
);
}
.segment-boundary-trigger--boundary
:hover
{
background
:
var
(
--color-gray-200
);
}
.segment-boundary-dropdown
{
padding
:
8px
;
background
:
var
(
--color-background-100
);
border
:
1px
solid
var
(
--color-gray-400
);
border-radius
:
6px
;
box-shadow
:
0
2px
8px
rgba
(
0
,
0
,
0
,
0.1
);
border-radius
:
16px
;
min-width
:
120px
;
user-select
:
none
;
cursor
:
default
;
box-shadow
:
0px
4px
8px
-4px
color-mix
(
in
srgb
,
var
(
--color-gray-900
)
4%
,
transparent
);
}
.segment-boundary-dropdown-positioner
{
z-index
:
2147483648
;
z-index
:
var
(
--top-z-index
)
;
}
.segment-boundary-dropdown-item
{
display
:
flex
;
align-items
:
center
;
padding
:
10px
8px
;
padding
:
8px
;
line-height
:
20px
;
font-size
:
14px
;
border-radius
:
6px
;
...
...
@@ -78,8 +110,10 @@
border-bottom-right-radius
:
4px
;
}
.segment-boundary-dropdown-divider
{
height
:
1px
;
background
:
var
(
--color-gray-400
);
margin
:
8px
0
;
.segment-boundary-group-label
{
padding
:
8px
;
font-size
:
13px
;
line-height
:
16px
;
font-weight
:
400
;
color
:
var
(
--color-gray-900
);
}
packages/next/src/next-devtools/dev-overlay/components/overview/segment-boundary-trigger.tsx
View file @
27250721
This diff is collapsed.
Click to expand it.
packages/next/src/next-devtools/dev-overlay/components/overview/segment-explorer.css
View file @
27250721
.segment-explorer-content
{
font-size
:
var
(
--size-14
);
padding
:
0
8px
;
width
:
700px
;
height
:
400px
;
max-width
:
calc
(
100vw
-
40px
);
max-height
:
calc
(
100vh
-
240px
);
}
.segment-explorer-page-route-bar
{
...
...
@@ -17,6 +21,7 @@
color
:
var
(
--color-gray-1000
);
font-family
:
var
(
--font-mono
);
white-space
:
nowrap
;
line-height
:
20px
;
}
.segment-explorer-item
{
...
...
@@ -54,7 +59,7 @@
}
.segment-explorer-filename--path
{
margin-right
:
8px
;
margin-right
:
auto
;
}
.segment-explorer-filename--path
small
{
display
:
inline-block
;
...
...
@@ -68,57 +73,118 @@
.segment-explorer-files
{
display
:
inline-flex
;
gap
:
8px
;
margin-left
:
auto
;
}
.segment-explorer-files
+
.segment-boundary-trigger
{
margin-left
:
8px
;
}
.segment-explorer-file-label
{
display
:
inline-flex
;
align-items
:
center
;
justify-content
:
center
;
height
:
20px
;
padding
:
2px
6px
;
padding
:
4px
6px
;
border-radius
:
16px
;
line-height
:
16px
;
font-size
:
var
(
--size-12
);
font-weight
:
500
;
user-select
:
none
;
cursor
:
pointer
;
}
.segment-explorer-file-label
:hover
{
filter
:
brightness
(
1.05
);
}
.segment-explorer-file-label--layout
,
.segment-explorer-file-label--template
,
.segment-explorer-file-label--default
{
background-color
:
var
(
--color-gray-300
);
color
:
var
(
--color-gray-1000
);
}
.segment-explorer-file-label--page
{
background-color
:
var
(
--color-blue-300
);
color
:
var
(
--color-blue-900
);
}
.segment-explorer-file-label--not-found
,
.segment-explorer-file-label--forbidden
,
.segment-explorer-file-label--unauthorized
{
.segment-explorer-file-label--overridden
{
background-color
:
var
(
--color-amber-300
);
color
:
var
(
--color-amber-900
);
}
.segment-explorer-file-label--loading
{
background-color
:
var
(
--color-green-300
);
color
:
var
(
--color-green-900
);
.segment-explorer-file-label
.code-icon
{
opacity
:
0
;
margin-left
:
0
;
width
:
0
;
transition
:
all
0.15s
ease-in-out
;
}
.segment-explorer-file-label--error
,
.segment-explorer-file-label--global-error
{
background-color
:
var
(
--color-red-300
);
color
:
var
(
--color-red-900
);
.segment-explorer-file-label
:hover
.code-icon
{
opacity
:
1
;
width
:
12px
;
margin-left
:
4px
;
}
.segment-explorer-file-label
:hover
{
filter
:
brightness
(
0.95
);
}
.segment-explorer-file-label--builtin
{
background-color
:
transparent
;
color
:
var
(
--color-gray-900
);
border
:
1px
dashed
var
(
--color-gray-500
);
height
:
24px
;
cursor
:
default
;
}
.segment-explorer-file-label--builtin
svg
{
margin-left
:
4px
;
margin-right
:
-4px
;
}
/* Footer styles */
.segment-explorer-footer
{
padding
:
8px
;
border-top
:
1px
solid
var
(
--color-gray-400
);
background-color
:
var
(
--color-background-100
);
user-select
:
none
;
}
.segment-explorer-footer-button
{
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
gap
:
8px
;
width
:
100%
;
padding
:
6px
;
background
:
var
(
--color-background-100
);
border
:
1px
solid
var
(
--color-gray-400
);
border-radius
:
6px
;
color
:
var
(
--color-gray-1000
);
font-size
:
var
(
--size-14
);
font-weight
:
500
;
cursor
:
pointer
;
transition
:
background-color
0.15s
ease
;
}
.segment-explorer-footer-button
:hover:not
(
:disabled
)
{
background
:
var
(
--color-gray-200
);
}
.segment-explorer-footer-button--disabled
{
opacity
:
0.5
;
cursor
:
not-allowed
;
}
.segment-explorer-footer-text
{
text-align
:
center
;
}
.segment-explorer-footer-badge
{
display
:
inline-flex
;
align-items
:
center
;
justify-content
:
center
;
min-width
:
20px
;
height
:
20px
;
padding
:
0
6px
;
background
:
var
(
--color-amber-300
);
color
:
var
(
--color-amber-900
);
border-radius
:
10px
;
font-size
:
var
(
--size-12
);
font-weight
:
600
;
line-height
:
1
;
}
.segment-explorer-file-label-tooltip--sm
{
white-space
:
nowrap
;
}
.segment-explorer-file-label-tooltip--lg
{
min-width
:
200px
;
}
packages/next/src/next-devtools/dev-overlay/components/overview/segment-explorer.tsx
View file @
27250721
This diff is collapsed.
Click to expand it.
packages/next/src/server/app-render/create-component-tree.tsx
View file @
27250721
...
...
@@ -28,6 +28,7 @@ import type {
import
{
DEFAULT_SEGMENT_KEY
}
from
'../../shared/lib/segment'
import
{
BOUNDARY_PREFIX
,
BOUNDARY_SUFFIX
,
getConventionPathByType
,
}
from
'./segment-explorer-path'
...
...
@@ -565,7 +566,7 @@ 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
&&
(
...
...
test/development/app-dir/segment-explorer/app/no-layout/framework/blog/layout.tsx
0 → 100644
View file @
27250721
import
Link
from
'next/link'
export
default
function
Layout
({
children
}:
{
children
:
React
.
ReactNode
})
{
return
(
<
div
>
<
h2
>
Layout - /no-layout/framework/blog
</
h2
>
{
children
}
<
Link
href=
"/no-layout/framework"
>
To /no-layout/framework
</
Link
>
</
div
>
)
}
test/development/app-dir/segment-explorer/app/no-layout/framework/blog/not-found.tsx
0 → 100644
View file @
27250721
export
default
function
NotFound
()
{
return
<
div
>
Not Found - /no-layout/framework/blog/not-found
</
div
>
}
test/development/app-dir/segment-explorer/app/no-layout/framework/blog/page.tsx
0 → 100644
View file @
27250721
export
default
function
Page
()
{
return
<
div
>
Page - /no-layout/framework/blog
</
div
>
}
test/development/app-dir/segment-explorer/app/no-layout/framework/layout.tsx
0 → 100644
View file @
27250721
import
Link
from
'next/link'
export
default
function
Layout
({
children
}:
{
children
:
React
.
ReactNode
})
{
return
(
<
div
>
<
h1
>
Layout - /no-layout/framework
</
h1
>
{
children
}
<
Link
href=
"/no-layout"
>
To /no-layout
</
Link
>
</
div
>
)
}
test/development/app-dir/segment-explorer/app/no-layout/not-found.tsx
0 → 100644
View file @
27250721
export
default
function
NotFound
()
{
return
<
div
>
Not Found - /no-layout
</
div
>
}
test/development/app-dir/segment-explorer/app/parallel-routes/@bar/error.tsx
0 → 100644
View file @
27250721
'use client'
export
default
function
Error
()
{
return
<
div
>
Error @bar
</
div
>
}
test/development/app-dir/segment-explorer/segment-explorer.test.ts
View file @
27250721
...
...
@@ -206,4 +206,18 @@ describe('segment-explorer', () => {
default.tsx"
`
)
})
it
(
'should display boundary selector when a segment has only boundary files'
,
async
()
=>
{
const
browser
=
await
next
.
browser
(
'/no-layout/framework/blog'
)
expect
(
await
getSegmentExplorerContent
(
browser
)).
toMatchInlineSnapshot
(
`
"app/
layout.tsx
no-layout/
framework/
layout.tsx
blog/
layout.tsx
page.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