feat(terminal): start each lesson from the state it teaches (THI-353) - #385
Conversation
Every lesson mounted a fresh default terminal, so the Git lessons asked for `git status`, `git merge feature/x` or `git push -u origin main` in a terminal that had no repository, no branch and no remote. The learner typed exactly what the lesson said, got "fatal: not a git repository" in red, and the exercise still validated: the validator only reads the command string. The browser census of 23 September found 46 of 198 lesson x environment combinations in that state; 33 of them were Git lessons. - Exercise gains an optional `setup` (src/app/data/lessonSetup.ts): a pure function of the initial state plus a one-line note shown in the terminal welcome message. Git lessons start in ~/projets with the repository, branch or remote they need; the security lesson gets a simulated ~/.ssh with the 700/600/644 permissions it teaches. - TerminalEmulator takes an `initialState` builder, read once per mount (lesson change or "Reinitialiser"). - Terminal output keeps its spacing (git branch indentation, git status tabs); the welcome message, instruction, success message and hint no longer show raw markdown backticks and asterisks. - The Windows hint of the scripts lesson now says to `cd projets` first. Permanent guard: lessonFidelity.test.ts replays, for every lesson x environment, the command the lesson tells the learner to type, and requires it to validate AND print no error. The solutions table must match the lesson's instruction or hint word for word, so it cannot drift. The 9 cases still broken in the engine (2>, ./script.sh, $PROFILE, three PowerShell cmdlets) run as it.fails in a ratchet that can only shrink: fixing one turns the suite red until its entry is removed. Replayed in the engine with the full lesson commands, 44 combinations failed before this change; 35 are fixed here, 9 remain in the ratchet (the census counted 46 because it also typed fragments of the hints). Bundle: +0.06 kB gzip (LessonPage), +0.7 kB (curriculum). Refs THI-353 Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Sorry @thierryvm, you've used your own review budget of 250,000 diff characters for the last 7 days.
You can request another review in 2 days and 20 hours by commenting @sourcery-ai review. Upgrade to get a review now.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Guide du réviseurCette PR synchronise les instructions des leçons avec le contexte initial du terminal en ajoutant des constructeurs d’état purs par leçon, en les intégrant à l’initialisation unique du terminal, en améliorant le rendu du texte du terminal et en garantissant la fidélité des leçons entre les environnements grâce à des tests de régression et à un mécanisme de suivi des lacunes connues du moteur. Diagramme de séquence pour l’initialisation du terminal spécifique à une leçonsequenceDiagram
participant LessonPage
participant TerminalEmulator
participant LessonSetup
participant TerminalEngine
LessonPage->>LessonPage: buildInitialState()
LessonPage->>LessonSetup: apply(createInitialState())
LessonSetup-->>LessonPage: prepared TerminalState
LessonPage->>TerminalEmulator: initialState=buildInitialState
TerminalEmulator->>TerminalEmulator: useState(initialState)
TerminalEmulator->>TerminalEngine: execute command
TerminalEngine-->>TerminalEmulator: output and validation result
Diagramme de flux pour la validation de la fidélité des leçonsflowchart LR
Lessons[Every lesson] --> Environments[Every environment]
Environments --> Instruction[Lesson instruction or hint]
Instruction --> Replay[Replay command in prepared terminal]
Replay --> Validate["validate(command, env)"]
Replay --> Output[Terminal output]
Validate --> Pass[Validation succeeds]
Output --> Clean[No error line]
Pass --> Fidelity[Lesson fidelity passes]
Clean --> Fidelity
Modifications au niveau des fichiers
Conseils et commandesInteragir avec Sourcery
Personnaliser votre expérienceAccédez à votre tableau de bord pour :
Obtenir de l’aide
Original review guide in EnglishReviewer's GuideThis PR synchronizes lesson instructions with the terminal’s starting context by adding pure per-lesson state builders, wiring them into one-time terminal initialization, improving terminal text rendering, and enforcing cross-environment lesson fidelity with regression tests and a ratchet for known engine gaps. Sequence diagram for lesson-specific terminal initializationsequenceDiagram
participant LessonPage
participant TerminalEmulator
participant LessonSetup
participant TerminalEngine
LessonPage->>LessonPage: buildInitialState()
LessonPage->>LessonSetup: apply(createInitialState())
LessonSetup-->>LessonPage: prepared TerminalState
LessonPage->>TerminalEmulator: initialState=buildInitialState
TerminalEmulator->>TerminalEmulator: useState(initialState)
TerminalEmulator->>TerminalEngine: execute command
TerminalEngine-->>TerminalEmulator: output and validation result
Flow diagram for lesson fidelity validationflowchart LR
Lessons[Every lesson] --> Environments[Every environment]
Environments --> Instruction[Lesson instruction or hint]
Instruction --> Replay[Replay command in prepared terminal]
Replay --> Validate["validate(command, env)"]
Replay --> Output[Terminal output]
Validate --> Pass[Validation succeeds]
Output --> Clean[No error line]
Pass --> Fidelity[Lesson fidelity passes]
Clean --> Fidelity
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Why
Refs THI-353 (P1 of the September check-up). Every lesson mounted a fresh default terminal, so the Git lessons asked for
git status,git merge feature/xorgit push -u origin mainin a terminal with no repository, no branch and no remote. The learner typed exactly what the lesson said, gotfatal: not a git repositoryin red, and the exercise still validated:validate()only reads the command string, never the engine output.What
Exercise.setup(src/app/data/lessonSetup.ts): a pure transform of the initial state + a one-line note shown in the terminal welcome message. Git lessons start in~/projetswith the repository / branch / remote they need; the security lesson gets a simulated~/.sshwith the 700/600/644 permissions it teaches.TerminalEmulator.initialState: builder read once per mount (lesson change or « Réinitialiser »).git branchindentation,git statustabs); long tokens still wrap (checked at 390px).**were shown literally).cd projetsfirst (found by the new drift check).Permanent guard
src/test/lessonFidelity.test.tsreplays, for every lesson × environment, the command the lesson tells the learner to type and requires it to validate and print no error line.lessonSolutions.tsmust match the lesson instruction/hint word for word, so it cannot drift.The 9 cases still broken in the engine (
2>,./script.sh,$PROFILE, three PowerShell cmdlets) run asit.failsinKNOWN_DESYNCS— a ratchet that can only shrink: fixing one turns the suite red until its entry is removed. They are the next PRs of THI-353.Gates
curriculum.ts): GOmain: LessonPage +0.06 kB gzip, curriculum +0.7 kB gzipgit merge,git merge --no-ff,git remote,ls -la ~/.sshvalidate with 0 red line; mobile 390×844 (CPU 4×): 0 horizontal overflow, 0 console error🤖 Generated with Claude Code
Résumé par Sourcery
Démarrer chaque terminal d’exercice depuis l’état contextuel requis par sa leçon et ajouter des vérifications de régression pour garantir la fidélité des commandes et de leur sortie.
Nouvelles fonctionnalités :
Corrections de bugs :
Améliorations :
Tests :
Original summary in English
Summary by Sourcery
Start each exercise terminal from the contextual state required by its lesson and add regression checks for command and output fidelity.
New Features:
Bug Fixes:
Enhancements:
Tests: