Skip to content

Commit 3a27de8

Browse files
LughConor Nash
authored andcommitted
Restore input-window tint as an opt-in activity-phase hook
Commit e40d3ac applied the tint by calling --update-input-activity-indicator directly from --set-activity-phase. The rebase onto upstream kept upstream s hook-based --set-activity-phase (pi-coding-agent-activity-phase-functions) and dropped that call, so the tint silently stopped working. Rather than re-patch core, provide a public opt-in handler matching the documented hook convention. pi-coding-agent-tint-input-window takes the (CHAT INPUT OLD NEW REASON) signature and is enabled with: (add-hook (quote pi-coding-agent-activity-phase-functions) (function pi-coding-agent-tint-input-window)) --update-input-activity-indicator now takes the input buffer explicitly so it composes with the hook (and is safe when the buffer is nil/dead during teardown). --set-activity-phase is left exactly as upstream wrote it. Also pin package-user-dir to a project-local .cache/elpa in the Makefile so test and dependency installs never pollute the developer s real ~/.emacs.d/elpa (which here is managed by straight.el). Overridable via make PACKAGE_USER_DIR=...
1 parent b9d8c59 commit 3a27de8

2 files changed

Lines changed: 34 additions & 14 deletions

File tree

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# pi-coding-agent Makefile
22

33
EMACS ?= emacs
4+
# Keep package state project-local so test/dep installs never pollute the
5+
# developer's real ~/.emacs.d/elpa (which may be managed by straight.el etc.).
6+
# Override with `make test PACKAGE_USER_DIR=...` if needed.
7+
PACKAGE_USER_DIR ?= $(abspath .cache/elpa)
48
BATCH = $(EMACS) --batch -Q -L . \
9+
--eval "(setq package-user-dir \"$(PACKAGE_USER_DIR)\")" \
510
--eval "(add-to-list 'treesit-extra-load-path (expand-file-name \"~/.emacs.d/tree-sitter\"))"
611
# Keep this checkout first in load-path even after package-initialize.
712
LOCAL_LOAD_PATH = --eval "(setq load-path (cons (expand-file-name \".\") load-path))"

pi-coding-agent-ui.el

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -481,22 +481,37 @@ Blends the default background toward cornflower blue."
481481
(pi-coding-agent--blend-color bg tint amount))))
482482
(error nil)))
483483

484-
(defun pi-coding-agent--update-input-activity-indicator (phase)
485-
"Update the input buffer background tint for PHASE.
484+
(defun pi-coding-agent--update-input-activity-indicator (input-buf phase)
485+
"Update INPUT-BUF background tint for PHASE.
486486
When PHASE is idle the background reverts to normal. Uses
487487
`face-remap-set-base' so the tint covers the entire window
488-
including empty regions, not just text."
489-
(when-let* ((input-buf pi-coding-agent--input-buffer))
490-
(when (buffer-live-p input-buf)
491-
(with-current-buffer input-buf
492-
(if (equal phase "idle")
493-
(when pi-coding-agent--input-activity-tinted
494-
(face-remap-reset-base 'default)
495-
(setq pi-coding-agent--input-activity-tinted nil))
496-
(when-let* ((bg (pi-coding-agent--input-activity-bg)))
497-
(face-remap-set-base 'default :background bg
498-
:foreground (face-foreground 'default nil t))
499-
(setq pi-coding-agent--input-activity-tinted t)))))))
488+
including empty regions, not just text. Does nothing when INPUT-BUF
489+
is nil or dead, so it is safe to call during session teardown."
490+
(when (buffer-live-p input-buf)
491+
(with-current-buffer input-buf
492+
(if (equal phase "idle")
493+
(when pi-coding-agent--input-activity-tinted
494+
(face-remap-reset-base 'default)
495+
(setq pi-coding-agent--input-activity-tinted nil))
496+
(when-let* ((bg (pi-coding-agent--input-activity-bg)))
497+
(face-remap-set-base 'default :background bg
498+
:foreground (face-foreground 'default nil t))
499+
(setq pi-coding-agent--input-activity-tinted t))))))
500+
501+
;;;###autoload
502+
(defun pi-coding-agent-tint-input-window
503+
(_chat-buffer input-buffer _old-phase new-phase _reason)
504+
"Tint INPUT-BUFFER while the session is active in NEW-PHASE.
505+
Opt-in handler for `pi-coding-agent-activity-phase-functions'. Tints the
506+
input window background whenever NEW-PHASE is anything other than \"idle\"
507+
and removes the tint when it returns to \"idle\".
508+
509+
The remaining arguments are accepted to match the abnormal-hook calling
510+
convention and are ignored. Enable with:
511+
512+
(add-hook \='pi-coding-agent-activity-phase-functions
513+
#\='pi-coding-agent-tint-input-window)"
514+
(pi-coding-agent--update-input-activity-indicator input-buffer new-phase))
500515

501516
;;;; Language Detection
502517

0 commit comments

Comments
 (0)