Explore the learn-p5 Expo app codebase (thorough). I need to understand the "next task/exercise" navigation and visual cue flow.
Find:
When a user completes all the tasks/exercises in an exercise (or the current exercise), what visual cue is shown to move them to the next one? Find the component that shows "next" / "continue" / completion cue.
Find the logic that determines "all exercises complete" and triggers navigation to the next exercise. Report whether navigation is automatic or manual currently.
Find the "task" vs "exercise" vs "module" structure - clarify the hierarchy. The user said "When the user completes all exercises and they must now go to the next exercise" - find the navigation that moves between exercises within a module (or between modules).
Find existing animation/visual cue components used for transitions (e.g. Reanimated, Lottie). Report what's available for making a "more noticeable" cue.
Report: file paths, line numbers, the completion/navigation flow, and the current cue rendering. Be thorough.
Assistant
I have thoroughly explored the codebase. Here is the complete report.
Report: "Next exercise / task" navigation and visual cue flow in learn-p5
0. Hierarchy clarification (important — the terminology is mixed in the code)
Defined in /workspaces/learn-p5/src/data/types.ts (lines 16–42):
code
Course (data file = a "module" in user-facing copy)
└─ Exercise (a "lesson" in many code paths; route param = `[id]`)
└─ ExerciseTask (a "task"; an exercise may have 0+ tasks)
Exercise.tasks?: ExerciseTask[] → optional multi-step tasks within one exercise.
So the user's phrasing "complete all tasks/exercises then go to next exercise" maps to:
Inside one Exercise with tasks[]: completing all tasks advances to the next exercise.
Between Exercises: route navigation inside the same Course (the "module").
There is no separate "module" navigation step between exercises — the "module" is just the Course wrapper. Course-to-course navigation is done by the user via the /learn list and the ExerciseCard.
1. Visual cue shown when an exercise finishes (the "Next →" cue)
Triggered from: /workspaces/learn-p5/src/app/learn/[course]/[id].tsx lines 723–763 (the useEffect keyed on state.completed):
tsx
// line 728
showToast("✓ Exercise completed!", "Next →", handleToastNext, "success");
The icon is check-circle (success tone) — see showToast definition at lines 158–167 and the Toast prop icon=… at lines 1046–1049 of [id].tsx.
The "Next →" string is the actionLabel of Toast. Tapping it calls toastActionRef.current, which is handleToastNext.
The toast auto-dismisses after 4000 ms (Toast.tsx line 26 default) and slides up via Animated.timing (lines 48–53). If the user does nothing, the toast disappears and no navigation happens (see section 2).
Rendering on screen
Toast.tsx is an absolutely-positioned Animated.View pinned to the top of the screen (lines 103–119):
Layout: a row with a MaterialCommunityIcons glyph (check-circle/alert-circle, lines 86–87) + the message, and (optional) the action button on the right (lines 92–98).
Color tone: success = colors.success, failure = colors.error (lines 35–36).
Inside the exercise screen it is mounted at /workspaces/learn-p5/src/app/learn/[course]/[id].tsx lines 1040–1050.
Note: this same Toast is reused for many things (task-complete interim message, "Task N/M complete", error messages, theme update notice), so it is the only completion-cue mechanism. It is a generic top-of-screen banner, not a dedicated celebratory "next exercise" overlay.
2. "All exercises complete" logic and whether navigation is automatic
Task-level completion (inside a single exercise)
Validation runs in the in-WebView bridge script, /workspaces/learn-p5/src/utils/editor/exerciseHtml.ts:
Lines 1180–1189 (no-pixel rules path): if there are tasks and ACTIVE_TASK_INDEX < TASKS.length - 1, it posts taskComplete; otherwise exerciseComplete.
Lines 1198–1206 (postSuccess, pixel-rule path): same logic.
Received in React Native at /workspaces/learn-p5/src/app/learn/[course]/[id].tsx lines 460–477:
The "all exercises complete" check is onlycourseData.exercises.every(l => arr.includes(...)) at lines 751–753. Its only side-effect is to add the course slug to completedCourses in AsyncStorage. It does NOT trigger navigation, nor a celebratory end-of-course cue.
When the individual exercise becomes completed it calls showToast("✓ Exercise completed!", "Next →", handleToastNext, …). The "Next →" is a manual tappable action, not an auto-trigger.
handleToastNext is defined at lines 708–721:
tsx
const handleToastNext = useCallback(() => {
setToastVisible(false);
if (!state.exercise) return;
loadCourse(course).then((courseData) => {
if (!courseData) return;
const currentIndex = courseData.exercises.findIndex((l) => l.id === id);
if (currentIndex >= 0 && currentIndex < courseData.exercises.length - 1) {
const nextLesson = courseData.exercises[currentIndex + 1];
router.replace(`/learn/${course}/${nextLesson.id}`); // ← next exercise within same course
} else {
router.replace(`/learn/${course}`); // ← last exercise: back to course list
}
});
}, [state.exercise, course, id, router]);
So:
Navigation between exercises within a module (Course) is MANUAL: the user must tap "Next →" on the toast. There is no auto-advance.
If the user lets the 4 s toast expire, nothing happens — they remain on the just-completed exercise.
The same router.replace(/learn/${course}/${nextLesson.id}) path is also reachable from the in-WebView goToNextLesson message ([id].tsx lines 490–501), but goToNextLesson is never posted by the bridge script — grep shows no goToNextLesson emit in exerciseHtml.ts. That handler is currently dead code / future hook.
Course completion (allDone === true) has no visual cue at all on the exercise screen — it silently writes to completedCourses. The only place this surfaces visually is the /learn list (/workspaces/learn-p5/src/app/learn/index.tsx) which renders a completed badge/asterisk on the course card.
Interim task-complete cue (between tasks within one exercise)
showToast(\Task i+1/{totalTasks} complete`, …)at[id].tsxline 472. SameToast` component, no action button. Auto-dismisses in 4 s.
The actual progression to the next task is automatic via the reducer (currentTaskIndex increments, line 102), and the WebView instruction panel does a Material-3 "fade-through" animation (exerciseHtml.ts lines 111–131 and 828–878). So next-task navigation is automatic, but next-exercise navigation is manual.
3. Navigation between exercises / modules
Between exercises within a course (the user's main ask)
Path: /workspaces/learn-p5/src/app/learn/[course]/[id].tsxhandleToastNext (lines 708–721), via router.replace(/learn/course/{nextLesson.id}).
The list of "next exercises" is rendered on the course landing page /workspaces/learn-p5/src/app/learn/[course]/index.tsx:
"Next exercise" hero with a big START button — lines 218–269.
"Up Next" list of upcoming lessons with lock icons and a "trophy" for the last one — lines 271–362.
Progress bar within the hero — lines 254–267.
Locking logic: /workspaces/learn-p5/src/utils/isExerciseLocked.ts — an exercise is locked unless all earlier exercises in the same course are completed (completedLessons AsyncStorage list).
Between modules (courses)
/workspaces/learn-p5/src/app/learn/index.tsx renders the list of courses via <ExerciseCard> (/workspaces/learn-p5/src/components/ExerciseCard.tsx).
ExerciseCard has a Continue button (lines 70–72, only when isCurrent && onContinue) and shows check-circle if completed, a lock if locked. There is no animation between course cards — they are flat Pressable rows.
So the navigation is:
code
/learn → /learn/[course] → /learn/[course]/[id]
↑ ↑ manual "Next →" tap on Toast
└── back-to-course on last exercise (router.replace)
router.replace is used everywhere (not push), so back-stack doesn't pile up.
4. Existing animation / visual-cue components you can reuse for a "more noticeable" cue
What is already installed
react-native-reanimated 4.2.1 (in package.json line 46, plus react-native-worklets 0.7.4 line 52) — fully wired into the app.
react-native-svg 15.15.3 (line 49) — used in ExerciseCard.tsx for the asterisk glyph.
expo-haptics (package.json line 35) — already used for the long-press cue at [id].tsx line 588 (Haptics.impactAsync).
No Lottie dependency. (grep for lottie returns nothing in src/; not in package.json.)
React Native built-in Animated is used in several places.
Existing animated cue components available for reuse
Component
File
Animation
Reusability for "noticeable next" cue
Toast
src/components/Toast.tsx
Top spring-in / slide-out via RN Animated (lines 31, 40–70); 4 s auto-dismiss; supports actionLabel + tone + custom icon
This is the current cue. Easy to extend (bigger text / longer duration / animated icon) but it is intentionally subtle.
StreakToast
src/components/StreakToast.tsx
RN Animated parallel spring + timing, plus a count-up number animation and an animated progress bar (lines 45–130)
Closest existing "celebratory" overlay — already includes a trophy/fire icon, milestone copy, and a progress bar. Good template for a "course complete" or "go to next module" celebratory cue.
AchievementBadgeModal
src/components/AchievementBadgeModal.tsx
Modal with animationType="fade", horizontal paging FlatList of badges, dot pagination (lines 64–141). Static (no spring), but a full-screen celebratory modal
Best candidate to model a "course complete / next module" celebratory screen. Could be repurposed for end-of-course cue.
ShakeModal
src/components/ShakeModal.tsx
RN Animated parallel spring + opacity (lines 35–63)
Reusable modal action-sheet pattern with haptics-friendly per-action variants.
Reanimated useAnimatedStyle for backdrop + drawer slide (lines 3–8, 27–85)
Reference pattern if you want a slide-up "next exercise" panel.
Onboarding [slide].tsx
src/app/onboarding/[slide].tsx
Reanimated (lines 6–10, 72, 354)
Reusable full-screen Reanimated overlay pattern.
In-WebView "fade-through"
exerciseHtml.ts lines 111–131, 828–878
expo-haptics availability
Imported in [id].tsx line 6 (expo-haptics), invoked at line 588 for long-press feedback. A "more noticeable" completion cue could easily add Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success) on state.completed.
Summary of the flow (one-liner)
User presses Run → in-WebView validation runs (exerciseHtml.ts lines ~1180–1206) → posts taskComplete or exerciseComplete.
[id].tsxhandleMessage (lines 460–477) reduces TASK_COMPLETE/EXERCISE_COMPLETE. For intermediate tasks it shows a Toast "Task i/N complete" (line 472) after a 480 ms delay timed to the WebView fade-through.
When the last task (or the no-task exercise) completes, state.completed flips true → the effect at lines 723–763 fires, calling showToast("✓ Exercise completed!", "Next →", handleToastNext, "success").
The Toast (src/components/Toast.tsx) springs in from the top, shows check-circle + "Next →" button, auto-dismisses in 4 s. Navigation to the next exercise is manual — tapping "Next →" calls handleToastNext (lines 708–721) which does router.replace('/learn/<course>/<nextId>'); if it was the last exercise, it routes back to /learn/<course>.
After completing the last exercise, there is no distinct course-completion cue — only a silent write to completedCourses AsyncStorage; the only visual reward is a deferred Toast for newly-unlocked achievements (line 737) and the existing AchievementBadgeModal invoked from elsewhere (dashboard).
The current cue is a single top-of-screen banner (Toast) that lasts 4 s and requires a tap on a small "Next →" link to advance. Nothing flashes, pulses, scales, or plays a celebration on completion — and there is no automatic advance. All the infrastructure for a more noticeable cue (Reanimated, Haptics, Lottie-free but full-screen modals already built) is in place, but unused for this moment.
/workspaces/learn-p5/src/components/StreakToast.tsx and /workspaces/learn-p5/src/components/AchievementBadgeModal.tsx — existing celebratory animated components reusable for a "more noticeable" cue.
/workspaces/learn-p5/src/hooks/useAchievements.ts — recordCompletion (line 69) used in the completion effect.
/workspaces/learn-p5/package.json lines 35–52 — available animation libraries (react-native-reanimated@4.2.1, react-native-worklets@0.7.4, expo-haptics@~55.0.9, react-native-svg@15.15.3). No Lottie.