* Create the session file, write cached startup metadata, and flush * buffered entries. Called on the first user/assistant message.
()
| 996 | * buffered entries. Called on the first user/assistant message. |
| 997 | */ |
| 998 | private async materializeSessionFile(): Promise<void> { |
| 999 | // Guard here too — reAppendSessionMetadata writes via appendEntryToFile |
| 1000 | // (not appendEntry) so it would bypass the per-entry persistence check |
| 1001 | // and create a metadata-only file despite --no-session-persistence. |
| 1002 | if (this.shouldSkipPersistence()) return |
| 1003 | this.ensureCurrentSessionFile() |
| 1004 | // mode/agentSetting are cache-only pre-materialization; write them now. |
| 1005 | this.reAppendSessionMetadata() |
| 1006 | if (this.pendingEntries.length > 0) { |
| 1007 | const buffered = this.pendingEntries |
| 1008 | this.pendingEntries = [] |
| 1009 | for (const entry of buffered) { |
| 1010 | await this.appendEntry(entry) |
| 1011 | } |
| 1012 | } |
| 1013 | } |
| 1014 | |
| 1015 | async insertMessageChain( |
| 1016 | messages: Transcript, |
no test coverage detected