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

Commit cead887

Browse files
authored
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.
1 parent adc92e1 commit cead887

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

assets/javascripts/discourse/connectors/topic-map-participants-after/ai-conversation-invite.gjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ export default class AiConversationInvite extends Component {
1818

1919
get participants() {
2020
const participants = [
21-
...this.header.topicInfo.details.allowed_users,
22-
...this.header.topicInfo.details.allowed_groups,
21+
...(this.header.topicInfo.details?.allowed_users ?? []),
22+
...(this.header.topicInfo.details?.allowed_groups ?? []),
2323
];
2424
return participants;
2525
}

spec/system/ai_bot/homepage_spec.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,33 @@
109109
before { SiteSetting.glimmer_post_stream_mode = value }
110110

111111
context "when glimmer_post_stream_mode=#{value}" do
112+
context "when mobile", mobile: true do
113+
it "allows navigating from AI conversation to regular topic, and loads new post stream" do
114+
regular_topic = Fabricate(:topic)
115+
regular_post = Fabricate(:post, topic: regular_topic)
116+
117+
post_url = Topic.relative_url(regular_topic.id, regular_topic.slug)
118+
post_with_link =
119+
Fabricate(
120+
:post,
121+
topic: pm,
122+
user: user,
123+
post_number: 4,
124+
raw: "This is a second reply by the user [link](#{post_url})",
125+
)
126+
127+
topic_page.visit_topic(pm)
128+
page.find(
129+
"article[data-post-id='#{post_with_link.id}'] .cooked a[href='#{post_url}']",
130+
).click
131+
132+
try_until_success do
133+
expect(topic_page.current_topic).to eq(regular_topic)
134+
expect(page).to have_css("article[data-post-id='#{regular_post.id}']")
135+
end
136+
end
137+
end
138+
112139
context "when `ai_bot_enable_dedicated_ux` is enabled" do
113140
it "allows uploading files to a new conversation" do
114141
ai_pm_homepage.visit

0 commit comments

Comments
 (0)