Commit Graph

6 Commits

Author SHA1 Message Date
Bingxi Zhao (Frank)
46093e5e2b update msg 2026-06-11 20:03:34 +08:00
Bingxi Zhao (Frank)
e3a351a488 refactor(guided-learning): post-merge hardening of #500
Security/correctness:
- Stop leaking diagnostic answers: persist a _sanitize_diagnostic() snapshot
  (drops top-level answers + inline answer keys) into progress.diagnostic,
  which is returned verbatim by the /progress endpoints. Grading is unaffected
  (authoritative answers live in LearningStore).
- _safe_json_parse + generate_from_notebook now use the shared fence-stripping
  parse_json_response instead of bare json.loads, so the common fenced/lightly
  -malformed LLM output is recovered instead of silently dropped / 500'd.

Decoupling:
- unified_ws change_module: move module lookup + PRETEST reset into
  LearningService.switch_module(); router keeps only the WS ordering
  (module_changed before cancel) and no longer imports learning.models.
- unified_ws check_active_turn: use new public TurnRuntimeManager
  .has_live_execution() instead of reaching into _lock/_executions.
- redo endpoint: LearningStore.clear_questions() instead of poking _questions_path.
- remove unused StreamEventType.USER_INPUT enum; document the WS message types.

Stability:
- LearningStore: question read-modify-write (save_question_answers/_meta),
  delete(), and clear_questions() now hold _cas_lock — consistent concurrency
  model; _atomic_write_text cleans up its temp file on failure.

Cleanliness/clarity:
- router: shared _validate_book_id() (9 endpoints) + _parse_modules()
  (init/replace); _classify_error drops unused expected_answer param.
- guided_learning: hoist logging/RAGService imports + module logger; move tuning
  constants to class top; ContextVar declared after imports.
- storage: hoist json import (7 inline copies removed).
- pocketbase_store: move _VALID_ID/_validate_id below the import block.
- rename misleading mastered_pct -> avg_mastery_pct (service + web consumers).

Frontend:
- learning [bookId] page uses lib fetchProgress (apiFetch -> auth redirect)
  instead of a raw credentials fetch; track/clear the retry + auto-advance
  timers on unmount; drop dead currentStage state + ModuleTree prop.
- learning-api: remove orphaned submitAnswer + AnswerRequest.
- CreateModuleDialog: use the static bookApi import; reset manualBookId to ''
  to match initial state; learning list page: stop shadowing the t() translator.

Conflict-resolution carryover: dropped the PR's incidental 300s factory timeout
(kept dev's stream runner).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-29 14:28:32 +08:00
unknown
e219b0b898 fix: rename passRate to masteryPercent, relax module name validation
- Rename passRate variable to masteryPercent in ModuleTree to match average mastery semantics
- Remove module name requirement from CreateModuleDialog (only KP count matters)
- Sync i18n strings for updated validation message
2026-05-21 00:56:15 +08:00
whf
1e37128eca Block 4: ModuleTree interactive — click to switch learning module 2026-05-16 22:46:13 +08:00
unknown
91dbafbe75 Block 7.5: i18n completion, WS reconnect with backoff, error retry button
- Add 16 i18n keys for guided learning (en/zh): input placeholder, submit button, no modules text, 13 stage labels
- Replace hardcoded STAGE_LABELS with t() calls using dynamic i18n keys
- Replace hardcoded "No modules loaded" in ModuleTree with i18n
- Add WebSocket auto-reconnect with exponential backoff (1s/2s/4s/8s, max 5 attempts)
- Add "Reconnect" button on error state for manual retry
- Add intentional disconnect on unmount to prevent ghost reconnects
2026-05-16 11:36:50 +08:00
whf
2620bf01b4 Block 9: ModuleTree nav component with mastery indicators, fetch progress from API 2026-05-14 04:20:33 +08:00