Porthole

The debug-build entry point.

Installed automatically by PortholeInitializer on process start, so in the normal case the only things you call yourself are the register functions: they are what turn anonymous state objects into names an agent can reason about.

Everything here is a no-op in release builds, where the porthole-noop artifact with the same signatures takes its place.

Properties

Link copied to clipboard
const val DEFAULT_PORT: Int = 8677

The port used when nothing says otherwise.

Link copied to clipboard
const val ENABLED: Boolean = true

True in debug builds where the real runtime is on the classpath.

Functions

Link copied to clipboard

Makes a Compose view's semantics tree readable by the semantics_tree tool.

Link copied to clipboard

Undoes attachComposeView. Call it when the view goes away.

Link copied to clipboard
fun install(app: Application, port: Int = portFromResources(app))

Starts the porthole: collectors, and the socket the timeline and the MCP server connect to.

Link copied to clipboard
fun mark(label: String, detail: String? = null)

Marks a moment on the timeline.

Link copied to clipboard
fun nameState(state: Any, name: String)

Give a androidx.compose.runtime.State a readable name.

Link copied to clipboard

Tracks a NavController's back stack, arguments and deep link.

Link copied to clipboard
fun registerViewModel(name: String, viewModel: Any)

Names the state held by a ViewModel (or any object) so recomposition reports say CartViewModel.items instead of <unnamed:...>.

Link copied to clipboard

Reports a back stack the app owns itself, rather than one androidx holds.

Link copied to clipboard

Stops everything and closes the socket.