Skip to content

Commit 7cb4072

Browse files
committed
perf(ai): guard update_imported_comments_disabled_state with conversation registry
1 parent e0445ff commit 7cb4072

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

app/src/ai/blocklist/block.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4739,6 +4739,10 @@ impl AIBlock {
47394739

47404740
if !cards.is_empty() {
47414741
self.has_imported_comments = true;
4742+
let conversation_id = self.client_ids.conversation_id;
4743+
BlocklistAIHistoryModel::handle(ctx).update(ctx, |model, _| {
4744+
model.mark_conversation_has_imported_comments(conversation_id);
4745+
});
47424746
}
47434747

47444748
self.imported_comments.insert(
@@ -5738,15 +5742,18 @@ impl AIBlock {
57385742
/// bulk "Open all in code review" button based on whether the current working
57395743
/// directory is still within the imported comments' repository.
57405744
fn update_imported_comments_disabled_state(&mut self, ctx: &mut ViewContext<Self>) {
5741-
let cwd_location = self.current_working_directory_location(ctx);
5742-
57435745
if self.has_imported_comments {
5746+
let cwd_location = self.current_working_directory_location(ctx);
57445747
self.update_own_imported_comments_disabled_state(cwd_location.as_ref(), ctx);
5745-
} else if self.model.is_latest_visible_exchange_in_root_task(ctx) {
5748+
} else if BlocklistAIHistoryModel::as_ref(ctx)
5749+
.conversation_has_imported_comments(&self.client_ids.conversation_id)
5750+
&& self.model.is_latest_visible_exchange_in_root_task(ctx)
5751+
{
57465752
// The "Open all" button is rendered by the latest visible exchange when the
57475753
// current thread has imported comments but this block does not own them directly.
57485754
// Update that block's button state from its CWD so the button disables when the
57495755
// user navigates outside the imported comments' repository.
5756+
let cwd_location = self.current_working_directory_location(ctx);
57505757
self.update_open_all_button_disabled_state(cwd_location.as_ref(), ctx);
57515758
} else {
57525759
return;

app/src/ai/blocklist/history_model.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ pub struct BlocklistAIHistoryModel {
273273
/// via `set_parent_for_conversation` and `restore_conversations`.
274274
children_by_parent: HashMap<AIConversationId, Vec<AIConversationId>>,
275275

276+
/// Conversations that have had at least one AIBlock receive imported review comments.
277+
conversations_with_imported_comments: HashSet<AIConversationId>,
278+
276279
/// In-flight optimistic conversation rename state keyed by conversation.
277280
in_flight_conversation_renames: HashMap<AIConversationId, InFlightConversationRename>,
278281

@@ -404,6 +407,14 @@ impl BlocklistAIHistoryModel {
404407
self.conversations_by_id.get(conversation_id)
405408
}
406409

410+
pub fn mark_conversation_has_imported_comments(&mut self, id: AIConversationId) {
411+
self.conversations_with_imported_comments.insert(id);
412+
}
413+
414+
pub fn conversation_has_imported_comments(&self, id: &AIConversationId) -> bool {
415+
self.conversations_with_imported_comments.contains(id)
416+
}
417+
407418
pub fn conversation_mut(
408419
&mut self,
409420
conversation_id: &AIConversationId,

0 commit comments

Comments
 (0)