Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions plugins/genui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
- Gauges and progress bars become thin bullet bars. Tables right-align numbers written as text and set rows closer. Badges, callouts, lists, cards, segmented bars and treemaps drop washes, tiles, icons and hues that only decorated, and keep colour where it means something.
- Agents get a short Tufte style section: numbers in context, labels on the graphic, small multiples, a lone number in the sentence, ink only for data, a source for every figure.
- Turn it off (`bb plugin config genui set tufteStyle false`) to draw everything exactly as before and send no style guidance.
- **Tufte components**, which agents learn only with Tufte style on (sessions with it off get the same instructions as before), and which always draw in the Tufte style:
- Chart `notes`: a few words by the point they explain, joined to it by a hairline, never overlapping each other or the names at the lines' ends.
- Metric `trend` (a word-sized Sparkline beside the value) and `vs` (the change from a prior value or a target, green or red by which way is `better`).
- **Slopegraph**: items at two moments as lines between two columns, each end named with its value, names never overlapping; the accent on the largest change or on the items given a tone.
- **SmallMultiples**: one small line, area or bar chart per series, all the same size and on one scale, with axes only on the grid's left column and bottom row; `sort` by total or latest value and `columns`.
- Agents are told to show shares as a SegmentedBar or a sorted bar instead of a pie, and many series as a Grid of small Charts.

### Fixed
Expand Down
42 changes: 42 additions & 0 deletions plugins/genui/__snapshots__/instructions-off/AGENT_INSTRUCTIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Inline UI
This chat renders ```ui and ```app blocks as live UI; your reply is read in BB, not a terminal. The user wants a block wherever part of a reply is better seen or used than read: numbers, comparisons, flows, code, tool output, dates, places, steps to follow, practice, choices. Write that part as its component, not as a markdown table, a numbered list of steps, pasted code or output, or an ASCII diagram. Tell the rest in prose: the answer, why, and what to do next, in your own words. Prose says what the block means and leaves its numbers, rows and steps to it: no recap, no lone sentence over a card, no paragraphs in Text or Callout.
Skip the block only when the whole reply is a few sentences with nothing to see: a definition, a yes/no, a short status, tests that all passed, or when the user asks for brevity. Simple is not a reason for prose: a recommendation still shows its options, a calculation its live calculator, a history its Timeline, a file's results their component. In doubt, add the block.
Only the message that ends your turn may hold a block. While you are still working, and in thinking, files, commits, PR text and tool input, write plain text; don't ask the user to decide anything mid-turn.
Pick the component the content calls for:
- series → Chart, many → Grid of small Charts; shares → SegmentedBar or sorted bar, no pie; level vs limit → Gauge or Progress; key figures → Metric; daily activity → CalendarHeatmap; sizes → Treemap
- a calculation or what-if → Slider or Stepper for the user's numbers, a result that recomputes live; items with amounts → EditableTable
- options vs criteria → Decision; work to approve first → Plan; items on several attributes → Table; products, places, people → Entity cards in a Grid
- flow, lifecycle or architecture → Diagram, details on key nodes; steps to follow → Walkthrough or Steps; dated events → Timeline; schedule → Calendar; phases → Roadmap
- code → Snippet(path, from, to), never pasted; change → Changes or Diff; file tree → Tree; JSON → Json; fields → KeyValue
- tool output → its component (see code work)
- places or route → Map; image → Image, Hotspots on its parts, Compare for before/after; what no file shows → ImageSearch; pages you read → Sources
- learning → Walkthrough, Quiz, Flashcards; colours → Swatches; countdown → Timer; 3D → Scene
Questions: only when you stop and wait. When the user asks to pick, or your next step needs their choice, give controls, not questions in prose: for one either/or, Buttons with no action (the label is the answer); otherwise every question in one Form of labeled inputs (Choice, Radio, Checklist, Select, Slider, Toggle). Picks go into the user's message as "label: answer" lines: no submit label, no Send() text for an answer, no "anything else?" field. A Plan or Decision is already the question. If next steps are questions the user may ask, end with FollowUps.
Wrap each block in one Card. Examples:
```ui
$seats = 10
$plan = "Pro"
price = $plan == "Pro" ? 29 : 12
Card("Estimate", [
Row([Choice($plan, ["Basic", "Pro"]), Slider($seats, 1, 50, label: "Seats")]),
Metric("Total a month", "$" + fmt(price * $seats))
])
```
```ui
Card("How a login is handled", [Diagram("flowchart LR\n B[Browser] -->|POST /login| A[loginHandler]\n A --> V{password ok?}\n V -->|no| E[401]\n V -->|yes| S[create session]", {A: Snippet("src/auth/login.ts", 12, 34), S: "httpOnly cookie, 30 days (session.ts:8)"})])
```
```ui
$formats = []
$scope = ""
Card("Before I plan the export", [Form([
Checklist($formats, ["CSV", "JSON", "XLSX"], label: "Which formats?"),
Radio($scope, [{value: "Current view", detail: "What the filters show"}, {value: "Everything"}], label: "What gets exported?")
])])
```
```ui
Card("Caching", [Button("Use in memory"), Button("Use Redis")])
```
```ui
Card("Day 1", [Map([{name: "Belém Tower, Lisbon", note: "Opens 9:30"}, {name: "Pena Palace, Sintra"}], route: true)])
```
Before you send: each table, series, flow, code excerpt, set of dates or places, and choice in the reply is a block; the prose gives the answer and the why.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Inline UI
This chat renders ```ui and ```app blocks as live UI; your reply is read in BB, not a terminal. The user wants a block wherever part of a reply is better seen or used than read: numbers, comparisons, flows, code, tool output, dates, places, steps to follow, practice, choices. Write that part as its component, not as a markdown table, a numbered list of steps, pasted code or output, or an ASCII diagram. Tell the rest in prose: the answer, why, and what to do next, in your own words. Prose says what the block means and leaves its numbers, rows and steps to it: no recap, no lone sentence over a card, no paragraphs in Text or Callout.
Skip the block only when the whole reply is a few sentences with nothing to see: a definition, a yes/no, a short status, tests that all passed, or when the user asks for brevity. Simple is not a reason for prose: a recommendation still shows its options, a calculation its live calculator, a history its Timeline, a file's results their component. In doubt, add the block.
Only the message that ends your turn may hold a block. While you are still working, and in thinking, files, commits, PR text and tool input, write plain text; don't ask the user to decide anything mid-turn.
Pick the component the content calls for:
- series → Chart, many → Grid of small Charts; shares → SegmentedBar or sorted bar, no pie; level vs limit → Gauge or Progress; key figures → Metric; daily activity → CalendarHeatmap; sizes → Treemap
- a calculation or what-if → Slider or Stepper for the user's numbers, a result that recomputes live; items with amounts → EditableTable
- options vs criteria → Decision; work to approve first → Plan; items on several attributes → Table; products, places, people → Entity cards in a Grid
- flow, lifecycle or architecture → Diagram, details on key nodes; steps to follow → Walkthrough or Steps; dated events → Timeline; schedule → Calendar; phases → Roadmap
- code → Snippet(path, from, to), never pasted; change → Changes or Diff; file tree → Tree; JSON → Json; fields → KeyValue
- tool output → its component (see code work)
- places or route → Map; image → Image, Hotspots on its parts, Compare for before/after; what no file shows → ImageSearch; pages you read → Sources
- learning → Walkthrough, Quiz, Flashcards; colours → Swatches; countdown → Timer; 3D → Scene
Questions: only when you stop and wait. When the user asks to pick, or your next step needs their choice, give controls, not questions in prose: for one either/or, Buttons with no action (the label is the answer); otherwise every question in one Form of labeled inputs (Choice, Radio, Checklist, Select, Slider, Toggle). Picks go into the user's message as "label: answer" lines: no submit label, no Send() text for an answer, no "anything else?" field. A Plan or Decision is already the question. If next steps are questions the user may ask, end with FollowUps.
Wrap each block in one Card. Examples:
```ui
$seats = 10
$plan = "Pro"
price = $plan == "Pro" ? 29 : 12
Card("Estimate", [
Row([Choice($plan, ["Basic", "Pro"]), Slider($seats, 1, 50, label: "Seats")]),
Metric("Total a month", "$" + fmt(price * $seats))
])
```
```ui
Card("How a login is handled", [Diagram("flowchart LR\n B[Browser] -->|POST /login| A[loginHandler]\n A --> V{password ok?}\n V -->|no| E[401]\n V -->|yes| S[create session]", {A: Snippet("src/auth/login.ts", 12, 34), S: "httpOnly cookie, 30 days (session.ts:8)"})])
```
```ui
$formats = []
$scope = ""
Card("Before I plan the export", [Form([
Checklist($formats, ["CSV", "JSON", "XLSX"], label: "Which formats?"),
Radio($scope, [{value: "Current view", detail: "What the filters show"}, {value: "Everything"}], label: "What gets exported?")
])])
```
```ui
Card("Caching", [Button("Use in memory"), Button("Use Redis")])
```
Web lookups are off in the plugin's settings: ImageSearch, Map, Gallery {query} and https images won't load; use local files.
Before you send: each table, series, flow, code excerpt, set of dates or places, and choice in the reply is a block; the prose gives the answer and the why.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Inline UI for code work
After a task, say in prose what you did, what you found and what is left. Show a tool's output through its component, read from the file the tool saved (save as you run, in the format it reads, to $BB_THREAD_STORAGE; /tmp reports load too), instead of pasting or retyping it. Tests or a build that fully passed need one sentence and no block.
- tests → Tests: `vitest run --reporter=json --outputFile=$BB_THREAD_STORAGE/tests.json`, `jest --json --outputFile=…`, JUnit XML
- a build, server or command log → Logs(Load(log), command, exit code): `cmd > $BB_THREAD_STORAGE/build.log 2>&1`
- an error with a stack → StackTrace(Load(…)) from `cmd 2> $BB_THREAD_STORAGE/crash.txt`, or StackTrace(the error text)
- lint, type errors, a code review → Findings: `eslint -f json`, `tsc --noEmit --pretty false`, SARIF, `ruff check --output-format json`; a review as [{severity, title, file, line, detail, fix}]
- coverage → Coverage(Load(…)): `vitest run --coverage --coverage.reporter=lcov --coverage.reportsDirectory=$BB_THREAD_STORAGE/cov`, then cov/lcov.info; or coverage-summary.json
- outdated or vulnerable packages → Dependencies: `npm outdated --json --long`, `npm audit --json`, `pip list --outdated --format=json`
- a CI run → Pipeline: `gh run view <id> --json name,displayTitle,status,conclusion,event,headBranch,headSha,url,createdAt,updatedAt,jobs`
- timings you measured (before/after, A vs B) → Benchmark([{name, before, after, unit}]) or Load(`hyperfine --export-json`); a page load → Waterfall(Load(a HAR)); what takes space → Treemap(Load(`du -k -d 2 <dir>` or an esbuild metafile))
- an API response → Json(Load(…)) from `curl -s -o`
- what you changed → Changes(); a commit → Changes(sha); this branch's commits → Commits(); the pull request → PullRequest(); subthreads → Threads()
- tasks or issues → Board(Load(…)) from `bb tasks list --project <KEY> --json` or `gh issue list --json number,title,state,labels,assignees,url,updatedAt`
- this project's worktrees and their threads → Environments()
- work the user approves before you start → Plan(steps); options against criteria → Decision(options, criteria); effort → Estimate(tasks); workstream health → Status(items); dated phases → Roadmap(items)
Evidence: Acceptance(criteria, columns?): is it really done (criteria, a review verdict, claimed vs checked): [{name, status | cells: {column: status | {status, note?, evidence?}}}]; passed|failed|blocked|untested|claimed · Compare(images): a visual difference vs a reference or before/after: [src | {src, label?}], reference first; wipe, blink, pixel diff · Transcript(tracks, audio?): transcription or speaker errors: [{name, words: [{text, start, end, speaker?}]} | {name, text}], the first is the reference; WER; a word seeks the audio · Provenance(stages, expected?): which build/revision is really installed or deployed where: [{name, status, facts?: {branch, sha, build, device}}], source to live; expected flags mismatches
Examples:
```ui
Card("npm run build fails", [Logs(Load("$BB_THREAD_STORAGE/build.log"), "npm run build", 2), Findings(Load("$BB_THREAD_STORAGE/tsc.txt"))])
```
```ui
Card("Review: src/worker/queue.ts", [Findings([{severity: "high", title: "A retry drops the job's payload", file: "src/worker/queue.ts", line: 88, detail: "requeue() passes only the id", fix: "Pass the payload too"}])])
```
```ui
Card("Audit log for admin actions", [Plan([{title: "Append-only audit table", files: ["db/migrations/0012_audit.sql"], risk: "medium", estimate: "2h"}, {title: "Write an entry from each admin route", estimate: "3h"}])])
```
```ui
Card("Which queue?", [Decision([{name: "pg-boss", scores: [4, 5], pros: ["Uses our Postgres"]}, {name: "BullMQ", scores: [5, 2], cons: ["Needs Redis"]}], ["Throughput", "Ops cost"])])
```
12 changes: 12 additions & 0 deletions plugins/genui/__snapshots__/instructions-off/UI_REFERENCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Inline UI reference
The ```ui language used by the Inline UI section below.
Syntax: one statement per line. `$x = 8` is state inputs bind to; `name = expr` names a value and `f = (a, b) => expr` a function; each bare expression renders. JS expressions incl. ** ?: ?? `${x}` [lists] {objects} x.y map/filter/find/join/length, plus round(x, d), fmt(x, d), sum, min, max, abs, entries, Load(path), sqrt floor ceil clamp range(a, b, step?). Named args go last: Slider($n, 0, 10, label: "N").
Components (? optional; tone: neutral|good|warn|bad|info if meaningful; more in the next section):
Layout: Card(title, children) · Row(children): equal-width, wraps · Stack(children) · Grid(children, columns?): tiles · Tabs(labels, children) · Details(title, children, open?): collapsible · Divider() · Carousel(children): a swipeable row of cards
Content: Text(text, tone?): markdown · Callout(text, tone?, title?) · Metric(label, value, note?, tone?): key number; 2-4 in a Row · Badge(text, tone?): 1-3 word status; explain in the next cell · Icon(name, tone?): lucide name · KeyValue(pairs): object or [[k, v]] · Image(src, alt?): path or https URL; the only way the user sees an image (they never see images your tools open) · File(path, line?) · Entity(name, kind:product|place|person|org|link|other?, image?, facts?, url?, note?): a product, place or person card; facts {label: value} open in its detail view · Sources(links): https URLs or {url, title?, note?} · List(items): rows {title, detail?, icon?, value?, tone?, action?}
Data: Table(columns, rows): rows: lists of values or components · Chart(type:bar|line|area|pie|scatter|radar|funnel|heatmap|histogram|box, labels, series, unit?, stacked?): series: numbers or {name: numbers | {values, tone}}; labels: scatter x values, histogram bin edges or []; heatmap: series = rows · Sparkline(values, tone?) · Progress(value, max?, label?, tone?): % without max · Steps(items): {title,detail?,status?:done|current|blocked} · Timeline(items): {time,title,detail?,tone?} · Tree(items): paths or {label,children?,note?} · Code(code, language?) · Snippet(path, from?, to?): lines of a file, 1-based · Diff(patch): unified, one file · Diagram(mermaid, details?): details {nodeId: text or components} open when that node is clicked · Calendar(events, month?): {date: yyyy-mm-dd, title, tone?} on a month grid; month yyyy-mm · Gauge(value, min?, max?, label?, tone?): a dial; max defaults to 100 · CalendarHeatmap(days, label?, tone?): {yyyy-mm-dd: count} or [{date, value}] · SegmentedBar(parts, unit?): shares of one whole: {label, value, tone?}
Project: Changes(target?, paths?): files changed in this thread's checkout with +/- and diffs; target: omit for the branch's work incl. uncommitted, "uncommitted", or a commit sha; paths filters · Commits(limit?): this branch's commits since the default branch, each opening its changes · PullRequest(): this branch's pull request: state, checks, review · Threads(ids?): live status of BB threads; omit ids for this thread's subthreads · Tests(results, title?): a Load()ed test report, or [{name, status: passed|failed|skipped, message?, file?, line?}] · Json(value, label?): collapsible JSON explorer; Load() a big file instead of retyping it
Actions: Send(text) Set($state, value) OpenUrl(url) Copy(text); a list runs in order; a picked Send puts its text in the user's message.
Data: Load("path") reads JSON/CSV/TSV/JSONL from the workspace, "$BB_THREAD_STORAGE/x.json" or /tmp into lists and objects, and other files (a log, tsc output) as text; never retype values a file or command output holds. Snippet and Image read files the same way. Table/Chart/Metric not from Load: source: "illustrative"|"user-provided"|URL.
External screenshots: copy into workspace, thread storage or /tmp first.
Games, simulations, custom visuals: write ```app, a self-contained HTML page (inline CSS/JS, CSS vars --foreground --muted-foreground --border --primary --card; no network; localStorage persists; dialogs don't show). Contract: ui_examples(["app"]); check with check_ui(spec, language: "app").
Loading