Skip to content

fix(web): Replace anti-pattern of assigning role="button" to entire message div#665

Merged
tiann merged 2 commits into
tiann:mainfrom
arkylin:fix/message-metadata-toggle
May 22, 2026
Merged

fix(web): Replace anti-pattern of assigning role="button" to entire message div#665
tiann merged 2 commits into
tiann:mainfrom
arkylin:fix/message-metadata-toggle

Conversation

@arkylin
Copy link
Copy Markdown
Contributor

@arkylin arkylin commented May 22, 2026

Fix: Replace anti-pattern of assigning role="button" to entire message div

Problem:
The entire message content div had role="button" and aria-expanded attributes,
which caused several issues:

  • Unwanted scrollbars appearing in the message area
  • Interference with text selection (mouse selection showed detailed info instead
    of selecting text)
  • Poor accessibility and keyboard navigation experience

Solution:

  • Remove role="button" and aria-expanded from the message content div
  • Add an explicit "Show info" / "Hide info" button next to the timestamp
  • This ensures proper text selection behavior without triggering the info panel
  • Improves accessibility with a clear, focusable button element

Testing:

  • Verified text selection works correctly
  • Confirmed no unwanted scrollbars
  • Tested keyboard navigation and screen reader compatibility

Replace the anti-pattern of assigning role="button" and aria-expanded to the entire message content div. Instead, show an explicit "Show info" / "Hide info" button next to the timestamp.

Also add a visible background container to MessageMetadata so users can actually see when metadata expands/collapses.

Remove now-unused metadataToggle.ts and its tests.

Before
Snipaste_2026-05-22_19-40-54
Snipaste_2026-05-22_19-41-13

After
Snipaste_2026-05-22_19-42-54
Snipaste_2026-05-22_19-43-08

…tton

Replace the anti-pattern of assigning role=\"button\" and aria-expanded to
the entire message content div. Instead, show an explicit \"Show info\" /
\"Hide info\" button next to the timestamp.

Also add a visible background container to MessageMetadata so users can
actually see when metadata expands/collapses.

Remove now-unused metadataToggle.ts and its tests.
Copilot AI review requested due to automatic review settings May 22, 2026 11:51
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Findings
None.

Summary
Review mode: initial
No high-confidence issues found in the latest diff. Residual risk: the PR removes the focused metadataToggle regression tests and replaces wrapper toggling with explicit UI buttons, but this runner cannot execute the web test/typecheck suite because bun is unavailable.

Testing
Not run (automation: bun not found in runner).

HAPI Bot

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the chat message metadata disclosure UX and accessibility by removing the “entire message is a button” pattern and replacing it with an explicit “Show info / Hide info” toggle button near the timestamp. It also updates MessageMetadata styling to make the expanded state visually distinct, and removes the now-obsolete event-guard utility and its tests.

Changes:

  • Remove role="button" / aria-expanded / click+keydown handlers from message containers and add an explicit metadata toggle <button> next to the timestamp.
  • Restyle MessageMetadata with a visible background container (subtle bg + padding + rounded corners).
  • Delete metadataToggle.ts and metadataToggle.test.ts (no longer needed after switching to explicit buttons).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
web/src/components/AssistantChat/messages/UserMessage.tsx Removes bubble-level “button” behavior and adds an explicit “Show info” toggle near the timestamp for user messages (incl. CLI output variant).
web/src/components/AssistantChat/messages/AssistantMessage.tsx Removes bubble-level “button” behavior and adds an explicit “Show info” toggle near the timestamp across assistant message variants.
web/src/components/AssistantChat/messages/MessageMetadata.tsx Adds a visible background container to the metadata footer for clearer expanded/collapsed affordance.
web/src/components/AssistantChat/messages/metadataToggle.ts Removed: no longer needed after switching to explicit toggle buttons.
web/src/components/AssistantChat/messages/metadataToggle.test.ts Removed: tests for removed helper.
Comments suppressed due to low confidence (1)

web/src/components/AssistantChat/messages/AssistantMessage.tsx:131

  • In the codexReview branch, MessageMetadata is rendered without passing turnCount. Since aggregated footers inject turnCount into metadata.custom, this branch will omit the “N turns” line (and aggregated labeling behavior) even when present. Pass turnCount={turnCount} here for consistency with the other branches.
                        {showMetadata && (
                            <MessageMetadata
                                invokedAt={invokedAt}
                                durationMs={durationMs}
                                usage={usage}
                                model={messageModel ?? null}
                            />
                        )}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread web/src/components/AssistantChat/messages/AssistantMessage.tsx
Comment thread web/src/components/AssistantChat/messages/AssistantMessage.tsx
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Findings
None.

Summary
Review mode: follow-up after new commits
No high-confidence issues found in the latest diff. I reviewed the full PR diff, using the previous HAPI Bot review and the compare diff as follow-up context. Residual risk: the removed metadataToggle unit coverage is not replaced by component-level coverage for the new explicit metadata buttons, and this runner cannot execute the web suite because bun is unavailable.

Testing
Not run (automation: bun not found in runner).

HAPI Bot

@tiann tiann merged commit 04d3d02 into tiann:main May 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants