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 / partition-of.ts
28 lines · 897 BRaw
1import Classify from '../classify'
2import type Git from '../git'
3import type { Partition } from './partition'
4
5/**
6 * A fetch's rows split the way ReplDiffSidebar splits them: pre-session
7 * rows apart, tests and generated files counted and hidden unless shown.
8 *
9 * No read-deny bucket: the pane feeds nothing to the model on its own.
10 *
11 * @param files the fetched rows
12 * @param noise `shown` keeps tests and generated files in the list
13 * @returns the groups
14 */
15export function partitionOf(
16 files: readonly Git.FileStat[],
17 noise: 'shown' | 'hidden',
18): Partition {
19 const preSession = files.filter(file => file.isPreSession)
20 const session = files.filter(file => !file.isPreSession)
21 const quiet = session.filter(file => !Classify.isNoiseFile(file.path))
22
23 return {
24 shown: noise === 'shown' ? session : quiet,
25 preSession,
26 noiseCount: session.length - quiet.length,
27 }
28}