Composer Controls

Research and effort controls that sit in a chat composer beside the model.

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/composer-controls

Usage

import { Effort, EffortPicker, ResearchToggle } from "./ui/uicontext/components/chat/ComposerControls.ts"
const Message = UiSchema.TaggedEnum({ ToggledResearch: {}, PickedEffort: { effort: Effort } })// both go in the composer's `tools` slot; the chat keeps the valuesexport const ChatControls = (h: Html.H<typeof Message.Type>, research: boolean, effort: Effort) => [	ResearchToggle(h, { on: research, onToggle: Message.ToggledResearch() }),	EffortPicker(h, { props: { value: effort }, onEmit: { Picked: ({ effort: picked }) => Message.PickedEffort({ effort: picked }) } }),]

API reference

EffortPickerComponent

Props

EffortPicker props
NameTypeDescription
valuerequiredEffort—
disabledboolean—
agentIdstringThis picker's id for agents, unique on the page
side"top" | "bottom"Open upward, as from a composer at the bottom of the screen

Events

EffortPicker events
EventPayloadDescription
Picked{ effort: Effort }—

Agent actions

What agents can do with EffortPicker
ActionDescription
PickedEffortSet how hard the model thinks before it answers: low, medium or high

ResearchToggleView function

Options

ResearchToggle options
NameTypeDefaultDescription
onrequiredboolean——
onTogglerequiredMessage——
disabledboolean——
labelstring"Research""Research" by default

Accessibility

  • Research is a toggle button: its pressed state is announced, and its tooltip says what the next answer will do.
  • Effort is a menu of radio items, each with what it's for; agents set it by level and read the current one.

Source