Commit 363cd1454139

Vincent Demeester <vincent@sbr.pm>
2026-02-13 23:06:24
fix(org-todos): fixed content written as temp file path
pi/org-todo-append passed a temp file path to org-batch-append-content which expects a content string, causing temp file paths like /tmp/pi-org-content-xxx to be written literally into org files. Removed unnecessary temp file indirection and passed content directly. Also fixed the add action to support the content parameter by appending content after creating the TODO heading.
1 parent 70641f9
Changed files (2)
dots
config
emacs
pi
agent
extensions
org-todos
dots/config/emacs/site-lisp/pi-org-todos.el
@@ -223,19 +223,12 @@ Returns JSON string."
 CONTENT: org-mode formatted text.
 Returns JSON string."
   (let ((f (pi/org-todo--get-file file)))
-    ;; Write content to temp file for org-batch-append-content
-    (let ((temp-file (make-temp-file "pi-org-content-")))
-      (unwind-protect
-          (progn
-            (with-temp-file temp-file
-              (insert content))
-            (condition-case err
-                (if (org-batch-append-content f heading temp-file)
-                    (pi/org-todo--json-response t `((heading . ,heading) (appended . t)))
-                  (pi/org-todo--json-response nil nil (format "Heading not found: %s" heading)))
-              (error
-               (pi/org-todo--json-response nil nil (error-message-string err)))))
-        (delete-file temp-file)))))
+    (condition-case err
+        (if (org-batch-append-content f heading content)
+            (pi/org-todo--json-response t `((heading . ,heading) (appended . t)))
+          (pi/org-todo--json-response nil nil (format "Heading not found: %s" heading)))
+      (error
+       (pi/org-todo--json-response nil nil (error-message-string err))))))
 
 (defun pi/org-todo-archive-done (&optional file)
   "Archive all DONE and CANX items in FILE.
dots/pi/agent/extensions/org-todos/index.ts
@@ -478,6 +478,16 @@ export default function (pi: ExtensionAPI) {
           const prioArg = priority !== undefined ? priority : "nil";
           const tagsArg = tags && tags.length > 0 ? `'(${tags.map(t => `"${t}"`).join(" ")})` : "nil";
           elisp = `(pi/org-todo-add "${heading.replace(/"/g, '\\"')}" "${section.replace(/"/g, '\\"')}" nil ${schedArg} ${prioArg} ${tagsArg})`;
+          // If content provided, append it after creating the TODO
+          if (content) {
+            const addResult = execEmacs(elisp);
+            if (!addResult.success) {
+              return {
+                content: [{ type: "text", text: `Error: ${addResult.error}` }],
+              };
+            }
+            elisp = `(pi/org-todo-append "${heading.replace(/"/g, '\\"')}" "${content.replace(/"/g, '\\"').replace(/\n/g, '\\n')}")`;
+          }
           break;
           
         case "append":