Repository navigation
Improve story pipeline loading and learning UI - #22
Conversation
Greptile SummaryThis PR stabilizes loading states across story, profile, and learning surfaces, introduces persistent story reading progress (tracked in device storage), and replaces
Confidence Score: 4/5Safe to merge, but the "Last Read" feature will silently show stale data for users returning to the home tab within the same app session. The story progress system, profile skeleton refactor, and VocabMaster improvements are all well-implemented and tested. The one functional gap is that LandingPage loads story progress only once on mount; because Ionic keeps tab pages alive, a user who reads a story and returns to the home tab will see no "Last Read" card (or a stale one) until the app reloads. src/pages/LandingPage.tsx — the storyProgress load effect needs to re-run on Ionic view focus events, not just on initial mount.
|
| Filename | Overview |
|---|---|
| src/lib/storyProgress.ts | New module: saves/reads per-story scene progress to device storage; logic is sound and backed by unit tests. |
| src/lib/storyProgress.test.ts | New test file covering save, apply, and last-read-story selection; mock is well-structured and all paths are exercised. |
| src/pages/StoryReadPage.tsx | Adds progress load/save effects with a hasLoadedProgress guard that resolves the previously flagged save-on-mount race; introduces skeleton loading UI. |
| src/pages/LandingPage.tsx | Drives real "Last Read" card from device-stored progress, but storyProgress effect runs with [] deps — won't refresh when the component stays mounted (Ionic tab cache) after the user reads and returns. |
| src/pages/ProfilePage.tsx | createFallbackDashboard now uses zeroed stats and real user metadata, fixing previously flagged fabricated-stats regression; getStatCards and level data read from real dashboard. |
| src/pages/VocabMaster.tsx | Double-advance guard added via advancingRef + 900 ms cooldown; absolute-positioned deck centering aligned with new CSS layout. |
| src/lib/asyncTimeout.ts | New utility: races any PromiseLike against a timeout and clears the timer in finally; used correctly throughout. |
| src/lib/learningLanguages.ts | Adds LEARNING_LANGUAGE_METADATA and getLearningLanguageMetadata with flag SVG imports; falls back to DEFAULT_LEARNING_LANGUAGE when unknown value is passed. |
| src/pages/StoryDetailPage.tsx | Loads and applies stored story progress for display; uses storyId-keyed effect with functional setStory update to avoid stale closures. |
Sequence Diagram
sequenceDiagram
participant U as User
participant LP as LandingPage
participant SRP as StoryReadPage
participant SP as storyProgress (storage)
U->>LP: Open app / switch to Home tab
LP->>SP: getStoryProgress() [on mount only]
SP-->>LP: StoryProgressMap
LP->>U: Render Last Read card (or nothing)
U->>SRP: Open story
SRP->>SP: getStoryProgressEntry(storyId) [on story load]
SP-->>SRP: restore currentScene
SRP->>U: Show story at saved scene
U->>SRP: Swipe to next scene
SRP->>SP: saveStoryProgress(story, currentScene)
U->>LP: Return to Home tab
Note over LP: storyProgress effect does NOT re-run
LP->>U: Shows STALE Last Read data
Comments Outside Diff (1)
-
src/pages/LandingPage.tsx, line 378-389 (link)"Last Read" card stays stale in Ionic's tab cache
The
storyProgresseffect has[]dependencies, so it only executes once — on the initial mount ofLandingPage. In Ionic React, tab pages are kept alive inIonRouterOutletand are never unmounted when the user navigates to another tab or a story and returns. The practical result: a user who reads a story for the first time will come back to the home tab and see no "Last Read" card (becausestoryProgressis still{}from the initial load), and a user who progresses further through a story won't see the updated progress percentage either, until the app is fully reloaded.Adding
useIonViewWillEnter(oruseIonViewDidEnter) from@ionic/reactto re-run thegetStoryProgress()fetch on each tab focus would fix this without changing the existing effect structure.
Reviews (3): Last reviewed commit: "fix: avoid fabricated profile fallback m..." | Re-trigger Greptile
| return ( | ||
| <IonButton disabled={disabled ?? loading} {...props}> | ||
| {loading ? <IonSpinner name="crescent" /> : children} | ||
| {loading ? <AppSkeleton className="app-skeleton--pill" width={72} height={16} /> : children} |
There was a problem hiding this comment.
Skeleton used for an active-loading state instead of a spinner
AppSkeleton is a content-placeholder pattern meant to convey "data is absent". Using it inside a button while an action is in-progress (e.g. signing in, saving) makes the UI look broken rather than busy, because the shimmer animation implies missing content rather than work underway. The same pattern also appears in the send button in AiHelperPage.tsx. The original IonSpinner (or an equivalent animated indicator) better communicates that a request is in-flight.
| {loading ? <AppSkeleton className="app-skeleton--pill" width={72} height={16} /> : children} | |
| {loading ? <IonSpinner name="crescent" /> : children} |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Summary
Validation
Notes