feat(web): the dojo remembers your session #92
Loading…
Reference in a new issue
No description provided.
Delete branch "web/dojo-memory"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The sensei had alzheimer: every visit to
/dojore-played his self-introduction, and going to the editor mid-quiz threw the kata away. Root cause: all dojo state lived in component-local$stateatoms of the route component, which SvelteKit destroys on navigation.What this does
web/src/lib/dojo/session.svelte.ts(new) — module-level reactive session store in the house style (audio.svelte.ts/state.svelte.ts):phase,topic/difficulty/mode/minutes,problem,answer,choice,result,correctChoice,revealed,results, the sensei (line/shown/talking/mood/lastActivity), theusedproblem set, the shiai prefetch and the brain config. It survives client-side navigation and dies on a hard reload — a new tab boots the dojo anew, and nothing is ever persisted (the config may hold an API key).endsAtepoch-ms deadline instead of remaining seconds. The mounted page recreates the ticker from it, so time keeps running while the student is away (an exam clock does not pause because you wandered off). A remount with an overdue deadline routes through the existing time-up handling.minutes = 0→ no deadline.INTROplays only on a fresh session (introducedflag). Returning to an idle menu gets a short tri-language line from the newRETURNset indojo/lines.ts("Back to the mat. It kept your place."). Returning mid-drill restores the stored line, mood and typed bubble verbatim — no new speech.+page.svelterefactored to read/write the store; all behavior otherwise unchanged (brain settings modal, ask-the-sensei, grading, verdicts, scorecard, pumping link). Brain config load/save semantics preserved (localStorage stays the source of truth; the store just caches it in memory).dojo/pumping/) gets the same quick treatment viapumping-session.svelte.ts— language,p, string, split and bubble survive the round trip.session-logic.ts(no runes) with unit tests.Verification
bun run check: 0 errors, 0 warningsbun test: 82 pass (9 new for deadline/remaining/arrival rules)bun run build: OK[ EDITOR ]and returning via[ DOJO ]keeps the same problem text, the clock continues (⧗ 04:56 → ⧗ 04:51 over ~5 s away, not reset), the phase is stillsolving(SUBMIT on the mat), and no re-intro — the bubble still shows the problem intro. Back at an idle menu the sensei says the short return line. Pumping drill survives the same round trip. Hard reload still starts clean (module memory only).Co-Authored-By: GLM (OpenCode) dev@yhkze.net