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

Commit 4da033c

Browse files
authored
FIX: Double render error with thumbnail suggestions (#968)
This PR fixes a bug where a double render error appears in the logs when thumbnails are suggested
1 parent dabef02 commit 4da033c

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

app/controllers/discourse_ai/ai_helper/assistant_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def suggest
3535
prompt.custom_instruction = params[:custom_prompt]
3636
end
3737

38-
suggest_thumbnails(input) if prompt.id == CompletionPrompt::ILLUSTRATE_POST
38+
return suggest_thumbnails(input) if prompt.id == CompletionPrompt::ILLUSTRATE_POST
3939

4040
hijack do
4141
render json:

spec/requests/ai_helper/assistant_controller_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,20 @@
101101
end
102102
end
103103

104+
it "prevents double render when mode is ILLUSTRATE_POST" do
105+
DiscourseAi::Completions::Llm.with_prepared_responses([proofread_text]) do
106+
expect {
107+
post "/discourse-ai/ai-helper/suggest",
108+
params: {
109+
mode: CompletionPrompt::ILLUSTRATE_POST,
110+
text: text_to_proofread,
111+
force_default_locale: true,
112+
}
113+
}.not_to raise_error
114+
expect(response.status).to eq(200)
115+
end
116+
end
117+
104118
context "when performing numerous requests" do
105119
it "rate limits" do
106120
RateLimiter.enable

0 commit comments

Comments
 (0)