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

Commit 96e6357

Browse files
committed
FIX: enum selection not working for persona tools
1 parent 2f845d1 commit 96e6357

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

assets/javascripts/discourse/components/ai-persona-tool-options.gjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ export default class AiPersonaToolOptions extends Component {
1616
}
1717

1818
get toolsMetadata() {
19-
const metatada = {};
19+
const metadata = {};
2020

2121
this.args.allTools.map((t) => {
22-
metatada[t.id] = {
22+
metadata[t.id] = {
2323
name: t.name,
2424
...t?.options,
2525
};
2626
});
2727

28-
return metatada;
28+
return metadata;
2929
}
3030

3131
@action
@@ -76,7 +76,7 @@ export default class AiPersonaToolOptions extends Component {
7676
>
7777
{{#if (eq optionMeta.type "enum")}}
7878
<field.Select @includeNone={{false}} as |select|>
79-
{{#each optionsObj.values as |v|}}
79+
{{#each optionMeta.values as |v|}}
8080
<select.Option @value={{v}}>{{v}}</select.Option>
8181
{{/each}}
8282
</field.Select>

spec/system/ai_bot/persona_spec.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,31 @@
1010
sign_in(admin)
1111
end
1212

13+
it "can select and save persona tool options" do
14+
visit "/admin/plugins/discourse-ai/ai-personas"
15+
find(".ai-persona-list-editor__new-button").click
16+
17+
expect(page).to have_current_path("/admin/plugins/discourse-ai/ai-personas/new")
18+
19+
form = PageObjects::Components::FormKit.new("form")
20+
form.field("name").fill_in("Test Persona")
21+
form.field("description").fill_in("This is a test persona.")
22+
form.field("system_prompt").fill_in("You are a helpful assistant.")
23+
form.field("tools").select("Update Artifact")
24+
form.field("toolOptions.UpdateArtifact.update_algorithm").select("full")
25+
form.submit
26+
27+
expect(page).to have_current_path(%r{/admin/plugins/discourse-ai/ai-personas/\d+/edit})
28+
29+
persona = AiPersona.order("id desc").first
30+
31+
expect(persona.name).to eq("Test Persona")
32+
expect(persona.description).to eq("This is a test persona.")
33+
expect(persona.tools.count).to eq(1)
34+
expect(persona.tools.first[0]).to eq("UpdateArtifact")
35+
expect(persona.tools.first[1]["update_algorithm"]).to eq("full")
36+
end
37+
1338
it "remembers the last selected persona" do
1439
visit "/"
1540
find(".d-header .ai-bot-button").click()

0 commit comments

Comments
 (0)