Skip to content

Commit

Permalink
Track lastUsedAgent and use it on new chats
Browse files Browse the repository at this point in the history
  • Loading branch information
knoopx committed Nov 14, 2023
1 parent 86a40e7 commit 7c0313d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/store/Store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof Chat> = {} as Instance<typeof Chat>) {
self.chats.push(chat)
Expand All @@ -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()
Expand Down

0 comments on commit 7c0313d

Please sign in to comment.