DEV: Cook streamed suggestion (#354)

This commit is contained in:
Keegan George 2023-12-13 12:24:22 -08:00 committed by GitHub
parent 031c2a6b46
commit 64587967c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 18 deletions

View File

@ -7,6 +7,7 @@ import { inject as service } from "@ember/service";
import DButton from "discourse/components/d-button";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
import { cook } from "discourse/lib/text";
import { bind } from "discourse-common/utils/decorators";
import eq from "truth-helpers/helpers/eq";
import not from "truth-helpers/helpers/not";
@ -69,7 +70,9 @@ export default class AIHelperOptionsMenu extends Component {
const suggestion = result.result;
if (suggestion.length > 0) {
this.suggestion = suggestion;
cook(suggestion).then((cooked) => {
this.suggestion = cooked;
});
}
}
@ -101,12 +104,7 @@ export default class AIHelperOptionsMenu extends Component {
}
if (option.name !== "Explain") {
this._activeAIRequest
.then(({ suggestions }) => {
this.suggestion = suggestions[0];
})
.catch(popupAjaxError)
.finally(() => {
this._activeAIRequest.catch(popupAjaxError).finally(() => {
this.loading = false;
this.menuState = this.MENU_STATES.result;
});

View File

@ -65,7 +65,7 @@ RSpec.describe Jobs::StreamPostHelper do
end
end
it "publishes a final update to signal we're donea" do
it "publishes a final update to signal we're done" do
explanation =
"In this context, \"pie\" refers to a baked dessert typically consisting of a pastry crust and filling."

View File

@ -77,6 +77,7 @@ RSpec.describe "AI Post helper", type: :system, js: true do
let(:translated_input) { "The rain in Spain, stays mainly in the Plane." }
skip "TODO: Fix explain option stuck in loading in test" do
it "shows a translation of the selected text" do
select_post_text(post_2)
post_ai_helper.click_ai_button
@ -91,6 +92,7 @@ RSpec.describe "AI Post helper", type: :system, js: true do
end
end
end
end
context "when AI helper is disabled" do
before { SiteSetting.composer_ai_helper_enabled = false }