470
471
storeFileEdit(edit: IFileEditRecord & IFileEditContent): Promise<void> {
472
>
return this._track(() => this._fileEditSequencer.queue(edit.filePath, async () => {
sessionDatabase.ts
473
>
const db = await this._ensureDb();
474
>
// Ensure the turn exists — lazily insert since the turn record
475
>
// may not have been created by an explicit createTurn() call.
476
>
await dbRun(db, 'INSERT OR IGNORE INTO turns (id) VALUES (?)', [edit.turnId]);
477
>
await dbRun(
478
>
db,
479
>
`INSERT OR REPLACE INTO file_edits
480
>
(turn_id, tool_call_id, file_path, edit_type, original_path, before_content, after_content, added_lines, removed_lines)
481
>
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,
482
>
[
483
>
edit.turnId,
484
>
edit.toolCallId,
485
>
edit.filePath,
486
>
edit.kind,
487
>
edit.originalPath ?? null,
488
>
edit.beforeContent ? Buffer.from(edit.beforeContent) : null,
489
>
edit.afterContent ? Buffer.from(edit.afterContent) : null,
490
>
edit.addedLines ?? null,
491
>
edit.removedLines ?? null,
492
>
],
493
>
);
494
>
}));
495
>
}
496
497
async getFileEdits(toolCallIds: string[]): Promise<IFileEditRecord[]> {