Skip to content

Commit 54886c9

Browse files
salman1993claude
andcommitted
fix(agents): retire a card failure notice once its status is superseded
The notice was only hidden while status differed, so a failed card Start followed by Start and Stop from the editor revived the old "didn't start" alert. The first observed transition away from the notice's status now clears it, whatever surface caused the change. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: Salman Mohammed <[email protected]>
1 parent 35fa1d7 commit 54886c9

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

‎src/bundled/agents/AgentsPage.test.tsx‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,36 @@ it("checks Start failure and keeps lifecycle controls available", async () => {
327327
await act(async () => control.refresh());
328328
expect(within(card).queryByText(/The agent didn't start/)).toBeNull();
329329
});
330+
it("retires a card Start failure after the editor starts and stops the agent", async () => {
331+
const { f } = setup();
332+
const [card] = await screen.findAllByRole("article", {
333+
name: "Agent Fixture agent",
334+
});
335+
if (!card) throw Error("Missing managed card");
336+
fireEvent.click(within(card).getByRole("button", { name: "Stop" }));
337+
await within(card).findByRole("button", { name: "Start" });
338+
const action = f.host.action;
339+
f.host.action = async () => {
340+
throw "synthetic start failure";
341+
};
342+
fireEvent.click(within(card).getByRole("button", { name: "Start" }));
343+
await within(card).findByText(/The agent didn't start/);
344+
f.host.action = action;
345+
fireEvent.click(
346+
within(card).getByRole("button", { name: "Actions for Fixture agent" }),
347+
);
348+
fireEvent.click(await screen.findByRole("menuitem", { name: "Edit" }));
349+
const dialog = screen.getByRole("dialog", { name: "Edit agent" });
350+
fireEvent.click(within(dialog).getByRole("button", { name: "Runtime" }));
351+
fireEvent.click(within(dialog).getByRole("button", { name: "Start" }));
352+
await within(card).findByText("Process running · relay readiness unverified");
353+
fireEvent.click(within(dialog).getByRole("button", { name: "Stop" }));
354+
await within(card).findByText("Process stopped");
355+
fireEvent.click(within(dialog).getByRole("button", { name: "Close editor" }));
356+
await waitFor(() => expect(screen.queryByRole("dialog")).toBeNull());
357+
expect(within(card).getByText("Process stopped")).toBeVisible();
358+
expect(within(card).queryByText(/The agent didn't start/)).toBeNull();
359+
});
330360
it("Add opens a focused creation dialog and retains a dirty draft on Escape", async () => {
331361
const { f } = setup();
332362
const add = await screen.findByRole("button", { name: "Add agent" });

‎src/bundled/agents/ManagedAgentActions.tsx‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ export function ManagedAgentActions({
2828
text: string;
2929
status: AgentView["status"];
3030
} | null>(null);
31+
// Retire on an observed transition away from the notice's status, from any
32+
// surface (editor, mention start), so returning to it cannot revive the notice.
33+
const [observed, setObserved] = useState(agent.status);
34+
if (observed !== agent.status) {
35+
setObserved(agent.status);
36+
if (notice && notice.status !== agent.status) setNotice(null);
37+
}
3138
useEffect(() => {
3239
if (imported) {
3340
details.current?.scrollIntoView?.({ block: "nearest" });

0 commit comments

Comments
 (0)