import type { Meta, StoryObj } from '@storybook/react' import { useState } from 'react' import { TerminalCursor, TerminalDisplay, TerminalInput, TerminalLine, } from './terminal-display' const meta: Meta = { title: 'Primitives/TerminalDisplay', component: TerminalDisplay, parameters: { layout: 'centered', backgrounds: { default: 'dark' } }, } export default meta type Story = StoryObj export const Default: Story = { name: 'Default', render: () => ( npm install {'added 312 packages, and audited 313 packages in 4s'} {'found 0 vulnerabilities'} npm run build {'\n> sandbox-app@1.0.0 build\n> tsc && vite build'} {'✓ built in 2.14s'} node dist/index.js ), } export const SandboxVariant: Story = { name: 'Sandbox Variant', render: () => ( Session initialized · node:20-alpine · us-east-1 git clone https://github.com/acme/api-service.git {'Cloning into \'api-service\'...\nremote: Enumerating objects: 1847, done.'} {'Receiving objects: 100% (1847/1847), 2.31 MiB | 14.2 MiB/s, done.'} cd api-service && npm ci {'added 421 packages in 6s'} npm test -- --reporter=dot {'............................................'} {'✓ 44 tests passed (2.8s)'} Analyzing test coverage... ), } export const WithErrors: Story = { name: 'With Errors', render: () => ( python main.py Loading model weights... {'Traceback (most recent call last):\n File "main.py", line 12, in \n model = load_checkpoint(args.ckpt)'} {'FileNotFoundError: [Errno 2] No such file or directory: \'model.pt\''} Checkpoint not found. Run download_weights.sh first. ./download_weights.sh ), } export const AgentSession: Story = { name: 'Agent Session', render: () => ( Task: Write and run unit tests for auth module Reading src/auth/jwt.ts... Found 4 exported functions to test {'cat > src/auth/__tests__/jwt.test.ts << \'EOF\''} {'Writing 6 test cases for: signToken, verifyToken, refreshToken, revokeToken'} npx vitest run src/auth/__tests__/jwt.test.ts {'✓ signToken returns a valid JWT (12ms)\n✓ verifyToken accepts valid tokens (3ms)\n✓ verifyToken rejects expired tokens (2ms)\n✓ refreshToken issues new token (8ms)\n✗ revokeToken marks token invalid (5ms)'} AssertionError: Expected token to be revoked but found status: "active" Investigating revocation logic... Found bug: redis.del() call missing await. Patching... npx vitest run src/auth/__tests__/jwt.test.ts {'✓ 6 tests passed (31ms)'} Task complete. Patch written to src/auth/jwt.ts:L84. ), } export const NoHeader: Story = { name: 'No Header', render: () => ( ls -la /workspace {'total 48\ndrwxr-xr-x 8 node node 4096 Mar 30 14:02 .\ndrwxr-xr-x 3 root root 4096 Mar 30 14:00 ..\n-rw-r--r-- 1 node node 842 Mar 30 14:01 package.json\ndrwxr-xr-x 4 node node 4096 Mar 30 14:02 src'} {'cat package.json | jq \'.scripts\''} {'{\n "build": "tsc && vite build",\n "test": "vitest",\n "dev": "vite"\n}'} ), } export const WithInput: Story = { name: 'With Input', render: () => { const [lines, setLines] = useState<{ type: 'info' | 'command' | 'output' | 'error' | 'success' | 'warning' | 'thinking'; text: string }[]>([ { type: 'info', text: 'Session ready · node:20-alpine' }, ]) return (
{lines.map((l, i) => ( {l.text} ))} { setLines((prev) => [ ...prev, { type: 'command', text: cmd }, { type: 'output', text: `[${cmd}] executed` }, ]) }} />
) }, }