Colors 'decision for you' and summary text in assistant replies so they stand out

A Claude Code mod: colors "decision for you" and summary sections in assistant replies so they stand out in long sessions.
Decision for you, Decision needed, Needs your input, Your call): bordered box, text in the theme's warning color.Summary, TL;DR, Recap): same, suggestion color.Agent tool call and its result): indented 2 cells behind a left rail ▎ in a per-agent color (hashed from the call id), so a call pairs with its result and parallel agents stay apart. Compact view:◈ <type> <description> <model · effort · worktree · @name>, plus interrupted / failed; the engine's live progress stays while it runs✓ 3 tools · 4.2k tok · 3.2s · +4 −1 and the report's first line, or ↻ running in backgroundN background agents launched row is not hookableA section opens on a heading, bold label or plain label matching the above and runs to the next heading / bold label or the end of the reply. Labels inside code fences are ignored. Text before the first callout keeps the engine's own drawing.
Inside a callout:
◆ decision, ≡ summary) + the label as written.- [ ] / - [x] become ☐ / ☑; numbers right-sized to the widest one.code and fenced blocks in the theme's code color.Works best when the agent labels sections consistently, e.g. in ~/.claude/CLAUDE.md:
Always label sections `**Decision for you:**` (last in reply) and `**Summary:**`.
git clone https://github.com/Tyru5/claude-callout-colors ~/claude-code-mods/callout-colors
claude --plugin-dir ~/claude-code-mods/callout-colors
Or set it permanently in ~/.claude/settings.json (:-separated for several):
{ "env": { "CLAUDE_CODE_PLUGIN_DIRS": "/path/to/claude-callout-colors" } }
claude plugin test .
.claude-plugin/types/ is generated by the engine on load and ignored.
hooks/register.tsx: ui.render hooks on AssistantMessage, ToolUse, ToolResult.hooks/split.ts: callout detection; label patterns at the top.hooks/layout.ts: callout body -> label + blocks (paragraphs, list rows, code).hooks/subagent.ts: subagent identity, outcome, per-agent color.hooks/*.test.ts: suite run by claude plugin test.MIT
hooks/register.tsx 167 lines1import type { Elements, Register, RenderChildren } from 'claude-code'
2
3import { layout, type Block, type Span } from './layout'
4import { split, type Kind } from './split'
5import { hue, identity, outcome } from './subagent'
6
7// Theme keys, so colors follow the person's theme.
8const COLOR: Record<Kind, string> = { decision: 'warning', summary: 'suggestion' }
9// Inline code, as the engine draws it.
10const CODE_COLOR = 'permission'
11const ICON: Record<Kind, string> = { decision: '◆', summary: '≡' }
12
13// Subagent calls: the Agent tool (`Task` in older transcripts).
14const SUBAGENT_TOOLS = new Set(['Agent', 'Task'])
15// Left rail: an absolute column of bars spanning the row's height (a border
16// style would add empty top/bottom rows and split call from result).
17const RAIL_BARS = Array(400).fill('▎').join('\n')
18
19export const register: Register = on => {
20 on('ui.render', { component: 'AssistantMessage' }, async ($, e, next) => {
21 const { Box, Text, Markdown } = $.ui.resolve(e)
22
23 const run = (s: Span, color: string, i: number) => (
24 <Text key={`s${i}`} bold={s.bold} color={s.bold ? color : s.code ? CODE_COLOR : undefined}>
25 {s.text}
26 </Text>
27 )
28 const runs = (spans: Span[], color: string) => <Text>{spans.map((s, i) => run(s, color, i))}</Text>
29
30 // Header row (icon + label), then body: paragraphs, hanging-indent list rows, code.
31 const callout = (kind: Kind, text: string, key: string, withLabel = true, top = 0) => {
32 const color = COLOR[kind]
33 const { label, blocks } = layout(text, withLabel)
34 const markerWidth = Math.max(1, ...blocks.map(b => (b.type === 'item' ? b.marker.length : 0))) + 1
35 const block = (b: Block, i: number) => {
36 const k = `b${i}`
37 switch (b.type) {
38 case 'gap':
39 return <Text key={k}> </Text>
40 case 'code':
41 return (
42 <Box key={k} marginLeft={2}>
43 <Text color={CODE_COLOR}>{b.text}</Text>
44 </Box>
45 )
46 case 'para':
47 return b.heading ? (
48 <Text key={k} bold color={color}>
49 {b.spans.map(s => s.text).join('')}
50 </Text>
51 ) : (
52 <Box key={k}>{runs(b.spans, color)}</Box>
53 )
54 case 'item':
55 return (
56 <Box key={k} flexDirection="row" marginLeft={b.depth * 2}>
57 <Box flexShrink={0} width={b.ordered ? markerWidth : 2}>
58 <Text color={color} bold={b.ordered}>
59 {b.marker}
60 </Text>
61 </Box>
62 <Box flexGrow={1} flexShrink={1}>
63 {runs(b.spans, color)}
64 </Box>
65 </Box>
66 )
67 }
68 }
69 return (
70 <Box key={key} borderStyle="round" borderColor={color} paddingX={1} flexDirection="column" marginTop={top}>
71 {label && (
72 <Text bold color={color}>
73 {ICON[kind]} {label}
74 </Text>
75 )}
76 {blocks.map(block)}
77 </Box>
78 )
79 }
80
81 // Between-tool-call summaries: whole block is a summary.
82 if (e.props.isSummary) {
83 return <Box flexDirection="column">{callout('summary', e.props.text, 's', false)}</Box>
84 }
85
86 const parts = split(e.props.text)
87 if (!parts.some(p => p.kind !== 'plain')) return next(e)
88
89 // Leading plain text keeps the engine's own drawing (and its reply bullet).
90 const [head, ...rest] = parts
91 const first =
92 head?.kind === 'plain' ? await next({ ...e, props: { ...e.props, text: head.text } }) : undefined
93 const tail = first ? rest : parts
94
95 return (
96 <Box flexDirection="column">
97 {first}
98 {tail.map((p, i) =>
99 p.kind === 'plain' ? (
100 <Markdown key={`p${i}`} text={p.text} />
101 ) : (
102 callout(p.kind, p.text, `c${i}`, true, first || i > 0 ? 1 : 0)
103 ),
104 )}
105 </Box>
106 )
107 })
108
109 // Subagent rows: an indented left rail in a per-agent color, so a call pairs
110 // with its result and parallel agents stay apart. Compact view draws an
111 // identity header and a one-line outcome; expanded (ctrl+o) keeps the engine's.
112 const railed = (
113 { Box, Text }: Pick<Elements['terminal'], 'Box' | 'Text'>,
114 color: string,
115 children: RenderChildren,
116 top = 0,
117 ) => (
118 <Box marginLeft={2} marginTop={top} paddingLeft={2} flexDirection="column">
119 <Box position="absolute" top={0} bottom={0} left={0} width={1} overflow="hidden">
120 <Text color={color}>{RAIL_BARS}</Text>
121 </Box>
122 {children}
123 </Box>
124 )
125
126 on('ui.render', { component: 'ToolUse' }, async ($, e, next) => {
127 if (!SUBAGENT_TOOLS.has(e.props.tool)) return next(e)
128 const { Box, Text } = $.ui.resolve(e)
129 const color = hue(e.props.tool_use_id)
130 if (e.props.isExpanded) return railed({ Box, Text }, color, await next(e), 1)
131
132 const id = identity(e.props.input, e.props.output)
133 const state = e.props.isInterrupted ? 'interrupted' : e.props.isErrored ? 'failed' : undefined
134 return railed({ Box, Text }, color, [
135 <Text key="id">
136 <Text bold color={color}>
137 ◈ {id.type}
138 </Text>
139 {id.description ? <Text> {id.description}</Text> : null}
140 {id.tags.length ? <Text dimColor> {id.tags.join(' · ')}</Text> : null}
141 {state ? <Text color="error"> {state}</Text> : null}
142 </Text>,
143 // live progress (sub-tool calls) while it runs
144 e.props.isRunning ? await next(e) : null,
145 ], 1)
146 })
147
148 on('ui.render', { component: 'ToolResult' }, async ($, e, next) => {
149 if (!SUBAGENT_TOOLS.has(e.props.tool)) return next(e)
150 const { Box, Text } = $.ui.resolve(e)
151 const color = hue(e.props.tool_use_id)
152 const o = e.props.isExpanded || e.props.isErrored ? undefined : outcome(e.props.output)
153 if (!o) return railed({ Box, Text }, color, await next(e))
154 return railed({ Box, Text }, color, [
155 <Text key="o">
156 <Text color={color}>{o.icon}</Text>
157 <Text dimColor> {o.stats.join(' · ')}</Text>
158 </Text>,
159 o.report ? (
160 <Text key="r" dimColor wrap="truncate-end">
161 {o.report}
162 </Text>
163 ) : null,
164 ])
165 })
166}
167hooks/layout.ts 88 lines1import { OPENER } from './split'
2
3// Inline run: bold, `code`, or plain.
4export type Span = { text: string; bold?: boolean; code?: boolean }
5export type Block =
6 | { type: 'para'; spans: Span[]; heading?: boolean }
7 | { type: 'item'; marker: string; ordered: boolean; depth: number; spans: Span[] }
8 | { type: 'code'; text: string }
9 | { type: 'gap' }
10export type Layout = { label?: string; blocks: Block[] }
11
12const BULLET = /^(\s*)[-*+]\s+(?:\[([ xX])\]\s+)?(.*)$/
13const ORDERED = /^(\s*)(\d+|[a-zA-Z])[.)]\s+(.*)$/
14const HEADING = /^\s*#{1,6}\s+(.*)$/
15const FENCE = /^\s*(```|~~~)/
16
17export function spans(md: string): Span[] {
18 const out: Span[] = []
19 for (const tok of md.split(/(\*\*[^*]+\*\*|__[^_]+__|`[^`]+`)/)) {
20 if (!tok) continue
21 if (/^(\*\*|__)/.test(tok)) out.push({ text: tok.slice(2, -2), bold: true })
22 else if (tok.startsWith('`')) out.push({ text: tok.slice(1, -1), code: true })
23 else out.push({ text: tok })
24 }
25 return out
26}
27
28// Callout text -> label (from its opener line) and structured body blocks.
29export function layout(text: string, withLabel = true): Layout {
30 const lines = text.split('\n')
31 let label: string | undefined
32 const blocks: Block[] = []
33
34 if (withLabel) {
35 const m = OPENER.exec(lines[0] ?? '')
36 if (m) {
37 label = m[1]
38 // Whatever follows the label on its line opens the body.
39 lines[0] = (lines[0] ?? '').slice(m.index + m[0].length).replace(/^\s*(?:\*\*|__)?\s*:?\s*(?:\*\*|__)?\s*:?\s*/, '')
40 }
41 }
42
43 let fence: string[] | undefined
44 const gap = () => {
45 if (blocks.length && blocks[blocks.length - 1]?.type !== 'gap') blocks.push({ type: 'gap' })
46 }
47
48 for (const line of lines) {
49 if (FENCE.test(line)) {
50 if (fence) {
51 blocks.push({ type: 'code', text: fence.join('\n') })
52 fence = undefined
53 } else fence = []
54 continue
55 }
56 if (fence) {
57 fence.push(line)
58 continue
59 }
60 if (!line.trim()) {
61 gap()
62 continue
63 }
64 const b = BULLET.exec(line)
65 const o = b ? undefined : ORDERED.exec(line)
66 const h = HEADING.exec(line)
67 const prev = blocks[blocks.length - 1]
68 if (b) {
69 const marker = b[2] === undefined ? '•' : b[2] === ' ' ? '☐' : '☑'
70 blocks.push({ type: 'item', marker, ordered: false, depth: depth(b[1]), spans: spans(b[3] ?? '') })
71 } else if (o) {
72 blocks.push({ type: 'item', marker: `${o[2]}.`, ordered: true, depth: depth(o[1]), spans: spans(o[3] ?? '') })
73 } else if (h) {
74 blocks.push({ type: 'para', heading: true, spans: spans(h[1] ?? '') })
75 } else if (prev && prev.type !== 'gap' && prev.type !== 'code' && !('heading' in prev && prev.heading)) {
76 // Wrapped continuation line joins the block above.
77 prev.spans.push(...spans(' ' + line.trim()))
78 } else {
79 blocks.push({ type: 'para', spans: spans(line.trim()) })
80 }
81 }
82 if (fence) blocks.push({ type: 'code', text: fence.join('\n') })
83 while (blocks[blocks.length - 1]?.type === 'gap') blocks.pop()
84 return { label, blocks }
85}
86
87const depth = (indent = '') => Math.floor(indent.replace(/\t/g, ' ').length / 2)
88hooks/split.ts 41 lines1export type Kind = 'decision' | 'summary'
2export type Part = { kind: 'plain' | Kind; text: string }
3
4// A line opening a callout: heading, bold label, or plain label.
5export const OPENER =
6 /^\s*(?:#{1,6}\s+|\*\*|__)?\s*(decisions? (?:for you|needed|required)|needs? your (?:decision|input|call)|your (?:call|decision)|summary|tl;?dr|recap)\b/i
7
8// A line that starts a new section, ending the callout before it.
9const SECTION = /^\s*(?:#{1,6}\s+\S|(?:\*\*|__)[^*_]+(?:\*\*|__)\s*:?\s*$|(?:\*\*|__)[^*_]+:(?:\*\*|__))/
10
11function kindOf(line: string): Kind | undefined {
12 const m = OPENER.exec(line)
13 if (!m) return undefined
14 return /summary|tl;?dr|recap/i.test(m[1] ?? '') ? 'summary' : 'decision'
15}
16
17export function split(text: string): Part[] {
18 const parts: Part[] = []
19 let cur: Part = { kind: 'plain', text: '' }
20 let inFence = false
21
22 const push = () => {
23 if (cur.text.trim()) parts.push({ kind: cur.kind, text: cur.text.replace(/^\n+|\n+$/g, '') })
24 }
25
26 for (const line of text.split('\n')) {
27 if (/^\s*(```|~~~)/.test(line)) inFence = !inFence
28 const opens = inFence ? undefined : kindOf(line)
29 if (opens) {
30 push()
31 cur = { kind: opens, text: '' }
32 } else if (!inFence && cur.kind !== 'plain' && SECTION.test(line)) {
33 push()
34 cur = { kind: 'plain', text: '' }
35 }
36 cur.text += line + '\n'
37 }
38 push()
39 return parts
40}
41hooks/subagent.ts 81 lines1// Subagent identity and outcome, from the Agent tool's input and stored result.
2
3type Input = {
4 description?: string
5 subagent_type?: string
6 model?: string
7 effort?: string
8 name?: string
9 isolation?: string
10}
11type Output = {
12 status?: string
13 resolvedModel?: string
14 totalToolUseCount?: number
15 totalTokens?: number
16 totalDurationMs?: number
17 toolStats?: { linesAdded?: number; linesRemoved?: number }
18 content?: { type: string; text?: string }[]
19 worktreeBranch?: string
20}
21
22export type Identity = { type: string; description: string; tags: string[] }
23export type Outcome = { icon: string; stats: string[]; report?: string }
24
25// Theme keys an agent's rail cycles through; warning/suggestion stay with the callouts.
26const HUES = ['merged', 'permission', 'autoAccept', 'claude', 'ide', 'remember', 'planMode', 'success']
27
28export function hue(id: string): string {
29 let h = 0
30 for (const ch of id) h = (h * 31 + ch.charCodeAt(0)) >>> 0
31 return HUES[h % HUES.length] ?? 'merged'
32}
33
34// `claude-haiku-5-5[1m]` -> `haiku 5.5`
35export function shortModel(id: string): string {
36 const m = /^claude-([a-z]+)-(\d+)-(\d+)/.exec(id)
37 return m ? `${m[1]} ${m[2]}.${m[3]}` : id
38}
39
40export function identity(input: unknown, output?: unknown): Identity {
41 const i = (input ?? {}) as Input
42 const o = (output ?? {}) as Output
43 const tags = [
44 o.resolvedModel ? shortModel(o.resolvedModel) : i.model,
45 i.effort,
46 i.isolation === 'worktree' ? `worktree${o.worktreeBranch ? ` ${o.worktreeBranch}` : ''}` : i.isolation,
47 i.name && `@${i.name}`,
48 ].filter((t): t is string => !!t)
49 return { type: i.subagent_type || 'general-purpose', description: i.description ?? '', tags }
50}
51
52export function tokens(n: number): string {
53 return n < 1000 ? `${n} tok` : `${(n / 1000).toFixed(n < 10_000 ? 1 : 0)}k tok`
54}
55
56export function duration(ms: number): string {
57 const s = ms / 1000
58 if (s < 60) return `${s.toFixed(s < 10 ? 1 : 0)}s`
59 const m = Math.floor(s / 60)
60 return `${m}m ${Math.round(s % 60)}s`
61}
62
63// Compact outcome for a finished or backgrounded agent; undefined leaves the engine's.
64export function outcome(output: unknown): Outcome | undefined {
65 const o = (output ?? {}) as Output
66 if (o.status === 'async_launched') return { icon: '↻', stats: ['running in background'] }
67 if (o.status !== 'completed') return undefined
68 const stats: string[] = []
69 if (o.totalToolUseCount !== undefined) stats.push(`${o.totalToolUseCount} tool${o.totalToolUseCount === 1 ? '' : 's'}`)
70 if (o.totalTokens) stats.push(tokens(o.totalTokens))
71 if (o.totalDurationMs) stats.push(duration(o.totalDurationMs))
72 const { linesAdded = 0, linesRemoved = 0 } = o.toolStats ?? {}
73 if (linesAdded || linesRemoved) stats.push(`+${linesAdded} −${linesRemoved}`)
74 const text = (o.content ?? []).map(c => c.text ?? '').join('\n')
75 const report = text
76 .split('\n')
77 .map(l => l.replace(/^\s*(?:#{1,6}\s+|[-*+]\s+|\d+[.)]\s+)/, '').replace(/\*\*|__|`/g, '').trim())
78 .find(Boolean)
79 return { icon: '✓', stats, report }
80}
81