Shows test runs in a pane.

Archived: not maintained.
A mod (a plugin that adds hooks to Claude Code) that shows test runs in a pane. It reads the progress of a test run from the log file the run writes.
A long test run in the background gives no sign of progress. work-pane shows each run with a progress bar and the pass and fail counts.
It is not installable from the marketplace. No plugin in .claude-plugin/marketplace.json lists it, so no cj-stack plugin ships it.
pnpm test 2>&1 | tee /tmp/e2e.log.12/146, and pass 11 fail 1.The log must print lines like [12/146] ✔ Suite test (19s) pass 11 fail 1. The script demo/fake-suite.sh prints such lines.
| Event | Decision |
|---|---|
A Bash command pipes to tee on its first line | Add a row, keep the last 10, and open the pane. |
| One second passes | Read the last 40 log lines of each running row and update the counts. |
| The count reaches the total | Mark the row finished: ✓, or ✗ if any test failed. |
| A foreground run ends | Read the log once and mark the row finished. |
You run /tests | Open the pane. It lists the newest three rows, or "No test runs yet". |
No settings. If you loaded a local copy, run claude plugin disable work-pane to turn it off.
| tee <file> or | tee -a <file> on the first line of the command.hooks/register.tsx 120 lines1import { atom, read, update } from 'claude-code'
2import type { Register } from 'claude-code'
3
4import type { TestRun } from '../types'
5
6const TESTS_PANE = 'tests'
7const BAR_CELLS = 16
8
9const runs = atom({ plugin: 'work-pane', key: 'runs' } as const, [] as TestRun[])
10
11const SHOWN_RUNS = 3
12const TEE = /\|\s*tee\s+(?:-a\s+)?(['"]?)([^\s'"|;&]+)\1/
13const UNIT = /\[(\d+)\/(\d+)\]/g
14
15function teeLog(command: string): string | undefined {
16 return TEE.exec(command.split("\n")[0])?.[2]
17}
18
19function parseLog(text: string): Pick<TestRun, 'done' | 'total' | 'pass' | 'fail'> {
20 const units = [...text.matchAll(UNIT)]
21 const last = units.at(-1)
22 if (!last) return {}
23 const line = text.slice(last.index).split('\n')[0]
24 const pass = /pass (\d+)/.exec(line)?.[1]
25 const fail = /fail (\d+)/.exec(line)?.[1]
26 return {
27 done: Number(last[1]),
28 total: Number(last[2]),
29 pass: pass === undefined ? undefined : Number(pass),
30 fail: fail === undefined ? undefined : Number(fail),
31 }
32}
33
34async function readRun($: Parameters<typeof read>[0], run: TestRun): Promise<TestRun> {
35 try {
36 const { stdout } = await $.process.run(['tail', '-n', '40', run.log], { timeoutMs: 2000 })
37 return { ...run, ...parseLog(stdout) }
38 } catch {
39 return run
40 }
41}
42
43export const register: Register = on => {
44 let isInteractive = true
45
46 on('session.start', async ($, e, next) => {
47 isInteractive = e.isInteractive !== false
48 if (!isInteractive) return next(e)
49 await $.command.register({ name: 'tests', description: 'Open the Tests pane' })
50 $.clock.every(1000, async () => {
51 const runningRuns = (await read($, runs)).filter(r => r.endedAt === undefined)
52 if (runningRuns.length === 0) return
53 for (const run of runningRuns) {
54 const read_ = await readRun($, run)
55 const isComplete = read_.total !== undefined && read_.done === read_.total
56 const next_ = isComplete ? { ...read_, endedAt: Date.now(), isFailed: (read_.fail ?? 0) > 0 } : read_
57 await update($, runs, list => list.map(r => (r.id === run.id ? next_ : r)))
58 }
59 $.ui.invalidate('ui.render')
60 })
61 return next(e)
62 })
63
64 on('command.run', { command: 'tests' }, async $ => {
65 await $.ui.open({ id: TESTS_PANE, title: 'Tests' })
66 return { text: 'Tests pane opened.' }
67 })
68
69 on('tool.call', async ($, e, next) => {
70 let args = e as unknown as Record<string, unknown>
71
72 const log = isInteractive && e.tool === 'Bash' && typeof args.command === 'string' ? teeLog(args.command) : undefined
73 if (log) {
74 const command = args.command as string
75 const run: TestRun = {
76 id: e.tool_use_id ?? `${Date.now()}`,
77 label: command.split('|')[0].trim().slice(0, 48),
78 log,
79 }
80 await update($, runs, list => [...list, run].slice(-10))
81 void $.ui.open({ id: TESTS_PANE, title: 'Tests' })
82 const ran = await next(e)
83 if (args.run_in_background !== true) {
84 const final = await readRun($, run)
85 const isFailed = ran.deny !== undefined || ran.isError === true || (final.fail ?? 0) > 0
86 await update($, runs, list => list.map(r => (r.id === run.id ? { ...final, endedAt: Date.now(), isFailed } : r)))
87 }
88 return ran
89 }
90
91 return next(e)
92 })
93
94 on('ui.render', { component: 'Pane', requestId: TESTS_PANE }, async ($, e) => {
95 const { Box, Text } = $.ui.resolve(e)
96 const testRows = (await read($, runs)).slice(-SHOWN_RUNS)
97 if (testRows.length === 0) return <Text dimColor>No test runs yet</Text>
98
99 return (
100 <Box flexDirection="column">
101 {testRows.map(r => {
102 const mark = r.endedAt === undefined ? '●' : r.isFailed ? '✗' : '✓'
103 const hasCount = r.total !== undefined && r.done !== undefined
104 const cells = hasCount ? Math.round((r.done! / Math.max(1, r.total!)) * BAR_CELLS) : 0
105 const counts = r.pass !== undefined ? ` · pass ${r.pass} fail ${r.fail ?? 0}` : ''
106 const state = hasCount
107 ? `${'█'.repeat(cells)}${'░'.repeat(BAR_CELLS - cells)} ${r.done}/${r.total}${counts}`
108 : r.endedAt === undefined ? 'running' : 'finished'
109 return (
110 <Box flexDirection="column" marginBottom={1}>
111 <Text dimColor={r.endedAt !== undefined}>{`${mark} ${r.label}`}</Text>
112 <Text dimColor>{` ${state}`}</Text>
113 </Box>
114 )
115 })}
116 </Box>
117 )
118 })
119}
120types/index.d.ts 18 lines1export type TestRun = {
2 id: string
3 label: string
4 log: string
5 done?: number
6 total?: number
7 pass?: number
8 fail?: number
9 endedAt?: number
10 isFailed?: boolean
11}
12
13declare module 'claude-code' {
14 interface PluginState {
15 'work-pane': { runs: TestRun[] }
16 }
17}
18