CUI

Components / AI interfaces

Agent plan and status

The steps an agent is working through, and a pill that says what it is doing now.

Functions: cui_agent_plan, cui_agent_status

Agent plan and status

Usage

cui_plan_step steps[] = {
    { "Search for sources", "3 results", CUI_TASK_DONE },
    { "Read the attached report", "Page 12 of 40", CUI_TASK_RUNNING },
    { "Draft the summary", NULL, CUI_TASK_PENDING },
};
int step = cui_agent_plan(ui, "plan", steps, 3, .title = "Research plan");
cui_agent_status(ui, "Reading quarterly-report.pdf", .status = CUI_TASK_RUNNING, .seconds = elapsed);

The rail fills up to the step in progress, the running step shimmers, and the header counts finished steps with a progress bar. The status pill shows loader dots while running and a check or a cross when done.

cui_agent_plan returns the index of the step that was clicked this frame, or -1. steps is your array and is only read: you change each status as the agent moves on. A step is a title, a detail line that may be NULL, and one of CUI_TASK_PENDING, CUI_TASK_RUNNING, CUI_TASK_DONE, CUI_TASK_FAILED or CUI_TASK_SKIPPED. Pending is the zero value. The header counts done and skipped steps as finished, and shows title, or "Plan".

cui_agent_status returns nothing, takes no id and keeps no state. status is pending when not set. seconds is the elapsed time you measured, shown as "42s" or "1m 05s", and 0 hides it. icon replaces the mark of every status except running.

Keyboard

None yet. A step is clicked with the pointer; the status pill only displays.

Options of cui_agent_plan

OptionTypeDefaultDescription
.titleconst char *"Plan"heading of the plan, default "Plan"

Options of cui_agent_status

OptionTypeDefaultDescription
.statuscui_task_statusOne of CUI_TASK_PENDING, CUI_TASK_RUNNING, CUI_TASK_DONE, CUI_TASK_FAILED or CUI_TASK_SKIPPED.
.secondsfloatelapsed time shown after the text, as 42s or 1m 05s; 0 hides it
.iconconst char *An icon: a CUI_ICON_* constant, or a string from another icon font.

cui_plan_step

FieldTypeDescription
titleconst char *the step's text; shimmers while the step is running
detailconst char *smaller muted line under the title (red when the step failed); may be NULL
statuscui_task_statusOne of CUI_TASK_PENDING, CUI_TASK_RUNNING, CUI_TASK_DONE, CUI_TASK_FAILED or CUI_TASK_SKIPPED.

cui_task_status: CUI_TASK_PENDING, CUI_TASK_RUNNING, CUI_TASK_DONE, CUI_TASK_FAILED, CUI_TASK_SKIPPED

Related