---
title: "Plan"
description: "Track a predefined plan and its completion count."
---

# Plan

Track a predefined plan and its completion count.

## Usage

Expand the plan and replay its steps to watch completion states change.

## Example

```contract
use uiFontFamily, BubbleFrame from "@rightui/ui"
use ButtonAI as ButtonContent from "@rightui/ui"
use TraceFrame, TraceLine, TraceCollapsible, TraceDisclosure, TraceSource, CodeBlockContent from "@rightui/ui"

component Demo
  props
    width: number
    reduced: bool
  inject
    uiFont: string
    rightuiDemoTime: number
    rightuiRunDemo: action
  state started = -1
  derive elapsed = started < 0 ? 14800 : max(0, rightuiDemoTime - started)
  derive busy = elapsed < 4800
  action replay
    started = rightuiDemoTime
    rightuiRunDemo(8800)
  view
    column gap="ui.space-16" min-width=0 min-height=288 max-width="24rem" width="100%" padding="ui.space-24 ui.space-0"
      BubbleFrame(id="ai-plan-question", align="end", variant="muted")
        text "Migrate the dialog components to Base UI." font-family=uiFontFamily(uiFont) data-rightui-font="body"
      TraceFrame()
        TraceCollapsible(id="ai-plan-0", title="Plan: migrate to Base UI", icon="route", status="", initiallyOpen=true, reduced=reduced)
          text (min(4, floor(elapsed / 1200)).toString() + " of 4 done") font-size="ui.text-sm" color="ui.muted-foreground" font-family=uiFontFamily(uiFont) data-rightui-font="body"
          TraceLine(title="Install @base-ui/react", icon=(elapsed >= 0 and elapsed < 1200 ? "dot" : "check"), status=(elapsed < 0 ? "pending" : elapsed < 1200 ? "running" : ""), reduced=reduced)
          TraceLine(title="Replace the Radix imports", icon=(elapsed >= 1200 and elapsed < 2400 ? "dot" : "check"), status=(elapsed < 1200 ? "pending" : elapsed < 2400 ? "running" : ""), reduced=reduced)
          TraceLine(title="Rename asChild to render", icon=(elapsed >= 2400 and elapsed < 3600 ? "dot" : "check"), status=(elapsed < 2400 ? "pending" : elapsed < 3600 ? "running" : ""), reduced=reduced)
          TraceLine(title="Run the type checker", icon=(elapsed >= 3600 and elapsed < 4800 ? "dot" : "check"), status=(elapsed < 3600 ? "pending" : elapsed < 4800 ? "running" : ""), reduced=reduced)
      if elapsed >= 4800
        text "Migrated Dialog and AlertDialog. The type checker passes.".slice(0, started < 0 or reduced ? 57 : floor((elapsed - 4800) / 20)) font-size="ui.text-sm" line-height="ui.leading-relaxed" font-family=uiFontFamily(uiFont) data-rightui-font="body"
      if not busy
        row margin-top="auto" align-items="flex-start"
          ButtonContent(id="ai-plan-replay", label="Replay", variant="outline", size="sm", disabled=false, press=replay)
            text "Replay" font-family=uiFontFamily(uiFont) data-rightui-font="body"

```

## Keyboard

Tab to actions and disclosures; Enter or Space activates them.

## Demo runtime

Timed examples use an injected clock. Add these members to your root component. Replace the scripted state with events from your TypeScript or Rust data source when connecting a model.

```contract
use defaultFontWeights from "@rightui/ui"
  state demoTime = 0
  state demoUntil = 0
  provide
    uiFont = "theme"
    uiWeights = defaultFontWeights()
    rightuiDemoTime = demoTime
    rightuiRunDemo = runDemo
  action runDemo(duration: number)
    demoUntil = max(demoUntil, demoTime + duration)
  action tickDemo
    demoTime = min(demoUntil, demoTime + 32)
  task demoClock when demoTime < demoUntil
    every(32, tickDemo)
```

## Source

File: patterns/ai-elements/plan.contract

```contract
use uiFontFamily, BubbleFrame from "@rightui/ui"
use ButtonAI as ButtonContent from "@rightui/ui"
use TraceFrame, TraceLine, TraceCollapsible, TraceDisclosure, TraceSource, CodeBlockContent from "@rightui/ui"

component Demo
  props
    width: number
    reduced: bool
  inject
    uiFont: string
    rightuiDemoTime: number
    rightuiRunDemo: action
  state started = -1
  derive elapsed = started < 0 ? 14800 : max(0, rightuiDemoTime - started)
  derive busy = elapsed < 4800
  action replay
    started = rightuiDemoTime
    rightuiRunDemo(8800)
  view
    column gap="ui.space-16" min-width=0 min-height=288 max-width="24rem" width="100%" padding="ui.space-24 ui.space-0"
      BubbleFrame(id="ai-plan-question", align="end", variant="muted")
        text "Migrate the dialog components to Base UI." font-family=uiFontFamily(uiFont) data-rightui-font="body"
      TraceFrame()
        TraceCollapsible(id="ai-plan-0", title="Plan: migrate to Base UI", icon="route", status="", initiallyOpen=true, reduced=reduced)
          text (min(4, floor(elapsed / 1200)).toString() + " of 4 done") font-size="ui.text-sm" color="ui.muted-foreground" font-family=uiFontFamily(uiFont) data-rightui-font="body"
          TraceLine(title="Install @base-ui/react", icon=(elapsed >= 0 and elapsed < 1200 ? "dot" : "check"), status=(elapsed < 0 ? "pending" : elapsed < 1200 ? "running" : ""), reduced=reduced)
          TraceLine(title="Replace the Radix imports", icon=(elapsed >= 1200 and elapsed < 2400 ? "dot" : "check"), status=(elapsed < 1200 ? "pending" : elapsed < 2400 ? "running" : ""), reduced=reduced)
          TraceLine(title="Rename asChild to render", icon=(elapsed >= 2400 and elapsed < 3600 ? "dot" : "check"), status=(elapsed < 2400 ? "pending" : elapsed < 3600 ? "running" : ""), reduced=reduced)
          TraceLine(title="Run the type checker", icon=(elapsed >= 3600 and elapsed < 4800 ? "dot" : "check"), status=(elapsed < 3600 ? "pending" : elapsed < 4800 ? "running" : ""), reduced=reduced)
      if elapsed >= 4800
        text "Migrated Dialog and AlertDialog. The type checker passes.".slice(0, started < 0 or reduced ? 57 : floor((elapsed - 4800) / 20)) font-size="ui.text-sm" line-height="ui.leading-relaxed" font-family=uiFontFamily(uiFont) data-rightui-font="body"
      if not busy
        row margin-top="auto" align-items="flex-start"
          ButtonContent(id="ai-plan-replay", label="Replay", variant="outline", size="sm", disabled=false, press=replay)
            text "Replay" font-family=uiFontFamily(uiFont) data-rightui-font="body"

```
