Skip to content

Commit 16830e2

Browse files
author
am
committed
fix: announce working agents in accessible activity status
Signed-off-by: am <6e30cd56c30e030cd31bb0939b94a7c257c9a09d5ba2d92cf2735da45629f248@buzz.block.builderlab.xyz>
1 parent 596b66f commit 16830e2

3 files changed

Lines changed: 50 additions & 0 deletions

File tree

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ it("collapses channel-wide evidence without hiding simultaneous turns or unknown
115115
name: "Agent activity in this thread",
116116
});
117117
const summary = within(channel).getByText("Channel-wide activity · 2 agents");
118+
expect(within(channel).getByRole("status")).toHaveTextContent(
119+
"Agent aaaaaaaa is working",
120+
);
121+
expect(within(thread).getByRole("status")).toHaveTextContent(
122+
"Agent aaaaaaaa is working",
123+
);
124+
expect(within(channel).getByRole("status")).toHaveClass("sr-only");
125+
expect(channel.querySelector("details [role=status]")).toBeNull();
118126
expect(channel.querySelector("details")).not.toHaveAttribute("open");
119127
expect(
120128
within(channel).getByRole("button", { name: /aaaaaaaaaaaa/ }),
@@ -152,6 +160,10 @@ it("collapses channel-wide evidence without hiding simultaneous turns or unknown
152160
expect(
153161
screen.queryByRole("region", { name: "Agent activity in this channel" }),
154162
).not.toBeInTheDocument();
163+
expect(within(channel).queryByRole("status")).not.toBeInTheDocument();
164+
expect(within(thread).getByRole("status")).toHaveTextContent(
165+
"Agent aaaaaaaa is working",
166+
);
155167
mounted.unmount();
156168
expect(f.observe).toHaveBeenCalledTimes(1); // Disclosure never owns capture.
157169
});

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,22 @@ export function ActivityAccessory({
6262
profiles.snapshot,
6363
);
6464
if (!keys) return null;
65+
// Keep the announcement outside collapsed details; only the visually deduplicated
66+
// agent typing is represented here, while public human typing remains separate.
67+
const workingNames = keys
68+
.split(":")
69+
.filter(
70+
(agent) =>
71+
turns.some(
72+
(turn) => turn.agent === agent && turn.state === "working",
73+
) || typing.some((entry) => entry.agent === agent),
74+
)
75+
.map((agent) =>
76+
resolveName(
77+
agent,
78+
identities.get(agent)?.name ?? `Agent ${agent.slice(0, 8)}`,
79+
),
80+
);
6581
const agents = (
6682
<div className={styles.agents}>
6783
{keys.split(":").map((agent) => {
@@ -127,6 +143,12 @@ export function ActivityAccessory({
127143
: "Agent activity in this channel"
128144
}
129145
>
146+
{workingNames.length > 0 && (
147+
<span className="sr-only" role="status">
148+
{workingNames.join(", ")}
149+
{workingNames.length === 1 ? " is working" : " are working"}
150+
</span>
151+
)}
130152
{threadRootId ? (
131153
agents
132154
) : (

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,7 @@ test.describe("thread activity", () => {
10351035
exact: true,
10361036
});
10371037
const indicator = thread.getByRole("status", { name: "Typing activity" });
1038+
const workingStatus = region.getByRole("status");
10381039
const openThread = async (root) => {
10391040
await page
10401041
.locator(`[data-channel-timeline] [data-message-id="${root.id}"]`)
@@ -1085,9 +1086,13 @@ test.describe("thread activity", () => {
10851086
await expect(channelActivity(page)).toHaveCount(0);
10861087
publish(keys[0], roots[0]);
10871088
await expect(region.getByRole("button")).toHaveCount(1);
1089+
await expect(workingStatus).toContainText("Worker 1 is working");
10881090
await expect(indicator).toHaveCount(0);
10891091
publish(keys[1], roots[0]);
10901092
await expect(region.getByRole("button")).toHaveCount(2);
1093+
await expect(workingStatus).toContainText(
1094+
/Worker [12], Worker [12] are working/,
1095+
);
10911096
for (const agent of agents)
10921097
await expect(
10931098
region.getByRole("button", { name: new RegExp(agent.slice(0, 12)) }),
@@ -1098,6 +1103,7 @@ test.describe("thread activity", () => {
10981103
publish(human, roots[0]);
10991104
await expect(indicator).toHaveCount(1);
11001105
await expect(indicator).not.toContainText("Worker");
1106+
await expect(workingStatus).toContainText("are working");
11011107
await page.setViewportSize({ width: 390, height: 844 });
11021108
await page.locator("[data-panel-dock]").evaluate(async (element) => {
11031109
await Promise.all(
@@ -1146,11 +1152,13 @@ test.describe("thread activity", () => {
11461152
await expect(region.getByRole("button")).toHaveCount(1);
11471153
publish(keys[1], roots[0], 9);
11481154
await expect(region).toHaveCount(0);
1155+
await expect(workingStatus).toHaveCount(0);
11491156
await expect(indicator).toHaveCount(0);
11501157
await page
11511158
.getByRole("button", { name: "Close Thread tab", exact: true })
11521159
.click();
11531160
// Channel uses the same rows behind an existing visible disclosure.
1161+
const channelStatus = channelActivity(page).getByRole("status");
11541162
const channelTyping = page
11551163
.getByRole("form", { name: "Send a message to Alpha", exact: true })
11561164
.locator("..")
@@ -1159,17 +1167,25 @@ test.describe("thread activity", () => {
11591167
await expect(channelActivity(page).locator("summary")).toHaveText(
11601168
"Channel-wide activity · 1 agent",
11611169
);
1170+
await expect(channelStatus).toContainText("Worker 1 is working");
11621171
await expect(channelTyping).toHaveCount(0);
11631172
publish(keys[1]);
11641173
await expect(channelActivity(page).locator("summary")).toHaveText(
11651174
"Channel-wide activity · 2 agents",
11661175
);
1176+
await expect(channelStatus).toContainText(
1177+
/Worker [12], Worker [12] are working/,
1178+
);
1179+
await expect(channelActivity(page).locator("details")).not.toHaveAttribute(
1180+
"open",
1181+
);
11671182
await expandChannelActivity(page);
11681183
await expect(channelActivity(page).getByRole("button")).toHaveCount(2);
11691184
await expect(channelTyping).toHaveCount(0);
11701185
publish(human);
11711186
await expect(channelTyping).toBeVisible();
11721187
await expect(channelTyping).not.toContainText("Worker");
1188+
await expect(channelStatus).toContainText("are working");
11731189
await page.screenshot({
11741190
path: testInfo.outputPath("channel-multiple-agents-human-typing.png"),
11751191
});

0 commit comments

Comments
 (0)