Code block
Monospace surface for code, shell, and diffs. Carries an optional filename + language header with copy. Supports line numbers, highlighted lines, and the add/remove diff variant.
Included in the single kansho full pack. Components are not offered as separate installs.
TypeScript with header and copy
1export async function load(id: string) {2 const row = await db.select().from(runs).where(eq(runs.id, id));3 if (!row) throw new RunNotFoundError(id);4 return row;5}Highlighted lines
1export async function load(id: string) {2 const row = await db.select().from(runs).where(eq(runs.id, id));3 if (!row) throw new RunNotFoundError(id);4 return row;5}Diff variant
function risk(commit: Commit) {− if (commit.files.length === 0) return 'low';+ if (commit.files.length === 0) return 'doc-only';+ if (commit.touchesSchema) return 'high'; return 'medium';}Shell — no line numbers, no filename
# rebuild the index after the new event type landspsql -c "REINDEX INDEX CONCURRENTLY idx_audit_log_event;"Inside an assistant message
Here's the smallest change that fixes it:
function risk(commit: Commit) {− if (commit.files.length === 0) return 'low';+ if (commit.files.length === 0) return 'doc-only';+ if (commit.touchesSchema) return 'high'; return 'medium';}Streamlined chat variant
For the route handler, the whole cookie write can stay compact:
response.cookies.set("session", token, { httpOnly: true, sameSite: "lax", secure: true,});Scrollable with maxHeight
1line 12line 23line 34line 45line 56line 67line 78line 89line 910line 1011line 1112line 1213line 1314line 1415line 1516line 1617line 1718line 1819line 1920line 2021line 2122line 2223line 2324line 2425line 2526line 2627line 2728line 2829line 2930line 3031line 3132line 3233line 3334line 3435line 3536line 3637line 3738line 3839line 3940line 40Component documentation
Code Block
components/agent/code-block.tsxPurpose
Displays code or diff lines with optional filename, line numbers, highlighting, scrolling, and copy feedback.
Appropriate use
Use for read-only code and command output in agent messages or inspection surfaces.
Example
components/agent/code-block.tsx has a representative live example in the "TypeScript with header and copy" section on /components/code-block.
States
Supports default or chat variants, plain code or typed context/add/remove lines, optional line numbers, highlighted rows, filename, language, and max height.
API and props
CodeBlock accepts code, lines, language, filename, showLineNumbers, highlightLines, maxHeight, variant, and className.
Dependencies
Direct imports are React, Lucide icons, IconButton, and cn.
Accessibility
The scrollable code region is keyboard-focusable and named; the copy control has a changing accessible label and polite copied feedback.
Limitations
It is a renderer, not a syntax parser or editor; highlighting is caller-supplied and clipboard failure has no visible error state.
Source
Source: components/agent/code-block.tsx.
Full pack
components/agent/code-block.tsx is documented at /components/code-block and installs only through the single Kansho full pack; no individual component install is offered.