React + Vite + TypeScript, PWA, offline-first. Six tabs: 수업 오늘 단어 문장
문법 한글, plus the full-screen SRS review overlay, the reading drill, the
conjugation trainer and the 두벌식 keyboard.
The visual language is carried over deliberately: two hand-tuned palettes,
three type stacks, about a dozen component classes, zero border-radius and
no icons anywhere — Korean glyphs do the work icons would.
THE GATE is the reason this app exists. buildGate() already took a
vocabQuery hook; filling it with a band query is what turns 371 hand-typed
words into something that scales. Three refinements sit inside that hook,
all of them narrowing:
1. words a not-yet-finished unit is the first to introduce are excluded,
so a frequency ceiling cannot smuggle 3.4's material into 2.1;
2. Phase 1 is filtered by the phonological ladder;
3. the list is capped at 800 by frequency, because renderGate() inlines
it into the prompt — strictly more restrictive than the band, so it
cannot leak.
prompt/tutor-system.md ships unchanged with {{GATE}} filled by renderGate().
Confidence is clamped per turn. The artifact wrote the model's ::progress
number straight into the sole gate on advancement, so one hallucinated 95
skipped a unit.
stub-tutor.ts stands in for the model on the artifact's exact contract —
onText receives cumulative text, an aborted turn keeps what it streamed —
so the real endpoint drops in without touching the UI. It rotates all four
task types and climbs progress gradually, which makes every render path
reachable with no server.
Two artifact bugs are not ported: task state lived in the full-page
re-render, so anything arriving mid-answer wiped typed text and placed
chips; and the day number was computed once at module load, so a session
left open overnight scheduled against yesterday.
Verified in a browser: all six tabs work, and after a hard reload with the
network cut every tab still works — including dictionary search out of OPFS.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
57 lines
1.8 KiB
TypeScript
57 lines
1.8 KiB
TypeScript
/* Tutor prose.
|
|
|
|
Deliberately almost no markup: the prompt allows **bold** and nothing
|
|
else. Two behaviours carry over from the artifact because they do real
|
|
work:
|
|
|
|
- a line that is mostly Korean and short is set larger, so an example
|
|
sentence reads as an example rather than as prose;
|
|
- a line opening with ✓ or ✗ is a marked answer, and gets the colour. */
|
|
|
|
import { Fragment } from "react";
|
|
|
|
const KOREAN = /[가-힣]/g;
|
|
const PUNCT = /[\s.,!?·…"'“”()[\]:;~-]/g;
|
|
|
|
/** Mostly-Korean and short enough to be an example, not a sentence of prose. */
|
|
function isKoreanLine(line: string): boolean {
|
|
const bare = line.replace(PUNCT, "");
|
|
if (!bare || bare.length > 60) return false;
|
|
const korean = (bare.match(KOREAN) ?? []).length;
|
|
return korean / bare.length > 0.55;
|
|
}
|
|
|
|
/** **bold** is the only inline markup the prompt permits. */
|
|
function inline(text: string) {
|
|
return text.split(/(\*\*[^*]+\*\*)/g).map((part, i) =>
|
|
part.startsWith("**") && part.endsWith("**") && part.length > 4 ? (
|
|
<strong key={i}>{part.slice(2, -2)}</strong>
|
|
) : (
|
|
<Fragment key={i}>{part}</Fragment>
|
|
),
|
|
);
|
|
}
|
|
|
|
export function MessageBody({ text }: { text: string }) {
|
|
const lines = text.split("\n");
|
|
|
|
return (
|
|
<>
|
|
{lines.map((line, i) => {
|
|
const trimmed = line.trim();
|
|
if (!trimmed) return <div className="gap" key={i} />;
|
|
|
|
const mark = trimmed.startsWith("✓") ? "ok" : trimmed.startsWith("✗") ? "no" : null;
|
|
const rest = mark ? trimmed.slice(1).trimStart() : trimmed;
|
|
|
|
return (
|
|
<p key={i} className={isKoreanLine(rest) ? "kline ko" : undefined}>
|
|
{mark && <span className={mark}>{mark === "ok" ? "✓" : "✗"}</span>}
|
|
{inline(rest)}
|
|
</p>
|
|
);
|
|
})}
|
|
</>
|
|
);
|
|
}
|