The accept-plan UI lands (docs/probe-teach-split.md §4, formerly the interim rule): presenting the plan no longer moves the phase — the learner's ACCEPT does. While the presented plan awaits its verdict, the composer's send square becomes two stacked buttons (green Accept plan / red Decline); typed text rides the verdict as his note, Enter keeps sending plain side questions (phase unmoved), decline asks for a revision and the buttons stay. The seam: accept sends a user message carrying a data-plan-accepted part (PlanAcceptedData in contracts/chat.ts, TeacherUIDataParts 'plan-accepted'); phaseAt3 reads it as the plan→teach event (plan_init demoted to presentation-only); convertToModelMessages drops data parts, so the teacher sees only the text. Mid-lesson rewrites need no fresh verdict — acceptance happens once, at the first presentation. The teacher's planning prompt now ends the turn at presentation and waits for the verdict (never teaches into an unaccepted plan). Gates: tsc clean, 304/304 (phases tests rewritten to the acceptance seam incl. decline/side-question/failed-init cases; composer verdict render tests), lint, build. Live GLM smoke ALL PASS: phase pinned at 'plan' after plan_init, presentation turn carried NO check, accept click flipped the summary to 'teach', then tagged checks moved the map (current=rates, visited=composite); zero console errors.
47 lines
1.9 KiB
TypeScript
47 lines
1.9 KiB
TypeScript
import type { UIMessage } from "ai";
|
|
import type {
|
|
DemoToolInput,
|
|
PlanAcceptedData,
|
|
PlanBlockData,
|
|
ProbeDoneInput,
|
|
ProbeDoneResult,
|
|
ResearchToolInput,
|
|
SubagentArtifactData,
|
|
VisualToolInput,
|
|
} from "./contracts.ts";
|
|
import type { AskToolInput, QuestionAnswerData, QuizToolInput } from "./question-core.ts";
|
|
|
|
/**
|
|
* The typed UI message for the teacher chat — gives the frontend typed tool
|
|
* parts ("tool-quiz" / "tool-ask_user_question" / "tool-research" / …) without
|
|
* importing the server-side agent into the client bundle.
|
|
*
|
|
* Question tools are CLIENT-SIDE (no execute): their OUTPUT type is the
|
|
* structured answer record the client builds and sends via addToolOutput.
|
|
* Job tools are SERVER-EXECUTED: their output is the plain-string dispatch
|
|
* acknowledgement (the result later arrives as a steer message — see
|
|
* SubagentSteerMessage in contracts.ts, whose artifact rides the
|
|
* data-subagent-artifact part typed here as DATA_PARTS).
|
|
*/
|
|
export type TeacherUITools = {
|
|
quiz: { input: QuizToolInput; output: QuestionAnswerData };
|
|
ask_user_question: { input: AskToolInput; output: QuestionAnswerData };
|
|
/** The prober's conclusion tool (docs/probe-teach-split.md §2): the
|
|
* input IS the learner assessment; the output confirms the handoff. */
|
|
probe_done: { input: ProbeDoneInput; output: ProbeDoneResult };
|
|
research: { input: ResearchToolInput; output: string };
|
|
demo: { input: DemoToolInput; output: string };
|
|
visual: { input: VisualToolInput; output: string };
|
|
};
|
|
|
|
export type TeacherUIDataParts = {
|
|
"subagent-artifact": SubagentArtifactData;
|
|
/** Plan blocks (wave 4): frozen plan snapshots rendered in the chat flow. */
|
|
"plan-block": PlanBlockData;
|
|
/** The plan-acceptance marker: the accept button's user message carries
|
|
* it — the plan→teach phase seam (docs/probe-teach-split.md §4). */
|
|
"plan-accepted": PlanAcceptedData;
|
|
};
|
|
|
|
export type TeacherUIMessage = UIMessage<unknown, TeacherUIDataParts, TeacherUITools>;
|