From fa48a21e6595bb7d73c2269ccd256ad8b6691f2b Mon Sep 17 00:00:00 2001 From: YokiiroBW Date: Mon, 27 Jul 2026 00:59:11 +0800 Subject: [PATCH] fix(chat): repair the message row layout and action buttons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three defects reported from real-machine testing, all rooted in the same few conflicting CSS blocks, so they are fixed together — separating them would leave intermediate states that render worse than either end. The action buttons showed wrapped vertical text inside a 2rem box. styles.css already defined .message-action-label, a clip-rect screen-reader-only class clearly written for these buttons, but nothing in the tree ever used it: ChatPanel rendered a bare span. Wire the class up so the buttons are icon-only, and drop the border so they read as plain icons rather than pills. .chat-message-actions and its buttons were defined five times across the stylesheet, three of those styling them as bordered pills that the final block then partially overrode. Remove .chat-message-actions button from the three pill rule groups and the small-screen grid rule, leaving one definition next to .message-action-icon. .chat-runtime-actions and .chat-stop-button keep the pill treatment; they are different controls. The avatar rendered below its bubble instead of beside it. .chat-message-row used align-items: flex-end, and .chat-message-content is taller than the bubble because the action bar reserves a row, so the avatar was pinned to the bottom of that taller box. Align to the top. Removing visibility: hidden from the hidden action bar also closes F-40 (audit P2-24): visibility removed the buttons from the tab order, so :focus-within could never fire and a keyboard user could never reveal them. Opacity alone keeps them focusable. Verified against the real stylesheet in a browser: avatar and bubble tops differ by 0px, the button computes to 34x34 with 0px border, the label measures 1x1, and focusing a button takes the bar from opacity 0 to 1. Co-Authored-By: Claude Opus 5 --- src/features/chat/ChatPanel.tsx | 6 ++-- src/styles.css | 58 ++++++++++++++++----------------- 2 files changed, 31 insertions(+), 33 deletions(-) diff --git a/src/features/chat/ChatPanel.tsx b/src/features/chat/ChatPanel.tsx index 8a11710..4a2b500 100644 --- a/src/features/chat/ChatPanel.tsx +++ b/src/features/chat/ChatPanel.tsx @@ -819,7 +819,7 @@ export function ChatPanel({ fixedSlot }: ChatPanelProps) { className="message-action-icon icon-copy" aria-hidden="true" /> - 复制 + 复制 ) : null} diff --git a/src/styles.css b/src/styles.css index 072d8fe..662ead5 100644 --- a/src/styles.css +++ b/src/styles.css @@ -508,7 +508,11 @@ select:focus { .chat-message-row { display: flex; - align-items: flex-end; + /* Aligns the avatar with the top of the bubble. It used to be `flex-end`, + which pinned the avatar to the bottom of `.chat-message-content` — and that + box is taller than the bubble because the action bar reserves a row, so the + avatar rendered below the bubble instead of beside it. */ + align-items: flex-start; gap: 0.55rem; width: min(82%, 46rem); justify-self: start; @@ -2176,14 +2180,10 @@ body, } .chat-runtime-actions, -.chat-message-actions { - display: flex; - flex-wrap: wrap; - gap: 6px; -} - +/* `.chat-message-actions button` is intentionally absent from these pill rules. + Message actions are borderless icon buttons; their single definition lives + further down next to `.message-action-icon`. */ .chat-runtime-actions button, -.chat-message-actions button, .chat-stop-button { border: 1px solid var(--line, #c8d8ea); border-radius: 999px; @@ -2195,7 +2195,6 @@ body, } .chat-runtime-actions button:hover, -.chat-message-actions button:hover, .chat-stop-button:hover { background: var(--soft-accent, #eaf3ff); color: var(--accent, #2f6fb2); @@ -2266,10 +2265,6 @@ body, color: var(--accent, #2f6fb2); } -.chat-message-actions { - margin-top: 8px; -} - .chat-stop-button { margin-top: 8px; border-color: #d88d8d; @@ -2459,7 +2454,6 @@ textarea:focus-visible, } .chat-runtime-actions button, -.chat-message-actions button, .chat-stop-button { min-height: 2rem; border: 1px solid var(--ui-line); @@ -2469,7 +2463,6 @@ textarea:focus-visible, } .chat-runtime-actions button:hover, -.chat-message-actions button:hover, .chat-stop-button:hover { border-color: var(--ui-line-strong); color: var(--ui-ink); @@ -2659,7 +2652,6 @@ textarea:focus-visible, } .chat-runtime-actions button, -.chat-message-actions button, .chat-stop-button, .voice-button, .file-picker, @@ -2668,6 +2660,10 @@ textarea:focus-visible, touch-action: manipulation; } +.chat-message-actions button { + touch-action: manipulation; +} + .chat-runtime-actions button:disabled { border-color: var(--ui-line); color: var(--ui-subtle); @@ -2738,17 +2734,11 @@ textarea:focus-visible, } .chat-runtime-actions button, - .chat-message-actions button, .chat-stop-button, .voice-button, .file-picker { width: 100%; } - - .chat-message-actions { - display: grid; - grid-template-columns: repeat(3, minmax(0, 1fr)); - } } :root { @@ -3125,27 +3115,31 @@ button:disabled { transform: translateY(-0.2rem); transition: opacity 150ms ease, - transform 150ms ease, - visibility 150ms ease; - visibility: hidden; + transform 150ms ease; } +/* Deliberately no `visibility: hidden`. It removed the buttons from the tab + order, so `:focus-within` could never fire and a keyboard user could never + reveal them. Opacity alone keeps them focusable. */ .chat-message-row:hover .chat-message-actions, .chat-message-row:focus-within .chat-message-actions { opacity: 1; pointer-events: auto; transform: translateY(0); - visibility: visible; } +/* The single definition of a message action button: borderless, icon only. + The visible label is carried by `.message-action-label`, which is clipped for + screen readers, so the button must never be sized for text. */ .chat-message-actions button { display: inline-flex; align-items: center; justify-content: center; width: 2rem; + height: 2rem; min-height: 2rem; padding: 0; - border: 1px solid transparent; + border: 0; border-radius: 0.55rem; color: var(--ui-subtle); background: transparent; @@ -3154,11 +3148,15 @@ button:disabled { .chat-message-actions button:hover:not(:disabled), .chat-message-actions button:focus-visible { - border-color: var(--ui-line); color: var(--ui-ink); background: var(--ui-surface-soft); } +.chat-message-actions button:hover:not(:disabled) .message-action-icon, +.chat-message-actions button:focus-visible .message-action-icon { + color: var(--ui-ink); +} + .message-action-label { position: absolute; width: 1px; @@ -3285,11 +3283,12 @@ button:disabled { } .chat-message-actions button { + width: 2.1rem; + height: 2.1rem; min-height: 2.1rem; } } - /* Stable chat session pills and native-style window controls. */ .chat-session-list { flex: 0 0 auto; @@ -3364,7 +3363,6 @@ button:disabled { } } - .message-attachment-image { display: block; max-width: min(22rem, 100%);