assistant2: Add testing environment variables (#27789)

To make it easier to design UIs for some of these scenarios. This PR
adds specifically two variables:
- `ZED_SIMULATE_NO_THREAD_HISTORY`
- `ZED_SIMULATE_NO_LLM_PROVIDER`

Release Notes:

- N/A

---------

Co-authored-by: Agus Zubiaga <hi@aguz.me>
This commit is contained in:
Danilo Leal 2025-03-31 15:19:42 -03:00 committed by GitHub
parent 0729d24d77
commit d50905e000
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 0 deletions

View File

@ -43,6 +43,11 @@ impl HistoryStore {
pub fn entries(&self, cx: &mut Context<Self>) -> Vec<HistoryEntry> {
let mut history_entries = Vec::new();
#[cfg(debug_assertions)]
if std::env::var("ZED_SIMULATE_NO_THREAD_HISTORY").is_ok() {
return history_entries;
}
for thread in self.thread_store.update(cx, |this, _cx| this.threads()) {
history_entries.push(HistoryEntry::Thread(thread));
}

View File

@ -203,6 +203,11 @@ impl LanguageModelRegistry {
}
pub fn active_provider(&self) -> Option<Arc<dyn LanguageModelProvider>> {
#[cfg(debug_assertions)]
if std::env::var("ZED_SIMULATE_NO_LLM_PROVIDER").is_ok() {
return None;
}
Some(self.active_model.as_ref()?.provider.clone())
}