Skip to content

Commit e1ae7cb

Browse files
authored
Guard reset_chips reload in focus and repo-path updates (warpdotdev#12360)
1 parent 01778ef commit e1ae7cb

3 files changed

Lines changed: 12 additions & 10 deletions

File tree

app/src/ai/blocklist/agent_view/agent_input_footer/chips.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ impl AgentInputFooter {
2525
.map(|v| v.to_string())
2626
.unwrap_or_default()
2727
|| chip.chip_kind() != chip_result.kind()
28-
// For parity with PromptDisplay: compare the first on-click value only.
29-
|| chip.first_on_click_value() != chip_result.on_click_values().first()
28+
|| chip.on_click_values() != chip_result.on_click_values()
3029
})
3130
})
3231
}

app/src/context_chips/display.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,7 @@ impl PromptDisplay {
177177
.map(|v| v.to_string())
178178
.unwrap_or_default()
179179
|| chip.chip_kind() != &chip_result.kind
180-
// I'm only comparing the first on-click values for efficiency, but we may need to change this in the future.
181-
|| chip.first_on_click_value() != chip_result.on_click_values.first()
180+
|| chip.on_click_values() != chip_result.on_click_values.as_slice()
182181
})
183182
})
184183
}
@@ -290,7 +289,9 @@ impl PromptDisplay {
290289
pub fn on_pane_focus_changed(&mut self, focused: bool, ctx: &mut ViewContext<Self>) {
291290
self.pane_is_focused = focused;
292291
let new_chips = self.collect_chips(ctx);
293-
self.reset_chips(&new_chips, ctx);
292+
if self.check_if_chip_values_have_changed(&new_chips, ctx) {
293+
self.reset_chips(&new_chips, ctx);
294+
}
294295
ctx.notify();
295296
}
296297

@@ -355,7 +356,9 @@ impl PromptDisplay {
355356
pub fn update_repo_path(&mut self, repo_path: Option<PathBuf>, ctx: &mut ViewContext<Self>) {
356357
self.current_repo_path = repo_path;
357358
let new_chips = self.collect_chips(ctx);
358-
self.reset_chips(&new_chips, ctx);
359+
if self.check_if_chip_values_have_changed(&new_chips, ctx) {
360+
self.reset_chips(&new_chips, ctx);
361+
}
359362
ctx.notify();
360363
}
361364
}

app/src/context_chips/display_chip.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ pub struct DisplayChip {
289289
chip_kind: ContextChipKind,
290290
display_chip_kind: DisplayChipKind,
291291
next_chip_kind: Option<ContextChipKind>,
292-
first_on_click_value: Option<String>,
292+
on_click_values: Vec<String>,
293293
quota_reset_popup: ViewHandle<FeaturePopup>,
294294
session_context: Option<SessionContext>,
295295
menu_positioning_provider: Arc<dyn MenuPositioningProvider>,
@@ -887,7 +887,7 @@ impl DisplayChip {
887887
chip_kind: chip_result.kind,
888888
display_chip_kind,
889889
next_chip_kind,
890-
first_on_click_value: chip_result.on_click_values.first().cloned(),
890+
on_click_values: chip_result.on_click_values,
891891
quota_reset_popup,
892892
session_context: config.session_context,
893893
menu_positioning_provider: config.menu_positioning_provider,
@@ -927,8 +927,8 @@ impl DisplayChip {
927927
&self.display_chip_kind
928928
}
929929

930-
pub fn first_on_click_value(&self) -> Option<&String> {
931-
self.first_on_click_value.as_ref()
930+
pub(crate) fn on_click_values(&self) -> &[String] {
931+
&self.on_click_values
932932
}
933933

934934
pub fn close_git_branch_menu(&mut self, ctx: &mut ViewContext<Self>) {

0 commit comments

Comments
 (0)