Skip to content

Commit 7b94e58

Browse files
mahanticodex
andcommitted
Add per-interest Attention pause and management controls
Co-authored-by: Codex <[email protected]> Signed-off-by: Arjun Mahanti <[email protected]>
1 parent c037057 commit 7b94e58

18 files changed

Lines changed: 549 additions & 127 deletions

‎docs/agents.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ older app or remote host.
255255

256256
## Agent Attention
257257

258-
Attention itself (the runtime, tools, storage and sources) is core, but it runs on this device only while a plugin that shows it is on. The bundled Attention plugin (`buzz.watching`, on by default) adds an Attention tab to the settings of every agent running on this device, whatever its type. The tab explains Attention, holds the switch that lets this device run the agent's watches, then groups that agent's subscriptions by Interest. It shows instructions, listening and delivery destinations, enabled state and available wake history, and suggests asks while the agent has none. Ask an agent to create watches through its Attention tools; pausing or removing one preserves the other saved objects. Empty Interests remain visible and can be deleted after their watches are removed. Turning the plugin off hides the tab and turns every agent's Attention off on this device; mentions still wake agents, and each agent keeps its saved switch for when the plugin is back on. The former standalone Agent Attention page is gone, so an old link to `buzz.agents/attention` opens as an unavailable destination.
258+
Attention itself (the runtime, tools, storage and sources) is core, but it runs on this device only while a plugin that shows it is on. The bundled Attention plugin (`buzz.watching`, on by default) adds an Attention tab to the settings of every agent running on this device, whatever its type. The tab explains Attention, holds the switch that lets this device run the agent's watches, then groups that agent's subscriptions by Interest. It shows instructions, listening and delivery destinations, enabled state and available wake history, and suggests asks while the agent has none. Ask an agent to create watches through its Attention tools; pausing or removing one preserves the other saved objects. Each Interest can be paused without changing its watches’ enabled settings. Deleting an Interest with watches asks for confirmation, then removes them together. Turning the plugin off hides the tab and turns every agent's Attention off on this device; mentions still wake agents, and each agent keeps its saved switch for when the plugin is back on. The former standalone Agent Attention page is gone, so an old link to `buzz.agents/attention` opens as an unavailable destination.
259259

260260
## Agent types and providers
261261

‎docs/buzz-help.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,10 +804,14 @@ confirmation.
804804
when each interest wakes the agent (**Triggers**), its instructions after waking
805805
(**Instructions**), and whether Attention is active on this device. Use its Active/Paused menu to change that.
806806
With nothing watched yet, a sonar preview shows example requests. Send your own request in a conversation with the agent.
807+
Each interest has an Active/Paused menu. Pausing stops its triggers without changing
808+
individual watch settings. Running turns may finish; activating resumes enabled
809+
watches, and an overdue timer can run once. Delete in that menu
810+
removes the interest; if it has watches, confirm to delete those too.
807811
Each watch shows its source and Active or Paused state. Expand a
808812
watch, then expand “Activity” for a compact event timeline. Expand an event to read its full
809813
content, or expand “Watch details” for conditions and the execution destination. Select its status pill to
810-
activate, pause, or delete it, or its source pill to inspect the watched channels or source. “Responds in” shows where the agent runs and replies; select that destination to open the conversation.
814+
resume, pause, or delete it, or its source pill to inspect the watched channels or source. “Responds in” shows where the agent runs and replies; select that destination to open the conversation.
811815
“Runs in” names its execution conversation; its instructions can specify a
812816
different place to report. A
813817
mention can still wake an agent when Attention is off; turning Attention on does not grant new access.

‎src/bundled/watching/AttentionPage.css‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@
158158
}
159159
}
160160
.attention-interest-head {
161+
padding-block-start: var(--space-2);
161162
display: flex;
162163
align-items: center;
163164
justify-content: space-between;
@@ -167,12 +168,6 @@
167168
min-width: 0;
168169
overflow-wrap: anywhere;
169170
}
170-
@media (hover: hover) and (pointer: fine) {
171-
.attention-interest-head:not(:hover, :focus-within) .attention-delete {
172-
opacity: 0;
173-
pointer-events: none;
174-
}
175-
}
176171
.attention-instructions-preview {
177172
min-width: 0;
178173
flex: 1;

‎src/bundled/watching/AttentionStatus.tsx‎

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,37 @@
1+
import type { RefObject } from "react";
12
import { Button } from "../../shared/design-system/ui/Button";
23
import { CircleIcon } from "../../shared/design-system/icons";
34
import {
45
MenuRoot,
56
MenuTrigger,
67
MenuPopup,
78
MenuItem,
9+
MenuGroup,
10+
MenuGroupLabel,
11+
MenuSeparator,
812
} from "../../shared/design-system/ui/Menu";
913

1014
export function AttentionStatus({
1115
name,
16+
heading = "Attention",
1217
active,
1318
pending,
1419
onChange,
20+
onDelete,
21+
triggerRef,
22+
returnFocus,
23+
popupRef,
24+
deleteConfirms = false,
25+
label = `Attention status for ${name}`,
1526
}: {
1627
name: string;
28+
heading?: string;
29+
popupRef?: RefObject<HTMLDivElement | null>;
30+
deleteConfirms?: boolean;
31+
triggerRef?: RefObject<HTMLButtonElement | null>;
32+
returnFocus?: RefObject<HTMLElement | null>;
33+
label?: string;
34+
onDelete?(): void;
1735
active: boolean;
1836
pending: boolean;
1937
onChange(active: boolean): void;
@@ -23,11 +41,14 @@ export function AttentionStatus({
2341
<MenuTrigger
2442
render={
2543
<Button
44+
ref={triggerRef}
2645
variant="subtle"
2746
size="xs"
28-
aria-label={`Attention status for ${name}`}
47+
aria-label={label}
2948
>
3049
<CircleIcon
50+
data-accent={active ? "citrus" : undefined}
51+
data-color-mode={active ? "light" : undefined}
3152
size={12}
3253
fill="currentColor"
3354
strokeWidth={0}
@@ -43,20 +64,37 @@ export function AttentionStatus({
4364
}
4465
/>
4566
<MenuPopup
67+
ref={popupRef}
68+
finalFocus={() =>
69+
triggerRef?.current?.isConnected
70+
? triggerRef.current
71+
: (returnFocus?.current ?? true)
72+
}
4673
size="compact"
4774
align="end"
48-
aria-label={`Attention status for ${name}`}
75+
aria-label={label}
4976
>
50-
{[true, false].map((enabled) => (
77+
<MenuGroup>
78+
<MenuGroupLabel>{heading}</MenuGroupLabel>
5179
<MenuItem
52-
key={String(enabled)}
53-
disabled={pending || active === enabled}
80+
disabled={pending}
5481
closeOnClick={false}
55-
onClick={() => onChange(enabled)}
82+
onClick={() => onChange(!active)}
5683
>
57-
{enabled ? "Activate" : "Pause"}
84+
{active ? "Pause" : "Resume"}
5885
</MenuItem>
59-
))}
86+
{onDelete && <MenuSeparator />}
87+
{onDelete && (
88+
<MenuItem
89+
tone="danger"
90+
disabled={pending}
91+
closeOnClick={deleteConfirms}
92+
onClick={onDelete}
93+
>
94+
Delete
95+
</MenuItem>
96+
)}
97+
</MenuGroup>
6098
</MenuPopup>
6199
</MenuRoot>
62100
);

‎src/bundled/watching/Tab.test.tsx‎

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,14 @@ it("shows one agent's watches, reacts to changes and surfaces save errors", asyn
158158
fireEvent.click(
159159
screen.getByRole("button", { name: "Watch status for task" }),
160160
);
161-
expect(screen.getByRole("menuitem", { name: "Activate" })).toBeTruthy();
161+
expect(screen.getByRole("menuitem", { name: "Resume" })).toBeTruthy();
162162
expect(within(ada).getByText("Paused")).toBeTruthy();
163163
expect(
164164
within(ada).getByRole("button", {
165165
name: "Attention status for Ada",
166166
}),
167167
).toBeTruthy();
168-
fireEvent.click(screen.getByRole("menuitem", { name: "Activate" }));
168+
fireEvent.click(screen.getByRole("menuitem", { name: "Resume" }));
169169
await waitFor(() =>
170170
expect(screen.getByRole("alert").textContent).toBe("Save failed"),
171171
);
@@ -192,7 +192,7 @@ it("shows one agent's watches, reacts to changes and surfaces save errors", asyn
192192
fireEvent.click(
193193
within(
194194
screen.getByRole("menu", { name: "Attention status for Ada" }),
195-
).getByRole("menuitem", { name: "Activate" }),
195+
).getByRole("menuitem", { name: "Resume" }),
196196
);
197197
await waitFor(() =>
198198
expect(save).toHaveBeenCalledWith("membership-a", {
@@ -297,9 +297,41 @@ it.each(["source", "event", "timer"] as const)(
297297
);
298298
expect(
299299
screen
300-
.getByRole("button", { name: "Delete Interest release" })
300+
.getByRole("button", { name: "Interest status for release" })
301301
.hasAttribute("disabled"),
302-
).toBe(true);
302+
).toBe(false);
303+
fireEvent.click(
304+
screen.getByRole("button", { name: "Interest status for release" }),
305+
);
306+
fireEvent.click(screen.getByRole("menuitem", { name: "Delete" }));
307+
expect(screen.getByRole("alertdialog")).toBeTruthy();
308+
fireEvent.click(screen.getByRole("button", { name: "Cancel" }));
309+
expect(save).not.toHaveBeenCalled();
310+
fireEvent.click(
311+
screen.getByRole("button", { name: "Interest status for release" }),
312+
);
313+
fireEvent.click(screen.getByRole("menuitem", { name: "Delete" }));
314+
fireEvent.click(
315+
screen.getByRole("button", { name: "Delete interest and watches" }),
316+
);
317+
await waitFor(() =>
318+
expect(screen.getByRole("alert").textContent).toBe(
319+
"Interest save failed",
320+
),
321+
);
322+
expect(save).toHaveBeenLastCalledWith("membership-a", {
323+
attentionExpected: expect.objectContaining({
324+
"interest/release": expect.objectContaining({
325+
slug: "interest/release",
326+
}),
327+
}),
328+
attention: { "watch/check": null, "interest/release": null },
329+
});
330+
fireEvent.click(screen.getByRole("button", { name: "Cancel" }));
331+
expect(
332+
screen.getByRole("button", { name: "Watch status for release" }),
333+
).toBeTruthy();
334+
save.mockClear();
303335
expect(screen.queryByRole("menuitem", { name: "Pause" })).toBeNull();
304336
fireEvent.click(
305337
screen.getByRole("button", { name: "Watch status for release" }),
@@ -310,7 +342,7 @@ it.each(["source", "event", "timer"] as const)(
310342
await waitFor(() =>
311343
expect(
312344
screen
313-
.getByRole("menuitem", { name: "Pause" })
345+
.getByRole("menuitem", { name: "Resume" })
314346
.getAttribute("aria-disabled"),
315347
).toBe("true"),
316348
);
@@ -334,7 +366,7 @@ it.each(["source", "event", "timer"] as const)(
334366
if (type === "timer") {
335367
expect(
336368
screen
337-
.getByRole("menuitem", { name: "Activate" })
369+
.getByRole("menuitem", { name: "Resume" })
338370
.getAttribute("aria-disabled"),
339371
).toBe("true");
340372
expect(
@@ -353,21 +385,27 @@ it.each(["source", "event", "timer"] as const)(
353385
screen.getByRole("region", { name: "Interest release" }),
354386
).toBeTruthy();
355387
const removeInterest = screen.getByRole("button", {
356-
name: "Delete Interest release",
388+
name: "Interest status for release",
357389
});
358390
fireEvent.click(removeInterest);
391+
fireEvent.click(screen.getByRole("menuitem", { name: "Delete" }));
359392
await waitFor(() =>
360393
expect(screen.getByRole("alert").textContent).toBe(
361394
"Interest save failed",
362395
),
363396
);
364397
expect(agent.attention["interest/release"]).toBeTruthy();
365398
rejectInterest = false;
366-
fireEvent.click(removeInterest);
399+
fireEvent.click(screen.getByRole("menuitem", { name: "Delete" }));
367400
await waitFor(() =>
368401
expect(screen.getByRole("heading", { name: "Attention" })).toBeTruthy(),
369402
);
370403
expect(save).toHaveBeenLastCalledWith("membership-a", {
404+
attentionExpected: expect.objectContaining({
405+
"interest/release": expect.objectContaining({
406+
slug: "interest/release",
407+
}),
408+
}),
371409
attention: { "interest/release": null },
372410
});
373411
},
@@ -464,17 +502,15 @@ it("keeps subscription controls disabled and the tab open while saving, and pres
464502
fireEvent.click(
465503
screen.getByRole("button", { name: "Watch status for Build" }),
466504
);
467-
toggle = screen.getByRole("menuitem", { name: "Pause" }) as HTMLButtonElement;
505+
toggle = screen.getByRole("menuitem", {
506+
name: "Pause",
507+
}) as HTMLButtonElement;
468508
remove = screen.getByRole("menuitem", {
469509
name: "Delete Build",
470510
}) as HTMLButtonElement;
471511
expect(toggle.getAttribute("aria-disabled")).not.toBe("true");
472512
expect(remove.getAttribute("aria-disabled")).not.toBe("true");
473-
expect(
474-
screen
475-
.getByRole("menuitem", { name: "Activate" })
476-
.getAttribute("aria-disabled"),
477-
).toBe("true");
513+
expect(screen.queryByRole("menuitem", { name: "Resume" })).toBeNull();
478514
expect(save).toHaveBeenCalledTimes(1);
479515
});
480516

@@ -541,11 +577,11 @@ it("explains Attention to a new agent and switches it on this device", async ()
541577
});
542578
expect(toggle.textContent).toContain("Paused");
543579
fireEvent.click(toggle);
544-
fireEvent.click(screen.getByRole("menuitem", { name: "Activate" }));
580+
fireEvent.click(screen.getByRole("menuitem", { name: "Resume" }));
545581
await waitFor(() =>
546582
expect(screen.getByRole("alert").textContent).toBe("Enable failed"),
547583
);
548-
fireEvent.click(screen.getByRole("menuitem", { name: "Activate" }));
584+
fireEvent.click(screen.getByRole("menuitem", { name: "Resume" }));
549585
await waitFor(() => expect(save).toHaveBeenCalledTimes(2));
550586
expect(save).toHaveBeenLastCalledWith("membership-b", {
551587
attentionEnabled: true,

0 commit comments

Comments
 (0)