MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / rollbackSession

Method rollbackSession

src/filesystem/transaction.ts:358–390  ·  view source on GitHub ↗

Rollback every committed transaction in a session, newest first.

(sessionId: string)

Source from the content-addressed store, hash-verified

356 }
357
358 async begin(sessionId: string, toolCallId?: string, cwd?: string): Promise<Transaction> {
359 await fs.mkdir(this.blobsDir, { recursive: true });
360 const row = this.getNextIdStmt.get() as { value: number };
361 const txnId = row.value;
362 this.incrementStmt.run();
363 return new Transaction(txnId, this, sessionId, toolCallId, cwd);
364 }
365
366 persistOps(
367 txnId: number,
368 sessionId: string,
369 ops: JournaledOp[],
370 gitSha: string | null,
371 toolCallId: string | undefined,
372 summary: string | undefined,
373 gitStatus?: string,
374 gitFailReason?: string | null,
375 ): void {
376 const tx = this.db.transaction(() => {
377 for (const op of ops) {
378 this.writeStmt.run(
379 txnId, sessionId, op.operation, op.path,
380 op.beforeHash, op.afterHash, gitSha, gitStatus ?? null, gitFailReason ?? null,
381 toolCallId ?? null, summary ?? null,
382 );
383 }
384 });
385 tx();
386 }
387
388 markRolledBack(txnId: number): void {
389 this.markRolledBackStmt.run(txnId);
390 }
391
392 async storeBlob(hash: string, content: string): Promise<void> {
393 const blobPath = path.join(this.blobsDir, hash.slice(0, 2), hash);

Callers 2

handleSlashCommandFunction · 0.80

Calls 5

loadBlobMethod · 0.95
writeFileAtomicFunction · 0.85
addMethod · 0.80
warnMethod · 0.80
runMethod · 0.65

Tested by

no test coverage detected