fix(frontend): show complete model activity from phase one

This commit is contained in:
User
2026-07-14 23:06:07 +02:00
parent f0f6c3c223
commit f58b1d84ae
5 changed files with 279 additions and 112 deletions
@@ -78,6 +78,11 @@ test("Resume from the panel activates the session and closes the panel", async (
await userEvent.click(await screen.findByText("Attiva uno"));
await screen.findByText("Domanda originale"); // panel open
await userEvent.click(screen.getByRole("button", { name: /resume/i }));
expect(useSessionStore.getState().activityLog).toContainEqual({
kind: "lifecycle",
phase: null,
text: "Resuming session",
});
await waitFor(() => expect(resumed).toBe("s1"));
await waitFor(() => expect(screen.queryByText("Domanda originale")).not.toBeInTheDocument()); // panel closed
});
@@ -206,23 +211,45 @@ test("a failed resume keeps the panel open and does not activate the session", a
await waitFor(() => expect(screen.getByText("Domanda originale")).toBeInTheDocument());
});
test("WIP icon toggles the Model activity panel and shows streamed reasoning", async () => {
test("closing and reopening Model activity preserves the complete activity log", async () => {
wrap();
// Activate a session by opening + resuming is heavy; instead drive the store directly.
// The WIP icon only renders with an active session, so simulate one via Resume.
server.use(http.post("http://localhost:8787/sessions/:id/resume", () => new HttpResponse(null, { status: 204 })));
await userEvent.click(await screen.findByText("Attiva uno")); // opens docs panel
await userEvent.click(await screen.findByRole("button", { name: /resume/i })); // active session
const SIX_LINES = ["FIRSTLINE step one", "step two", "step three", "step four", "step five", "step six"].join("\n");
act(() => { useSessionStore.getState().applyEvent({ type: "activity_delta", text: SIX_LINES }); });
// The verbose stream stays in the (closed) left panel: its START is not shown centrally
// (the central working indicator shows only the last 5 lines of tail, by design).
await userEvent.click(await screen.findByText("Attiva uno"));
await userEvent.click(await screen.findByRole("button", { name: /resume/i }));
act(() => {
const store = useSessionStore.getState();
store.setPhase("F4");
store.setLastUserEntry({ kind: "input", text: "Inspect patient cohort" });
store.applyEvent({
type: "activity_event",
activity: { kind: "tool", toolCallId: "tool-1", toolName: "bash", status: "running" },
});
store.applyEvent({
type: "activity_event",
activity: { kind: "tool", toolCallId: "tool-1", toolName: "bash", status: "completed" },
});
store.applyEvent({ type: "text_delta", text: "Cohort ready" });
});
const beforeClose = useSessionStore.getState().activityLog;
expect(screen.queryByRole("heading", { name: /model activity/i })).not.toBeInTheDocument();
expect(screen.queryByText(/FIRSTLINE/)).not.toBeInTheDocument();
await userEvent.click(screen.getByRole("button", { name: /model activity/i }));
// Panel open: the full streamed text is visible inside it.
expect(await screen.findByRole("heading", { name: /model activity/i })).toBeInTheDocument();
expect(screen.getByText(/FIRSTLINE/)).toBeInTheDocument();
const panel = (await screen.findByRole("heading", { name: /model activity/i })).closest("aside");
expect(panel).not.toBeNull();
expect(within(panel!).getByText("Inspect patient cohort")).toBeInTheDocument();
expect(within(panel!).getByText("bash")).toBeInTheDocument();
expect(within(panel!).getByText("Cohort ready")).toBeInTheDocument();
await userEvent.click(screen.getByRole("button", { name: /close model activity/i }));
expect(screen.queryByRole("heading", { name: /model activity/i })).not.toBeInTheDocument();
expect(useSessionStore.getState().activityLog).toEqual(beforeClose);
await userEvent.click(screen.getByRole("button", { name: /show model activity/i }));
const reopened = (await screen.findByRole("heading", { name: /model activity/i })).closest("aside");
expect(reopened).not.toBeNull();
expect(within(reopened!).getByText("Inspect patient cohort")).toBeInTheDocument();
expect(within(reopened!).getByText("bash")).toBeInTheDocument();
expect(within(reopened!).getByText("Cohort ready")).toBeInTheDocument();
});
test("session finalization shows the completion banner and returns to landing", async () => {