SLOPSHOPPER

oli-claude-mod-clean-view

A calm checklist above the prompt that hides tool calls, diffs and command output while Claude works.

bandrowsguardcommandtoastprompt
v0.1.0no licenseupdated 2026-10-21OliverRC/oli-claude-mods/plugins/clean-view
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · oli-claude-mod-clean-view
› fix the failing auth test and add an audit log call ╭───────────────────────────────────────╮ │ oli-claude-mod-clean-view │ ⏺ Read(src/auth.ts) │ Clean View is off: showing everything │ ⎿ Read 6 lines ╰───────────────────────────────────────╯ ⏺ Update(src/auth.ts) ⎿ Added 2 lines, removed 1 line ⏺ Read(/work/app/src/auth.ts) ⎿ Denied by oli-claude-mod-clean-view: Clean View: call plan_steps first to lay out the steps of this job (l ● Done. refresh now rejects expired claims and logs an audit event. ✻ Worked for 42s · done 4:20 PM › /simple ⎿ oli-claude-mod-clean-view: Clean View is off. [ ○ Clean View: OFF ] ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts

Draws

Band
[ ○ Clean View: OFF ]
README

Clean View

A Claude Code mod that makes Claude feel calm for non-technical people: tool calls, diffs and command output are hidden, and a simple checklist above the prompt shows the plan, the current step and how far along it is.

The idea and original prompt for Clean View came from Tristen O'Brien.

Use it

  • Click ● Clean View: ON at the right of the band above the prompt to switch it, or type /simple on, /simple off, or /simple to flip it. The choice is remembered.

Install

See the marketplace README.

Develop

claude plugin validate .
claude plugin test .
Source 3 files
hooks/register.tsx 9 lines
1import type { Register } from 'claude-code'
2
3import { registerCleanView } from './clean-view'
4
5// One entry point; add more mods beside Clean View here.
6export const register: Register = on => {
7  registerCleanView(on)
8}
9
hooks/clean-view.tsx 683 lines
1import { atom, read, update } from 'claude-code'
2import type { EngineInterface, On, RenderChildren } from 'claude-code'
3
4import type { CleanViewChecklist, CleanViewTask } from '../types'
5
6type $ = EngineInterface
7type Checklist = CleanViewChecklist
8type Task = CleanViewTask
9
10export const PLAN_TOOL = 'mcp__oli-claude-mod-clean-view__plan_steps'
11export const PROGRESS_TOOL = 'mcp__oli-claude-mod-clean-view__report_progress'
12
13const enabled = atom({ plugin: 'oli-claude-mod-clean-view', key: 'cleanViewEnabled' } as const, true)
14const checklist = atom({ plugin: 'oli-claude-mod-clean-view', key: 'checklist' } as const, null)
15const tickAtom = atom({ plugin: 'oli-claude-mod-clean-view', key: 'tick' } as const, 0)
16const helperTokens = atom({ plugin: 'oli-claude-mod-clean-view', key: 'helperTokens' } as const, {})
17
18const LIVE_AGENT = new Set(['pending', 'running', 'waiting'])
19
20/** The helper agents still at work, minus the one whose turn is ending. */
21async function liveHelpers($: $, except?: string) {
22  return (await $.agent.list()).filter(a => LIVE_AGENT.has(a.status) && a.id !== except)
23}
24
25export function tokens(n: number): string {
26  return n >= 1000 ? `${(n / 1000).toFixed(1).replace(/\.0$/, '')}k tokens` : `${n} tokens`
27}
28
29const ALWAYS_ALLOWED = new Set(['ToolSearch', 'TodoWrite', 'TaskCreate', 'TaskUpdate', 'AskUserQuestion'])
30const STORE_KEY = 'cleanViewEnabled'
31const MAX_NAME = 40
32const METER = 10
33
34const GUIDE = `# Clean View is on
35
36The person sees a simple checklist of your plan instead of tool calls, so keep it accurate and friendly.
37
38- For every request, even a quick question, call \`plan_steps\` first (load it with ToolSearch if it is deferred): 2 to 8 short steps, in order.
39- Write every step name in plain English a non-technical person understands. Keep it under 40 characters and start it with a verb, like "Build the pricing section".
40- Never put file paths, file names, commands, code or tool names in a step name.
41- Call \`report_progress\` as real progress happens, and with percent 100 the moment a step finishes.
42- If this session has TodoWrite or TaskCreate, you may use your to-do list as the plan instead.`
43
44const CODE_FILE = /\b[\w.-]+\.(?:tsx?|jsx?|mjs|cjs|mts|cts|json|php|py|rb|cs|go|rs|java|kt|swift|c|cc|cpp|h|hpp|css|scss|less|html?|vue|svelte|md|ya?ml|toml|ini|sh|zsh|bash|sql|lock|env|xml|csproj|sln)\b/gi
45
46/** The one cleaner every step and job name passes through. */
47export function cleanName(raw: string): string {
48  let s = String(raw ?? '')
49    .replace(/`[^`]*`?/g, ' ')
50    .split(/\s+/)
51    .filter(word => !word.includes('/') && !word.includes('\\'))
52    .join(' ')
53    .replace(CODE_FILE, ' ')
54    .replace(/\s+/g, ' ')
55    .trim()
56  if (s.length > MAX_NAME) {
57    const cut = s.slice(0, MAX_NAME - 1)
58    const space = cut.lastIndexOf(' ')
59    s = (space > 0 ? cut.slice(0, space) : cut).replace(/[\s,.;:–-]+$/, '') + '…'
60  }
61  if (s === '' || s === '…') return 'Working on it'
62  return s.charAt(0).toUpperCase() + s.slice(1)
63}
64
65export function duration(ms: number): string {
66  const total = Math.max(0, Math.round(ms / 1000))
67  const h = Math.floor(total / 3600)
68  const m = Math.floor((total % 3600) / 60)
69  const s = total % 60
70  if (h > 0) return `${h}h ${m}m`
71  return m > 0 ? `${m}m ${s}s` : `${s}s`
72}
73
74function apiErrorSentence(kind: string | undefined, details = ''): string {
75  if (/too long|context|too many tokens/i.test(details)) return 'type /compact and try again'
76  if (/network|ECONN|ENOTFOUND|socket|fetch failed|offline|connection/i.test(details)) return 'the internet connection dropped'
77  if (kind === 'rate_limit' || kind === 'billing_error') return 'you hit your usage limit, try again a little later'
78  if (kind === 'overloaded' || kind === 'server_error') return "Claude's servers are busy, try again in a minute"
79  if (kind === 'authentication_failed' || kind === 'oauth_org_not_allowed' || kind === 'cloud_credential_error') return 'type /login'
80  return 'something went wrong, try again'
81}
82
83const USER_SAID_NO = /user (?:doesn't|does not) want to proceed|user rejected|rejected by the user|denied by the user|user declined/i
84
85// --- state edits ------------------------------------------------------------
86
87// Module timers die with a reload; session.start resyncs them.
88let timer: { cancel: () => void } | undefined
89let failures = 0
90let lastApiError: { kind?: string; details?: string } | null = null
91
92function syncTimer($: $, list: Checklist | null) {
93  const isLive = list !== null && (list.phase === 'working' || list.phase === 'needs-you')
94  if (isLive && timer === undefined) timer = $.clock.every(250, () => void update($, tickAtom, n => (n ?? 0) + 1))
95  if (!isLive && timer !== undefined) {
96    timer.cancel()
97    timer = undefined
98  }
99}
100
101async function edit($: $, fn: (list: Checklist | null) => Checklist | null) {
102  let out = null as Checklist | null
103  await update($, checklist, list => (out = fn(list ?? null)))
104  syncTimer($, out)
105  return out
106}
107
108function newList(now: number, title: string): Checklist {
109  return {
110    title,
111    phase: 'working',
112    tasks: [
113      { id: 'placeholder-1', name: 'Understand your request', status: 'active', percent: 0, hasReported: false },
114      { id: 'placeholder-2', name: 'Plan the steps', status: 'upcoming', percent: 0, hasReported: false },
115    ],
116    needsYouReason: null,
117    stuckReason: null,
118    startedAt: now,
119    finishedAt: null,
120    isCollapsed: false,
121    isPlanned: false,
122  }
123}
124
125function working(list: Checklist): Checklist {
126  return { ...list, phase: 'working', needsYouReason: null, stuckReason: null, finishedAt: null, isCollapsed: false, isWaitingOnHelpers: false }
127}
128
129/** Makes the first unfinished step active when none is. */
130function ensureActive(tasks: Task[]): Task[] {
131  if (tasks.some(t => t.status === 'active')) return tasks
132  const i = tasks.findIndex(t => t.status !== 'done')
133  return i < 0 ? tasks : tasks.map((t, j) => (j === i ? { ...t, status: 'active' } : t))
134}
135
136export function applyPlan(list: Checklist, steps: string[]): Checklist {
137  const tasks: Task[] = steps.map((step, i) => ({
138    id: `step-${i + 1}`,
139    name: cleanName(step),
140    status: i === 0 ? 'active' : 'upcoming',
141    percent: 0,
142    hasReported: false,
143  }))
144  return { ...working(list), tasks, isPlanned: true }
145}
146
147export function applyProgress(list: Checklist, rawName: string, rawPercent: number): Checklist {
148  const name = cleanName(rawName)
149  const percent = Math.min(100, Math.max(0, Math.round(Number.isFinite(rawPercent) ? rawPercent : 0)))
150  let tasks = list.isPlanned ? [...list.tasks] : []
151  let at = tasks.findIndex(t => t.name.toLowerCase() === name.toLowerCase())
152  if (at < 0) {
153    tasks.push({ id: `step-${tasks.length + 1}-${name}`, name, status: 'upcoming', percent: 0, hasReported: false })
154    at = tasks.length - 1
155  }
156  tasks = tasks.map((t, i): Task => {
157    if (i < at) return { ...t, status: 'done', percent: 100 }
158    if (i === at) return { ...t, status: percent >= 100 ? 'done' : 'active', percent, hasReported: true }
159    return t.status === 'active' ? { ...t, status: 'upcoming' } : t
160  })
161  if (percent >= 100) {
162    const nextAt = tasks.findIndex((t, i) => i > at && t.status !== 'done')
163    const following = tasks[nextAt]
164    if (following) tasks[nextAt] = { ...following, status: 'active', percent: 0, hasReported: false }
165  }
166  return { ...list, tasks }
167}
168
169type Todo = { content?: unknown; status?: unknown }
170
171function fromTodos(list: Checklist, todos: Todo[]): Checklist {
172  const old = new Map(list.tasks.map(t => [t.name, t]))
173  const tasks = todos.map((todo, i): Task => {
174    const name = cleanName(String(todo.content ?? ''))
175    const prior = old.get(name)
176    if (todo.status === 'completed') return { id: `todo-${i + 1}`, name, status: 'done', percent: 100, hasReported: true }
177    const status = todo.status === 'in_progress' ? 'active' : 'upcoming'
178    return { id: `todo-${i + 1}`, name, status, percent: prior?.percent ?? 0, hasReported: prior?.hasReported ?? false }
179  })
180  return { ...list, tasks: ensureActive(tasks), isPlanned: true }
181}
182
183// --- the job's life -----------------------------------------------------------
184
185async function nameJob($: $, text: string, startedAt: number) {
186  const prompt = `Name this job in 2 to 6 plain words a non-technical person understands, starting with a verb. No file names, code or punctuation. Reply with the name only.\n\nRequest: ${text.slice(0, 2000)}`
187  try {
188    let answer = await $.model.complete({ model: 'haiku', effort: 'low', maxTokens: 24, timeoutMs: 15000, prompt })
189    if (!answer.isAnswered && answer.reason === 'api-error') answer = await $.model.complete({ model: 'haiku', maxTokens: 24, timeoutMs: 15000, prompt })
190    if (!answer.isAnswered) return
191    const words = (answer.text.split('\n')[0] ?? '').replace(/["'*.]/g, '').trim().split(/\s+/).slice(0, 6).join(' ')
192    if (words === '') return
193    await edit($, list => (list !== null && list.startedAt === startedAt ? { ...list, title: cleanName(words) } : list))
194  } catch {
195    // The placeholder title stays.
196  }
197}
198
199async function onPrompt($: $, text: string) {
200  const now = await $.clock.now()
201  failures = 0
202  lastApiError = null
203  let startedAt: number | null = null
204  await edit($, list => {
205    // A reply to "Needs you" or "Stuck" carries the same job on.
206    if (list !== null && (list.phase === 'needs-you' || list.phase === 'stuck' || list.phase === 'working')) return working(list)
207    startedAt = now
208    return newList(now, cleanName(text.split(/\s+/).slice(0, 6).join(' ')))
209  })
210  if (startedAt !== null) void nameJob($, text, startedAt)
211}
212
213async function setNeedsYou($: $, reason: string) {
214  await edit($, list => (list === null || list.phase === 'done' || list.phase === 'stopped' ? list : { ...list, phase: 'needs-you', needsYouReason: reason }))
215}
216
217async function clearNeedsYou($: $) {
218  await edit($, list => (list?.phase === 'needs-you' ? { ...list, phase: 'working', needsYouReason: null } : list))
219}
220
221async function setStuck($: $, reason: string) {
222  await edit($, list => (list === null ? list : { ...list, phase: 'stuck', stuckReason: reason, needsYouReason: null }))
223}
224
225async function noteOutcome($: $, ran: { deny?: string; isError?: true; text?: string; result?: unknown }) {
226  if (ran.deny !== undefined) return
227  if (ran.isError) {
228    const said = `${ran.text ?? ''} ${typeof ran.result === 'string' ? ran.result : ''}`
229    if (USER_SAID_NO.test(said)) return setStuck($, 'you said no to a step, so Claude paused')
230    failures += 1
231    if (failures >= 3) await setStuck($, 'a step keeps failing, Claude is trying another way')
232    return
233  }
234  failures = 0
235  await edit($, list => (list?.phase === 'stuck' ? { ...list, phase: 'working', stuckReason: null } : list))
236}
237
238async function onTurnComplete($: $, reason: string, answer: string) {
239  const now = await $.clock.now()
240  const error = lastApiError
241  lastApiError = null
242  const isHelping = reason === 'answer' && (await liveHelpers($)).length > 0
243  let doneJob: number | null = null
244  await edit($, list => {
245    if (list === null) return list
246    if (reason === 'error') return { ...list, phase: 'stuck', stuckReason: apiErrorSentence(error?.kind, error?.details), needsYouReason: null }
247    if (reason === 'refusal') return { ...list, phase: 'stuck', stuckReason: "Claude couldn't help with that request", needsYouReason: null }
248    if (reason === 'aborted') return { ...list, phase: 'stopped', finishedAt: now, needsYouReason: null }
249    const isUnfinished = list.isPlanned && list.tasks.some(t => t.status !== 'done')
250    if (isUnfinished && list.phase === 'stuck') return list
251    // Claude often answers without ticking off its last steps; only a reply that asks something needs you.
252    // shortcut: a question mid-reply that doesn't end on "?" reads as done, upgrade to a Haiku check if that bites.
253    if (isUnfinished && /\?\s*$/.test(answer.replace(/[*_`)\]]+\s*$/, ''))) return { ...list, phase: 'needs-you', needsYouReason: 'Claude asked you a question' }
254    // Background helpers still running: the job isn't done until they report back.
255    if (isHelping) return { ...list, isWaitingOnHelpers: true }
256    doneJob = list.startedAt
257    const tasks = list.tasks.map((t): Task => ({ ...t, status: 'done', percent: 100 }))
258    return { ...list, tasks, phase: 'done', finishedAt: now, needsYouReason: null, stuckReason: null, isCollapsed: false }
259  })
260  if (doneJob !== null) {
261    const startedOf = doneJob
262    $.clock.after(5000, () => {
263      void edit($, list => (list !== null && list.phase === 'done' && list.startedAt === startedOf ? { ...list, isCollapsed: true } : list))
264    })
265  }
266}
267
268async function toggle($: $, to?: boolean) {
269  let now = true
270  await update($, enabled, was => (now = to ?? !(was ?? true)))
271  await $.store.set(STORE_KEY, now)
272  $.ui.toast(now ? 'Clean View is on: tool details are hidden' : 'Clean View is off: showing everything')
273  return now
274}
275
276// --- drawing ------------------------------------------------------------------
277
278function fit(text: string, width: number): string {
279  if (text.length > width) return text.slice(0, Math.max(0, width - 1)) + '…'
280  return text.padEnd(width)
281}
282
283// A soft pastel palette that reads well on dark terminals.
284const PALETTE = {
285  peach: '#FAB387',
286  pink: '#F38BA8',
287  mauve: '#CBA6F7',
288  blue: '#89B4FA',
289  green: '#A6E3A1',
290  yellow: '#F9E2AF',
291  red: '#EBA0AC',
292  text: '#CDD6F4',
293  subtle: '#7F849C',
294  track: '#45475A',
295}
296const TITLE_RAMP = [PALETTE.peach, PALETTE.pink, PALETTE.mauve, PALETTE.blue]
297const SWEEP_FADE = ['#3B3052', '#5B4A7A', '#8C7BD0', '#B4BEFE']
298const SPARKLE = ['✶', '✷', '✸', '✹', '✺', '✹', '✸', '✷']
299
300function hex(color: string): [number, number, number] {
301  const n = parseInt(color.slice(1), 16)
302  return [(n >> 16) & 255, (n >> 8) & 255, n & 255]
303}
304
305/** The colour at `t` (0..1) along a ramp of hex stops. */
306function rampAt(stops: string[], t: number): string {
307  const x = Math.min(1, Math.max(0, t)) * (stops.length - 1)
308  const i = Math.min(stops.length - 2, Math.floor(x))
309  const a = hex(stops[i] ?? '#000000')
310  const b = hex(stops[i + 1] ?? '#000000')
311  const f = x - i
312  return '#' + a.map((v, k) => Math.round(v + ((b[k] ?? 0) - v) * f).toString(16).padStart(2, '0')).join('')
313}
314
315type Cell = { char: string; color: string }
316
317function meter(task: Task, tick: number, isAnimated: boolean): Cell[] {
318  const ramp = (i: number) => rampAt([PALETTE.pink, PALETTE.mauve, PALETTE.blue], i / (METER - 1))
319  const track = (): Cell => ({ char: '░', color: PALETTE.track })
320  if (task.status === 'done') return Array.from({ length: METER }, (_, i) => ({ char: '█', color: rampAt(['#40A02B', PALETTE.green], i / (METER - 1)) }))
321  if (task.status === 'upcoming') return Array.from({ length: METER }, track)
322  if (task.hasReported) {
323    const filled = Math.round(task.percent / 10)
324    return Array.from({ length: METER }, (_, i) => (i < filled ? { char: '█', color: ramp(i) } : track()))
325  }
326  // No percent yet: a fading four-cell comet bouncing across the meter.
327  const step = isAnimated ? tick % 12 : 0
328  const head = step < 7 ? step + 3 : 15 - step
329  const dir = step < 7 ? 1 : -1
330  return Array.from({ length: METER }, (_, i) => {
331    const behind = (head - i) * dir
332    const shade = SWEEP_FADE[SWEEP_FADE.length - 1 - behind]
333    return behind >= 0 && shade !== undefined ? { char: '█', color: shade } : track()
334  })
335}
336
337function label(task: Task, firstUpcoming: boolean): string {
338  if (task.status === 'done') return 'Done'
339  if (task.status === 'upcoming') return firstUpcoming ? 'Next' : 'Up next'
340  return task.hasReported ? `${task.percent}%` : 'Working'
341}
342
343// --- hooks ----------------------------------------------------------------------
344
345export function registerCleanView(on: On) {
346  on('session.start', async ($, e, next) => {
347    const saved = await $.store.get(STORE_KEY)
348    if (typeof saved === 'boolean') await update($, enabled, () => saved)
349    await $.tool.register({
350      name: 'plan_steps',
351      description:
352        'Lay out every step of the job up front, before any other tool: 2 to 8 short plain-English step names, in order, each under 40 characters and starting with a verb. No file names, paths, commands or code. The first step starts right away.',
353      inputSchema: {
354        type: 'object',
355        properties: { steps: { type: 'array', items: { type: 'string' }, minItems: 1, maxItems: 8 } },
356        required: ['steps'],
357      },
358      isDeferred: false,
359    })
360    await $.tool.register({
361      name: 'report_progress',
362      description:
363        'Report progress on the current step, by its name from plan_steps, as real progress happens. Send percent 100 the moment a step finishes; the next step then starts. A name not in the plan becomes a new step.',
364      inputSchema: {
365        type: 'object',
366        properties: { task: { type: 'string' }, percent: { type: 'number', minimum: 0, maximum: 100 } },
367        required: ['task', 'percent'],
368      },
369      isDeferred: false,
370    })
371    await $.command.register({ name: 'simple', description: 'Turn Clean View on or off', argumentHint: 'on|off' })
372    syncTimer($, await read($, checklist))
373    return next(e)
374  })
375
376  on('command.run', { command: 'simple' }, async ($, e) => {
377    const arg = e.args.trim().toLowerCase()
378    const isOn = await toggle($, arg === 'on' ? true : arg === 'off' ? false : undefined)
379    return { text: isOn ? 'Clean View is on.' : 'Clean View is off.' }
380  })
381
382  on('prompt.compose', async ($, e, next) => {
383    const composed = await next(e)
384    if (!(await read($, enabled))) return composed
385    return { ...composed, sections: [...composed.sections, { id: 'CLAUDE-MOD-CLEAN-VIEWide', text: GUIDE, scope: 'session' as const }] }
386  })
387
388  on('turn.start', async ($, e, next) => {
389    const text = e.text.trim()
390    if (text !== '' && !text.startsWith('/')) await onPrompt($, text)
391    return next(e)
392  })
393
394  on('tool.call', async ($, e, next) => {
395    const tool = String(e.tool)
396    const input = e as unknown as Record<string, unknown>
397
398    if (tool === PLAN_TOOL) {
399      const steps = Array.isArray(input.steps) ? input.steps.filter((s): s is string => typeof s === 'string' && s.trim() !== '') : []
400      if (steps.length === 0) return { deny: 'plan_steps needs 2 to 8 short step names.' }
401      const now = await $.clock.now()
402      const list = await edit($, l => applyPlan(l ?? newList(now, 'Working on it'), steps.slice(0, 8)))
403      return { result: `Planned ${list?.tasks.length ?? 0} steps. The first one has started.` }
404    }
405    if (tool === PROGRESS_TOOL) {
406      const now = await $.clock.now()
407      const percent = Math.min(100, Math.max(0, Number(input.percent) || 0))
408      await edit($, l => applyProgress(l ?? newList(now, 'Working on it'), String(input.task ?? ''), percent))
409      return { result: `Progress noted: ${Math.round(percent)}%.` }
410    }
411    if (e.agentId !== undefined) return next(e)
412
413    if ((await read($, enabled)) && !ALWAYS_ALLOWED.has(tool) && !(await read($, checklist))?.isPlanned) {
414      return { deny: 'Clean View: call plan_steps first to lay out the steps of this job (load it with ToolSearch if it is deferred), then try again.' }
415    }
416
417    await clearNeedsYou($)
418    if (tool === 'AskUserQuestion') await setNeedsYou($, 'Claude has a question for you')
419    if (tool === 'TodoWrite' && Array.isArray(input.todos)) {
420      const now = await $.clock.now()
421      await edit($, l => fromTodos(l ?? newList(now, 'Working on it'), input.todos as Todo[]))
422    }
423    if (tool === 'TaskUpdate') {
424      await edit($, l => {
425        if (l === null) return l
426        const id = String(input.taskId)
427        if (input.status === 'deleted') return { ...l, tasks: ensureActive(l.tasks.filter(t => t.id !== id)) }
428        const tasks = l.tasks.map((t): Task => {
429          if (t.id !== id) return t
430          const named = typeof input.subject === 'string' ? { ...t, name: cleanName(input.subject) } : t
431          if (input.status === 'completed') return { ...named, status: 'done', percent: 100, hasReported: true }
432          if (input.status === 'in_progress') return { ...named, status: 'active' }
433          if (input.status === 'pending') return { ...named, status: 'upcoming' }
434          return named
435        })
436        return { ...l, tasks: ensureActive(tasks) }
437      })
438    }
439
440    const ran = await next(e)
441
442    if (tool === 'TaskCreate' && ran.deny === undefined && !ran.isError) {
443      const made = (ran.result as { task?: { id?: string } } | undefined)?.task
444      const now = await $.clock.now()
445      await edit($, l => {
446        const base = l ?? newList(now, 'Working on it')
447        const tasks = base.isPlanned ? base.tasks : []
448        const task: Task = { id: String(made?.id ?? `task-${tasks.length + 1}`), name: cleanName(String(input.subject ?? '')), status: 'upcoming', percent: 0, hasReported: false }
449        return { ...base, tasks: ensureActive([...tasks, task]), isPlanned: true }
450      })
451    }
452    await clearNeedsYou($)
453    await noteOutcome($, ran)
454    return ran
455  })
456
457  on('classic.Notification', async ($, e, next) => {
458    if (e.notification_type === 'permission_prompt') await setNeedsYou($, 'Claude needs your OK to continue')
459    if (e.notification_type === 'elicitation_dialog') await setNeedsYou($, 'Claude has a question for you')
460    return next(e)
461  })
462
463  on('classic.StopFailure', async ($, e, next) => {
464    lastApiError = { kind: e.error, details: e.error_details }
465    return next(e)
466  })
467
468  on('turn.complete', async ($, e, next) => {
469    if (e.agentId === undefined) await onTurnComplete($, e.reason, e.answer)
470    const done = await next(e)
471    // The last helper finishing while Claude sits idle closes the job.
472    if (e.agentId !== undefined && (await read($, checklist))?.isWaitingOnHelpers && (await liveHelpers($, e.agentId)).length === 0) {
473      await onTurnComplete($, 'answer', '')
474    }
475    return done
476  })
477
478  on('turn.step', async function* ($, e, next) {
479    const step = yield* next(e)
480    const id = e.agentId
481    const u = step.usage
482    if (id !== undefined && u) {
483      const size = u.input_tokens + u.cache_read_input_tokens + u.cache_creation_input_tokens + u.output_tokens
484      await update($, helperTokens, all => ({ ...all, [id]: size }))
485    }
486    return step
487  })
488
489  // --- hide the technical rows ---
490
491  on('ui.render', { component: 'ToolUse' }, async ($, e, next) => {
492    if (!(await read($, enabled))) return next(e)
493    const { Box } = $.ui.resolve(e)
494    return <Box display="none" />
495  })
496  on('ui.render', { component: 'ToolResult' }, async ($, e, next) => {
497    if (!(await read($, enabled))) return next(e)
498    const { Box } = $.ui.resolve(e)
499    return <Box display="none" />
500  })
501  on('ui.render', { component: 'ToolGroup' }, async ($, e, next) => {
502    if (!(await read($, enabled))) return next(e)
503    const { Box } = $.ui.resolve(e)
504    return <Box display="none" />
505  })
506  on('ui.render', { component: 'ToolProgress' }, async ($, e, next) =>
507    (await read($, enabled)) ? next({ ...e, props: { ...e.props, hint: '' } }) : next(e),
508  )
509
510  // --- the band ---
511
512  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
513    if (e.props.hasSurvey) return next(e)
514    const { Box, Text, Button } = $.ui.resolve(e)
515    const isOn = await read($, enabled)
516    const list = await read($, checklist)
517    const tick = await read($, tickAtom)
518
519    const button = (
520      <Button key="clean-view-toggle" label={isOn ? '● Clean View: ON' : '○ Clean View: OFF'} onPress={() => void toggle($)} />
521    )
522    const plainRow = (left: RenderChildren) => (
523      <Box flexDirection="row" justifyContent="space-between">
524        <Box flexShrink={1}>{left}</Box>
525        {button}
526      </Box>
527    )
528    if (!isOn || list === null) return plainRow(<Text> </Text>)
529
530    const now = await $.clock.now()
531    const took = duration((list.finishedAt ?? now) - list.startedAt)
532    const isLive = list.phase === 'working' || list.phase === 'needs-you'
533    const helpers = isLive ? await liveHelpers($) : []
534    const helperSizes = await read($, helperTokens)
535    const accent = {
536      'working': PALETTE.pink,
537      'needs-you': PALETTE.yellow,
538      'stuck': PALETTE.red,
539      'stopped': PALETTE.subtle,
540      'done': PALETTE.green,
541    }[list.phase]
542    const isAnimated = list.phase === 'working' || list.phase === 'needs-you'
543
544    const words = list.title.split(' ')
545    const title = words.map((word, i) => (
546      <Text bold color={rampAt(TITLE_RAMP, words.length === 1 ? 0 : i / (words.length - 1))}>
547        {i === 0 ? word : ` ${word}`}
548      </Text>
549    ))
550    const header = (() => {
551      switch (list.phase) {
552        case 'needs-you':
553          return (
554            <Text wrap="truncate-end">
555              <Text inverse bold color={PALETTE.yellow}> Needs you </Text>
556              <Text color={PALETTE.text}> {list.needsYouReason ?? ''}</Text>
557            </Text>
558          )
559        case 'stuck':
560          return <Text wrap="truncate-end" bold color={PALETTE.red}>⚠ Stuck: {list.stuckReason ?? ''}</Text>
561        case 'stopped':
562          return (
563            <Text wrap="truncate-end" color={PALETTE.subtle}>
564              ■ Stopped · {title} · you pressed Esc
565            </Text>
566          )
567        case 'done':
568          return (
569            <Text wrap="truncate-end">
570              <Text bold color={PALETTE.green}>✓ All done · </Text>
571              {title}
572              <Text color={PALETTE.subtle}> · took {took}</Text>
573            </Text>
574          )
575        default:
576          return (
577            <Text wrap="truncate-end">
578              <Text color={accent}>{SPARKLE[tick % SPARKLE.length]} </Text>
579              {title}
580              {list.isWaitingOnHelpers && helpers.length > 0 && (
581                <Text color={PALETTE.subtle}> · waiting on {helpers.length} {helpers.length === 1 ? 'helper' : 'helpers'}</Text>
582              )}
583            </Text>
584          )
585      }
586    })()
587    const headerRow = (
588      <Box flexDirection="row" justifyContent="space-between">
589        <Box flexShrink={1}>{header}</Box>
590        <Box flexDirection="row" gap={1} flexShrink={0}>
591          {list.phase === 'working' && <Text color={PALETTE.subtle}>{took}</Text>}
592          {button}
593        </Box>
594      </Box>
595    )
596    // Collapsed, the finished job keeps its frame: one line inside the green border.
597    if (list.phase === 'done' && list.isCollapsed) {
598      return (
599        <Box flexDirection="column" borderStyle="round" borderColor={accent} paddingX={1}>
600          {headerRow}
601        </Box>
602      )
603    }
604
605    const total = list.tasks.length
606    const doneCount = list.tasks.filter(t => t.status === 'done').length
607    const active = list.tasks.find(t => t.status === 'active')
608    const overall = total === 0 ? 0 : Math.round((doneCount * 100 + (active?.percent ?? 0)) / total)
609    const stepOf = Math.min(total, doneCount + (active ? 1 : 0))
610    const stepText = `Step ${Math.max(1, stepOf)} of ${total}`
611    const barWidth = METER
612    const barFilled = Math.round((overall / 100) * barWidth)
613    const barRamp = {
614      'working': [PALETTE.peach, PALETTE.pink],
615      'needs-you': [PALETTE.peach, PALETTE.yellow],
616      'stuck': [PALETTE.peach, PALETTE.red],
617      'stopped': [PALETTE.track, PALETTE.subtle],
618      'done': ['#40A02B', PALETTE.green],
619    }[list.phase]
620
621    // border 2 + padding 2, then glyph 2 + name + space + meter 10 + two spaces + label 7
622    const nameWidth = Math.max(6, e.props.bodyColumns - 4 - 2 - 1 - METER - 2 - 7)
623    const firstUpcoming = list.tasks.findIndex(t => t.status === 'upcoming')
624    const cells = (task: Task) => meter(task, tick, isAnimated).map(cell => <Text color={cell.color}>{cell.char}</Text>)
625
626    return (
627      <Box flexDirection="column" borderStyle="round" borderColor={accent} paddingX={1}>
628        {headerRow}
629        <Text wrap="truncate-end">
630          <Text color={PALETTE.subtle}>{stepText}  </Text>
631          {Array.from({ length: barWidth }, (_, i) =>
632            // A space between cells so the slanted glyphs don't run together.
633            i < barFilled ? <Text color={rampAt(barRamp, i / (barWidth - 1))}>▰</Text> : <Text color={PALETTE.track}>▱</Text>,
634          )}
635          <Text color={accent}>  {overall}%</Text>
636        </Text>
637        {list.tasks.map((task, i) => {
638          const name = fit(task.name, nameWidth)
639          if (task.status === 'done') {
640            return (
641              <Text wrap="truncate-end">
642                <Text color={PALETTE.green}>✓ </Text>
643                <Text color={PALETTE.subtle}>{name} </Text>
644                {cells(task)}
645                <Text color={PALETTE.green}>  {label(task, false)}</Text>
646              </Text>
647            )
648          }
649          if (task.status === 'active') {
650            const isWaiting = list.phase === 'needs-you'
651            return (
652              <Text wrap="truncate-end">
653                <Text color={isWaiting ? PALETTE.yellow : PALETTE.pink}>{isWaiting ? '‖ ' : '▶ '}</Text>
654                <Text bold color={PALETTE.text}>{name} </Text>
655                {cells(task)}
656                <Text bold color={accent}>  {label(task, false)}</Text>
657              </Text>
658            )
659          }
660          return (
661            <Text wrap="truncate-end" color={PALETTE.subtle}>
662              ○ {name} {cells(task)}  {label(task, i === firstUpcoming)}
663            </Text>
664          )
665        })}
666        {helpers.map(agent => {
667          const size = helperSizes[agent.id]
668          return (
669            <Text wrap="truncate-end">
670              <Text color={PALETTE.mauve}>  ↳ {SPARKLE[tick % SPARKLE.length]} </Text>
671              <Text color={PALETTE.text}>{cleanName(agent.description || agent.type)}</Text>
672              <Text color={PALETTE.subtle}>
673                {' '}· {agent.type}
674                {size !== undefined ? ` · ${tokens(size)}` : ''}
675              </Text>
676            </Text>
677          )
678        })}
679      </Box>
680    )
681  })
682}
683
types/index.d.ts 39 lines
1export type CleanViewTaskStatus = 'done' | 'active' | 'upcoming'
2
3export type CleanViewTask = {
4  id: string
5  name: string
6  status: CleanViewTaskStatus
7  percent: number
8  hasReported: boolean
9}
10
11export type CleanViewPhase = 'working' | 'needs-you' | 'stuck' | 'stopped' | 'done'
12
13export type CleanViewChecklist = {
14  title: string
15  phase: CleanViewPhase
16  tasks: CleanViewTask[]
17  needsYouReason: string | null
18  stuckReason: string | null
19  startedAt: number
20  finishedAt: number | null
21  isCollapsed: boolean
22  /** True once Claude laid out a real plan (plan_steps or a to-do list). */
23  isPlanned: boolean
24  /** True while Claude's own turn has ended but helpers it started are still running. */
25  isWaitingOnHelpers?: boolean
26}
27
28declare module 'claude-code' {
29  interface PluginState {
30    'oli-claude-mod-clean-view': {
31      cleanViewEnabled: boolean
32      checklist: CleanViewChecklist | null
33      tick: number
34      /** Context size of each helper agent's latest step, by agent id. */
35      helperTokens: Record<string, number>
36    }
37  }
38}
39