fix(web): keep chat row actions visible in reserved columns

This commit is contained in:
2026-10-21 01:11:22 +01:00
parent fe02d153f1
commit 2c1d5ccd47
4 changed files with 265 additions and 87 deletions
+20
View File
@@ -8,6 +8,26 @@ test, or a code change without a capture, is `partial` at best.
Status legend: `todo` · `partial` (some of it works) · `done` (working + captured).
### 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;
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,
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).
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.
### Chat performance and usage (2026-10-21)
The chat header now shows reported output tokens/sec, total processed tokens,
+29 -68
View File
@@ -163,10 +163,11 @@
text-transform: none;
}
.chat-row {
--chat-row-control: 44px;
position: relative;
display: grid;
grid-template-columns: minmax(0, 1fr);
gap: 2px;
grid-template-columns: minmax(0, 1fr) 22px var(--chat-row-control);
gap: 8px;
align-items: start;
cursor: pointer;
}
@@ -174,7 +175,7 @@
and the Chat actions menu is a sibling of this button. */
.chat-session-button {
grid-column: 1;
grid-row: 1 / span 3;
grid-row: 1;
display: grid;
gap: 2px;
width: 100%;
@@ -198,9 +199,6 @@
gap: 8px;
align-items: center;
flex-wrap: wrap;
/* The star is an absolute top-right overlay; reserve its corner so it never
covers the Streaming/New/Idle word on a touch screen where it is always on. */
padding-right: 26px;
}
.chat-row .row-title { min-width: 0; }
.chat-row .row-meta { grid-column: 1; }
@@ -209,41 +207,25 @@
text-overflow: ellipsis;
white-space: nowrap;
}
.chat-row-model { font-size: 11px; }
/* Star (top-right) and the more menu (bottom-right) sit over the row's own
corners on hover/focus, so they never become an extra row or reserve width. */
.chat-row-model { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Visible, dedicated trailing controls: no invisible hit targets, hover reveal,
or overlays on the title, path, model or backend activity mark. */
.chat-row-actions {
position: absolute;
inset: 0;
opacity: 0;
pointer-events: none;
transition: opacity 100ms ease-out;
grid-column: 3;
grid-row: 1;
display: grid;
gap: 2px;
}
.chat-row-actions > .chat-star,
.chat-row-actions > .chat-menu-button,
.chat-row-actions > .chat-menu-panel { pointer-events: auto; }
.chat-row:hover .chat-row-actions,
.chat-row:focus-within .chat-row-actions,
.chat-row.menu-open .chat-row-actions { opacity: 1; }
/* An open menu paints above the rows below it, not under their content. */
.chat-row.menu-open { z-index: 30; }
@media (hover: none) {
.chat-row-actions { opacity: 1; }
.chat-row-actions > .chat-star,
.chat-row-actions > .chat-menu-button,
.chat-row-actions > .chat-menu-panel { pointer-events: auto; }
}
.chat-row-actions .chat-menu-item { padding: 3px 10px; font-size: 12px; }
.chat-row-actions .chat-menu-item { min-height: 44px; padding: 8px 12px; font-size: 12px; }
/* The local star: outline when unstarred, filled and accented when starred. */
.chat-star {
position: absolute;
top: 5px;
right: 6px;
width: 20px;
height: 20px;
min-width: 0;
min-height: 0;
width: var(--chat-row-control);
height: var(--chat-row-control);
min-width: 44px;
min-height: 44px;
padding: 0;
display: inline-flex;
align-items: center;
@@ -251,33 +233,29 @@
border-radius: var(--radius-control);
background: var(--color-surface);
color: var(--muted);
font-size: 13px;
font-size: 18px;
line-height: 1;
}
.chat-star:hover { color: var(--color-text); }
.chat-star.starred { color: var(--color-accent); }
.chat-row .chat-menu-button {
position: absolute;
right: 6px;
bottom: 5px;
width: 20px;
height: 20px;
min-width: 0;
min-height: 0;
width: var(--chat-row-control);
height: var(--chat-row-control);
min-width: 44px;
min-height: 44px;
padding: 0;
display: inline-flex;
align-items: center;
justify-content: center;
background: var(--color-surface);
border-radius: var(--radius-control);
font-size: 13px;
font-size: 18px;
line-height: 1;
}
/* The row menu opens below the bottom-right button; the open row stacks above
its neighbours so the panel is not covered by the next row. */
.chat-row .chat-menu-panel { top: calc(100% + 4px); bottom: auto; right: 8px; }
/* 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.chat-menu-wrap { position: absolute; inset: 0; }
.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;
@@ -1195,23 +1173,8 @@
.chat-group-toggle { min-height: 40px; padding: 10px 42px; font-size: 12px; }
.chat-group-directory .chat-group-title { font-size: 12px; }
.chat-row { min-height: 96px; }
.chat-row .row-head { padding-right: 50px; }
.chat-backend-logo { width: 22px; height: 22px; }
.chat-backend-logo svg { width: 20px; height: 20px; }
.chat-star {
top: 2px;
right: 2px;
width: 44px;
height: 44px;
font-size: 18px;
}
.chat-row .chat-menu-button {
right: 2px;
bottom: 2px;
width: 44px;
height: 44px;
font-size: 18px;
}
.chat-row-actions .chat-menu-item { padding: 8px 12px; font-size: 14px; }
.back-button .back-chevron { width: 24px; height: 24px; }
.chat-bar-title { font-size: 18px; }
@@ -1225,9 +1188,9 @@
.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 {
position: absolute;
top: 12px;
right: 54px;
grid-column: 2;
grid-row: 1;
margin-top: 12px;
display: inline-flex;
align-items: center;
justify-content: center;
@@ -1241,7 +1204,6 @@
.chat-question-field[hidden] { display: none; }
.chat-backend-logo[data-activity="streaming"] { color: var(--accent); }
.chat-backend-logo[data-activity="new"] { color: var(--ok); }
.chat-row .row-head { padding-right: 86px; }
.chat-backend-chip {
flex: 0 0 auto;
padding: 1px 6px;
@@ -1271,6 +1233,5 @@
.chat-reasoning-toggle, .chat-tool-chip, .chat-group-toggle,
.chat-send, .chat-stop, .chat-attach, .chat-model-button, .chat-model-option,
.chat-new { min-height: 48px; }
.chat-row .chat-star, .chat-row .chat-menu-button { width: 48px; height: 48px; }
.chat-row .row-head { padding-right: 86px; }
.chat-row { --chat-row-control: 48px; }
}
+15 -19
View File
@@ -1187,31 +1187,16 @@ function effectiveChatSession(session) {
function openChatMenu(sessionId) {
const scrollTop = document.getElementById("chatRows")?.scrollTop ?? 0;
state.chatMenu = state.chatMenu === sessionId ? null : sessionId;
renderContent();
const rows = document.getElementById("chatRows");
if (rows) rows.scrollTop = scrollTop;
if (state.chatMenu) {
// The panel hangs below its button. Near the bottom of the window that would
// put the items off-screen (a real hit-test failure, not just clipping), so
// flip the panel above the row when it does not fit below.
const row = document.querySelector(`#chatRows .chat-row[data-session="${CSS.escape(sessionId)}"]`);
const panel = row?.querySelector(".chat-menu-panel");
if (panel && panel.getBoundingClientRect().bottom > window.innerHeight - 8) {
panel.style.top = "auto";
panel.style.bottom = "calc(100% + 4px)";
}
// Flipping is not always enough: a row at the very bottom edge can leave the
// panel (and its items) below the viewport even when it opens upwards. Bring
// the row into view so the menu is actually reachable.
if (panel && row) {
const rect = panel.getBoundingClientRect();
if (rect.top < 8 || rect.bottom > window.innerHeight - 8) {
row.scrollIntoView({ block: "nearest" });
}
}
// The re-render replaced the focused button; move focus into the panel so a
// keyboard operator can walk the items without hunting for the next Tab stop.
const first = document.querySelector(`#chatRows .chat-row[data-session="${CSS.escape(sessionId)}"] .chat-menu-item`);
first?.focus();
first?.focus({ preventScroll: true });
}
}
@@ -2466,6 +2451,17 @@ function renderChatActionsMenu(session, duplicateTitles = new Set()) {
}),
);
wrap.append(menu);
// Measure after mounting (and after openChatMenu restores list scroll), but
// before painting. Re-anchor on every render, not only the initial click.
queueMicrotask(() => {
if (!menu.isConnected) return;
const anchor = wrap.querySelector(".chat-menu-button").getBoundingClientRect();
const rect = menu.getBoundingClientRect();
const below = anchor.bottom + 4;
const top = below + rect.height <= window.innerHeight - 8 ? below : anchor.top - rect.height - 4;
menu.style.left = `${Math.max(8, Math.min(anchor.right - rect.width, window.innerWidth - rect.width - 8))}px`;
menu.style.top = `${Math.max(8, Math.min(top, window.innerHeight - rect.height - 8))}px`;
});
}
return wrap;
}
+201
View File
@@ -0,0 +1,201 @@
// Focused UI-smoke extension: real createChatView + mock repository only.
// No native chats, provider calls, live server or framework.
import assert from "node:assert/strict";
import { createServer } from "node:http";
import { readFile, mkdir, writeFile } from "node:fs/promises";
import { resolve, extname, dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { launchChrome } from "./browser.mjs";
const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
const out = resolve(process.argv[2] ?? "captures-chat-row-actions");
await mkdir(out, { recursive: true });
const html = `<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
${["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>
<script type="module">
import { createChatView } from '/src/views/chat.js';
import { newChatThread } from '/src/chat.js';
const long = 'Review a very long chat title that must never overlap any of its controls or backend mark';
const directory = '/Users/fixture/projects/a-very-long-project-directory/with/deeply/nested/worktrees';
const sessions = [
{ id:'selected', title:long, backend:'opencode', model:'openai/gpt-6.1-sol-with-a-very-long-model-name', starred:true },
{ id:'streaming', title:long, backend:'claude', model:'claude-sonnet' },
{ id:'new', title:long, backend:'codex', model:'gpt-5' },
{ id:'closed', title:long, backend:'opencode', model:'gpt-6.1', closed:true },
].map(s => ({ ...s, directory, updated_at:Date.now() }));
window.calls = { routes:[], stars:[] };
window.state = {
view:'chat', chatActiveId:'selected', chatSessions:sessions, chatQuery:'',
chatOverrides:{}, chatStars:new Set(['selected']), chatClosedOpen:true,
chatSeen:{}, chatThreads:new Map([
['selected',{...newChatThread('selected'),loaded:true}],
['streaming',{...newChatThread('streaming'),loaded:true,running:true}],
]), connection:{kind:'disconnected'}, chatSubscriptions:new Set(), chatDrafts:{}, chatScroll:{},
};
const repo = {
starChat:async(id,starred) => { calls.stars.push({id,starred}); return {starred}; },
chatHistory:async() => ({messages:[]}), chatShells:async() => [],
};
const rt = {state,repo,renderContent:() => paint(),focusDetailHeading:() => {},pushRoute:route => calls.routes.push(route)};
const view = createChatView(rt);
window.paint = () => document.querySelector('#fixture').replaceChildren(view.renderChatList());
window.reset = () => { state.chatMenu=null; state.chatActiveId='selected'; paint(); };
paint();
</script>`;
const server = createServer(async (req, res) => {
try {
const path = new URL(req.url, "http://fixture").pathname;
if (path === "/") { res.setHeader("Content-Type", "text/html"); res.end(html); return; }
const file = resolve(root, `.${path}`);
if (!file.startsWith(root + "/")) throw Error("outside fixture");
res.setHeader("Content-Type", extname(file) === ".css" ? "text/css" : "text/javascript");
res.end(await readFile(file));
} catch { res.writeHead(404); res.end(); }
});
await new Promise(r => server.listen(0, "127.0.0.1", r));
let browser, mouse;
const captures = [];
const measurements = [];
try {
browser = await launchChrome();
const page = await browser.openPage(`http://127.0.0.1:${server.address().port}/`);
await page.waitForSelector('.chat-row-actions');
// A direct page CDP connection supplies actual pointer movement without clicks.
const target = (await (await fetch(`http://127.0.0.1:${browser.port}/json/list`)).json()).find(t => t.id === page.targetId);
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 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();
};
mouse.addEventListener('message', listener);
mouse.send(JSON.stringify({id,method:'Input.dispatchMouseEvent',params:{type:'mouseMoved',x,y}}));
});
const capture = async name => {
const file = `${name}.png`;
await page.screenshot(resolve(out, file));
captures.push(file);
};
const geometry = () => page.evaluate(`(() => {
const overlaps = (a,b) => a.left < b.right && b.left < a.right && a.top < b.bottom && b.top < a.bottom;
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=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,
visible:style.visibility==='visible' && style.display!=='none',
hit:document.elementFromPoint(r.x+r.width/2,r.y+r.height/2)===button,
overlap:content.some(node => overlaps(r,node.getBoundingClientRect())),
nested:!!button.parentElement.closest('button')};
})};
});
})()`);
for (const width of [390, 420, 1100]) {
await page.resize(width, 844);
await page.evaluate('reset()');
await move(1, 1);
const before = await geometry();
measurements.push({width, rows:before});
assert.equal(before.length, 4);
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');
assert.equal(button.transition, '0s');
assert.equal(button.visible, true);
assert.equal(button.hit, true, `${row.id}: control centre hit-test`);
assert.equal(button.overlap, false, `${row.id}: no text/logo overlay`);
assert.equal(button.nested, false);
}
assert.equal(await page.evaluate('document.documentElement.scrollWidth > innerWidth'), false);
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}`);
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');
const more = before[0].controls[1];
await move(more.x + 22, more.y + 22);
assert.deepEqual(await geometry(), before, 'hovering Chat actions reveals no new controls');
assert.equal(await page.evaluate("document.querySelectorAll('.chat-menu-panel').length"), 0, 'hover never opens a menu');
await capture(`rows-hover-${width}`);
// Natural keyboard order: thread, star, menu. Focus must not open the menu.
await page.evaluate("document.querySelector('[data-session=selected] .chat-session-button').focus()");
await page.pressKey('Tab');
assert.equal(await page.evaluate("document.activeElement.classList.contains('chat-star')"), true);
await page.pressKey('Tab');
assert.equal(await page.evaluate("document.activeElement.classList.contains('chat-menu-button')"), true);
assert.equal(await page.evaluate("document.querySelectorAll('.chat-menu-panel').length"), 0);
await capture(`rows-keyboard-${width}`);
await page.pressKey('Enter');
assert.equal(await page.evaluate("document.activeElement.classList.contains('chat-menu-item')"), true);
assert.deepEqual(await page.evaluate("Array.from(document.querySelectorAll('.chat-menu-item'),n=>n.textContent)"), ['Rename…', 'Close chat…', 'Hide on this device']);
assert.equal(await page.evaluate('state.chatActiveId'), 'selected');
assert.deepEqual(await page.evaluate('calls.routes'), []);
await capture(`rows-menu-${width}`);
await page.evaluate('reset()');
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});
assert.equal(await page.evaluate('calls.stars.length'), stars + 1);
assert.equal(await page.evaluate('state.chatActiveId'), 'selected');
assert.deepEqual(await page.evaluate('calls.routes'), []);
await page.click('[data-session=streaming] .chat-star');
// Force the closed trigger against the actual list scroller bottom. Unlike
// click(selector), Enter does not silently scroll it to the viewport centre.
await page.resize(width, 500);
await page.evaluate(`(() => {
const rows=document.querySelector('#chatRows'), row=document.querySelector('[data-session=closed]');
rows.scrollTop += row.getBoundingClientRect().bottom - rows.getBoundingClientRect().bottom;
row.querySelector('.chat-menu-button').focus({preventScroll:true});
})()`);
assert.equal(await page.evaluate(`(() => {
const rows=document.querySelector('#chatRows'), row=document.querySelector('[data-session=closed]');
return Math.abs(row.getBoundingClientRect().bottom-rows.getBoundingClientRect().bottom)<2 && rows.scrollTop>0;
})()`), true, 'fixture must exercise a real scroller bottom edge');
await page.pressKey('Enter');
const items = await page.evaluate(`Array.from(document.querySelectorAll('.chat-menu-item'), node => {
const r=node.getBoundingClientRect();
return {text:node.textContent,inside:r.top>=0 && r.bottom<=innerHeight,
hit:node===document.elementFromPoint(r.x+r.width/2,r.y+r.height/2)};
})`);
assert.ok(items.some(item => item.text === 'Reopen'));
assert.ok(items.every(item => item.inside && item.hit), JSON.stringify(items));
await capture(`rows-bottom-menu-${width}`);
await page.evaluate('paint()');
assert.equal(await page.evaluate(`Array.from(document.querySelectorAll('.chat-menu-item')).every(node => {
const r=node.getBoundingClientRect();
return r.top>=0 && r.bottom<=innerHeight && document.elementFromPoint(r.x+r.width/2,r.y+r.height/2)===node;
})`), true, 'open menu re-anchors on a later render');
await page.click('.chat-menu-rename');
assert.equal(await page.evaluate('state.chatRename.id'), 'closed');
assert.equal(await page.evaluate('state.chatActiveId'), 'selected');
assert.deepEqual(await page.evaluate('calls.routes'), []);
await page.resize(width, 844);
await page.evaluate('reset()');
}
await page.emulateTouch();
await page.resize(390, 844);
assert.ok((await geometry()).every(row => row.controls.every(button => button.width >= 48 && button.height >= 48)));
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}`);
} finally {
mouse?.close();
await browser?.close();
await new Promise(r => server.close(r));
}