MCPcopy Create free account
hub / github.com/HELPMEEADICE/doge-code / recordTranscript

Function recordTranscript

src/utils/sessionStorage.ts:1454–1495  ·  view source on GitHub ↗
(
  messages: Message[],
  teamInfo?: TeamInfo,
  startingParentUuidHint?: UUID,
  allMessages?: readonly Message[],
)

Source from the content-addressed store, hash-verified

1452// messagesToKeep → not a prefix → not tracked → CB gets parentUuid=null
1453// (correct: truncates --continue chain at compact boundary).
1454export async function recordTranscript(
1455 messages: Message[],
1456 teamInfo?: TeamInfo,
1457 startingParentUuidHint?: UUID,
1458 allMessages?: readonly Message[],
1459): Promise<UUID | null> {
1460 const cleanedMessages = cleanMessagesForLogging(messages, allMessages)
1461 const sessionId = getSessionId() as UUID
1462 const messageSet = await getSessionMessages(sessionId)
1463 const newMessages: typeof cleanedMessages = []
1464 let startingParentUuid: UUID | undefined = startingParentUuidHint
1465 let seenNewMessage = false
1466 for (const m of cleanedMessages) {
1467 if (messageSet.has(m.uuid as UUID)) {
1468 // Only track skipped messages that form a prefix. After compaction,
1469 // messagesToKeep appear AFTER new CB/summary, so this skips them.
1470 if (!seenNewMessage && isChainParticipant(m)) {
1471 startingParentUuid = m.uuid as UUID
1472 }
1473 } else {
1474 newMessages.push(m)
1475 seenNewMessage = true
1476 }
1477 }
1478 if (newMessages.length > 0) {
1479 await getProject().insertMessageChain(
1480 newMessages,
1481 false,
1482 undefined,
1483 startingParentUuid,
1484 teamInfo,
1485 )
1486 }
1487 // Return the last ACTUALLY recorded chain-participant's UUID, OR the
1488 // prefix-tracked UUID if no new chain participants were recorded. This lets
1489 // callers (useLogMessages) maintain the correct parent chain even when the
1490 // slice is all-recorded (rewind, /resume scenarios where every message is
1491 // already in messageSet). Progress is skipped — it's written to the JSONL
1492 // but nothing chains TO it (see isChainParticipant).
1493 const lastRecorded = newMessages.findLast(isChainParticipant)
1494 return (lastRecorded?.uuid as UUID | undefined) ?? startingParentUuid ?? null
1495}
1496
1497export async function recordSidechainTranscript(
1498 messages: Message[],

Callers 4

submitMessageMethod · 0.85
handleOrphanedPermissionFunction · 0.85
useLogMessagesFunction · 0.85

Calls 7

cleanMessagesForLoggingFunction · 0.85
getSessionIdFunction · 0.85
getSessionMessagesFunction · 0.85
isChainParticipantFunction · 0.85
getProjectFunction · 0.85
insertMessageChainMethod · 0.80
hasMethod · 0.45

Tested by

no test coverage detected