# NexStream Android TV Remaining-Work Completion Pattern

Use this when finishing leftover Android TV app work after autonomous-agent runs or broad audit phases.

## User expectations

- Research first, then implement. For each remaining class of work, check authoritative Android docs plus GitHub/forum/community patterns where relevant.
- Do not hand Cursor/OpenCode/Claude a giant catch-all prompt. Use small chunks with explicit scope and stop conditions.
- Build/test after each implementation batch. Do not accumulate many edits before the next Gradle check.
- Finish with zero build errors. Include debug and release builds when touching Gradle/R8/manifest/release behavior.

## Research targets by remaining-work type

- Android TV UI/focus: Android TV quality guidelines, TV navigation docs, android/tv-samples, Compose TV focus patterns.
- File backup/import: Storage Access Framework docs, ActivityResultContracts CreateDocument/OpenDocument, secure file-sharing docs.
- Room backup: Room DAO/entity docs; prefer read-only DAO additions and existing upsert/insert paths to avoid schema bumps.
- Addon/control-center UX: TV-readable cards, status summaries, clear focus/action hints, health/error states, safe-mode visibility.
- Debrid/account UX: device-code/PIN/API-token flow patterns; never log/export tokens; show provider status, account expiry/traffic if available, refresh/disconnect actions.
- Release hardening: R8/ProGuard docs and actual `assembleRelease`; fix missing rules from generated `missing_rules.txt`, not guesses.

## Implementation discipline

1. Record research findings in `docs/REMAINING_WORK_RESEARCH*.md`.
2. Inspect current repo surfaces before editing: screens, ViewModels, DAOs, manifest, Gradle, ProGuard.
3. Implement one batch at a time.
4. After each batch run at least `./gradlew compileDebugKotlin`; for functional screen/data changes run `testDebugUnitTest assembleDebug`; for release/Gradle/R8 changes run `assembleRelease` too.
5. If an agent/model is capped, stalls, or touches no files, stop retrying giant prompts and either switch to a smaller chunk or implement directly.
6. Update `docs/REFACTOR_LEDGER.md`, final handoff docs, and QA checklist.

## Safe backup rules from this session

- Export non-secret settings, public profiles, watchlist, and watch progress.
- Exclude debrid tokens, Trakt tokens, API keys, cookies, PIN hashes/salts, tokenized addon URLs, and diagnostic URLs.
- Prefer SAF document picker over raw filesystem paths.
- Keep Android `allowBackup=false` unless explicitly re-audited.
