MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / cycle_model_variant

Method cycle_model_variant

crates/opencode-tui/src/app/app.rs:2828–2863  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

2826 }
2827
2828 fn cycle_model_variant(&mut self) {
2829 let Some(model_ref) = self.context.current_model.read().clone() else {
2830 return;
2831 };
2832 let (model_key, explicit_variant) =
2833 parse_model_ref_selection(&model_ref, &self.available_models, &self.model_variants);
2834 let Some(variants) = self.model_variants.get(&model_key).cloned() else {
2835 self.model_variant_selection.remove(&model_key);
2836 self.context.set_model_variant(None);
2837 return;
2838 };
2839 if variants.is_empty() {
2840 self.model_variant_selection.insert(model_key, None);
2841 self.context.set_model_variant(None);
2842 return;
2843 }
2844
2845 let current = self
2846 .model_variant_selection
2847 .get(&model_key)
2848 .cloned()
2849 .flatten()
2850 .or(explicit_variant);
2851 let next = match current {
2852 None => Some(variants[0].clone()),
2853 Some(current_value) => {
2854 let index = variants.iter().position(|item| item == &current_value);
2855 match index {
2856 Some(idx) if idx + 1 < variants.len() => Some(variants[idx + 1].clone()),
2857 _ => None,
2858 }
2859 }
2860 };
2861 self.model_variant_selection.insert(model_key, next.clone());
2862 self.context.set_model_variant(next);
2863 }
2864
2865 fn current_model_label(&self) -> String {
2866 let Some(model) = self.context.current_model.read().clone() else {

Callers 2

handle_eventMethod · 0.80

Calls 7

readMethod · 0.80
set_model_variantMethod · 0.80
is_emptyMethod · 0.80
cloneMethod · 0.45
getMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected