Update this file EVERY session with new findings. Persistent handoff memory. Covers: pipapk (Android overlay app), isotope-apk-ref (Capacitor app), server.mjs pip API, CI pipeline, ADB workflow.
getPatchedCommunityBundleinserver.mjsnow carries BOTH anchor forms for each of its 16 null-safety guards: the upstream isotopeai.in form first, the served-build form second. Verified by execution: 16/16 fire on the served bundle, all sites guarded on the upstream bundle. This makes an upstream asset swap safe β the same patcher fires on either bundle.- The
OWN_UID_BUDDY/OWN_UID_GROUPblocks stayed standalone (they pushinvite-own-uid-*into_criticalPatchFailures) and gained the upstream anchor as a fallback candidate. Do NOT merge them into the isoGuard table β that double-patches and breakstest-bundle-patch-escalation. - UPSTREAM DIVERGENCE (verified 2026-11-02, isotopeai.in): the new build REMOVED group chat (zero "chat"/"messages"/"getGroupMessages" in Community-C50D_1u4.js), the leaderboard tab (21β1), create-group button, and invite-code dialogs. The 7,940-char chat component lives ONLY in server.mjs (COMMUNITY_CHAT_COMPONENT_TO) β migrating bundles without re-authoring those anchors ships a Community page with no chat. Decision recorded in
docs/preview/UPSTREAM-SYNC-DECISION.md. - Simple Mode chunks (SimpleFocus/SimpleTasks/SimpleToday/SimpleProgress/SimpleSettings/SimpleSyllabus/SimpleTaskRow/SimplePrimitives) exist in
public/assets/byte-identical to upstream but are ORPHANS: the served App-CQ9mV4wu.js (22 KB) has zero refs to them; upstream App-Bl00Vir8.js (172 KB) dynamically imports all 8. Wiring them in requires replacing the App bundle and its 6 missing deps β part of the blocked migration.
- User directive (late night): "see planning file of apk β you have overdone" β the plan is
pipapk.mdin the repo root (Option A RECOMMENDED): native PiP companion, NO WebView; 750ms poll ofGET /api/pip/state; native card render; POST actions to/api/pip/action; auto system PiP 340:390; offline badge. - Fix committed (0b3f2c9): Added missing
targetEditorRow: LinearLayout?field declaration inFloatingTimerService.kt:83to resolve compile errorUnresolved reference: targetEditorRow. - ADBs in rotation (update on connect): Primary: 127.0.0.1:34111 (sleepy); Secondary: 10.171.170.148:45875 (just updated).
- Pending: Trigger CI to verify build 0b3f2c9 green β download APK β install on 10.171.170.148:45875.
- Rebuilt (uncommitted, in progress of CI):
TimerState.kt(new): shared snapshot parser (keys = PIP_BRIDGE_JS relay 1:1), moved out of service.PipClient.kt(new): zero-dep HTTP client βfetchState(ui){state,ok,seq}+postAction(type,value).PipActivity.kt(rewritten): NO WebView β native card (piP card per Β§4b contract: heading/ time 56sp mono/status dot+label/chip/attempts+Target dialog/βββ·/Undo/progress strip), 750ms poll- 250ms tick, auto
enterPictureInPictureMode(Rational(340,390))on active (guarded once/session,onUserLeaveHinttoo), offline badge, "Float" pill β FloatingTimerService.
- 250ms tick, auto
FloatingTimerService.kt(simplified): dropped SSE thread + 1s poll β shared PipClient 750ms poll (seq-diff render) + 250ms tick; card UI/drag/resize/FGS unchanged; keep expand/close.- Manifest: PipActivity
supportsPictureInPicture="true"added.
- The app now REQUIRES a /focus page running somewhere (Cromite/WebView) as the state owner β APK is a pure remote view/remote control (pipapk.md Β§5 owner model).
- Previous state: ac77b1a/0c9da43 (WebView shell, installed+tested), d24fc37 (native card port with
WebView main UI β build
31386282787green, installed, blocked by device sleep mid-test; superseded by this Option-A rebuild). - pipapk.md checklist to verify on device: state activeβauto PiP; buttons change counts in app UI + polls; overlay mode + FGS notification; 750ms cadence; server-down badge.
| Piece | What it is | Where |
|---|---|---|
isotope-code |
The real product: React/Vite web app (focus timer), Node server.mjs | repo root, this repo |
pipapk/ |
Android APK: shell showing the REAL isotope web UI in a WebView (like isotope-apk), with a draggable floating window over other apps | pipapk/ |
isotope-apk-ref/ |
CURRENT TARGET β Capacitor wrapper with NATIVE floating timer card + PiP (appId in.isotopeai.app) |
isotope-apk-ref/ |
~/.agents/skills/, repo isotope-apk-ref/.agents/skills/ |
Skills: ui-ux-pro-max, android-kotlin, android-adb, github-actions-efficiency, nodejs-backend-patterns | both locations |
- User rejected the custom-drawn Kotlin card + 10ms polling mirror ("video streaming inside an app", "dumb thing", "bad ui").
- User directive: "i want it like isotope-apk" β the APK must show the actual isotope web UI, not a bespoke mirror card.
- Current correct design (rewrite, commit pending):
PipActivity= full-screen WebView βhttp://127.0.0.1:3000/focus(real compiled UI; state owner = server/browser).FloatingOverlayService= draggable overlay WebView window (same URL) with drag bar + close. Permission banner for display-over-other-apps + "Float" button. No FGS, no polling, no notification, no PiP card, no boot receiver. - Deleted:
PipBridgeService.kt,PipState.kt,BootReceiver.kt. Manifest pruned to INTERNET + SYSTEM_ALERT_WINDOW only. Gradle deps trimmed to justandroidx.core:core-ktx.
- Server:
bin/isotope restartrestarts (logs~/.isotope/logs/server.log), listens127.0.0.1:3000. - Real UI served at
http://127.0.0.1:3000/focusβ bundle includes injectedPIP_BRIDGE_JS(relays focus-store state toPOST /__pip/state; single-line; guarded by!raw.includes('__pipBridge'); appended at END of bundle ingetPatchedFocusBundleβ both polyfill prepend and bridge append must keep output single-line fornode --check). - localStorage sync/bootstrap infra reconciles multiple storages (Cromite vs WebView are separate partitions). Server + browser = state owners; APK is a pure window.
- Real Capacitor project in-repo:
capacitor.config.json(appIdin.isotopeai.app, name IsotopeAI, version v3.3.9, webDirwww, androidSchemehttps,webContentsDebuggingEnabled: true, appendUserAgentIsotopeAI-Android/3.3.9),android/Gradle project,scripts/prepare-www.js. - Build chain:
npm run prepare-www(buildswww/from repo-rootindex.html+public/, injectsandroid-bridge.js+android-floating-timer-bridge.js) βnpm run apply-patchesβnpx cap sync androidβcd android && ./gradlew assembleDebug --no-daemon(scriptandroid:debug). - Permission story: OVERLAY (SYSTEM_ALERT_WINDOW) + PiP + FGS specialUse + exact alarms all declared; Android 14/15 will ask for each at runtime β overlay/PiP need user grant on device.
- Read
isotope-apk-ref/AGENTS.md+.agent/docs before touching its code (repo rule). - Deprecation risk to check: vanilla JS classes (FlipTimer/TimerQuirk) with default timer-native-durations vs web app's TimerPipBridge semantics β verify parity of timers on first device test.
4. Server pip API (server.mjs, before 404 fence ~line 6570) β VERIFIED LIVE THIS SESSION (exact lines)
GET /api/pip/state(6573): cached snapshot +seq(monotonic) +pipClients(SSE subscribers). Default/empty cache shape (6575-6583):{ok,active:false,timerState:'idle',mode,activePhase:null, displayedSeconds:0,totalSeconds:0,completionAtMs:0,updatedAtMs,pomodoroCycle:1, pomodoroSessionsUntilLongBreak:4,questionsAttempted/Correct/Incorrect/Skipped:0,targetQuestions:0, undoAvailable:false,showQuestionControls:false,focusTypeLabel:'Focus',focusTypeIcon:'',theme:'dark', pipConnected,pipStateAt}β keys match TimerState.fromJson() 1:1 (no mapping needed).POST /api/pip/action(6588): JSON body{type, value}; allowlistcorrect|incorrect|skipped|undo| setTarget|expand|close; 400 on unknown type;setTargetrequires numeric, clamped 0-9999; response{...snapshot, applied:true, seq}; broadcasts{type, value, ts, seq}to ALL SSE clients.POST /__pip/state(6615): page relay stores cache +pipSeq += 1. No SSE broadcast on snapshot.GET /__pip/events(6632): SSE carries ONLY action envelopes{type,value,ts,seq}+: pingheartbeats β NEVER snapshots. β native clients must (re)poll/api/pip/state; seq-diff renders.- THE ACTION LOOP IS REAL β
PIP_BRIDGE_JS(injected into the /focus bundle, line 4246) hases.onmessage:correct|incorrect|skippedβs.recordQuestionResult(type);undoβs.undoLastQuestionResult();setTargetβs.setTargetQuestions(value). So: card POST β server SSE β page applies to REAL store β page relays new snapshot β cache β card re-renders. Buttons drive the ACTUAL timer, no mirror. Bridge relay payload (thepush()fn) is the same key set as above. - Live check this session:
curl /api/pip/stateβ{"active":true,"timerState":"running",..., "displayedSeconds":100,"totalSeconds":1500,"completionAtMs":99999999999999,...}.
- Workflow
.github/workflows/pip-apk.yml: pathspipapk/**; checkout@v4; temurin 17;gradle/actions/setup-gradle@v4;./gradlew :app:assembleDebug; upload artifact. Repo is PUBLIC β no secrets needed. Already lean: path filter,concurrency: pip-apk-${{ github.ref }}cancel-in-progress,timeout-minutes: 20. - Polling:
curl -H "Authorization: Bearer $GITHUB_PAT" .../actions/runs?per_page=1(PAT stored in.envat repo root). Artifact download:.../actions/artifacts/<ID>/zipwith-L(302) β must write to~/.cache/opencode/tmp/..., NOT/tmp(does not exist in Termux!). - CI debug key changes EVERY build (fresh runner, no keystore cache) β
adb install -rfails withINSTALL_FAILED_UPDATE_INCOMPATIBLEβ alwaysadb uninstall in.isotopeai.pipbefore install. - Stack: AGP 8.5.2, Kotlin 1.9.24, Gradle wrapper 8.7, JDK 17, compileSdk 35, minSdk 24.
- Remote races: automated
docs(screenshots)commits land on main β push can be rejected βgit stash && git pull --rebase origin main && git stash poppattern. - Last green run:
31371202541(success), artifact9056139608, APK 2,234,950 B. Skills commit7161d65(CodeQL31377721739, CI31372765985green). WebView commitac77b1a: Build PiP APK31382113320FAILED (FLAG_KEEP_SCREEN_ON); CodeQL/CI/Release still ran green.
12 workflows: auto-label, ci, codeql, dependency-review, pages, pip-apk, regenerate-release, release, schema-lint, screenshots, stale, welcome.
Waste sources (evidence from live runs):
ci.yml(Lint & Health, matrix node 20+22) β NO path filter: runs on EVERY push incl. screenshots-bot commits and pipapk-only commits.codeql.yml(most expensive job) β NO path filter: runs on every push/PR + weekly cron.release.ymlβ fires on every push to main (not just tags): created/updated a Release for the pipapk-only commit ac77b1a; doesnode --checkon 10 files + changelog extraction + release API each time.screenshots.ymlβ triggers onserver.mjschanges β produces the racingdocs(screenshots)bot commits (the recurring push-race cause). Bot commits then re-trigger ci/codeql/release wastefully.
Fixes to apply (top 3, guardrail-checked):
- ci.yml:
paths-ignore: [pipapk/**]+ jobif: github.actor != 'github-actions[bot]'(skip re-linting bot screenshot commits). Keep matrix (no explicit removal commitment; node 20 deprecation warnings visible in every log). - codeql.yml: same
paths-ignore+ actor gate (pipapk-only commits never touch JS analysis targets β no validation hidden). - release.yml:
pushtrigger getspaths:(package.json, CHANGELOG.md, server.mjs, public/, scripts/, docs/**, .github/workflows/release.yml, .github/workflows/screenshots.yml) β tags + workflow_dispatch unchanged.
Validation note: compile of the Kotlin fix + workflow gates is validated ONLY by the next CI run (no local JDK); the actor-gate behavior is standard GH Actions and low risk.
- Port changes often β asks user, e.g. 34111. Loopback
adb connect 127.0.0.1:<port>always works. Old: 10.191.181.183:34163 (dead), 10.171.170.148:45355 (dead). adb -s 127.0.0.1:34111 install ~/isotope-pip.apk,adb -s ... shell am start -n in.isotopeai.pip/app.isotopeai.pip.PipActivity(applicationIdin.isotopeai.pip, componentapp.isotopeai.pip).- Screen: 1720x2408 portrait, density override 306 (scale 1.9125) β BUT screencap often returns rotated 2408x1720 (landscape) β always read PNG header, don't assume orientation.
- uiautomator dump fails "could not get idle state" whenever the app animates continuously (Choreographer tickers) β use
screencap+~/.cache/opencode/tmp/pip-apk/new/pngscan.py(pure-python PNG decoder + brand-color cluster finder) to locate buttons. This model cannot view images β never rely on Read for screenshots. - Successful uninstall/install test:
u0_a612 2353 ... S in.isotopeai.pipprocess confirmed;mCurrentFocuscheck viadumpsys window.
inis a Kotlin keyword β packageapp.isotopeai.pip; applicationIdin.isotopeai.pip(launch command uses applicationId prefix).returninsideThread { }lambda illegal β usebreak(moot now β no manual threads).coerceAtMost(Int)on Long receiver returns Long β add.toInt().FrameLayout.gravitydoes not exist βFrameLayout.LayoutParams(w, h, Gravity.CENTER).ViewGroup.getChildAt()returnsView!β cast before typed use (we fixed via destructured Pair).- Cleartext HTTP: manifest
usesCleartextTraffic+res/xml/network_security_config.xml(cleartext allowed only for 127.0.0.1/localhost) β WebView JS/localStorage needjavaScriptEnabled/domStorageEnabled. - Kotlin port-of-Java gotchas (hit in the FloatingTimerService port):
Math.max(long,long)β Kotlin has no int/long overload mixing βMath.max(0L, x); Java(int)casts β.toInt()((screenW*0.36f).toInt());Typeface.MONOSPACE_BOLDis API 28+ β useTypeface.create(Typeface.MONOSPACE, Typeface.BOLD)for minSdk 24; localvalshadowing a field of the same name silently nulls the field (rename the local);Content-Type: application/jsonbody POST viaHttpURLConnection(doOutput + outputStream.use) works fine for the local server.
- Ripple press feedback on ALL buttons (
RippleDrawablewrapping pill, overlay0x33FFFFFF). - Touch targets >= 44-48dp; haptics (
CONFIRM, API 30+ guard) on timer actions; content descriptions on icon-only buttons. - 8dp spacing rhythm; tabular timer numerals (
setFontFeatureSettings("tnum")on O+). - NO emojis as icons (use text glyphs only where they are data, e.g. counters).
- Remaining pattern: Minimal Single Column, dark
#0F172A-class bg with violet brand#8B5CF6.
- No JDK/SDK on device β builds ONLY via GitHub Actions; Termux has node/npm/npx (skills CLI 1.5.22), adb, python3 (no PIL β use pngscan.py), bash, curl.
- Server runs in Termux; browser (Cromite) on same phone hits
127.0.0.1:3000/focus. session-ses_*.mdfiles are auto-generated session artifacts β do NOT commit.- Repo branches: work only on
main. Readisotope-apk-ref/AGENTS.md+.agent/docs before touching isotope-apk-ref code.
- Overlay card gained header expand β / close Γ buttons (commit
65e12b2). - Free-size toggle button for corner-drag resize (commit
5ffec31). - Native system PiP mode added to PipActivity (commit
3137188): supportsPictureInPicture="true" in manifest, enterPip(340,390) with safe aspect ratio (clamp 1/2.39..2.39), onPictureInPictureModeChanged pauses the auto-start poll while minimized, "Enter PiP Mode" button on settings screen. - All three CI-built (GitHub Actions pip-apk.yml). Newest APK:
~/.cache/opencode/tmp/apk/app-debug.apk(2.1MB, isMinifyEnabled=false). - BLOCKED on on-device install: wireless ADB down (10.171.170.148:45355 unreachable). Need pairing IP:port + 6-digit code + connect IP:port.
- Overlay card: draggable + corner-handle resize WORKS after elevation fix (card elevation 4dp covered the handle; handle now 8dp elevation + 44dp touch target). Verified resize 536x612 -> 459x711 via input swipe.
- Native system PiP: "Enter PiP Mode" button -> mIsInPictureInPictureMode=true, task mode=pinned, pip-dismiss-overlay present. Verified.
- Device gotcha: ColorOS/OnePlus freeze manager aggressively kills the
FloatingTimerService in background; the stuck NotificationShade + "Display
over other apps" settings page needs
input keyevent 4x3 to dismiss. - Install: CI debug APKs have different signatures per run -> uninstall before
install (
adb uninstall in.isotopeai.pip). - adb on Termux: needs
HOMEset andTMPDIR=/data/data/com.termux/files/usr/tmp(/tmp doesn't exist, read-only). Device re-pairs: 10.171.170.148:45355 (old), then 192.168.1.8:39249/43999.