Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit d8bace5

Browse files
committed
FIX: llm selector memory broken
llm selector for bot was no longer remembering selected item.
1 parent ede65c9 commit d8bace5

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

assets/javascripts/discourse/components/ai-persona-llm-selector.gjs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,21 +148,24 @@ export default class AiPersonaLlmSelector extends Component {
148148
this.setAllowLLMSelector();
149149

150150
if (this.hasLlmSelector) {
151-
let llm = this.keyValueStore.getItem(LLM_SELECTOR_KEY);
151+
let llmId = this.keyValueStore.getItem(LLM_SELECTOR_KEY);
152+
if (llmId) {
153+
llmId = parseInt(llmId, 10);
154+
}
152155

153156
const llmOption =
154-
this.llmOptions.find((innerLlmOption) => innerLlmOption.id === llm) ||
157+
this.llmOptions.find((innerLlmOption) => innerLlmOption.id === llmId) ||
155158
this.llmOptions[0];
156159

157160
if (llmOption) {
158-
llm = llmOption.id;
161+
llmId = llmOption.id;
159162
} else {
160-
llm = "";
163+
llmId = "";
161164
}
162165

163-
if (llm) {
166+
if (llmId) {
164167
next(() => {
165-
this.currentLlm = llm;
168+
this.currentLlm = llmId;
166169
});
167170
}
168171
}

spec/system/ai_bot/homepage_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,13 @@
254254
it "Allows choosing persona and LLM" do
255255
ai_pm_homepage.visit
256256

257-
ai_pm_homepage.persona_selector.expand
258-
ai_pm_homepage.persona_selector.select_row_by_name(persona.name)
259-
ai_pm_homepage.persona_selector.collapse
260-
261257
ai_pm_homepage.llm_selector.expand
262258
ai_pm_homepage.llm_selector.select_row_by_name(claude_2_dup.display_name)
263259
ai_pm_homepage.llm_selector.collapse
260+
261+
# confirm memory works for llm selection
262+
ai_pm_homepage.visit
263+
expect(ai_pm_homepage.llm_selector).to have_selected_name(claude_2_dup.display_name)
264264
end
265265

266266
it "renders back to forum link" do

0 commit comments

Comments
 (0)