MCPcopy Index your code
hub / github.com/simstudioai/sim / withStoppedContentBlock

Function withStoppedContentBlock

apps/sim/lib/copilot/chat/persisted-message.ts:269–306  ·  view source on GitHub ↗
(message: PersistedMessage)

Source from the content-addressed store, hash-verified

267}
268
269export function withStoppedContentBlock(message: PersistedMessage): PersistedMessage {
270 const contentBlocks = message.contentBlocks ?? []
271 const hasAssistantText = contentBlocks.some(
272 (block) =>
273 block.type === MothershipStreamV1EventType.text &&
274 block.channel !== MothershipStreamV1TextChannel.thinking &&
275 block.content?.trim()
276 )
277 if (
278 contentBlocks.some(
279 (block) =>
280 block.type === MothershipStreamV1EventType.complete &&
281 block.status === MothershipStreamV1CompletionStatus.cancelled
282 )
283 ) {
284 return message
285 }
286
287 return normalizeMessage({
288 ...message,
289 contentBlocks: [
290 ...(hasAssistantText || !message.content.trim()
291 ? []
292 : [
293 {
294 type: MothershipStreamV1EventType.text,
295 channel: MothershipStreamV1TextChannel.assistant,
296 content: message.content,
297 },
298 ]),
299 ...contentBlocks,
300 {
301 type: MothershipStreamV1EventType.complete,
302 status: MothershipStreamV1CompletionStatus.cancelled,
303 },
304 ],
305 })
306}
307
308export interface UserMessageParams {
309 id: string

Callers 2

buildOnCompleteFunction · 0.90
route.tsFile · 0.90

Calls 1

normalizeMessageFunction · 0.85

Tested by

no test coverage detected