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 / after-fetch / after-fetch.ts
29 lines · 924 BRaw
1import Todos from '../../todos'
2import Turns from '../../turns'
3import type { PaneModel } from '../pane-model'
4import type { Fetched } from './fetched'
5
6/**
7 * The model once a refresh has settled: the outcome's data (kept as it was
8 * when the fetch was unavailable), the transcript's turns and todos.
9 *
10 * @param model the model before the refresh
11 * @param fetched what the refresh read
12 * @returns the settled model
13 */
14export function afterFetch(model: PaneModel, fetched: Fetched): PaneModel {
15 const { outcome, messages } = fetched
16 const isData = outcome.kind === 'data'
17 const isKept = outcome.kind === 'unavailable'
18 const data = isData ? outcome.data : isKept ? model.data : null
19
20 return {
21 ...model,
22 isLoading: false,
23 hasSettled: true,
24 isOutsideRepository: outcome.kind === 'no-repository',
25 data,
26 turns: Turns.turnDiffsOf(messages),
27 todos: Todos.todoProgressOf(messages),
28 }
29}