Session status
Read session.status to show progress and decide when Send or Stop is available.
session. has the sealed type SessionStatus, so a switch can cover every case:
final class const StatusLine({super.key}) extends StatelessWidget {
@override
Widget build(BuildContext context) =>
switch (TandemSessionScope.of(context).status) {
Idle() => const SizedBox.shrink(),
Thinking(:final backendTool?) => Text('Using $backendTool…'),
Thinking() => const LinearProgressIndicator(),
Calling(:final tool) => Text('Running $tool…'),
AwaitingApproval(:final request) => Text(
'Waiting for you: ${request.tool}',
),
Stopping() => const Text('Stopping…'),
};
}Thinking. identifies the latest backend tool call, such as find_customer. The name lasts from TOOL_CALL_START until its result or the agent's next text or call. When several backend tools run, it identifies the latest call. Use it to show progress during a long turn. The order desk's searchCatalog is a method of the screen, so it runs as Calling with tool set to OrderDeskCubitTool.. The generated enum prints the name the agent knows, so the status line shows Running .
Thinking. is true while the agent draws a view for TandemView, from its tandem_show_view call until its next text or call. Match Thinking(drawing: before the general Thinking() case to show a drawing status.
Send and Stop
Call session. to send a message. While a run is open, the message appears in the chat and waits for the next run.
Call session. while the status is Thinking or Calling(approved: . Stop hides later text and prevents the remaining calls from running. A method already running continues to completion.
An approved method runs as Calling(approved: and cannot be stopped. Disable Stop until it returns.
Stopping means Tandem is still reading the stopped run's stream to its end. A new message waits until that finishes. This keeps the backend's conversation consistent.
Statuses compare by value, so select and distinct can ignore repeated values that describe the same state.