()
| 358 | * sessions (CCR) where local files don't persist between sessions. |
| 359 | */ |
| 360 | export async function persistFileSnapshotIfRemote(): Promise<void> { |
| 361 | if (getEnvironmentKind() === null) { |
| 362 | return |
| 363 | } |
| 364 | try { |
| 365 | const snapshotFiles: SystemFileSnapshotMessage['snapshotFiles'] = [] |
| 366 | |
| 367 | // Snapshot plan file |
| 368 | const plan = getPlan() |
| 369 | if (plan) { |
| 370 | snapshotFiles.push({ |
| 371 | key: 'plan', |
| 372 | path: getPlanFilePath(), |
| 373 | content: plan, |
| 374 | }) |
| 375 | } |
| 376 | |
| 377 | if (snapshotFiles.length === 0) { |
| 378 | return |
| 379 | } |
| 380 | |
| 381 | const message: SystemFileSnapshotMessage = { |
| 382 | type: 'system', |
| 383 | subtype: 'file_snapshot', |
| 384 | content: 'File snapshot', |
| 385 | level: 'info', |
| 386 | isMeta: true, |
| 387 | timestamp: new Date().toISOString(), |
| 388 | uuid: randomUUID(), |
| 389 | snapshotFiles, |
| 390 | } |
| 391 | |
| 392 | const { recordTranscript } = await import('./sessionStorage.js') |
| 393 | await recordTranscript([message]) |
| 394 | } catch (error) { |
| 395 | logError(error) |
| 396 | } |
| 397 | } |
| 398 |
no test coverage detected