Unverified Commit ed2c6b9b authored by Aurora Scharff's avatar Aurora Scharff Committed by GitHub

Refine the Security Insight upgrade prompt (#99354)

## Summary

Align the Security Insight with the existing DevTools and Insight-card
typography. The upgrade handoff remains agent-first, while the prompt is
easier to scan with:

- the standard Insight heading style
- normal body-copy spacing and typography
- a compact Agent prompt box with the existing Insight-style Copy prompt
action
- the exact paste-ready Markdown shown in the prompt body

Adds a Storybook example for visual review and keeps the clipboard
behavior covered by the existing test.

## Before and after

| Before | After |
| --- | --- |
| <img width="446" height="733" alt="Previous Vulnerability Insight"
src="https://github.com/user-attachments/assets/ae0bab2a-4549-4441-b27d-327ad49b16c5"
/> | <img width="446" height="733" alt="image"
src="https://github.com/user-attachments/assets/f37a4520-3516-4c9c-b529-9eb784be5b27"
/> |

## Verification

- Viewed the component in local Storybook at desktop and narrow widths.
- Focused formatting and ESLint checks passed.
- Integration test updated but not run; this draft was verified in
Storybook without a full framework build.

<!-- NEXT_JS_LLM -->
parent abe3b50d
......@@ -12,6 +12,7 @@ import { Resizer } from '../resizer'
import { useFocusTrap } from '../errors/dev-tools-indicator/utils'
import { CopyButton } from '../copy-button'
import { CodeFrameShell } from '../code-frame/code-frame-shell'
import { CopyPromptIcon } from '../../icons/copy-prompt'
import { css } from '../../utils/css'
export function VulnerabilityInsight({
......@@ -78,9 +79,12 @@ export function VulnerabilityInsight({
className="nextjs__container_errors_label nextjs__container_errors_label_instant"
data-nextjs-vulnerability-label
>
Vulnerability Insight
Security Insight
</span>
<h2 id="nextjs__container_errors_desc">
<h2
id="nextjs__container_errors_desc"
className="nextjs__container_errors_desc nextjs__container_errors_desc_instant"
>
Upgrade Next.js to a safe version.
</h2>
<p>
......@@ -91,24 +95,25 @@ export function VulnerabilityInsight({
</ErrorOverlayDialogHeader>
<ErrorOverlayDialogBody>
<div data-nextjs-vulnerability-action>
<p>
Copy the prompt and paste it into your coding agent to
upgrade this app.
</p>
<p>Ask your coding agent to upgrade:</p>
<CodeFrameShell
header={
<>
<span data-text>Upgrade prompt</span>
<span data-nextjs-vulnerability-prompt-title>
Agent prompt
</span>
<CopyButton
content={prompt}
actionLabel="Copy upgrade prompt"
actionLabel="Copy prompt"
successLabel="Copied"
icon={<CopyPromptIcon />}
showLabel
data-nextjs-vulnerability-copy
/>
</>
}
>
<code data-nextjs-vulnerability-prompt>{prompt}</code>
<span data-nextjs-vulnerability-prompt>{prompt}</span>
</CodeFrameShell>
</div>
</ErrorOverlayDialogBody>
......@@ -127,43 +132,75 @@ const styles = css`
}
[data-nextjs-vulnerability-insight] h2 {
margin: 16px 0 8px;
font-size: var(--size-20);
font-weight: 500;
color: var(--color-gray-1000);
}
[data-nextjs-vulnerability-insight] p,
[data-nextjs-vulnerability-action] > p {
margin: 8px 0;
font-size: var(--size-14);
line-height: var(--size-20);
font-family: var(--font-stack-sans);
letter-spacing: normal;
color: var(--color-gray-900);
}
[data-nextjs-vulnerability-action] {
display: flex;
flex-direction: column;
gap: 8px;
gap: 12px;
}
[data-nextjs-vulnerability-action] > p {
margin-bottom: 0;
}
[data-nextjs-vulnerability-action] .code-frame-lines {
min-width: 0;
white-space: pre-wrap;
overflow-wrap: anywhere;
}
[data-nextjs-vulnerability-action] [data-nextjs-vulnerability-prompt],
[data-nextjs-vulnerability-action] [data-nextjs-vulnerability-prompt-title] {
font-family: var(--font-stack-sans);
font-size: var(--size-14);
line-height: var(--size-20);
letter-spacing: normal;
}
[data-nextjs-vulnerability-prompt-title] {
font-size: var(--size-13);
}
[data-nextjs-vulnerability-copy] {
display: inline-flex;
flex-shrink: 0;
align-items: center;
justify-content: center;
margin-left: auto;
width: var(--size-24);
height: var(--size-24);
padding: 4px;
border: none;
border-radius: var(--rounded-md-2);
background: transparent;
color: var(--color-gray-1000);
gap: 6px;
height: auto;
padding: 5px 10px;
border: 1px solid var(--color-gray-alpha-300);
border-radius: 9999px;
background: var(--color-background-100);
color: var(--color-gray-900);
font-family: var(--font-stack-sans);
font-size: var(--size-11);
font-weight: 500;
line-height: 1;
cursor: pointer;
transition:
background 120ms ease,
border-color 120ms ease,
color 120ms ease;
}
[data-nextjs-vulnerability-action] [data-nextjs-copy-button-label] {
font-family: var(--font-stack-sans);
font-size: var(--size-11);
line-height: 1;
}
[data-nextjs-vulnerability-copy] svg {
width: var(--size-12);
height: var(--size-12);
}
[data-nextjs-vulnerability-copy]:hover {
background: var(--color-gray-alpha-100);
background: var(--color-background-200);
border-color: var(--color-gray-alpha-500);
color: var(--color-gray-1000);
}
[data-nextjs-vulnerability-copy]:focus-visible {
outline: var(--focus-ring);
......
......@@ -52,6 +52,17 @@ export const Turbopack: Story = {
},
}
export const Vulnerability: Story = {
args: {
...Default.args,
rendered: true,
transitionDurationMs: 0,
runtimeErrors: [],
hasVulnerabilityInsight: true,
isTurbopack: true,
},
}
export const VeryLongErrorMessage: Story = {
args: {
...Default.args,
......
......@@ -38,18 +38,23 @@ describe('vulnerability insight', () => {
await retry(async () => {
expect(
await portalText(browser, '[data-nextjs-vulnerability-label]')
).toBe('Vulnerability Insight')
).toBe('Security Insight')
})
const displayedPrompt = await portalText(
browser,
'[data-nextjs-vulnerability-prompt]'
)
expect(displayedPrompt).toBe(
'Run `next upgrade --ai=security` and follow its instructions.'
)
await clickInPortal(browser, '[aria-label="Copy upgrade prompt"]')
await clickInPortal(browser, '[aria-label="Copy prompt"]')
let copiedPrompt = ''
await retry(async () => {
copiedPrompt = await browser.eval(() => navigator.clipboard.readText())
expect(copiedPrompt).toBe(displayedPrompt)
expect(copiedPrompt).toBe(
'Run `next upgrade --ai=security` and follow its instructions.'
)
})
expect(copiedPrompt).toMatchInlineSnapshot(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment