* Create the session file, write cached startup metadata, and flush * buffered entries. Called on the first user/assistant message.
()
| 1020 | * buffered entries. Called on the first user/assistant message. |
| 1021 | */ |
| 1022 | private async materializeSessionFile(): Promise<void> { |
| 1023 | // Guard here too — reAppendSessionMetadata writes via appendEntryToFile |
| 1024 | // (not appendEntry) so it would bypass the per-entry persistence check |
| 1025 | // and create a metadata-only file despite --no-session-persistence. |
| 1026 | if (this.shouldSkipPersistence()) return |
| 1027 | this.ensureCurrentSessionFile() |
| 1028 | // mode/agentSetting are cache-only pre-materialization; write them now. |
| 1029 | this.reAppendSessionMetadata() |
| 1030 | if (this.pendingEntries.length > 0) { |
| 1031 | const buffered = this.pendingEntries |
| 1032 | this.pendingEntries = [] |
| 1033 | for (const entry of buffered) { |
| 1034 | await this.appendEntry(entry) |
| 1035 | } |
| 1036 | } |
| 1037 | } |
| 1038 | |
| 1039 | async insertMessageChain( |
| 1040 | messages: Transcript, |
no test coverage detected