CUI

Components / AI interfaces

Reasoning and tool calls

A folding block for a model's reasoning, and a row for each tool it calls with its status.

Functions: cui_reasoning, cui_tool_call

Reasoning and tool calls

Usage

cui_reasoning(ui, "think", .thinking = streaming, .seconds = elapsed) {
    cui_text(ui, thoughts, .size = 13.5f, .color = CUI_COLOR_TEXT_SECONDARY);
}
cui_tool_call(ui, "search", "web_search", .icon = CUI_ICON_GLOBE, .detail = query, .status = CUI_TASK_DONE, .seconds = 1.4f,
              .input = request_json, .output = response_json);
cui_tool_call(ui, "read", "read_file", .detail = "quarterly-report.pdf", .status = CUI_TASK_RUNNING);

While thinking, the reasoning header shimmers and counts up; when it ends, the block folds to "Thought for 8s". Clicking the header opens or closes it, and from then on your choice sticks. A tool call shows its status as a ring, a spinner, a check or a cross, with the time. Clicking it opens the input and output, which are highlighted as JSON when they look like JSON.

Keyboard

  • Tab focuses a reasoning block's header or a tool call, and Enter or Space folds or unfolds it.

Options of cui_reasoning

OptionTypeDefaultDescription
.thinkingboolstill thinking: the header shimmers and the body opens; it folds when this turns false
.secondsfloattime spent, for the header: "Thinking for 12s", then "Thought for 12s"
.titleconst char *header text to show instead of the "Thinking" and "Thought for" lines

Options of cui_tool_call

OptionTypeDefaultDescription
.statuscui_task_statusOne of CUI_TASK_PENDING, CUI_TASK_RUNNING, CUI_TASK_DONE, CUI_TASK_FAILED or CUI_TASK_SKIPPED.
.iconconst char *An icon: a CUI_ICON_* constant, or a string from another icon font.
.detailconst char *muted text after the tool's name, e.g. the file or query it works on
.inputconst char *what was sent to the tool; the row then opens to show it (as JSON when it parses)
.outputconst char *what the tool returned, shown when open; labelled "Error" when the status is failed
.secondsfloathow long the call took, shown at the end of the row unless it is pending; 0 hides it

Related