feat(lessons): multi-step exercises checked on the terminal state - #403
Conversation
An exercise can now have steps, each checked on the terminal state after the command (a merge in progress, a file without conflict markers, a merge commit), not on the text typed. A pure engine, progressExercise, is shared by LessonPage and the tests, which replay every solution the way a learner types it. One-command exercises are a single step, and a command that printed an error no longer validates. - Conflicts lesson: five steps, from git merge to git commit --no-edit, with advice for git add while the markers are still in, and a restart after git merge --abort. Every output checked against Git 2.56. - dotenv and scripts lessons: two steps (cd projets, then the command). Windows now teaches bash script.sh. - LessonPage: no more auto-advance after 2.5 s. The success shows in the panel and in the terminal, and « Suivant » waits for the learner. Progress belongs to one terminal session (Réinitialiser, env change). - TerminalEmulator: onCommand gets the output and the previous state, and may return feedback lines printed after the command output. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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 3 days and 21 hours by commenting @sourcery-ai review. Upgrade to get a review now.
Guide du réviseurCette PR introduit un moteur partagé d’exercices basé sur l’état final du terminal pour les leçons à commande unique et les leçons en plusieurs étapes, migre les leçons clés — en particulier la résolution des conflits Git — vers une progression basée sur l’état avec rejet des erreurs et conseils de récupération, et met à jour le terminal/l’interface utilisateur afin de préserver la progression par session tout en remplaçant l’avance automatique par une navigation explicite et accessible. Diagramme de séquence pour la validation des commandes du terminalsequenceDiagram
participant Learner
participant TerminalEmulator
participant TerminalEngine
participant ExerciseEngine as progressExercise
participant LessonPage
Learner->>TerminalEmulator: Enter command
TerminalEmulator->>TerminalEngine: Execute command
TerminalEngine-->>TerminalEmulator: newState, lines
TerminalEmulator->>ExerciseEngine: progressExercise(exercise, step, command, state, prevState, lines)
ExerciseEngine-->>TerminalEmulator: StepProgress and feedback
TerminalEmulator-->>Learner: Output and feedback lines
ExerciseEngine-->>LessonPage: Updated step or completed state
LessonPage-->>Learner: Step status or Suivant CTA
Diagramme de flux de la progression d’un exercice basé sur l’état du terminalflowchart TD
A[Command entered] --> B[TerminalEmulator executes command]
B --> C[progressExercise receives state, prevState, lines]
C --> D{Current step check passes?}
D -- No --> E{Known mistake?}
E -- Yes --> F[Print warning feedback]
E -- No --> G[Keep current step]
D -- Yes --> H[Advance one or more completed steps]
H --> I{All steps complete?}
I -- No --> J[Print next-step feedback]
I -- Yes --> K[Mark lesson complete and show Suivant]
Diagramme de flux de l’exercice de résolution des conflits Gitflowchart TD
A[git merge feature/nouvelle-feature] --> B{Merge conflict present?}
B -- Yes --> C[Read index.html]
C --> D{Conflict markers removed?}
D -- No --> E[git checkout --theirs index.html]
E --> D
D -- Yes --> F[git add index.html]
F --> G{Index has no conflict markers?}
G -- No --> H[Print repair guidance]
H --> E
G -- Yes --> I[git commit --no-edit]
I --> J{Merge commit has two parents and no markers?}
J -- Yes --> K[Exercise complete]
J -- No --> L[Do not complete]
B -- No --> M[Remain on merge step]
C --> N[git merge --abort]
N --> O[Restart at step 1]
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 introduces a shared terminal-state exercise engine for both single-command and multi-step lessons, migrates key lessons—especially Git conflict resolution—to state-based progression with error rejection and recovery guidance, and updates the terminal/UI to preserve progress per session while replacing auto-advance with accessible, explicit navigation. Sequence diagram for terminal command validationsequenceDiagram
participant Learner
participant TerminalEmulator
participant TerminalEngine
participant ExerciseEngine as progressExercise
participant LessonPage
Learner->>TerminalEmulator: Enter command
TerminalEmulator->>TerminalEngine: Execute command
TerminalEngine-->>TerminalEmulator: newState, lines
TerminalEmulator->>ExerciseEngine: progressExercise(exercise, step, command, state, prevState, lines)
ExerciseEngine-->>TerminalEmulator: StepProgress and feedback
TerminalEmulator-->>Learner: Output and feedback lines
ExerciseEngine-->>LessonPage: Updated step or completed state
LessonPage-->>Learner: Step status or Suivant CTA
Flow diagram for terminal-state exercise progressionflowchart TD
A[Command entered] --> B[TerminalEmulator executes command]
B --> C[progressExercise receives state, prevState, lines]
C --> D{Current step check passes?}
D -- No --> E{Known mistake?}
E -- Yes --> F[Print warning feedback]
E -- No --> G[Keep current step]
D -- Yes --> H[Advance one or more completed steps]
H --> I{All steps complete?}
I -- No --> J[Print next-step feedback]
I -- Yes --> K[Mark lesson complete and show Suivant]
Flow diagram for Git conflict resolution exerciseflowchart TD
A[git merge feature/nouvelle-feature] --> B{Merge conflict present?}
B -- Yes --> C[Read index.html]
C --> D{Conflict markers removed?}
D -- No --> E[git checkout --theirs index.html]
E --> D
D -- Yes --> F[git add index.html]
F --> G{Index has no conflict markers?}
G -- No --> H[Print repair guidance]
H --> E
G -- Yes --> I[git commit --no-edit]
I --> J{Merge commit has two parents and no markers?}
J -- Yes --> K[Exercise complete]
J -- No --> L[Do not complete]
B -- No --> M[Remain on merge step]
C --> N[git merge --abort]
N --> O[Restart at step 1]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Why
Until now an exercise only saw the text the learner typed, never what the terminal did with it. Two consequences:
git merge, then jumped to the next lesson 2.5 s later: the learner sawCONFLICTand never resolved it, which is the whole point of the lesson;cat .envoutside the project printed an error and completed the exercise).What changes
src/app/data/exerciseSteps.ts).Exerciseis now either one command (validate) orsteps, each with acheckon the terminal state after the command ({command, env, state, prevState, lines}), an optionalwarnfor a known mistake, and an exercise-levelrestart.progressExerciseis pure and shared by LessonPage and the tests. A command can complete several steps when their results are already there, never skip one whose result is missing.git merge feature/nouvelle-feature→cat index.html(WindowsGet-Content) →git checkout --theirs index.html→git add index.html→git commit --no-edit.git addwith the markers still in prints advice (git checkout feature/nouvelle-feature -- index.html);git merge --abortrestarts at step 1; a merge commit that recorded the markers never completes.cd projets, then the command). Windows now teachesbash script.sh(PowerShell does not run a bash script itself).role="status"panel with a « Suivant » CTA; the nav « Suivant » is filled once done. Steps are listed with their state (sr-only labels). Progress belongs to one terminal session: « Réinitialiser » and every environment change start over (a session counter, so Linux → Windows → Linux cannot bring stale steps back). An exercise already completed can be redone without recording it twice.onCommand(command, state, {lines, prevState})may return feedback lines, printed after the command's output in their own colour.validateConflictsremoved (the conflict steps read the git state).scripts/export-curriculum.tsreportsstepsexercises.Verification
Updated 0 paths from the indexforcheckout --theirsafter a prematuregit add. terminal-fidelity-auditor: 12 MATCH, 1 COSMETIC (git logdecoration on a TTY), 0 wrong.exerciseSteps.test.ts(engine, conflict walk-through, warn, abort, markers committed, Windows) andlessonPageExercise.test.tsx(no auto-advance, Suivant, failed command, steps, Réinitialiser, env round-trip, replay) — both shown red against the previous LessonPage.lessonFidelityreplays every solution throughprogressExercise; the garbage-input tests now assert no exercise advances.Known, out of scope: the Windows engine still runs
.\script.shas bash (real PowerShell hands it to the file association) — planned with the Windows fidelity work.🤖 Generated with Claude Code
Résumé par Sourcery
Valider les exercices par rapport à l’état final du terminal et guider les apprenants tout au long de leur réalisation en plusieurs étapes, sans navigation automatique.
Nouvelles fonctionnalités :
bash script.shpour les exercices de scripts Windows.Corrections de bugs :
Améliorations :
Documentation :
Tests :
Tâches :
Original summary in English
Summary by Sourcery
Validate exercises against the terminal state and guide learners through multi-step completion without automatic navigation.
New Features:
bash script.shfor Windows script exercises.Bug Fixes:
Enhancements:
Documentation:
Tests:
Chores: