Skip to content

armgit / qm

Public Imported from GitHub
0

Multiplayer agent harness for work.

Show parent breadcrumbs and unwrap singleton activity (#1585)

Regan Bell276f7e2ade44
diff --git a/plugins/web-ui/src/chat.ts b/plugins/web-ui/src/chat.ts
index de643a46e..618efe64f 100644
--- a/plugins/web-ui/src/chat.ts
+++ b/plugins/web-ui/src/chat.ts
@@ -2434,6 +2434,8 @@ export function createChatSurface(
const animating = active && !stopping;
let label = stopping ? "Stop requested" : workLabel(work);
if (stopped) label = `You stopped after ${goalElapsedLabel(0, workSeconds(work) * 1000)}`;
+ if (timeline.length === 1 && !tail.trim() && !stopped && !stopping && !work.stale && !work.pendingApprovals?.length)
+ return html`${renderTimelineItem(timeline[0]!, work)}${replies.map((reply) => html`<div class="streaming-text" dir="auto">${markdown(reply)}</div>`)}`;
let fold =
timeline.length || tail.trim() || work.pendingApprovals?.length
? html`<details
@@ -2449,7 +2451,7 @@ export function createChatSurface(
activityGroups(timeline),
(items) => timelineKey(items[0]!),
(items) => {
- if (items[0]?.kind === "text") return renderTimelineItem(items[0], work);
+ if (items.length === 1 || items[0]?.kind === "text") return renderTimelineItem(items[0]!, work);
const summary = activityGroupSummary(items, work.status);
const groupIcon = { read: BookOpen, search: Search, execute: Terminal, other: Wrench }[
summary.category
diff --git a/plugins/web-ui/src/shell.css b/plugins/web-ui/src/shell.css
index daba3f6f5..b193d5b48 100644
--- a/plugins/web-ui/src/shell.css
+++ b/plugins/web-ui/src/shell.css
@@ -12857,3 +12857,21 @@ body.app-edit-embed .custom-chat-shell.app-edit-chat > .chat-bottom-dock {
outline-offset: 6px;
border-radius: 8px;
}
+
+.split-pane-parent {
+ min-width: 0;
+ max-width: 30%;
+ padding: 0;
+ border: 0;
+ background: transparent;
+ color: var(--muted-foreground);
+ font: inherit;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ cursor: pointer;
+}
+.split-pane-parent:hover {
+ color: var(--foreground);
+ text-decoration: underline;
+}
diff --git a/plugins/web-ui/src/split.ts b/plugins/web-ui/src/split.ts
index 3a9fd5b88..57d09f4bd 100644
--- a/plugins/web-ui/src/split.ts
+++ b/plugins/web-ui/src/split.ts
@@ -1217,7 +1217,8 @@ class PaneTab implements ITabRenderer {
const awaiting = paneAwaitsInput(panel);
const background = paneBackground(panel);
const sessionId = panelParams(panel).sessionId ?? paneSession(panel)?.id;
- attachTooltip(this.element, crumb ? `${crumb} / ${title}` : title);
+ const parent = sessionId ? sessionParent(sessionId) : undefined;
+ attachTooltip(this.element, [crumb, parent ? sessionTitle(parent) : null, title].filter(Boolean).join(" / "));
render(
html`
${working ? html`<span class="working-mark" ${ref(syncWorkingPulse)}>${workingWave()}</span>` : nothing}
@@ -1236,6 +1237,24 @@ class PaneTab implements ITabRenderer {
? html`<span class="split-pane-crumb">${crumb}</span><span class="split-pane-crumb-sep">/</span>`
: nothing
}
+ ${
+ parent
+ ? html`<button
+ type="button"
+ class="split-pane-parent"
+ aria-label=${`Back to parent: ${sessionTitle(parent)}`}
+ ${tip(sessionTitle(parent))}
+ @pointerdown=${(event: Event) => event.stopPropagation()}
+ @click=${(event: Event) => {
+ event.stopPropagation();
+ focusPane(panel.id);
+ void openSession(parent);
+ }}
+ >
+ ${sessionTitle(parent)}</button
+ ><span class="split-pane-crumb-sep">/</span>`
+ : nothing
+ }
<span class="split-pane-title-text" dir="auto">${title}</span>
${sessionStatusMark(paneSession(panel)?.status)}
${
diff --git a/plugins/web-ui/test/activity-folding.test.ts b/plugins/web-ui/test/activity-folding.test.ts
new file mode 100644
index 000000000..9dbd0be0d
--- /dev/null
+++ b/plugins/web-ui/test/activity-folding.test.ts
@@ -0,0 +1,54 @@
+import assert from "node:assert/strict";
+import { test } from "node:test";
+import { harness, SESSION } from "./deep-link-boot-fixture.ts";
+
+for (const count of [1, 2]) {
+ test(`${count} tool items use only useful activity folds`, async () => {
+ const entries = Array.from({ length: count }, (_, index) => [
+ {
+ seq: index * 2,
+ type: "tool_call",
+ createdAt: 1000,
+ payload: { tool: "execute", callId: String(index), command: `echo ${index}` },
+ },
+ {
+ seq: index * 2 + 1,
+ type: "tool_result",
+ createdAt: 2000,
+ payload: { tool: "execute", callId: String(index), code: 0, stdout: String(index) },
+ },
+ ]).flat();
+ const h = await harness({ path: `/s/${SESSION.id}`, listSessions: [SESSION], entries });
+ try {
+ h.releaseSessions();
+ await h.boot();
+ await h.sessionsReady();
+ assert.equal(document.querySelectorAll(".tool-expandable").length, count);
+ assert.equal(document.querySelectorAll(".work-fold").length, count === 1 ? 0 : 2);
+ const tool = document.querySelector<HTMLDetailsElement>(".tool-expandable")!;
+ tool.open = true;
+ tool.dispatchEvent(new Event("toggle"));
+ assert.match(tool.textContent!, /echo 0/);
+ } finally {
+ await h.close();
+ }
+ });
+}
+
+test("a subagent header includes its parent title in the breadcrumb", async () => {
+ const parent = { ...SESSION, id: "parent", title: "Build report" };
+ const h = await harness({
+ path: `/s/${SESSION.id}`,
+ listSessions: [parent, { ...SESSION, parentSessionId: parent.id }],
+ });
+ try {
+ h.releaseSessions();
+ await h.boot();
+ await h.sessionsReady();
+ const crumb = document.querySelector<HTMLButtonElement>(".split-pane-parent");
+ assert.equal(crumb?.textContent?.trim(), "Build report");
+ assert.equal(crumb?.getAttribute("aria-label"), "Back to parent: Build report");
+ } finally {
+ await h.close();
+ }
+});
diff --git a/plugins/web-ui/test/deep-link-boot-fixture.ts b/plugins/web-ui/test/deep-link-boot-fixture.ts
index 5d635d387..2a860f7d9 100644
--- a/plugins/web-ui/test/deep-link-boot-fixture.ts
+++ b/plugins/web-ui/test/deep-link-boot-fixture.ts
@@ -24,6 +24,7 @@ interface HarnessOptions {
holdTranscript?: boolean;
holdApprovals?: boolean;
listSessions?: unknown[];
+ entries?: unknown[];
savedCanvas?: boolean;
welcome?: boolean;
connectionReturn?: boolean;
@@ -152,7 +153,7 @@ export async function harness(opts: HarnessOptions): Promise<Harness> {
earlierEntries: older ? 0 : 80,
});
}
- return Response.json({ session: SESSION, entries: [] });
+ return Response.json({ session: SESSION, entries: opts.entries ?? [] });
}
if (path === "/api/sessions") {
await sessionsHeld;
diff --git a/plugins/web-ui/test/split-single-header.test.ts b/plugins/web-ui/test/split-single-header.test.ts
index e57e01a88..9f6bea084 100644
--- a/plugins/web-ui/test/split-single-header.test.ts
+++ b/plugins/web-ui/test/split-single-header.test.ts
@@ -29,7 +29,19 @@ test("only full standalone chats render their own session topbar", () => {
test("the pane tab carries the scope / title breadcrumb", () => {
assert.match(split, /function paneCrumb\(panel: IDockviewPanel\): string \| null/);
assert.match(split, /class="split-pane-crumb"/);
- assert.match(split, /attachTooltip\(this\.element, crumb \? `\$\{crumb\} \/ \$\{title\}` : title\);/);
+ const tooltip = split.match(/attachTooltip\(this\.element, (.*crumb.*)\);/)?.[1];
+ assert.ok(tooltip);
+ for (const crumb of [null, "Project"]) {
+ for (const parent of [undefined, { title: "Parent" }]) {
+ const actual = runInNewContext(tooltip, {
+ crumb,
+ parent,
+ title: "Child",
+ sessionTitle: (session: { title: string }) => session.title,
+ });
+ assert.equal(actual, `${crumb ? "Project / " : ""}${parent ? "Parent / " : ""}Child`);
+ }
+ }
// crumb changes must retrigger a header redraw
assert.match(split, /\$\{paneCrumb\(p\) \?\? ""\}\|\$\{paneTitle\(p\)\}/);
assert.match(css, /\.split-pane-crumb \{/);