MCPcopy Create free account
hub / github.com/WJX20/claude-code / persistToRemote

Method persistToRemote

src/utils/sessionStorage.ts:1303–1344  ·  view source on GitHub ↗
(sessionId: UUID, entry: TranscriptMessage)

Source from the content-addressed store, hash-verified

1301 }
1302
1303 private async persistToRemote(sessionId: UUID, entry: TranscriptMessage) {
1304 if (isShuttingDown()) {
1305 return
1306 }
1307
1308 // CCR v2 path: write as internal worker event
1309 if (this.internalEventWriter) {
1310 try {
1311 await this.internalEventWriter(
1312 'transcript',
1313 entry as unknown as Record<string, unknown>,
1314 {
1315 ...(isCompactBoundaryMessage(entry) && { isCompaction: true }),
1316 ...(entry.agentId && { agentId: entry.agentId }),
1317 },
1318 )
1319 } catch {
1320 logEvent('tengu_session_persistence_failed', {})
1321 logForDebugging('Failed to write transcript as internal event')
1322 }
1323 return
1324 }
1325
1326 // v1 Session Ingress path
1327 if (
1328 !isEnvTruthy(process.env.ENABLE_SESSION_PERSISTENCE) ||
1329 !this.remoteIngressUrl
1330 ) {
1331 return
1332 }
1333
1334 const success = await sessionIngress.appendSessionLog(
1335 sessionId,
1336 entry,
1337 this.remoteIngressUrl,
1338 )
1339
1340 if (!success) {
1341 logEvent('tengu_session_persistence_failed', {})
1342 gracefulShutdownSync(1, 'other')
1343 }
1344 }
1345
1346 setRemoteIngressUrl(url: string): void {
1347 this.remoteIngressUrl = url

Callers 1

appendEntryMethod · 0.95

Calls 6

isShuttingDownFunction · 0.85
isCompactBoundaryMessageFunction · 0.85
logEventFunction · 0.85
logForDebuggingFunction · 0.85
isEnvTruthyFunction · 0.85
gracefulShutdownSyncFunction · 0.85

Tested by

no test coverage detected