From 7c0313d9230c9e14c0ef6f2bb94a9d0addc4deae Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 14 Nov 2023 12:45:38 +0100 Subject: [PATCH] Track lastUsedAgent and use it on new chats --- src/store/Store.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/store/Store.ts b/src/store/Store.ts index d0903b0..8644f5e 100644 --- a/src/store/Store.ts +++ b/src/store/Store.ts @@ -14,7 +14,14 @@ export const Store = t state: t.optional(State, {}), playground: t.optional(Playground, {}), }) - + .views((self) => ({ + get lastChat() { + return self.chats[self.chats.length - 1] + }, + get lastUsedAgent() { + return this.lastChat?.agent + }, + })) .actions((self) => ({ addChat(chat: Instance = {} as Instance) { self.chats.push(chat) @@ -25,7 +32,7 @@ export const Store = t self.state.navigate(self.agents[self.agents.length - 1]) }, newChat() { - this.addChat({ agent: self?.agents[0] }) + this.addChat({ agent: self.lastUsedAgent }) }, newAgent() { this.addAgent()