Commit f28fa1ba7b4f
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