assistant2: Add testing environment variables (#27789)
Danilo Leal
and
Agus Zubiaga
created 9 months ago
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>
Change summary
crates/assistant2/src/history_store.rs | 5 +++++
crates/language_model/src/registry.rs | 5 +++++
2 files changed, 10 insertions(+)
Detailed changes
@@ -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));
}
@@ -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())
}