branch: externals/ellama commit abb82f308e8784232f8eeba4e887bd50a5333f05 Author: Sergey Kostyaev <sskosty...@gmail.com> Commit: Sergey Kostyaev <sskosty...@gmail.com>
Ensure unique elements in session and global contexts Improve context management by ensuring that elements added to the session and global contexts are unique. This is achieved by using `cl-pushnew` with a test function `equal-including-properties` to compare elements. --- ellama.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ellama.el b/ellama.el index ae7c8ff0c8..bdbb7302e2 100644 --- a/ellama.el +++ b/ellama.el @@ -1084,8 +1084,8 @@ If EPHEMERAL non nil new session will not be associated with any file." (if-let* ((id ellama--current-session-id) (session (with-current-buffer (ellama-get-session-buffer id) ellama--current-session))) - (push element (ellama-session-context session))) - (push element ellama--global-context) + (cl-pushnew element (ellama-session-context session) :test #'equal-including-properties)) + (cl-pushnew element ellama--global-context :test #'equal-including-properties) (get-buffer-create ellama--context-buffer t) (with-current-buffer ellama--context-buffer (erase-buffer)