diff --git a/webviews/src/agent-session/acpmux/App.tsx b/webviews/src/agent-session/acpmux/App.tsx index efd759284d81..2b313ba4b916 100644 --- a/webviews/src/agent-session/acpmux/App.tsx +++ b/webviews/src/agent-session/acpmux/App.tsx @@ -582,6 +582,7 @@ import { configureLiveLineBelow, useLiveLineBelow } from "./liveLineBelow"; import { configureToolRunLook } from "./toolRunLook"; import { configureSentLook } from "./conversation/SentMessageLine"; import { configureInboxNoticeLook } from "./conversation/inboxNoticeLook"; +import { configureMessageLineLook } from "./conversation/messageLineLook"; import { configureNoticeLook } from "./conversation/noticeLook"; import { InboxNoticeCard } from "./conversation/InboxNoticeCard"; import { mergeInboxNotices, type InboxMessage } from "./conversation/inboxNotice"; @@ -10587,6 +10588,7 @@ function AcpmuxPane() { configureToolRunLook(theme.toolRunLook); configureSentLook(theme.sentLook); configureInboxNoticeLook(theme.inboxNoticeLook); + configureMessageLineLook(theme.messageLineLook); configureNoticeLook(theme.noticeLook); configureTurnActionsPlacement(theme.turnActionsPlacement); configureSubagentTray(theme.subagentTray); diff --git a/webviews/src/agent-session/acpmux/composer.gallery.ts b/webviews/src/agent-session/acpmux/composer.gallery.ts index 1408cc89d052..231946b7fcd8 100644 --- a/webviews/src/agent-session/acpmux/composer.gallery.ts +++ b/webviews/src/agent-session/acpmux/composer.gallery.ts @@ -1692,8 +1692,8 @@ export default agentPaneEntry({ ], }), play: async (ctx) => { - // It waits in the one collapsed group of waiting messages (PendingMessagesCard.tsx). - await ctx.click({ selector: ".cv-pending__toggle" }); + // It waits as its own line; with others it waits in their one collapsed group (PendingMessagesCard.tsx). + if (ctx.document.querySelector(".cv-pending__toggle")) await ctx.click({ selector: ".cv-pending__toggle" }); await ctx.waitFor(() => ctx.document.querySelector('[data-queued-message="q1"] .cv-disclosure__toggle')); await ctx.click({ selector: '[data-queued-message="q1"] .cv-disclosure__toggle' }); await ctx.waitFor(() => diff --git a/webviews/src/agent-session/acpmux/conversation/AgentMessageRow.css b/webviews/src/agent-session/acpmux/conversation/AgentMessageRow.css index 250b80d969b2..69ba98d56f98 100644 --- a/webviews/src/agent-session/acpmux/conversation/AgentMessageRow.css +++ b/webviews/src/agent-session/acpmux/conversation/AgentMessageRow.css @@ -135,6 +135,18 @@ button.cv-agentmsg__name:focus-visible { > .cv-agentmsg__chevron { color: var(--cv-text); } +/* Shut and stacked, the toggle holds no words: it takes back the line's gap before it, so the chevron + sits right after the recipient's chip, as after any row's words (transcript-chevron-after-label). */ +.acpmux-row .cv-agentmsg:not([data-open]) .cv-agentmsg__toggle:has(> .cv-agentmsg__preview:empty) { + margin-inline-start: calc(-1 * var(--grid-gap) - 0.5 * var(--ds-space-1)); +} +/* Stacked or opened, the toggle holds no words and has no box of its own: the line, which the + pointer already toggles, shows its focus. */ +.cv-agentmsg__line:has(.cv-agentmsg__toggle:focus-visible > .cv-agentmsg__preview:empty) { + outline: 1.5px solid color-mix(in srgb, var(--agent-accent) 55%, transparent); + outline-offset: -1.5px; + border-radius: 6px; +} .cv-agentmsg__toggle:focus-visible { /* Inset: the transcript row clips paint (`contain: paint`). */ outline: 1.5px solid color-mix(in srgb, var(--agent-accent) 55%, transparent); @@ -216,3 +228,31 @@ button.cv-agentmsg__name:focus-visible { .cv-agentmsg__line:is(:hover, :active, :focus-within):not(:has(.cv-agent-tag.is-open:is(:hover, :focus))) { color: var(--cv-text); } + +/* A stacked message row's first line (messageLineLook.ts, the default): on its own line under the + row's verb, recipient and count, at the text column, dim, cut there with one ellipsis (Leo said + yes, 2026-11-02, to splitting "Sent to · and 5 more commands " so the chip and + count read on the first line and the preview below). The row's one tone, never lit on hover. + model.ts adds its --cv-message-preview-line (MESSAGE_PREVIEW_LINE_PT) under the 22px row. */ +.cv-msgline__preview { + box-sizing: border-box; + height: var(--cv-message-preview-line); + min-width: 0; + padding-inline-start: var(--cv-tool-text-inset); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + color: var(--cv-text-dim); + font-size: var(--text-detail); + line-height: var(--cv-message-preview-line); + letter-spacing: var(--text-detail--letter-spacing); + cursor: default; + user-select: none; +} +/* In a column that spaces its parts by the tool group's inner gap (`.cv-agentmsg`, `.cv-disclosure`), + the first line still sits right under its row, as a send's does: the row and its first line are + one entry (model.ts `messagePreviewLine`, 18px under the row). */ +.cv-agentmsg > .cv-msgline__preview, +.cv-disclosure > .cv-msgline__preview { + margin-top: calc(-1 * var(--grid-gap-inner)); +} diff --git a/webviews/src/agent-session/acpmux/conversation/AgentMessageRow.tsx b/webviews/src/agent-session/acpmux/conversation/AgentMessageRow.tsx index b95824c1065c..b21a1ae93924 100644 --- a/webviews/src/agent-session/acpmux/conversation/AgentMessageRow.tsx +++ b/webviews/src/agent-session/acpmux/conversation/AgentMessageRow.tsx @@ -12,6 +12,7 @@ import { ChevronRight } from "./icons"; import { clipMessagePreview } from "./clipMessagePreview"; import { HEADER_TOGGLE_ATTRIBUTE, headerToggleClick } from "./headerToggle"; import { AgentTag } from "./AgentTag"; +import { useMessageLineLook } from "./messageLineLook"; import "./AgentMessageRow.css"; /// The message's first line of text as it reads, its spaces collapsed and its Markdown marks (a @@ -81,6 +82,10 @@ export function AgentMessageRow({ }) { const bodyId = useId(); const [before = "", after = ""] = sentence.split("\u0000"); + // Stacked (the default, messageLineLook.ts): the first line under the row, on its own line. + const look = useMessageLineLook(); + const inline = look === "single" && !open ? preview : ""; + const below = look === "stacked" && !open ? preview : ""; return (
{/* Open, the message is under the line: its first line here would say it twice. */} - {open ? "" : preview} + {inline} {/* The hover row stays in the sentence column: the trailing column holds only status. */} {actions} @@ -139,6 +144,13 @@ export function AgentMessageRow({
+ {below && ( + // Its words are the toggle's label too, so a screen reader reads them there. + // oxlint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions +
+ {below} +
+ )} {open && (
{body} diff --git a/webviews/src/agent-session/acpmux/conversation/HoverFade.gallery.ts b/webviews/src/agent-session/acpmux/conversation/HoverFade.gallery.ts index 26f152445093..c677269e0df0 100644 --- a/webviews/src/agent-session/acpmux/conversation/HoverFade.gallery.ts +++ b/webviews/src/agent-session/acpmux/conversation/HoverFade.gallery.ts @@ -81,9 +81,10 @@ const received = () => { isWorking: true }, ); const RECEIVED_LINE = ".cv-received > .cv-disclosure__line"; -/// Opens the group of waiting messages, which shows collapsed (PendingMessagesCard.tsx). +/// Opens the group of waiting messages, which shows collapsed (PendingMessagesCard.tsx); one waiting +/// message is its own line, with no group to open. const openWaiting: Play = async (ctx) => { - await ctx.click({ selector: ".cv-pending__toggle" }); + if (ctx.document.querySelector(".cv-pending__toggle")) await ctx.click({ selector: ".cv-pending__toggle" }); await ctx.waitFor(() => ctx.document.querySelector(RECEIVED_LINE)); }; diff --git a/webviews/src/agent-session/acpmux/conversation/InboxNoticeCard.tsx b/webviews/src/agent-session/acpmux/conversation/InboxNoticeCard.tsx index bd5c59ddca24..91361d08e81b 100644 --- a/webviews/src/agent-session/acpmux/conversation/InboxNoticeCard.tsx +++ b/webviews/src/agent-session/acpmux/conversation/InboxNoticeCard.tsx @@ -16,6 +16,7 @@ import { useContext, useEffect, useId, useLayoutEffect, useMemo, useState, type ReactNode } from "react"; import { useT } from "../i18n"; import { DisclosureRow } from "../subagents/DisclosureRow"; +import { useMessageLineLook } from "./messageLineLook"; import { PromptMarksSession } from "../threadMinimap/promptMarks"; import { mentionedRepository } from "../../../githubReferences"; import { CardCopy } from "./CardCopy"; @@ -115,6 +116,9 @@ function InboxThreadLine({ }, [holds, reveal]); // Several messages each say who sent them; one alone is under its sender's line already. const heads = (messages?.length ?? 0) > 1; + // Stacked (the default, messageLineLook.ts): the preview on its own line under the sender. + const lineLook = useMessageLineLook(); + const preview = thread.preview || t("message.noText"); return ( {thread.label && {thread.label}} - - {thread.preview || t("message.noText")} - + {lineLook === "single" && ( + + {preview} + + )} {thread.count > 1 && {t("tools.more", { n: thread.count - 1 })}} } + below={lineLook === "stacked" && !open ? preview : undefined} >
diff --git a/webviews/src/agent-session/acpmux/conversation/IncomingMessageCard.gallery.ts b/webviews/src/agent-session/acpmux/conversation/IncomingMessageCard.gallery.ts index c2801b1ebf83..98acf7f62540 100644 --- a/webviews/src/agent-session/acpmux/conversation/IncomingMessageCard.gallery.ts +++ b/webviews/src/agent-session/acpmux/conversation/IncomingMessageCard.gallery.ts @@ -141,9 +141,11 @@ const minimalChat = chat([ assistant("Merged cmux/grid-fix into this branch.", 4.5), summary(4.5, { status: "completed" }), ]); +const PREVIEW = ".cv-received__preview, .cv-received > .cv-disclosure__below"; const linesDrawn: Play = async (ctx) => { await openReceivedRow(ctx); - await ctx.waitFor(() => ctx.document.querySelectorAll(".cv-received__preview").length >= minimalTexts.length); + // A line's first line: on the line (`single`) or under it (stacked, messageLineLook.ts). + await ctx.waitFor(() => ctx.document.querySelectorAll(PREVIEW).length >= minimalTexts.length); }; const ALT_ID = "incoming-minimal-alt"; /// Draws a gallery-only line over the shipped one: its stylesheet, then `mark` on each line (its @@ -158,7 +160,7 @@ const alternate = style.textContent = css; ctx.document.head.append(style); ctx.document.querySelectorAll(".cv-received").forEach((line, index) => { - const preview = line.querySelector(".cv-received__preview"); + const preview = line.querySelector(PREVIEW); const name = line.querySelector(".cv-received__from")?.textContent ?? ""; if (preview) mark(preview, minimalTexts[index] ?? "", name); }); diff --git a/webviews/src/agent-session/acpmux/conversation/IncomingMessageCard.tsx b/webviews/src/agent-session/acpmux/conversation/IncomingMessageCard.tsx index 2a957e274ccf..43d7c576a6e0 100644 --- a/webviews/src/agent-session/acpmux/conversation/IncomingMessageCard.tsx +++ b/webviews/src/agent-session/acpmux/conversation/IncomingMessageCard.tsx @@ -56,6 +56,7 @@ import { MessageScopeContext, type MessageScope } from "../chips/messageScope"; import { mentionedRepository } from "../../../githubReferences"; import { useAnchoredCollapse } from "./useAnchoredCollapse"; import { laneNotice } from "./laneReport"; +import "./AgentMessageRow.css"; import "./LaneNoticeBatch.css"; import { messageOpened, setMessageOpened } from "./incomingOpened"; import { useTranscriptDisclosure } from "./transcriptDisclosure"; @@ -63,6 +64,7 @@ import { useTranscriptReadOnly } from "./readOnly"; import { Face } from "../multiplayer/Faces"; import { FileAttachment, type FileAttachmentInfo } from "../FileAttachment"; import { isGuest, type Participant } from "../multiplayer/participants"; +import { useMessageLineLook } from "./messageLineLook"; import type { AgentNotice } from "./agentNotice"; import { NoticeMark, SEVERITY_LABEL } from "./NoticeMark"; import { noticeMarkdown } from "./agentNotice"; @@ -312,6 +314,7 @@ export function IncomingMessageLine({ // estimator reads it. const [opened, setOpen] = useState(() => messageOpened(session, id)); const open = whole || opened; + const lineLook = useMessageLineLook(); const show = (next: boolean) => { setMessageOpened(session, id, next); setOpen(next); @@ -433,22 +436,26 @@ export function IncomingMessageLine({ lineClassName="cv-agent-activity-row" toggleLabel={t("message.collapsedLabel", { from, preview: preview || t("message.noText") })} label={ - // Find counts the panel's whole text, not the line's first-line copy of it. - // A notice's title is its text (the row's, which Find searches): Find highlights it here, - // inside the line Find otherwise skips (chatFind.ts `findSkipped`). - - {agentNotice && look === "tag" && agentNotice.severity !== "info" && ( - - {t(SEVERITY_LABEL[agentNotice.severity])} - - )} - {preview || t("message.noText")} - + // Find counts the panel's whole text, not the line's first-line copy of it. Stacked (the + // default, messageLineLook.ts) a message's first line is under the sender, on its own line. + // A notice's title is its text (the row's, which Find searches) and stays on the line: Find + // highlights it here, inside the line Find otherwise skips (chatFind.ts `findSkipped`). + lineLook === "single" || agentNotice ? ( + + {agentNotice && look === "tag" && agentNotice.severity !== "info" && ( + + {t(SEVERITY_LABEL[agentNotice.severity])} + + )} + {preview || t("message.noText")} + + ) : null } + below={lineLook === "stacked" && !open && !agentNotice ? preview || t("message.noText") : undefined} // It opens at once, its height alone moving, as the message's card always did; closing fades. fadeIn={false} // One slot at the line's end, over the preview's tail, shown on hover or focus: it never moves diff --git a/webviews/src/agent-session/acpmux/conversation/MessageGroupHead.css b/webviews/src/agent-session/acpmux/conversation/MessageGroupHead.css index 775b7a8dc021..95620001f957 100644 --- a/webviews/src/agent-session/acpmux/conversation/MessageGroupHead.css +++ b/webviews/src/agent-session/acpmux/conversation/MessageGroupHead.css @@ -93,3 +93,13 @@ display: none; } } +/* Stacked (messageLineLook.ts): the senders on their own line under the count, at the text column + (`.cv-msgline__preview`, AgentMessageRow.css), a whole line of the head's box even where the head + sits in a flex line (PendingMessagesCard.css `.cv-pending__line`). */ +.cv-message-group__below { + flex: 0 0 100%; + width: 100%; +} +.cv-pending__line:has(> .cv-message-group__below) { + flex-wrap: wrap; +} diff --git a/webviews/src/agent-session/acpmux/conversation/MessageGroupHead.tsx b/webviews/src/agent-session/acpmux/conversation/MessageGroupHead.tsx index b591fc58173e..4f6d617732db 100644 --- a/webviews/src/agent-session/acpmux/conversation/MessageGroupHead.tsx +++ b/webviews/src/agent-session/acpmux/conversation/MessageGroupHead.tsx @@ -13,6 +13,8 @@ import { ChevronRight } from "./icons"; import { SenderMark } from "./IncomingMessageCard"; import type { IncomingMessage } from "./incomingMessage"; import { useInboxNoticeLook } from "./inboxNoticeLook"; +import { useMessageLineLook } from "./messageLineLook"; +import "./AgentMessageRow.css"; import "./MessageGroupHead.css"; const ROW_ICON = rowIconSize(12); @@ -66,32 +68,46 @@ export function MessageGroupHead({ mark?: ReactNode; }) { const look = useInboxNoticeLook(); + // Stacked (the default, messageLineLook.ts): the senders on their own line under the count, cut + // there, as a message row's first line is; `quiet` keeps them in the tooltip only. + const lineLook = useMessageLineLook(); + const below = lineLook === "stacked" && look !== "group-count" && !open ? senders : undefined; + const inline = lineLook === "single" ? senders : undefined; return ( - + <> + + {below && ( + // The head's tooltip and label already name them; this line is for the eye and the pointer. + // oxlint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions +
+ {below} +
+ )} + ); } diff --git a/webviews/src/agent-session/acpmux/conversation/MessageLineLook.gallery.ts b/webviews/src/agent-session/acpmux/conversation/MessageLineLook.gallery.ts new file mode 100644 index 000000000000..71822c562818 --- /dev/null +++ b/webviews/src/agent-session/acpmux/conversation/MessageLineLook.gallery.ts @@ -0,0 +1,184 @@ +// l10n-allow-file: gallery fixtures (sample lanes, messages and commands), not shipped UI. +// Message rows between agents in a coordinator's running turn, drawn after Leo's 2026-11-02 +// captures of the coordinator chat. He said yes to splitting "Sent to build-box/spinner-lane +// · and 5 more commands coordinator: Leo's answer (v…", a count, a target and a message preview +// truncated on one line, and of the same rows: "i also think this is quite weird looking". The turn +// holds `acpmux send` calls that also ran other commands, a SendMessage, another machine's lane's +// message, the live "Sending message to …" line and seven messages from six sessions that wait. +// Each look (messageLineLook.ts, theme `messageLineLook`) draws the same chat: `stacked`, the +// default, puts the verb, recipient chip, count and chevron on the line and the message's first line +// (a group's senders) on its own line under it; `single` is the one line from before; `quiet` keeps +// the line alone until the row opens. `opened` shows an opened send: the message at the text +// column, Copy and Raw quiet under it, nothing beside the chevron. +import { agentPaneEntry } from "../../../gallery/format"; +import type { Play } from "../../../gallery/play"; +import { SESSION_ID, activity, chat, session, tool, user } from "../../../gallery/fixtures/acpmux"; +import type { AcpmuxActivity, AcpmuxSnapshot } from "../model"; + +const PEER = "studio-mac"; +const COORD = "coordinator"; + +const LONG = + "coordinator: idle ~65 min on Leo's browser-tab speed ask (optimistic open, no top new-tab animation in the main pane first). What's the PR and head? If it's waiting on something, name the fix you're putting in flight; otherwise continue. Stop when merged and the nightly opens a tab instantly in the right pane."; + +/// A coordinator's shell call: a check, then one `acpmux send`, then more commands, so the row reads +/// "Sent to · and N more commands". +const sendAndMore = (target: string, text: string, status = "completed"): AcpmuxActivity => { + const command = [ + "acpmux ls --json > /tmp/coord-ls.json", + `acpmux send --no-wait ${target} '${text.replace(/'/g, "'\\''")}'`, + "python3 /tmp/summarize.py", + "git -C ~/Projects/leo-workspace fetch -q", + "tools/now show | head -40", + "pr-owner orphans", + "date", + ].join("; "); + return tool(command.slice(0, 120), "execute", status, { + command, + description: `Nudge ${target.split("/").at(-1)}`, + ...(status === "completed" ? { output: "queued\n", exitCode: 0 } : {}), + }); +}; +const plainSend = (target: string, text: string): AcpmuxActivity => { + const command = `acpmux send --no-wait ${target} '${text.replace(/'/g, "'\\''")}'`; + return tool(command.slice(0, 120), "execute", "completed", { + command, + description: `Tell ${target.split("/").at(-1)}`, + output: "queued\n", + exitCode: 0, + }); +}; +const run = (description: string, command: string): AcpmuxActivity => + tool(command, "execute", "completed", { description, command, output: "ok\n", exitCode: 0 }); +const sendingNow = (target: string, text: string): AcpmuxActivity => + tool(`acpmux send ${target} '${text}'`, "execute", "in_progress", { + command: `acpmux send ${target} '${text}'`, + description: `Ask ${target}`, + }); + +const fromPeer = (text: string, minutes: number) => + user(text, minutes, { + incoming: { + kind: "message", + message: { name: `${PEER}/fleet-mesh`, sessionId: "s-mesh", harness: "claude", text, raw: text }, + }, + untyped: true, + }); + +const WAITING = [ + ["course-lane", "s-w1", "Lesson 4 merged; the gallery has its captures."], + ["build-box/broker-socket", "s-w2", "SHIP at 4be1c09; landing."], + ["build-box/web-base-reds", "s-w3", "Rerun went green; base is clear."], + ["build-box/freestyle-pause-resume", "s-w4", "Paused VMs resume on the next open."], + ["build-box/newtab-flash", "s-w5", "PR #33190 at 7d1e2aa, review running."], + ["build-box/env-picker", "s-w6", "The picker reads machines first now."], + ["build-box/newtab-flash", "s-w5", "Review passed; merging."], +].map(([from, sessionId, text], index) => ({ + id: `waiting-${index}`, + prompt: text!, + message: { name: from!, sessionId: sessionId!, harness: "codex", text: text!, raw: text! }, +})); + +function coordinatorTurn(): AcpmuxSnapshot { + const snapshot = chat( + [ + user("Check on the routed lanes and nudge the idle ones.", 6, { id: "coord-prompt" }), + activity([run("Check states of my routed lanes", "acpmux ls --json --status running")], 5.8), + activity([sendAndMore("build-box/newtab-flash", LONG)], 5.6, { id: "coord-send-1" }), + activity( + [ + sendAndMore( + "build-box/freestyle-pause-resume", + "coordinator: idle ~40 min on the pause/resume ask. Name the PR and its head, or the fix you are putting in flight.", + ), + ], + 5.4, + ), + fromPeer( + 'The area→owner table is live. NOW.md has a "## Area owners" section (generated from the registry), and the asks reconciler reads it.', + 5.2, + ), + activity( + [run("Check rerun result; start router-review for HQ#6406", "gh run view 41578642105 --json conclusion")], + 5, + ), + activity( + [ + plainSend( + "build-box/web-base-reds", + "coordinator: rerun of 41578642105 --failed was accepted (job 3 of 4 green so far).", + ), + plainSend( + "build-box/env-picker", + "coordinator: nobody owns Cloud GitHub identity. Build both halves: the picker row and the token handoff.", + ), + ], + 4.8, + ), + activity([sendingNow("build-box/right-pane", "Is #33102 merged? Name the head.")], 4.6), + ], + { + title: COORD, + isWorking: true, + queue: WAITING, + sessions: [ + session({ sessionId: SESSION_ID, title: COORD, name: COORD }), + session({ sessionId: "s-newtab", name: "build-box/newtab-flash", title: "newtab-flash" }), + session({ + sessionId: "s-mesh", + name: `${PEER}/fleet-mesh`, + title: "fleet-mesh", + peer: PEER, + host: PEER, + hostKind: undefined, + }), + ], + }, + ); + // A Claude Code chat: its runs fold per run (turns.ts), as in Leo's capture. + return { ...snapshot, summary: { ...snapshot.summary!, family: "claude" } }; +} + +/// Opens the first send, to show the opened message with Copy and Raw under it. +const openFirstSend: Play = async (ctx) => { + await ctx.click({ selector: ".cv-sent" }); + await ctx.waitFor(() => ctx.document.querySelector(".cv-subsession__under .cv-subsession__actions")); +}; + +export default agentPaneEntry({ + id: "agent-pane.message-line-look", + title: "Message rows: line and first line", + area: "Agent pane", + height: 560, + covers: [ + "agent-session/acpmux/conversation/messageLineLook.ts", + "agent-session/acpmux/conversation/SentMessageLine.tsx", + "agent-session/acpmux/conversation/AgentMessageRow.tsx", + "agent-session/acpmux/conversation/IncomingMessageCard.tsx", + "agent-session/acpmux/conversation/MessageGroupHead.tsx", + "agent-session/acpmux/conversation/Thinking.tsx", + "agent-session/acpmux/subagents/DisclosureRow.tsx", + ], + keywords: ["message", "sent", "received", "preview", "two lines", "stacked", "and more commands", "sending"], + variants: { + stacked: { + note: "The default: each message row's verb, recipient chip, count and chevron on its line, the message's first line on its own line under it, cut there. The live send line has the envelope and no token counts; the waiting group's senders sit under its count.", + snapshot: coordinatorTurn(), + }, + opened: { + note: "The first send opened: its message at the row's text column, Copy and Raw quiet on one line under it at the same indent, nothing beside the chevron.", + snapshot: coordinatorTurn(), + play: openFirstSend, + }, + single: { + note: "Gallery version (theme messageLineLook single): the one line from before, the chip, count and first line cut together.", + theme: { messageLineLook: "single" }, + snapshot: coordinatorTurn(), + }, + quiet: { + note: "Gallery version (theme messageLineLook quiet): the line alone, the first line only once the row opens.", + theme: { messageLineLook: "quiet" }, + snapshot: coordinatorTurn(), + }, + }, +}); diff --git a/webviews/src/agent-session/acpmux/conversation/PendingMessagesCard.tsx b/webviews/src/agent-session/acpmux/conversation/PendingMessagesCard.tsx index 475e162a369a..9fb70ce0b42f 100644 --- a/webviews/src/agent-session/acpmux/conversation/PendingMessagesCard.tsx +++ b/webviews/src/agent-session/acpmux/conversation/PendingMessagesCard.tsx @@ -57,6 +57,25 @@ export function PendingMessagesCard({ }, [holdsMatch, reveal]); if (!rows?.length) return null; const n = displayRows?.length ?? rows.length; + // One message waiting is that message's own line, never a group of one: "1 message from 1 session" + // over a row naming the same session said it twice (the coordinator, relaying Leo's capture). + const only = n === 1 ? (displayRows ?? rows)[0] : undefined; + if (only && only.incoming?.kind === "message") + return ( +
+
+ + {renderMessage(only)} + +
+
+ ); const countSources = flat ? bySender(displayRows ?? []) : sources; const names = countSources.map((group) => { const first = group.rows[0]!; diff --git a/webviews/src/agent-session/acpmux/conversation/QueuedMessageCard.gallery.ts b/webviews/src/agent-session/acpmux/conversation/QueuedMessageCard.gallery.ts index 67c31efbbabb..da8c3f774f69 100644 --- a/webviews/src/agent-session/acpmux/conversation/QueuedMessageCard.gallery.ts +++ b/webviews/src/agent-session/acpmux/conversation/QueuedMessageCard.gallery.ts @@ -56,10 +56,10 @@ const outboxNote = { message: queuedMessage({ text: OUTBOX_TEXT, client: "acpmux-outbox#7", promptId: "a-outbox" })!, }; -/// Opens the group of waiting messages, which shows collapsed. +/// Opens the group of waiting messages, which shows collapsed; one waiting message is its own line. const openGroup: Play = async (ctx) => { - await ctx.waitFor(() => ctx.document.querySelector(".cv-pending__toggle")); - ctx.document.querySelector(".cv-pending__toggle")!.click(); + await ctx.waitFor(() => ctx.document.querySelector(".cv-pending__toggle, .cv-pending--one")); + ctx.document.querySelector(".cv-pending__toggle")?.click(); await ctx.waitFor(() => ctx.document.querySelector(".cv-received__from")); }; diff --git a/webviews/src/agent-session/acpmux/conversation/RowGrammar.test.tsx b/webviews/src/agent-session/acpmux/conversation/RowGrammar.test.tsx index c90b7aada2fa..795f6bdb4f14 100644 --- a/webviews/src/agent-session/acpmux/conversation/RowGrammar.test.tsx +++ b/webviews/src/agent-session/acpmux/conversation/RowGrammar.test.tsx @@ -219,16 +219,21 @@ test("a send reads Sent to , the recipient one chip, its status in th expect(rows["acpmux-send"]!.querySelector(".cv-recipient")!.textContent).toBe("fanout-infra"); }); -test("every message preview is cut by the one rule: one muted span that ellipsizes", async () => { - const { rows } = await fourRows(); +test("every message preview is cut by the one rule: one muted line under the row that ellipsizes", async () => { + const { container, rows } = await fourRows(); for (const kind of ["send-message", "acpmux-send"]) { - const previews = rows[kind]!.querySelectorAll(".cv-agentmsg__preview"); - expect({ kind, previews: previews.length }).toEqual({ kind, previews: 1 }); + // Stacked (the default look), the first line sits on its own line under the row, never inline. + const scope = container.querySelector(`[data-kind="${kind}"]`)!; + const previews = [...scope.querySelectorAll(".cv-msgline__preview")].filter((node) => node.textContent); + const inline = [...rows[kind]!.querySelectorAll(".cv-agentmsg__preview")].filter((node) => node.textContent); + expect({ kind, previews: previews.length, inline: inline.length }).toEqual({ kind, previews: 1, inline: 0 }); } const css = readFileSync(new URL("./AgentMessageRow.css", import.meta.url), "utf8"); - const rule = /\.cv-agentmsg__preview \{([^}]*)\}/.exec(css)?.[1] ?? ""; - expect(rule).toContain("text-overflow: ellipsis"); - expect(rule).toContain("white-space: nowrap"); + for (const name of ["cv-agentmsg__preview", "cv-msgline__preview"]) { + const rule = new RegExp(`\\.${name} \\{([^}]*)\\}`).exec(css)?.[1] ?? ""; + expect(rule).toContain("text-overflow: ellipsis"); + expect(rule).toContain("white-space: nowrap"); + } }); test("the subagent line's duration is in the trailing column, not the sentence", async () => { diff --git a/webviews/src/agent-session/acpmux/conversation/SentMessageLine.test.tsx b/webviews/src/agent-session/acpmux/conversation/SentMessageLine.test.tsx index c905b553ddab..70cc7003dc9e 100644 --- a/webviews/src/agent-session/acpmux/conversation/SentMessageLine.test.tsx +++ b/webviews/src/agent-session/acpmux/conversation/SentMessageLine.test.tsx @@ -9,6 +9,7 @@ import type { AcpmuxActivity } from "../model"; import { acpmuxSendCall } from "./acpmuxSends"; import { toolGroups } from "./toolGroups"; import { AcpmuxSendLine, configureSentLook } from "./SentMessageLine"; +import { configureMessageLineLook } from "./messageLineLook"; import { resetTranscriptDisclosure } from "./transcriptDisclosure"; import { SubsessionContext, SubsessionStore } from "../subagents/subsessions"; import type { AcpmuxSessionEntry } from "../sessionList"; @@ -100,7 +101,9 @@ test("a sent message reads its target, how it was taken and its first line, and }), ); const row = container.querySelector(".cv-sent")!; - expect(row.textContent).toBe("Sent to coord-deputy Merged #4182 queued"); + // Stacked (the default): the line holds who and how; the first line is on its own line under it. + expect(row.textContent).toBe("Sent to coord-deputy queued"); + expect(container.querySelector(".cv-sent__below")?.textContent).toBe("Merged #4182"); expect(row.dataset.sendState).toBe("sent"); expect(row.classList.contains("is-live")).toBe(false); expect(row.getAttribute("aria-expanded")).toBe("false"); @@ -109,7 +112,7 @@ test("a sent message reads its target, how it was taken and its first line, and expect(container.querySelector(".cv-subsession__under h2")?.textContent).toBe("Merged #4182"); // Open, the message shows once: under the row, not again as the row's first line. expect(row.textContent).toBe("Sent to coord-deputy queued"); - expect(row.querySelector(".cv-sent__preview")).toBeNull(); + expect(container.querySelector(".cv-sent__below")).toBeNull(); // The command stays one more click away, behind Raw. expect(container.querySelector(".cv-shell")).toBeNull(); await act(async () => container.querySelector(".cv-subsession__toggle")!.click()); @@ -133,9 +136,9 @@ test("closing the row brings its first line back", async () => { const container = await line(bash("acpmux send --no-wait coord-deputy 'Restore base.'", { output: "queued" })); const row = container.querySelector(".cv-sent")!; await act(async () => row.click()); - expect(row.textContent).toBe("Sent to coord-deputy queued"); + expect(container.querySelector(".cv-sent__below")).toBeNull(); await act(async () => row.click()); - expect(row.textContent).toBe("Sent to coord-deputy Restore base. queued"); + expect(container.querySelector(".cv-sent__below")?.textContent).toBe("Restore base."); }); test("the quote look drops its quoted line while the row is open", async () => { @@ -154,14 +157,15 @@ test("the quote look drops its quoted line while the row is open", async () => { test("in flight it is live, with the spinner", async () => { const running = await line(bash("acpmux send lane 'status?'", { status: "in_progress" })); const row = running.querySelector(".cv-sent")!; - expect(row.textContent).toBe("Sending to lane status?"); + expect(row.textContent).toBe("Sending to lane"); + expect(running.querySelector(".cv-sent__below")?.textContent).toBe("status?"); expect(row.classList.contains("is-live")).toBe(true); expect(row.querySelector(".cv-tool__icon svg")).not.toBeNull(); }); test("a send whose text comes from a file names its target and the file", async () => { const unknown = await line(bash(`acpmux send reports:leo "$(cat /tmp/summary.md)"`, { output: "" })); - expect(unknown.querySelector(".cv-sent")!.textContent).toBe("Sent to reports:leo /tmp/summary.md"); + expect(unknown.querySelector(".cv-sent")!.textContent).toBe("Sent to reports:leo"); expect(unknown.querySelector(".cv-sent__file")?.textContent).toBe("/tmp/summary.md"); }); @@ -196,7 +200,8 @@ test("a compound command's send says the other work, which stays behind Raw", as }), ); const row = container.querySelector(".cv-sent")!; - expect(row.textContent).toBe("Sent to coord-deputy · and 2 more commands Restore base. queued"); + expect(row.textContent).toBe("Sent to coord-deputy · and 2 more commands queued"); + expect(container.querySelector(".cv-sent__below")?.textContent).toBe("Restore base."); await act(async () => row.click()); await act(async () => container.querySelector(".cv-subsession__toggle")!.click()); expect(container.querySelector(".cv-shell")?.textContent).toContain("git fetch -q"); @@ -250,7 +255,8 @@ test("a send the call does not say went reads only who it was for", async () => ); const row = container.querySelector(".cv-sent")!; expect(row.dataset.sendState).toBe("ended"); - expect(row.textContent).toBe("Message to lane · and 2 more commands Pushed."); + expect(row.textContent).toBe("Message to lane · and 2 more commands"); + expect(container.querySelector(".cv-sent__below")?.textContent).toBe("Pushed."); }); test("a batch's message names its recipient and the file its words came from; opening one shows the whole shell body at once", async () => { @@ -267,11 +273,11 @@ test("a batch's message names its recipient and the file its words came from; op , ); const rows = [...container.querySelectorAll(".cv-sent")]; - expect(rows.map((row) => row.textContent)).toEqual([ - "Sent to nightly escalate.md queued", - "Sent to owner relay.md queued", + expect(rows.map((row) => row.textContent)).toEqual(["Sent to nightly queued", "Sent to owner queued"]); + expect([...container.querySelectorAll(".cv-sent__below .cv-sent__file")].map((file) => file.textContent)).toEqual([ + "escalate.md", + "relay.md", ]); - expect(rows[0]!.querySelector(".cv-sent__file")?.textContent).toBe("escalate.md"); // Each message opens on its own. await act(async () => rows[1]!.click()); expect(rows[0]!.getAttribute("aria-expanded")).toBe("false"); @@ -301,7 +307,8 @@ test("a send of a file the agent wrote with Write opens to that message rendered const send = groups.flatMap((group) => (group.type === "send" ? [group.send] : []))[0]!; const container = await render(); const row = container.querySelector(".cv-sent")!; - expect(row.textContent).toContain("Composer"); + // Shut, the message's first line is its own line under the row (messageLineLook.ts, stacked). + expect(container.querySelector(".cv-sent__below")?.textContent).toContain("Composer"); await act(async () => row.click()); expect(container.querySelector(".cv-subsession__markdown h2")?.textContent).toBe("Composer"); expect(container.querySelector(".cv-subsession__markdown strong")?.textContent).toBe("ship"); @@ -309,3 +316,36 @@ test("a send of a file the agent wrote with Write opens to that message rendered expect(container.querySelector(".cv-shell")).toBeNull(); expect(container.querySelector(".cv-subsession__toggle")).not.toBeNull(); }); + +test("the chip and count stay on the line and the first line goes under it; opened, Copy and Raw sit under the message", async () => { + // Leo said yes (2026-11-02) to splitting "Sent to gcp-codex-swarm-10/spinner-chatgpt · and 5 more + // commands claude-sr2-coord: Leo's answer (v…" into the target and count, then the preview below. + const container = await line( + bash("cd ~/wt && git fetch -q && acpmux send --no-wait coord-deputy 'Restore base, then report.'; date", { + output: "queued", + }), + ); + const row = container.querySelector(".cv-sent")!; + expect(row.querySelector(".cv-sent__preview")).toBeNull(); + // No Copy beside the chevron. + expect(row.querySelector(".cv-sent-actions")).toBeNull(); + const below = container.querySelector(".cv-sent__below")!; + expect(below.previousElementSibling).toBe(row); + // The first line toggles the row as the line does. + await act(async () => below.click()); + expect(row.getAttribute("aria-expanded")).toBe("true"); + const actions = container.querySelector(".cv-subsession__under .cv-subsession__actions")!; + expect(actions.querySelector(".cv-sent-actions")).not.toBeNull(); + expect(actions.querySelector(".cv-subsession__toggle")?.textContent).toContain("Raw"); +}); + +test("the single look keeps the one line from before", async () => { + configureMessageLineLook("single"); + try { + const container = await line(bash("acpmux send --no-wait coord-deputy 'Restore base.'", { output: "queued" })); + expect(container.querySelector(".cv-sent")!.textContent).toBe("Sent to coord-deputy Restore base. queued"); + expect(container.querySelector(".cv-sent__below")).toBeNull(); + } finally { + await act(async () => configureMessageLineLook("stacked")); + } +}); diff --git a/webviews/src/agent-session/acpmux/conversation/SentMessageLine.tsx b/webviews/src/agent-session/acpmux/conversation/SentMessageLine.tsx index 3a1ccc1b6c85..8b8420fcbd2d 100644 --- a/webviews/src/agent-session/acpmux/conversation/SentMessageLine.tsx +++ b/webviews/src/agent-session/acpmux/conversation/SentMessageLine.tsx @@ -36,6 +36,7 @@ import { McpCallDetails } from "./McpCallRows"; import { mcpCall, mcpRawName } from "./mcpCalls"; import { ShellBlock } from "./ShellBlock"; import { useTranscriptDisclosure } from "./transcriptDisclosure"; +import { useMessageLineLook } from "./messageLineLook"; import { SubsessionContext, SubsessionStore } from "../subagents/subsessions"; import "./AgentMessageRow.css"; import "./SubsessionCallCard.css"; @@ -137,6 +138,11 @@ export function SentMessageLine({ }) { const t = useT(); const shape = useSyncExternalStore(subscribe, snapshot, snapshot); + // Stacked (the default, messageLineLook.ts): the line holds the verb, the recipient, the count and + // the chevron; the first line goes under it, on a line of its own. `quiet` draws no first line + // until the row opens. The arrow and quote shapes keep their one line. + const lineLook = useMessageLineLook(); + const stacked = shape === "sentence" && lineLook !== "single"; const [open, setOpen] = useTranscriptDisclosure(disclosureKey); const [rawShown, setRawShown] = useState(rawOpen); // A send that fails while it shows opens its Raw then: the output says why. @@ -160,9 +166,13 @@ export function SentMessageLine({ const chat = useSyncExternalStore(store.subscribeNames, readChat, readChat); const preview = text ? messagePreview(text) : ""; // The open row shows the whole message under it: its first line on the row would say it twice. - const trailing = preview && state !== "failed" && !(open && text) ? preview : ""; + const shown = preview && state !== "failed" && !(open && text) ? preview : ""; // No words to show, only where they came from: the file's path, as code, after the line. - const source = !text && file && state !== "failed" ? file : ""; + const fileShown = !text && file && state !== "failed" ? file : ""; + // Stacked, they take the line under the row instead (`below`); `quiet` shows neither while shut. + const trailing = stacked ? "" : shown; + const source = stacked ? "" : fileShown; + const below = stacked && lineLook === "stacked" && !open ? shown || fileShown : ""; const label = shape === "arrow" && (state === "sending" || state === "sent") && preview ? t(state === "sending" ? "subsession.sending" : "subsession.to", { name: MARK, text: preview }) @@ -232,8 +242,9 @@ export function SentMessageLine({ )} {/* Copy takes the message's text, shown while the row is pointed at, as a SendMessage - row's is (MessageCard.tsx); its click never toggles the row. */} - {text && ( + row's is (MessageCard.tsx); its click never toggles the row. Stacked, it sits with Raw + under the opened message instead, never beside the chevron. */} + {text && !stacked && ( // oxlint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events event.stopPropagation()}> @@ -253,6 +264,14 @@ export function SentMessageLine({ className={`cv-tool__chevron cv-rotor${open ? " is-open" : " is-hover"}`} />
+ {below && ( + // The first line, on its own line at the text column, cut there; it toggles as the row does. + // Its words are the opened message's, so a screen reader and Find read them there. + // oxlint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions +
+ {text ? below : {below}} +
+ )} {open && (
{text ? ( @@ -260,7 +279,11 @@ export function SentMessageLine({
- + : undefined} + > {raw(reveal)} @@ -279,12 +302,15 @@ export function SentMessageLine({ export function RawToggle({ children, icon, + actions, startOpen = false, open: shown, onOpenChange, }: { children: ReactNode; icon?: ReactNode; + /// Quiet actions on the opened message (its Copy), on Raw's line before it. + actions?: ReactNode; startOpen?: boolean; open?: boolean; onOpenChange?: (open: boolean) => void; @@ -294,19 +320,29 @@ export function RawToggle({ const open = shown ?? own; const setOpen = (next: (value: boolean) => boolean) => (onOpenChange ? onOpenChange(next(open)) : setOwn(next)); const id = useId(); + const button = ( + + ); return (
- + {actions ? ( +
+ {actions} + {button} +
+ ) : ( + button + )} {open &&
{children}
}
); diff --git a/webviews/src/agent-session/acpmux/conversation/SubsessionCallCard.css b/webviews/src/agent-session/acpmux/conversation/SubsessionCallCard.css index a7b4548118c5..cf5c0246b23a 100644 --- a/webviews/src/agent-session/acpmux/conversation/SubsessionCallCard.css +++ b/webviews/src/agent-session/acpmux/conversation/SubsessionCallCard.css @@ -73,3 +73,23 @@ font-family: var(--cv-code-font, var(--cv-mono)); font-size: 0.92em; } + +/* Inside an opened message (`.cv-subsession__under`, already at the text column) Raw starts where + the message does, never a second indent in (Leo, 2026-11-02: "Raw ⌄" "on its own oddly indented + line"). */ +.cv-subsession__under > .cv-subsession__raw { + padding-inline-start: 0; +} +/* The opened message's quiet actions (SentMessageLine.tsx, stacked): Copy, then Raw, on one line + under the message at its indent, shown while it is open. */ +.cv-subsession__actions { + display: flex; + align-items: center; + gap: var(--grid-gap); + min-height: var(--cv-footer-control-slot, 24px); +} +.cv-subsession__actions > .cv-sent-actions { + height: auto; + margin-inline-start: calc(-1 * (var(--cv-footer-control-slot, 24px) - 16px) / 2); + opacity: 1; +} diff --git a/webviews/src/agent-session/acpmux/conversation/Thinking.tsx b/webviews/src/agent-session/acpmux/conversation/Thinking.tsx index 8a19b9a442e3..1a911eab172b 100644 --- a/webviews/src/agent-session/acpmux/conversation/Thinking.tsx +++ b/webviews/src/agent-session/acpmux/conversation/Thinking.tsx @@ -177,9 +177,14 @@ export function Thinking({ // (App.tsx counts nothing while the tray lists it). const counts = useContext(WorkingCountsContext); const tokens = counts?.tokens; - const showTokens = Boolean(tokens) && timed; + // A send's line names who it goes to and for how long; the turn's token counts there are noise + // (Leo, 2026-11-02, on "Sending message to … 3m 56s · ↓1.4K out ↑819.5K in" among the message + // rows: "i also think this is quite weird looking"). + const sending = doing !== undefined && sendName !== undefined; + const showTokens = Boolean(tokens) && timed && !sending; // One count, as Claude Code's live line says it ("47.4K tokens"): the turn's output, with the - // split on hover (liveLineTokens.experiment.ts). + // split on hover (liveLineTokens.experiment.ts). Never "↓ out ↑ in" in the line's words (the + // coordinator, relaying Leo's capture of "Thinking 7m 34s · ↓ 4.5K out ↑ 1.4M in"). const oneCount = experimentArm(liveLineTokens) === "total"; // The label already names the subagents it waits on: no second count of them. const parts = (counts && !waiting ? workingParts(t, counts) : []).filter( diff --git a/webviews/src/agent-session/acpmux/conversation/activityTone.test.ts b/webviews/src/agent-session/acpmux/conversation/activityTone.test.ts index 90fdcaa54cf1..a34038793ded 100644 --- a/webviews/src/agent-session/acpmux/conversation/activityTone.test.ts +++ b/webviews/src/agent-session/acpmux/conversation/activityTone.test.ts @@ -8,8 +8,9 @@ const gallery = readFileSync(join(import.meta.dir, "transcript.gallery.ts"), "ut test("background activity has one secondary tone and lifts on hover or focus; a step row only on focus; a received message never", () => { expect(css).toContain("--cv-activity-text: color-mix(in srgb, var(--cv-fg) 58%, transparent);"); // The lift skips a row whose session link chip has the focus: the chip lights alone (AgentTag.css). - // A tool run's or group's summary line (`is-run`) is left out: it lights on hover only. - expect(css).toContain(".cv-tool:not(.is-run):focus-within:not(:has(.cv-agent-tag.is-open:focus)),"); + // A tool run's or group's summary line (`is-run`) is left out: it lights on hover only. A sent + // message's row keeps one steady tone, as a received one's does. + expect(css).toContain(".cv-tool:not(.is-run, .cv-sent):focus-within:not(:has(.cv-agent-tag.is-open:focus)),"); expect(css).not.toContain(".cv-tool:focus-within"); expect(css).toMatch(/\.cv-tool\.is-run:hover > \.cv-tool__text \{\s*color: var\(--cv-text\);/); // A step row draws nothing more on hover (agent-pane-step-rows.test.ts). diff --git a/webviews/src/agent-session/acpmux/conversation/conversation.css b/webviews/src/agent-session/acpmux/conversation/conversation.css index 937a92bfd300..de69f8dd94ec 100644 --- a/webviews/src/agent-session/acpmux/conversation/conversation.css +++ b/webviews/src/agent-session/acpmux/conversation/conversation.css @@ -95,6 +95,7 @@ sense for these to be spaced differently", #29965). */ --cv-message-line: var(--cv-tool-row-height); --cv-message-subhead: 22px; /* a sender's head inside that group */ + --cv-message-preview-line: 18px; /* a message row's first line, under it (messageLineLook.ts) */ --cv-live-gap: 10px; /* over the running turn's live line, inside its row */ --cv-disclosure-line-height: var(--cv-tool-row-height); /* A status row between two replies (model.ts `isStatusRow`) sits in the middle of the gap (Leo, @@ -2389,13 +2390,16 @@ pre.cv-math-source { "no longer change on hover"; agent-pane-step-rows.test.ts), so only focus lifts it. */ /* A session link chip in the row (AgentTag.css) lights alone: its focus is not the row's. A tool run's or group's summary line lights on hover only (below), so its focus is left out. */ -.cv-tool:not(.is-run):focus-within:not(:has(.cv-agent-tag.is-open:focus)), +/* A message row keeps one steady tone (design/chat-transcript.md, as a received message's line): + a sent row the reader clicked never reads brighter than the ones around it (Leo, 2026-11-02, on + rows "in bright and dim text with no clear rule": "i also think this is quite weird looking"). */ +.cv-tool:not(.is-run, .cv-sent):focus-within:not(:has(.cv-agent-tag.is-open:focus)), .cv-worked:hover, .cv-worked:focus-visible { color: var(--cv-text); } -.cv-tool:not(.is-run):focus-within:not(:has(.cv-agent-tag.is-open:focus)) .cv-tool__chevron, -.cv-tool:not(.is-run):focus-within:not(:has(.cv-agent-tag.is-open:focus)) .cv-tool__detail { +.cv-tool:not(.is-run, .cv-sent):focus-within:not(:has(.cv-agent-tag.is-open:focus)) .cv-tool__chevron, +.cv-tool:not(.is-run, .cv-sent):focus-within:not(:has(.cv-agent-tag.is-open:focus)) .cv-tool__detail { color: var(--cv-text); } /* The running rows' mark (`Spinner`: compaction, tool groups, MCP calls, command and shell rows). @@ -5990,6 +5994,11 @@ article.acpmux-row--before-indicator .cv-user:is(:not(:has(.cv-user__pending)), background: color-mix(in srgb, var(--agent-text) 9%, transparent); } .cv-repo-recovery button:hover { background: color-mix(in srgb, var(--agent-text) 15%, transparent); } +/* Stacked (messageLineLook.ts): the received line holds the sender alone, so its name may take the + line's width instead of sharing it with the first line, which is under it. */ +.cv-received > .cv-disclosure__line:not(:has(.cv-received__preview)) > .cv-received__sender { + max-width: calc(100% - var(--cv-chevron-glyph, 12px) - var(--ds-space-4, 16px)); +} /* The selection's Reply chip (SelectionReply.tsx): a small pill over the selection's end, as Claude's and ChatGPT's. It shows on the selection's end with no fade-in and goes when the selection does. `icon` draws the glyph alone. */ diff --git a/webviews/src/agent-session/acpmux/conversation/laneNoticeBatches.ts b/webviews/src/agent-session/acpmux/conversation/laneNoticeBatches.ts index 17d2f6178fed..2a217beeee51 100644 --- a/webviews/src/agent-session/acpmux/conversation/laneNoticeBatches.ts +++ b/webviews/src/agent-session/acpmux/conversation/laneNoticeBatches.ts @@ -331,7 +331,9 @@ function projectAllInboxRows(rows: readonly AcpmuxRow[], foldNotices: boolean): const push = (row: AcpmuxRow) => { if (row.laneNoticeBatch?.kind === "inbox") { const children = project(row.laneNoticeBatch.rows, true); - if (insideInbox) out.push(...children); + // A batch of one message is that message's own line: a head over a lone row names its + // sender twice. + if (insideInbox || children.length === 1) out.push(...children); else if (children.length) out.push(projectedBatch(row, children)); return; } diff --git a/webviews/src/agent-session/acpmux/conversation/messageLineLook.ts b/webviews/src/agent-session/acpmux/conversation/messageLineLook.ts new file mode 100644 index 000000000000..81059c3665e7 --- /dev/null +++ b/webviews/src/agent-session/acpmux/conversation/messageLineLook.ts @@ -0,0 +1,41 @@ +import { useSyncExternalStore } from "react"; + +/// How a message row between agents lays out its parts: a sent message ("Sent to "), another +/// agent's received line ( · host) and the head of a folded group of messages ("7 messages +/// from 6 sessions"). Leo said yes (2026-11-02) to splitting "Sent to gcp-codex-swarm-10/spinner-chatgpt +/// · and 5 more commands claude-sr2-coord: Leo's answer (v…", a count, a target and a message preview +/// truncated on one line, and of the same rows "i also think this is quite weird looking". +/// `stacked`, the default: the line holds the verb, the chip, the count and the chevron; the message's +/// first line (a group's senders) sits on its own line under it, at the text column, cut there. +/// The others are gallery versions kept beside it (MessageLineLook.gallery.ts): `single`, the one +/// line from before (cmux#29800's rows); `quiet`, the line alone, with no preview until the row +/// opens. The native host sends no value, so the default holds there. +export type MessageLineLook = "stacked" | "single" | "quiet"; + +const LOOKS: readonly MessageLineLook[] = ["stacked", "single", "quiet"]; +let current: MessageLineLook = "stacked"; +const listeners = new Set<() => void>(); + +/// The theme carried a look: the transcript follows at once. Anything else keeps the default. +export function configureMessageLineLook(value: unknown): void { + const next = LOOKS.find((look) => look === value) ?? "stacked"; + if (next === current) return; + current = next; + for (const listener of listeners) listener(); +} + +const subscribe = (listener: () => void) => { + listeners.add(listener); + return () => void listeners.delete(listener); +}; +const snapshot = () => current; + +/// The look now. +export const useMessageLineLook = (): MessageLineLook => useSyncExternalStore(subscribe, snapshot, snapshot); + +/// The look now, outside React (the row estimator, model.ts). +export const messageLineLook = (): MessageLineLook => current; + +/// The preview line's height under a stacked message row, in points: `--cv-message-preview-line` +/// (AgentMessageRow.css), the detail size's line. model.ts adds it to a stacked row with a preview. +export const MESSAGE_PREVIEW_LINE_PT = 18; diff --git a/webviews/src/agent-session/acpmux/conversation/transcript.gallery.ts b/webviews/src/agent-session/acpmux/conversation/transcript.gallery.ts index 820a28288a16..6b276f2849f0 100644 --- a/webviews/src/agent-session/acpmux/conversation/transcript.gallery.ts +++ b/webviews/src/agent-session/acpmux/conversation/transcript.gallery.ts @@ -826,8 +826,12 @@ const liveLineClear = async (ctx: PlayContext) => { const doc = ctx.document; await ctx.waitFor(() => doc.querySelector(".cv-worked.is-below .cv-thinking")); const words = doc.querySelector(".cv-worked.is-below .cv-thinking")!.getBoundingClientRect(); - const over = [...doc.querySelectorAll(".cv-tool, .cv-md")] - .map((node) => ({ step: node.matches(".cv-tool"), bottom: node.getBoundingClientRect().bottom })) + // A stacked message row's first line under it (messageLineLook.ts) is the row's last line. + const over = [...doc.querySelectorAll(".cv-tool, .cv-msgline__preview, .cv-md")] + .map((node) => ({ + step: node.matches(".cv-tool, .cv-msgline__preview"), + bottom: node.getBoundingClientRect().bottom, + })) .filter(({ bottom }) => bottom <= words.top + 1); if (!over.length) throw new Error("no tool row or reply draws over the live line"); const nearest = over.reduce((a, b) => (b.bottom > a.bottom ? b : a)); diff --git a/webviews/src/agent-session/acpmux/model.ts b/webviews/src/agent-session/acpmux/model.ts index 42c042ecb29b..ffd473db93be 100644 --- a/webviews/src/agent-session/acpmux/model.ts +++ b/webviews/src/agent-session/acpmux/model.ts @@ -1268,6 +1268,12 @@ const TOOL_RUN_BOTTOM = 0; /// grid the run adds no frame of its own (the stack's gap is the spacing), so the frame is 0. const LINE_FRAME = TOOL_RUN_TOP + TOOL_RUN_BOTTOM; const lineRow = () => LINE_FRAME + toolRowHeight(); +/// A message row (a send, SentMessageLine.tsx and AgentMessageRow.tsx; another agent's received line; +/// a folded group's head): one tool row, and in the stacked look (conversation/messageLineLook.ts, +/// the default) its first line's own line under it while it is shut and has one. +const messagePreviewLine = (shown: boolean) => + shown && messageLineLook() === "stacked" ? MESSAGE_PREVIEW_LINE_PT * chromeScale : 0; +const messageRowHeight = (preview: boolean) => toolRowHeight() + messagePreviewLine(preview); /// Ordinary tool rows use the compact rhythm. Notes and specialized MCP cards keep a conservative /// estimate until their renderer reports its measured height (a wait can contain several three-line replies). @@ -1293,7 +1299,8 @@ function activityStepHeight(item: AcpmuxActivity, width: number): number { if (!tool) return item.kind === "note" ? noteHeight(item.text, width) : 26; // A message to another agent (SendMessage, `acpmux send`, a sub-session's `send_message`) is one // line on the tool rows' line (AgentMessageRow.tsx), as every one-line row is. - if (agentMessage(tool)) return toolRowHeight(); + const message = agentMessage(tool); + if (message) return messageRowHeight(Boolean(message.text.trim())); const mcp = mcpCall(tool); if (mcp) { const subsession = subsessionCall(tool, mcp); @@ -1315,7 +1322,7 @@ function activityStepHeight(item: AcpmuxActivity, width: number): number { return cardHeight("working") + replyHeight(subsession.prompt) + toolRowHeight(); // A message sent to a sub-session is the sent-message row a shell `acpmux send` draws // (SubsessionCallCard.tsx SentLine, SentMessageLine.tsx): one tool row. - if (subsession.tool === "send") return toolRowHeight(); + if (subsession.tool === "send") return messageRowHeight(Boolean(subsession.text.trim())); return 40; } switch (tool.kind) { @@ -1355,7 +1362,9 @@ function foldedRunSteps(row: AcpmuxRow, groups: readonly ToolGroup[], width: num /// An entry a folded run keeps on its own line: a group starts closed there (ToolGroupRow.tsx /// `folded`), one line, as a sent message's row is (SentMessageLine.tsx); anything else is its calls. function foldedGroupHeight(group: ToolGroup, width: number): number { - if (group.type === "group" || group.type === "send") return toolRowHeight(); + if (group.type === "send") + return messageRowHeight(group.send.state !== "failed" && Boolean(group.send.text?.trim() || group.send.file)); + if (group.type === "group") return toolRowHeight(); // `.cv-tool-group` lists its calls flush too. const items = "items" in group ? group.items : [group.item]; return items.reduce((sum, item) => sum + activityStepHeight(item, width), 0); @@ -2072,8 +2081,15 @@ function measuredRowHeight( // one-line row; opened, each sender's 22px head, then each of its messages as its own row draws // it, 24px in, less the frame the row gives a row, which the group has once. if (row.kind === LANE_NOTICE_BATCH && row.laneNoticeBatch) { + // Shut, a waiting inbox batch's head draws its senders under its count (stacked look); a + // delivered one names them only in its hover (LaneNoticeBatch.tsx `received`). + if (!messageOpened(sessionId, row.id)) { + const waiting = row.laneNoticeBatch.rows.some( + (member) => member.kind === "queuedMessage" || member.steer === "waiting", + ); + return finish(lineRow() + messagePreviewLine(row.laneNoticeBatch.kind === "inbox" && waiting)); + } const head = finish(lineRow()); - if (!messageOpened(sessionId, row.id)) return head; // An inbox batch's messages sit on its own columns, with no indent (LaneNoticeBatch.css). const inner = row.laneNoticeBatch.kind === "inbox" ? width : width - 24; return ( @@ -2086,8 +2102,13 @@ function measuredRowHeight( ); } if (row.kind === PENDING_MESSAGES && row.pendingMessages) { + // One message waiting draws as its own line, with no group head (PendingMessagesCard.tsx). + const shown = row.pendingMessages.displayRows ?? row.pendingMessages.rows; + if (shown.length === 1 && shown[0]!.incoming?.kind === "message") + return measuredRowHeight(shown[0]!, width, cache, beforeFooter, lastTurn, sessionId); + // Shut, its head draws the senders under the count (stacked look). + if (!messageOpened(sessionId, row.id)) return finish(lineRow() + messagePreviewLine(true)); const head = finish(lineRow()); - if (!messageOpened(sessionId, row.id)) return head; const senders = new Set(); let height = head; for (const member of row.pendingMessages.displayRows ?? row.pendingMessages.rows) { @@ -2115,7 +2136,9 @@ function measuredRowHeight( // from the icon column and 10px padding across): the whole text // (conversation/IncomingMessageCard.tsx), its images' 128px, and Details' 24px line. const line = lineRow(); - if (!messageOpened(sessionId, row.id)) return finish(line); + // Shut, its first line sits under the sender (stacked look); a tool's notice keeps its title + // on the line (IncomingMessageCard.tsx). + if (!messageOpened(sessionId, row.id)) return finish(line + messagePreviewLine(!row.incoming.message.notice)); const { lineHeight } = metrics(); const text = row.incoming.message.text; if (receivedPrepared.size > 256) receivedPrepared.clear(); @@ -2133,13 +2156,18 @@ function measuredRowHeight( // The group's head is a tool row (MessageGroupHead.tsx) on the one-line rows' line. const head = toolRowHeight(); const grouped = threads.length > 1 && foldsThreads(inboxNoticeLook()); - if (grouped && !messageOpened(sessionId, row.id)) return finish(head + LINE_FRAME); + if (grouped && !messageOpened(sessionId, row.id)) + return finish(head + LINE_FRAME + messagePreviewLine(inboxNoticeLook() !== "group-count")); const { lineHeight } = metrics(); if (receivedPrepared.size > 256) receivedPrepared.clear(); let height = (grouped ? head : 0) + (threads.length > 1 && inboxNoticeLook() === "card" ? 6 : 0); for (const thread of threads) { height += line; - if (!messageOpened(sessionId, inboxThreadKey(row.id, thread.threadId))) continue; + // Shut, its preview sits under the sender (stacked look). + if (!messageOpened(sessionId, inboxThreadKey(row.id, thread.threadId))) { + height += messagePreviewLine(true); + continue; + } const text = thread.messages?.map((m) => m.text).join("\n\n") ?? thread.preview; const inset = grouped ? 24 : 0; height += 2 + 4 + 16 + (text ? textHeight(text, Math.max(80, width - 44 - inset), receivedPrepared) : lineHeight); @@ -2649,6 +2677,7 @@ import { currentChatMetrics } from "./chatDisplay"; import { messageOpened } from "./conversation/incomingOpened"; import { inboxThreadKey } from "./conversation/inboxNotice"; import { foldsThreads, inboxNoticeLook } from "./conversation/inboxNoticeLook"; +import { MESSAGE_PREVIEW_LINE_PT, messageLineLook } from "./conversation/messageLineLook"; import { isDiagram, isUnlabeledLang } from "./conversation/codeShape"; /// The pane's fallback accessible name and problem-only header status. A handshake that is diff --git a/webviews/src/agent-session/acpmux/rowEstimates.test.ts b/webviews/src/agent-session/acpmux/rowEstimates.test.ts index 5d9937815b43..f6825d098fde 100644 --- a/webviews/src/agent-session/acpmux/rowEstimates.test.ts +++ b/webviews/src/agent-session/acpmux/rowEstimates.test.ts @@ -26,6 +26,7 @@ import { COLLAPSED_PROMPT_LINES, PASTE_CHIP_HEIGHT, PROMPT_MORE_HEIGHT } from ". import { currentChatMetrics } from "./chatDisplay"; import { gridLength, TRANSCRIPT_FOOTER_CONTROL } from "./transcriptGrid"; import { BUBBLE } from "./transcriptSpacing"; +import { MESSAGE_PREVIEW_LINE_PT } from "./conversation/messageLineLook"; const reply = (id: string, text: string) => ({ id, version: 1, at: 0, kind: "assistant", text }); // A footer carries its answer's text, for Copy (conversation/turns.ts), so the estimate never reads it. @@ -278,7 +279,9 @@ test("a hidden row after the chat's last footer leaves it the last one", () => { // Every one-line row takes a one-call tool run's frame: 2px over the 22px tool line, the 4px run gap // under it (model.ts LINE_ROW, conversation.css `.acpmux-row--line`). -test("another agent's message is one 22px tool line in the one-line rows' frame, however long", () => { +// Shut, a message row also draws its first line on its own 18px line under it (messageLineLook.ts, +// stacked, the default): 22 + 18, however long the message. +test("another agent's message is one 22px tool line and its preview line, however long", () => { const row = (id: string, text: string) => ({ id, version: 1, @@ -288,11 +291,11 @@ test("another agent's message is one 22px tool line in the one-line rows' frame, incoming: { kind: "message", message: { name: "cmux16/glass-lens", text, raw: text } }, }); const [short, long] = heightsOf([row("m1", "Draft is up."), row("m2", "Line of the report.\n".repeat(40))]); - expect(short).toBe(22); + expect(short).toBe(22 + MESSAGE_PREVIEW_LINE_PT); expect(long).toBe(short); }); -test("a message this agent sent another one is one 22px tool line in the one-line rows' frame", () => { +test("a message this agent sent another one is one 22px tool line and its preview line", () => { const send = { kind: "tool", text: "SendMessage", @@ -305,7 +308,7 @@ test("a message this agent sent another one is one 22px tool line in the one-lin }, }; const [height] = heightsOf([{ id: "s", version: 1, at: 0, kind: "activity", items: [send] }]); - expect(height).toBe(22); + expect(height).toBe(22 + MESSAGE_PREVIEW_LINE_PT); }); test("a task notice is a tool row's line in the one-line rows' frame", () => { @@ -492,22 +495,29 @@ test("a folded run with messages to other agents is estimated as the lines it dr // A run adds no margin of its own (grid.md 5.5): its lines are flush 22px lines, one apart top to top // (design/chat-transcript.md "One-line row pitch", #29965). const lines = (n: number) => n * 22; + // Each message row also draws its first line under it, on its own 18px line (messageLineLook.ts, + // `stacked`, the default; design/chat-transcript.md "Message rows"). + const preview = MESSAGE_PREVIEW_LINE_PT; // Plain work still folds to its one summary line. expect(heightsOf(run([shell("a", "git status"), read]))[0]).toBe(lines(1)); // A send between two commands: a line each. - expect(heightsOf(run([shell("a", "git status"), send("b", "lane-b"), shell("c", "cat x")]))[0]).toBe(lines(3)); + expect(heightsOf(run([shell("a", "git status"), send("b", "lane-b"), shell("c", "cat x")]))[0]).toBe( + lines(3) + preview, + ); // Two sends, as two calls or as one shell batch. - expect(heightsOf(run([send("a", "lane-a"), send("b", "lane-b")]))[0]).toBe(lines(2)); + expect(heightsOf(run([send("a", "lane-a"), send("b", "lane-b")]))[0]).toBe(lines(2) + 2 * preview); expect(heightsOf(run([shell("a", "acpmux send --no-wait lane-a 'a'; acpmux send --no-wait lane-b 'b'")]))[0]).toBe( - lines(2), + lines(2) + 2 * preview, ); // Work folded on each side of the sends: "Ran 2 commands", the send, the fold of the rest, the // sub-session message. const mixed = [shell("a", "ls"), shell("b", "cat y"), send("s", "lane-a"), shell("d", "git diff"), read, sendMessage]; - expect(heightsOf(run(mixed))[0]).toBe(lines(4)); + expect(heightsOf(run(mixed))[0]).toBe(lines(4) + 2 * preview); // A sub-session message alone is one tool row, folded or not. - expect(heightsOf(run([sendMessage]))[0]).toBe(lines(1)); - expect(heightsOf([{ id: "one", version: 1, at: 0, kind: "activity", items: [sendMessage] }])[0]).toBe(lines(1)); + expect(heightsOf(run([sendMessage]))[0]).toBe(lines(1) + preview); + expect(heightsOf([{ id: "one", version: 1, at: 0, kind: "activity", items: [sendMessage] }])[0]).toBe( + lines(1) + preview, + ); }); test("a turn's end keeps a reply's room: a folded reply to the person keeps it, a folded note does not", () => { diff --git a/webviews/src/agent-session/acpmux/subagents/DisclosureRow.css b/webviews/src/agent-session/acpmux/subagents/DisclosureRow.css index afd89599ff57..232b68ee09da 100644 --- a/webviews/src/agent-session/acpmux/subagents/DisclosureRow.css +++ b/webviews/src/agent-session/acpmux/subagents/DisclosureRow.css @@ -39,7 +39,7 @@ /* A line that starts with its toggle: the hover plate keeps its inset, the icon stays in the shared column. */ .cv-disclosure__line > :is(.cv-disclosure__toggle, .cv-disclosure__open):first-child:not(.is-chevron) { - margin-inline-start: calc(-1 * var(--ds-space-1)); + margin-inline-start: calc(-0.5 * var(--ds-space-1)); } /* A line that opens a chat (`.cv-disclosure__open`) ends at its status; its chevron is the panel's own toggle right after it. */ @@ -72,6 +72,15 @@ justify-content: center; color: var(--cv-text-muted); } +/* A stacked message's line has no label (its first line is under it): no empty slot, so its + chevron sits right after the sender, as after any label's words. */ +.cv-disclosure__label:empty { + display: none; +} +.cv-disclosure__toggle:not(:has(> .cv-disclosure__label:not(:empty), > .cv-disclosure__icon)) { + padding-inline-start: 0; + margin-inline-start: calc(-1 * var(--ds-space-1)); +} .cv-disclosure__label { min-width: 0; overflow: hidden; diff --git a/webviews/src/agent-session/acpmux/subagents/DisclosureRow.tsx b/webviews/src/agent-session/acpmux/subagents/DisclosureRow.tsx index ab4024b842d2..227b2a0d9c25 100644 --- a/webviews/src/agent-session/acpmux/subagents/DisclosureRow.tsx +++ b/webviews/src/agent-session/acpmux/subagents/DisclosureRow.tsx @@ -52,6 +52,9 @@ export type DisclosureRowProps = { actions?: ReactNode; /// Before the toggle, outside its button. leading?: ReactNode; + /// A second line under the row (a received message's first line, stacked: messageLineLook.ts), + /// at the text column; a click on it toggles the row as the line does. + below?: ReactNode; /// Shared activity-row treatment for transcript notices. lineClassName?: string; /// The row's own class, next to `cv-disclosure`. @@ -77,6 +80,7 @@ export function DisclosureRow({ toggleLabel, actions, leading, + below, lineClassName, className, }: DisclosureRowProps) { @@ -149,6 +153,18 @@ export function DisclosureRow({ )} {actions} + {below !== undefined && below !== null && below !== "" && ( + // The toggle's label reads these words for a screen reader; this is the pointer's target. + // oxlint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions +
+ {below} +
+ )} {collapse.present && (
{children}
diff --git a/webviews/test/agent-pane-suggested-tasks.test.ts b/webviews/test/agent-pane-suggested-tasks.test.ts index c20ef10c9ee8..05ddba7baa11 100644 --- a/webviews/test/agent-pane-suggested-tasks.test.ts +++ b/webviews/test/agent-pane-suggested-tasks.test.ts @@ -578,7 +578,7 @@ await requireBrowserLane("agent-pane-suggested-tasks.test.ts", async () => { // One line at the left with the sender's name and the message's first line, the sender's // words only; nothing under it until it opens. expect(await card.locator(".cv-received__from").innerText()).toBe("Grid fix"); - expect(await card.locator(".cv-received__preview").innerText()).toBe( + expect(await card.locator(".cv-disclosure__below").innerText()).toBe( "The grid fix is on cmux/grid-fix; tests pass.", ); expect(await card.locator(".cv-disclosure__panel").count()).toBe(0); @@ -617,7 +617,7 @@ await requireBrowserLane("agent-pane-suggested-tasks.test.ts", async () => { }); const card = incoming(page); await card.waitFor({ timeout: 10_000 }); - expect(await card.locator(".cv-received__preview").innerText()).toBe("Step 1 of the landing report."); + expect(await card.locator(".cv-disclosure__below").innerText()).toBe("Step 1 of the landing report."); expect(await card.locator(".cv-disclosure__line").evaluate((el) => el.getBoundingClientRect().height)).toBe(22); expect(await page.locator(".cv-received__body, .cv-received__show, [data-cut]").count()).toBe(0); const toggle = card.getByRole("button", { name: /Message from Grid fix/ }); @@ -1051,8 +1051,10 @@ await requireBrowserLane("agent-pane-suggested-tasks.test.ts", async () => { }), ], }); - // It waits for the running turn, in the one group of waiting messages (pendingMessages.ts). - await page.locator(".cv-pending__toggle").click(); + // It waits for the running turn as its own line: one waiting message has no group to open + // (PendingMessagesCard.tsx). + await page.locator(".cv-pending__toggle, .cv-pending--one").first().waitFor({ timeout: 10_000 }); + if (await page.locator(".cv-pending__toggle").count()) await page.locator(".cv-pending__toggle").click(); const card = incoming(page); await card.waitFor({ timeout: 10_000 }); // Closed, the line alone; its images are in the panel the line opens. diff --git a/webviews/test/agent-pane-transcript-chevron-column.test.ts b/webviews/test/agent-pane-transcript-chevron-column.test.ts index 015f575c02cc..014aa06e6540 100644 --- a/webviews/test/agent-pane-transcript-chevron-column.test.ts +++ b/webviews/test/agent-pane-transcript-chevron-column.test.ts @@ -94,8 +94,12 @@ await requireBrowserLane("agent-pane-transcript-chevron-column.test.ts", async ( } if (width === 760) { const toggle = page.locator(".cv-agentmsg__toggle"); - const size = await toggle.boundingBox(); - await toggle.click({ position: { x: size!.width - 2, y: size!.height / 2 } }); + // Stacked (messageLineLook.ts), the message's first line is under the row and is the + // pointer's target; the line's toggle holds no words then and has no box to click. + const below = page.locator(".cv-agentmsg__below"); + const target = (await below.count()) > 0 ? below.first() : toggle; + const size = await target.boundingBox(); + await target.click({ position: { x: size!.width - 2, y: size!.height / 2 } }); expect(await toggle.getAttribute("aria-expanded")).toBe("true"); await page.locator(".cv-agentmsg__chevron").click(); expect(await toggle.getAttribute("aria-expanded")).toBe("false"); diff --git a/webviews/test/agent-pane-turn-tokens-muted.test.tsx b/webviews/test/agent-pane-turn-tokens-muted.test.tsx index f2fa6674354d..3c80aaa23375 100644 --- a/webviews/test/agent-pane-turn-tokens-muted.test.tsx +++ b/webviews/test/agent-pane-turn-tokens-muted.test.tsx @@ -10,7 +10,7 @@ import { expect, test } from "bun:test"; import { readFileSync } from "node:fs"; import path from "node:path"; -import { tokenLines, tokenLineMarkup } from "./support/turnTokenLines"; +import { SPLIT, tokenLines, tokenLineMarkup } from "./support/turnTokenLines"; const conversationCss = readFileSync( path.resolve(import.meta.dir, "../src/agent-session/acpmux/conversation/conversation.css"), @@ -45,3 +45,14 @@ test("the count takes the theme's tertiary text token, in tabular numerals, neve expect(conversationCss).toContain("--cv-text-muted: var(--agent-muted);"); expect(conversationCss).toContain("--cv-text-dim: var(--agent-soft);"); }); + +// The coordinator, relaying Leo's capture of "Thinking 7m 34s · ↓ 4.5K out ↑ 1.4M in": the split +// counts on the live line are "debug noise in the main transcript". It says one count, as Claude +// Code's does, and keeps the split in that count's hover. +test("the live line at the bottom says one count, the split on hover", () => { + const line = Object.entries(tokenLines).find(([name]) => name.includes("Thinking.tsx"))![1]; + const html = tokenLineMarkup(line, SPLIT); + expect(html).toContain(' { const composer = rect(".acpmux-composer-box"); // A received message's line leads with its sender (IncomingMessageCard.tsx `leading`). const headerIcon = rect('[data-row-id="grid-header"] .cv-disclosure__line > :first-child'); + // Stacked (messageLineLook.ts), the received message's first line sits on its own line + // right under its line: the run gap is from there. + const firstLine = document.querySelector('[data-row-id="grid-header"] .cv-msgline__preview'); + const headerEnd = firstLine ? firstLine.getBoundingClientRect().bottom : header.bottom; const toolIcon = rect(".acpmux-activity .cv-tool__icon"); const chevron = rect(".acpmux-activity .cv-tool__chevron"); // A reply's own action row, when it draws one: a turn's copy now lives in its footer @@ -120,7 +124,7 @@ await requireBrowserLane("transcript-rhythm.test.ts", async () => { toolIcon, chevron, copy, - gaps: [message.top - header.bottom, group.top - message.bottom], + gaps: [message.top - headerEnd, group.top - message.bottom], // The live line is one more line of the tool run over it: flush (#29965). liveUnderRun: live.top - group.bottom, inner: paragraphs[1]!.top - paragraphs[0]!.bottom, diff --git a/webviews/test/incoming-message-disclosure-browser.test.ts b/webviews/test/incoming-message-disclosure-browser.test.ts index bcce670406ea..1530a9ee8c9f 100644 --- a/webviews/test/incoming-message-disclosure-browser.test.ts +++ b/webviews/test/incoming-message-disclosure-browser.test.ts @@ -236,11 +236,12 @@ await requireBrowserLane("incoming-message-disclosure-browser.test.ts", async () const row = page.locator(".cv-received"); await row.waitFor({ timeout: 10_000 }); expect(await row.count()).toBe(1); - // Closed: one line on the tool rows' 22px line, the sender and the first line, nothing under it. - expect(await row.evaluate((el) => Math.round(el.getBoundingClientRect().height))).toBe(22); + // Closed: the sender on the tool rows' 22px line, the first line on its own 18px line under it + // (messageLineLook.ts `stacked`), nothing else. + expect(await row.evaluate((el) => Math.round(el.getBoundingClientRect().height))).toBe(40); expect(await row.locator(".cv-disclosure__line").evaluate((el) => el.getBoundingClientRect().height)).toBe(22); expect(await row.locator(".cv-received__from").innerText()).toBe("Grid fix"); - expect(await row.locator(".cv-received__preview").innerText()).toBe( + expect(await row.locator(".cv-disclosure__below").innerText()).toBe( "Paragraph 1 of the landing report: every check on the grid lane passed on this run.", ); expect(await row.locator(".cv-disclosure__panel").count()).toBe(0); @@ -447,14 +448,19 @@ await requireBrowserLane("incoming-message-disclosure-browser.test.ts", async () [{ promptId: "q-2", prompt: "Docs are rebuilt for the 2.3 release notes." }], ); try { - await page.locator(".cv-pending__toggle").click(); + // One waiting message is its own line; more wait in one collapsed group (PendingMessagesCard.tsx). + await page.locator(".cv-pending__toggle, .cv-pending--one").first().waitFor({ timeout: 10_000 }); + if (await page.locator(".cv-pending__toggle").count()) await page.locator(".cv-pending__toggle").click(); const rows = page.locator(".cv-received"); await rows.nth(1).waitFor({ timeout: 10_000 }); const lines = await rows.evaluateAll((all) => all.map((row) => { const line = row.querySelector(":scope > .cv-disclosure__line")!; const chevron = line.querySelector(".cv-rotor")!.getBoundingClientRect(); - const words = line.querySelector(".cv-received__preview")!.getBoundingClientRect(); + // Stacked, the line's last words are the sender's; its first line is under it. + const words = line + .querySelector(".cv-received__preview, .cv-received__from")! + .getBoundingClientRect(); const hover = line.querySelector(".cv-received__hover"); return { right: Math.round(chevron.right), diff --git a/webviews/test/incoming-minimal-collapse.test.tsx b/webviews/test/incoming-minimal-collapse.test.tsx index 182ce8c8127c..f198ef8e0063 100644 --- a/webviews/test/incoming-minimal-collapse.test.tsx +++ b/webviews/test/incoming-minimal-collapse.test.tsx @@ -95,7 +95,7 @@ for (const minimal of [false, true]) const { open, opened, toggle } = await line(`line-${minimal}`); // The name and the first line of text, as it reads, and nothing under the line. expect(host.querySelector(".cv-received__from")?.textContent).toBe("grid-lane"); - expect(host.querySelector(".cv-received__preview")?.textContent).toBe("Rebased onto main; ready for review."); + expect(host.querySelector(".cv-disclosure__below")?.textContent).toBe("Rebased onto main; ready for review."); expect(host.textContent).not.toContain("Received message from"); expect(host.querySelector(".cv-received__text")).toBeNull(); expect(host.querySelector(".cv-disclosure__panel")).toBeNull(); @@ -122,7 +122,7 @@ for (const minimal of [false, true]) await act(async () => toggle().click()); expect(toggle().getAttribute("aria-expanded")).toBe("false"); expect(host.querySelector(".cv-received__text")).toBeNull(); - expect(host.querySelector(".cv-received__preview")?.textContent).toBe("Rebased onto main; ready for review."); + expect(host.querySelector(".cv-disclosure__below")?.textContent).toBe("Rebased onto main; ready for review."); }); test("switching Minimal Mode leaves a closed message its one line", async () => { @@ -131,7 +131,7 @@ test("switching Minimal Mode leaves a closed message its one line", async () => expect(host.querySelector(".cv-received__text")).toBeNull(); await act(async () => setChatDisplay({})); expect(host.querySelector(".cv-received__text")).toBeNull(); - expect(host.querySelector(".cv-received__preview")?.textContent).toBe("Rebased onto main; ready for review."); + expect(host.querySelector(".cv-disclosure__below")?.textContent).toBe("Rebased onto main; ready for review."); }); test("the reader's toggle plays the fold: the panel's height grows on open and closing fades out", async () => { diff --git a/webviews/test/lane-notice-card.test.tsx b/webviews/test/lane-notice-card.test.tsx index 85f5e8c67f87..d785d9361bbe 100644 --- a/webviews/test/lane-notice-card.test.tsx +++ b/webviews/test/lane-notice-card.test.tsx @@ -154,9 +154,9 @@ test("five ended reports collapse to one count and preserve all five independent test("a single report shows its verdict; its full P2 remains readable and metadata is under Details", async () => { const { opened } = await mount([report("single-block", "BLOCK")]); expect(host.querySelector(".cv-lane-batch")).toBeNull(); - expect(host.querySelector(".cv-received__preview")?.textContent).toContain("BLOCK"); - expect(host.querySelector(".cv-received__preview")?.textContent).not.toContain("lane report: turn"); - expect(host.querySelector(".cv-received__preview")?.textContent).not.toContain("\n"); + expect(host.querySelector(".cv-disclosure__below")?.textContent).toContain("BLOCK"); + expect(host.querySelector(".cv-disclosure__below")?.textContent).not.toContain("lane report: turn"); + expect(host.querySelector(".cv-disclosure__below")?.textContent).not.toContain("\n"); expect(host.querySelector(".cv-received__text")).toBeNull(); await click(".cv-received__from--open"); expect(opened).toEqual(["session-single-block"]); diff --git a/webviews/test/message-preview-browser.test.ts b/webviews/test/message-preview-browser.test.ts index 6876f84a08af..8c03305c462c 100644 --- a/webviews/test/message-preview-browser.test.ts +++ b/webviews/test/message-preview-browser.test.ts @@ -88,10 +88,10 @@ await requireBrowserLane("message-preview-browser.test.ts", async () => { }, width === 360 ? 1.25 : 1, ); - // Closed: the line alone, its first line cut with an ellipsis on one line, nothing under it. + // Closed: the line and, under it, its first line cut with an ellipsis on one line (stacked). expect(await page.locator(".cv-received__text, .cv-received__show, [data-cut]").count()).toBe(0); const preview = await page - .locator(".cv-received__preview") + .locator(".cv-disclosure__below") .first() .evaluate((box) => { const style = getComputedStyle(box); @@ -101,7 +101,8 @@ await requireBrowserLane("message-preview-browser.test.ts", async () => { // One line: no taller than the 26px line it sits on. oneLine: box.getBoundingClientRect().height <= - box.closest(".cv-disclosure__line")!.getBoundingClientRect().height + 0.5, + box.closest(".cv-disclosure")!.querySelector(".cv-disclosure__line")!.getBoundingClientRect().height + + 0.5, }; }); expect(preview).toEqual({ overflow: "ellipsis", wrap: "nowrap", oneLine: true }); @@ -127,7 +128,8 @@ await requireBrowserLane("message-preview-browser.test.ts", async () => { }); test("sent preview has no fade or partial chip and Show more reveals all of it", async () => { await open(); - await page.locator(".cv-message .cv-agentmsg__toggle").click(); + // Stacked, the toggle holds no words: the line, which toggles whole, takes the click. + await page.locator(".cv-message .cv-agentmsg__line").first().click(); await page.locator(".cv-message__text").waitFor(); expect((await intact(".cv-message__text")).mask).toBe("none"); await page.locator(".cv-message__more").waitFor(); @@ -135,9 +137,10 @@ await requireBrowserLane("message-preview-browser.test.ts", async () => { await page.locator(".cv-message__more").click(); expect(await page.locator(".cv-message__text").evaluate((box) => box.clientHeight >= box.scrollHeight)).toBe(true); // Open, the toggle button holds no preview and has no width since #32867 put the chevron right - // after the words; the whole line still toggles, so close it from its chevron. + // after the words, and stacked it holds none shut either; the whole line still toggles, so close + // and open it from its chevron. + await page.locator(".cv-message .cv-agentmsg__chevron").click(); await page.locator(".cv-message .cv-agentmsg__chevron").click(); - await page.locator(".cv-message .cv-agentmsg__toggle").click(); expect(await page.locator(".cv-message__more").getAttribute("aria-expanded")).toBe("true"); await page.locator(".cv-message__more").press("Enter"); expect(await intact(".cv-message__text")).toEqual({ mask: "none", split: 0, visible: true }); @@ -147,7 +150,7 @@ await requireBrowserLane("message-preview-browser.test.ts", async () => { expect(await page.locator(".cv-received__text").count()).toBe(0); expect( await page - .locator(".cv-received__preview") + .locator(".cv-disclosure__below") .first() .evaluate((box) => getComputedStyle(box).textOverflow), ).toBe("ellipsis"); @@ -163,7 +166,8 @@ await requireBrowserLane("message-preview-browser.test.ts", async () => { const toggle = row.locator(direction === "received" ? ".cv-disclosure__toggle" : ".cv-agentmsg__toggle"); const text = row.locator(direction === "received" ? ".cv-received__text" : ".cv-message__text"); if (direction === "sent") { - await toggle.click(); + // Shut and stacked, the message's first line under its row is what the pointer opens. + await row.locator(".cv-agentmsg__below").click(); await row.locator(".cv-codeblock button").first().waitFor({ state: "attached" }); await page.waitForFunction( (selector) => document.querySelector(selector)?.style.maxHeight === "0px", diff --git a/webviews/test/queue-agent-message.test.tsx b/webviews/test/queue-agent-message.test.tsx index d5e64b9f94e5..ebbbafecfa38 100644 --- a/webviews/test/queue-agent-message.test.tsx +++ b/webviews/test/queue-agent-message.test.tsx @@ -224,7 +224,7 @@ test("an agent's waiting message: its line, no Read after this turn, a message's const entry = agent(1); await card(entry, calls); expect(host.querySelector(".cv-received__from")?.textContent).toBe("lane-1"); - expect(host.querySelector(".cv-received__preview")?.textContent).toContain("CI is green on #24001"); + expect(host.querySelector(".cv-disclosure__below")?.textContent).toContain("CI is green on #24001"); expect(host.querySelector(".cv-received__queued-head, .cv-received__queued")).toBeNull(); expect(host.textContent).not.toContain("Read after this turn"); expect(host.querySelector(".acpmux-queued, .cv-spinner, [data-spinner]")).toBeNull(); diff --git a/webviews/test/transcript-received-line.test.ts b/webviews/test/transcript-received-line.test.ts index 74f3c516610e..ce642f87ad66 100644 --- a/webviews/test/transcript-received-line.test.ts +++ b/webviews/test/transcript-received-line.test.ts @@ -63,6 +63,9 @@ await requireBrowserLane("transcript-received-line.test.ts", async () => { received: Line | null; run: Line | null; sender: { text: string; height: number; top: number; bottom: number } | null; + /** The message's first line, on its own line under the received line (messageLineLook.ts + * `stacked`, its 18px pinned by rowEstimates.test.ts); null when the line carries it. */ + first: { text: string; height: number } | null; }; const measure = (page: Page): Promise => @@ -118,7 +121,8 @@ await requireBrowserLane("transcript-received-line.test.ts", async () => { const tagBox = tag?.querySelector(".cv-agent-tag")?.getBoundingClientRect(); return { glyph: glyph ? (glyph.top + glyph.bottom) / 2 : null, - received: line(receivedRow, ".cv-received__preview", ".cv-received__mark > *"), + // Stacked, the line's words are the sender's; the first line is under it (`first`). + received: line(receivedRow, ".cv-received__preview, .cv-received__from", ".cv-received__mark > *"), run: line(runRow, ".cv-tool__summary", ".cv-tool__icon > *"), sender: tag && tagBox @@ -132,6 +136,13 @@ await requireBrowserLane("transcript-received-line.test.ts", async () => { bottom: tagBox.bottom, } : null, + first: (() => { + const below = receivedRow?.parentElement?.querySelector(":scope > .cv-msgline__preview"); + const box = below?.getBoundingClientRect(); + return below && box && box.height > 0 + ? { text: (below.textContent ?? "").replace(/\s+/g, " ").trim(), height: box.height } + : null; + })(), }; }); @@ -177,7 +188,9 @@ await requireBrowserLane("transcript-received-line.test.ts", async () => { }); test(`the received line and the run's line are one line apart (${theme.file})`, async () => { const got = await of(theme); - expect(Math.abs(got.run!.centre - got.received!.centre - value("step-pitch"))).toBeLessThanOrEqual(0.5); + // Line to line, plus the message's first line under the received one. + const first = got.first?.height ?? 0; + expect(Math.abs(got.run!.centre - got.received!.centre - first - value("step-pitch"))).toBeLessThanOrEqual(0.5); }); test(`the received line's words are the tool rows' size (${theme.file})`, async () => { const got = await of(theme); @@ -191,8 +204,12 @@ await requireBrowserLane("transcript-received-line.test.ts", async () => { test(`the sender is named once, its machine after it (${theme.file})`, async () => { const got = await of(theme); expect(got.sender!.text).toBe("merge-timeout · lane-vm-01"); - // Its message's "merge-timeout:" signature is out: the line names the sender once. - expect(got.received!.text).toContain("lane-vm-01please deploy"); + // Its message's "merge-timeout:" signature is out: the line names the sender once, and the + // message's first line (under it, stacked) starts at its words. + if (got.first) { + expect(got.received!.text).toContain("lane-vm-01"); + expect(got.first.text.startsWith("please deploy")).toBe(true); + } else expect(got.received!.text).toContain("lane-vm-01please deploy"); }); test(`the sender's tag stays inside its line, clear of the run's line (${theme.file})`, async () => { const got = await of(theme); diff --git a/webviews/test/transcript-row-alignment.test.ts b/webviews/test/transcript-row-alignment.test.ts index a90795f4963c..330df1ad08e5 100644 --- a/webviews/test/transcript-row-alignment.test.ts +++ b/webviews/test/transcript-row-alignment.test.ts @@ -159,11 +159,15 @@ await requireBrowserLane("transcript-row-alignment.test.ts", async () => { const line = rows[index]!.querySelector(selector); if (!line) continue; const box = line.getBoundingClientRect(); + // A message row's first line is on its own line right under the row's line + // (messageLineLook.ts `stacked`): the row ends under it, so the room below starts there. + const first = line.parentElement?.querySelector(":scope > .cv-msgline__preview")?.getBoundingClientRect(); + const bottom = first && first.height > 0 && first.top >= box.bottom - 0.5 ? first.bottom : box.bottom; gaps.push({ kind, label: line.textContent?.trim().slice(0, 40) ?? "", above: box.top - before.getBoundingClientRect().bottom, - below: after.getBoundingClientRect().top - box.bottom, + below: after.getBoundingClientRect().top - bottom, }); } } diff --git a/webviews/test/transcript-row-message.test.tsx b/webviews/test/transcript-row-message.test.tsx index 60c608b64b57..e07e63536d63 100644 --- a/webviews/test/transcript-row-message.test.tsx +++ b/webviews/test/transcript-row-message.test.tsx @@ -77,7 +77,7 @@ test("a sent message starts as one collapsed line: Sent to, the recipient, a one expect(row.getAttribute("data-direction")).toBe("sent"); expect(row.querySelector(".cv-agentmsg__line")?.textContent).toContain("Sent to"); expect(row.querySelector(".cv-agentmsg__name")?.textContent).toBe("coordinator"); - expect(row.querySelector(".cv-agentmsg__preview")?.textContent).toBe("first line"); + expect(row.querySelector(".cv-agentmsg__below")?.textContent).toBe("first line"); expect(toggle().getAttribute("aria-expanded")).toBe("false"); // Closed, how far it got is one word on the line; nothing else draws: no body, no Show more. expect(row.querySelector(".cv-agentmsg__line > .cv-tool__trail > .cv-message__status")?.textContent).toBe( @@ -291,7 +291,7 @@ test("the shared row draws a received message too: the caller's icon, a chip tha expect(row.querySelector(".cv-agentmsg__icon [data-testid=harness-mark]")).not.toBeNull(); expect(row.querySelector(".cv-agentmsg__line > .cv-agentmsg__sentence > .reply")?.textContent).toBe("Reply"); // First line only, its Markdown marks dropped. - expect(row.querySelector(".cv-agentmsg__preview")?.textContent).toBe("Done: the grid fix is on cmux/grid-fix."); + expect(row.querySelector(".cv-agentmsg__below")?.textContent).toBe("Done: the grid fix is on cmux/grid-fix."); await act(async () => host.querySelector("button.cv-agentmsg__name")!.click()); expect(opened).toEqual(["grid-fix"]); expect(host.querySelector(".cv-agentmsg__card")).toBeNull(); @@ -326,6 +326,6 @@ test("an acpmux_send call draws as the same collapsed message line, never an MCP const message = host.querySelector(".cv-agentmsg")!; expect(message.getAttribute("data-direction")).toBe("sent"); expect(message.querySelector(".cv-agentmsg__name")?.textContent).toBe("build-box/lane-a"); - expect(message.querySelector(".cv-agentmsg__preview")?.textContent).toBe("Rebase on main."); + expect(message.querySelector(".cv-agentmsg__below")?.textContent).toBe("Rebase on main."); expect(toggle().getAttribute("aria-expanded")).toBe("false"); }); diff --git a/webviews/test/transcript-row-pitch-browser.test.ts b/webviews/test/transcript-row-pitch-browser.test.ts index 53f4078ba79f..c31df8939375 100644 --- a/webviews/test/transcript-row-pitch-browser.test.ts +++ b/webviews/test/transcript-row-pitch-browser.test.ts @@ -133,7 +133,8 @@ await requireBrowserLane("transcript-row-pitch-browser.test.ts", async () => { (shown) => (window as unknown as { __showRawRows(rows: unknown): void }).__showRawRows(shown), rows, ); - await page.locator(".cv-pending__line").waitFor(); + // One waiting message draws as its own received line, with no group head (PendingMessagesCard.tsx). + await page.locator(".cv-pending .cv-disclosure__line, .cv-pending__line").first().waitFor(); await page.evaluate(() => document.fonts.ready); // Two frames for the transcript to place rows by their drawn heights. await page.evaluate( @@ -179,11 +180,17 @@ await requireBrowserLane("transcript-row-pitch-browser.test.ts", async () => { return part.height === 0 ? 0 : Math.max(box.top - part.top, part.bottom - box.bottom); }), ); + // A message row's first line, on its own 18px line right under the row's line + // (messageLineLook.ts `stacked`): the next row sits that much further down. + const under = [...(article?.querySelectorAll(".cv-msgline__preview") ?? [])] + .map((first) => first.getBoundingClientRect()) + .find((first) => first.height > 0 && Math.abs(first.top - box.bottom) < 4); return { row: article?.dataset.rowId ?? "?", line: el.className.toString().split(" ")[0], top: box.top, height: box.height, + below: under?.height ?? 0, overhang, icon: icon?.getBoundingClientRect().left ?? Number.NaN, text: textLeft(el, icon), @@ -207,7 +214,8 @@ await requireBrowserLane("transcript-row-pitch-browser.test.ts", async () => { PENDING_MESSAGES_ROW_ID, ]); const [first] = lines; - const pitch = lines[1]!.top - first!.top; + // Row line to row line, less a stacked message's first line under the earlier one. + const pitch = lines[1]!.top - first!.top - first!.below; const off = lines.flatMap((line, index) => { const name = `${line.row} (${line.line})`; const previous = lines[index - 1]; @@ -216,9 +224,13 @@ await requireBrowserLane("transcript-row-pitch-browser.test.ts", async () => { ? [`${name} is ${line.height}px tall, ${first!.row} ${first!.height}px`] : []), ...(line.overhang > 0.5 ? [`${name} has a part ${line.overhang}px out of its line`] : []), - ...(previous && Math.abs(line.top - previous.top - pitch) > 0.5 - ? [`${name} sits ${line.top - previous.top}px under ${previous.row}, ${pitch}px elsewhere`] + ...(previous && Math.abs(line.top - previous.top - previous.below - pitch) > 0.5 + ? [ + `${name} sits ${line.top - previous.top}px under ${previous.row} (its first line ${previous.below}px), ${pitch}px elsewhere`, + ] : []), + // A message's first line is the one 18px line (rowEstimates.test.ts MESSAGE_PREVIEW_LINE_PT). + ...(line.below && Math.abs(line.below - 18) > 0.5 ? [`${name} has a ${line.below}px first line`] : []), ...(Math.abs(line.icon - first!.icon) > 0.5 ? [`${name} icon at ${line.icon}, ${first!.icon} elsewhere`] : []), diff --git a/webviews/test/transcript-spacing-kinds.test.ts b/webviews/test/transcript-spacing-kinds.test.ts index a97dfa87264d..8c7716a4496e 100644 --- a/webviews/test/transcript-spacing-kinds.test.ts +++ b/webviews/test/transcript-spacing-kinds.test.ts @@ -106,6 +106,15 @@ await requireBrowserLane("transcript-spacing-kinds.test.ts", async () => { }; const row = (id: string) => document.querySelector(`[data-row-id="${id}"]`); const rowLines = (id: string) => lines(row(id)); + // A message row's first line sits on its own 18px line under the row (messageLineLook.ts + // `stacked`, pinned by rowEstimates.test.ts): the row's own lines are those above it, and the + // pitch to the row under it is one row line plus that first line. + const below = (id: string) => row(id)?.querySelector(".cv-msgline__preview")?.getBoundingClientRect(); + const lineLines = (id: string) => { + const first = below(id); + return first ? rowLines(id).filter((line) => line.bottom <= first.top + 0.5) : rowLines(id); + }; + const belowHeight = (id: string) => below(id)?.height ?? 0; /** A footer's first glyph, shown or hover-revealed (an earlier turn's row keeps its place). */ const glyph = (id: string) => { const svg = row(id)?.querySelector(".cv-turn-actions button svg"); @@ -116,9 +125,11 @@ await requireBrowserLane("transcript-spacing-kinds.test.ts", async () => { const at = (line: Line | undefined) => (line ? (line.top + line.bottom) / 2 : null); const diff = (a: number | null | undefined, b: number | null | undefined) => a == null || b == null ? null : Math.round((b - a) * 100) / 100; + const minus = (gap: number | null, height: number) => + gap == null ? null : Math.round((gap - height) * 100) / 100; const long = rowLines("kinds-long"); - const received = rowLines("kinds-received"); + const received = lineLines("kinds-received"); const scheduled = rowLines("backgroundTurn-spacing-scheduled"); const run = rowLines("kinds-run"); const short = rowLines("kinds-short"); @@ -130,7 +141,7 @@ await requireBrowserLane("transcript-spacing-kinds.test.ts", async () => { const gaps: Record = { "body-line": long.length > 1 ? diff(at(long[0]), at(long[1])) : null, "footer-to-received": diff(glyph("kinds-footer"), at(received[0])), - "received-to-status": diff(at(received.at(-1)), at(scheduled[0])), + "received-to-status": minus(diff(at(received.at(-1)), at(scheduled[0])), belowHeight("kinds-received")), "status-to-run": diff(at(scheduled.at(-1)), at(run[0])), "run-to-child": run.length > 2 ? diff(at(run[0]), at(run[1])) : null, "child-pitch": run.length > 2 ? diff(at(run[1]), at(run[2])) : null, @@ -231,6 +242,14 @@ await requireBrowserLane("transcript-spacing-kinds.test.ts", async () => { }; const diff = (a: number | null | undefined, b: number | null | undefined) => a == null || b == null ? null : Math.round((b - a) * 100) / 100; + // A message row's first line sits on its own 18px line under the row (messageLineLook.ts + // `stacked`): the pitch from it to the row under it is one row line plus that line. + const below = (row: Element | undefined) => { + const first = row?.querySelector(".cv-msgline__preview")?.getBoundingClientRect(); + return first && first.height > 0 ? first.height : 0; + }; + const after = (row: Element | undefined, gap: number | null) => + gap == null ? null : Math.round((gap - below(row)) * 100) / 100; const live = rows.find( (row) => row.classList.contains("acpmux-thinking") || row.classList.contains("acpmux-working"), ); @@ -246,8 +265,8 @@ await requireBrowserLane("transcript-spacing-kinds.test.ts", async () => { "live-to-waiting": diff(head(live), head(byClass("acpmux-pendingMessages"))), "reply-footer-to-received": footer && footer.height > 0 ? diff((footer.top + footer.bottom) / 2, head(received)) : null, - "received-to-sent": diff(head(received), head(sent)), - "sent-to-live": diff(head(sent), head(live)), + "received-to-sent": after(received, diff(head(received), head(sent))), + "sent-to-live": after(sent, diff(head(sent), head(live))), "status-to-prompt": diff(head(byClass("acpmux-subagentDone")), bubble?.top), "prompt-to-sent": diff(bubble?.bottom, head(document.querySelector('[data-row-id="sp-sent"]') ?? undefined)), "note-to-live": diff(head(document.querySelector('[data-row-id="notes-last"]') ?? undefined), head(live)), @@ -255,9 +274,12 @@ await requireBrowserLane("transcript-spacing-kinds.test.ts", async () => { const chips = [...document.querySelectorAll(".cv-agent-tag")].filter(shown).map((chip) => { const label = lines(chip)[0]; const box = chip.getBoundingClientRect(); - // The row's own words: a received line's preview, a sent line's verb. + // The row's own words: a received line's preview, a sent line's verb; stacked, a received + // line's first line is under it, so its line's own size (the sender's words) stands in. const row = chip.closest("[data-row-id]") ?? document.body; - const words = row.querySelector(".cv-received__preview, .cv-agentmsg__words, .cv-agentmsg__preview"); + const words = + row.querySelector(".cv-received__preview, .cv-agentmsg__words, .cv-agentmsg__preview") ?? + row.querySelector(".cv-disclosure__line, .cv-agentmsg__line"); const size = (element: Element) => parseFloat(getComputedStyle(element).fontSize); return { overText: label ? Math.round((box.height - (label.bottom - label.top)) * 100) / 100 : 99, diff --git a/webviews/test/transcript-spacing-table.test.ts b/webviews/test/transcript-spacing-table.test.ts index 8cfde3f00e58..149a0f50b7ae 100644 --- a/webviews/test/transcript-spacing-table.test.ts +++ b/webviews/test/transcript-spacing-table.test.ts @@ -139,7 +139,16 @@ await requireBrowserLane("transcript-spacing-table.test.ts", async () => { /** The drawn lines of the transcript row that holds `text`, top to bottom. */ const rowLines = (text: string) => lines(holding(text)?.closest(".acpmux-row")); // A running turn lists a run's calls one line each; a finished one folds them ("Sent 3 messages"). - const sends = rowLines("Take the one-line row pitch"); + // Each send's first line sits on its own 18px line under it (messageLineLook.ts `stacked`, + // pinned by rowEstimates.test.ts): the pitch is between the sends' own lines, less that line. + const sendRow = holding("Take the one-line row pitch")?.closest(".acpmux-row"); + const firstLines = [...(sendRow?.querySelectorAll(".cv-msgline__preview") ?? [])].map((element) => + element.getBoundingClientRect(), + ); + const firstLine = firstLines.find((box) => box.height > 0)?.height ?? 0; + const sends = rowLines("Take the one-line row pitch").filter( + (line) => !firstLines.some((box) => line.top >= box.top - 0.5 && line.bottom <= box.bottom + 0.5), + ); const short = paragraph("Briefs are out"); const commands = rowLines("gh pr checks 2210").length ? rowLines("gh pr checks 2210") : rowLines("Checked #2210"); /** The first line of the shown row of kind `kind` whose words read `text`, across spans: the @@ -155,6 +164,7 @@ await requireBrowserLane("transcript-spacing-table.test.ts", async () => { const diff = (a: number | null | undefined, b: number | null | undefined) => a == null || b == null ? null : Math.round((b - a) * 100) / 100; + const less = (gap: number | null) => (gap == null ? null : Math.round((gap - firstLine) * 100) / 100); const at = (line: { top: number; bottom: number } | null | undefined) => centre(line ?? undefined); const glyphCentre = glyph ? (glyph.top + glyph.bottom) / 2 : null; const gaps: Record = { @@ -163,8 +173,8 @@ await requireBrowserLane("transcript-spacing-table.test.ts", async () => { "footer-to-next": diff(glyphCentre, at(inboxes[0])), "step-to-prompt": diff(at(inboxes[0]), prompt?.top), "prompt-to-step": diff(prompt?.bottom, at(sends[0])), - "step-pitch": diff(at(sends[0]), at(sends[1])), - "step-to-prose": diff(at(sends.at(-1)), at(short[0])), + "step-pitch": less(diff(at(sends[0]), at(sends[1]))), + "step-to-prose": less(diff(at(sends.at(-1)), at(short[0]))), "prose-to-step": diff(at(short.at(-1)), at(commands[0])), "run-to-step": diff(at(commands.at(-1)), at(inboxes[1])), "step-to-live": diff(at(inboxes[1]), at(live)), diff --git a/webviews/test/transcript-system-rows.test.ts b/webviews/test/transcript-system-rows.test.ts index c20ce3268919..0abe898d33a7 100644 --- a/webviews/test/transcript-system-rows.test.ts +++ b/webviews/test/transcript-system-rows.test.ts @@ -53,7 +53,9 @@ await requireBrowserLane("transcript-system-rows.test.ts", async () => { await vite?.close(); }); - type Mark = { name: string; centre: number; left: number } | null; + /** `below`: the height of the message's first line under its row (messageLineLook.ts `stacked`, + * pinned by rowEstimates.test.ts), which the pitch to the next row adds; 0 for any other row. */ + type Mark = { name: string; centre: number; left: number; below: number } | null; type Measured = { marks: Mark[]; bare: string[]; rows: string[] }; /** The rows in the capture's order: each mark is the first glyph line of the text named. */ @@ -87,7 +89,13 @@ await requireBrowserLane("transcript-system-rows.test.ts", async () => { range.setStart(node, at); range.setEnd(node, at + text.length); const rect = [...range.getClientRects()].find((each) => each.width > 0 && each.height > 0); - if (rect) return { name: text, centre: (rect.top + rect.bottom) / 2, left: rect.left }; + if (!rect) continue; + const first = node.parentElement + .closest(".acpmux-row") + ?.querySelector(".cv-msgline__preview") + ?.getBoundingClientRect(); + const below = first && first.top >= rect.bottom - 0.5 ? first.height : 0; + return { name: text, centre: (rect.top + rect.bottom) / 2, left: rect.left, below }; } return null; }; @@ -145,7 +153,8 @@ await requireBrowserLane("transcript-system-rows.test.ts", async () => { for (let index = 1; index < ORDER.length; index += 1) test(`"${ORDER[index - 1]}" to "${ORDER[index]}" is ${SYSTEM_ROW_PITCH}px centre to centre (${theme.file})`, async () => { const { marks } = await of(theme); - const gap = marks[index]!.centre - marks[index - 1]!.centre; + // A stacked message row adds its first line's own line under it; the row lines stay 22 apart. + const gap = marks[index]!.centre - marks[index - 1]!.centre - marks[index - 1]!.below; expect(Math.abs(gap - SYSTEM_ROW_PITCH)).toBeLessThanOrEqual(1); }); test(`"Scheduled check" and the compaction start their words on the run's text column (${theme.file})`, async () => {