MCPcopy Index your code
hub / github.com/codeaashu/claude-code / reconstructContentReplacementState

Function reconstructContentReplacementState

src/utils/toolResultStorage.ts:960–988  ·  view source on GitHub ↗
(
  messages: Message[],
  records: ContentReplacementRecord[],
  inheritedReplacements?: ReadonlyMap<string, string>,
)

Source from the content-addressed store, hash-verified

958 * resumes (parent IDs aren't in the subagent's messages).
959 */
960export function reconstructContentReplacementState(
961 messages: Message[],
962 records: ContentReplacementRecord[],
963 inheritedReplacements?: ReadonlyMap<string, string>,
964): ContentReplacementState {
965 const state = createContentReplacementState()
966 const candidateIds = new Set(
967 collectCandidatesByMessage(messages)
968 .flat()
969 .map(c => c.toolUseId),
970 )
971
972 for (const id of candidateIds) {
973 state.seenIds.add(id)
974 }
975 for (const r of records) {
976 if (r.kind === 'tool-result' && candidateIds.has(r.toolUseId)) {
977 state.replacements.set(r.toolUseId, r.replacement)
978 }
979 }
980 if (inheritedReplacements) {
981 for (const [id, replacement] of inheritedReplacements) {
982 if (candidateIds.has(id) && !state.replacements.has(id)) {
983 state.replacements.set(id, replacement)
984 }
985 }
986 }
987 return state
988}
989
990/**
991 * AgentTool-resume variant: encapsulates the feature-flag gate + parent

Callers 3

REPLFunction · 0.85

Calls 5

addMethod · 0.45
hasMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected