Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
c2ecaf2
perf(site): avoid descendant :focus-within selectors
mafredri Oct 26, 2026
413356e
fix(site/src/pages/AgentsPage/components): paint the upload overlay o…
mafredri Oct 27, 2026
82a60dd
test(site/src/pages/AgentsPage/components): leave overlay visibility …
mafredri Oct 27, 2026
3f6c8fc
fix(site/src/pages/AgentsPage/components/ChatConversation): hide the …
mafredri Oct 27, 2026
7297b96
test(site/src/pages/AgentsPage/components): capture the card-focus an…
mafredri Oct 27, 2026
9627b9a
fix(site/src/pages/AgentsPage/components): show attachment buttons fr…
mafredri Oct 27, 2026
92cf177
test(site/src/pages/AgentsPage/components): write the focus stories p…
mafredri Oct 27, 2026
02fb818
docs(site/src/pages/AgentsPage/components): shorten the attachment vi…
mafredri Oct 27, 2026
5389e59
test(site/src/pages/AgentsPage/components): tab without waiting for a…
mafredri Oct 27, 2026
de4b302
fix(site/src/pages/AgentsPage/components): keep hidden attachment but…
mafredri Oct 27, 2026
20210dc
test(site/src/pages/AgentsPage/components): leave focus order to the …
mafredri Oct 27, 2026
c5a2590
docs(site/src/pages/AgentsPage/components): name the rule the attachm…
mafredri Oct 27, 2026
ee9ed7e
test(site/src/pages/AgentsPage/components): capture the transcript im…
mafredri Oct 27, 2026
446c78e
fix(site/src/pages/AgentsPage/components): keep the hidden download l…
mafredri Oct 27, 2026
30d26d3
perf(site/src/pages/AgentsPage/components): blur the download link on…
mafredri Oct 27, 2026
23da067
fix(site/src/pages/AgentsPage/components): fade the Download link's blur
mafredri Oct 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,41 @@ export const SingleImage: Story = {
},
};

// Focus on View, Paste inline or Remove shows Paste inline and Remove. The
// hidden buttons stay in the tab order, so Shift+Tab from the end of the page
// reaches Remove and then Paste inline.
export const ViewFocused: Story = {
args: (() => {
const file = createMockFile("clipboard.txt", "text/plain", 2048);
return {
attachments: [file],
uploadStates: new Map<File, UploadState>([
[file, { status: "uploaded", fileId: "file-1" }],
]),
previewUrls: new Map<File, string>(),
textContents: new Map<File, string>([[file, "Pasted text."]]),
};
})(),
play: async () => {
await userEvent.tab();
},
};

export const PasteFocused: Story = {
args: ViewFocused.args,
play: async () => {
await userEvent.tab({ shift: true });
await userEvent.tab({ shift: true });
},
};

export const RemoveFocused: Story = {
args: ViewFocused.args,
play: async () => {
await userEvent.tab({ shift: true });
},
};

export const MultipleImages: Story = {
args: (() => {
const files = [
Expand Down
9 changes: 6 additions & 3 deletions site/src/pages/AgentsPage/components/AttachmentPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ export const AttachmentPreview: React.FC<{
// Key combines file metadata with index as a fallback for
// duplicate names. Acceptable for a small, append-only list.
key={`${file.name}-${file.size}-${file.lastModified}-${index}`}
className="group relative"
// Not `group-focus-within`: WebKit restyles every ancestor's subtree for a
// descendant `:focus-within` rule. Hidden buttons take no pointer input but
// stay tabbable, since focus shows them; `visibility` would make Shift+Tab skip them.
className="relative [--actions-opacity:0] [--actions-pointer-events:none] hover:[--actions-opacity:1] hover:[--actions-pointer-events:auto] focus-within:[--actions-opacity:1] focus-within:[--actions-pointer-events:auto] [@media(hover:none)]:[--actions-opacity:1] [@media(hover:none)]:[--actions-pointer-events:auto]"
Comment thread
mafredri marked this conversation as resolved.
Resolved
>
{isRasterImageMediaType(file.type) && previewUrl ? (
<button
Expand Down Expand Up @@ -183,7 +186,7 @@ export const AttachmentPreview: React.FC<{
);
onInlineText(file, nextContent);
}}
className="absolute -bottom-2 -right-2 flex size-6 cursor-pointer items-center justify-center rounded-full bg-surface-primary text-content-secondary shadow-xs opacity-0 transition-opacity hover:bg-surface-secondary hover:text-content-primary group-hover:opacity-100 group-focus-within:opacity-100 focus:opacity-100"
className="absolute -bottom-2 -right-2 flex size-6 cursor-pointer items-center justify-center rounded-full bg-surface-primary text-content-secondary opacity-(--actions-opacity) shadow-xs transition-opacity [pointer-events:var(--actions-pointer-events)] hover:bg-surface-secondary hover:text-content-primary"
aria-label="Paste inline"
>
<ClipboardPasteIcon aria-hidden="true" className="size-3.5" />
Expand Down Expand Up @@ -217,7 +220,7 @@ export const AttachmentPreview: React.FC<{
<button
type="button"
onClick={() => onRemove(file)}
className="absolute -right-2 -top-2 flex size-6 cursor-pointer items-center justify-center rounded-full bg-surface-primary text-content-secondary shadow-xs opacity-0 transition-opacity hover:bg-surface-secondary hover:text-content-primary group-hover:opacity-100 group-focus-within:opacity-100 focus:opacity-100"
className="absolute -right-2 -top-2 flex size-6 cursor-pointer items-center justify-center rounded-full bg-surface-primary text-content-secondary opacity-(--actions-opacity) shadow-xs transition-opacity [pointer-events:var(--actions-pointer-events)] hover:bg-surface-secondary hover:text-content-primary"
aria-label={`Remove ${file.name}`}
>
<XIcon aria-hidden="true" className="size-3.5" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ export const getAttachmentDownload = (
const DownloadOverlay: React.FC<AttachmentDownload> = (download) => (
<AttachmentDownloadLink
{...download}
className="invisible absolute right-1 top-1 flex size-6 items-center justify-center rounded bg-surface-primary/80 text-content-secondary opacity-0 shadow-xs backdrop-blur-xs transition-opacity hover:text-content-primary group-hover/attachment:visible group-hover/attachment:opacity-100 group-focus-within/attachment:visible group-focus-within/attachment:opacity-100 [@media(hover:none)]:visible [@media(hover:none)]:opacity-100 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-content-link"
// The frame sets the blur only while the link shows, so a hidden link adds
// no compositing layer. The blur transitions with the opacity so both fade.
Comment on lines +173 to +174

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment slop : (

className="absolute right-1 top-1 flex size-6 items-center justify-center rounded bg-surface-primary/80 text-content-secondary opacity-(--download-opacity) shadow-xs [backdrop-filter:var(--download-backdrop-filter)] transition-[opacity,backdrop-filter] [pointer-events:var(--download-pointer-events)] hover:text-content-primary focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-content-link"
>
<DownloadIcon aria-hidden="true" className="size-3.5" />
</AttachmentDownloadLink>
Expand All @@ -184,7 +186,10 @@ const AttachmentPreviewFrame: React.FC<{
children: React.ReactNode;
}> = ({ href, displayName, downloadName, mediaType, children }) => {
return (
<div className="group/attachment relative inline-flex flex-col items-start">
// Not `group-focus-within`: WebKit restyles every ancestor's subtree for a
// descendant `:focus-within` rule. The hidden link takes no pointer input but
// stays tabbable, since focus shows it; `visibility` would make Shift+Tab skip it.
<div className="relative inline-flex flex-col items-start [--download-opacity:0] [--download-pointer-events:none] [--download-backdrop-filter:none] hover:[--download-opacity:1] hover:[--download-pointer-events:auto] hover:[--download-backdrop-filter:blur(var(--blur-xs))] focus-within:[--download-opacity:1] focus-within:[--download-pointer-events:auto] focus-within:[--download-backdrop-filter:blur(var(--blur-xs))] [@media(hover:none)]:[--download-opacity:1] [@media(hover:none)]:[--download-pointer-events:auto] [@media(hover:none)]:[--download-backdrop-filter:blur(var(--blur-xs))]">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P4 [CRF-30] An expired or failed framed image still renders the Download link, and 555e1c8 makes that link tabbable and announced by screen readers at rest. (Nami)

AttachmentBlock wraps RemoteImageBlock in AttachmentPreviewFrame whenever framePreview is set, and RemoteImageBlock renders AttachmentFallbackTile ("Image expired" or "Image failed to load") when the file is gone. A screen reader now reads "Image expired" followed by a Download link for that file, and Tab lands on it. On main the link was invisible at rest and reachable only by hover. RemoteTextAttachmentButton already returns the tile before building the frame; the image path needs the same ordering, so the frame or its caller has to know the image's failure state.

🤖

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On main this link already shows for an expired or failed image on hover and on devices without hover; this PR adds the keyboard and screen reader stop at rest, as for every hidden Download link. Hiding it for a failed image needs RemoteImageBlock's failure state in the frame, the ownership change this review lists as out of scope.

🤖 Posted using /amend-review skill via Coder Agents.

Comment thread
mafredri marked this conversation as resolved.
Resolved
{children}
<DownloadOverlay
href={href}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1386,22 +1386,27 @@ export const AssistantMessageWithImage: Story = {
"src",
`data:image/png;base64,${MockPngBase64}`,
);
expect(
Comment thread
mafredri marked this conversation as resolved.
Resolved
canvas.queryByRole("link", { name: "Download generated-image.png" }),
).not.toBeInTheDocument();
expect(
canvas.queryByRole("button", { name: "Copy message" }),
).not.toBeInTheDocument();
const viewButton = canvas.getByRole("button", {
name: "View generated-image.png",
});
viewButton.focus();
expect(viewButton).toHaveFocus();
await waitFor(() => {
expect(
canvas.getByRole("link", { name: "Download generated-image.png" }),
).toBeVisible();
});
},
};

// Focus on View shows the Download link.
export const AssistantMessageWithImageViewFocused: Story = {
args: AssistantMessageWithImage.args,
play: ({ canvasElement }) => {
const canvas = within(canvasElement);
canvas.getByRole("button", { name: "View generated-image.png" }).focus();
},
};

// The hidden link stays in the tab order, so Shift+Tab from the end of the
// page reaches it.
export const AssistantMessageWithImageDownloadFocused: Story = {
args: AssistantMessageWithImage.args,
play: async () => {
await userEvent.tab({ shift: true });
},
};

Expand Down
Loading