Mixins / foldkit-mixins-ui

ThinkingSteps

namespace · packages/mixins-ui/src/thinkingSteps.ts:1

export * as ThinkingSteps from './thinkingSteps.js'

In the guides

  • ChatMixins / foldkit-mixins-ui

Members

ThinkingSteps.Args

const · packages/mixins-ui/src/thinkingSteps/state.ts:25

const Args: Schema.Struct<{
  readonly openSteps: Schema.optionalKey<Schema.$Array<Schema.String>>
  readonly multiple: Schema.optionalKey<Schema.Boolean>
}>

What decides how a step's press changes the open details, the same for the life of a placement.

ThinkingSteps.configure

function · packages/mixins-ui/src/thinkingSteps.ts:331

function configure<const Names extends string = never>(
  config: Presets<ThinkingStepsPreset, Names>,
): {
  readonly view: <Outer>(
    options: ThinkingStepsView<Outer> & PresetOption<Names>,
    h: HtmlBuilder<Outer>,
  ) => Html
}

The application's own trace: base for every use, presets chosen at a use with preset (a flat list, a card), and the call over both. Which steps are open stays the Bundle's.

ThinkingSteps.controls

function · packages/mixins-ui/src/thinkingSteps/state.ts:55

function controls<Outer>(
  model: Model,
  onMessage: (message: Message) => Outer,
): {
  open: Option.Option<boolean>
  onToggle: (open: boolean) => Outer
  openSteps: readonly string[]
  onToggleStep: (id: string) => Outer
}

The view's four options for a placed Model: ThinkingSteps.view({ id, steps, ...ThinkingSteps.controls(model, onMessage) }, h).

ThinkingSteps.elapsed

function · packages/mixins-ui/src/thinkingSteps.ts:173

function elapsed(milliseconds: number): string

A duration as a reader says it: 0.4s, 1.2s, 12s, 1m 5s.

ThinkingSteps.init

function · packages/mixins-ui/src/thinkingSteps/state.ts:33

function init(args?: Args): Model

ThinkingSteps.Message

const · packages/mixins-ui/src/thinkingSteps/state.ts:16

const Message: MessageUnion<{
  readonly Toggled: { readonly open: Schema.Boolean }
  readonly ToggledStep: { readonly id: Schema.String }
}>

ThinkingSteps.Model

const · packages/mixins-ui/src/thinkingSteps/state.ts:10

const Model: Schema.Struct<{
  readonly open: Schema.OptionFromNullOr<Schema.Boolean>
  readonly openSteps: Schema.$Array<Schema.String>
}>

Whether the trace is open as the reader asked (none: it follows the work), and the steps whose detail is open.

ThinkingSteps.shown

function · packages/mixins-ui/src/thinkingSteps.ts:169

function shown(
  open: Option.Option<boolean>,
  steps: ReadonlyArray<ThinkingStep>,
): boolean

Whether the trace is open: as the reader asked, or else while it runs.

ThinkingSteps.stateOf

function · packages/mixins-ui/src/thinkingSteps.ts:160

function stateOf(
  steps: ReadonlyArray<ThinkingStep>,
): 'running' | 'done' | 'failed'

The trace's state, from its top steps: running while any runs or any waits with none failed, failed once one failed and none runs, done once every step is done or skipped. A trace with no steps yet is running.

ThinkingSteps.StepState

type · packages/mixins-ui/src/thinkingSteps.ts:64

type StepState = 'pending' | 'running' | 'done' | 'failed' | 'skipped'

Where a step stands; skipped is work a trace chose not to do, which counts as finished.

ThinkingSteps.ThinkingStep

interface · packages/mixins-ui/src/thinkingSteps.ts:66

interface ThinkingStep {
  readonly id: string
  readonly title: string
  readonly state: StepState
  readonly duration?: number | undefined
  readonly icon?: Html | undefined
  readonly href?: string | undefined
  readonly trailing?: Html | undefined
  readonly detail?: Html | string | undefined
  readonly steps?: ReadonlyArray<ThinkingStep> | undefined
}

ThinkingSteps.ThinkingStepsPreset

type · packages/mixins-ui/src/thinkingSteps.ts:322

type ThinkingStepsPreset = Pick<
  ThinkingStepsView<never>,
  'style' | 'words' | 'trigger'
> & {
  readonly mixins?: MixinList<never>
}

What a trace is given once: its look, words and how its steps open.

ThinkingSteps.ThinkingStepsSlots

const · packages/mixins-ui/src/thinkingSteps.ts:28

const ThinkingStepsSlots: Slots.Contract<{ readonly root: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>; readonly trigger: Slot.UnnamedSlot<Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>, readonly [Event.EventToken<"click">], readonly [Attr.AttrToken<"aria-expanded">], readonly Slot.RequirementName[], boolean>; readonly summary: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>; readonly chevron: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>; readonly panel: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>; readonly list: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capabil …;

An assistant's reasoning and tool calls as a trace, ai-elements' Reasoning and Chain of Thought: a button that shows and hides the list of steps, saying Thinking (the running step's title) while it works and Thought for 4s once done, and the steps, each with a marker for its state, its title, how long it took, and detail and steps of its own.

Whether the trace is open is the application's, as an Option: none follows the work, open while it runs and shut once it is done, and the button sends the state the reader asked for, which the application keeps from then on (Bundles.ThinkingSteps keeps it, and controls feeds the view). Given onToggleStep, a step with detail is a button that shows and hides it, the open ones the application's; without it, every detail shows. A shut part stays drawn and inert, so its close can animate and aria-controls names a node. A step's state is said in words beside its title; the marker is hidden from assistive technology. With trigger: 'none' the steps are a plain list with no button and nothing to shut.

ThinkingSteps.ThinkingStepsView

interface · packages/mixins-ui/src/thinkingSteps.ts:122

interface ThinkingStepsView<Message> {
  readonly id: string
  readonly steps: ReadonlyArray<ThinkingStep>
  readonly open: Option.Option<boolean>
  readonly onToggle: (open: boolean) => NoInfer<Message>
  readonly trigger?: 'button' | 'none' | undefined
  readonly duration?: number | undefined
  readonly summary?: string | undefined
  readonly openSteps?: ReadonlyArray<string> | undefined
  readonly onToggleStep?: ((id: string) => NoInfer<Message>) | undefined
  readonly words?: Partial<ThinkingStepsWords> | undefined
  readonly style?: NamedStyle<typeof ThinkingStepsSlots> | undefined
  readonly mixins?: MixinList<Message> | undefined
}

ThinkingSteps.ThinkingStepsWords

interface · packages/mixins-ui/src/thinkingSteps.ts:89

interface ThinkingStepsWords {
  readonly pending: string
  readonly running: string
  readonly done: string
  readonly failed: string
  readonly skipped: string
  readonly thinking: string
  readonly thought: string
  readonly thoughtFor: string
  readonly stopped: string
  readonly stoppedAfter: string
  readonly steps: string
}

The text a trace draws that is not one step's content.

ThinkingSteps.update

function · packages/mixins-ui/src/thinkingSteps/state.ts:39

function update(
  model: Model,
  message: Message,
  args?: Args,
): Return<Model, Message>

The Model after message; the one it was given when the press changes nothing.

ThinkingSteps.view

function · packages/mixins-ui/src/thinkingSteps.ts:209

function view<Message>(
  options: ThinkingStepsView<Message>,
  h: HtmlBuilder<Message>,
): Html

ThinkingSteps.words

const · packages/mixins-ui/src/thinkingSteps.ts:108

const words = {
  pending,
  running,
  done,
  failed,
  skipped,
  thinking,
  thought,
  thoughtFor,
  stopped,
  stoppedAfter,
  steps,
}