Terminal and Files

The panes of a coding agent's workspace: files, a terminal and an editor.

  1. ~/billingbun install

    bun install v1.4.2
    
    ✓ 367 packages installed [412ms]
  2. ~/billingbun run lint

    src/invoice/tax.ts
      14:7  warning  'rate' is assigned but never used  no-unused-vars
    ✖ 1 problem (0 errors, 1 warning)
  3. ~/billingbun test src/invoice

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/shell

Usage

import { Terminal, type TerminalEntry } from "./ui/uicontext/components/kit/Shell.ts"
export const AgentTerminal = <M>(h: Html.H<M>, entries: ReadonlyArray<TerminalEntry>, running: boolean) =>	Terminal(h, { label: "Terminal", entries, streaming: running })

Examples

Before anything runs

While the session starts the terminal shows a placeholder; with nothing run yet it says so and what comes next.

Starting

Nothing run yet

Nothing has run yet

Commands the agent runs show here with their output.

API reference

FileTreeComponent

Props

FileTree props
NameTypeDefaultDescription
idrequiredstring—Identifies the tree for agents
labelrequiredstring—The tree's accessible name: "Files"
nodesrequiredFileNode[]—The files and folders at the top level, each folder with its children
status"loading" | "ready""ready""loading" shows a placeholder; "ready" by default
selectedstring | null—The open file
defaultOpenstring[]—Folders open at first; default the top level
agentIdstring—The id agents see this tree by; files:<id> when left out

Events

FileTree events
EventPayloadDescription
RequestedOpenFile{ path: string }The person picked a file to open

Agent actions

What agents can do with FileTree
ActionDescription
ToggledFolderOpen or close a folder by its path
ClickedFileOpen a file by its path

FileEditorComponent

Props

FileEditor props
NameTypeDescription
idrequiredstringIdentifies the editor in the events it sends
pathrequiredstringThe file's path, shown as the editor's heading
valuerequiredstringThe file's saved text; the person's edits stay a draft until Save
languagestring"TypeScript", shown in the status bar
readOnlystringWhy it can't be edited: "The agent is working in this file"
saveLabelstring"Save", "Save draft"; leave can without "save" to hide it
canrequired"save"[]"save" when this person may save; read-only without it
outcomeOutcome | nullThe app's answer to the request in flight; its request is the action's id
agentIdstringThe id agents see this editor by; file:<id> when left out

Events

FileEditor events
EventPayloadDescription
RequestedSave{ id: string; path: string; value: string }The person saved their draft

Agent actions

What agents can do with FileEditor
ActionDescription
UpdatedTextReplace the file's whole text (saved with SubmittedSave)
SubmittedSaveSave the edited file
ClickedDiscardThrow away unsaved edits

TerminalView function

Options

Terminal options
NameTypeDefaultDescription
labelrequiredstring—The log's accessible name: "Terminal"
entriesrequiredTerminalEntry[]—The commands and their output, oldest first
status"loading" | "ready""ready""loading" shows a placeholder; "ready" by default
empty{ readonly title: string; readonly hint?: string }—What shows before anything has run; "Nothing has run yet" when left out
streamingboolean—Lines are still arriving
maxLinesnumber400Lines of one command's output shown before the rest fold away; 400 by default
copybooleantrueA Copy button on each command, for its prompt and output; true by default

PaneSwitcherView function

Options

PaneSwitcher options
NameTypeDescription
labelrequiredstringThe group's accessible name: "Workspace panes"
panesrequiredReadonlyArray<{ readonly id: string; readonly label: string; readonly badge?: string }>The panes to pick from, each with an optional badge: "3"
selectedrequiredstringThe id of the pane showing
onSelectrequired(id: string) => MessageThe message for picking a pane

Accessibility

  • The file tree is a nav: folders open and close as disclosures, and the open file is marked aria-current.
  • The terminal is a focusable log, so new lines are announced and the keyboard can scroll it.
  • The editor is a labelled text area; Mod+S saves. The pane switcher is a row of toggle buttons (aria-pressed).

Source