Skip to content

[#50]: Build Prepare for Offline chapter selection#175

Open
mattrace-gloo wants to merge 2 commits into
mainfrom
mrace/feature/fluent-50-prepare-offline-chapter-selection
Open

[#50]: Build Prepare for Offline chapter selection#175
mattrace-gloo wants to merge 2 commits into
mainfrom
mrace/feature/fluent-50-prepare-offline-chapter-selection

Conversation

@mattrace-gloo

@mattrace-gloo mattrace-gloo commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

TLDR

Implements Prepare for Offline chapter selection (#50) and fixes My Work showing empty after sync by pulling role-filtered assignments from the same endpoint the web app uses. Adds a cloud icon state and auto-sync when local assignment data is incomplete.

Reviewer checklist

  • GitHub issue linked in Details (Closes #NNN when this PR completes it)
  • How to verify steps completed or valid waiver noted below
  • Acceptance criteria met, or unmet AC waived in the issue with linked follow-up (see AGENTS.md)
  • Scope limited to this issue — no adjacent tickets implemented/stubbed without approval
  • Android device tested when required (native / mic / camera / filesystem / permissions) — do not check unless verified on a device

Details

Closes #50

Prepare for Offline (#50): Project picker when opened from Settings, collapsible chapter accordion grouped by book, per-book select-all, and a 5-column chapter grid. Assigned users get pre-selected assigned chapters with a collapsed accordion; unassigned users start with an empty selection and expanded accordion. Optional { projectId, projectName } route params for future #39 trigger.

My Work sync fix: Mobile previously synced only GET /users/:id/chapter-assignments/all, which returns project chapters without assignee fields populated. Web My Work uses GET /users/:id/chapter-assignments (role-filtered). Sync now calls both endpoints; userNeedsAssigneeRepair() forces a full re-sync when local chapters exist but no assignee/checker is set. My Work filter includes not_started and draft stages for assignees.

Cloud sync UX: New online_needs_sync status shows an amber refresh overlay on the cloud icon when download sync is needed. Home auto-triggers sync once per session when incomplete local data is detected while online.

UI polish: Settings screen OFFLINE section layout, shared header safe-area padding, status-bar/header fixes on stack screens.

Screenshot_1783699382 Screenshot_1783699412 Screenshot_1783699401 Screenshot_1783699391

Type of change:

Technical changes

  • src/db/queries.prepareOffline.ts — project chapters with assigned_user_id
  • src/hooks/usePrepareOfflineSelection.ts — selection state, assigned/unassigned init, accordion defaults
  • src/app/prepare-offline/ProjectPickerStep, ChapterSelectionAccordion, BookChapterSection, BookSectionHeader, ChapterSelectorGrid, SelectionCheckbox
  • src/services/sync.tssyncUserChapterWork(), assignee repair on stale local data
  • src/services/api.tsgetUserChapterAssignments()
  • src/db/repository.tsuserNeedsAssigneeRepair()
  • src/hooks/useLocalSyncHealth.ts — detects incomplete local assignment data
  • src/utils/syncStatusState.tsonline_needs_sync status
  • src/components/ui/CloudSyncStatusIcon.tsx — amber refresh glyph for updates available
  • src/app/screens/HomeScreen.tsx — auto-sync when local data needs repair

Lines changed: ~1,500 | Files modified: 42

Testing

  • npm run format:check — pass
  • npm run lint — pass
  • npm run typecheck — pass
  • npm test -- --ci — 179 passed

New tests: groupChaptersByBook.test.ts, usePrepareOfflineSelection.test.ts, ChapterSelectorGrid.test.tsx, PrepareForOfflineScreen.test.tsx, useLocalSyncHealth.test.ts, syncStatusState.test.ts (needs-sync cases), mapChapterAssignment.test.ts

How to verify

  1. npm run format:check && npm run lint && npm run typecheck && npm test -- --ci
  2. My Work: Sign in as a user with assigned chapters (e.g. mrace+t@gloo.us on dev) → confirm My Work populates without manually tapping sync; cloud icon briefly shows amber then syncs
  3. Prepare for Offline: Settings → Prepare for Offline → select project → confirm book accordions and chapter grid
  4. Assigned user: accordion collapsed, assigned chapters pre-selected, header shows "Assigned chapters (n)"
  5. Unassigned user: accordion expanded, no pre-selection, header shows "Selected chapters (n)"
  6. Toggle individual chapters and book "Select all"; confirm counts update live

Expected: My Work shows assigned chapters after launch sync; cloud icon reflects stale data; chapter selection UI matches #50 scope. No download button or resource tiers (#51 deferred).

Follow-ups

Add project picker, chapter selection accordion with per-book grids,
and a dedicated prepare-offline query module to avoid conflicts with
in-flight recording PRs.
@mattrace-gloo mattrace-gloo marked this pull request as ready for review July 10, 2026 02:34
Sync role-filtered chapter assignments from the web My Work endpoint,
auto-repair stale local data on launch, and show a cloud indicator when
download sync is needed. Refactors Prepare for Offline components and
Settings/header layout.
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.

Build Prepare for Offline Screen with Chapter Selection

1 participant