mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-19 08:39:02 +03:00
fix(session-ui): keep the latest response copy visible at rest (#64640)
This commit is contained in:
committed by
GitHub
Unverified
parent
79bd2c6f11
commit
0220248dc1
@@ -119,32 +119,50 @@ story("desktop user message actions still appear on hover and keyboard focus", a
|
||||
await expect(actions).toHaveCSS("pointer-events", "auto")
|
||||
})
|
||||
|
||||
story("desktop response copy stays visible while its metadata waits for hover or focus", async ({ mount, page }) => {
|
||||
const timeline = await mount("current-session-timeline-rows--conversation", { args: { scenario: "interruption" } })
|
||||
story("desktop keeps only the latest response copy visible at rest", async ({ mount, page }) => {
|
||||
const timeline = await mount("current-session-timeline-rows--response-speed", { args: { steered: true } })
|
||||
expect(await page.evaluate(() => matchMedia("(hover: hover)").matches)).toBe(true)
|
||||
|
||||
const actions = timeline.locator('[data-slot="text-part-copy-wrapper"]')
|
||||
const latest = timeline.locator('[data-component="text-part"]').filter({ hasText: "The timeline checks passed." })
|
||||
|
||||
const latestActions = latest.locator('[data-slot="text-part-copy-wrapper"]')
|
||||
|
||||
const latestMeta = latestActions.locator('[data-slot="text-part-meta"]')
|
||||
|
||||
await expect(latestActions).toHaveCSS("opacity", "1")
|
||||
await expect(latestActions.getByRole("button", { name: "Copy response", exact: true })).toBeVisible()
|
||||
await expect(latestMeta).toHaveCSS("opacity", "0")
|
||||
await latest.locator('[data-slot="text-part-body"]').hover()
|
||||
await expect(latestMeta).toHaveCSS("opacity", "1")
|
||||
|
||||
const earlier = timeline.locator('[data-component="text-part"]').filter({ hasText: "I'll inspect the timeline" })
|
||||
|
||||
const actions = earlier.locator('[data-slot="text-part-copy-wrapper"]')
|
||||
await expect(actions).toHaveCount(1)
|
||||
await expect(actions).toHaveCSS("height", "20px")
|
||||
await expect(actions).toHaveCSS("margin-top", "8px")
|
||||
await expect(actions).toHaveCSS("gap", "4px")
|
||||
await expect(actions).toHaveCSS("opacity", "1")
|
||||
await expect(actions).toHaveCSS("pointer-events", "auto")
|
||||
await expect(actions).toHaveCSS("opacity", "0")
|
||||
await expect(actions).toHaveCSS("pointer-events", "none")
|
||||
|
||||
const copy = actions.getByRole("button", { name: "Copy response", exact: true })
|
||||
await expect(copy).toBeVisible()
|
||||
|
||||
await expect(copy).toHaveCSS("width", "20px")
|
||||
await expect(copy).toHaveCSS("height", "20px")
|
||||
await expect(copy.locator('[data-slot="icon-svg"]')).toHaveCSS("width", "14px")
|
||||
const rest = await copy.boundingBox()
|
||||
|
||||
const meta = actions.locator('[data-slot="text-part-meta"]')
|
||||
await expect(meta).toHaveCSS("opacity", "0")
|
||||
await expect(meta).toHaveCSS("pointer-events", "none")
|
||||
|
||||
await expect(meta).toHaveCSS("font-size", "12px")
|
||||
await expect(meta).toHaveCSS("line-height", "18px")
|
||||
await expect(meta).toHaveCSS("gap", "4px")
|
||||
await expect(meta.locator('[data-slot="text-part-meta-item"]')).toHaveText(["Build", "Claude Sonnet 4", "4s"])
|
||||
await expect(meta.locator('[data-slot="text-part-meta-item"]')).toHaveText([
|
||||
"Build",
|
||||
"Claude Sonnet 4",
|
||||
"Balanced",
|
||||
"4m 50s",
|
||||
])
|
||||
const separators = meta.locator('[data-slot="text-part-meta-separator"]')
|
||||
await expect(separators).toHaveCount(2)
|
||||
|
||||
@@ -152,15 +170,16 @@ story("desktop response copy stays visible while its metadata waits for hover or
|
||||
await expect(separator).toHaveText("\u00B7")
|
||||
}
|
||||
|
||||
await actions.locator("..").hover()
|
||||
await expect(meta).toHaveCSS("opacity", "1")
|
||||
await expect(meta).toHaveCSS("pointer-events", "auto")
|
||||
await earlier.locator('[data-slot="text-part-body"]').hover()
|
||||
await expect(actions).toHaveCSS("opacity", "1")
|
||||
await expect(actions).toHaveCSS("pointer-events", "auto")
|
||||
expect(await copy.boundingBox()).toEqual(rest)
|
||||
await copy.hover()
|
||||
await expect(actions).toHaveCSS("opacity", "1")
|
||||
|
||||
await page.mouse.move(0, 0)
|
||||
await expect(meta).toHaveCSS("opacity", "0")
|
||||
await expect(actions).toHaveCSS("opacity", "1")
|
||||
await expect(actions).toHaveCSS("opacity", "0")
|
||||
await copy.focus()
|
||||
await expect(meta).toHaveCSS("opacity", "1")
|
||||
await expect(meta).toHaveCSS("pointer-events", "auto")
|
||||
await expect(actions).toHaveCSS("opacity", "1")
|
||||
await expect(actions).toHaveCSS("pointer-events", "auto")
|
||||
})
|
||||
|
||||
@@ -582,15 +582,6 @@
|
||||
justify-content: flex-start;
|
||||
gap: 4px;
|
||||
|
||||
/* The copy control stays visible; only the metadata waits for hover or focus. Keeping the metadata
|
||||
in flow means the copy control does not move. */
|
||||
[data-slot="text-part-meta"] {
|
||||
@media (hover: hover) {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
[data-component="tooltip-v2-trigger"] {
|
||||
display: inline-flex;
|
||||
flex: none;
|
||||
@@ -661,10 +652,14 @@
|
||||
transition: none;
|
||||
}
|
||||
|
||||
&:hover [data-slot="text-part-copy-wrapper"] [data-slot="text-part-meta"],
|
||||
&:focus-within [data-slot="text-part-copy-wrapper"] [data-slot="text-part-meta"] {
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
@media (hover: hover) {
|
||||
&:not(:hover, :focus-within) {
|
||||
[data-slot="text-part-copy-wrapper"]:not([data-keep-copy-visible]),
|
||||
[data-slot="text-part-copy-wrapper"][data-keep-copy-visible] [data-slot="text-part-meta"] {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ export function SessionAssistantContent(props: {
|
||||
content: SessionMessageAssistant["content"][number]
|
||||
contentID: string
|
||||
showAssistantCopyPartID?: string | null
|
||||
keepCopyVisible?: boolean
|
||||
turnDurationMs?: number | null
|
||||
turnTokensPerSecond?: number
|
||||
sources?: TurnSources
|
||||
@@ -85,6 +86,7 @@ export function SessionAssistantContent(props: {
|
||||
text={content().text}
|
||||
message={props.message}
|
||||
showCopy={props.showAssistantCopyPartID === props.contentID}
|
||||
keepCopyVisible={props.keepCopyVisible}
|
||||
turnDurationMs={props.turnDurationMs}
|
||||
turnTokensPerSecond={props.turnTokensPerSecond}
|
||||
sources={props.sources}
|
||||
|
||||
@@ -1138,6 +1138,7 @@ export function AssistantTextContent(props: {
|
||||
text: string
|
||||
message: SessionMessageAssistant
|
||||
showCopy: boolean
|
||||
keepCopyVisible?: boolean
|
||||
turnDurationMs?: number | null
|
||||
turnTokensPerSecond?: number
|
||||
/** The finished turn's web searches and fetches, shown as a chip in its footer. */
|
||||
@@ -1232,7 +1233,11 @@ export function AssistantTextContent(props: {
|
||||
|
||||
function copyFooter() {
|
||||
return (
|
||||
<div data-slot="text-part-copy-wrapper" data-interrupted={interrupted() ? "" : undefined}>
|
||||
<div
|
||||
data-slot="text-part-copy-wrapper"
|
||||
data-keep-copy-visible={props.keepCopyVisible ? "" : undefined}
|
||||
data-interrupted={interrupted() ? "" : undefined}
|
||||
>
|
||||
<MessageActionButton
|
||||
copied={copy.copied()}
|
||||
size="small"
|
||||
|
||||
@@ -306,6 +306,10 @@ export function createNextTimelineRowRenderer(input: {
|
||||
: undefined
|
||||
}
|
||||
|
||||
const latestCopyTurn = createMemo(() =>
|
||||
Array.from(input.projection.assistantMessagesByParent().keys()).findLast((id) => !!copyContentID(id)),
|
||||
)
|
||||
|
||||
const padding = () => input.padding?.() ?? "px-4 md:px-6"
|
||||
|
||||
const indexGroupContents = (refs: PartRef[]) => {
|
||||
@@ -579,6 +583,7 @@ export function createNextTimelineRowRenderer(input: {
|
||||
content={content()}
|
||||
contentID={ref()!.partID}
|
||||
showAssistantCopyPartID={copyContentID(row().userMessageID)}
|
||||
keepCopyVisible={latestCopyTurn() === row().userMessageID}
|
||||
turnDurationMs={duration(row().userMessageID)}
|
||||
turnTokensPerSecond={turnTokensPerSecond()}
|
||||
sources={turnSourcesValue()}
|
||||
|
||||
@@ -18,6 +18,7 @@ export function AssistantContent(props: {
|
||||
content: SessionMessageAssistant["content"][number]
|
||||
contentID: string
|
||||
showAssistantCopyPartID?: string | null
|
||||
keepCopyVisible?: boolean
|
||||
turnDurationMs?: number | null
|
||||
turnTokensPerSecond?: number
|
||||
sources?: TurnSources
|
||||
@@ -37,6 +38,7 @@ export function AssistantContent(props: {
|
||||
text={content().text}
|
||||
message={props.message}
|
||||
showCopy={props.showAssistantCopyPartID === props.contentID}
|
||||
keepCopyVisible={props.keepCopyVisible}
|
||||
turnDurationMs={props.turnDurationMs}
|
||||
turnTokensPerSecond={props.turnTokensPerSecond}
|
||||
sources={props.sources}
|
||||
|
||||
@@ -322,6 +322,10 @@ export function createSessionTimelineRowRenderer(input: {
|
||||
: undefined
|
||||
}
|
||||
|
||||
const latestCopyTurn = createMemo(() =>
|
||||
Array.from(input.projection.assistantMessagesByParent().keys()).findLast((id) => !!copyContentID(id)),
|
||||
)
|
||||
|
||||
const padding = () => input.padding?.() ?? "px-4 md:px-6"
|
||||
|
||||
const indexGroupContents = (refs: PartRef[]) => {
|
||||
@@ -576,6 +580,7 @@ export function createSessionTimelineRowRenderer(input: {
|
||||
content={content()}
|
||||
contentID={ref()!.partID}
|
||||
showAssistantCopyPartID={copyContentID(row().userMessageID)}
|
||||
keepCopyVisible={latestCopyTurn() === row().userMessageID}
|
||||
turnDurationMs={duration(row().userMessageID)}
|
||||
turnTokensPerSecond={turnTokensPerSecond()}
|
||||
sources={turnSourcesValue()}
|
||||
|
||||
Reference in New Issue
Block a user