spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / mods / diff / hooks / pane-state / header-totals-of.ts
32 lines · 1.1 KBRaw
1import type Git from '../git'
2import type { HeaderTotals } from './header-totals'
3import type { Partition } from './partition'
4
5/**
6 * The header's counts (ReplDiffSidebar): the fetched totals less the
7 * pre-session rows, and how many session files fell past the row cap.
8 *
9 * Files past the cap were never dated, so they always count and always
10 * show as `notShown`: an edit that sorts after fifty older ones stays seen.
11 *
12 * @param data the fetch
13 * @param partition its rows, grouped
14 * @returns the counts and how many session files are past the cap
15 */
16export function headerTotalsOf(
17 data: Git.DiffData,
18 partition: Partition,
19): HeaderTotals {
20 const { stats, files } = data
21 const before = partition.preSession
22 const filesCount = stats.filesCount - before.length
23
24 return {
25 filesCount,
26 linesAdded:
27 stats.linesAdded - before.reduce((sum, file) => sum + file.added, 0),
28 linesRemoved:
29 stats.linesRemoved - before.reduce((sum, file) => sum + file.removed, 0),
30 notShown: Math.max(0, filesCount - (files.length - before.length)),
31 }
32}