Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions assets/javascripts/discourse/components/modal/diff-modal.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,18 @@ export default class ModalDiffModal extends Component {

@bind
subscribe() {
this.messageBus.subscribe(CHANNEL, this.updateResult);
this.messageBus.subscribe(
CHANNEL,
this.updateResult,
this.currentUser
?.discourse_ai_helper_stream_composer_suggestion_last_message_bus_id
);
}

@bind
cleanup() {
// stop all callbacks so it does not end up streaming pointlessly
this.smoothStreamer.resetStreaming();
this.diffStreamer.reset();
this.#resetState();
this.messageBus.unsubscribe(CHANNEL, this.updateResult);
}

Expand Down
6 changes: 6 additions & 0 deletions lib/ai_helper/entry_point.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ def inject_into(plugin)
:discourse_ai_helper_stream_suggestion_last_message_bus_id,
include_condition: -> { SiteSetting.ai_helper_enabled && scope.authenticated? },
) { MessageBus.last_id("/discourse-ai/ai-helper/stream_suggestion/#{object.id}") }

plugin.add_to_serializer(
:current_user,
:discourse_ai_helper_stream_composer_suggestion_last_message_bus_id,
include_condition: -> { SiteSetting.ai_helper_enabled && scope.authenticated? },
) { MessageBus.last_id("/discourse-ai/ai-helper/stream_composer_suggestion") }
end
end
end
Expand Down
6 changes: 1 addition & 5 deletions spec/system/ai_helper/ai_composer_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
Group.find_by(id: Group::AUTO_GROUPS[:admins]).add(user)
assign_fake_provider_to(:ai_helper_model)
SiteSetting.ai_helper_enabled = true
Jobs.run_immediately!
sign_in(user)
end

Expand Down Expand Up @@ -80,7 +81,6 @@ def trigger_composer_helper(content)
end

it "replaces the composed message with AI generated content" do
skip("Message bus updates not appearing in tests")
trigger_composer_helper(input)
ai_helper_menu.fill_custom_prompt(custom_prompt_input)

Expand Down Expand Up @@ -109,7 +109,6 @@ def trigger_composer_helper(content)
let(:spanish_input) { "La lluvia en España se queda principalmente en el avión." }

it "replaces the composed message with AI generated content" do
skip("Message bus updates not appearing in tests")
trigger_composer_helper(spanish_input)

DiscourseAi::Completions::Llm.with_prepared_responses([input]) do
Expand All @@ -121,7 +120,6 @@ def trigger_composer_helper(content)
end

it "reverts results when Ctrl/Cmd + Z is pressed on the keyboard" do
skip("Message bus updates not appearing in tests")
trigger_composer_helper(spanish_input)

DiscourseAi::Completions::Llm.with_prepared_responses([input]) do
Expand All @@ -134,7 +132,6 @@ def trigger_composer_helper(content)
end

it "shows the changes in a modal" do
skip("Message bus updates not appearing in tests")
trigger_composer_helper(spanish_input)

DiscourseAi::Completions::Llm.with_prepared_responses([input]) do
Expand Down Expand Up @@ -168,7 +165,6 @@ def trigger_composer_helper(content)
let(:proofread_text) { "The rain in Spain, stays mainly in the Plane." }

it "replaces the composed message with AI generated content" do
skip("Message bus updates not appearing in tests")
trigger_composer_helper(input)

DiscourseAi::Completions::Llm.with_prepared_responses([proofread_text]) do
Expand Down
3 changes: 0 additions & 3 deletions spec/system/ai_helper/ai_proofreading_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

context "when triggering via keyboard shortcut" do
it "proofreads selected text" do
skip("Animation causing diff not to appear correctly in specs")
visit "/new-topic"
composer.fill_content("hello worldd !")

Expand All @@ -38,7 +37,6 @@
end

it "proofreads all text when nothing is selected" do
skip("Animation causing diff not to appear correctly in specs")
visit "/new-topic"
composer.fill_content("hello worrld")

Expand All @@ -65,7 +63,6 @@
before { SiteSetting.rich_editor = true }

it "proofreads selected text and replaces it" do
skip("Animation causing diff not to appear correctly in specs")
visit "/new-topic"
expect(composer).to be_opened
composer.toggle_rich_editor
Expand Down