Components/Agents

Agents

A selectable list of agents, grouped by availability.

VerifiedSince 0.3.4

Usage

Basic

The caller owns selectedId and writes it back from select.

Loading demo...

Best Practices

  • Keep the component at the picker layer; start conversations, fetch capabilities, and run agents in the surrounding module.
  • On a localized page, pass enabledTitle, disabledTitle, and emptyText together.
  • Use stable ids from the backend or registry, never display names that may be localized or renamed.
  • Keep badgeText to a count, a status initial, or a short label.
  • Use loading only for the initial fetch; put per-agent run status in that item's description or badge instead of blocking the list.

API Reference

TxAgentsList

Props

PropTypeDefaultDescription
agentsAgentItemProps[]requiredAgent records; enabled items render before disabled ones.
selectedIdstring | nullnullMarks the item with this id as selected.
loadingbooleanfalseShows four skeleton rows instead of the groups.
enabledTitlestring'Enabled'Title of the enabled group.
disabledTitlestring'Disabled'Title of the disabled=true group.
emptyTextstring'No agents'Shown when agents is empty and the list is not loading.

Events

EventPayloadDescription
selectstringRe-emits the id selected in an enabled TxAgentItem.

TxAgentItem

Props

PropTypeDefaultDescription
idstringrequiredStable id emitted through select.
namestringrequiredPrimary label.
descriptionstring''Secondary text.
iconClassstring'i-carbon-bot'Icon class shown in the avatar area.
selectedbooleanfalseApplies active styling and aria-selected=true.
disabledbooleanfalseBlocks click, Enter, and Space selection and applies aria-disabled=true.
badgeTextstring | number''Right-side badge; an empty string, null, or undefined renders none.

Events

EventPayloadDescription
selectstringFires when an enabled item is activated by click, Enter, or Space.

Slots

SlotPropsDescription
badge-Replaces the badge content when badgeText is set.

Overview

  • TxAgentsList splits agents into enabled and disabled groups by disabled, keeps the original order within each, and shows each group's count in its header.
  • loading wins over both the groups and the empty state.
  • Each group body is a role="listbox" labelled by its title; each item is a role="option".
  • Disabled items keep the option role; aria-disabled and a click guard block their selection.

Technologies

  • TxAgentItem is built on TxCardItem with a fixed rounded avatar shape.
  • Source: packages/tuffex/packages/components/src/agents/.
查看源码
packages/tuffex/packages/components/src/agents/index.ts