branch: externals/ellama
commit 7bd7aa46544e316f90f545a098caafbc80f65520
Merge: 72e47ca1f5 afcbca80bb
Author: Sergey Kostyaev <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #360 from s-kostyaev/save-session-directory
Add directory tracking to sessions
---
NEWS.org | 4 ++++
ellama.el | 12 +++++++++---
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/NEWS.org b/NEWS.org
index 11b07cf24f..ee208291c6 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -1,3 +1,7 @@
+* Version 1.10.2
+- Added directory tracking to sessions, including a directory path in the extra
+ data field and setting the default directory when a session is initialized to
+ maintain working directory context.
* Version 1.10.1
- Added option to allow all tools without confirmation using new
~ellama-tools-allow-all~ variable marked as dangerous.
diff --git a/ellama.el b/ellama.el
index 89b40c86b4..d3931c7376 100644
--- a/ellama.el
+++ b/ellama.el
@@ -6,7 +6,7 @@
;; URL: http://github.com/s-kostyaev/ellama
;; Keywords: help local tools
;; Package-Requires: ((emacs "28.1") (llm "0.24.0") (plz "0.8") (transient
"0.7") (compat "29.1"))
-;; Version: 1.10.1
+;; Version: 1.10.2
;; SPDX-License-Identifier: GPL-3.0-or-later
;; Created: 8th Oct 2023
@@ -882,7 +882,7 @@ If EPHEMERAL non nil new session will not be associated
with any file."
ellama-sessions-directory
(concat id "." (ellama-get-session-file-extension)))))
(session (make-ellama-session
- :id id :provider provider :file file-name))
+ :id id :provider provider :file file-name :extra `(:dir
,dir)))
(buffer (if file-name
(progn
(make-directory ellama-sessions-directory t)
@@ -1021,7 +1021,13 @@ If EPHEMERAL non nil new session will not be associated
with any file."
:provider (ellama-session-provider session)
:file (ellama-session-file session)
:prompt (ellama-session-prompt session)
- :extra extra)))
+ :extra extra))
+ (with-current-buffer buffer
+ (when-let* ((extra)
+ ((plistp extra))
+ (dir (plist-get extra :dir))
+ ((file-exists-p dir)))
+ (setq default-directory dir))))
(setq ellama--current-session-id (ellama-session-id
ellama--current-session))
(puthash (ellama-session-id ellama--current-session)
buffer ellama--active-sessions)