Repository navigation
feat(import): background imports, multi-stage progress, and off-thread Fitbit parsing - #66
Merged
Merged
Conversation
…oundation Lay the groundwork for the import-experience redesign: - ImportController singleton outside the React tree owns the import lifecycle (services, worker pool, per-job AbortController), so imports survive navigation instead of being discarded on unmount. - useImportStore (Zustand) holds per-job progress; controller writes are rAF-coalesced (one store write per frame) with a test-env fallback. - Unified, serializable ImportJobProgress model (multi-stage + sub-items + throughput/ETA + capped errors) alongside the existing per-service progress shapes. - End-to-end cancellation: AbortSignal threaded through both services via a checkpoint() helper at existing yield points; cancel leaves IDB/OPFS consistent (per-day/per-batch + dedup idempotent). - useImport/useGoogleHealthImport refactored to thin subscribe+dispatch hooks that preserve their existing public API. - Design-system primitives: status/disclosure icons (check-circle, alert-triangle, x-circle, circle-dashed, circle-dot, spinner, chevron-up/down), import-stage status tokens (both themes), and ProgressBar size/tone variants. - ADRs 0026 (background import controller) and 0027 (Fitbit parsing in Web Workers). Refs: docs/decisions/0026, docs/decisions/0027 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qn5jBf8f5u1bXnC2ioq8pG
…f-thread Fitbit parsing Build the redesigned import experience on the new background architecture. Fitbit/Google Health parsing (ADR 0027): - Extract pure parser cores (intraday HR, SpO2, HRV, snoring) and move the heavy work into a dedicated fitbitParser.worker.ts, ending the multi-minute main-thread freeze. Parsing is chunked (~2,000 entries) with determinate per-file and per-chunk progress; ArrayBuffers are transferred in, one file per pool task to bound memory; the job AbortSignal cancels queued work. - Output proven byte-identical to the legacy path via golden-fixture and chunk-invariance tests. Storage path unchanged. - Granular per-data-type progress flows into ImportJobProgress.subItems so the intraday-HR substage shows a live determinate bar. Import UI: - ImportStageList: all stages visible from the start, each with its own pending/active/done/warning/error state (icon shape + text word + colour, never colour alone); indeterminate when totals are unknown (no fake 0%); expandable Fitbit sub-stages; throughput/ETA on the active stage. - ImportStatusDock: persistent bottom-left pill (mounted at RootLayout) that survives navigation, expands to a non-modal panel, shows overall weighted progress, confirmed cancel, and fires a completion toast. - ImportSummary: success / partial / error variants with per-file error disclosure and elapsed time. - ImportWizard adopts an active or terminal background job on mount, adds "Continue in background", surfaces a busy second-import attempt, and drops all emoji glyphs for themeable Icons. a11y: one quantized polite live region + an assertive region for terminals, indeterminate bars omit aria-valuenow, reduced-motion fallbacks, ≥44px targets, focus management. Refs: docs/decisions/0026, docs/decisions/0027 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qn5jBf8f5u1bXnC2ioq8pG
…ff-thread Fitbit parsing - CHANGELOG: populate [Unreleased] with the user-facing import changes (background imports + persistent indicator, multi-stage progress, off-thread intraday parsing, safe immediate cancellation, tab-close behavior). - Help: expand the "Importing Data" article (background import and the progress indicator, cancelling, de-duplication, closing the tab) and add "Background Import" and "Intraday" glossary entries. - Dev docs: point data-architecture user-flow at ADRs 0026/0027. Refs: docs/decisions/0026, docs/decisions/0027 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qn5jBf8f5u1bXnC2ioq8pG
- Add tests/e2e/import-redesign.spec.ts covering the headline journeys:
multi-stage progress list, background import surviving navigation (dock
persists across routes), confirmed cancel, completion toast on another
route, and reduced-motion spinner fallback (Chromium + Firefox).
- Fix dropped completion feedback when a CPAP and a Fitbit import finish
concurrently: track toasted/announced job ids in Sets so each terminal
transition toasts and announces exactly once (QA SHOULD-FIX).
- Migrate the pre-existing import-wizard E2E spec to the redesigned summary
("Import complete" / "Import finished with issues") with strengthened
stat assertions.
- Add stable data-testid/data-animated hooks to the dock pill icon and use
them in E2E instead of hashed-class selectors.
- NITs: 44px panel-close target, inline style moved to CSS module,
documented the test-only IndexedDBService cast in __resetForTests.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qn5jBf8f5u1bXnC2ioq8pG
kabaka
added a commit
that referenced
this pull request
Jun 23, 2026
…ging (#67) Two import follow-ups from the #66 reviews: (1) perf — stream Google Health heavy types to storage per file, bounding peak heap to ~O(one file) instead of O(whole data type) and fixing OOM risk on large multi-year Fitbit imports, with all 7 behavior invariants preserved; (2) refactor — route the 23 parser warn sites through a DEV-gated, error-name-only logging helper so no file-content fragments reach the console (security LOW-1). QA approved; security clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Reworks the data-import experience end to end, addressing the three reported pain points and several adjacent improvements. Designed and reviewed by the specialist agent team (ux, ui-design, performance) before implementation, then gated through
qaandsecurity.Problems solved
pending / active / done / warning / errorstate (icon shape + text word + colour, never colour alone).ImportControllersingleton backed by a dedicateduseImportStore. Imports now run in the background and survive navigation, surfaced by a persistent bottom-left status pill (expandable detail panel, confirmed cancel, completion toast) mounted app-wide.fitbitParser.worker.tswith chunked, determinate per-file/per-chunk progress — the intraday-HR sub-stage now shows a live bar instead of a multi-minute freeze.Also included
ImportJobProgressmodel (stages + sub-items + throughput/ETA + capped errors).AbortSignal+checkpoint()threaded through both import services; cancel stops work at safe boundaries and leaves IndexedDB/OPFS consistent (per-day/per-batch + de-dup idempotent).aria-valuenow, reduced-motion fallbacks, ≥44px targets, theme-correct.Architecture decisions
Correctness & safety
parseFitbitLegacyDateTime(timezone-load-bearing) is untouched.Testing
checkpoint/abort, throughput/ETA, worker equivalence, and the new UI.tests/e2e/import-redesign.spec.tscovers multi-stage progress, background-survives-navigation, confirmed cancel, completion toast, and reduced-motion (Chromium + Firefox; one documented skip). Pre-existing import spec migrated to the new summary copy.typecheck,eslint(0 errors), andbuild(worker emitted as its own chunk) all green.Follow-ups (non-blocking, noted by review)
console.warn(pre-existing).performancework).🤖 Generated with Claude Code
https://claude.ai/code/session_01Qn5jBf8f5u1bXnC2ioq8pG
Generated by Claude Code