Skip to content

feat: foundation — Home/Drafts, SQLite storage, draft-backed recorder - #1

Merged
morepriyam merged 8 commits into
mainfrom
feat/foundation-home
Jun 5, 2026
Merged

morepriyam merged 8 commits into
mainfrom
feat/foundation-home

Conversation

@morepriyam

Copy link
Copy Markdown
Collaborator

Foundation for pulse-new: the app shell, a reactive SQLite storage layer, and a fully draft-backed recorder. Everything flows through the draft model — the seam the recorder and (upcoming) timeline editor both depend on.

What's included

App shell & Home

  • Expo Router shell: stack with gesture root, safe-area provider, light/dark theming, status bar
  • Home/Drafts screen — reactive useLiveQuery list, draft cards (clip count, trim-aware duration, runtime cover frame), empty state, New (+) FAB
  • Pulse theme tokens (brand red accent, light/dark)

Storage (SQLite + Drizzle)

  • projects + segments schema encoding the non-destructive edit model (originalFilename never mutated; trims/splits are metadata)
  • Single connection with enableChangeListener (powers live queries) and FK cascade
  • Migration gate blocks app start until the schema is ready
  • Draft mutations: create / addSegment / deleteSegment / reorder / rename / delete, each autosaving lastModified

Recorder (Phase A — persistence)

  • CameraView with JIT camera+mic permission gate (Settings fallback)
  • Clips moved out of cache into Documents/drafts/{id}/segments/ as relative paths, absolutized at runtime
  • Each clip autosaved as a segments row on stop; segment bar driven by useLiveQuery
  • Resume a draft from Home via draftId; lazy draft creation + empty-draft cleanup on exit
  • First-frame thumbnails generated at runtime (no disk persistence, no extra dep)
  • Native clip duration via expo-video (not a JS timer)
  • Camera controls (flip / flash / stabilization) + hold-and-drag clip reorder + inline delete

Structure & tooling

  • Recorder refactored into src/features/recorder/ (two hooks + presentational components); recorder.tsx is a thin orchestrator. Convention: components/ = shared, features/<screen>/ = feature-scoped
  • Prettier configured + wired into ESLint; codebase is tsc-, lint-, and Prettier-clean

Not in scope (next)

  • Timeline editor (real Milestone 0) — timeline.tsx is a stub; draftId is already passed in
  • Native export module (AVFoundation / Media3) and upload flow
  • Recorder polish: hold-to-record, clip import, tap-to-preview, zoom gesture

See docs/implementation-status.md for the full status, edge-case backlog, and phased plan.

Testing

Camera needs hardware (npx expo run:ios / run:android). Verified on device: record from +, persistence across app kill, resume from a card, delete, reorder, lazy creation, and empty-draft cleanup.

Strip create-expo boilerplate to a minimal native-first shell and build
the first screen.

- Root layout: Stack with gesture root, safe-area provider, system
  light/dark nav theming, status bar
- Theme: add Pulse brand red (#F01E21) accent + border/onAccent tokens
  for light & dark
- Home/Drafts: brand header, elegant empty state, red New (+) FAB
- Recorder placeholder route so the + flow is navigable
- Switch ios/android npm scripts to dev-build (expo run:*)

Verified on iOS simulator in light & dark.
Add the persistence backbone (plan §3) and make Home render real drafts.

- Schema: projects + segments with the non-destructive trim model
  (originalFilename never mutated; trim = in/out ms; split = second row
  on the same file). Cascade delete segments with their project.
- Drizzle + expo-sqlite: single connection (enableChangeListener),
  foreign_keys pragma, generated migrations applied at startup via a
  MigrationGate that gates the app until the schema is ready.
- babel (inline-import .sql) + metro (.sql sourceExt) for migration bundling.
- Home: reactive useLiveQuery with a trim-aware duration aggregate;
  DraftCard (thumb/name/clip count + duration/relative date); empty state
  preserved. __DEV__ seed/clear controls to exercise the list pre-recorder.

Verified on iOS simulator: migrations run, list reacts to inserts live,
effective duration (8.2s + trimmed 3s = 0:11) computed correctly.
Snapshot of build state vs. design docs: what's done (storage layer +
app shell), the gaps (build-order inversion, recorder not yet wired
through the draft model), and a phased plan (A: persistence seam,
B: timeline editor, C: native export, D: upload). Cross-linked to
pulse-new-plan.md decisions.
Add the recorder (#2): expo-camera CameraView with just-in-time
camera+mic permissions, tap-to-record, bottom segment bar (inline
delete), and → to the timeline. Register recorder + timeline as
full-screen modals; timeline is a placeholder stub for now.

Infra: add expo-camera/expo-video/expo-file-system, Android camera
permissions + package id, and a prebuild plugin disabling Xcode
script sandboxing so the bundle phase can write ip.txt on device.

Segments are still in-memory only — wiring the recorder through the
draft model is Phase A (see docs/implementation-status.md).
- Add right-side control rail: flip (facing), flash (enableTorch,
  back-camera only), and stabilization cycling all four
  videoStabilizationMode values with a mode caption.
- Generate first-frame thumbnails for recorded clips via expo-video's
  createVideoPlayer + generateThumbnailsAsync (expo-video-thumbnails is
  deprecated in SDK 56); wait for player readiness so extraction isn't
  empty, render via expo-image with the icon as a pending fallback.
- Inset the segment delete badge so the horizontal ScrollView no longer
  clips it; dark backing for contrast over bright thumbnails.
- Default stabilization to 'off' so the preview FOV matches the
  recording (no zoom jump at record start; richer modes stay opt-in).
Phase A — close the persistence seam so recorder/editor talk only
through the draft model (no live session object):
- file-store util: move recorded clips cache -> Documents/drafts/{id}/
  segments, store relative paths, absolutize at runtime
- draft mutations (create/add/delete/reorder/rename/delete) with
  autosave + lastModified bump; segmentsForDraft + firstSegmentFilename
- recorder writes each clip on stop, bar driven by useLiveQuery, resume
  by draftId, lazy draft creation, empty-draft cleanup on exit
- thumbnails derived at runtime from the persisted clip (no disk
  persistence, no new dep) in both segment bar and draft cards
- native clip duration via expo-video (not a JS timer)

Refactor recorder.tsx (459 -> 114 lines) into a thin orchestrator over
src/features/recorder/ (use-recorder, use-recorder-permissions,
permission-gate, camera-controls, segment-bar, close-button).

Code quality: strip template/redundant comments, drop dead code
(BottomTabInset, MaxContentWidth, ThemedView light/darkColor props),
fix the web color-scheme lint error.

Tooling: add Prettier (config + scripts) and wire eslint-config-prettier.
@morepriyam
morepriyam merged commit 491008b into main Jun 5, 2026
1 check passed
@morepriyam
morepriyam deleted the feat/foundation-home branch June 8, 2026 17:45
morepriyam added a commit that referenced this pull request Jun 13, 2026
feat: foundation — Home/Drafts, SQLite storage, draft-backed recorder
morepriyam added a commit that referenced this pull request Aug 12, 2026
…advisories

Bumps transitive dependency resolutions already permitted by existing
semver ranges declared by Expo's own packages and devDependencies:

- js-yaml 3.15.0 -> 3.15.1 (babel-plugin-istanbul, dev-only)
- js-yaml 4.3.0 -> 4.3.1 (@expo/xcpretty, eslint's @eslint/eslintrc)
- brace-expansion 5.0.7 -> 5.0.9 (minimatch used by @expo/cli,
  @expo/config, @expo/config-plugins, @expo/fingerprint,
  @expo/metro-config)
- brace-expansion 1.1.16 -> 1.1.18 (eslint's minimatch@3)

No package.json ranges were changed and no Expo/framework versions
were bumped or overridden - these are patch-level fixes already
allowed by the existing dependency graph.

Closes dependabot alerts #14, #13, #11, #8.

Note: the following dependabot alerts remain open and are not
fixable via a lockfile refresh:
- #17, #16 (image-size DoS): no patched version exists upstream;
  image-size is archived and pulled in transitively via metro, even
  on the latest metro/expo releases. Needs an upstream fix in Metro.
- #2 (uuid missing bounds check): the xcode package (used by
  @expo/config-plugins) pins uuid@^7.0.3 and has not bumped it in
  its latest release. Not practically exploitable here since xcode
  only calls uuid.v4() with no output buffer (the affected code path
  is v3()/v5()/v6() with a caller-supplied buffer).
- #1 (esbuild dev server): comes from drizzle-kit's deprecated
  @esbuild-kit/esm-loader dependency, unrelated to Expo/Metro's dev
  server (already patched). Dev-only, low real-world risk since
  @esbuild-kit only uses esbuild's transform API, not serve().
@morepriyam morepriyam self-assigned this Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant