diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-16 00:14:17 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-16 00:14:17 -0500 |
| commit | 2e71594ebad7d8636b39ca65a260307733ac2def (patch) | |
| tree | 47dab2a99c1c39a5e5d1e1f71c751621752916da /modules | |
| parent | 8a1ae3ba99b8f93a9af32cd7aa5ccc7d50dbbaf3 (diff) | |
| download | dotemacs-2e71594ebad7d8636b39ca65a260307733ac2def.tar.gz dotemacs-2e71594ebad7d8636b39ca65a260307733ac2def.zip | |
fix(ai-config): intern model in gptel-switch-backend (modeline hang)
cj/gptel-switch-backend set gptel-model to the raw completing-read string. gptel's modeline code calls symbolp on gptel-model and signals wrong-type-argument on a string, which surfaces as a redisplay hang (reachable from C-; a B). The sibling command cj/gptel-change-model already interns. This one didn't.
I added a pure cj/gptel--model-to-symbol helper (mirroring cj/gptel--model-to-string) and route the model through it before the setq. The existing switch-backend test asserted the buggy string value. It now asserts a symbol plus an explicit symbolp guard.
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/ai-config.el | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/modules/ai-config.el b/modules/ai-config.el index e439ab5c9..20bf6ec88 100644 --- a/modules/ai-config.el +++ b/modules/ai-config.el @@ -192,6 +192,16 @@ Ensures gptel and backends are initialized." ((symbolp m) (symbol-name m)) (t (format "%s" m)))) +(defun cj/gptel--model-to-symbol (m) + "Return model M as a symbol regardless of its type. +`gptel-model' must be a symbol: gptel's modeline code calls `symbolp' +on it and signals `wrong-type-argument' on a string, which surfaces as a +redisplay hang. Coerce any model value through this before assigning it." + (cond + ((symbolp m) m) + ((stringp m) (intern m)) + (t (intern (format "%s" m))))) + ;; Backend/model switching helpers (pure logic, extracted for testability) (defun cj/gptel--build-model-list (backends model-fn) @@ -270,7 +280,7 @@ necessary. Prompt for whether to apply the selection globally or buffer-locally. (mapcar #'cj/gptel--model-to-string models) nil t nil nil (cj/gptel--model-to-string (bound-and-true-p gptel-model))))) (setq gptel-backend backend - gptel-model model) + gptel-model (cj/gptel--model-to-symbol model)) (message "Switched to %s with model: %s" choice model)))) ;; Clear assistant buffer (moved out so it's always available) |
