Skip to content
4 changes: 2 additions & 2 deletions scripts/gallery-matrix/shift-baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -957,8 +957,8 @@
"agent-pane.incoming-message#messages": 0,
"agent-pane.incoming-message#mid-turn": 0,
"agent-pane.incoming-message#minimal": 0,
"agent-pane.incoming-message#minimal-fade-count": 0.0175,
"agent-pane.incoming-message#minimal-inline-name": 0.0175,
"agent-pane.incoming-message#minimal-fade-count": 0.0318,
"agent-pane.incoming-message#minimal-inline-name": 0.0318,
"agent-pane.incoming-message#minimal-off": 0,
"agent-pane.incoming-message#minimal-open": 0.0624,
"agent-pane.incoming-message#notice": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,15 +334,17 @@ export default agentPaneEntry({
note: "Opened, the message grows in place under its line, with no box, and nothing else draws: no status block, no result JSON.",
snapshot: sends(),
play: async (ctx) => {
await ctx.click({ selector: ".cv-agentmsg__toggle" });
// Stacked (#33249), a shut row's toggle holds no words and sits on the recipient's chip, which
// opens the subagent; the person clicks the message's first line under the row, which toggles it.
await ctx.click({ selector: ".cv-agentmsg__below" });
await ctx.waitFor(() => ctx.document.querySelector(".cv-agentmsg__card"));
},
},
"sent-opened-long": {
note: "A long message opens capped near eight lines, the rest a scroll away under a fade.",
snapshot: long(),
play: async (ctx) => {
await ctx.click({ selector: ".cv-agentmsg__toggle" });
await ctx.click({ selector: ".cv-agentmsg__below" });
await ctx.waitFor(() => ctx.document.querySelector(".cv-message__text"));
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,9 @@ export default agentPaneEntry({
snapshot: sent(),
play: async (ctx) => {
await openTurn(ctx);
// Trusted clicks settle before the next step, so Raw is clicked where it rests.
await ctx.click({ role: "button", name: /net-retries: done/ });
// Trusted clicks settle before the next step, so Raw is clicked where it rests. Stacked
// (#33249), the message's first line sits under its row, out of the row's name; it toggles too.
await ctx.click({ text: /^net-retries: done$/ });
await ctx.waitFor(() => ctx.document.querySelector(".cv-subsession__under .cv-md h2"));
await ctx.click({ selector: ".cv-subsession__under .cv-subsession__toggle" });
await ctx.waitFor(() => ctx.document.querySelector(".cv-subsession__under .cv-shell"));
Expand Down
23 changes: 23 additions & 0 deletions webviews/src/agent-session/acpmux/conversation/foldAnchor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,29 @@ describe("foldToggleAt", () => {
expect(folding).toBe(false);
});
}
// A stacked message row's first line sits under the row and toggles it (messageLineLook.ts); it
// goes as the row opens, so the click holds the row's line, never the first line itself.
for (const [kind, html] of [
[
"a sent message",
'<div class="cv-tool is-toggle cv-sent" role="button" aria-expanded="false"><b>to</b></div><div class="cv-msgline__preview cv-sent__below" aria-hidden><i>first</i></div>',
],
[
"an agent message",
'<div class="cv-agentmsg"><div class="cv-tool cv-agentmsg__line" data-header-toggle=""><b>to</b></div><div class="cv-msgline__preview cv-agentmsg__below" aria-hidden><i>first</i></div></div>',
],
[
"a folded group's head",
'<button class="cv-tool cv-message-group__head" aria-expanded="false"><b>3 messages</b></button><div class="cv-msgline__preview cv-message-group__below" aria-hidden><i>a, b</i></div>',
],
] as const) {
test(`holds ${kind}'s line for a click on its first line`, () => {
const { document, at } = row(html);
const line = document.querySelector("b")!.parentElement;
expect(at("i")).toBe(line as HTMLElement);
expect(at(".cv-msgline__preview")).toBe(line as HTMLElement);
});
}
test("leaves a menu's trigger alone", () => {
expect(row('<button aria-expanded="false" aria-haspopup="menu">…</button>').at("button")).toBeUndefined();
});
Expand Down
8 changes: 7 additions & 1 deletion webviews/src/agent-session/acpmux/conversation/foldAnchor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,16 @@ export type FoldAnchor = {
until: number;
};

/// A message row's first line, on its own line under the row (messageLineLook.ts, stacked: a sent
/// message, an agent message, a received line, a folded group's head). It toggles its row, so a click
/// on it holds the row's line, as a click on the line does; the first line itself goes as the row opens.
const FIRST_LINE = ".cv-msgline__preview";

/// The disclosure line `target` is on, inside one of `scroller`'s rows; undefined for anything else.
export function foldToggleAt(target: EventTarget | null, scroller: HTMLElement): HTMLElement | undefined {
const element = target && typeof (target as Element).closest === "function" ? (target as Element) : null;
const toggle = element?.closest<HTMLElement>(FOLD_TOGGLE);
const line = element?.closest(FIRST_LINE)?.previousElementSibling;
const toggle = line?.matches(FOLD_TOGGLE) ? (line as HTMLElement) : element?.closest<HTMLElement>(FOLD_TOGGLE);
if (!toggle || !scroller.contains(toggle) || !toggle.closest(".acpmux-row")) return undefined;
// A control of its own inside the toggle (a sent line's recipient, its Copy) opens nothing there.
const control = element?.closest<HTMLElement>(NESTED_CONTROL);
Expand Down