feat(02-05): add companion greeting to forest and avatar to lesson screen

- Add forest-greeting companion area in HTML with avatar + text
- Add lesson-companion area in HTML above letter area
- Wire getGreeting() call for returning users in app.ts
- Show companion avatar in lesson screen via getProgress lookup
- Fix pre-existing noUncheckedIndexedAccess errors in fallbacks.ts (Rule 3)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-29 12:15:45 +02:00
co-authored by Claude Opus 4.6
parent 2cf7687d51
commit 57a929bc1a
4 changed files with 50 additions and 3 deletions
+17 -1
View File
@@ -5,7 +5,7 @@ import type {
Progress,
} from "../types";
import { companions } from "../companion/characters";
import { saveProgress } from "../storage/db";
import { saveProgress, getProgress } from "../storage/db";
import {
createExerciseState,
handleKeyPress,
@@ -88,6 +88,22 @@ export function initLessonScreen(
const backBtn = document.getElementById("lesson-back-btn") as HTMLButtonElement;
const state = createExerciseState(level);
// Show companion avatar (per ASST-04)
getProgress(_db).then((progress) => {
if (!progress) return;
const companion = companions.find(
(c) => c.type === progress.selectedCharacter,
);
if (!companion) return;
const area = document.getElementById("lesson-companion")!;
const avatar = document.getElementById(
"lesson-companion-avatar",
) as HTMLImageElement;
avatar.src = companion.avatarUrl;
avatar.alt = companion.name;
area.style.display = "flex";
});
// Render keyboard
renderKeyboard(keyboardContainer, layout, level);