# PIXIESPROUT HANDOFF — 2026-08-07 (session 3.1h)

## CRITICAL BUG: APK built with STALE JS bundle — fixes NOT in installed APK

Bekky downloaded + installed `pixiesprout-1.0.112-arm64.apk` (versionCode 139) and
**NONE of today's fixes are present.** Root cause (high confidence):

- The server build ran `./gradlew assembleRelease` WITHOUT `./gradlew clean` first.
- Build output showed `1025 up-to-date` tasks — Gradle reused cached artifacts and
  did NOT re-bundle the new JS. The `createBundleReleaseJsAndAssets` task was cached.
- This is the EXACT pitfall documented in `pixiesprout-apk-build` skill:
  "Gradle caches version numbers... Always run `./gradlew clean` before `assembleRelease`."

## THE FIX (next session — do this FIRST)
On the German server (`root@46.4.121.190`), project at `/root/sgt_code_workspace/PixieSprout`:

```bash
cd /root/sgt_code_workspace/PixieSprout/android
export HOME=/root ANDROID_HOME=/opt/android-sdk
export PATH=$PATH:/opt/android-sdk/platform-tools
bash gradlew clean          # <-- CRITICAL: forces fresh JS bundle
bash build-and-sign.sh      # decrypts keystore pass from GPG, then assembleRelease
```

Then verify the bundle actually contains a fix marker BEFORE shipping:
```bash
unzip -p app/build/outputs/apk/release/app-release.apk assets/index.android.bundle | grep -c "Heads up about your pets"
# MUST be >= 1. If 0, the bundle is stale — do NOT ship.
```

## TODAY'S CHANGES (all synced to server, TS-verified 0 errors)
All in `/root/sgt_code_workspace/PixieSprout/` (server) and
`C:\Users\danam\SGT-FANTASTIC-08-06-26\Local\PixieSprout\` (local):

1. **Problem-scan fixes** (`screens/IdentifyScreen.tsx`):
   - Pill mismatch: `s.button` gets `marginTop: 0` in the 3 button rows (was 8)
   - Multi-photo flow: after capture → symptoms screen (June 11 design); "Analyze together" routes to real scan
   - "+" button now visible: `borderColor:'#BFD9B4'`, `backgroundColor:'#FFF9EE'`, green `+`
2. **Care preferences selectable** (`components/SettingsPanel.tsx`): Organic-first / Pet-safe / Edible / DIY-first / Store-bought chips now toggleable, persist to `appSettings.carePreferences`
3. **Care prefs fed to AI**: threaded App→IdentifyScreen→PlantModeScreen→plant ID prompt + problem scan prompt (`services/plantIdentification/xiaomiMimoProvider.ts`, `services/problemScanService.ts`, `screens/PlantModeScreen.tsx`, `screens/IdentifyScreen.tsx`, `App.tsx`)
4. **Pet-safety pop-up** (`screens/PlantModeScreen.tsx`): `petSafety` field on plant ID result; non-blocking Alert "Heads up about your pets" with "Add anyway" primary, only when `petSafeCaution` ON + plant toxic/caution
5. **Treatment warnings** (`services/problemScanService.ts` + `screens/IdentifyScreen.tsx`): `treatmentWarnings` field, shown as "⚠️ Safety notes" in case result; prompt enforces DIY-first, kids/pets organic, edible-plant harvest warnings, universal outdoor safe-application heads-up
6. **Export zero-byte fix** (`services/dataExport/dataExportService.ts`): `exportTempDir` + zip output switched from `cacheDirectory` to `documentDirectory` (cache fallback) — cacheDirectory unreliable on Android
7. **One-case-per-plant + points** (`services/investigation/*`, `screens/IdentifyScreen.tsx`, `screens/ProfileScreen.tsx`): `InvestigationPoint` type, `points[]`, `getOpenInvestigationForPlant`, `appendPointToInvestigation`, backfill legacy cases, `renderOpenCaseContext` feeds prior points to AI

## OTA SERVER STATE (verified correct, but device not applying)
- Latest released OTA: `6a75c495bce64410088d0757` (updateId `e02e1992-...`), gitCommit `safety-careprefs-20260807`
- Server chain 100% verified: 1 released, manifest serves new updateId, bundle hash matches, fix markers in bundle
- Device still shows old code even after force-stop/reopen/cache-clear → likely stale local OTA cache pin
- **The APK (once rebuilt with clean) is the reliable fix** — same release keystore, installs over the top, preserves data

## DATA PRESERVATION (CRITICAL)
- The APK is signed with `pixiesprout-release.keystore` (CN=Dana, O=PixieSprout) — SAME key as installed app
- Installing over the top PRESERVES data (garden, plants, photos). NO uninstall, NO data loss.
- Export/import is a safety net only; export was broken (zero-byte) but now fixed in source.

## BUILD ENV (server)
- Java 17: `/usr/lib/jvm/java-17-openjdk-amd64`
- Android SDK: `/opt/android-sdk` (local.properties: `sdk.dir=/opt/android-sdk`)
- Keystore: `android/app/keystore/pixiesprout-release.keystore`, pass decrypted from GPG by `build-and-sign.sh`
- node_modules present on server
- APK output: `android/app/build/outputs/apk/release/app-release.apk` (~151MB)
- File server (same machine): `cp` APK to `/opt/fileserver/files/pixy/VoiceFlow/`, then create share link via API (see `file-server-german-vps` skill)

## NEXT SESSION ACTION PLAN
1. `bash gradlew clean` then `bash build-and-sign.sh` on server
2. Verify bundle contains "Heads up about your pets" marker (grep the .bundle)
3. Bump version to 1.0.113 / versionCode 140
4. Copy to fileserver, create share link, verify HTTP 200 + content-type
5. Give Bekky the link — install over the top, data preserved
