Repository navigation
fix(adb): read window focus from the displays section on Android 16 - #2998
cyberpunk47 wants to merge 1 commit into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
| it("reports focus as unknown when neither section declares it", async () => { | ||
| const { window, limitations } = await inspectWindow({ | ||
| "dumpsys:window:windows": "WINDOW MANAGER WINDOWS\n", | ||
| "dumpsys:window:displays": "WINDOW MANAGER DISPLAY CONTENTS\n", |
There was a problem hiding this comment.
Fallback errors lack test coverage
The new tests cover successful reads, but none checks a failed displays read. Add a case where windows declares no focus and displays exits with an error. Assert that inspect_adb_window returns the error rather than a successful unknown-focus result. Otherwise, a future change could hide a failed device read without breaking these tests.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/adb/AdbProvider.test.ts
Line: 1062-1065
Comment:
**Fallback errors lack test coverage**
The new tests cover successful reads, but none checks a failed `displays` read. Add a case where `windows` declares no focus and `displays` exits with an error. Assert that `inspect_adb_window` returns the error rather than a successful unknown-focus result. Otherwise, a future change could hide a failed device read without breaking these tests.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6b407ae2e6
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| maxOutputBytes: DUMPSYS_WINDOW_MAX_OUTPUT_BYTES, | ||
| }); | ||
| if (!fallback.ok) return fallback; | ||
| ({ focusedWindow, focusedApp } = parseWindowFocusOutput( |
There was a problem hiding this comment.
Select the focused display before parsing focus
On an Android 16 device with more than one display, AOSP's RootWindowContainer.dumpDisplayContents iterates getChildCount() and dumps each DisplayContent, so this fallback can contain several mCurrentFocus/mFocusedApp pairs (often null for an inactive display). Passing the whole stream to parseWindowFocusOutput, which retains only the first pair, drops display identity and can report a secondary display or literal null even when another display is focused. Select the top-focused/display-specific block before producing the singular result.
AGENTS.md reference: AGENTS.md:L23-L23
Useful? React with 👍 / 👎.
Share tagged readiness observations, retain partial provider facts, authenticate bridge identity, bound diagnostics, and preserve cancellation and lost-session reasons. Fail closed for unparsed MIPS ABI attributes and macOS saved Hopper databases without a script-capable bridge route. Reviewed fixes: #2010, #2108, #2513, #2695, #2731, #2771, #2828, #2867, #2868, #2870, #2880, #2919, #2945, #2961, #2981, #2998, #3000, #3002. Validation: 285 focused source/boundary tests passed. Real Ghidra, IDA, Linux Hopper, and Windows provider runs were not repeated. BREAKING CHANGE: MIPS targets with unresolved GNU ABI attributes and saved Hopper databases on macOS are refused rather than advertised as supported.
Use one named input-schema projection for clients and catalog identity, preserve dialect declarations, and bound compact schema depth. Keep canonical SDK output validation when output advertisements are disabled. Release request-owned state on cancellation and carry upstream limitations through composed workflows. Preserve doctor full-output envelopes and validate navigation facts at their owner. Reviewed fixes: #2088, #2108, #2513, #2684, #2693, #2695, #2836, #2864, #2868, #2877, #2933, #2998, #3002, #3015. Validation: focused schema, SDK output-validation, context, and workflow tests passed; no schema dialect or canonical output validation was relaxed.
|
@morluto shall i close this pr as relevent fixes have been done. |
|
Heads up: main covers this in its own way in d4bd65c. The code is in 🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
|
Superseded by the delivered change on main: d4bd65c53. ADB foreground-window observation supports the Android 16 displays section, with the documented fallback and parser regressions already on main. Closing this earlier proposal. Current main qualification passed: https://github.com/morluto/rea/actions/runs/38690953281. |
|
Thanks @cyberpunk47 for the Android 16 display-section fallback case. Main includes the fallback handling. |
Summary
Fixes #2996
On Android 16,
dumpsys window windowsno longer printsmCurrentFocus/mFocusedApp, soinspect_adb_windowreturnednullfocus with no explanation while an app was on screen. When thewindowssection declares neither line, the provider now readsdumpsys window displays. Each result says which section supplied the values. When neither section declares focus, a limitation says focus is unknown, not absent.Problem and expected behavior
focused_window: null,focused_app: null,observed_lines: [].focused_window: "Window{… NexusLauncherActivity}",focused_app: "ActivityRecord{… t2}", plus the limitation "Focus declarations were read fromdumpsys window displays".Violated invariant (AGENTS.md): "Unresolved identity or applicability must remain unknown rather than be treated as absent, foreign, or aligned."
Change and scope
src/adb/AdbProvider.ts(inspect_adb_window):dumpsys window windowsfirst, so earlier builds behave as before.dumpsys window displays.src/contracts/adb/adbToolContracts.ts: the tool description names both sections.src/adb/AdbShellOutput.ts: the doc comment names both sections; parsing is unchanged.dumpsyscall on builds that need it.Contribution scope: not applicable (routine fix within existing boundaries).
Contract and boundary impact
inspect_adb_windowshell observationdumpsysonlydocs/public/product-catalog.json), package, or installation impact: none trackedExpected effects:
Evidence and regression coverage
src/adb/AdbProvider.test.ts):shellStubkeys can now name a third shell word (dumpsys:window:displays), so tests can tell the sections apart; existing two-word keys behave as before.windowshas no focus lines anddisplayshas both. Both values are reported, and the limitation namesdisplays.windowshas both lines.displaysis not stubbed, so a second call would fail the test.focused_windowisnull). The other two fail only on the new limitation text.windowshas 0 focus lines anddisplayshas both.windows-first order keeps their path unchanged.For evidence-bearing changes:
Validation performed
npx vitest run src/adb: 5 files, 116 tests passednpm run typecheck: passednpm run lint: no new diagnostics in changed files. The 2 existing errors (artifactComparison.test.ts,ManagedCilDecoding.test.ts) are also on main.oxfmton changed files: cleannpm run jscpd: 2.93%Compatibility, safety, and release
dumpsys window displayscall, only when the first section declares no focus; same timeout and output capBefore merge
type(scope): outcome.