Commit 6425e48b5bd3

Vincent Demeester <vincent@sbr.pm>
2026-07-03 10:31:22
feat(emacs): shorten pi-coding-agent buffer names
Override pi-coding-agent--buffer-name so session buffers use a compact *pi:input:DIR* form instead of the verbose *pi-coding-agent-input:DIR*, keeping window titles readable.
1 parent c95ec23
Changed files (1)
dots
config
emacs
dots/config/emacs/init.el
@@ -3310,6 +3310,19 @@ With \\[universal-argument] \\[universal-argument]: always prompt with completio
   ;; extensions) by default — frontend equivalent of --approve (v2.5.0).
   (pi-coding-agent-project-trust-policy 'approve)
   :config
+  ;; Shorten buffer names (and thus the Emacs frame/window title) from
+  ;; "*pi-coding-agent-input:~/src/home*" to "*pi:input:~/src/home*".
+  (declare-function pi-coding-agent--buffer-name "pi-coding-agent-ui")
+  (defun vde/pi-coding-agent-buffer-name (type dir &optional session)
+    "Shorter buffer name for pi-coding-agent TYPE in DIR with SESSION."
+    (let ((type-str (pcase type (:chat "chat") (:input "input")))
+          (abbrev-dir (abbreviate-file-name dir)))
+      (if (and session (not (string-empty-p session)))
+          (format "*pi:%s:%s<%s>*" type-str abbrev-dir session)
+        (format "*pi:%s:%s*" type-str abbrev-dir))))
+  (advice-add 'pi-coding-agent--buffer-name :override
+              #'vde/pi-coding-agent-buffer-name)
+
   ;; NOTE: thinking blocks are visible by default since v2.5.0, which also
   ;; batches history replay and avoids the O(n²) re-render that previously
   ;; forced us to hide thinking. Re-enable the advice below only if long