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