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:
@@ -36,7 +36,7 @@ export const SPINNER_FRAMES = FRAMES.length;
|
||||
|
||||
export function BrailleSpinner({
|
||||
className,
|
||||
label = "Teacher is working",
|
||||
label = "Working",
|
||||
}: {
|
||||
/** Sizing/position classes; height drives the scale (width is the cell's 1:2 aspect). */
|
||||
className?: string;
|
||||
|
||||
@@ -561,8 +561,19 @@ export class SessionModel {
|
||||
this.tail = [...this.tail, ...optimistic];
|
||||
});
|
||||
try {
|
||||
const res = await this.postInputEvent(input, controller.signal);
|
||||
if (controller.signal.aborted) return;
|
||||
// SUBMITS ARE NOT ABORTABLE BY VIEW TEARDOWN (owner, 2026-10-10 —
|
||||
// the dead-session-start postmortem): the POST must NOT ride
|
||||
// consumeAbort. Diet A's abort-on-unmount (session.ts's stop())
|
||||
// fires on React StrictMode's simulated remount in dev — it killed
|
||||
// the ?prompt first send ~8ms in (POST aborted, never retried:
|
||||
// the page's sentInitial guard had already flipped), leaving the
|
||||
// session dead until a second message, which then persisted
|
||||
// WITHOUT the first — the optimistic tail rode a record that never
|
||||
// contained it. The POST is a ~100ms ack since Diet B; it cannot
|
||||
// starve the connection pool, so it needs no teardown guard. The
|
||||
// STREAM consume stays on the controller — releasing that held
|
||||
// connection is Diet A's whole job.
|
||||
const res = await this.postInputEvent(input);
|
||||
if (res.status === 409) {
|
||||
this.setError("A turn is already running — try again in a moment.");
|
||||
this.setStatus("error");
|
||||
@@ -582,6 +593,10 @@ export class SessionModel {
|
||||
// replay lands on top). One live view connection per page, always —
|
||||
// the browser's 6-per-origin pool is the scarce resource.
|
||||
await res.text().catch(() => {}); // drain the tiny ack; release the socket
|
||||
// A stop() or a newer send/consume won while the ack was in
|
||||
// flight: the turn is live server-side either way — do not attach
|
||||
// a stream from a view that is gone or superseded.
|
||||
if (this.consumeAbort !== controller) return;
|
||||
await this.resumeStream(true);
|
||||
} catch (err) {
|
||||
if ((err as Error).name === "AbortError") return; // stop() or a newer consume won
|
||||
|
||||
@@ -248,7 +248,7 @@ function sessionMeta(chat: ChatListItem): string {
|
||||
if ((chat.kind ?? "teach") === "practice" && chat.pendingProblem) {
|
||||
return `Problem waiting · ${timeAgo(chat.updatedAt)}`;
|
||||
}
|
||||
if (chat.busy) return (chat.kind ?? "teach") === "practice" ? "Practicing…" : "Teacher is working…";
|
||||
if (chat.busy) return "Working…";
|
||||
return timeAgo(chat.updatedAt);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user