Commit f28fa1ba7b4f

Vincent Demeester <vincent@sbr.pm>
2026-02-05 23:19:05
fix(ai-storage): always update same session file on subsequent saves
Previously, if the AI generated a different description on subsequent /save-session calls, it would create a new file instead of updating. Now, once a session file is created, all subsequent saves update that same file regardless of the description.
1 parent 81c5020
Changed files (1)
dots
pi
agent
extensions
ai-storage
dots/pi/agent/extensions/ai-storage/index.ts
@@ -147,21 +147,31 @@ export default function (pi: ExtensionAPI) {
 				const { yearMonth, date, time } = getDateInfo();
 				const sessionDir = join(SESSIONS_DIR, yearMonth);
 
-				// Sanitize filename
-				const slug = description
-					.toLowerCase()
-					.replace(/[^a-z0-9]+/g, "-")
-					.replace(/^-+|-+$/g, "")
-					.substring(0, 60);
-
-				const filename = `${date}-${slug}.md`;
-				const filepath = join(sessionDir, filename);
-
 				// Create directory
 				await mkdir(sessionDir, { recursive: true });
 
+				// If we already saved this session, always update the same file
+				// (ignore new description from AI)
+				let filepath: string;
+				let filename: string;
+				
+				if (currentSessionFile) {
+					filepath = currentSessionFile;
+					filename = filepath.split("/").pop() || "";
+				} else {
+					// Sanitize filename for new session
+					const slug = description
+						.toLowerCase()
+						.replace(/[^a-z0-9]+/g, "-")
+						.replace(/^-+|-+$/g, "")
+						.substring(0, 60);
+
+					filename = `${date}-${slug}.md`;
+					filepath = join(sessionDir, filename);
+				}
+
 				// Check if we're updating the current session or creating a new one
-				const isUpdate = currentSessionFile === filepath;
+				const isUpdate = currentSessionFile !== null;
 
 				if (isUpdate) {
 					// Read existing content