Syed Hasnain

Background Runs

Component

About

Ongoing and completed agent jobs collected in one actionable inbox.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Background Runs to your project and fits it to your theme.

Code

How Background Runs is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

import * as React from 'react'
import BackgroundRuns, { type BackgroundRun } from '@/components/ui/background-runs'

const jobs = [
  { id: 'audit', label: 'Audit authentication flows', detail: 'Reviewing 18 routes and 42 server functions', done: '18 routes reviewed, 2 issues found' },
  { id: 'tests', label: 'Run visual regression tests', detail: 'Comparing 116 documentation routes', done: '116 routes match the baseline' },
  { id: 'docs', label: 'Draft release notes', detail: 'Summarizing 24 merged pull requests', done: 'Draft ready for review' },
]

export default function Demo() {
  const [active, setActive] = React.useState(0)
  const [progress, setProgress] = React.useState(58)
  const [seconds, setSeconds] = React.useState(18)
  const finished = active >= jobs.length

  React.useEffect(() => {
    const timer = setTimeout(
      () => {
        if (finished) {
          setActive(0)
          setProgress(6)
          setSeconds(1)
        } else if (progress >= 100) {
          setActive((value) => value + 1)
          setProgress(6)
          setSeconds(1)
        } else {
          setProgress((value) => Math.min(100, value + 10))
          setSeconds((value) => value + 1)
        }
      },
      finished ? 2400 : progress >= 100 ? 250 : 220,
    )
    return () => clearTimeout(timer)
  }, [finished, progress])

  const items: BackgroundRun[] = jobs.map((job, index) => {
    if (index < active || (index === active && progress >= 100))
      return { id: job.id, label: job.label, detail: job.done, status: 'complete', updatedAt: 'Just now' }
    if (index === active)
      return { id: job.id, label: job.label, detail: job.detail, progress, status: 'running', updatedAt: `${seconds}s` }
    if (index === active + 1 && progress >= 100)
      return { id: job.id, label: job.label, detail: job.detail, progress: 2, status: 'running', updatedAt: '0s' }
    return { id: job.id, label: job.label, detail: 'Starts after the current run', status: 'queued', updatedAt: 'Queued' }
  })

  return <BackgroundRuns className="w-full max-w-lg" items={items} />
}

Dependencies

More by Syed Hasnain

View all
  • Color Picker

    Color Picker

    81
  • Cost Meter

    Cost Meter

    30
  • Message Scroller

    Message Scroller

    24
  • Quota Banner

    Quota Banner

    21
  • Commit

    Commit

    17
  • Attachments

    Attachments

    16
  • Image Generation Loader

    Image Generation Loader

    15
  • Background Inbox

    Background Inbox

    15

Explore more

Part of Pasta UI — browse the full library on 21st.dev.