* Create the session file, write cached startup metadata, and flush * buffered entries. Called on the first user/assistant message.
()
| 1056 | * buffered entries. Called on the first user/assistant message. |
| 1057 | */ |
| 1058 | private async materializeSessionFile(): Promise<void> { |
| 1059 | // Guard here too — reAppendSessionMetadata writes via appendEntryToFile |
| 1060 | // (not appendEntry) so it would bypass the per-entry persistence check |
| 1061 | // and create a metadata-only file despite --no-session-persistence. |
| 1062 | if (this.shouldSkipPersistence()) return |
| 1063 | this.ensureCurrentSessionFile() |
| 1064 | // mode/agentSetting are cache-only pre-materialization; write them now. |
| 1065 | this.reAppendSessionMetadata() |
| 1066 | if (this.pendingEntries.length > 0) { |
| 1067 | const buffered = this.pendingEntries |
| 1068 | this.pendingEntries = [] |
| 1069 | for (const entry of buffered) { |
| 1070 | await this.appendEntry(entry) |
| 1071 | } |
| 1072 | } |
| 1073 | } |
| 1074 | |
| 1075 | async insertMessageChain( |
| 1076 | messages: Transcript, |
no test coverage detected