Cartesiandocs

Android SDK

Embed in a screen

Put the assistant directly in your own layout, such as a tab, a pane or a dedicated screen.

CartesianChat is the assistant without a panel around it. It fills whatever space you give it.

@Composable
fun AssistantTab() {
    CartesianChat(Modifier.fillMaxSize())
}
kotlin

It uses Cartesian.client, Cartesian.options and Cartesian.listener by default. You can override any of them for one screen:

CartesianChat(
    modifier = Modifier.fillMaxSize(),
    options = Cartesian.options.toBuilder().title("Style advisor").build(),
    onClose = { navController.popBackStack() },   // shows a close button in the header
)
kotlin

Hoisting the controller

If you need to read or drive the assistant from outside, for example to show an unread dot, prefill the composer or react to state, create the controller yourself and pass it in:

val controller = rememberCartesianChatController()

LaunchedEffect(Unit) { controller.draft = "Snacks for a road trip" }

Column {
    if (controller.chat.isResponding) LinearProgressIndicator()
    CartesianChat(controller, Modifier.weight(1f))
}
kotlin

See the CartesianChatController reference for everything it exposes.

CartesianChat adds safe-drawing insets itself when it is embedded. Inside CartesianPanelHost only the navigation-bar inset is applied, because the panel already handles the rest.