Screens

Coding Agent

An agent working in a repo — chat with plan and permission requests on one side, file changes, terminal and a live preview on the other.

3 variantsMIT

Preview

Full screen

Installation

Copies the screen into components/ and installs every component it uses, with their dependencies and theme tokens.

pnpm dlx shadcn@latest add https://uilab.tmih06.com/r/coding-agent.json

Usage

Pass your own data and wire the callbacks to your agent runtime.

import { CodingAgent } from "@/components/coding-agent";
import { ToolCallBlock } from "@/components/ui/tool-call-block";
import { ToolApprovalQueue } from "@/components/ui/tool-approval-queue";

export function AgentScreen({ run }: { run: AgentRun }) {
  return (
    <div className="h-dvh">
      <CodingAgent
        data={{
          title: run.task.title,
          repo: run.repo,
          branch: run.branch,
          model: run.model,
          user: { name: run.user.name },
          // Each turn's content is any React node — tool calls, approvals.
          messages: run.turns.map((turn) => ({
            id: turn.id,
            role: turn.role,
            at: turn.createdAt,
            content:
              turn.role === "user" ? (
                turn.text
              ) : (
                <>
                  {turn.calls.map((call) => (
                    <ToolCallBlock key={call.id} data={call} />
                  ))}
                  {turn.approvals.length > 0 && (
                    <ToolApprovalQueue
                      data={turn.approvals}
                      layout="flat"
                      onDecide={(requests, decision, scope) =>
                        run.decide(requests, decision, scope)
                      }
                    />
                  )}
                </>
              ),
          })),
          activity: run.working ? run.status : undefined,
          files: run.changes,
          terminal: run.lastCommand,
          checkpoints: run.checkpoints,
          preview: { url: run.previewUrl, content: <iframe src={run.previewUrl} /> },
        }}
        status={run.working ? "streaming" : "idle"}
        onSend={(message) => run.send(message.text, message.mode)}
        onStop={() => run.stop()}
        onApply={(selection) => run.apply(selection)}
        onDiscard={() => run.discard()}
        onRestore={(checkpoint) => run.restore(checkpoint.id)}
      />
    </div>
  );
}

// While the run loads, pass null explicitly — the skeleton keeps the viewport,
// header, both panes and the composer dock in place. Keep stale data and set
// loading when refetching.
export function AgentScreenState({ query }: { query: RunQuery }) {
  return (
    <div className="h-dvh">
      <CodingAgent
        data={query.data ? toAgentData(query.data) : null}
        loading={query.isRefetching}
        skeleton={{ messages: 3, files: 3 }}
      />
    </div>
  );
}

Props

PropTypeDefaultDescription
data*CodingAgentData | null—The task, repo and branch, the thread, the live activity line, changed files, the last terminal run, checkpoints and the preview. Pass null while they load.
loadingbooleanfalseForce the layout-preserving skeleton while refetching, even when stale data is available.
skeleton{ messages?: number; files?: number }—Shape hints for the loading state: chat turn and file tab placeholder counts before the real cardinality is known.
status"idle" | "streaming""idle"While streaming, the composer queues follow-ups and shows Stop instead of Send.
tab"changes" | "terminal" | "preview"—Controls the work panel tab. Uncontrolled it starts on Changes.
onTabChange(tab: WorkTab) => void—Called when the user picks a tab.
onSend(message: ComposerMessage) => void—Called with the text, mode (ask, plan or act), context and model.
onStop() => void—Stop from the composer or the activity line.
onApply(selection: HunkSelection) => void—Apply the kept hunks from the Changes tab.
onDiscard() => void—Discard every change.
applyingbooleanfalsePuts the Apply button in its loading state.
onRestore(checkpoint: Checkpoint) => void—Called after the user confirms restoring to a checkpoint.
localestring—Intl locale for message times in the thread.
labelsPartial<CodingAgentLabels>—Your own UI strings (pane names, toggles, placeholders, the empty Changes tab, the `loading` announcement), plus `thread`, `activity`, `composer`, `checkpoints`, `files` and `terminal` for the components inside, for translating. Right-to-left works under `dir="rtl"`: chat moves to the right, code and the terminal stay left to right.
classNamestring—Extra classes for the root.
type CodingAgentData = {
  title: string;
  repo: string;
  branch: string;
  model: string;
  user: { name: string; avatar?: string };
  messages: ThreadMessage[];            // from chat-thread; content is a ReactNode
  activity?: AgentStatusData;           // live status at the end of the thread
  files: FileChange[];                  // from file-changes
  terminal: TerminalRun;                // from terminal-output
  checkpoints: Checkpoint[];            // from checkpoint-timeline
  preview: { url: string; content: ReactNode };
};

// Lays out by its own width: from 960px chat and the work panel sit side by side
// and either can be collapsed; below that a switch shows Chat, Changes, Terminal
// or Preview. Give the parent a height.