SLOPSHOPPER

hide-diffs

Shows a one-line summary instead of the diff under Edit, Write, NotebookEdit and Bash calls (ctrl+q), and folds each shell command to one line (alt+q)

bandrowsguardtoast
★ 5v1.2.1MITupdated 2026-10-12gixxy22/hide-diffs
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · hide-diffs
› fix the failing auth test and add an audit log call ⏺ Read(src/auth.ts) ⎿ Read 6 lines ⏺ Update(src/auth.ts) ⎿ Added 2 lines, removed 1 line ⏺ Bash(bun test) ⎿ 3 pass, 1 fail ● Done. refresh now rejects expired claims and logs an audit event. ✻ Worked for 42s · done 4:20 PM Diffs hidden (ctrl+q to show) · Commands folded (alt+q to show) ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts

Draws

Band
Diffs hidden (ctrl+q to show) · Commands folded (alt+q to show)
README

hide-diffs

Tired of long diffs filling your Claude Code screen? This mod swaps them for a short summary:

Changed src/api/index.ts:42 (+12 −3)

Press ctrl+q any time to show the full diffs again.

It also folds each shell command to one line, ● Bash(npm test -- --run src/api) ⎿ 24 lines. Press alt+q to show commands in full.

Without hide-diffs

An edit showing a 15-line diff

With hide-diffs

The same edit as a one-line summary

With compact mode (turn it on in settings)

Each edit on one line, with its counts after the file name

Without folded commands

Three shell commands, each with its output under it

With folded commands (alt+q switches them)

Each shell command on one line, with how many lines it printed or its error

What it does

  • Hides long diffs from edits, new files, notebooks and shell commands, and shows the file, line and lines changed instead.
  • Easy to spot. Every hidden diff starts with 🔶, so you can see at a glance where Claude changed something.
  • Keeps short diffs. Changes of 5 lines or fewer still show in full.
  • Never hides what you need. If Claude asks you to review an edit, you still see the whole diff.
  • Keeps count. A small line above the prompt shows what's changed this session: Diffs hidden (ctrl+q to show) · Commands folded (alt+q to show) · 14 files (+320 −85) this session
  • Folds shell commands. A finished Bash or PowerShell call takes one line: the command, cut to fit, then how many lines it printed (or its error in red, or what it changed in files). Press alt+q to show commands in full.
  • Compact mode. Turn it on in settings to put the line counts right on the edit's own line, ● Update(src/api/index.ts) 🔶 (+12 −3), so each change takes one line.
  • Remembers your choice. If you turn diffs back on, they stay on next time.

Install

Works on Windows, macOS and Linux.

1. Add the mod. In Claude Code, type these two commands:

/plugin marketplace add gixxy22/hide-diffs
/plugin install hide-diffs@gixxy22-plugins

2. Turn on the ctrl+q and alt+q shortcuts. Open your keybindings file:

  • Windows: C:\Users\<you>\.claude\keybindings.json
  • macOS / Linux: ~/.claude/keybindings.json

If the file doesn't exist, create it with this:

{
  "bindings": [
    { "context": "Global", "bindings": { "ctrl+q": "settings:sortByTokens", "alt+q": "settings:periodWeek" } }
  ]
}

If it already exists, just add the "ctrl+q": "settings:sortByTokens" and "alt+q": "settings:periodWeek" lines inside your Global bindings.

Why settings:sortByTokens and settings:periodWeek? A mod can only borrow a shortcut action that Claude Code isn't using at that moment. Those two are only used inside the /usage screen, so ctrl+q and alt+q always reach hide-diffs.

Prefer a different key? Use any key you like in place of ctrl+q.

3. Restart Claude Code. That's it.

Settings

Type /config and look for hide-diffs.

SettingDefaultWhat it does
Show small diffs5Diffs with this many changed lines or fewer still show in full. Set it to 0 to hide every diff.
Icon🔶Shown at the start of each hidden diff. Use any emoji or symbol, or leave it empty for none.
Compact modeoffPuts the line counts on an edit's own line, like ● Write(src/a.ts) 🔶 (+12 −0), and drops the summary line under it. Shell commands and notebooks keep their summary line.

Update

Run these in a terminal, then restart Claude Code:

claude plugin marketplace update gixxy22-plugins
claude plugin update hide-diffs@gixxy22-plugins

Uninstall

Run this in a terminal, then restart Claude Code:

claude plugin uninstall hide-diffs@gixxy22-plugins

License

MIT

Source 2 files
hooks/register.tsx 510 lines
1import { atom, read, update } from 'claude-code'
2import type { EngineInterface, Register } from 'claude-code'
3
4import type { CallChanges, CommandOutcome, CommandOutcomes, SessionTally } from '../types'
5
6type PatchHunk = { newStart?: number; lines: string[] }
7type FileChangeOutput = {
8  filePath: string
9  structuredPatch?: PatchHunk[]
10  type?: 'create' | 'update'
11  content?: string
12  gitDiff?: { additions: number; deletions: number }
13  staged?: boolean
14}
15type NotebookOutput = { notebook_path: string; cell_id?: string; old_source?: string; new_source: string }
16type BashEditDiff = { files: { filePath: string; hunks: PatchHunk[] }[]; moreFiles: number }
17type BashOutput = { bashEditDiff?: BashEditDiff }
18type ShellOutput = BashOutput & {
19  stdout?: string
20  stderr?: string
21  interrupted?: boolean
22  backgroundTaskId?: string
23  returnCodeInterpretation?: string
24}
25type Change = { added: number; removed: number }
26type TextElement = ReturnType<EngineInterface['ui']['resolve']>['Text']
27
28const DIFF_TOOLS = new Set(['Edit', 'Write', 'MultiEdit'])
29const TRACKED_TOOLS = ['Edit', 'Write', 'NotebookEdit', 'Bash'] as const
30// Tools whose runs the transcript folds into one line (`Made 3 edits +33 -5`).
31const FILE_TOOLS = new Set(['Edit', 'Write', 'NotebookEdit'])
32
33// The chord bound to this action in ~/.claude/keybindings.json (ctrl+q) presses the toggle button.
34// A plugin can only borrow an engine action while no engine handler of it is mounted: the diff
35// panel holds app:toggleDiffNoiseFilter whenever the diff has test files, so ctrl+q never reached
36// the button. settings:sortByTokens is only handled inside the /usage dialog.
37const TOGGLE_ACTION = 'settings:sortByTokens'
38const STORE_KEY = 'isHiding'
39const isHiding = atom({ plugin: 'hide-diffs', key: 'isHiding' } as const, true)
40// The second chord (alt+q) folds shell commands; settings:periodWeek is another /usage-only action.
41const COMMANDS_ACTION = 'settings:periodWeek'
42const COMMANDS_STORE_KEY = 'isFoldingCommands'
43const isFoldingCommands = atom({ plugin: 'hide-diffs', key: 'isFoldingCommands' } as const, true)
44// Each finished shell call's one-line outcome: a finished row need not carry its result.
45const outcomes = atom({ plugin: 'hide-diffs', key: 'outcomes' } as const, {} as CommandOutcomes)
46const SHELL_TOOLS = new Set(['Bash', 'PowerShell'])
47const tally = atom({ plugin: 'hide-diffs', key: 'tally' } as const, { files: [], added: 0, removed: 0 } as SessionTally)
48// The project root when the session started; paths stay relative to it after `/cd` or a worktree move.
49const startRoot = atom({ plugin: 'hide-diffs', key: 'startRoot' } as const, null as string | null)
50// Each finished call's counts, for the compact line: a live call row need not carry its result.
51const changes = atom({ plugin: 'hide-diffs', key: 'changes' } as const, {} as CallChanges)
52
53function countChangedLines(hunks: PatchHunk[] = []): Change {
54  let added = 0
55  let removed = 0
56  for (const hunk of hunks) {
57    for (const line of hunk.lines) {
58      if (line.startsWith('+')) added += 1
59      else if (line.startsWith('-')) removed += 1
60    }
61  }
62  return { added, removed }
63}
64
65// The lines a finished Edit or Write added and removed; undefined for one held for
66// review, which leaves the file unchanged and whose diff the person needs to see.
67function fileChange(output: FileChangeOutput): Change | undefined {
68  if (output.staged) return undefined
69  // A new file's patch can be empty: count the lines it was written with.
70  if (output.type === 'create') {
71    return { added: output.content ? output.content.replace(/\n$/, '').split('\n').length : 0, removed: 0 }
72  }
73  // An empty patch means the diff timed out or the file was too large; git's counts stand in.
74  if (!output.structuredPatch?.length && output.gitDiff) {
75    return { added: output.gitDiff.additions, removed: output.gitDiff.deletions }
76  }
77  return countChangedLines(output.structuredPatch)
78}
79
80// The new-file line number of the first added or removed line.
81function firstChangedLine(hunks: PatchHunk[] = []) {
82  const hunk = hunks[0]
83  if (!hunk?.newStart) return undefined
84  let line = hunk.newStart
85  for (const text of hunk.lines) {
86    if (text.startsWith('+') || text.startsWith('-')) return line
87    line += 1
88  }
89  return undefined
90}
91
92// Lines only in one side of a cell, counted as a multiset: close enough for a summary.
93function countNotebookLines(output: NotebookOutput): Change {
94  const before = output.old_source ? output.old_source.split('\n') : []
95  const after = output.new_source ? output.new_source.split('\n') : []
96  const remaining = new Map<string, number>()
97  for (const line of before) remaining.set(line, (remaining.get(line) ?? 0) + 1)
98  let added = 0
99  for (const line of after) {
100    const left = remaining.get(line) ?? 0
101    if (left > 0) remaining.set(line, left - 1)
102    else added += 1
103  }
104  let removed = 0
105  for (const left of remaining.values()) removed += left
106  return { added, removed }
107}
108
109function relativePath(filePath: string, projectRoot: string) {
110  // Separators are folded only to find the root; the path keeps its own, as the row above shows
111  // it. Folding changes no length, so the root's length cuts the original path.
112  const fold = (text: string) => text.replace(/\\/g, '/')
113  const path = fold(filePath)
114  const root = fold(projectRoot).replace(/\/$/, '') + '/'
115  // Windows paths ignore case; elsewhere a folder differing only in case is another folder.
116  const isWindows = /^[a-z]:\//i.test(root)
117  const isInside = isWindows ? path.toLowerCase().startsWith(root.toLowerCase()) : path.startsWith(root)
118  return isInside ? filePath.slice(root.length) : filePath
119}
120
121function summarize(change: Change) {
122  return `(+${change.added} −${change.removed})`
123}
124
125// `(+N −N)` with the added count green and the removed count red, in the theme's colours.
126function coloredSummary(Text: TextElement, change: Change) {
127  return (
128    <Text>
129      (<Text color="success">+{change.added}</Text> <Text color="error">−{change.removed}</Text>)
130    </Text>
131  )
132}
133
134// What a hidden diff's summary says: the file it changed and the lines it added and removed.
135// Undefined for anything drawn in full: another tool, a missing output, a review, a small diff.
136type HiddenChange = { what: string; change: Change }
137
138function describeChange(tool: string, output: unknown, root: string, isSmall: (change: Change) => boolean): HiddenChange | undefined {
139  if (tool === 'Bash') {
140    const changes = (output as BashOutput | undefined)?.bashEditDiff
141    if (!changes) return undefined
142    const fileCount = changes.files.length + changes.moreFiles
143    const change = countChangedLines(changes.files.flatMap(file => file.hunks))
144    if (fileCount === 0 || isSmall(change)) return undefined
145    return { what: `Changed ${fileCount} file${fileCount === 1 ? '' : 's'}`, change }
146  }
147
148  if (tool === 'NotebookEdit') {
149    const notebook = output as NotebookOutput | undefined
150    if (!notebook?.notebook_path) return undefined
151    const change = countNotebookLines(notebook)
152    if (isSmall(change)) return undefined
153    const cell = notebook.cell_id ? ` cell ${notebook.cell_id}` : ''
154    return { what: `Changed ${relativePath(notebook.notebook_path, root)}${cell}`, change }
155  }
156
157  if (!DIFF_TOOLS.has(tool)) return undefined
158  const file = output as FileChangeOutput | undefined
159  if (!file?.filePath) return undefined
160  const change = fileChange(file)
161  if (!change || isSmall(change)) return undefined
162  const verb = file.type === 'create' ? 'Created' : 'Changed'
163  const line = file.type === 'create' ? undefined : firstChangedLine(file.structuredPatch)
164  return { what: `${verb} ${relativePath(file.filePath, root)}${line ? `:${line}` : ''}`, change }
165}
166
167// How the engine lays out an Edit or Write row, which no API reports (as akilin/claude-plugins'
168// better-tool-rows measures it): a blank line, then `● Update(path)` as wide as the line,
169// up to GROUP_INDENT columns further in inside a group, a result line opening with ROW_GUTTER.
170const GROUP_INDENT = 6
171const ROW_GUTTER = '  ⎿  '
172// Tools whose row label is `● Name(file_path)`, so the counts can be laid just past it.
173const LABELED_TOOLS = new Set(['Edit', 'Write'])
174
175// The name the engine draws an Edit or Write row under.
176function rowName(tool: string, input: { old_string?: unknown }) {
177  return tool === 'Write' ? 'Write' : input.old_string === '' ? 'Create' : 'Update'
178}
179
180// The columns a string takes on a terminal: 2 for wide CJK characters and pictographs.
181function textWidth(text: string) {
182  let width = 0
183  for (const char of text) {
184    const c = char.codePointAt(0) ?? 0
185    if (/^[\p{Mn}\p{Me}​-‍︀-️]$/u.test(char)) continue
186    const isWide =
187      (c >= 0x1100 && c <= 0x115f) || (c >= 0x2e80 && c <= 0xa4cf) || (c >= 0xac00 && c <= 0xd7a3) ||
188      (c >= 0xf900 && c <= 0xfaff) || (c >= 0xff00 && c <= 0xff60) || (c >= 0x1f300 && c <= 0x1faff)
189    width += isWide ? 2 : 1
190  }
191  return width
192}
193
194// Relative to `root` with its own separators, as the engine draws a path it is handed.
195function shortPath(path: string, root: string) {
196  const dir = /[\\/]$/.test(root) ? root : `${root}/`
197  const head = path.slice(0, dir.length)
198  const isWindows = /^([A-Za-z]:[\\/]|\\\\)/.test(root)
199  const fold = (text: string) => text.replace(/\\/g, '/').toLowerCase()
200  return (isWindows ? fold(head) === fold(dir) : head === dir) ? path.slice(dir.length) : path
201}
202
203// `text` cut to `width` columns, ending in `…` where it was cut.
204function fitWidth(text: string, width: number) {
205  if (textWidth(text) <= width) return text
206  let fitted = ''
207  for (const char of text) {
208    if (textWidth(fitted + char) > width - 1) break
209    fitted += char
210  }
211  return `${fitted}…`
212}
213
214function lineCount(text = '') {
215  const trimmed = text.replace(/\s+$/, '')
216  return trimmed ? trimmed.split('\n').length : 0
217}
218
219function plural(count: number, word: string) {
220  return `${count} ${word}${count === 1 ? '' : 's'}`
221}
222
223// What a folded command's line says of its result: `16 lines`, `no output`, or an
224// error's first line (`Exit code 1 (+3 lines)`).
225function commandOutcome(isErrored: boolean, output: unknown): CommandOutcome {
226  if (isErrored) {
227    const lines = (typeof output === 'string' ? output : '').split('\n').map(line => line.trim()).filter(Boolean)
228    const first = fitWidth((lines[0] ?? 'Failed').replace(/^Error:\s*/, ''), 40)
229    return { text: lines.length > 1 ? `${first} (+${plural(lines.length - 1, 'line')})` : first, isError: true }
230  }
231  const result = output as ShellOutput | undefined
232  if (result?.backgroundTaskId) return { text: 'running in background', isError: false }
233  const lines = lineCount(result?.stdout) + lineCount(result?.stderr)
234  if (lines > 0) return { text: plural(lines, 'line'), isError: false }
235  return { text: result?.returnCodeInterpretation || 'no output', isError: false }
236}
237
238export const register: Register = (on, options) => {
239  // Diffs with this many changed lines or fewer are drawn in full; 0 hides every diff.
240  const smallDiffLines = Math.max(0, Number(options.smallDiffLines ?? 5))
241  const isSmall = (change: Change) => change.added + change.removed <= smallDiffLines
242  // Marks where a diff was hidden; empty for none.
243  const icon = String(options.icon ?? '🔶').trim()
244  const lead = icon ? `${icon} ` : ''
245  // Puts the counts on the call's own line and drops the summary line under it.
246  const compact = options.compact === true
247
248  // Restore the last toggle from the store, so it survives restarts, and record the starting root.
249  on('session.start', async ($, e, next) => {
250    if ((await read($, startRoot)) === null) {
251      const root = await $.session.root()
252      await update($, startRoot, () => root)
253    }
254    const saved = await $.store.get(STORE_KEY)
255    if (typeof saved === 'boolean') await update($, isHiding, () => saved)
256    const savedFolding = await $.store.get(COMMANDS_STORE_KEY)
257    if (typeof savedFolding === 'boolean') await update($, isFoldingCommands, () => savedFolding)
258    return next(e)
259  })
260
261  // Record each finished shell command's outcome for its folded line.
262  on('tool.call', { tool: ['Bash', 'PowerShell'] }, async ($, e, next) => {
263    const ran = await next(e)
264    if (ran.deny !== undefined) return ran
265    const outcome = commandOutcome(ran.isError === true, ran.isError ? ran.text : ran.result)
266    await update($, outcomes, current => ({ ...current, [e.tool_use_id]: outcome }))
267    return ran
268  })
269
270  // Add each finished change to the session tally shown on the switch.
271  on('tool.call', { tool: TRACKED_TOOLS }, async ($, e, next) => {
272    const ran = await next(e)
273    if (ran.deny !== undefined || ran.isError) return ran
274
275    const files: string[] = []
276    let change: Change = { added: 0, removed: 0 }
277    if (e.tool === 'Bash') {
278      const diff = (ran.result as BashOutput | undefined)?.bashEditDiff
279      if (!diff) return ran
280      files.push(...diff.files.map(file => file.filePath))
281      change = countChangedLines(diff.files.flatMap(file => file.hunks))
282    } else if (e.tool === 'NotebookEdit') {
283      const output = ran.result as NotebookOutput | undefined
284      if (!output?.notebook_path) return ran
285      files.push(output.notebook_path)
286      change = countNotebookLines(output)
287    } else {
288      const output = ran.result as FileChangeOutput | undefined
289      const changed = output?.filePath ? fileChange(output) : undefined
290      if (!output || !changed) return ran
291      files.push(output.filePath)
292      change = changed
293    }
294
295    await update($, tally, current => ({
296      files: [...new Set([...current.files, ...files])],
297      added: current.added + change.added,
298      removed: current.removed + change.removed,
299    }))
300    await update($, changes, current => ({ ...current, [e.tool_use_id]: change }))
301    return ran
302  })
303
304  // A small dim switch above the prompt; it must stay mounted for the chord to reach it.
305  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
306    if (e.props.hasSurvey) return next(e)
307
308    const hiding = await read($, isHiding)
309    const folding = await read($, isFoldingCommands)
310    const totals = await read($, tally)
311    const { Box, Button, Text } = $.ui.resolve(e)
312    const fileCount = totals.files.length
313    const tallyText = fileCount
314      ? ` · ${fileCount} file${fileCount === 1 ? '' : 's'} ${summarize(totals)} this session`
315      : ''
316
317    return (
318      <Box>
319        <Button
320          action={TOGGLE_ACTION}
321          dimColor
322          key="toggle-diffs"
323          label={hiding ? 'Diffs hidden (ctrl+q to show)' : 'Diffs shown (ctrl+q to hide)'}
324          onPress={async () => {
325            const nowHiding = await update($, isHiding, value => !value)
326            await $.store.set(STORE_KEY, nowHiding)
327            $.ui.toast(nowHiding ? 'Diffs hidden' : 'Diffs shown')
328          }}
329          plain
330        />
331        <Text dimColor> · </Text>
332        <Button
333          action={COMMANDS_ACTION}
334          dimColor
335          key="toggle-commands"
336          label={folding ? 'Commands folded (alt+q to show)' : 'Commands shown (alt+q to fold)'}
337          onPress={async () => {
338            const nowFolding = await update($, isFoldingCommands, value => !value)
339            await $.store.set(COMMANDS_STORE_KEY, nowFolding)
340            $.ui.toast(nowFolding ? 'Commands folded to one line' : 'Commands shown in full')
341          }}
342          plain
343        />
344        {tallyText ? <Text dimColor>{tallyText}</Text> : null}
345      </Box>
346    )
347  })
348
349  // The transcript folds runs of edits into one line; while diffs are shown, unfold
350  // those runs so ctrl+q visibly brings every diff back.
351  on('ui.render', { component: 'ToolGroup' }, async ($, e, next) => {
352    if (e.props.isExpanded || !e.props.calls.some(call => FILE_TOOLS.has(call.tool))) return next(e)
353    if (!(await read($, isHiding))) return next({ ...e, props: { ...e.props, isExpanded: true } })
354
355    // Folded: lay the icon over the line's blank indent, so the engine's text stays where it is.
356    const row = await next(e)
357    if (!icon || e.surface !== 'terminal') return row
358    const { Box, Text } = $.ui.resolve(e)
359    return (
360      <Box>
361        {row}
362        <Box position="absolute" bottom={0} left={0}>
363          <Text>{icon}</Text>
364        </Box>
365      </Box>
366    )
367  })
368
369  // Compact: the counts ride on the call's own line (`● Write(src/a.ts)  (+12 −0)`) and
370  // the result line under it is dropped, so each hidden diff takes one line.
371  on('ui.render', { component: 'ToolUse' }, async ($, e, next) => {
372    if (!compact || !LABELED_TOOLS.has(e.props.tool)) return next(e)
373    if (e.props.isRunning || e.props.isErrored || e.props.isInterrupted) return next(e)
374    const input = e.props.input as { file_path?: unknown; old_string?: unknown } | undefined
375    if (typeof input?.file_path !== 'string' || !(await read($, isHiding))) return next(e)
376
377    // The row's own result when it carries one, else what the call recorded.
378    const root = (await read($, startRoot)) ?? (await $.session.root())
379    const recorded = (await read($, changes))[e.props.tool_use_id]
380    const change =
381      describeChange(e.props.tool, e.props.output, root, isSmall)?.change ??
382      (recorded && !isSmall(recorded) ? recorded : undefined)
383    if (!change) return next(e)
384
385    // Hand the engine the path relative to the root, so the label's width is known, and
386    // leave its row whole (status dot and all): the counts are laid over its last line.
387    const path = shortPath(input.file_path, root)
388    const row = await next({ ...e, props: { ...e.props, input: { ...input, file_path: path } } })
389    const { Box, Text } = $.ui.resolve(e)
390    const counts = (
391      <Text dimColor>
392        {lead}
393        {coloredSummary(Text, change)}
394      </Text>
395    )
396    const labelWidth = textWidth(`● ${rowName(e.props.tool, input)}(${path})`)
397    const countsWidth = textWidth(`${lead}${summarize(change)}`)
398    const columns = e.viewport?.columns ?? 80
399
400    // A label too long for the line wraps; the counts go on a line of their own beneath it.
401    if (labelWidth + 2 + countsWidth > columns - GROUP_INDENT) {
402      return (
403        <Box flexDirection="column">
404          {row}
405          <Box>
406            <Text dimColor>{ROW_GUTTER}</Text>
407            {counts}
408          </Box>
409        </Box>
410      )
411    }
412    return (
413      <Box>
414        {row}
415        <Box position="absolute" bottom={0} left={labelWidth + 2}>
416          {counts}
417        </Box>
418      </Box>
419    )
420  })
421
422  // Folded commands: a finished shell call draws one line of its own, `● Bash(cmd…)  ⎿  16 lines`,
423  // and its output is dropped; a running one keeps the engine's row, its command cut to one line.
424  // A command whose file changes are on show (ctrl+q) stays whole.
425  on('ui.render', { component: 'ToolUse' }, async ($, e, next) => {
426    if (e.surface !== 'terminal' || !SHELL_TOOLS.has(e.props.tool) || e.props.isInterrupted) return next(e)
427    const input = e.props.input as { command?: unknown } | undefined
428    if (typeof input?.command !== 'string' || !(await read($, isFoldingCommands))) return next(e)
429    const output = e.props.isErrored ? undefined : (e.props.output as ShellOutput | undefined)
430    if (!(await read($, isHiding)) && output?.bashEditDiff?.files.length) return next(e)
431
432    const width = (e.viewport?.columns ?? 80) - GROUP_INDENT
433    const command = input.command.replace(/\s+/g, ' ').trim()
434    const head = `● ${e.props.tool}()`
435    const outcome =
436      e.props.output !== undefined ? commandOutcome(e.props.isErrored, e.props.output) : (await read($, outcomes))[e.props.tool_use_id]
437    if (e.props.isRunning || !outcome) {
438      const fitted = fitWidth(command, Math.max(12, width - textWidth(head)))
439      return next({ ...e, props: { ...e.props, input: { ...input, command: fitted } } })
440    }
441
442    // What the command changed in files rides on the line too; its diff is never drawn.
443    const edits = output?.bashEditDiff
444    const change = edits?.files.length ? countChangedLines(edits.files.flatMap(file => file.hunks)) : undefined
445    const files = edits ? plural(edits.files.length + edits.moreFiles, 'file') : ''
446    const tail = `  ⎿  ${outcome.text}${change ? ` · ${lead}${files} ${summarize(change)}` : ''}`
447    const fitted = fitWidth(command, Math.max(12, width - textWidth(head) - textWidth(tail)))
448    const { Box, Text } = $.ui.resolve(e)
449    return (
450      <Box>
451        <Text color={outcome.isError ? 'error' : 'success'}>● </Text>
452        <Text bold>{e.props.tool}</Text>
453        <Text>({fitted})</Text>
454        <Text dimColor>  ⎿  </Text>
455        {outcome.isError ? <Text color="error">{outcome.text}</Text> : <Text dimColor>{outcome.text}</Text>}
456        {change ? (
457          <Text dimColor>
458            {' · '}
459            {lead}
460            {files} {coloredSummary(Text, change)}
461          </Text>
462        ) : null}
463      </Box>
464    )
465  })
466
467  on('ui.render', { component: 'ToolResult' }, async ($, e, next) => {
468    // A folded command's row carries its outcome, so its result block is dropped.
469    if (e.surface === 'terminal' && SHELL_TOOLS.has(e.props.tool) && (await read($, isFoldingCommands))) {
470      const output = e.props.isErrored ? undefined : (e.props.output as ShellOutput | undefined)
471      const showsEdits = !(await read($, isHiding)) && output?.bashEditDiff?.files.length
472      if (!output?.interrupted && !showsEdits) {
473        const { Box } = $.ui.resolve(e)
474        return <Box />
475      }
476    }
477    if (e.props.isErrored || !(await read($, isHiding))) return next(e)
478
479    const root = (await read($, startRoot)) ?? (await $.session.root())
480    const hidden = describeChange(e.props.tool, e.props.output, root, isSmall)
481    if (!hidden) return next(e)
482    const { Box, Text } = $.ui.resolve(e)
483
484    // Bash: draw its own output, minus the per-file diff of what the command changed.
485    if (e.props.tool === 'Bash') {
486      const { bashEditDiff: _hidden, ...outputWithoutDiff } = e.props.output as BashOutput
487      const drawn = await next({ ...e, props: { ...e.props, output: outputWithoutDiff } })
488      return (
489        <Box flexDirection="column">
490          {drawn}
491          <Text dimColor>
492            {lead}
493            {hidden.what} {coloredSummary(Text, hidden.change)}
494          </Text>
495        </Box>
496      )
497    }
498
499    // Compact: an Edit or Write row already carries the counts.
500    if (compact && LABELED_TOOLS.has(e.props.tool)) return <Box />
501
502    return (
503      <Text dimColor>
504        {lead}
505        {hidden.what} {coloredSummary(Text, hidden.change)}
506      </Text>
507    )
508  })
509}
510
types/index.d.ts 21 lines
1export type SessionTally = { files: string[]; added: number; removed: number }
2// The lines one finished call added and removed, keyed by its tool_use_id.
3export type CallChanges = Record<string, { added: number; removed: number }>
4// What a folded shell command's line says of its result (`16 lines`, `Exit code 1`).
5export type CommandOutcome = { text: string; isError: boolean }
6// Each finished shell call's outcome, keyed by its tool_use_id.
7export type CommandOutcomes = Record<string, CommandOutcome>
8
9declare module 'claude-code' {
10  interface PluginState {
11    'hide-diffs': {
12      isHiding: boolean
13      tally: SessionTally
14      startRoot: string | null
15      changes: CallChanges
16      isFoldingCommands: boolean
17      outcomes: CommandOutcomes
18    }
19  }
20}
21