MCPcopy
hub / github.com/OpenCoworkAI/open-codesign / flushSession

Function flushSession

apps/desktop/src/main/session-chat.ts:136–146  ·  view source on GitHub ↗
(manager: SessionManager)

Source from the content-addressed store, hash-verified

134}
135
136function 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
148function isRecord(value: unknown): value is Record<string, unknown> {
149 return typeof value === 'object' && value !== null;

Callers 5

appendCommentEventFunction · 0.85
appendSessionChatMessageFunction · 0.85
appendSessionToolStatusFunction · 0.85
appendSessionDesignBriefFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected