Skip to content

Commit 8a3c025

Browse files
committed
Safely rename default* -> select* in config/updated.
1 parent b22fcdf commit 8a3c025

File tree

4 files changed

+43
-32
lines changed

4 files changed

+43
-32
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Safely rename `default*` -> `select*` in `config/updated`.
6+
57
## 0.43.0
68

79
- Support `chat/selectedBehaviorChanged` client notification.

docs/protocol.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,22 +1058,28 @@ interface ConfigUpdatedParams {
10581058
*/
10591059
models?: ChatModel[];
10601060

1061-
/**
1062-
* The default model to use in the chat, if that is present
1063-
* clients should update chat selected model unless user changed it
1064-
*/
1065-
defaultModel?: ChatModel;
1066-
10671061
/**
10681062
* The chat behaviors the user can select.
10691063
*/
10701064
behaviors?: ChatBehavior[];
1065+
1066+
/**
1067+
* The model for client select in chat, if that is present
1068+
* clients should forcefully update chat selected model.
1069+
*
1070+
* Server returns this when starting and only when makes sense to
1071+
* force update a model, like a config change.
1072+
*/
1073+
selectModel?: ChatModel;
10711074

10721075
/**
1073-
* The default behavior to use in the chat, if that is present
1074-
* clients should update chat selected behavior unless user changed it.
1075-
*/
1076-
defaultBehavior?: ChatBehavior;
1076+
* The behavior for client select in chat, if that is present
1077+
* clients should forcefully update chat selected behavior.
1078+
*
1079+
* Server returns this when starting and only when makes sense to
1080+
* force update a behavior, like a config change.
1081+
*/
1082+
selectBehavior?: ChatBehavior;
10771083

10781084
/**
10791085
* Message to show when starting a new chat.

integration-test/integration/initialize_test.clj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@
4343
(testing "config updated"
4444
(is (match?
4545
{:chat {:models models
46-
:defaultModel "anthropic/claude-sonnet-4-20250514"
46+
:selectModel "anthropic/claude-sonnet-4-20250514"
4747
:behaviors ["agent" "plan"]
48-
:defaultBehavior "plan"
48+
:selectBehavior "plan"
4949
:welcomeMessage "Welcome to ECA!\n\nType '/' for commands\n\n"}}
5050
(eca/client-awaits-server-notification :config/updated)))))
5151

@@ -97,18 +97,18 @@
9797
:providers
9898
(merge fixture/default-providers
9999
{"my-custom" {:api "openai-chat"
100-
:url "MY_URL"
101-
:key "MY_KEY"
102-
:models {"foo1" {}
103-
"bar2" {}}}})})})))))
100+
:url "MY_URL"
101+
:key "MY_KEY"
102+
:models {"foo1" {}
103+
"bar2" {}}}})})})))))
104104
(testing "initialized notification"
105105
(eca/notify! (fixture/initialized-notification)))
106106

107107
(testing "config updated"
108108
(is (match?
109109
{:chat {:models models
110-
:defaultModel "my-custom/bar-2"
110+
:selectModel "my-custom/bar-2"
111111
:behaviors ["agent" "plan"]
112-
:defaultBehavior "agent"
112+
:selectBehavior "agent"
113113
:welcomeMessage "Welcome to ECA!\n\nType '/' for commands\n\n"}}
114114
(eca/client-awaits-server-notification :config/updated))))))

src/eca/handlers.clj

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,22 @@
4545
(when (not= (:providers-config-hash @db*) new-providers-hash)
4646
(swap! db* assoc :providers-config-hash new-providers-hash)
4747
(models/sync-models! db* config (fn [models]
48-
(let [db @db*]
49-
(config/notify-fields-changed-only!
50-
{:chat
51-
{:models (sort (keys models))
52-
:default-model (f.chat/default-model db config)
53-
:behaviors (:chat-behaviors db)
54-
:default-behavior (or (:defaultBehavior (:chat config)) ;;legacy
55-
(:defaultBehavior config))
56-
:welcome-message (or (:welcomeMessage (:chat config)) ;;legacy
57-
(:welcomeMessage config))}}
58-
messenger
59-
db*)))))))]
48+
(let [db @db*]
49+
(config/notify-fields-changed-only!
50+
{:chat
51+
{:models (sort (keys models))
52+
:behaviors (:chat-behaviors db)
53+
:select-model (f.chat/default-model db config)
54+
:select-behavior (or (:defaultBehavior (:chat config)) ;;legacy
55+
(:defaultBehavior config))
56+
:welcome-message (or (:welcomeMessage (:chat config)) ;;legacy
57+
(:welcomeMessage config))
58+
;; Deprecated, remove after changing emacs, vscode and intellij.
59+
:default-model (f.chat/default-model db config)
60+
:default-behavior (or (:defaultBehavior (:chat config)) ;;legacy
61+
(:defaultBehavior config))}}
62+
messenger
63+
db*)))))))]
6064
(swap! db* assoc-in [:config-updated-fns :sync-models] #(sync-models-and-notify! %))
6165
(sync-models-and-notify! config))
6266
(future
@@ -127,5 +131,4 @@
127131
:eca/mcp-start-server
128132
(f.tools/start-server! (:name params) db* messenger config)))
129133

130-
(defn chat-selected-behavior-changed [{:keys []} {:keys [_behavior]}]
131-
)
134+
(defn chat-selected-behavior-changed [{:keys []} {:keys [_behavior]}])

0 commit comments

Comments
 (0)