Skip to content

Improve story pipeline loading and learning UI - #22

Merged
pablonification merged 8 commits into
mainfrom
feat/story-pipeline
May 9, 2026
Merged

pablonification merged 8 commits into
mainfrom
feat/story-pipeline

Conversation

@pablonification

Copy link
Copy Markdown
Owner

Summary

  • stabilize loading states across story, profile, and learning surfaces
  • track story reading progress and improve learning language context throughout the app
  • refine profile subpage skeletons and language settings return behavior
  • add resilient visual fallbacks for home, garden, and story cards
  • smooth Vocab Master card deck animations and swipe handling

Validation

  • npm run precommit
  • npm run check
  • npm run build

Notes

  • Production build still reports existing large bundle chunk warnings from Vite.

@greptile-apps

greptile-apps Bot commented May 9, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR stabilizes loading states across story, profile, and learning surfaces, introduces persistent story reading progress (tracked in device storage), and replaces IonSpinner throughout the app with AppSkeleton for a more consistent visual treatment.

  • Story progress module: A new storyProgress.ts (with unit tests) persists per-story scene positions; StoryReadPage and StoryDetailPage load/save this progress, and LandingPage drives a real "Last Read" card from it.
  • Profile skeletons: ProfileLoadingSkeleton is decomposed into per-route variants so each subpage shows a contextually accurate placeholder; createFallbackDashboard now uses zeroed stats and real user metadata, fixing previously flagged fabricated-stats regressions.
  • Language badge & flags: Eight Southeast Asian flag SVGs are added and wired through getLearningLanguageMetadata; the badge and profile language row now show flag thumbnails with language name and country context.
  • VocabMaster deck: Cards are repositioned to position: absolute with translateX(-50%) centering; an advancingRef + 900 ms cooldown prevents double-advance glitches from rapid swipes.

Confidence Score: 4/5

Safe 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.

Important Files Changed

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
Loading

Comments Outside Diff (1)

  1. src/pages/LandingPage.tsx, line 378-389 (link)

    P1 "Last Read" card stays stale in Ionic's tab cache

    The storyProgress effect has [] dependencies, so it only executes once — on the initial mount of LandingPage. In Ionic React, tab pages are kept alive in IonRouterOutlet and 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 (because storyProgress is 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 (or useIonViewDidEnter) from @ionic/react to re-run the getStoryProgress() 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

Comment thread src/pages/StoryReadPage.tsx Resolved
return (
<IonButton disabled={disabled ?? loading} {...props}>
{loading ? <IonSpinner name="crescent" /> : children}
{loading ? <AppSkeleton className="app-skeleton--pill" width={72} height={16} /> : children}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

Suggested change
{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!

@pablonification
pablonification merged commit 9658002 into main May 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant