Skip to content

Commit 79ad9f7

Browse files
authored
Merge pull request #404 from editor-code-assistant/add-chat-update-to-protocol
Add chat/update notification for renaming chats
2 parents bb7ac1c + 5adbc12 commit 79ad9f7

File tree

7 files changed

+64
-0
lines changed

7 files changed

+64
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
- Fix `/resume` broken for OpenAI chats: handle nil reasoning text during replay, preserve prompt-id after chat replacement, and clear UI before replaying messages. #400
66
- Add GitHub Enterprise support for Copilot authentication via `auth.url` and `auth.clientId` provider config. #402
77

8+
- Add `chat/update` notification for renaming chats. Chat titles are now persisted to the database and broadcast to all connected clients including remote web interface.
9+
810
## 0.124.2
911

1012
- Fix OpenAI Responses API tool calls not executing when streaming response returns empty output, and fix spurious retries caused by stale tool-call state with Copilot encrypted IDs. #398

docs/protocol.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,6 +1707,36 @@ _Response:_
17071707
interface ChatDeleteResponse {}
17081708
```
17091709

1710+
### Chat update (↩️)
1711+
1712+
A client request to update chat metadata like title.
1713+
Server will persist the change, broadcast to all connected clients via `chat/contentReceived` with metadata content, and return an empty response.
1714+
1715+
_Request:_
1716+
1717+
* method: `chat/update`
1718+
* params: `ChatUpdateParams` defined as follows:
1719+
1720+
```typescript
1721+
interface ChatUpdateParams {
1722+
/**
1723+
* The chat session identifier.
1724+
*/
1725+
chatId: string;
1726+
1727+
/**
1728+
* New title for the chat.
1729+
*/
1730+
title?: string;
1731+
}
1732+
```
1733+
1734+
_Response:_
1735+
1736+
```typescript
1737+
interface ChatUpdateResponse {}
1738+
```
1739+
17101740
### Chat selected agent changed (➡️)
17111741

17121742
A client notification for server telling the user selected a different agent in chat.

src/eca/features/chat.clj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,20 @@
11421142
(messenger/chat-cleared messenger {:chat-id chat-id :messages messages})
11431143
(db/update-workspaces-cache! @db* metrics)))
11441144

1145+
(defn update-chat
1146+
"Update chat metadata like title.
1147+
Broadcasts the change to all connected clients."
1148+
[{:keys [chat-id title]} db* messenger metrics]
1149+
(when (and (get-in @db* [:chats chat-id])
1150+
title)
1151+
(swap! db* assoc-in [:chats chat-id :title] title)
1152+
(messenger/chat-content-received messenger
1153+
{:chat-id chat-id
1154+
:role "system"
1155+
:content {:type :metadata :title title}})
1156+
(db/update-workspaces-cache! @db* metrics))
1157+
{})
1158+
11451159
(defn rollback-chat
11461160
"Remove messages from chat in db until content-id matches.
11471161
Then notify to clear chat and then the kept messages."

src/eca/handlers.clj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,10 @@
238238
(metrics/task metrics :eca/chat-fork
239239
(f.chat/fork-chat params db* messenger metrics)))
240240

241+
(defn chat-update [{:keys [db* messenger metrics]} params]
242+
(metrics/task metrics :eca/chat-update
243+
(f.chat/update-chat params db* messenger metrics)))
244+
241245
(defn mcp-stop-server [{:keys [db* messenger metrics config]} params]
242246
(metrics/task metrics :eca/mcp-stop-server
243247
(f.tools/stop-server! (:name params) db* messenger config metrics)))

src/eca/remote/handlers.clj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,16 @@
244244
:variant (:variant body)})
245245
(no-content))))))
246246

247+
(defn handle-update-chat [{:keys [db*] :as components} request chat-id]
248+
(if-not (chat-or-404 db* chat-id)
249+
(error-response 404 "chat_not_found" (str "Chat " chat-id " does not exist"))
250+
(let [body (parse-body request)
251+
config (config/all @db*)]
252+
(handlers/chat-update
253+
(assoc components :config config)
254+
{:chat-id chat-id :title (:title body)})
255+
(no-content))))
256+
247257
(defn handle-set-trust [{:keys [db*]} request {:keys [sse-connections*]}]
248258
(let [body (parse-body request)
249259
trust (boolean (:trust body))]

src/eca/remote/routes.clj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"model" [handlers/handle-change-model components request chat-id]
6767
"agent" [handlers/handle-change-agent components request chat-id]
6868
"variant" [handlers/handle-change-variant components request chat-id]
69+
"update" [handlers/handle-update-chat components request chat-id]
6970
nil)))
7071
6 (let [action (nth segments 4)
7172
tcid (nth segments 5)]

src/eca/server.clj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@
115115
(defmethod jsonrpc.server/receive-request "chat/fork" [_ components params]
116116
(eventually (handlers/chat-fork (with-config components) params)))
117117

118+
(defmethod jsonrpc.server/receive-request "chat/update" [_ components params]
119+
(eventually (handlers/chat-update (with-config components) params)))
120+
118121
(defmethod jsonrpc.server/receive-notification "mcp/stopServer" [_ components params]
119122
(async-notify (handlers/mcp-stop-server (with-config components) params)))
120123

0 commit comments

Comments
 (0)