(manager: SessionManager)
| 134 | } |
| 135 | |
| 136 | function flushSession(manager: SessionManager): void { |
| 137 | const file = manager.getSessionFile(); |
| 138 | const header = manager.getHeader(); |
| 139 | if (file === undefined || header === null) { |
| 140 | throw new CodesignError('Session file unavailable', 'IPC_DB_ERROR'); |
| 141 | } |
| 142 | // pi defers writing user-only sessions; desktop chat must persist immediately. |
| 143 | mkdirSync(path.dirname(file), { recursive: true }); |
| 144 | const lines = [header, ...manager.getEntries()].map((entry) => JSON.stringify(entry)); |
| 145 | writeFileSync(file, `${lines.join('\n')}\n`, 'utf8'); |
| 146 | } |
| 147 | |
| 148 | function isRecord(value: unknown): value is Record<string, unknown> { |
| 149 | return typeof value === 'object' && value !== null; |
no outgoing calls
no test coverage detected