Skip to content

Commit 09cb05c

Browse files
morgmartCarl
authored andcommitted
Let owners dismiss an agent's error on a message
Dismiss is local and display-only: it hides one agent's error on one message on this device without changing the outcome. Error reasons wrap instead of truncating. Co-authored-by: Carl <c217fe6b9d958f41c3a5e030dccc7f626775a923089cb6491305eade75ea1f1b@buzz.block.builderlab.xyz> Signed-off-by: morgmart <[email protected]>
1 parent af2f4cb commit 09cb05c

6 files changed

Lines changed: 212 additions & 35 deletions

File tree

‎src/bundled/agent-activity/ActivityAccessory.module.css‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@
77
display: flex;
88
flex-direction: column;
99
}
10+
/* Error dismissal is a sibling action, never a button nested in NavigationItem. */
11+
.row {
12+
display: flex;
13+
align-items: center;
14+
gap: var(--space-1);
15+
}
16+
.row > :first-child {
17+
min-width: 0;
18+
flex: 1;
19+
}
20+
1021
/* One glanceable line each; NavigationItem's label truncation applies per line. */
1122
.preview {
1223
min-width: 0;
@@ -20,6 +31,13 @@
2031
text-overflow: ellipsis;
2132
white-space: nowrap;
2233
}
34+
/* Errors explain what to do; keep their reason readable instead of clipped. */
35+
.preview[data-error] > * {
36+
overflow: visible;
37+
text-overflow: clip;
38+
white-space: normal;
39+
overflow-wrap: anywhere;
40+
}
2341
.detail {
2442
color: var(--text-subtle);
2543
}

‎src/bundled/agent-activity/ActivityAccessory.test.tsx‎

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,3 +423,93 @@ it("shows local receipt and failure without requiring an ACP transcript, and ope
423423
f.dispose();
424424
}
425425
});
426+
427+
it("dismisses only that agent's error on this message, without changing other work", () => {
428+
const local = createLocalAgentActivity();
429+
const f = fixture(local);
430+
const onFocusedRemoval = vi.fn();
431+
const view = render(
432+
<ActivityAccessory {...f.props} onFocusedRemoval={onFocusedRemoval} />,
433+
);
434+
const begin = (agent: string, messageId: string) =>
435+
local.begin({
436+
scope: "test",
437+
channelId: "c",
438+
threadRootId: root,
439+
messageId,
440+
agent,
441+
});
442+
try {
443+
act(() => {
444+
begin(A, root).finish({
445+
ok: false,
446+
error: "Provider unavailable after a long and detailed reason",
447+
});
448+
begin(A, next).finish({ ok: false, error: "Elsewhere" });
449+
begin(B, root).step("Read", "notes.txt");
450+
});
451+
fireEvent.click(
452+
screen.getByRole("button", { name: /View agent activity/ }),
453+
);
454+
expect(
455+
screen.getByText("Provider unavailable after a long and detailed reason")
456+
.parentElement,
457+
).toHaveAttribute("data-error");
458+
expect(
459+
screen.queryByRole("button", { name: "Dismiss error from Bubbles" }),
460+
).toBeNull();
461+
fireEvent.click(
462+
screen.getByRole("button", { name: "Dismiss error from Blossom" }),
463+
);
464+
expect(f.props.open).not.toHaveBeenCalled();
465+
expect(onFocusedRemoval).not.toHaveBeenCalled();
466+
expect(
467+
screen.getByRole("button", { name: "View activity for Bubbles" }),
468+
).toBeInTheDocument();
469+
expect(
470+
screen.queryByRole("button", { name: "View activity for Blossom" }),
471+
).toBeNull();
472+
expect(
473+
local.reader
474+
.work()
475+
.filter((row) => row.agent === A)
476+
.map((row) => [row.messageId, row.state]),
477+
).toEqual([[next, "error"]]);
478+
} finally {
479+
view.unmount();
480+
f.dispose();
481+
}
482+
});
483+
484+
it("moves focus out when dismissing the last error removes the bubble", () => {
485+
const local = createLocalAgentActivity();
486+
const f = fixture(local);
487+
const onFocusedRemoval = vi.fn();
488+
const view = render(
489+
<ActivityAccessory {...f.props} onFocusedRemoval={onFocusedRemoval} />,
490+
);
491+
try {
492+
act(() => {
493+
local
494+
.begin({
495+
scope: "test",
496+
channelId: "c",
497+
threadRootId: root,
498+
messageId: root,
499+
agent: A,
500+
})
501+
.finish({ ok: false, error: "Provider unavailable" });
502+
});
503+
fireEvent.click(
504+
screen.getByRole("button", { name: /View agent activity/ }),
505+
);
506+
fireEvent.click(
507+
screen.getByRole("button", { name: "Dismiss error from Blossom" }),
508+
);
509+
expect(onFocusedRemoval).toHaveBeenCalledOnce();
510+
expect(screen.queryByText("Provider unavailable")).toBeNull();
511+
} finally {
512+
view.unmount();
513+
f.dispose();
514+
}
515+
});

‎src/bundled/agent-activity/ActivityAccessory.tsx‎

Lines changed: 68 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import { activityTarget } from "../../features/agents/activity-target";
1515
import { profileActivityViewTarget } from "../../features/profiles/target";
1616
import { publicKeyLabels } from "../../shared/identity/public-key";
1717
import { Button } from "../../shared/design-system/ui/Button";
18+
import { IconButton } from "../../shared/design-system/ui/IconButton";
19+
import { XIcon } from "../../shared/design-system/icons";
1820
import { NavigationItem } from "../../shared/design-system/ui/NavigationItem";
1921
import { ShimmerText } from "../../shared/design-system/ui/ShimmerText";
2022
import { TypingDots } from "../../shared/design-system/ui/TypingDots";
@@ -284,43 +286,74 @@ function ActivityBubble({
284286
? currentActivity(entry.records, entry.turns)
285287
: undefined;
286288
return (
287-
<NavigationItem
288-
key={entry.agent}
289-
aria-label={`View activity for ${entry.name}`}
290-
disabled={!target || !props.canOpen(target)}
291-
onClick={() => {
292-
if (target && props.canOpen(target) && props.open(target))
293-
setExpanded(false);
294-
}}
295-
icon={
296-
<ActivityAvatar
297-
session={props.session}
298-
entry={entry}
299-
size="small"
300-
/>
301-
}
302-
label={
303-
<span className={`text-body-sm ${styles.preview}`}>
304-
<ShimmerText
305-
active={
306-
entry.lifecycle
307-
? entry.state === "working"
308-
: entry.working
289+
<div key={entry.agent} className={styles.row}>
290+
<NavigationItem
291+
aria-label={`View activity for ${entry.name}`}
292+
disabled={!target || !props.canOpen(target)}
293+
onClick={() => {
294+
if (target && props.canOpen(target) && props.open(target))
295+
setExpanded(false);
296+
}}
297+
icon={
298+
<ActivityAvatar
299+
session={props.session}
300+
entry={entry}
301+
size="small"
302+
/>
303+
}
304+
label={
305+
<span
306+
className={`text-body-sm ${styles.preview}`}
307+
data-error={
308+
entry.lifecycle && entry.state === "error"
309+
? ""
310+
: undefined
309311
}
310312
>
311-
{entry.lifecycle
312-
? label(entry)
313-
: !entry.working
314-
? "Activity interrupted or out of date"
315-
: (preview?.title ??
316-
"Waiting for activity details")}
317-
</ShimmerText>
318-
{preview?.detail && (
319-
<span className={styles.detail}>{preview.detail}</span>
320-
)}
321-
</span>
322-
}
323-
/>
313+
<ShimmerText
314+
active={
315+
entry.lifecycle
316+
? entry.state === "working"
317+
: entry.working
318+
}
319+
>
320+
{entry.lifecycle
321+
? label(entry)
322+
: !entry.working
323+
? "Activity interrupted or out of date"
324+
: (preview?.title ??
325+
"Waiting for activity details")}
326+
</ShimmerText>
327+
{preview?.detail && (
328+
<span className={styles.detail}>
329+
{preview.detail}
330+
</span>
331+
)}
332+
</span>
333+
}
334+
/>
335+
{entry.lifecycle && entry.state === "error" ? (
336+
<IconButton
337+
size="xs"
338+
aria-label={`Dismiss error from ${entry.name}`}
339+
icon={<XIcon />}
340+
onClick={(event) => {
341+
event.stopPropagation();
342+
if (
343+
props.message &&
344+
props.session.agentActivity.dismissError?.(
345+
entry.agent,
346+
props.channelId,
347+
props.message.id,
348+
)
349+
) {
350+
if (entries.length === 1) props.onFocusedRemoval?.();
351+
setExpanded(entries.length > 1);
352+
}
353+
}}
354+
/>
355+
) : undefined}
356+
</div>
324357
);
325358
})}
326359
</div>

‎src/features/agents/activity.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,12 @@ export function createAgentActivity(
515515
queries: Object.freeze({
516516
snapshot: () => snapshot,
517517
clearHistory,
518+
/** Display-only local acknowledgement, scoped to this session and access. */
519+
dismissError(agent: string, channelId: string, messageId: string) {
520+
if (!local || closed || !canAccess(channelId)) return false;
521+
local.source.dismissError?.({ scope: local.scope, agent, messageId });
522+
return true;
523+
},
518524
archive: history?.host,
519525
selectHistory(agent: string) {
520526
if (historyAgent === agent) return;

‎src/features/agents/local-activity.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ export type LocalWork = Readonly<{
2222
export type LocalAgentSource = {
2323
work(): readonly LocalWork[];
2424
subscribeWork(listener: () => void): () => void;
25+
/** Hides one already-seen error on this device; never changes its outcome. */
26+
dismissError?(work: Pick<LocalWork, "scope" | "agent" | "messageId">): void;
2527
};
2628

2729
/** App-owned local facts. No relay publication, inference, polling or process control. */
@@ -42,6 +44,19 @@ export function createLocalAgentActivity() {
4244
const reader: LocalAgentSource = {
4345
work: () => work,
4446
subscribeWork: (listener) => subscribe(workListeners, listener),
47+
dismissError({ scope, agent, messageId }) {
48+
for (const [id, row] of entries)
49+
if (
50+
row.state === "error" &&
51+
row.scope === scope &&
52+
row.agent === agent &&
53+
row.messageId === messageId
54+
) {
55+
entries.delete(id);
56+
publish();
57+
return;
58+
}
59+
},
4560
};
4661
return {
4762
reader,

‎tests/browser/local-agent-activity.spec.mjs‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@ test("local agent receipt, work and failure agree across sidebar, thread and exa
112112
const box = await popup.boundingBox();
113113
expect(box.x).toBeGreaterThanOrEqual(0);
114114
expect(box.x + box.width).toBeLessThanOrEqual(width);
115+
// The full reason wraps rather than truncating; Dismiss stays inside.
116+
await expect(popup.getByText("Fixture provider unavailable")).toHaveCSS(
117+
"white-space",
118+
"normal",
119+
);
120+
const dismiss = await popup
121+
.getByRole("button", { name: /^Dismiss error from / })
122+
.boundingBox();
123+
expect(dismiss.x + dismiss.width).toBeLessThanOrEqual(box.x + box.width);
115124
await page.screenshot({
116125
path: testInfo.outputPath(`local-activity-${colorScheme}-${width}.png`),
117126
});
@@ -120,6 +129,12 @@ test("local agent receipt, work and failure agree across sidebar, thread and exa
120129
await expect(waiting).toBeFocused();
121130
}
122131
}
132+
// Dismiss hides only this device's view of the error; focus stays in the row.
133+
await waiting.focus();
134+
await page.keyboard.press("Enter");
135+
await page.getByRole("button", { name: /^Dismiss error from / }).click();
136+
await expect(waiting).toHaveCount(0);
137+
await expect(page.locator("body")).not.toBeFocused();
123138
});
124139

125140
// Real host composition: dedup is about two mounted presentations, not two agents.

0 commit comments

Comments
 (0)