Save last finish_reason, display a "Resume" button

This commit is contained in:
Alex Gleason committed 2025-12-28 16:49:51 -06:00
1 parent dc0144a477
commit 44dfd25a84
10 files changed
+102 -7

No files matched your search

+35
View File
@@ -358,4 +358,39 @@ export class DotAI {
console.warn(`Failed to write .git/shakespeare/template.json file: ${error}`);
}
}
/**
* Read the last finish reason from .git/ai/FINISH_REASON file
* @returns The finish reason string, or null if file doesn't exist or is empty
*/
async readFinishReason(): Promise<string | null> {
try {
const finishReasonPath = join(this.workingDir, ".git", "ai", "FINISH_REASON");
const content = await this.fs.readFile(finishReasonPath, "utf8");
const trimmed = content.trim();
return trimmed || null;
} catch {
return null;
}
}
/**
* Write the finish reason to .git/ai/FINISH_REASON file
* @param finishReason The finish reason string, or null to clear
*/
async writeFinishReason(finishReason: string | null): Promise<void> {
const aiDir = join(this.workingDir, ".git", "ai");
const finishReasonPath = join(aiDir, "FINISH_REASON");
try {
// Ensure .git/ai directory exists
await this.fs.mkdir(aiDir, { recursive: true });
// Write the finish reason (empty string if null)
const content = finishReason ? finishReason.trim() + "\n" : "";
await this.fs.writeFile(finishReasonPath, content);
} catch (error) {
console.warn(`Failed to write .git/ai/FINISH_REASON file: ${error}`);
}
}
}