feat(frontend): sessions list/create + steering + resume + selectors

- NavSessions: left nav listing sessions via listSessions (TanStack Query),
  clicking resumes via resumeSession and sets active; active item highlighted
- NewSessionDialog: ShadCn dialog with question textarea, workspace native
  select (from listWorkspaces), graceful model field (dropdown when models
  list is non-empty, free-text input when empty per §9 degradation),
  optional thinking/provider fields; try/catch surfaces errors inline
- SteerInput: text input + button POSTs to postSteer, clears on send,
  supports Enter key; only shown when a session is active
- WorkflowBar: renders 8 phases (F1..F8) with data-active highlighting
  driven by useSessionStore.currentPhase (new store field + setPhase action)
- AppShell: wires all four components; right artifact sidebar now collapsible
  via a toggle button (useState sidebarOpen); replaces old "Nuova domanda"
  button with NewSessionDialog trigger
- f1-loop.test: updated to drive through the new dialog flow (open → fill
  question → submit → wait for SSE → respond)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-28 13:06:01 +02:00
co-authored by Claude Sonnet 4.6
parent 3ecfed5d3d
commit 544882f95b
9 changed files with 547 additions and 22 deletions
+69
View File
@@ -0,0 +1,69 @@
// frontend/src/shell/SteerInput.test.tsx
import { render, screen, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { http, HttpResponse } from "msw";
import { server } from "../test/msw";
import { SteerInput } from "./SteerInput";
beforeEach(() => {
server.use(
http.post("http://localhost:8787/sessions/:id/steer", () =>
new HttpResponse(null, { status: 204 }),
),
);
});
test("renders a text input and submit button", () => {
render(<SteerInput sessionId="s1" />);
expect(screen.getByRole("textbox")).toBeInTheDocument();
expect(screen.getByRole("button", { name: /invia|send|steer/i })).toBeInTheDocument();
});
test("submitting typed text POSTs to /steer and clears the input", async () => {
let captured: unknown = null;
server.use(
http.post("http://localhost:8787/sessions/:id/steer", async ({ request, params }) => {
captured = { id: params.id, body: await request.json() };
return new HttpResponse(null, { status: 204 });
}),
);
render(<SteerInput sessionId="s1" />);
const input = screen.getByRole("textbox");
await userEvent.type(input, "redirect to plan B");
await userEvent.click(screen.getByRole("button", { name: /invia|send|steer/i }));
await waitFor(() => {
expect(captured).toEqual({ id: "s1", body: { text: "redirect to plan B" } });
});
expect(input).toHaveValue("");
});
test("pressing Enter in the input submits the steer", async () => {
let captured: unknown = null;
server.use(
http.post("http://localhost:8787/sessions/:id/steer", async ({ request }) => {
captured = await request.json();
return new HttpResponse(null, { status: 204 });
}),
);
render(<SteerInput sessionId="s1" />);
const input = screen.getByRole("textbox");
await userEvent.type(input, "use approach X{Enter}");
await waitFor(() => {
expect(captured).toEqual({ text: "use approach X" });
});
});
test("does not POST when input is empty", async () => {
let called = false;
server.use(
http.post("http://localhost:8787/sessions/:id/steer", () => {
called = true;
return new HttpResponse(null, { status: 204 });
}),
);
render(<SteerInput sessionId="s1" />);
await userEvent.click(screen.getByRole("button", { name: /invia|send|steer/i }));
// small wait to ensure the call didn't go through
await new Promise((r) => setTimeout(r, 50));
expect(called).toBe(false);
});