Skip to content

Commit

Permalink
Merge pull request #445 from solliancenet/jdh-agent-selection-stickin…
Browse files Browse the repository at this point in the history
…ess-experimentation-02

Make the agent selection sticky across chat sessions (experimental-02 branch)
  • Loading branch information
codingbandit authored Jan 12, 2024
2 parents d15460d + 4d3a970 commit 1422c05
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/ui/UserPortal/stores/appStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const useAppStore = defineStore('app', {
isSidebarClosed: false as boolean,
agents: [] as Agent[],
selectedAgents: new Map(),
lastSelectedAgent: null as Agent | null,
}),

getters: {},
Expand Down Expand Up @@ -112,10 +113,21 @@ export const useAppStore = defineStore('app', {
},

getSessionAgent(session: Session) {
return this.selectedAgents.get(session.id);
var selectedAgent = this.selectedAgents.get(session.id);
if (!selectedAgent) {
if (this.lastSelectedAgent) {
// Default to the last selected agent to make the selection "sticky" across sessions.
selectedAgent = this.lastSelectedAgent;
} else {
// Default to the first agent in the list.
selectedAgent = this.agents[0];
}
}
return selectedAgent;
},

setSessionAgent(session: Session, agent: Agent) {
this.lastSelectedAgent = agent;
return this.selectedAgents.set(session.id, agent);
},

Expand Down

0 comments on commit 1422c05

Please sign in to comment.