MCPcopy Index your code
hub / github.com/anomalyco/opencode / replay

Function replay

packages/opencode/src/cli/cmd/run/session-data.ts:582–620  ·  view source on GitHub ↗
(data: SessionData, commits: SessionCommit[], messageID: string, role: MessageRole, thinking: boolean)

Source from the content-addressed store, hash-verified

580// buffered text parts that were waiting on role confirmation. User-role
581// parts are silently dropped.
582function replay(data: SessionData, commits: SessionCommit[], messageID: string, role: MessageRole, thinking: boolean) {
583 for (const [partID, msg] of data.msg.entries()) {
584 if (msg !== messageID || data.ids.has(partID)) {
585 continue
586 }
587
588 if (role === "user" && !data.includeUserText) {
589 data.ids.add(partID)
590 drop(data, partID)
591 continue
592 }
593
594 const kind = data.part.get(partID)
595 if (!kind) {
596 continue
597 }
598
599 if (role === "user" && kind === "assistant") {
600 data.part.set(partID, "user")
601 }
602
603 if (kind === "reasoning" && !thinking) {
604 if (data.end.has(partID)) {
605 data.ids.add(partID)
606 }
607 drop(data, partID)
608 continue
609 }
610
611 flushPart(data, commits, partID)
612
613 if (!data.end.has(partID)) {
614 continue
615 }
616
617 data.ids.add(partID)
618 drop(data, partID)
619 }
620}
621
622function toolCommit(
623 part: ToolPart,

Callers 1

reduceSessionDataFunction · 0.70

Calls 5

flushPartFunction · 0.85
dropFunction · 0.70
addMethod · 0.65
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected