aiellie

Search

Find a component, template or page

GitHub
Components

Attempt Picker

Several attempts at one task side by side, with progress while they run, then lines changed, tests passing and a suggested pick, and one to apply while the rest are discarded.

Fix rounding in the cart total

0 of 3 done
Still running
Open full screen
fig. 01 · open it full screen from the corner

Installation

npx shadcn@latest add "@aiellie/attempt-picker"

shadcn needs the @aiellie registry in components.json first. npx aiellie add attempt-picker adds it on its first run, then installs the same way.

Attempt Picker lays out several attempts at the same task, from different models or approaches, so you can pick one. While they run, each shows its progress. Once they're done, each shows the lines it added and removed and how many tests pass, and the one you select opens to its summary, files, cost and time.

It suggests one: the most tests passing, then the smallest change. It waits until every attempt has reported, so an early finisher isn't suggested over the rest. Applying one discards the others.

Getting started

  1. Pass the attempts

    Update attempts as they report. onApply adds the button; set applied once it's done.

    components/attempts.tsx
    import { AttemptPicker } from "@/components/aiellie/attempt-picker"
    
    export function Attempts({ run }: { run: Run }) {
      const [applied, setApplied] = useState<string>()
    
      return (
        <AttemptPicker
          task={run.task}
          attempts={run.attempts}
          applied={applied}
          onApply={async (id) => {
            await run.apply(id)
            setApplied(id)
          }}
        />
      )
    }

Anatomy

<div data-slot="attempt-picker" data-state="ready" role="group">
  <div data-slot="attempt-picker-header" />
  <div role="radiogroup">
    <div data-slot="attempt-picker-attempt" data-state="done" data-selected role="radio" />
  </div>
  <button data-slot="attempt-picker-apply" />
</div>

The attempts are a radio group: the arrow keys move the selection. Failing tests and failed attempts take the destructive colour, and the suggested one carries a quiet tag.

suggestAttempt is exported too, if you'd rather show the suggestion somewhere else.

Examples

No suggestion

Pass suggested={null} when there's nothing to measure, like two drafts of the same text.

Write the release announcement

2 attempts
Drops the other 1

API reference

AttemptPicker

PropTypeDefaultDescription
taskstringrequiredWhat every attempt was given.
attemptsAttempt[]required
selected, defaultSelected, onSelectedChangestringthe first
suggestedstring | nullsuggestAttempt(attempts)null for none.
appliedstringThe others show as discarded.
onApply(id: string) => voidAdds Apply.

All other div props are forwarded.

Attempt

FieldTypeDefaultDescription
id, labelstringrequired
state"running" | "done" | "failed"required
progressnumberFrom 0 to 1 while running.
summarystringWhat it did, in a sentence.
additions, deletions, filesnumber
tests{ passed: number; total: number }
coststringAlready formatted: "$0.42".
secondsnumber