Skip to content

Commit bbbb50b

Browse files
committed
feat: persist selected agent
Resolves #37
1 parent 4c13dc3 commit bbbb50b

File tree

4 files changed

+44
-60178
lines changed

4 files changed

+44
-60178
lines changed

_build/js/src/chatHistory.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ export const chatHistory = {
224224
};
225225
}
226226

227-
_namespace[key].onAddMessage = onAddMessage;
227+
if (onAddMessage) {
228+
_namespace[key].onAddMessage = onAddMessage;
229+
}
228230

229231
return {
230232
addUserMessage: (content, hidden = false) => {

_build/js/src/globalState.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import type { Config } from './index';
1+
import type { AvailableAgent, Config } from './index';
22
import type { Modal } from './ui/localChat/types';
33

44
export const globalState = {
55
modalOpen: false,
66
config: {} as Config,
77
modal: {} as Modal,
8+
selectedAgent: {} as Record<string, AvailableAgent | undefined>,
89
};

_build/js/src/ui/localChat/modalInput.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,10 @@ export const buildModalInput = (config: LocalChatConfig) => {
176176

177177
const agentSelectComponent = buildSelect(
178178
globalState.config.availableAgents,
179-
globalState.modal.selectedAgent?.id,
179+
globalState.selectedAgent[config.key]?.id,
180180
(selectedAgent) => {
181181
globalState.modal.selectedAgent = selectedAgent ?? undefined;
182+
globalState.selectedAgent[config.key] = selectedAgent ?? undefined;
182183
},
183184
{
184185
idProperty: 'id',

0 commit comments

Comments
 (0)