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

Function replayMessage

packages/opencode/src/cli/cmd/run/session-replay.ts:153–231  ·  view source on GitHub ↗
(
  data: SessionData,
  message: SessionMessages[number],
  thinking: boolean,
  config: ReplayConfig,
)

Source from the content-addressed store, hash-verified

151}
152
153function replayMessage(
154 data: SessionData,
155 message: SessionMessages[number],
156 thinking: boolean,
157 config: ReplayConfig,
158): ReplayMessage {
159 if (message.info.role === "user") {
160 const prompt = messagePrompt(message)
161 if (!prompt.text.trim()) {
162 return {
163 commits: [],
164 }
165 }
166
167 return {
168 commits: [
169 {
170 kind: "user",
171 text: prompt.text,
172 phase: "start",
173 source: "system",
174 messageID: message.info.id,
175 },
176 ],
177 }
178 }
179
180 const commits: StreamCommit[] = []
181 let patch: FooterPatch | undefined
182
183 const info = apply(
184 data,
185 {
186 id: `bootstrap:message:${message.info.id}`,
187 type: "message.updated",
188 properties: {
189 sessionID: message.info.sessionID,
190 info: message.info,
191 },
192 },
193 message.info.sessionID,
194 thinking,
195 config.limits,
196 )
197 commits.push(...info.commits)
198 patch = mergePatch(patch, info.footer?.patch)
199
200 for (const part of message.parts) {
201 const next = apply(
202 data,
203 {
204 id: `bootstrap:part:${part.id}`,
205 type: "message.part.updated",
206 properties: {
207 sessionID: part.sessionID,
208 part,
209 time: 0,
210 },

Callers 1

replaySessionFunction · 0.85

Calls 5

messagePromptFunction · 0.90
messageTurnSummaryCommitFunction · 0.90
mergePatchFunction · 0.85
pushMethod · 0.80
applyFunction · 0.70

Tested by

no test coverage detected