fix: verdict death — plan→teach seam inferred from first nodeId-tagged quiz

The Accept/Decline verdict gate is gone (owner ruling 2026-09-26):
presenting the plan ends the teacher's turn; the learner's next message
is a natural reply. Teaching begins at the first quiz call tagged with a
nodeId (probe quizzes carry none) — both folds (view phaseAt3, native
phaseAt3Lh) advance on the call itself, and the teach divider renders
before that whole assistant block. No backwards compat: verdict markers,
the verdict input event, optimistic appends, composer buttons, and
projection all deleted; prompts and docs rewritten to the natural flow.
This commit is contained in:
amosblomqvist
2026-09-27 00:48:46 +03:00
parent dcb839232c
commit 145b470752
17 changed files with 221 additions and 389 deletions
+13 -54
View File
@@ -128,7 +128,7 @@ const useIsoLayoutEffect = typeof window === "undefined" ? useEffect : useLayout
* as a sub-agent result — rendered as an artifact card, never a bubble. */
/** The quiet system line (custom-message scheme rendering): centered, muted,
* small — the transcript's voice for events that are not speech (wake
* scaffolding, the learner's plan verdict). */
* scaffolding). */
function SystemLine({ children, testId }: { children: React.ReactNode; testId?: string }) {
return (
<div
@@ -402,7 +402,7 @@ export function Chat({
.catch(() => {});
});
const [setupOpen, setSetupOpen] = useState(false);
/** The last explicitly-sent draft (composer send, verdict note): the
/** The last explicitly-sent draft (composer send): the
* refusal flow restores it into the composer and Save replays it.
* Auto-continuations (probe answers) never set it — their refusal
* opens the dialog with no replay. */
@@ -575,35 +575,6 @@ export function Chat({
// derives its own from the same transcript).
const planTree = useMemo(() => latestTree(messages), [messages]);
// ── The plan verdict gate (docs/probe-teach-split.md §4) ──
// The plan has been presented (a tree exists) and the session still sits in
// the planning phase → the composer's send square becomes the stacked
// Accept / Decline buttons. Acceptance is the explicit plan→teach seam
// (a data-plan-accepted part on the message); decline asks for revision.
const planVerdict = useMemo(
() => phaseAt3(messages) === "plan" && planTree !== null,
[messages, planTree],
);
const sendVerdict = useCallback(
(accepted: boolean) => {
const note = text.trim();
if (note) draftRef.current = note; // refusal flow: the note replays as text
setText("");
// TWO REAL MESSAGES, ONE TURN (the custom-message scheme, user-decided
// 2026-09-12): a typed note is the learner's own user message, and the
// verdict is its own custom message — marker part ONLY, no human-
// authored text (the model-facing wording lives in toLlmMessages,
// the native convertToLlm seam; nothing fake is persisted as speech).
// ONE input event, ONE turn: the session hook appends the optimistic
// note + verdict marker (local ids — the settle sync lands the
// server canon) and POSTs {type:"verdict"}; the server persists the
// pair as its own write-ahead — the same single-turn mechanism
// syncFromServer uses, no 409 dance, no double teacher turn.
void send({ type: "verdict", accepted, note: note || undefined });
},
[text, send],
);
// ── Session usage (wave-4 stats bar) ──
// The money channel: the record's turns log, folded client-side by
// core/prices.ts. Seeded once on mount (the page doesn't carry turns),
@@ -1076,21 +1047,17 @@ export function Chat({
// assistant group — is gone). Never a user bubble: the wake is
// scaffolding; the model-facing instruction lives in the adapter.
<PhaseDivider key={m.id || `m-${mi}`} phase="plan" />
) : m.role === "user" && m.parts.some((p) => p.type === "data-verdict") ? (
// The learner's plan verdict (custom-message scheme): the
// accept IS the phase seam — it renders the TEACHING DIVIDER
// (owner ruling 2026-09-26: replaced the "✓ Plan accepted"
// line; same spot, one signal, not two). A DECLINE is not a
// seam — it stays the quiet revision line. Never a user
// bubble: the model-facing wording is the adapter's, and this
// is the learner's ACT, not their words (a typed note, if
// any, renders above as its own real message).
((m.parts.find((p) => p.type === "data-verdict") as
| { data?: { accepted?: boolean } }
| undefined)?.data?.accepted)
? <PhaseDivider key={m.id || `m-${mi}`} phase="teach" />
: <SystemLine key={m.id || `m-${mi}`} testId="verdict-declined">↻ Plan revision requested</SystemLine>
) : (
) : m.role === "assistant" && mi > 0 && phases[mi] === "teach" && phases[mi - 1] !== "teach" ? (
// THE INFERRED TEACH SEAM (owner ruling 2026-09-26, the verdict
// death): teaching begins where the FIRST nodeId-tagged quiz is
// posed — the fold (phaseTimeline, the same derivation the phase
// chip reads) flips to teach exactly AT this assistant group, so
// the divider renders before the whole block (thinking -> prose ->
// the quiz call) — where the explicit accept marker used to sit.
// The boundary check (this index flips, the previous didn't)
// guarantees exactly ONE divider per session.
<PhaseDivider key={`teach-${m.id || `m-${mi}`}`} phase="teach" />
) : (
<Fragment key={m.id || `m-${mi}`}>
<Message from={m.role} className={m.role === "assistant" ? "max-w-full" : undefined}>
<MessageContent className={m.role === "assistant" ? "w-full" : undefined}>
@@ -1234,14 +1201,6 @@ export function Chat({
onStop={abortInFlightTurn}
canSend={canSend}
onEscape={dictation.active ? dictation.cancel : undefined}
verdict={
planVerdict
? {
onAccept: () => sendVerdict(true),
onDecline: () => sendVerdict(false),
}
: undefined
}
/>
}
onSubmitAnswer={(output) => {
+15 -60
View File
@@ -1,6 +1,6 @@
"use client";
import { CheckIcon, CornerDownLeftIcon, SquareIcon, XIcon } from "lucide-react";
import { CornerDownLeftIcon, SquareIcon } from "lucide-react";
import { cn } from "@/lib/utils";
import { Hint } from "@/components/ui/hint";
@@ -12,16 +12,13 @@ import { Hint } from "@/components/ui/hint";
* Corner-radius math (concentric with the shell): shell rounded-2xl (16px) −
* row padding p-1.5 (6px) = button rounded-[10px] = 25% of the 40px button.
*/
/** What one Enter press does, in precedence order (the plan-verdict
* behavior is user-decided 2026-09-19, docs/probe-teach-split.md §4):
* stop a busy stream; ACCEPT when the plan verdict pends — typed text
* rides the acceptance as the note (the green button's exact semantics;
* an empty box accepts too, so Enter can never strand the verdict);
* otherwise send the message. Pure so the static-render harness can pin
* the decision (key events can't be simulated in renderToStaticMarkup). */
export function enterAction(state: { busy: boolean; verdictPending: boolean; canSend: boolean }): "stop" | "accept" | "send" | "none" {
/** What one Enter press does, in precedence order: stop a busy stream,
* otherwise send the message. (The plan-verdict accept branch died
* 2026-09-26 with the verdict itself.) Pure so the static-render harness
* can pin the decision (key events can't be simulated in
* renderToStaticMarkup). */
export function enterAction(state: { busy: boolean; canSend: boolean }): "stop" | "send" | "none" {
if (state.busy) return "stop";
if (state.verdictPending) return "accept";
if (state.canSend) return "send";
return "none";
}
@@ -34,7 +31,6 @@ export function Composer({
onStop,
canSend,
autoFocus,
verdict,
onEscape,
placeholder = "Ask, answer, or steer the lesson…",
}: {
@@ -45,10 +41,6 @@ export function Composer({
onStop: () => void;
canSend: boolean;
autoFocus?: boolean;
/** The plan verdict gate: while the presented plan awaits the learner's
* word, the send square becomes two stacked buttons — green accept,
* red decline. Typed text rides the verdict as his note. */
verdict?: { onAccept: () => void; onDecline: () => void };
/** Escape while a dictation runs stops it (STT wave, 2026-09-17). No-op
* when absent — Esc otherwise means nothing in the composer. */
onEscape?: () => void;
@@ -63,9 +55,8 @@ export function Composer({
className="flex items-end gap-1.5 p-1.5"
onSubmit={(e) => {
e.preventDefault();
const action = enterAction({ busy, verdictPending: Boolean(verdict), canSend });
const action = enterAction({ busy, canSend });
if (action === "stop") onStop();
else if (action === "accept") verdict?.onAccept();
else if (action === "send") onSend();
}}
>
@@ -86,56 +77,21 @@ export function Composer({
// Chat convention: Enter sends, Shift+Enter is a newline.
// ⌘/Ctrl+Enter also sends — the universal submit shortcut
// across every input in the app (thinking field, answers).
// While the plan verdict pends, Enter ACCEPTS the plan instead
// (enterAction — user-decided 2026-09-19).
if (e.key === "Enter" && (e.metaKey || e.ctrlKey || !e.shiftKey)) {
e.preventDefault();
const action = enterAction({ busy, verdictPending: Boolean(verdict), canSend });
if (action === "stop") onStop();
else if (action === "accept") verdict?.onAccept();
else if (action === "send") onSend();
}
const action = enterAction({ busy, canSend });
if (action === "stop") onStop();
else if (action === "send") onSend();
}
}}
placeholder={placeholder}
autoFocus={autoFocus}
rows={1}
className="field-sizing-content lh-input max-h-48 min-h-10 flex-1 resize-none bg-transparent px-2.5 py-2 outline-none placeholder:text-muted-foreground"
/>
{verdict && !busy ? (
// The plan verdict (docs/probe-teach-split.md §4): accept
// sanctions teaching (phase plan→teach); decline sends the
// revision request. Enter accepts too (user-decided 2026-09-19 —
// it formerly sent a plain message, which left the verdict
// pending on the next message; a side question now rides the
// acceptance as its note instead).
<div className="flex shrink-0 flex-col justify-end gap-1" data-testid="plan-verdict-buttons">
<Hint
// Enter accepts too — one press, either button (the user
// decided 2026-09-19; surface keys honestly per state).
label="Accept the plan"
binding="enter"
side="left"
>
<button
type="button"
onClick={verdict.onAccept}
className="flex h-[19px] items-center justify-center gap-1 rounded-md bg-emerald-600 px-3 text-xs font-medium text-white transition-colors hover:bg-emerald-500"
>
<CheckIcon className="size-3" /> Accept plan
</button>
</Hint>
<button
type="button"
onClick={verdict.onDecline}
className="flex h-[19px] items-center justify-center gap-1 rounded-md bg-destructive px-3 text-xs font-medium text-destructive-foreground transition-colors hover:opacity-90"
>
<XIcon className="size-3" /> Decline
</button>
</div>
) : (
// No tooltip on the send square — the ↵ glyph is the
// affordance and Enter is obvious (owner, subtlety
// round 2026-09-25).
{/* No tooltip on the send square — the ↵ glyph is the
affordance and Enter is obvious (owner, subtlety
round 2026-09-25). */}
<button
type="submit"
aria-label={busy ? "Stop" : "Send"}
@@ -149,7 +105,6 @@ export function Composer({
>
{busy ? <SquareIcon className="size-4" /> : <CornerDownLeftIcon className="size-5" />}
</button>
)}
</form>
);
}
-17
View File
@@ -19,7 +19,6 @@ import {
needsContinuation,
newAnswerResult,
newUserMessage,
newVerdictMessage,
projectView,
type ChatInput,
type LhMessage,
@@ -133,16 +132,6 @@ export function absorbed(m: LhMessage, record: readonly LhMessage[]): boolean {
(r as ToolResultMessage).toolCallId === toolCallId,
);
}
if (role === "custom") {
const marker = m as { customType?: string; details?: { accepted?: unknown } };
if (marker.customType !== "verdict") return false;
return record.some(
(r) =>
(r as { role?: string }).role === "custom" &&
(r as { customType?: string }).customType === "verdict" &&
(r as { details?: { accepted?: unknown } }).details?.accepted === marker.details?.accepted,
);
}
return false;
}
@@ -465,12 +454,6 @@ export class SessionModel {
else if (input.type === "answer") {
const tool = pendingCallTool([...this.base, ...this.tail], input.toolCallId) ?? "quiz";
optimistic.push({ ...newAnswerResult(input.toolCallId, tool, input.answer), id: localId() });
} else if (input.type === "verdict") {
if (input.note) optimistic.push({ ...newUserMessage(input.note), id: localId() });
optimistic.push({
...newVerdictMessage(input.accepted, new Date().toISOString()),
id: localId(),
});
}
if (optimistic.length > 0) this.mutate(() => {
this.tail = [...this.tail, ...optimistic];