FIX: Don't error when navigating from AI Bot topic to regular (#1366)

We were getting an error in this logic causing Ember to fail to render the non-bot-topic that we navigate to.

I believe this is because the getter of participants is re-calculating (due to this.header.topicInfo being updated) before the args to this connector changes. Adding some safe navigation here fixes the issue.
This commit is contained in:
Mark VanLandingham 2025-05-23 13:30:08 -05:00 committed by GitHub
parent adc92e1e75
commit cead887480
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 2 deletions

View File

@ -18,8 +18,8 @@ export default class AiConversationInvite extends Component {
get participants() {
const participants = [
...this.header.topicInfo.details.allowed_users,
...this.header.topicInfo.details.allowed_groups,
...(this.header.topicInfo.details?.allowed_users ?? []),
...(this.header.topicInfo.details?.allowed_groups ?? []),
];
return participants;
}

View File

@ -109,6 +109,33 @@ RSpec.describe "AI Bot - Homepage", type: :system do
before { SiteSetting.glimmer_post_stream_mode = value }
context "when glimmer_post_stream_mode=#{value}" do
context "when mobile", mobile: true do
it "allows navigating from AI conversation to regular topic, and loads new post stream" do
regular_topic = Fabricate(:topic)
regular_post = Fabricate(:post, topic: regular_topic)
post_url = Topic.relative_url(regular_topic.id, regular_topic.slug)
post_with_link =
Fabricate(
:post,
topic: pm,
user: user,
post_number: 4,
raw: "This is a second reply by the user [link](#{post_url})",
)
topic_page.visit_topic(pm)
page.find(
"article[data-post-id='#{post_with_link.id}'] .cooked a[href='#{post_url}']",
).click
try_until_success do
expect(topic_page.current_topic).to eq(regular_topic)
expect(page).to have_css("article[data-post-id='#{regular_post.id}']")
end
end
end
context "when `ai_bot_enable_dedicated_ux` is enabled" do
it "allows uploading files to a new conversation" do
ai_pm_homepage.visit