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
+18 -3
View File
@@ -1,5 +1,5 @@
// frontend/src/shell/f1-loop.test.tsx
import { render, screen } from "@testing-library/react";
import { render, screen, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { http, HttpResponse } from "msw";
import { act } from "react";
@@ -19,14 +19,29 @@ test("F1: create session -> widget via SSE -> respond -> POST /response", async
server.use(
http.post("http://localhost:8787/sessions", () => HttpResponse.json({ id: "s1" })),
http.get("http://localhost:8787/sessions", () => HttpResponse.json([])),
http.get("http://localhost:8787/workspaces", () =>
HttpResponse.json([{ name: "default", file: "default.db" }]),
),
http.get("http://localhost:8787/models", () => HttpResponse.json({ models: [] })),
http.post("http://localhost:8787/sessions/s1/response", async ({ request }) => {
responded = await request.json();
return new HttpResponse(null, { status: 204 });
}),
);
render(<App />);
await userEvent.click(screen.getByRole("button", { name: /nuova/i })); // start a session (UI affordance)
// simulate the backend emitting the F1 widget
// Open the "Nuova domanda" dialog
await userEvent.click(screen.getByRole("button", { name: /nuova/i }));
// Fill in the question and submit
const textarea = await screen.findByLabelText(/domanda/i);
await userEvent.type(textarea, "Quante vendite?");
await userEvent.click(screen.getByRole("button", { name: /^crea$/i }));
// Wait for the session to be created and SSE to connect
await waitFor(() => expect(FakeEventSource.instances).toHaveLength(1));
// Simulate the backend emitting the F1 widget
act(() =>
FakeEventSource.instances[0].emit({
type: "ui_request",