feat(app): always show the assistant copy button (#64478)

This commit is contained in:
James Long
2026-11-17 12:37:35 -05:00
committed by GitHub
Unverified
parent 7828491cc9
commit 5db3553efa
6 changed files with 65 additions and 76 deletions
@@ -120,9 +120,6 @@ export function createTimelineCache(
get agents() {
return agents()
},
get copyAlwaysVisible() {
return data.copyAlwaysVisible
},
navigateToSession: data.navigateToSession,
sessionHref: data.sessionHref,
readMedia: data.readMedia,
@@ -45,8 +45,6 @@ export function SessionUIProvider(
const language = useLanguage()
const settings = useSettings()
const directory = () => props.directory
const releaseChannel = import.meta.env.VITE_OPENCODE_CHANNEL ?? "local"
const copyAlwaysVisible = releaseChannel === "dev" || releaseChannel === "local"
const readImage = createMemo<ReadMarkdownImage>(() => {
const dir = directory()
@@ -240,7 +238,6 @@ export function SessionUIProvider(
directory={directory()}
sessionID={params.id}
agents={settings.visibility.customAgents()}
copyAlwaysVisible={copyAlwaysVisible}
shellRunning={(id) => !!data.shell.get(id)}
shellOutput={(input) => serverSDK.api.shell.output(input)}
readMedia={(uri, mime, signal) => serverSDK.media.load(uri, mime, signal)}
@@ -98,49 +98,66 @@ story.describe("touch timeline", () => {
})
})
story("desktop message actions still appear on hover and keyboard focus", async ({ mount, page }) => {
story("desktop user message actions still appear on hover and keyboard focus", async ({ mount, page }) => {
const timeline = await mount("current-session-timeline-rows--conversation", { args: { scenario: "interruption" } })
expect(await page.evaluate(() => matchMedia("(hover: hover)").matches)).toBe(true)
for (const action of [
{ slot: "user-message-menu", name: "More actions" },
{ slot: "text-part-copy-wrapper", name: "Copy response" },
]) {
const actions = timeline.locator(`[data-slot="${action.slot}"]`)
await expect(actions).toHaveCount(1)
await expect(actions).toHaveCSS("opacity", "0")
await expect(actions).toHaveCSS("pointer-events", "none")
await actions.locator("..").hover()
await expect(actions).toHaveCSS("opacity", "1")
await expect(actions).toHaveCSS("pointer-events", "auto")
if (action.slot === "text-part-copy-wrapper") {
await expect(actions).toHaveCSS("height", "20px")
await expect(actions).toHaveCSS("margin-top", "8px")
await expect(actions).toHaveCSS("gap", "4px")
const meta = actions.locator('[data-slot="text-part-meta"]')
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"])
const separators = meta.locator('[data-slot="text-part-meta-separator"]')
await expect(separators).toHaveCount(2)
for (const separator of await separators.all()) {
await expect(separator).toHaveText("\u00B7")
}
const copy = actions.getByRole("button", { name: action.name, exact: true })
await expect(copy).toHaveCSS("width", "20px")
await expect(copy).toHaveCSS("height", "20px")
await expect(copy.locator('[data-slot="icon-svg"]')).toHaveCSS("width", "14px")
}
await page.mouse.move(0, 0)
await expect(actions).toHaveCSS("opacity", "0")
await actions.getByRole("button", { name: action.name, exact: true }).focus()
await expect(actions).toHaveCSS("opacity", "1")
await expect(actions).toHaveCSS("pointer-events", "auto")
await page.getByRole("button", { name: "Reset", exact: true }).focus()
}
const actions = timeline.locator('[data-slot="user-message-menu"]')
await expect(actions).toHaveCount(1)
await expect(actions).toHaveCSS("opacity", "0")
await expect(actions).toHaveCSS("pointer-events", "none")
await actions.locator("..").hover()
await expect(actions).toHaveCSS("opacity", "1")
await expect(actions).toHaveCSS("pointer-events", "auto")
await page.mouse.move(0, 0)
await expect(actions).toHaveCSS("opacity", "0")
await actions.getByRole("button", { name: "More actions", exact: true }).focus()
await expect(actions).toHaveCSS("opacity", "1")
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" } })
expect(await page.evaluate(() => matchMedia("(hover: hover)").matches)).toBe(true)
const actions = timeline.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")
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"])
const separators = meta.locator('[data-slot="text-part-meta-separator"]')
await expect(separators).toHaveCount(2)
for (const separator of await separators.all()) {
await expect(separator).toHaveText("\u00B7")
}
await actions.locator("..").hover()
await expect(meta).toHaveCSS("opacity", "1")
await expect(meta).toHaveCSS("pointer-events", "auto")
expect(await copy.boundingBox()).toEqual(rest)
await page.mouse.move(0, 0)
await expect(meta).toHaveCSS("opacity", "0")
await expect(actions).toHaveCSS("opacity", "1")
await copy.focus()
await expect(meta).toHaveCSS("opacity", "1")
await expect(meta).toHaveCSS("pointer-events", "auto")
})
@@ -582,16 +582,9 @@
justify-content: flex-start;
gap: 4px;
/* Production keeps the whole footer hover-only. Dev channels keep the copy control visible and
hide only the metadata. Keeping the metadata in flow means the copy control does not move. */
@media (hover: hover) {
&:not([data-copy-always-visible]) {
opacity: 0;
pointer-events: none;
}
}
&[data-copy-always-visible] [data-slot="text-part-meta"] {
/* 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;
@@ -668,14 +661,8 @@
transition: none;
}
&:hover [data-slot="text-part-copy-wrapper"],
&:focus-within [data-slot="text-part-copy-wrapper"] {
opacity: 1;
pointer-events: auto;
}
&:hover [data-slot="text-part-copy-wrapper"][data-copy-always-visible] [data-slot="text-part-meta"],
&:focus-within [data-slot="text-part-copy-wrapper"][data-copy-always-visible] [data-slot="text-part-meta"] {
&: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;
}
-5
View File
@@ -72,8 +72,6 @@ export const {
sessionID?: string
/** Whether message meta names the agent; the app follows its Show agent setting. Defaults to true. */
agents?: boolean
/** Whether the assistant copy control stays visible at rest; the app enables this on dev/local builds. */
copyAlwaysVisible?: boolean
shellRunning?: (id: string) => boolean
shellOutput?: (input: ShellOutputInput) => Promise<ShellOutputOutput>
turnDiff?: TurnDiffSource
@@ -95,9 +93,6 @@ export const {
get agents() {
return props.agents ?? true
},
get copyAlwaysVisible() {
return props.copyAlwaysVisible === true
},
navigateToSession: props.onNavigateToSession,
sessionHref: props.onSessionHref,
shellRunning: props.shellRunning,
@@ -1232,11 +1232,7 @@ export function AssistantTextContent(props: {
function copyFooter() {
return (
<div
data-slot="text-part-copy-wrapper"
data-interrupted={interrupted() ? "" : undefined}
data-copy-always-visible={data.copyAlwaysVisible ? "" : undefined}
>
<div data-slot="text-part-copy-wrapper" data-interrupted={interrupted() ? "" : undefined}>
<MessageActionButton
copied={copy.copied()}
size="small"