Components / AI interfaces
Composer and model picker
The message box of a chat, with attachments, send and stop, and a menu for choosing the model.
Functions: cui_chat_composer, cui_model_picker

Usage
static char draft[4096];
static int model;
int ev = cui_chat_composer(ui, "composer", draft, sizeof draft, .placeholder = "Ask anything", .busy = generating,
.attachments = files, .attachment_count = n, .removed = &removed,
.models = models, .model_count = 3, .model = &model);
if (ev & CUI_COMPOSER_SEND) send(draft);
if (ev & CUI_COMPOSER_STOP) stop();
if (ev & CUI_COMPOSER_REMOVE) remove_file(removed);
The text area grows with its content up to max_lines, then scrolls. Enter sends and Shift+Enter starts a new line. Send stays disabled while the draft is empty, and while busy it becomes a stop button. The model picker can also be used alone: cui_model_picker(ui, "model", models, n, &model).
Keyboard
- Enter sends and Shift+Enter starts a new line.
Options of cui_chat_composer
| Option | Type | Default | Description |
|---|---|---|---|
.placeholder | const char * | Muted text shown while the field is empty. | |
.busy | bool | a reply is being generated: the send button becomes stop and Enter does not send | |
.attachments | const char *const * | names of the attached files, shown as chips above the text, each with an x | |
.attachment_count | int | number of attachments | |
.removed | int * | set to the index of the attachment whose x was clicked (with CUI_COMPOSER_REMOVE) | |
.models | const cui_model * | models for a picker beside the attach button; NULL for no picker | |
.model_count | int | number of models | |
.model | int * | index of the chosen model, read and written | |
.max_lines | int | 8 | default 8 |
.width | cui_size | Width: CUI_FILL, CUI_FIT, CUI_PX(n) or CUI_PCT(n); unset uses the component's own. |
Options of cui_model_picker
| Option | Type | Default | Description |
|---|---|---|---|
.ghost | bool | no border or fill on the button until hovered, for use inside another control | |
.placement | cui_placement | One of CUI_PLACE_BOTTOM_START, CUI_PLACE_BOTTOM, CUI_PLACE_BOTTOM_END, CUI_PLACE_TOP_START, CUI_PLACE_TOP, CUI_PLACE_TOP_END, CUI_PLACE_RIGHT_START, CUI_PLACE_LEFT_START, CUI_PLACE_RIGHT or CUI_PLACE_LEFT. |
cui_model
| Field | Type | Description |
|---|---|---|
name | const char * | shown on the button and as the row's heading in the list |
detail | const char * | smaller muted line under the name in the list, e.g. what the model is good at |
badge | const char * | small accent badge after the name, e.g. "New"; NULL for none |
icon | const char * | An icon: a CUI_ICON_* constant, or a string from another icon font. |
Related
- Text area: A multi-line text field that wraps and scrolls.
- Suggestions, response actions and the context meter: Prompt suggestions to start from, the actions under a response, and a ring that shows how full the context is.
- Sources and citations: Citations inside an answer and the list of sources they point to.
- Voice orb: An animated orb for voice modes that shows listening, thinking and speaking.