ScreenDebugTab
The Screen tab: the app's windows and the UI tree in each, under /api/v1/screen/, for agents and scripts that drive the app.
Register it from debug code:
// src/debug, LustroBootstrap
val screen = ScreenDebugTab.create(app) { """{"route":"${navController.currentRoute()}"}""" }
Lustro.builder(app).addTab(screen).build().start()GET tree returns every window of the app's process, the activity and each dialog, popup, and bottom sheet over it, in the order the app added them, with the nodes of each: the classic Views, and the Compose semantics nodes of each Compose host. A node carries its id, test tag, text, content description, role, its bounds in the window and on the screen in pixels, the part of it that is visible on the screen, whether it is enabled, its click and other semantics actions, its selected and toggle state, focus, editable text, and scroll position and range. A window carries whether it has the window focus: a window of another app, such as a permission dialog, can cover the app's while the app still answers, and then no window of the app has the focus.
The tab reads the same data as uiautomator dump, in the app's process: a read takes milliseconds instead of a second or more, sees every test tag, and does not wait for the screen to stop changing. GET tree?settle=500 waits, for up to that many milliseconds, until two reads in a row on consecutive frames give the same tree.
Compose is optional. The tab checks at runtime that the app has Compose UI and reads the semantics tree of each Compose host only then; the View tree it reads in every app. The text of a password field comes as one dot for each character, as the screen shows it.
The tab reads the windows on the main thread. A main thread that does not run the read within five seconds, plus the settle time, gets the client a 504 with the code main_thread_blocked, so a client of an app that does not respond does not wait for the request timeout.
The tab has no console view: it stays out of the tab bar, and _meta lists it. GET /api/v1/screen/_schema describes its routes.
Types
Factory for ScreenDebugTab.