Skip to content

fix(site/src/pages/AgentsPage/components): keep hidden attachment controls tabbable and click-through - #31366

Merged
mafredri merged 18 commits into
mainfrom
perf/chat-focus-within
Nov 26, 2026
Merged

mafredri merged 18 commits into
mainfrom
perf/chat-focus-within

Conversation

@mafredri

@mafredri mafredri commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

On main, the attachment controls that show on hover or focus mishandle keyboard and pointer input:

  • The transcript's Download link hides with visibility, so Shift+Tab skips it. Tab from View reaches it only because focus on View shows it first.
  • The composer's hidden Remove button overhangs the top of its chip. Pointing at the overhang lands on the invisible button, which shows the buttons, and a click there hits Remove.
  • WebKit gives each hidden Download link a compositing layer for its backdrop blur.

The composer's attachment card and the transcript's attachment frame now set custom properties from their own hover and focus-within, and their controls read them for opacity, pointer events and, on the Download link, the blur. Hidden controls stay in the tab order in both directions and take no pointer input. The blur applies only while the link shows and fades with it, so hidden links add no compositing layers: with four hidden links in view, WebKit composites 5 layers on main and 1 here. Devices without hover now show the composer's buttons at rest, as the transcript already did for the Download link.

The new stories capture each focus state, including Shift+Tab onto the hidden Download link, Remove and Paste inline.

🤖 This PR was created with the help of Coder Agents.

@mafredri

This comment has been minimized.

@coder-agents-review

coder-agents-review Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Chat: Review posted | View chat
Requested: 2026-10-28 09:00 UTC by @mafredri

Review history
  • R1 (2026-10-27): 9 reviewers, 3 Nit, 5 P3, 3 P4, COMMENT. Review
  • R2 (2026-10-27): 8 reviewers, 4 Nit, 6 P3, 4 P4, COMMENT. Review
  • R3 (2026-10-27): 7 reviewers, 4 Nit, 6 P3, 4 P4, APPROVE. Review
  • R4 (2026-10-27): 9 reviewers, 4 Nit, 6 P3, 6 P4, COMMENT. Review
  • R5 (2026-10-28): 8 reviewers, 4 Nit, 6 P3, 6 P4, APPROVE. Review

deep-review v0.13.0 | Round 5 | 4fd76a9..d597e00

Last posted: Round 5, 16 findings (6 P3, 6 P4, 4 Nit), APPROVE. Review

Finding inventory

Findings

# Sev Status Location Summary Round Reviewer Posted
CRF-1 Nit Author fixed (a1933cc) AttachmentPreview.stories.tsx:70 PasteFocused and RemoveFocused assert toHaveFocus in play (FE1) R1 Netero Yes
CRF-2 Nit Author fixed (a1933cc) ConversationTimeline.stories.tsx:1341 AssistantMessageWithImage adds toHaveFocus assertion in play (FE1) R1 Netero Yes
CRF-3 Note Note (body) AttachmentPreview.stories.tsx:47 New stories pass against base production files; only Pixel captures check the visibility change R1 Netero No
CRF-4 P3 Author contested; panel closed R2 (2/2 accept) AttachmentBlocks.tsx:190 Download link hidden with visibility, so Shift+Tab skips it; composer now uses opacity plus pointer-events R1 Zoro P3, Nami P4 Yes
CRF-5 P4 Author fixed (PR description) AttachmentPreview.tsx:148 pointer-events none means the button overhang outside the card no longer reveals the buttons; not listed in PR body R1 Bisky P4, Mafuuu P4, Zoro P4, Nami Note, Pariston Note Yes
CRF-6 P3 Author fixed (PR description) AttachmentPreview.tsx:145 PR description does not say where the other 4 of 7 descendant focus-within rules are or which PR removes them R1 Leorio P3, Pariston Note Yes
CRF-7 P4 Author fixed (4f40017) AttachmentPreview.tsx:145 Card comment names a WebKit cost but not the rule; "take no taps" understates pointer-events none R1 Leorio P4, Gon Note Yes
CRF-8 P4 Author fixed (4f40017) AttachmentBlocks.tsx:187 Frame comment implies Download is unreachable by keyboard; omits that View focus reveals it R1 Leorio Yes
CRF-9 P3 Author fixed (a1933cc) ConversationTimeline.stories.tsx:1338 Comment defends the assertion instead of naming the frame focus-within dependency R1 Gon P2 Yes
CRF-10 P3 Author fixed (a1933cc) ConversationTimeline.stories.tsx:1347 "Keyboard focus on View" but the story calls .focus() R1 Gon P2, Leorio P4 Yes
CRF-11 P3 Author fixed (a1933cc) AttachmentPreview.stories.tsx:44 CardFocused comment calls View "the card" and says Shift+Tab starts after the card; stories start from body and depend on Remove being last R1 Gon P2, Bisky Note Yes
CRF-12 Nit Author fixed (a1933cc) AttachmentPreview.stories.tsx:47 CardFocused focuses View; siblings name the focused control R1 Gon Yes
CRF-13 Note Note (body) AttachmentPreview.tsx:148 Nothing checks pointer-events while hidden or the composer's hover:none path; needs human acceptance R1 Bisky No
CRF-14 Note Dropped by orchestrator (DownloadOverlay is module-private with one caller next to the frame that defines the variables) AttachmentBlocks.tsx:173 DownloadOverlay always shows if rendered outside the frame R1 Mafuuu No
CRF-15 Nit Dropped by orchestrator ("subject" is the Selectors spec term; CRF-6 already asks for a description edit) PR description "subject-position" and "idle focus, pointer p50" undefined R1 Leorio No
CRF-16 OOS Out of scope (body) ProjectChatRow.tsx:184 group-has-focus-visible compiles to a descendant focus rule R1 Pariston No
CRF-17 OOS Out of scope (body) ChatsPanel.tsx:563 group-focus-visible descendant focus rule on Agents sidebar R1 Pariston No
CRF-18 OOS Out of scope (body) MermaidDiagram.tsx:182 group-focus-visible descendant focus rule in transcript R1 Pariston No
CRF-19 OOS Out of scope (body) InboxItem.tsx:61 group-focus descendant focus rules R1 Pariston No
CRF-20 OOS Out of scope (body) ConversationTimeline.tsx:341 group-hover descendant rules; hover cost not measured R1 Pariston No
CRF-21 OOS Out of scope (body) AttachmentBlocks.tsx:173 Download hover path has no coverage; Storybook here cannot emulate hover R1 Bisky No
CRF-22 OOS Author fixed (555e1c8, link now tabbable while hidden) AttachmentBlocks.tsx:698 Expired or failed image frame has no focusable child, so Download is unreachable by keyboard R1 Leorio No
CRF-23 P3 Author fixed (eab0e50) ConversationTimeline.stories.tsx:1330 PR removed the only check that Download is hidden at rest; both framed-image stories end with Download shown R2 Bisky Yes
CRF-24 P4 Author fixed (eab0e50) ConversationTimeline.stories.tsx:1338 "only once the frame's focus-within shows it" reads as a count R2 Leorio Yes
CRF-25 Nit Author fixed (eab0e50) AttachmentPreview.stories.tsx:44 "shows both buttons" follows a list of three buttons R2 Gon Yes
CRF-26 OOS Author fixed (555e1c8) AttachmentBlocks.tsx:173 Shift+Tab skips the visibility-hidden Download link and the virtual cursor cannot find it, on main and in this PR R2 Zoro, Nami No
CRF-27 OOS Out of scope (body) ConversationTimeline.stories.tsx:1324 AssistantMessageWithImage play keeps pre-PR expect calls that FE1 forbids R2 Bisky No
CRF-28 P2 Dropped by orchestrator (comment is accurate per Leorio, Bisky, Meruem; it is the text the R2 review suggested, and the proposed rewrite differs by one clause) ConversationTimeline.stories.tsx:1350 DownloadFocused comment could be shorter R3 Gon No
CRF-29 Note Dropped by orchestrator (reviewer judged the paired declarations a reasonable cost; asks no change) AttachmentPreview.tsx:148 Shown state is two variables that every state must set together R3 Meruem No
CRF-30 P4 Author accepted R5 (same dead link pointer and touch users get on main; hiding it needs RemoteImageBlock's failure state, CRF-36) AttachmentBlocks.tsx:192 Expired or failed framed image keeps a Download link for the deleted file, now tabbable and announced at rest R4 Nami Yes
CRF-31 P4 Author fixed (d597e00) AttachmentBlocks.tsx:192 On hover-out the blur drops at once while opacity fades, showing an unblurred chip for the fade R4 Chopper Yes
CRF-32 Note Note (body) AttachmentBlocks.tsx:192 Nothing checks backdrop-filter none on the hidden link; same class as CRF-13 R4 Bisky No
CRF-33 P2 Dropped by orchestrator (the clause is the wording CRF-7 asked for in R1; removing it reverses the review's own request) AttachmentPreview.tsx:145 "take no pointer input" restates the class R4 Gon No
CRF-34 P2 Dropped by orchestrator (same reason as CRF-33) AttachmentBlocks.tsx:189 "take no pointer input" restates the class R4 Gon No
CRF-35 Note Dropped by orchestrator (asks no change; blur reason sits next to the reader of the variable) AttachmentBlocks.tsx:173 Blur rationale lives on DownloadOverlay, not the frame that sets it R4 Gon No
CRF-36 OOS Out of scope (body) AttachmentBlocks.tsx:463 RemoteImageBlock owns the expired/failed state while AttachmentBlock decides to render the frame, so the frame cannot drop the link R4 Nami No
CRF-37 P2 Dropped by orchestrator (comment is accurate and states the purpose, "so both fade"; rewrite is wording preference) AttachmentBlocks.tsx:174 Blur transition comment restates the class instead of the hover-out trap R5 Gon No

Contested and acknowledged

CRF-30 (P4, AttachmentBlocks.tsx:192) - Expired or failed framed image keeps a Download link, now tabbable and announced

  • Finding: RemoteImageBlock renders AttachmentFallbackTile inside AttachmentPreviewFrame when the file is gone, so the frame still renders a Download link for the deleted file; since 555e1c8 the link is tabbable and announced at rest. Proposed: return the tile before building the frame, as RemoteTextAttachmentButton does.
  • Author defense: On main the 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 needs RemoteImageBlock's failure state in the frame, the ownership change listed out of scope (CRF-36).
  • Author accepted (R5): Nami, the agent that raised it in R4 (resumed via message_agent), accepted: the PR gives keyboard and screen reader users the control pointer users already had (the goal of CRF-22 and CRF-26), and removing the dead link requires the CRF-36 ownership change, which the PR does not touch. Kite found no change at lines 192 or 700 since R4 that alters these facts. The dead link stays for every input method until a human files or declines CRF-36.

CRF-4 (P3, AttachmentBlocks.tsx:190) - Download link hidden with visibility, Shift+Tab skips it

  • Finding: The transcript's Download link is hidden with visibility, so Shift+Tab from after an attachment lands on View and leaves the frame without reaching Download, while the composer's buttons were switched to opacity plus pointer-events for the same problem. Proposed: hide Download with opacity plus a pointer-events variable, or document why the transcript differs.
  • Author defense: main hides Download with invisible, so Shift+Tab skips it there too; the PR keeps main's transcript behavior and only keeps the composer buttons (opacity-hidden on main) in the tab order. The frame comment now says the hidden link is out of the tab order and that focus on View shows it before the next Tab.
  • Panel closure (R2, 2/2): Zoro and Nami, the agents that raised it in R1 (resumed via message_agent), both accepted. Each verified that base DownloadOverlay starts with invisible, so the behavior is not a regression, and that the updated frame comment covers the documentation remedy. The pre-existing gap is listed out of scope as CRF-26.

Round log

Round 1

Netero first pass: 2 Nit, 1 Note, no P0. Panel proceeds. Round type: round 1, full panel. Focused (TSX only): ging-ts, ging-react, nami (specialists), pariston, mafuuu (core), bisky (tests changed), gon, leorio (once-per-PR floor). Wildcard: zoro (random draw). Workspace agent disconnected mid-round; nami, pariston, mafuuu, leorio and zoro were resumed (same agents) and wrote their files after reconnect. Gon's three P2 comment findings settled at P3 (rough edge: wrong or misleading story and component comments, no runtime effect). Totals: 5 P3, 3 P4, 3 Nit, 2 Note (body), 2 dropped, 7 out of scope. Reviewed against 8ac6897..b7828d0.

Round 2

Churn guard PROCEED: 10 addressed, CRF-4 contested. PR rebased onto 4fd76a9 (base #31365 updated). Netero: no findings; CRF-1 and CRF-2 fixes verified. Round type: fix round (no files added or moved, no signature change, same goal, +58 effective). Panel: zoro, nami (CRF-4 dispute check-in, previous agents via message_agent), gon, leorio (comments touched, raised CRF-7 to CRF-11), bisky (CRF-11 raiser, stories changed), ging-ts, ging-react (TSX specialists). Wildcard: mafuuu (random draw from distilled set).
Cross-check: CRF-4 closed 2/2. ging-ts, ging-react, mafuuu: no findings. New: 1 P3 (Bisky, verified only AssistantMessageWithImage and AssistantMessageWithImageViewFocused render AttachmentPreviewFrame; the frame wraps only raster images and text previews, so the two assistant PDF stories do not render it), 1 P4, 1 Nit, 2 out of scope. Reviewed against 4fd76a9..4f40017.

Round 3

Churn guard PROCEED: CRF-23, CRF-24, CRF-25 addressed (eab0e50). Netero: no findings; all three fixes verified, tsc and biome clean, 5 focus stories pass. Round type: fix round (one test commit, story files only). Panel: bisky, leorio, gon (raised CRF-23 to CRF-25, code touched), ging-ts, ging-react, nami (specialists for the changed .tsx story files). Wildcard: meruem (random draw from distilled set).
Cross-check: no in-scope findings. CRF-23 to CRF-25 fixes verified by Netero, Bisky (Tab reaches BODY with the frame focus-within rule deleted, so the new story detects a broken rule), Leorio, Gon, Nami. Gon P2 (CRF-28) dropped. Keep-argument: a comment that restates what the play shows costs every reader; drop reason: the comment is accurate, was adopted verbatim from the R2 suggestion, and the rewrite saves three words, so requesting it is churn. Meruem Note (CRF-29) dropped as asking no change. Reviewed against 4fd76a9..eab0e50.

Round 4

Churn guard PROCEED: no open findings. Inventory validation: 555e1c8 hides the transcript Download link with opacity plus --download-pointer-events instead of visibility, so CRF-26 (Shift+Tab skip, out of scope) and CRF-22 (failed image frame has no focusable child) no longer hold; marked Author fixed. CRF-14 assumption (DownloadOverlay module-private, one caller) unchanged.
Netero: no findings; verified rest and Shift+Tab-focused computed styles of the Download link, and that Tailwind 4.3.3 emits --blur-xs and -webkit-backdrop-filter. Round type: fix round (two commits, same files, no signature or goal change, effective additions unchanged at +66), though the transcript hiding method changed. Panel: zoro, nami (raised CRF-4/CRF-26, the code now changed), leorio (raised CRF-22; comments touched), gon (comments touched), bisky (DownloadFocused story changed), ging-ts, ging-react (TSX specialists), killua (new compositing-layer claim, backdrop-filter variable). Wildcard: chopper (random draw from distilled set).
Cross-check: Nami P4 (CRF-30) verified: AttachmentBlock wraps RemoteImageBlock in the frame (line ~698) and RemoteImageBlock returns AttachmentFallbackTile on expired/failed (lines 463 to 480), while RemoteTextAttachmentButton returns the tile before building a frame (lines 331 to 349). On main the dead link already showed on hover and hover:none, so the PR extends it to keyboard and screen reader users at rest; P4. Chopper P4 (CRF-31) inferred from class lists (transition-opacity only); keep-argument for higher: none, 150 ms visual glitch. Gon P2s (CRF-33, CRF-34) dropped. Keep-argument: restating code in a comment costs every reader, and line 147 is about 85 columns. Drop reason: CRF-7 in R1 explicitly asked for the pointer-input clause, the author added it, and biome passes. Nami's storybook run hit ENOSPC (the /home/coder volume is at 100%, 6.1G free); Netero and Bisky ran the stories successfully. Reviewed against 4fd76a9..1c64437.

Round 5

Churn guard PROCEED: CRF-31 addressed (d597e00, transition-[opacity,backdrop-filter]); CRF-30 acknowledged by author without a code change (reply PRRC_kwDOGkVX1s8AAAABBf3sdw), status left Open pending panel evaluation.
Netero: no findings; verified transition-[opacity,backdrop-filter] compiles to transition-property: opacity, -webkit-backdrop-filter, backdrop-filter with the default duration and timing. Round type: fix round (one line plus one comment sentence). Panel: nami (raised CRF-30, evaluates the acknowledgement; R4 agent reused), chopper (raised CRF-31; R4 agent reused), ging-ts, ging-react (TSX specialists), gon, leorio (comment line touched), killua (backdrop-filter transition and compositing claim in the description). Wildcard: kite (random draw from distilled set).
Cross-check: CRF-31 fix verified by Netero (compiled CSS), Chopper (raiser), Nami, Killua (transition starts only on value change, so links mounted at rest start none). CRF-30 accepted by Nami (raiser). Gon P2 (CRF-37) dropped. Keep-argument: a maintainer aligning with the sibling buttons' transition-opacity would not learn from the comment what breaks. Drop reason: the comment says the purpose ("so both fade"), which tells that maintainer the blur must stay in the list. No new in-scope findings. Reviewed against 4fd76a9..d597e00.

About deep-review

CRF = Coder Review Finding (P0-P4, Nit, Note)

Reviewer Focus
Bisky tests
Chopper ops/errors
Churn-guard change verification
Ging language modernization
Gon naming
Hisoka edge cases
Killua perf
Kite change integrity
Knov contracts
Knuckle SQL
Komugi flake/determinism
Kurapika security
Law decomposition
Leorio docs
Luffy product
Mafu-san process
Mafuuu contracts
Melody dispatch/pairing
Meruem structural
Nami frontend
Netero mechanical checks
Pariston premise testing
Pen-botter product gaps
Razor verification
Robin duplication
Ryosuke Go arch
Takumi concurrency
Zoro shape

🤖 Managed by Coder Agents.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T09:03:16.059883Z d597e00 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

chatgpt-codex-connector[bot]

This comment was marked as outdated.

@coder-agents-review coder-agents-review Bot left a comment

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.

This PR moves the attachment overlays' focus-within to the card and frame and passes the state to the buttons through custom properties. Compiled with the repo's Tailwind 4.3.3, the head CSS has no descendant :focus-within rule left in site/src. Findings: 5 P3, 3 P4, 3 Nit.

Out of scope (needs a ticket or explicit acceptance by a human):

  • site/src/pages/AgentsPage/components/ProjectPage/ProjectChatRow.tsx:184: group-has-focus-visible:* compiles to .group:has(:focus-visible) *, a descendant focus rule of the kind this PR removes.
  • site/src/pages/AgentsPage/components/ChatsSidebar/chats/ChatsPanel.tsx:563: group-focus-visible:opacity-100 compiles to .group:focus-visible * on the Agents sidebar.
  • site/src/pages/AgentsPage/components/ChatElements/MermaidDiagram.tsx:182: group-focus-visible:opacity-100, the same kind of rule, in the transcript.
  • site/src/modules/notifications/NotificationsInbox/InboxItem.tsx:61: group-focus:hidden and group-focus:flex compile to .group:focus *.
  • site/src/pages/AgentsPage/components/ChatConversation/ConversationTimeline.tsx:341: group-hover/* rules compile to .group:hover *; their WebKit cost on pointer movement is not measured by the focus bench.
  • site/src/pages/AgentsPage/components/ChatConversation/AttachmentBlocks.tsx:173: the hover path that shows Download has no story or test, because Storybook here cannot emulate :hover.
  • site/src/pages/AgentsPage/components/ChatConversation/AttachmentBlocks.tsx:698: an expired or failed image frame has no focusable child, so focus-within never matches and Download cannot be reached by keyboard (same on main).

Notes:

  • The new and changed stories also pass with the base versions of AttachmentPreview.tsx and AttachmentBlocks.tsx (pnpm exec vitest run --project=storybook, 76 passed both ways), so only the Pixel captures check the opacity and visibility change.
  • Nothing in CI checks pointer-events: none on the hidden buttons or the composer's new @media (hover: none) path: Pixel screenshots do not show pointer-events, and Pixel's browser reports hover: hover. This gap needs a human to accept it.

🤖 This review was automatically generated with Coder Agents.

@mafredri
mafredri force-pushed the perf/chat-focus-within branch from b7828d0 to 4f40017 Compare October 27, 2026 18:58
@mafredri

This comment has been minimized.

@chatgpt-codex-connector

This comment has been minimized.

@coder-agents-review coder-agents-review Bot left a comment

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.

Re-review of the rebased PR at 4f40017f24. Findings: 1 P3, 1 P4, 1 Nit, all in the story files.

All 11 posted round-1 findings were fixed except the Shift+Tab one on the Download link, which you contested. The reviewers who raised it accepted your defense: main already hides Download with invisible, and the frame comment now says how keyboard users reach the link. The pre-existing gap is listed below.

Out of scope (needs a ticket or explicit acceptance by a human):

  • site/src/pages/AgentsPage/components/ChatConversation/AttachmentBlocks.tsx:173: on main and in this PR, Shift+Tab into a transcript attachment frame skips the visibility-hidden Download link, and screen reader users browsing with the virtual cursor do not find it unless focus is already inside the frame.
  • site/src/pages/AgentsPage/components/ChatConversation/ConversationTimeline.stories.tsx:1324: the AssistantMessageWithImage play keeps expect calls from before this PR (image count, src, Copy message absent, toHaveFocus on View), which FE1 forbids in play functions.

🤖 This review was automatically generated with Coder Agents.

@mafredri

This comment has been minimized.

@chatgpt-codex-connector

This comment has been minimized.

coder-agents-review[bot]

This comment was marked as outdated.

@mafredri
mafredri added this pull request to stack #31375 October 27, 2026 21:24
@mafredri
mafredri marked this pull request as ready for review October 27, 2026 21:29
@mafredri
mafredri requested a review from a team as a code owner October 27, 2026 21:29
@pr-queue-manager
pr-queue-manager Bot requested a review from jakehwll October 27, 2026 21:32
@mafredri

This comment has been minimized.

@chatgpt-codex-connector

This comment has been minimized.

@coder-agents-review coder-agents-review Bot left a comment

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.

Re-review at 1c64437d01. The transcript's Download link now hides with opacity and --download-pointer-events like the composer's buttons, and its backdrop blur applies only while it shows. Findings: 2 P4, both on the attachment frame.

The new hiding fixes two items listed as out of scope earlier: Shift+Tab now reaches the Download link, and a frame without a focusable preview can reach it too. Tailwind 4.3.3 compiles the blur variable to both -webkit-backdrop-filter and backdrop-filter and emits --blur-xs. At rest the link computes opacity 0, pointer-events none, backdrop-filter none; after Shift+Tab from the end of the page it is focused with blur(4px).

Out of scope (needs a ticket or explicit acceptance by a human):

  • site/src/pages/AgentsPage/components/ChatConversation/AttachmentBlocks.tsx:463: RemoteImageBlock owns the expired and failed state, while its parent AttachmentBlock decides whether to render the frame, so the component that renders the Download link cannot see that the file is gone.

Notes:

  • Nothing checks that a hidden Download link has backdrop-filter: none. A hidden link has opacity 0, so its screenshot is the same with or without the blur, and FE1 forbids asserting computed style in a play function. This is the same gap as the hidden buttons' pointer-events and needs a human to accept it.

🤖 This review was automatically generated with Coder Agents.

// 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.

jakehwll
jakehwll previously approved these changes Oct 28, 2026
@mafredri

This comment has been minimized.

@chatgpt-codex-connector

This comment has been minimized.

coder-agents-review[bot]

This comment was marked as outdated.

@mafredri
mafredri force-pushed the perf/chat-focus-within branch from 86dc608 to 23da067 Compare November 18, 2026 14:24
mafredri added a commit that referenced this pull request Nov 23, 2026
…29596)

Base: `main`. First of a stack; #31365, #31366, #31367 and #31572
follow.

`useChatDropdownPosition`, which both chat composers use, sets five
`--mobile-dropdown-*` properties on `<html>` from an effect that
re-reads the composer's position on focus, input, selection, scroll and
resize, at every width. Only below-`md` utilities read them, and a
changed custom property on the root restyles every element. Browsers
skip a write of an equal value, so on `main` the root restyles each time
a value changes, for example when the composer grows by a line.

This PR runs the effect only below `md`, where dropdown positioning is
unchanged.

#31278 bench (a tool, not for merging) on production builds of
`f348cd66d7` (this PR's base on `main` then) and the pre-rebase version
of `af7b2c7b4a` (this PR; later commits change only tests), one chat
with 72k nodes at 1800 px, 3 alternating runs per side:

| keystroke that wraps the composer | `main` | this PR |
|---|---|---|
| Chromium | 467 to 649 ms | 17 to 32 ms |
| WebKit | 3,381 to 3,892 ms | 99 to 118 ms |

Other keystrokes and focusing the composer did not change beyond noise.

<details>
<summary>Run details</summary>

Each run types 560 characters after 340 prefilled ones, so the composer
grows by a line 6 times in Chromium and 5 in WebKit. Each wrap cell
gives min to max over the wrapping keystrokes of all 3 runs.

| p50, min to max | `main` | this PR |
|---|---|---|
| Chromium, other keystrokes | 23 to 24 ms | 23 to 24 ms |
| WebKit, other keystrokes | 97 to 99 ms | 97 to 98 ms |
| Chromium focus, pointer | 11 to 13 ms | 11 to 15 ms |
| WebKit focus, pointer | 271 to 332 ms | 303 to 324 ms |

</details>

> 🤖 This PR was created with the help of Coder Agents, and has been
reviewed by a human. 🏂🏻
@mafredri
mafredri force-pushed the perf/chat-focus-within branch from 23da067 to 43afcdb Compare November 23, 2026 15:40
Base automatically changed from perf/chat-code-block-scroll to main November 24, 2026 11:43
While a stylesheet has any `A:focus-within B` rule, WebKit restyles the
whole subtree of every ancestor of the focused element on each focus
change. The attachment overlays used Tailwind's group-focus-within for
that. The composer's Paste inline and Remove buttons now share one
wrapper that shows on hover, on focus of the preview button before it
(peer-focus), and on its own subject-position focus-within. The
transcript's Download link shows on peer-focus-within of the preview and
is hidden with opacity only, so Tab from View still reaches it.
…ver Paste inline again

Moving both overlay buttons into one wrapper after the upload overlay
painted Paste inline above the overlay, where main paints it below. The
wrapper now stays at opacity 1 and sets a custom property that both
buttons read as their opacity, so it is no stacking context. It sits
before the overlays, and Remove keeps painting above them with z-10
inside an isolated attachment root.
…to the screenshot

Story play functions set up the captured state and do not assert what
the DOM renders. Keep the Tab order checks, which need a browser and
have no Vitest browser project, and wait for the opacity transitions so
the capture shows the settled overlay.
…download link with visibility again

Hidden with opacity only, the link stayed in the tab order and the
accessibility tree and took clicks over the View button's corner. A
peer-based `visible` did not survive the focus move from View, so Tab
landed on the body. The attachment frame now sets custom properties on
its own hover and focus-within, as main's group-focus-within did
without a descendant selector, and the link reads them for its
visibility and opacity.
…d View-focus states

Add stories that end with the attachment card focused and with View focused, and drop the visibility assertion from AssistantMessageWithImage.
…om the card's focus-within

The composer card now sets the buttons' opacity and visibility through
custom properties on its own hover and focus-within, as the transcript's
attachment frame does, and the buttons sit where they are on main. The
wrapper, peer classes, pointer-events, isolate and z-10 are gone; with
main's DOM order the upload overlay again paints over Paste inline and
under Remove.

Hidden with visibility, the buttons leave the tab order and the
accessibility tree. A card whose preview is not a button (a PDF, for
example) has nothing else to focus, so it shows them at rest, and
devices without hover show them as the transcript does.

The stories end with the card, Paste inline and Remove focused;
ThumbnailFocused ended on Remove and is now RemoveFocused.
…lainly

The shared play helper and args constant only saved a few lines across
three stories; each story now tabs to its control and the later ones
reuse CardFocused.args, as ConversationTimeline does. The waits for
animations are gone: the Pixel preview disables transitions.
…tons in the tab order

With visibility, Shift+Tab from the composer skipped Paste inline and
Remove, and a card without a focusable preview showed Remove at rest,
which flipped as an upload finished. The buttons hide with opacity only
again, as on main; focus shows them through the card's focus-within, and
a pointer-events variable keeps them from taking taps while hidden.

PasteFocused and RemoveFocused now reach their buttons with Shift+Tab.
…screenshots

FE1 keeps assertions out of play functions, and the Pixel capture of
each focus story shows whether Tab reached its control. CardFocused
focuses View, so it is now ViewFocused, and the comments say what the
stories do.
…age frame at rest

AssistantMessageWithImage now ends without focus, so its screenshot shows
Download hidden; the Tab to Download moves to
AssistantMessageWithImageDownloadFocused. The attachment card comment
names the two buttons focus shows.
…ink in the tab order

The transcript's Download link was hidden with visibility, so Shift+Tab
from below the attachment frame skipped it and the screen reader's
virtual cursor did not find it. It now hides like the composer's
buttons: opacity plus a pointer-events variable from the frame's own
hover, focus-within and hover:none, so it stays in the tab order and
does not take clicks over View's corner while hidden.
…ly while it shows

With opacity hiding, the link's backdrop-blur-xs stayed applied at rest,
and Chromium composited one layer per transcript attachment: 40 images
took 45 layers instead of 5. The frame now sets the backdrop filter
with the link's other variables, so a hidden link has none. The frame
comments now say why hidden controls stay tabbable.
The frame drops the blur variable in the same style change that starts
the opacity fade, so the link showed an unblurred chip until the fade
ended. Transitioning backdrop-filter with opacity fades both together
and still ends at none, so a hidden link keeps no compositing layer.
@mafredri
mafredri force-pushed the perf/chat-focus-within branch from 43afcdb to ef413a3 Compare November 24, 2026 11:43
…o one line

Each comment now keeps only the reason a reader cannot get from the
class list: why the controls avoid group-focus-within and visibility,
and why the blur is set only while the link shows.
…lur layer

Chromium also composites a hidden link that keeps its backdrop filter,
so naming only WebKit invited dropping the blur variable. The composer
comment now words the group-focus-within reason like the frame's.
@mafredri mafredri changed the title perf(site/src/pages/AgentsPage/components): avoid descendant :focus-within selectors fix(site/src/pages/AgentsPage/components): keep hidden attachment controls tabbable and click-through Nov 25, 2026
@mafredri
mafredri merged commit 13e1f46 into main Nov 26, 2026
34 checks passed
@mafredri
mafredri deleted the perf/chat-focus-within branch November 26, 2026 11:20
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 26, 2026

This branch had an error being deployed

1 failed deployment
docs-preview — eca85f35 Deployed Nov 26, 2026 by mafredri via cleanup #536
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants