delete the batch practice-problems module (superseded by practice sessions)

Owner ruling 2026-10-04: the module is a sunk cost, retrievable from
history if ever revisited. Removed: core practice contracts + pipeline
helpers, the PracticeStore port + adapter + data dir path, server
service + API routes (sets, clusters picker, practice aborts), the
practice pages + dialog/exam/list UI, chain-table's Generate handoff,
sidebar nav, activity-dock practice rows, and the partitioner/
problemGenerator/grader model roles (BACKGROUND_MODEL_ROLES 8 → 5).

Survivors, moved to core/chains.ts (pure + browser-safe): ReasoningChain,
chainsForSelection, formatChainLine — the chain table and graph
emission still consume them.
This commit is contained in:
amosblomqvist
2026-10-04 21:34:24 +03:00
parent a2c1287415
commit 814c2ad412
50 changed files with 125 additions and 5767 deletions
+13 -49
View File
@@ -1,7 +1,7 @@
"use client";
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
import { ActivityIcon, BotIcon, FileTextIcon, GraduationCapIcon, PenToolIcon, PlayIcon, SearchIcon, SquareIcon, WaypointsIcon } from "lucide-react";
import { ActivityIcon, BotIcon, FileTextIcon, PenToolIcon, PlayIcon, SearchIcon, SquareIcon, WaypointsIcon } from "lucide-react";
import { cn } from "@/lib/utils";
import type { CallUsage, JobKind, JobRecord } from "@/src/core";
import { isModelsRefusal, isProviderKeyRefusal, jobCost } from "@/src/core";
@@ -65,24 +65,9 @@ export interface FeedExtraction {
startedAt: number;
}
/** A live practice row — per-problem (owner ruling, 2026-09-29),
* matching the extraction per-chunk pattern. id is the ROW KEY
* (setId:partition | setId:gen:pid | setId:grade:pid) — the abort
* seam is row-keyed; the label carries the i/N. */
export interface FeedPractice {
id: string;
kind: "generation" | "grading";
title: string;
phase: string;
startedAt: number;
problemIndex?: number;
problemTotal?: number;
}
export interface ActivityFeed {
jobs: FeedJob[];
extractions: FeedExtraction[];
practice?: FeedPractice[];
}
const EMPTY_FEED: ActivityFeed = { jobs: [], extractions: [] };
@@ -98,12 +83,12 @@ const ActivityContext = createContext<{ feed: ActivityFeed; refresh: () => void
* THE ACTIVITY FEED, PUSH-DRIVEN (architecture S5, 2026-10-02): the
* adaptive poll is RETIRED — the dock refetches exactly when truth moves.
* Every cause is announced on the events channel: extraction phase
* transitions and practice rows (activity-changed), job writes
* transitions (activity-changed), job writes
* (jobs-changed — the running-jobs blobs), and channel resync (reconnect /
* dev-restart catch-up) — plus the one client-local cause that predates
* the channel: visibility, a tab becoming visible refetches at once.
* Announced fetches ride a 250ms trailing debounce (extraction phases and
* practice progress burst); resync and visibility are immediate. A failed
* Announced fetches ride a 250ms trailing debounce (extraction phase
* bursts); resync and visibility are immediate. A failed
* fetch keeps the last feed (the dock never flickers to empty on a blip).
*/
export function ActivityProvider({ children }: { children: React.ReactNode }) {
@@ -122,7 +107,7 @@ export function ActivityProvider({ children }: { children: React.ReactNode }) {
if (res.ok) {
const data = (await res.json()) as Partial<ActivityFeed>;
if (alive)
setFeed({ jobs: data.jobs ?? [], extractions: data.extractions ?? [], practice: data.practice ?? [] });
setFeed({ jobs: data.jobs ?? [], extractions: data.extractions ?? [] });
}
} catch {
// transport blip: keep the last feed, announce again next event
@@ -177,18 +162,14 @@ export function useActivity(): { feed: ActivityFeed; refresh: () => void } {
// ─── Pure presentation helpers (exported for tests) ──────────────────────────
/** One dock blob: the unified view of a job, an extraction run, or a
* practice run. */
/** One dock blob: the unified view of a job or an extraction run. */
export interface ActivityBlob {
/** job.id, the extraction job's row id (source id, or "src#i" for
* chunk jobs — unique per row, per-chunk jobs owner 2026-09-28), or
* the practice SET id (the abort seam is set-keyed). */
/** job.id, or the extraction job's row id (source id, or "src#i" for
* chunk jobs — unique per row, per-chunk jobs owner 2026-09-28). */
id: string;
process: "job" | "extraction" | "practice";
/** Sub-agent kind for jobs (extraction/practice blobs have none). */
process: "job" | "extraction";
/** Sub-agent kind for jobs (extraction blobs have none). */
jobKind?: JobKind;
/** Practice run kind (generation | grading) — practice blobs only. */
practiceKind?: "generation" | "grading";
/** Extraction phase (extracting/auditing/merging/embedding); jobs carry none. */
phase?: string;
title: string;
@@ -269,20 +250,6 @@ export function toBlobs(feed: ActivityFeed): ActivityBlob[] {
activity: "",
});
}
for (const run of feed.practice ?? []) {
blobs.push({
id: run.id, // the ROW key — practice abort is row-keyed
process: "practice",
practiceKind: run.kind,
phase: run.phase,
title: run.title,
chatId: "", // practice is not chat-scoped
startedAt: run.startedAt,
cost: null, // practice runs ride no live cost channel (v1)
context: null,
activity: "",
});
}
blobs.sort((a, b) => a.startedAt - b.startedAt);
return blobs;
}
@@ -346,7 +313,7 @@ export function ActivitySection({ feed: feedProp }: { feed?: ActivityFeed }) {
body: JSON.stringify({
kind: blob.process,
// Extractions abort by SOURCE id (chatId) — chunk rows share one
// source and die together; practice aborts by SET id (blob.id).
// source and die together.
id: blob.process === "extraction" ? blob.chatId : blob.id,
}),
});
@@ -420,14 +387,11 @@ function ActivityBlobRow({
abortState: AbortState | undefined;
onAbort: () => void;
}) {
const Icon =
blob.process === "extraction" ? WaypointsIcon : blob.process === "practice" ? GraduationCapIcon : (blob.jobKind && KIND_ICON[blob.jobKind]) || BotIcon;
const Icon = blob.process === "extraction" ? WaypointsIcon : (blob.jobKind && KIND_ICON[blob.jobKind]) || BotIcon;
const label =
blob.process === "extraction"
? `Extraction — ${blob.phase ?? "running"}`
: blob.process === "practice"
? `Practice — ${blob.phase ?? "running"}`
: blob.jobKind === "research"
: blob.jobKind === "research"
? "Researcher"
: blob.jobKind === "demo"
? "Demo builder"
+7 -28
View File
@@ -40,7 +40,7 @@
* the Google-Photos pattern — appears only when something is selected,
* showing the agents' ACTUAL input (chainsForSelection over the flat
* node-id selection: a premise without its conclusion counts as the
* singleton it becomes) + Clear + Generate problem set. DELETE (owner,
* singleton it becomes) + Clear. DELETE (owner,
* 2026-09-29 night: "this is really the view deletion should be done
* in") rides the same bar FENCED at the right end — divider + the
* destructive red pair — and opens the SAME full-death confirm dialog
@@ -51,8 +51,7 @@
* auto-expanded under their clusters (non-matching clusters hide; the
* collapsed view returns on clear).
*
* Read-only toward the graph. Named neutrally (ChainTable, not
* Practice*) — only the Generate handoff knows about practice.
* Read-only toward the graph.
*/
import { useEffect, useMemo, useState } from "react";
@@ -70,7 +69,6 @@ import {
import { chainsForSelection, formatChainLine, fuzzyScore } from "@/src/core";
import type { GraphChain, GraphNode } from "@/src/core";
import { TopBar } from "@/components/top-bar";
import { PracticeDialog } from "@/components/practice-dialog";
import { DeleteNodeDialog } from "@/components/delete-node-dialog";
import { LatexGlyph } from "@/components/latex-glyph";
@@ -113,7 +111,6 @@ export function ChainTableBody({
onToggleChain,
onToggleNodes,
onClear,
onGenerate,
onDelete,
onClose,
}: {
@@ -134,7 +131,6 @@ export function ChainTableBody({
* proposition checks all reduce to this. */
onToggleNodes: (ids: string[], next: boolean) => void;
onClear: () => void;
onGenerate: () => void;
/** Opens the full-death confirm dialog (owner, 2026-09-29 night). */
onDelete: () => void;
onClose: () => void;
@@ -235,7 +231,7 @@ export function ChainTableBody({
<div data-testid="chain-table" className="relative flex h-full min-h-0 flex-col">
{/* THE shared top bar (standardization ruling): title at the standard
size, drag mechanics, sidebar reopen, traffic-light gutter — the
same element as every chat/practice surface. Search + close
same element as every chat surface. Search + close
carve out with lh-no-drag (the mask law: later in the DOM). */}
<TopBar>
<span className="min-w-0 flex-1 truncate font-title text-3xl tracking-tight">Chains</span>
@@ -498,15 +494,7 @@ export function ChainTableBody({
>
Clear
</button>
<button
type="button"
data-testid="chain-generate"
onClick={onGenerate}
className="rounded-full bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90"
>
Generate problem set
</button>
{/* The danger fence (owner ruling): a divider quarantines
{/* The danger fence (owner ruling): a divider quarantines
the destructive action at the bar's right end — the
safe actions and the kill switch never blend. The
full-death confirm dialog catches the misclick. */}
@@ -576,7 +564,7 @@ function RowCheckbox({
}
/** The graph view's overlay wrapper: owns query + sort + selection +
* expansion + the custom practice dialog; mounts ABSOLUTE INSIDE the
* expansion; mounts ABSOLUTE INSIDE the
* graph area, full-bleed (owner ruling: the translucent blurred surface
* IS the overlay — no inner card). Esc + the top-bar X dismiss (there
* is no backdrop margin to click anymore). Read-only toward the graph. */
@@ -600,19 +588,18 @@ export function ChainTableOverlay({
const [selection, setSelection] = useState<ReadonlySet<string>>(() => new Set());
const [expandedClusters, setExpandedClusters] = useState<ReadonlySet<string>>(() => new Set());
const [expandedChains, setExpandedChains] = useState<ReadonlySet<string>>(() => new Set());
const [dialogOpen, setDialogOpen] = useState(false);
const [deleteOpen, setDeleteOpen] = useState(false);
// Esc dismisses (unless a dialog has focus — each dialog's own Esc
// owns its layer; all listen on window, so the guards are explicit).
useEffect(() => {
if (!open || dialogOpen || deleteOpen) return;
if (!open || deleteOpen) return;
const onKeyDown = (e: KeyboardEvent) => {
if (e.key === "Escape") onClose();
};
window.addEventListener("keydown", onKeyDown);
return () => window.removeEventListener("keydown", onKeyDown);
}, [open, dialogOpen, deleteOpen, onClose]);
}, [open, deleteOpen, onClose]);
if (!open) return null;
@@ -665,18 +652,10 @@ export function ChainTableOverlay({
onToggleChain={(id) => setExpandedChains((prev) => toggleIn(prev, id))}
onToggleNodes={toggleNodes}
onClear={() => setSelection(new Set())}
onGenerate={() => setDialogOpen(true)}
onDelete={() => setDeleteOpen(true)}
onClose={onClose}
/>
</div>
{dialogOpen && (
<PracticeDialog
mode="custom"
selection={{ nodeIds, propositions: selectedNodes.length, chains: derived.length }}
onClose={() => setDialogOpen(false)}
/>
)}
{deleteOpen && (
<DeleteNodeDialog
nodes={selectedNodes.map((n) => ({ id: n.id, name: n.name }))}
+4 -5
View File
@@ -880,12 +880,11 @@ export function GraphChromeRow({
)}
</div>
)}
{/* The chain table (chains overlay, owner plan 2026-09-29) — the
graph's free-form practice entry. Own container (36px band),
between the search and Import. */}
{/* The chain table (chains overlay, owner plan 2026-09-29). Own
container (36px band), between the search and Import. */}
{!isEmpty && (
<div className="graph-chrome-fade-in shrink-0 rounded-xl border bg-card/85 px-1 py-[3px] shadow-lg backdrop-blur">
<Hint label="Every reasoning chain, selectable for practice" side="bottom">
<Hint label="Every reasoning chain" side="bottom">
<button
type="button"
onClick={onOpenChains}
@@ -1664,7 +1663,7 @@ export function GraphView() {
ABSOLUTE INSIDE the graph area (the session-overlay idiom —
never a body portal) so the app chrome stays sharp and
reachable; the overlay itself is read-only toward the graph
and owns its selection + the custom practice dialog.
and owns its selection.
LAST CHILD OF THE ROOT, DELIBERATELY (owner, 2026-09-29
night): app-region subtraction resolves by DOM order, not
z-index — mounted earlier, the chrome's lh-no-drag column
-466
View File
@@ -1,466 +0,0 @@
"use client";
/**
* The problem-set creation dialog (practice slice 5, 2026-09-29;
* cluster-picker + discretized-axes fixes same evening): the three
* NAMED-LEVEL parameters — a 5-detent ladder slider, a 3-detent cue
* slider, a Theory|Application toggle — + the CLUSTER picker → POST
* /api/practice/sets → router.push to the new exam page. In the
* delete-session dialog's shape (portaled z-50, pure body exported for
* SSR pins).
*
* GRAPH-DOMAIN, NOT CHAT-DOMAIN (owner ruling 2026-09-29): problem sets
* take NODES. The picker lists the birth-session clusters the graph
* view renders (GET /api/graph/clusters); picking one resolves to its
* member node ids, and the cluster's label rides along as the set's
* title. This dialog is the ONLY creation entry for now — the graph-view
* cluster entry comes later with the free-form selection UI.
*
* Honest failures inline: 400 empty_selection (the vanished-nodes edge
* — the cluster's propositions are gone) renders the honest line;
* 503 (models/key refusal) renders the server's line + an "Open
* settings" deep link (the zero-keys precedent — setup owns the fix,
* the dialog owns the pointer).
*/
import { useCallback, useEffect, useState } from "react";
import { createPortal } from "react-dom";
import { useRouter } from "next/navigation";
import { useSettingsDialog } from "@/components/settings/settings-dialog";
import { CUE_LEVELS, LADDER_RUNGS, PRESENTATIONS } from "@/src/core";
import type { GraphClusterGroup, PracticeParams } from "@/src/core";
/** The creation defaults (owner, 2026-09-29): rung 2 Direct exercise,
* cue 1 Adjacent context, Theory. */
export const DEFAULT_PRACTICE_PARAMS: PracticeParams = {
ladderRung: 2,
cueDistance: 1,
presentation: "theory",
};
/** The two creation modes (chains overlay, owner plan 2026-09-29):
* "cluster" — the /practice page's picker (stays cluster-ONLY, owner
* ruling 2026-09-29); "custom" — the graph view's chain table hands in
* a free-form node selection; no picker, a selection summary instead. */
export type PracticeDialogMode = "cluster" | "custom";
/** The custom mode's handoff: the flat node-id selection + the derived
* shape (chainsForSelection over the selection — the overlay computes
* it for its pinned preview and passes the same numbers here). */
export interface PracticeSelection {
nodeIds: string[];
propositions: number;
chains: number;
}
export interface PracticeFailure {
status: number;
error: string;
code?: string;
}
/** The dialog's pure body — exported for SSR pins (the delete-session /
* settings body pattern). The wrapper owns state + fetch + portal. */
export function PracticeDialogBody({
mode = "cluster",
params,
onParam,
note,
onNote,
clusters,
selectedKey,
onSelect,
selection,
busy,
failure,
onOpenSettings,
onClose,
onRun,
}: {
mode?: PracticeDialogMode;
params: PracticeParams;
onParam: (patch: Partial<PracticeParams>) => void;
/** The learner's free-form note (owner, 2026-09-29) — optional,
* typing-only; carried to the partitioner + generators as additional
* input they weigh but need not follow. */
note: string;
onNote: (note: string) => void;
clusters: GraphClusterGroup[];
selectedKey: string | null;
onSelect: (key: string) => void;
/** The custom mode's handoff (chain-table selections). */
selection?: PracticeSelection;
busy: boolean;
failure: PracticeFailure | null;
onOpenSettings: () => void;
onClose: () => void;
onRun: () => void;
}) {
const canRun = !busy && (mode === "custom" ? (selection?.nodeIds.length ?? 0) > 0 : selectedKey !== null);
return (
<div
role="dialog"
aria-modal="true"
aria-label="New problem set"
data-testid="practice-dialog"
onClick={(e) => e.stopPropagation()}
className="flex max-h-[85vh] w-[32rem] max-w-[calc(100vw-2rem)] flex-col rounded-xl border bg-card p-5 shadow-xl"
>
<h2 className="font-title text-2xl tracking-tight">New problem set</h2>
{/* The cluster picker — CLUSTER mode only (custom mode replaces
it with the selection summary below): a birth-session group of
the graph, resolved to node ids on create (graph-domain, owner
2026-09-29). */}
{mode === "cluster" && (
<div className="mt-4 flex flex-col gap-1">
<span className="text-xs uppercase tracking-widest text-muted-foreground/70">
Cluster
</span>
<div
className="max-h-40 overflow-y-auto rounded-lg border"
data-testid="practice-dialog-clusters"
>
{clusters.map((cluster) => (
<button
type="button"
key={cluster.key}
data-testid={`practice-cluster-${cluster.key}`}
onClick={() => onSelect(cluster.key)}
className={`flex w-full items-center justify-between gap-3 px-3 py-2 text-left text-sm transition-colors hover:bg-accent ${
selectedKey === cluster.key ? "bg-accent" : ""
}`}
>
<span className="min-w-0 truncate">
{cluster.label ?? (
<span className="text-muted-foreground/60">
unlabeled cluster
</span>
)}
</span>
<span className="shrink-0 text-xs tabular-nums text-muted-foreground">
{cluster.kind === "notes" ? "notes · " : ""}
{cluster.nodeCount} {cluster.nodeCount === 1 ? "node" : "nodes"}
</span>
</button>
))}
{clusters.length === 0 && (
<div className="px-3 py-2 text-sm text-muted-foreground">
No clusters yet — a cluster appears once a session births its
first node.
</div>
)}
</div>
</div>
)}
{/* CUSTOM mode: no picker — the chain table already chose. The
dated default title (the pipeline's own `Practice — date`,
stamped server-side when no title is posted) + the derived
shape of the handoff. */}
{mode === "custom" && (
<div className="mt-4 flex flex-col gap-1" data-testid="practice-dialog-selection">
<span className="text-xs uppercase tracking-widest text-muted-foreground/70">
Selection
</span>
<div className="rounded-lg border bg-accent/30 px-3 py-2 text-sm">
<div className="text-muted-foreground">Practice — {new Date().toISOString().slice(0, 10)}</div>
<div data-testid="practice-dialog-selection-line">
{selection?.propositions ?? 0} {selection?.propositions === 1 ? "node" : "nodes"} →{" "}
{selection?.chains ?? 0} {selection?.chains === 1 ? "chain" : "chains"}
</div>
</div>
</div>
)}
{/* The three parameters — named levels, never a number to
interpolate (owner, 2026-09-29). Stepped sliders snap to the
detents; each shows the level's NAME + its one-line
definition; presentation is a two-segment toggle. */}
<div className="mt-4 flex flex-col gap-3">
<div className="flex flex-col gap-1">
<span className="flex items-center justify-between text-[11px] text-muted-foreground">
Ladder
<span className="text-muted-foreground/80">0 · 1 · 2 · 3 · 4</span>
</span>
<input
type="range"
min={0}
max={4}
step={1}
value={params.ladderRung}
data-testid="param-ladder"
onChange={(e) =>
onParam({
ladderRung: Number(
e.target.value,
) as PracticeParams["ladderRung"],
})
}
className="h-1.5 w-full accent-primary"
/>
<span data-testid="param-ladder-level" className="text-xs">
<span className="font-medium">
{LADDER_RUNGS[params.ladderRung].name}
</span>
<span className="text-muted-foreground">
{" "}
— {LADDER_RUNGS[params.ladderRung].definition}
</span>
</span>
</div>
<div className="flex flex-col gap-1">
<span className="flex items-center justify-between text-[11px] text-muted-foreground">
Cue distance
<span className="text-muted-foreground/80">0 · 1 · 2</span>
</span>
<input
type="range"
min={0}
max={2}
step={1}
value={params.cueDistance}
data-testid="param-cue"
onChange={(e) =>
onParam({
cueDistance: Number(
e.target.value,
) as PracticeParams["cueDistance"],
})
}
className="h-1.5 w-full accent-primary"
/>
<span data-testid="param-cue-level" className="text-xs">
<span className="font-medium">
{CUE_LEVELS[params.cueDistance].name}
</span>
<span className="text-muted-foreground">
{" "}
— {CUE_LEVELS[params.cueDistance].definition}
</span>
</span>
</div>
<div className="flex flex-col gap-1">
<span className="text-[11px] text-muted-foreground">
Presentation
</span>
<div className="flex gap-1" data-testid="param-presentation">
{(["theory", "application"] as const).map((pres) => (
<button
type="button"
key={pres}
data-testid={`param-presentation-${pres}`}
onClick={() => onParam({ presentation: pres })}
className={`flex-1 rounded-md border px-3 py-1.5 text-xs transition-colors ${
params.presentation === pres
? "border-primary bg-primary/10 font-medium text-foreground"
: "text-muted-foreground hover:bg-accent"
}`}
>
{PRESENTATIONS[pres].name}
</button>
))}
</div>
<span
data-testid="param-presentation-level"
className="text-xs text-muted-foreground"
>
{PRESENTATIONS[params.presentation].definition}
</span>
</div>
{/* The learner's free-form note — the last word before create:
wishes for the problems, weighed by the agents, nothing owed. */}
<div className="flex flex-col gap-1">
<span className="text-[11px] text-muted-foreground">
Anything else? (optional)
</span>
<textarea
value={note}
data-testid="practice-note"
onChange={(e) => onNote(e.target.value)}
rows={3}
maxLength={2000}
placeholder="Anything you want the problems to lean toward — situations, emphasis, context about you. The agents weigh it; nothing is promised."
className="w-full resize-y rounded-lg border bg-background px-3 py-2 text-sm outline-none focus-visible:ring-1 focus-visible:ring-ring"
/>
</div>
</div>
{failure && (
<div
data-testid="practice-dialog-error"
className="mt-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive"
>
{failure.code === "empty_selection"
? "Nothing practicable is left in that cluster — the graph changed."
: failure.error}
{failure.status === 503 && (
<button
type="button"
data-testid="practice-dialog-open-settings"
onClick={onOpenSettings}
className="ml-2 underline underline-offset-2"
>
Open settings
</button>
)}
</div>
)}
<div className="mt-5 flex justify-end gap-2">
<button
type="button"
onClick={onClose}
disabled={busy}
className="rounded-md px-3 py-1.5 text-sm text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"
>
Cancel
</button>
<button
type="button"
data-testid="practice-dialog-create"
onClick={onRun}
disabled={!canRun}
className="rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-40"
>
{busy ? "Creating…" : "Create"}
</button>
</div>
</div>
);
}
/** The stateful wrapper: fetches the cluster list, runs the create POST
* (nodeIds + the cluster's label as title + params), navigates on 202. */
export function PracticeDialog({
mode = "cluster",
selection,
onClose,
}: {
mode?: PracticeDialogMode;
selection?: PracticeSelection;
onClose: () => void;
}) {
const router = useRouter();
const { open: openSettings } = useSettingsDialog();
const [params, setParams] = useState<PracticeParams>({
...DEFAULT_PRACTICE_PARAMS,
});
const [note, setNote] = useState("");
const [clusters, setClusters] = useState<GraphClusterGroup[] | null>(null);
const [selectedKey, setSelectedKey] = useState<string | null>(null);
const [busy, setBusy] = useState(false);
const [failure, setFailure] = useState<PracticeFailure | null>(null);
// The picker's truth is the graph's clustering (fresh on open).
// The picker's truth is the graph's clustering (fresh on open) —
// cluster mode only; custom mode arrives with its selection in hand.
useEffect(() => {
if (mode !== "cluster") return;
let alive = true;
fetch("/api/graph/clusters", { cache: "no-store" })
.then((res) => res.json() as Promise<{ clusters: GraphClusterGroup[] }>)
.then((d) => {
if (alive) setClusters(d.clusters);
})
.catch(() => {
if (alive) setClusters([]);
});
return () => {
alive = false;
};
}, []);
// Esc closes (claimed, the delete-session discipline).
useEffect(() => {
const onKeyDown = (e: KeyboardEvent) => {
if (e.key === "Escape") {
e.stopPropagation();
onClose();
}
};
window.addEventListener("keydown", onKeyDown);
return () => window.removeEventListener("keydown", onKeyDown);
}, [onClose]);
const run = useCallback(async () => {
if (busy) return;
// The POST payload, by mode: custom mode sends the chain table's
// nodeIds with NO title (the pipeline stamps its dated default);
// cluster mode resolves the group + posts its label as title.
let postNodeIds: string[];
let postTitle: string | undefined;
if (mode === "custom") {
if (!selection || selection.nodeIds.length === 0) return;
postNodeIds = selection.nodeIds;
postTitle = undefined;
} else {
const picked = (clusters ?? []).find((c) => c.key === selectedKey);
if (!picked) return;
postNodeIds = picked.nodeIds;
postTitle = picked.label ?? undefined;
}
setBusy(true);
setFailure(null);
try {
const res = await fetch("/api/practice/sets", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
nodeIds: postNodeIds,
params,
title: postTitle,
note: note.trim() || undefined,
}),
});
const body = (await res.json()) as {
id?: string;
error?: string;
code?: string;
};
if (!res.ok || !body.id) {
setFailure({
status: res.status,
error: body.error ?? `Create failed (${res.status})`,
code: body.code,
});
setBusy(false);
return;
}
router.push(`/practice/${body.id}`);
} catch {
setFailure({
status: 0,
error: "Create failed — network error. Try again.",
});
setBusy(false);
}
}, [mode, selection, clusters, selectedKey, busy, params, note, router]);
return createPortal(
<div
className="fixed inset-0 z-50 flex items-center justify-center bg-background/80"
onClick={() => {
if (!busy) onClose();
}}
>
<PracticeDialogBody
mode={mode}
params={params}
selection={selection}
onParam={(patch) => setParams((prev) => ({ ...prev, ...patch }))}
note={note}
onNote={setNote}
clusters={clusters ?? []}
selectedKey={selectedKey}
onSelect={setSelectedKey}
busy={busy}
failure={failure}
onOpenSettings={() => openSettings()}
onClose={onClose}
onRun={() => void run()}
/>
</div>,
document.body,
);
}
-445
View File
@@ -1,445 +0,0 @@
"use client";
/**
* The exam page (practice slice 5, one-attempt redesign 2026-09-29):
* one problem set, numbered problems, markdown statements, a textarea +
* dictation per problem (the bar renders only on the FOCUSED box —
* thinking out loud is the primary answering mode). ONE ATTEMPT: each
* problem has its OWN submit button; once submitted the box locks and
* the MODEL SOLUTION reveals instantly (rubric collapsed by default).
* The grade (score 0–10 + brief reasoning) lands via the events channel and
* updates live — no reload.
*
* TOP BAR (owner, UI round 2026-09-29): the chat pattern — an h-15
* lh-drag header in flow above the scroller, the sidebar reopen toggle
* first (it clears the traffic lights via .lh-closed-toggle), the set
* title truncating beside it. The levels + status stay in the body.
*
* DISPLAY-SEAM MATH HEALING: statements/solutions/rubrics/reasoning ride
* the same streaming-args parse as quiz/ask strings — restoreMathEscapes
* heals them at render (the same helper the tool-part seam uses).
*
* POLLING: 2s while the set isn't ready (stubs → filled), and while a
* grading run is live for this set (activity feed practice rows are
* keyed setId:grade:problemId — the LIVE rows name exactly which
* problems' grades are pending). A settled page goes quiet; a dropped
* grade shows "grade interrupted" honestly.
*/
import { useCallback, useEffect, useRef, useState } from "react";
import { useServerEvent, useServerResync } from "@/components/server-events";
import type { Problem, ProblemSet } from "@/src/core";
import { CUE_LEVELS, LADDER_RUNGS, PRESENTATIONS } from "@/src/core";
import { restoreMathEscapes } from "@/src/core";
import { MessageResponse } from "@/components/ai-elements/message";
import { TopBar } from "@/components/top-bar";
import { BrailleSpinner } from "@/components/braille-spinner";
import { DictationBar, useDictation } from "@/components/dictation";
/** One answerable problem: textarea + focus-gated dictation bar. */
export function ProblemBox({
problem,
draft,
onDraft,
}: {
problem: Pick<Problem, "id">;
draft: string;
onDraft: (text: string) => void;
}) {
const [focused, setFocused] = useState(false);
// The dictation appends into THIS box only (per-box instance).
const dictation = useDictation({
append: (text) => onDraft(text),
});
return (
<div
className="flex flex-col gap-1.5"
data-testid={`problem-box-${problem.id}`}
>
<textarea
data-testid={`answer-${problem.id}`}
value={draft}
rows={5}
placeholder="Think out loud — dictation or typing, both fine."
onChange={(e) => onDraft(e.target.value)}
onFocus={() => setFocused(true)}
onBlur={() => setFocused(false)}
className="w-full resize-y rounded-lg border bg-background px-3 py-2 text-sm outline-none focus-visible:ring-1 focus-visible:ring-ring"
/>
{focused && <DictationBar dictation={dictation} />}
</div>
);
}
/** The exam page's pure body — exported for SSR pins. */
export function PracticeExamBody({
set,
drafts,
onDraft,
onSubmit,
submittingId,
submitErrors,
liveGradeIds,
}: {
set: ProblemSet;
drafts: Record<string, string>;
onDraft: (problemId: string, text: string) => void;
/** Per-problem submit (owner 2026-09-29): ONE attempt per problem. */
onSubmit: (problemId: string) => void;
/** The problem whose submit POST is in flight. */
submittingId: string | null;
/** Per-problem submit failures, keyed by problem id. */
submitErrors: Record<string, string>;
/** Problems whose grade rows are LIVE (the activity feed read). */
liveGradeIds: ReadonlySet<string>;
}) {
return (
<div className="flex h-dvh">
<div className="flex min-w-0 flex-1 flex-col">
{/* The top bar (owner, UI round 2026-09-29): the new-session
pattern — h-15, lh-drag (the Electron window-drag surface, so
the traffic lights never cover content), the sidebar reopen
toggle first, the set title truncating beside it. */}
<TopBar>
<div
className="min-w-0 flex-1 truncate font-title text-3xl tracking-tight"
data-testid="practice-exam-title"
>
{set.title}
</div>
</TopBar>
<div className="relative flex min-h-0 flex-1">
<div
className="h-full min-w-0 flex-1 overflow-y-auto"
data-testid="practice-exam-scroll"
>
<div
className="mx-auto flex w-full max-w-3xl flex-col gap-6 p-6"
data-testid="practice-exam"
>
<div className="flex flex-col gap-1">
<p
className="text-xs text-muted-foreground/80"
data-testid="practice-exam-levels"
>
{LADDER_RUNGS[set.params.ladderRung].name} ·{" "}
{CUE_LEVELS[set.params.cueDistance].name} ·{" "}
{PRESENTATIONS[set.params.presentation].name}
</p>
<p
className="text-sm text-muted-foreground"
data-testid="practice-exam-status"
>
{set.status === "partitioning" && "Partitioning the chains…"}
{set.status === "generating" &&
`Generating — ${set.problems.filter((p) => p.status === "ready").length}/${set.problems.length} problems ready`}
{set.status === "error" &&
(set.error ?? "Something went wrong")}
{set.status === "ready" &&
(liveGradeIds.size > 0
? "Grading your answers…"
: `${set.problems.length} problems · ${set.problems.filter((p) => p.grade).length} graded`)}
</p>
</div>
{set.problems.map((problem, i) => (
<section
key={problem.id}
className="rounded-xl border bg-card p-4"
data-testid={`problem-${problem.id}`}
>
<h2 className="mb-2 text-xs font-medium uppercase tracking-wide text-muted-foreground">
Problem {i + 1}
</h2>
{problem.status === "generating" ? (
// The stub: propositions NEVER surface (never-announce law).
<div
className="flex items-center gap-2 text-sm text-muted-foreground"
data-testid={`generating-${problem.id}`}
>
<BrailleSpinner className="size-4" />
Generating problem…
</div>
) : problem.status === "error" ? (
<p
className="text-sm text-destructive"
data-testid={`problem-error-${problem.id}`}
>
This problem failed to generate
{problem.error ? ` — ${problem.error}` : ""}.
</p>
) : (
<>
<div className="lh-prose text-sm">
<MessageResponse mode="static">
{restoreMathEscapes(problem.statement)}
</MessageResponse>
</div>
{problem.answer === undefined ? (
// ANSWERABLE (owner 2026-09-29): the box + its OWN submit
// button — one attempt, submitted the moment it's clicked.
<div className="flex flex-col items-start gap-2">
<div className="w-full">
<ProblemBox
problem={problem}
draft={drafts[problem.id] ?? ""}
onDraft={(text) => onDraft(problem.id, text)}
/>
</div>
<button
type="button"
data-testid={`practice-submit-${problem.id}`}
onClick={() => onSubmit(problem.id)}
disabled={
set.status !== "ready" ||
(drafts[problem.id] ?? "").trim() === "" ||
submittingId !== null
}
className="rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:opacity-40"
>
{submittingId === problem.id
? "Submitting…"
: "Submit answer"}
</button>
{submitErrors[problem.id] && (
<p
data-testid={`practice-submit-error-${problem.id}`}
className="text-sm text-destructive"
>
{submitErrors[problem.id]}
</p>
)}
</div>
) : (
// SUBMITTED (owner 2026-09-29): the answer locks, the
// model solution reveals INSTANTLY, the rubric stays
// collapsed, and the grade lands live when it lands.
<div className="mt-4 flex flex-col gap-3">
<textarea
data-testid={`answer-${problem.id}`}
value={problem.answer}
readOnly
rows={5}
className="w-full resize-y rounded-lg border bg-muted/40 px-3 py-2 text-sm text-muted-foreground"
/>
<div
className="rounded-lg border bg-background p-3"
data-testid={`reveal-${problem.id}`}
>
{problem.grade ? (
<div className="flex flex-col gap-1.5">
<div className="flex items-baseline gap-2">
<span
data-testid={`grade-${problem.id}`}
className="font-mono text-sm font-medium"
>
{problem.grade.score}/10
</span>
</div>
<div
className="lh-prose text-sm"
data-testid={`reasoning-${problem.id}`}
>
<MessageResponse mode="static">
{restoreMathEscapes(
problem.grade.reasoning,
)}
</MessageResponse>
</div>
</div>
) : liveGradeIds.has(problem.id) ? (
<div
className="flex items-center gap-2 text-sm text-muted-foreground"
data-testid={`grading-${problem.id}`}
>
<BrailleSpinner className="size-4" />
Grading…
</div>
) : (
<p
className="text-sm text-muted-foreground"
data-testid={`grade-interrupted-${problem.id}`}
>
Grade interrupted — the answer stands.
</p>
)}
<div className="mt-3 text-xs uppercase tracking-wide text-muted-foreground">
Model solution
</div>
<div
className="lh-prose text-sm"
data-testid={`solution-${problem.id}`}
>
<MessageResponse mode="static">
{restoreMathEscapes(problem.solution)}
</MessageResponse>
</div>
<details
className="mt-3"
data-testid={`rubric-${problem.id}`}
>
<summary className="cursor-pointer select-none text-xs uppercase tracking-wide text-muted-foreground">
Rubric
</summary>
<div className="mt-2 lh-prose text-sm">
<MessageResponse mode="static">
{restoreMathEscapes(problem.rubric)}
</MessageResponse>
</div>
</details>
</div>
</div>
)}
</>
)}
</section>
))}
</div>
</div>
</div>
</div>
</div>
);
}
export function PracticeExam({ initial }: { initial: ProblemSet }) {
const [set, setSet] = useState<ProblemSet>(initial);
const [drafts, setDrafts] = useState<Record<string, string>>({});
const [submittingId, setSubmittingId] = useState<string | null>(null);
const [submitErrors, setSubmitErrors] = useState<Record<string, string>>({});
// Which problems' grade rows are LIVE (activity feed) — drives the
// per-problem "Grading…" spinners and the status line.
const [liveGradeIds, setLiveGradeIds] = useState<Set<string>>(new Set());
// True from a successful submit until the feed shows no live grade
// rows for this set — kept fresh across refetches (S7: the tick).
const mounted = useRef(true);
useEffect(() => {
mounted.current = true;
return () => {
mounted.current = false;
};
}, []);
const refetch = useCallback(async () => {
try {
const res = await fetch(`/api/practice/sets/${initial.id}`, {
cache: "no-store",
});
if (!res.ok) return;
const d = (await res.json()) as { set: ProblemSet };
if (mounted.current) setSet(d.set);
} catch {
// transient fetch failures keep the last snapshot
}
}, [initial.id]);
// PUSH (S7, 2026-10-02): the 2s grading-liveness interval is RETIRED —
// the practice registry announces every grade-row transition
// (activity-changed), and tick() reads exactly that liveness, so it
// fires when truth moved: debounced (the S4 law) + on mount + on
// resync. Ungated by design: a fresh grade registration must be seen
// even from a fully-settled page (the old needsPoll gate would have
// missed it — gradingLive fed the gate, and registration is what
// flips it). The activity feed's practice rows are ROW-KEYED
// (setId:grade:problemId) — the live rows name exactly which grades
// are pending; a dropped grade (no live row) settles the page.
const tick = useCallback(async () => {
await refetch();
try {
const res = await fetch("/api/activity", { cache: "no-store" });
if (!res.ok) return;
const feed = (await res.json()) as {
practice?: Array<{ id: string; kind: string }>;
};
if (mounted.current) {
const prefix = `${initial.id}:grade:`;
const pids = (feed.practice ?? [])
.filter((row) => row.id.startsWith(prefix))
.map((row) => row.id.slice(prefix.length));
setLiveGradeIds(new Set(pids));
}
} catch {
// keep the last liveness read
}
}, [refetch, initial.id]);
const tickRef = useRef(tick);
tickRef.current = tick;
const tickDebounceRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
useEffect(() => {
void tickRef.current();
return () => {
if (tickDebounceRef.current) clearTimeout(tickDebounceRef.current);
};
}, []);
useServerEvent("activity-changed", () => {
if (tickDebounceRef.current) clearTimeout(tickDebounceRef.current);
tickDebounceRef.current = setTimeout(() => {
tickDebounceRef.current = undefined;
void tickRef.current();
}, 250);
});
useServerResync(() => void tickRef.current());
// ONE attempt per problem (owner 2026-09-29): the submit posts THAT
// problem's answer alone; the server refuses a second submission
// forever after. On success the box locks (answer persisted) and the
// reveal shows instantly; the grade arrives via the events channel.
const submit = useCallback(
async (problemId: string) => {
if (submittingId !== null) return;
const p = set.problems.find((q) => q.id === problemId);
if (!p || p.answer !== undefined) return; // done problems never resubmit
const text = drafts[problemId] ?? "";
if (text.trim() === "") return;
setSubmittingId(problemId);
setSubmitErrors((prev) => {
const next = { ...prev };
delete next[problemId];
return next;
});
try {
const res = await fetch(`/api/practice/sets/${set.id}/answers`, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ answers: [{ problemId, text }] }),
});
if (!res.ok) {
const body = (await res.json().catch(() => ({}))) as {
error?: string;
};
setSubmitErrors((prev) => ({
...prev,
[problemId]: body.error ?? `Submit failed (${res.status})`,
}));
setSubmittingId(null);
return;
}
setSubmittingId(null);
// The grade lands via the events channel: the grade row's register
// announces activity-changed (S7), which triggers tick() above.
await refetch();
} catch {
setSubmitErrors((prev) => ({
...prev,
[problemId]: "Submit failed — network error. Try again.",
}));
setSubmittingId(null);
}
},
[submittingId, set, drafts, refetch],
);
return (
<PracticeExamBody
set={set}
drafts={drafts}
onDraft={(problemId, text) =>
setDrafts((prev) => ({ ...prev, [problemId]: text }))
}
onSubmit={(problemId) => void submit(problemId)}
submittingId={submittingId}
submitErrors={submitErrors}
liveGradeIds={liveGradeIds}
/>
);
}
-304
View File
@@ -1,304 +0,0 @@
"use client";
/**
* The problem-set list (practice slice 5): rows of sets — title, date,
* status, problem/graded counts — click through to the exam page; a
* delete affordance in the delete-session dialog's shape; "New problem
* set" opens the creation dialog. Refetches /api/practice/sets when a
* practice phase moves (events channel, S7), so statuses live-update;
* a settled list goes quiet.
*/
import { useCallback, useEffect, useRef, useState } from "react";
import { useServerEvent, useServerResync } from "@/components/server-events";
import { useRouter } from "next/navigation";
import { createPortal } from "react-dom";
import { PlusIcon, TrashIcon } from "lucide-react";
import { TopBar } from "@/components/top-bar";
import type { ProblemSet } from "@/src/core";
import { PracticeDialog } from "@/components/practice-dialog";
/** A set's status word — plain and honest, no invented progress. */
export function setStatusWord(set: Pick<ProblemSet, "status">): string {
return set.status === "partitioning"
? "partitioning"
: set.status === "generating"
? "generating"
: set.status;
}
/** The list's pure body — exported for SSR pins. Rows are buttons
* (click-through); the delete affordance is a nested icon button. */
export function PracticeListBody({
sets,
onOpen,
onDelete,
onNew,
}: {
sets: ProblemSet[];
onOpen: (id: string) => void;
onDelete: (set: ProblemSet) => void;
onNew: () => void;
}) {
return (
<div className="flex h-dvh">
<div className="flex min-w-0 flex-1 flex-col">
{/* The top bar (owner, UI round 2026-09-29): the new-session
pattern — h-15, lh-drag (the Electron window-drag surface),
the sidebar reopen toggle first, "Practice" beside it, the
page's one action at the right edge (lh-no-drag — it must
stay clickable inside the drag band). */}
<TopBar>
<div className="min-w-0 flex-1 truncate font-title text-3xl tracking-tight">
Practice
</div>
<button
type="button"
data-testid="practice-new"
onClick={onNew}
className="lh-no-drag flex shrink-0 items-center gap-1.5 rounded-md border px-3 py-1.5 text-sm transition-colors hover:bg-accent"
>
<PlusIcon className="size-3.5" />
New problem set
</button>
</TopBar>
<div className="relative flex min-h-0 flex-1">
<div
className="h-full min-w-0 flex-1 overflow-y-auto"
data-testid="practice-list-scroll"
>
<div
className="mx-auto flex w-full max-w-3xl flex-col gap-3 p-6"
data-testid="practice-list"
>
{sets.length === 0 && (
<div
className="rounded-xl border bg-card p-6 text-sm text-muted-foreground"
data-testid="practice-empty"
>
No problem sets yet — create one from a session.
</div>
)}
<div className="flex flex-col gap-2">
{sets.map((set) => {
const ready = set.problems.filter(
(p) => p.status === "ready",
).length;
const graded = set.problems.filter((p) => p.grade).length;
return (
<div key={set.id} className="flex items-stretch gap-1">
<button
type="button"
data-testid={`practice-row-${set.id}`}
onClick={() => onOpen(set.id)}
className="flex flex-1 items-center justify-between gap-4 rounded-xl border bg-card px-4 py-3 text-left transition-colors hover:bg-accent/50"
>
<span className="min-w-0">
<span className="block truncate font-medium">
{set.title}
</span>
<span className="block text-xs text-muted-foreground">
{set.createdAt.slice(0, 10)} ·{" "}
{set.problems.length > 0
? `${ready}/${set.problems.length} problems`
: "no problems yet"}
{graded > 0 ? ` · ${graded} graded` : ""}
</span>
</span>
<span
data-testid={`practice-status-${set.id}`}
className={`shrink-0 text-xs uppercase tracking-wide ${
set.status === "error"
? "text-destructive"
: "text-muted-foreground"
}`}
>
{setStatusWord(set)}
</span>
</button>
<button
type="button"
data-testid={`practice-delete-${set.id}`}
aria-label={`Delete ${set.title}`}
onClick={() => onDelete(set)}
className="flex items-center rounded-xl border px-3 text-muted-foreground/60 transition-colors hover:bg-accent hover:text-foreground"
>
<TrashIcon className="size-4" />
</button>
</div>
);
})}
</div>
</div>
</div>
</div>
</div>
</div>
);
}
/** The delete confirm — the delete-session dialog's shape (no mode
* checkbox: a set has no preserve-graph question). Pure body + portal
* wrapper. */
export function DeleteSetBody({
title,
busy,
failure,
onClose,
onRun,
}: {
title: string;
busy: boolean;
failure: string | null;
onClose: () => void;
onRun: () => void;
}) {
return (
<div
role="dialog"
aria-modal="true"
aria-label="Delete problem set"
data-testid="delete-set-dialog"
onClick={(e) => e.stopPropagation()}
className="w-[32rem] max-w-[calc(100vw-2rem)] rounded-xl border bg-card p-5 shadow-xl"
>
<h2 className="font-title text-2xl tracking-tight text-destructive">
Delete problem set?
</h2>
<p className="mt-2 font-mono text-sm">{title}</p>
<p className="mt-3 text-sm text-muted-foreground">
The set and its problems are removed. Nothing in the graph or your
sessions changes.
</p>
{failure && (
<p
data-testid="delete-set-error"
className="mt-3 text-sm text-destructive"
>
{failure}
</p>
)}
<div className="mt-5 flex justify-end gap-2">
<button
type="button"
onClick={onClose}
disabled={busy}
className="rounded-md px-3 py-1.5 text-sm text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"
>
Cancel
</button>
<button
type="button"
data-testid="delete-set-run"
onClick={onRun}
disabled={busy}
className="rounded-md bg-destructive px-3 py-1.5 text-sm font-medium text-destructive-foreground transition-colors hover:bg-destructive/90 disabled:opacity-40"
>
{busy ? "Deleting…" : "Delete"}
</button>
</div>
</div>
);
}
export function PracticeListPage({
initialSets,
}: {
initialSets: ProblemSet[];
}) {
const router = useRouter();
const [sets, setSets] = useState<ProblemSet[]>(initialSets);
const [creating, setCreating] = useState(false);
const [deleting, setDeleting] = useState<ProblemSet | null>(null);
const [deleteBusy, setDeleteBusy] = useState(false);
const [deleteFailure, setDeleteFailure] = useState<string | null>(null);
const refresh = useCallback(async () => {
try {
const res = await fetch("/api/practice/sets", { cache: "no-store" });
if (!res.ok) return;
const d = (await res.json()) as { sets: ProblemSet[] };
setSets(d.sets);
} catch {
// a transient failure keeps the last snapshot
}
}, []);
// PUSH (S7, 2026-10-02): the bounded 2s reveal poll is RETIRED — the
// practice registry announces every phase transition (register,
// generating, grading, finish) as activity-changed, so the list
// refetches exactly when a set's status moved. Debounced (the S4
// law); resync heals a reconnect; the mount read catches drift since
// the server-rendered snapshot.
const refreshRef = useRef(refresh);
refreshRef.current = refresh;
const listDebounceRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
useEffect(() => {
void refreshRef.current();
return () => {
if (listDebounceRef.current) clearTimeout(listDebounceRef.current);
};
}, []);
useServerEvent("activity-changed", () => {
if (listDebounceRef.current) clearTimeout(listDebounceRef.current);
listDebounceRef.current = setTimeout(() => {
listDebounceRef.current = undefined;
void refreshRef.current();
}, 250);
});
useServerResync(() => void refreshRef.current());
const runDelete = useCallback(async () => {
if (!deleting || deleteBusy) return;
setDeleteBusy(true);
setDeleteFailure(null);
try {
const res = await fetch(`/api/practice/sets/${deleting.id}`, {
method: "DELETE",
});
if (!res.ok) {
const body = (await res.json().catch(() => ({}))) as { error?: string };
setDeleteFailure(body.error ?? `Delete failed (${res.status})`);
setDeleteBusy(false);
return;
}
setDeleting(null);
setDeleteBusy(false);
await refresh();
} catch {
setDeleteFailure("Delete failed — network error. Try again.");
setDeleteBusy(false);
}
}, [deleting, deleteBusy, refresh]);
return (
<>
<PracticeListBody
sets={sets}
onOpen={(id) => router.push(`/practice/${id}`)}
onDelete={(set) => setDeleting(set)}
onNew={() => setCreating(true)}
/>
{creating && <PracticeDialog onClose={() => setCreating(false)} />}
{deleting &&
createPortal(
<div
className="fixed inset-0 z-50 flex items-center justify-center bg-background/80"
onClick={() => {
if (!deleteBusy) setDeleting(null);
}}
>
<DeleteSetBody
title={deleting.title}
busy={deleteBusy}
failure={deleteFailure}
onClose={() => setDeleting(null)}
onRun={() => void runDelete()}
/>
</div>,
document.body,
)}
</>
);
}
+1 -1
View File
@@ -49,7 +49,7 @@ import type { ThinkingLevel } from "@earendil-works/pi-agent-core";
/** The pickers' slot identity — same roster language as the Agent
* section's slot rows. */
const SLOT_META: Record<ModelSlotName, { label: string; roster: string }> = {
strong: { label: "Strong", roster: "Prober, teacher, practice trio" },
strong: { label: "Strong", roster: "Prober, teacher" },
cheap: { label: "Cheap", roster: "Researcher, demo builder, extractor, auditor" },
vision: { label: "Vision", roster: "Visual maker + PDF reader" },
};
+1 -16
View File
@@ -6,7 +6,7 @@ import { usePathname, useRouter } from "next/navigation";
import { MenuShell } from "@/components/menu-shell";
import { DeleteSessionDialog } from "@/components/delete-session-dialog";
import type { ChatDeleteMode } from "@/src/core";
import { GraduationCapIcon, PanelLeftCloseIcon, PanelLeftOpenIcon, PlusIcon, SearchIcon, SettingsIcon } from "lucide-react";
import { PanelLeftCloseIcon, PanelLeftOpenIcon, PlusIcon, SearchIcon, SettingsIcon } from "lucide-react";
import { ActivitySection } from "@/components/activity-dock";
import { CoverageMenuBlock } from "@/components/extraction-coverage";
import { LhMark } from "@/components/lh-mark";
@@ -655,21 +655,6 @@ function SessionsSidebar() {
<span className="sr-only">create a new session</span>
</button>
{/* Practice (slice 5, 2026-09-29): the set list's entry — the same
quiet row language as New session, active-state lit while any
/practice route is open. GraduationCapIcon to match the dock. */}
<button
type="button"
data-testid="nav-practice"
onClick={() => router.push("/practice")}
className={`mx-3 mb-1 flex items-center gap-1.5 rounded-md px-2 py-1.5 text-xs uppercase tracking-wider transition-colors hover:bg-accent hover:text-foreground ${
pathname.startsWith("/practice") ? "bg-accent text-foreground" : "text-muted-foreground"
}`}
>
<GraduationCapIcon className="size-3" />
Practice
</button>
<div className="mx-3 mb-1 flex items-center gap-2">
<span className="text-xs uppercase tracking-widest text-muted-foreground/70">Sessions</span>
<Hint label="Search sessions" action="sessions-search" side="bottom">