practice round: dead session starts, prompt laws, preamble, label unify
THE START BUG (owner report, reproduced live both kinds): new sessions (?prompt flow — practice and teach alike) sat dead until a second message, which then persisted WITHOUT the first. Root cause, proven both directions: the submit POST rode the view's consumeAbort controller; React StrictMode's simulated remount fires Diet A's unmount cleanup (model.stop()) ~8ms in and killed the POST mid-flight; the page's sentInitial guard had already flipped, so it never retried. Teach was equally broken — only unnoticed, because every teach chat in use predates the diet and practice starts are always fresh. Fix: the submit law — POSTs are not abortable by view teardown (they are ~100ms acks since Diet B and cannot starve the pool); after the ack, a consumeAbort identity check guards the stream attach. Pinned with the stop-mid-submit regression test. Live: StrictMode on, practice draft POST 200/67ms, stream attached, message persisted, problem posed. PRACTICE PROMPT (00-base): the opening rule — material arrives two ways, both first-class (picked propositions primary; free-form — topics, course material, files/PDFs — fully supported, never refused); as soon as material exists the reply poses, at most one short line before the problem call, no warm-up interview. Plus the hard law: no problem is ever conversation — every problem through the tool (no thinking field/no reveal/no verdict attaches to prose). GRAPH-CONTEXT PREAMBLE: custom markers flatten to user-role on the wire, so the old "Contextualization — the learner picked…" read like a system broadcast in the learner's voice channel. Now the bracket convention: "[Session context] — picked from the learner's knowledge map…". SIDEBAR: busy rows unify to "Working…" for both kinds (the spinner's default label included); "Practicing…"/"Teacher is working…" retired. Gates: 1490/1490, typecheck, lint. doctrine's stale doc pointer fixed.
This commit is contained in:
@@ -48,7 +48,7 @@ describe("newGraphContextMessage", () => {
|
||||
it("frames the context for the model: propositions listed, chains appended", () => {
|
||||
const m = newGraphContextMessage(PICKS, ["Modus ponens → Soundness"]);
|
||||
assert.equal(m.customType, "graph-context");
|
||||
assert.match(m.content, /Contextualization — the learner picked these propositions/);
|
||||
assert.match(m.content, /\[Session context\] — picked from the learner's knowledge map/);
|
||||
// IDS FIRST (owner round 9): every pick carries its id — the problem
|
||||
// tool's target field references these; names alone no longer.
|
||||
assert.ok(m.content.includes(`- [${PICKS[0]!.id}] Modus ponens: If P implies Q and P holds, Q holds.`));
|
||||
@@ -69,7 +69,7 @@ describe("newGraphContextMessage", () => {
|
||||
const wire = toLlmMessages([m as unknown as LhMessage] as never);
|
||||
assert.equal(wire.length, 1);
|
||||
assert.equal(wire[0]!.role, "user");
|
||||
assert.ok(String((wire[0]!.content as { text?: string }[])[0]!.text).includes("Contextualization"));
|
||||
assert.ok(String((wire[0]!.content as { text?: string }[])[0]!.text).includes("[Session context]"));
|
||||
});
|
||||
|
||||
it("projectView: a user-side data part — never a text bubble", () => {
|
||||
|
||||
@@ -67,7 +67,7 @@ describe("SessionRow", () => {
|
||||
assert.ok(html.includes("braille-frame"), "CSS-animated frames");
|
||||
assert.ok((html.match(/class="braille-frame"/g) ?? []).length === 10, "all ten frames");
|
||||
assert.ok(html.includes('data-frame="0"'), "frame 0 leads (static fallback)");
|
||||
assert.ok(html.includes("Teacher is working"), "accessible label");
|
||||
assert.ok(html.includes("Working"), "accessible label");
|
||||
assert.ok(!html.includes("bg-attention"), "no colored state fill — monochrome by design");
|
||||
});
|
||||
|
||||
@@ -77,7 +77,7 @@ describe("SessionRow", () => {
|
||||
// contract can't silently re-widen: an extraction-only "working"
|
||||
// row would be a double signal.
|
||||
const html = render(item({ busy: true, pendingQuestion: false }));
|
||||
assert.ok(html.includes("Teacher is working"), "the spinner's label names the turn, not agents");
|
||||
assert.ok(html.includes("Working"), "the spinner's label names the turn, not agents");
|
||||
});
|
||||
|
||||
it("the meta line: state replaces the count when the state is the useful fact", () => {
|
||||
@@ -87,7 +87,7 @@ describe("SessionRow", () => {
|
||||
assert.ok(!awaiting.includes("braille-spinner"), "…and the spinner stays off");
|
||||
|
||||
const working = render(item({ busy: true }));
|
||||
assert.ok(working.includes("Teacher is working…"), "working meta");
|
||||
assert.ok(working.includes("Working…"), "working meta");
|
||||
|
||||
// Owner, typography round 5: the message count is dropped — it
|
||||
// informed no decision. Idle meta is just how long ago.
|
||||
@@ -121,9 +121,10 @@ describe("timeAgo", () => {
|
||||
});
|
||||
|
||||
describe("SessionRow practice badge (practice sessions, 2026-10-04)", () => {
|
||||
it("a practice row carries the dumbbell badge and the Practicing meta while busy", () => {
|
||||
it("a practice row carries the dumbbell badge and the unified Working meta while busy (owner, 2026-10-10)", () => {
|
||||
const html = render(item({ kind: "practice", busy: true }));
|
||||
assert.match(html, /Practicing…/);
|
||||
assert.match(html, /Working…/);
|
||||
assert.doesNotMatch(html, /Practicing…/);
|
||||
assert.match(html, /aria-label="Practice session"/);
|
||||
});
|
||||
|
||||
@@ -133,9 +134,9 @@ describe("SessionRow practice badge (practice sessions, 2026-10-04)", () => {
|
||||
assert.doesNotMatch(html, /Practicing…/);
|
||||
});
|
||||
|
||||
it("busy teaching rows still say the teacher is working", () => {
|
||||
it("busy teaching rows say the same unified Working", () => {
|
||||
const html = render(item({ busy: true }));
|
||||
assert.match(html, /Teacher is working…/);
|
||||
assert.match(html, /Working…/);
|
||||
});
|
||||
|
||||
it("a practice row with a posed problem says the problem is waiting", () => {
|
||||
|
||||
@@ -593,6 +593,48 @@ describe("resumeStream (the reattach path)", () => {
|
||||
assert.equal(m.getState().status, "ready");
|
||||
});
|
||||
|
||||
it("SESSION START SURVIVES A STOP() RACING THE SUBMIT (owner, 2026-10-10 — the dead-practice-start postmortem)", async () => {
|
||||
// React StrictMode's simulated remount fires the unmount cleanup
|
||||
// (~8ms in) while the ?prompt first send's POST is in flight — the
|
||||
// exact live repro: pre-fix, the POST rode consumeAbort and died
|
||||
// with AbortError, the page's sentInitial guard never retried, and
|
||||
// the session sat dead until a second message (which then persisted
|
||||
// WITHOUT the first). The law: submits are not abortable by view
|
||||
// teardown — the POST completes, the turn is server-side, and the
|
||||
// dead view attaches no stream.
|
||||
let resolvePost!: () => void;
|
||||
let postAborted = false;
|
||||
const fetches: string[] = [];
|
||||
globalThis.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => {
|
||||
const url = String(input);
|
||||
fetches.push(url);
|
||||
if (url === "/api/chat") {
|
||||
init?.signal?.addEventListener("abort", () => {
|
||||
postAborted = true;
|
||||
});
|
||||
await new Promise<void>((r) => {
|
||||
resolvePost = () => r();
|
||||
});
|
||||
return Response.json({ ok: true });
|
||||
}
|
||||
if (url === "/api/chats/chat_x") {
|
||||
return Response.json({ messages: [{ id: "u1", role: "user", content: "quiz me", timestamp: 1 }] });
|
||||
}
|
||||
if (url === "/api/chats/chat_x/stream") return new Response("data: [DONE]\n\n", { status: 200 });
|
||||
throw new Error(`unexpected fetch: ${url}`);
|
||||
}) as typeof globalThis.fetch;
|
||||
const m = model();
|
||||
const sending = m.send({ type: "text", text: "quiz me" });
|
||||
await new Promise((r) => setTimeout(r, 5)); // the POST is in flight
|
||||
m.stop(); // StrictMode's simulated unmount lands mid-submit
|
||||
resolvePost(); // the ack completes anyway
|
||||
await sending;
|
||||
assert.equal(postAborted, false, "the submit POST carries no teardown signal at all");
|
||||
assert.ok(fetches.includes("/api/chat"), "the submit reached the server");
|
||||
assert.ok(!fetches.some((u) => u.endsWith("/stream")), "a dead view attaches no stream — the turn is server-side");
|
||||
assert.equal(m.getState().status, "ready");
|
||||
});
|
||||
|
||||
it("REATTACH REPLAYS ONTO A CLEAN SLATE (owner, optimistic round 3): an aborted attempt's partials never double", async () => {
|
||||
// StrictMode's simulated remount aborts the first resume mid-replay;
|
||||
// its partial tail survived into the retry and the replay DOUBLED
|
||||
|
||||
Reference in New Issue
Block a user