fix(web): align chat row icons and standardize interaction surfaces
This commit is contained in:
+16
-7
@@ -10,20 +10,29 @@ Status legend: `todo` · `partial` (some of it works) · `done` (working + captu
|
||||
|
||||
### Always-visible chat row actions (2026-10-21)
|
||||
|
||||
Star and Chat actions are always visible in a reserved trailing column, separate
|
||||
from title/path/model and the backend/activity mark. Native sibling buttons have
|
||||
44px targets (48px for coarse pointers), keyboard focus rings, and no hover reveal
|
||||
or opacity/layout transition. Only explicit activation opens the action menu;
|
||||
Star is always visible at the top right and Chat actions at the bottom right of
|
||||
a reserved trailing column that stretches with the row. The non-shrinking harness
|
||||
mark precedes the title inside the native session button. Native sibling action
|
||||
buttons have 44px targets (48px for coarse pointers), common ghost-button
|
||||
background/border/hover/active/focus tokens, and no hover reveal or opacity/layout
|
||||
transition. Only starred chats use an accented star. Session interaction feedback
|
||||
belongs to the outer row, matching an ordinary row without an inner rectangle.
|
||||
Only explicit activation opens the action menu;
|
||||
its existing Rename/Close/Reopen/Hide items and shared star API are unchanged.
|
||||
Menus preserve list scroll and anchor inside the viewport outside scroller clipping.
|
||||
|
||||
`test/chat-row-actions-browser.mjs` uses actual `createChatView` with mock repo/rt,
|
||||
not native chats. It captures long-title/path, selected/starred, streaming, new,
|
||||
closed, hover, keyboard, explicit-menu and scroller-bottom states at 390/420/1100px,
|
||||
plus coarse-pointer 390px. Geometry and hit-tests check non-overlap, target sizes,
|
||||
plus coarse-pointer 390px. Geometry and hit-tests check top/right and bottom/right
|
||||
anchoring (including taller content), left-before-title placement, non-overlap, target sizes,
|
||||
no hover-open/reveal, keyboard order, shared-star calls, retained selected chat,
|
||||
Rename activation and exactly one thread-route dispatch. Capture manifest:
|
||||
approved OpenCode temporary `chat-row-actions-captures/manifest.json` (16 PNGs).
|
||||
Rename activation and exactly one route dispatch per thread/logo click. CDP-forced
|
||||
normal/hover/active/hover+active/focus-visible states compare computed styles with
|
||||
ordinary ghost and row buttons (selected and unselected), including coarse input;
|
||||
real pointer movement, clicks and keyboard Tab/Enter separately verify behavior.
|
||||
Capture manifest: approved OpenCode temporary
|
||||
`chat-row-layout-followup-captures/manifest.json` (22 `topright-leftlogo-bottomright-*.png` captures).
|
||||
Usage-rail, composer-fit and miniatures browser regressions pass unchanged;
|
||||
723 unit tests pass. Live authenticated/native-chat verification and deployment
|
||||
are not performed by this isolated fixture change; no parity status is promoted.
|
||||
|
||||
+17
-20
@@ -166,7 +166,7 @@
|
||||
--chat-row-control: 44px;
|
||||
position: relative;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 22px var(--chat-row-control);
|
||||
grid-template-columns: minmax(0, 1fr) var(--chat-row-control);
|
||||
gap: 8px;
|
||||
align-items: start;
|
||||
cursor: pointer;
|
||||
@@ -189,18 +189,21 @@
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
.chat-session-button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
|
||||
/* The inner session button must never take the generic button hover fill: on a
|
||||
selected row it read as a darker rectangle inside the row's own padding. */
|
||||
.chat-session-button:hover { background: none; }
|
||||
/* The row, not an inner rectangle, owns session hover/press/focus feedback. */
|
||||
.chat-row .chat-session-button:is(:hover, :active, :focus-visible) { background: transparent; outline: none; }
|
||||
.chat-row:not(.selected):not(:hover):has(.chat-session-button:active) { background: var(--color-elevated-2); }
|
||||
.chat-row:has(.chat-session-button:focus-visible) {
|
||||
outline: var(--focus-ring-width) solid var(--focus-ring-color);
|
||||
outline-offset: var(--focus-ring-offset);
|
||||
}
|
||||
.chat-row .row-head {
|
||||
grid-column: 1;
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
.chat-row .row-title { min-width: 0; }
|
||||
.chat-row .row-title { flex: 1 1 auto; min-width: 0; }
|
||||
.chat-row .row-meta { grid-column: 1; }
|
||||
.chat-row .chat-row-meta {
|
||||
overflow: hidden;
|
||||
@@ -211,9 +214,13 @@
|
||||
/* Visible, dedicated trailing controls: no invisible hit targets, hover reveal,
|
||||
or overlays on the title, path, model or backend activity mark. */
|
||||
.chat-row-actions {
|
||||
grid-column: 3;
|
||||
grid-column: 2;
|
||||
grid-row: 1;
|
||||
display: grid;
|
||||
align-self: stretch;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
min-height: calc(2 * var(--chat-row-control) + 2px);
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
@@ -230,14 +237,10 @@
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: var(--radius-control);
|
||||
background: var(--color-surface);
|
||||
color: var(--muted);
|
||||
font-size: 18px;
|
||||
line-height: 1;
|
||||
}
|
||||
.chat-star:hover { color: var(--color-text); }
|
||||
.chat-star.starred { color: var(--color-accent); }
|
||||
button.chat-star.starred { color: var(--color-accent); }
|
||||
.chat-row .chat-menu-button {
|
||||
width: var(--chat-row-control);
|
||||
height: var(--chat-row-control);
|
||||
@@ -247,15 +250,12 @@
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: var(--color-surface);
|
||||
border-radius: var(--radius-control);
|
||||
font-size: 18px;
|
||||
line-height: 1;
|
||||
}
|
||||
/* Viewport-anchored on explicit click so the list scroller cannot clip items. */
|
||||
.chat-row .chat-menu-panel { position: fixed; top: auto; bottom: auto; right: auto; }
|
||||
.chat-menu-wrap { position: relative; }
|
||||
.chat-row-actions button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
|
||||
.chat-menu-button { min-width: 30px; font-size: 15px; line-height: 1; }
|
||||
.chat-menu-panel {
|
||||
position: absolute;
|
||||
@@ -1188,9 +1188,6 @@
|
||||
.chat-create-backend { padding: 6px 12px; border: 1px solid var(--border); color: var(--muted); }
|
||||
.chat-create-backend.selected { border-color: var(--accent); background: var(--tint-selected); color: var(--text); }
|
||||
.chat-backend-logo {
|
||||
grid-column: 2;
|
||||
grid-row: 1;
|
||||
margin-top: 12px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
@@ -2109,6 +2109,7 @@ function renderChatRow(session, duplicateTitles = new Set(), home = "") {
|
||||
},
|
||||
});
|
||||
const head = h("span", { class: "row-head" });
|
||||
head.append(chatBackendLogo(session.backend, activity));
|
||||
head.append(h("span", { class: "row-title chat-row-title", text: sessionTitle(session) }));
|
||||
// Only the status word, coloured, with no dot and no operator chip. A closed
|
||||
// session says so here instead of carrying a second chip.
|
||||
@@ -2128,11 +2129,11 @@ function renderChatRow(session, duplicateTitles = new Set(), home = "") {
|
||||
if (model !== "") {
|
||||
sessionButton.append(h("span", { class: "row-meta chat-row-model muted", text: model }));
|
||||
}
|
||||
row.append(sessionButton, chatBackendLogo(session.backend, activity), renderChatActionsMenu(session, duplicateTitles));
|
||||
row.append(sessionButton, renderChatActionsMenu(session, duplicateTitles));
|
||||
return row;
|
||||
}
|
||||
|
||||
/** Keep the fixed harness mark current without repainting the list or its rows. */
|
||||
/** Keep the harness mark current without repainting the list or its rows. */
|
||||
function refreshChatRowActivity(sessionId, thread) {
|
||||
const row = document.querySelector(`#chatRows .chat-row[data-session="${CSS.escape(sessionId)}"]`);
|
||||
const icon = row?.querySelector(".chat-backend-logo");
|
||||
@@ -2152,7 +2153,7 @@ function refreshChatRowActivity(sessionId, thread) {
|
||||
* order, the model note and the footer naming the value that will be sent. Every
|
||||
* server string is set with textContent.
|
||||
*/
|
||||
/** One agent's mark on the right of its chat row. */
|
||||
/** One agent's mark immediately before its chat title. */
|
||||
function chatBackendLogo(backend, activity = "idle") {
|
||||
const value = String(backend ?? "").trim().toLowerCase() || "opencode";
|
||||
const label = chatBackendLabel(value);
|
||||
|
||||
@@ -14,6 +14,7 @@ const html = `<!doctype html><meta charset="utf-8"><meta name="viewport" content
|
||||
${["design/tokens/tokens", "base", "shell", "lists", "run-detail", "chat", "dialogs"].map(n => `<link rel="stylesheet" href="/${n}.css">`).join("")}
|
||||
<style>body { margin: 0; } #fixture { display: flex; height: calc(100dvh - 80px); max-width: 540px; margin: 40px auto; } #fixture > .chat-list { flex: 1; }</style>
|
||||
<div id="fixture"></div>
|
||||
<div style="position:fixed;top:-1000px;left:0"><button id="ghostBaseline" class="ghost">Ordinary ghost</button><button id="rowBaseline" class="row">Ordinary row</button></div>
|
||||
<script type="module">
|
||||
import { createChatView } from '/src/views/chat.js';
|
||||
import { newChatThread } from '/src/chat.js';
|
||||
@@ -58,6 +59,7 @@ await new Promise(r => server.listen(0, "127.0.0.1", r));
|
||||
let browser, mouse;
|
||||
const captures = [];
|
||||
const measurements = [];
|
||||
const styleComparisons = [];
|
||||
try {
|
||||
browser = await launchChrome();
|
||||
const page = await browser.openPage(`http://127.0.0.1:${server.address().port}/`);
|
||||
@@ -67,19 +69,73 @@ try {
|
||||
mouse = new WebSocket(target.webSocketDebuggerUrl);
|
||||
await new Promise(r => mouse.addEventListener('open', r, {once:true}));
|
||||
let sequence = 0;
|
||||
const move = (x, y) => new Promise((resolve, reject) => {
|
||||
const command = (method, params = {}) => new Promise((resolve, reject) => {
|
||||
const id = ++sequence;
|
||||
const listener = event => {
|
||||
const response = JSON.parse(event.data);
|
||||
if (response.id !== id) return;
|
||||
mouse.removeEventListener('message', listener);
|
||||
response.error ? reject(Error(response.error.message)) : resolve();
|
||||
response.error ? reject(Error(response.error.message)) : resolve(response.result);
|
||||
};
|
||||
mouse.addEventListener('message', listener);
|
||||
mouse.send(JSON.stringify({id,method:'Input.dispatchMouseEvent',params:{type:'mouseMoved',x,y}}));
|
||||
mouse.send(JSON.stringify({id,method,params}));
|
||||
});
|
||||
const move = (x, y) => command('Input.dispatchMouseEvent', {type:'mouseMoved',x,y});
|
||||
await command('DOM.enable');
|
||||
await command('CSS.enable');
|
||||
const {root:documentRoot} = await command('DOM.getDocument');
|
||||
const force = async (selector, forcedPseudoClasses) => {
|
||||
const {nodeId} = await command('DOM.querySelector', {nodeId:documentRoot.nodeId,selector});
|
||||
await command('CSS.forcePseudoState', {nodeId,forcedPseudoClasses});
|
||||
};
|
||||
const styles = selector => page.evaluate(`(() => {
|
||||
const s=getComputedStyle(document.querySelector(${JSON.stringify(selector)}));
|
||||
return Object.fromEntries(['backgroundColor','borderTopColor','borderTopWidth','borderRadius','boxShadow','color',
|
||||
'outlineColor','outlineWidth','outlineStyle','outlineOffset'].map(key=>[key,s[key]]));
|
||||
})()`);
|
||||
const compareStyles = async (width, coarse = false) => {
|
||||
await move(1,1);
|
||||
await page.evaluate('document.activeElement.blur()');
|
||||
for (const state of [[],['hover'],['active'],['hover','active'],['focus-visible']]) {
|
||||
const selectors=['#ghostBaseline','[data-session=streaming] .chat-star','[data-session=streaming] .chat-menu-button'];
|
||||
for (const selector of selectors) await force(selector,state);
|
||||
// Allow the shared background/border transitions to settle before comparing.
|
||||
await page.evaluate('new Promise(r=>setTimeout(r,250))');
|
||||
const baseline=await styles('#ghostBaseline');
|
||||
for (const selector of selectors.slice(1)) assert.deepEqual(await styles(selector),baseline,`${selector}: ghost ${state}`);
|
||||
await force('[data-session=selected] .chat-star',state);
|
||||
await page.evaluate('new Promise(r=>setTimeout(r,250))');
|
||||
const starred=await styles('[data-session=selected] .chat-star');
|
||||
for (const key of ['backgroundColor','borderTopColor','borderTopWidth','borderRadius','boxShadow','outlineWidth','outlineStyle','outlineOffset']) assert.equal(starred[key],baseline[key],`starred ghost ${state}: ${key}`);
|
||||
assert.equal(starred.color,await page.evaluate("(() => {const el=document.createElement('span');el.style.color='var(--color-accent)';document.body.append(el);const color=getComputedStyle(el).color;el.remove();return color;})()"),'starred state alone keeps its accent');
|
||||
await force('[data-session=selected] .chat-star',[]);
|
||||
for (const selector of selectors) await force(selector,[]);
|
||||
for (const selected of [false,true]) {
|
||||
const row=selected?'[data-session=selected]':'[data-session=streaming]';
|
||||
await page.evaluate(`document.querySelector('#rowBaseline').classList.toggle('selected',${selected})`);
|
||||
await force('#rowBaseline',state);
|
||||
await force(row,state.includes('hover')?['hover']:[]);
|
||||
await force(row+' .chat-session-button',state);
|
||||
await page.evaluate('new Promise(r=>setTimeout(r,250))');
|
||||
const expected=await styles('#rowBaseline'), actual=await styles(row);
|
||||
// Container and native row inherit the same row surface/focus tokens.
|
||||
for (const key of ['backgroundColor','borderTopColor','borderTopWidth','borderRadius','boxShadow','outlineColor','outlineWidth','outlineStyle','outlineOffset']) {
|
||||
assert.equal(actual[key],expected[key],`row selected=${selected} ${state}: ${key}`);
|
||||
}
|
||||
const inner=await styles(row+' .chat-session-button');
|
||||
assert.equal(inner.backgroundColor,'rgba(0, 0, 0, 0)','no inner hover/press fill');
|
||||
assert.equal(inner.boxShadow,'none','no inner inset');
|
||||
assert.equal(inner.outlineStyle,'none','focus ring belongs to outer row');
|
||||
styleComparisons.push({width,coarse,state,selected,ghost:baseline,starred,row:actual,inner});
|
||||
if (!selected && state.includes('active') && !state.includes('hover') && !coarse) await capture(`active-surface-${width}`);
|
||||
await force(row+' .chat-session-button',[]);
|
||||
await force(row,[]);
|
||||
await force('#rowBaseline',[]);
|
||||
}
|
||||
}
|
||||
};
|
||||
const capture = async name => {
|
||||
const file = `${name}.png`;
|
||||
const file = `topright-leftlogo-bottomright-${name}.png`;
|
||||
await page.screenshot(resolve(out, file));
|
||||
captures.push(file);
|
||||
};
|
||||
@@ -88,7 +144,15 @@ try {
|
||||
return [...document.querySelectorAll('.chat-row')].map(row => {
|
||||
const controls = [...row.querySelectorAll('.chat-star,.chat-menu-button')];
|
||||
const content = [...row.querySelectorAll('.chat-session-button,.chat-backend-logo')];
|
||||
return {id:row.dataset.session, controls:controls.map(button => {
|
||||
const r=row.getBoundingClientRect(), s=getComputedStyle(row), logo=row.querySelector('.chat-backend-logo'), title=row.querySelector('.chat-row-title');
|
||||
const star=controls[0].getBoundingClientRect(), more=controls[1].getBoundingClientRect();
|
||||
return {id:row.dataset.session,
|
||||
topRight:Math.abs(star.top-r.top-parseFloat(s.paddingTop))<1,
|
||||
bottomRight:Math.abs(more.bottom-r.bottom+parseFloat(s.paddingBottom)+parseFloat(s.borderBottomWidth))<1,
|
||||
sameRight:star.right===more.right && Math.abs(star.right-r.right+parseFloat(s.paddingRight))<1,
|
||||
logoBeforeTitle:logo.parentElement===title.parentElement && logo.nextElementSibling===title && logo.getBoundingClientRect().right<=title.getBoundingClientRect().left,
|
||||
logoNonshrink:getComputedStyle(logo).flexShrink==='0',
|
||||
controls:controls.map(button => {
|
||||
const r=button.getBoundingClientRect(), style=getComputedStyle(button);
|
||||
return {width:r.width,height:r.height,x:r.x,y:r.y,opacity:getComputedStyle(button.parentElement).opacity,
|
||||
transition:getComputedStyle(button.parentElement).transitionDuration,
|
||||
@@ -106,6 +170,7 @@ try {
|
||||
const before = await geometry();
|
||||
measurements.push({width, rows:before});
|
||||
assert.equal(before.length, 4);
|
||||
for (const row of before) for (const key of ['topRight','bottomRight','sameRight','logoBeforeTitle','logoNonshrink']) assert.equal(row[key],true,`${row.id}: ${key}`);
|
||||
for (const row of before) for (const button of row.controls) {
|
||||
assert.ok(button.width >= 44 && button.height >= 44, `${row.id}: touch target`);
|
||||
assert.equal(button.opacity, '1');
|
||||
@@ -119,6 +184,10 @@ try {
|
||||
assert.equal(await page.evaluate("document.querySelector('[data-session=streaming] .chat-backend-logo').dataset.activity"), 'streaming');
|
||||
assert.equal(await page.evaluate("document.querySelector('[data-session=new] .chat-backend-logo').dataset.activity"), 'new');
|
||||
await capture(`rows-visible-${width}`);
|
||||
await compareStyles(width);
|
||||
await page.evaluate("document.querySelector('[data-session=selected] .chat-session-button').style.minHeight='160px'");
|
||||
assert.ok((await geometry()).every(row=>row.topRight && row.bottomRight && row.sameRight),'controls anchor to full row height, not two adjacent fixed rows');
|
||||
await page.evaluate("document.querySelector('[data-session=selected] .chat-session-button').style.minHeight=''");
|
||||
const first = before[0].controls[0];
|
||||
await move(first.x + 22, first.y + 22);
|
||||
assert.deepEqual(await geometry(), before, 'hover changes neither controls nor layout');
|
||||
@@ -144,6 +213,13 @@ try {
|
||||
await capture(`rows-menu-${width}`);
|
||||
|
||||
await page.evaluate('reset()');
|
||||
await page.click('[data-session=streaming] .chat-menu-button');
|
||||
assert.equal(await page.evaluate('state.chatMenu'), 'streaming');
|
||||
assert.equal(await page.evaluate('state.chatActiveId'), 'selected');
|
||||
assert.deepEqual(await page.evaluate('calls.routes'), []);
|
||||
await capture(`rows-pointer-menu-${width}`);
|
||||
await page.click('[data-session=streaming] .chat-menu-button');
|
||||
assert.equal(await page.evaluate("document.querySelectorAll('.chat-menu-panel').length"), 0);
|
||||
const stars = await page.evaluate('calls.stars.length');
|
||||
await page.click('[data-session=streaming] .chat-star');
|
||||
assert.deepEqual(await page.evaluate('calls.stars.at(-1)'), {id:'streaming',starred:true});
|
||||
@@ -187,13 +263,18 @@ try {
|
||||
}
|
||||
await page.emulateTouch();
|
||||
await page.resize(390, 844);
|
||||
measurements.push({width:390,coarse:true,rows:await geometry()});
|
||||
assert.ok((await geometry()).every(row => row.controls.every(button => button.width >= 48 && button.height >= 48)));
|
||||
assert.ok((await geometry()).every(row => row.topRight && row.bottomRight && row.sameRight && row.logoBeforeTitle && row.logoNonshrink));
|
||||
await compareStyles(390,true);
|
||||
await capture('rows-coarse-pointer-390');
|
||||
// Exactly one route dispatch for a thread click (all action tests dispatched 0).
|
||||
await page.click('[data-session=selected] .chat-session-button');
|
||||
assert.deepEqual(await page.evaluate('calls.routes'), [{kind:'chatSession',id:'selected'}]);
|
||||
await writeFile(resolve(out, 'manifest.json'), JSON.stringify({captures, measurements, widths:[390,420,1100],fixture:'actual createChatView, mock repo/rt, no native chat'}, null, 2));
|
||||
console.log(`PASS: visible stable controls, no hover menu/reveal, 44/48px targets, keyboard order, shared star API, preserved selected thread, single route dispatch, bottom menu hit-tests. Captures: ${out}`);
|
||||
await page.click('[data-session=selected] .chat-backend-logo');
|
||||
assert.deepEqual(await page.evaluate('calls.routes'), [{kind:'chatSession',id:'selected'},{kind:'chatSession',id:'selected'}], 'logo inside native session button dispatches once too');
|
||||
await writeFile(resolve(out, 'manifest.json'), JSON.stringify({captures, measurements, styleComparisons, widths:[390,420,1100],fixture:'actual createChatView, mock repo/rt, no native chat'}, null, 2));
|
||||
console.log(`PASS: top-right star, left-before-title logo, bottom-right more, common ghost/row computed styles (${styleComparisons.length} states), no hover reveal, 44/48px targets, keyboard order, shared star API, selected thread retained, single thread/logo click dispatch, bottom menu hit-tests. Captures: ${out}`);
|
||||
} finally {
|
||||
mouse?.close();
|
||||
await browser?.close();
|
||||
|
||||
Reference in New Issue
Block a user