fix(snapshot): name the captured Android app in the snapshot header
Summary
After a failed open, the launcher was in front, but the snapshot -i header said Page: com.android.settings / App: com.android.settings, so an agent read launcher nodes as Settings. The Android snapshot helper's content classifier already reads window metadata. It now names one foreground application window, androidSnapshot.foregroundWindowPackage, using the same rule the presentation uses to hide stale windows: the window must be active or focused, at the highest layer, and not owned by android or com.android.systemui. Input-method and system windows are never application windows. The snapshot response's appName/appBundleId and the header name that app. A stale session-app window Android leaves behind is not foreground, so it cannot win. The session record keeps its app. The UIAutomator fallback, Appium and other platforms report no foreground window and still name the session app. snapshots.md documents this, including that a foreign app shows its package name.
8 files touched. Fixes #4483.
Validation
- Tested SHA
03ef82ac26, base9676eedac5. Round 3 replaced the window list with one foreground package after maintainer review. Round 5 kept the unchanged acknowledgement on main's identity. Live runs below are fromf1eb37a425. snapshot-content-recovery.test.ts: a stale, inactive, lower-layer session-app window under an active launcher names the launcher; an active system window above it and an IME window do not count. When only a framework window is active, it names nothing.snapshot.test.ts: a helper-route capture publishesforegroundWindowPackage. Deleting the metadata spread insnapshot.tsfails it.snapshot-app-identity.test.ts: the launcher case fails on base. The session label is kept when the session app is in front; the session app is named without the fact; with no session app, the foreground app is named; the stored session app stays put, and a repeated unchanged snapshot of a foreign app is acknowledged under that app's header.pnpm exec vitest run --project unit-core packages/platform-android/src packages/command-runtime/src/commands/capture: 143 files, 1505 tests passed.pnpm typecheckandpnpm check:quick: pass.- Live at
f1eb37a425: Pixel 9a API 37 emulator, T3 device command against a source daemon,android-helper0.21.37-dev. A failedopen com.android.settings --relaunch --foreground --session hdr(#4482, forced by three looping slice-provider clients), thensnapshot -i:
| Build | Header | foregroundWindowPackage | Node packages |
|---|---|---|---|
base 9676eedac5 | Page/App: com.android.settings | ā | launcher workspace |
| head | Page/App: com.google.android.apps.nexuslauncher | com.google.android.apps.nexuslauncher | com.google.android.apps.nexuslauncher, com.google.android.googlequicksearchbox (launcher search widget) |
Then open com.android.settings + snapshot -i shows appBundleId and foregroundWindowPackage com.android.settings.
š¤ Generated with Claude Code