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 / drawn-files-of / drawn-files-of.ts
31 lines · 943 BRaw
1import type Git from '../git'
2import Limits from '../limits'
3import PaneState from '../pane-state'
4
5/**
6 * The files whose bodies the pane draws now, in drawing order: the listed
7 * session rows, then the pre-session rows while their section is open.
8 *
9 * Past PRE_SESSION_BODY_CAP pre-session files only their legend shows, so
10 * none of their bodies is wanted.
11 *
12 * @param model the pane's state: its fetch and its two toggles
13 * @returns the rows, none without a fetch
14 */
15export function drawnFilesOf(
16 model: Pick<
17 PaneState.PaneModel,
18 'data' | 'isNoiseShown' | 'isPreSessionShown'
19 >,
20): readonly Git.FileStat[] {
21 const partition = PaneState.partitionOf(
22 model.data?.files ?? [],
23 model.isNoiseShown ? 'shown' : 'hidden',
24 )
25
26 const isBodied =
27 model.isPreSessionShown &&
28 partition.preSession.length <= Limits.PRE_SESSION_BODY_CAP
29
30 return [...partition.shown, ...(isBodied ? partition.preSession : [])]
31}