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
32 lines · 1006 BRaw
1import Classify from '../classify'
2import Git from '../git'
3import type { Partition } from './partition'
4
5/**
6 * A fetch's rows split as ReplDiffSidebar splits them, in its order (by
7 * name): pre-session apart, tests and generated files 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 sorted = [...files].sort((a, b) =>
20 Git.displayPathOf(a).localeCompare(Git.displayPathOf(b)),
21 )
22
23 const preSession = sorted.filter(file => file.isPreSession)
24 const session = sorted.filter(file => !file.isPreSession)
25 const quiet = session.filter(file => !Classify.isNoiseFile(file.path))
26
27 return {
28 shown: noise === 'shown' ? session : quiet,
29 preSession,
30 noiseCount: session.length - quiet.length,
31 }
32}