Skip to content

Commit b3e5d2b

Browse files
committed
Make model picker search and header labels truthful
1 parent a24d936 commit b3e5d2b

3 files changed

Lines changed: 43 additions & 12 deletions

File tree

src/tui/app/tests/state_model_poke_03.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,34 @@ fn test_login_smoke_model_picker_renders_unstacked_provider_rows() {
585585
);
586586
}
587587

588+
#[test]
589+
fn test_model_picker_filter_text_includes_provider_and_method() {
590+
let entry = crate::tui::PickerEntry {
591+
name: "glm-51-nvfp4".to_string(),
592+
options: vec![crate::tui::PickerOption {
593+
provider: "Comtegra GPU Cloud".to_string(),
594+
api_method: "openai-compatible:comtegra".to_string(),
595+
available: true,
596+
detail: "https://llm.comtegra.cloud/v1".to_string(),
597+
estimated_reference_cost_micros: None,
598+
}],
599+
action: crate::tui::PickerAction::Model,
600+
selected_option: 0,
601+
is_current: false,
602+
is_default: false,
603+
recommended: false,
604+
recommendation_rank: usize::MAX,
605+
old: false,
606+
created_date: None,
607+
effort: None,
608+
};
609+
610+
let filter_text = crate::tui::PickerKind::Model.filter_text(&entry);
611+
assert!(filter_text.contains("glm-51-nvfp4"));
612+
assert!(filter_text.contains("Comtegra GPU Cloud"));
613+
assert!(filter_text.contains("openai-compatible:comtegra"));
614+
}
615+
588616
#[test]
589617
fn test_login_picker_preview_stays_open_and_updates_filter() {
590618
let mut app = create_test_app();

src/tui/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,13 @@ impl PickerKind {
704704
.unwrap_or("");
705705
format!("{} {} {} {}", entry.name, status, window, detail)
706706
}
707-
Self::Model => entry.name.clone(),
707+
Self::Model => {
708+
let route = entry.active_option();
709+
let provider = route.map(|option| option.provider.as_str()).unwrap_or("");
710+
let method = route.map(|option| option.api_method.as_str()).unwrap_or("");
711+
let detail = route.map(|option| option.detail.as_str()).unwrap_or("");
712+
format!("{} {} {} {}", entry.name, provider, method, detail)
713+
}
708714
}
709715
}
710716
}

src/tui/ui_header.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -231,15 +231,12 @@ fn header_provider_auth_tag(name: &str, auth: &AuthStatus) -> &'static str {
231231
""
232232
}
233233
}
234-
"openai" => {
235-
if auth.openai_has_oauth {
236-
"oauth"
237-
} else if auth.openai_has_api_key {
238-
"api-key"
239-
} else {
240-
""
241-
}
242-
}
234+
"openai" => match (auth.openai_has_oauth, auth.openai_has_api_key) {
235+
(true, true) => "oauth+key",
236+
(true, false) => "oauth",
237+
(false, true) => "api-key",
238+
(false, false) => "",
239+
},
243240
"copilot" => {
244241
if auth.copilot_has_api_token {
245242
"oauth"
@@ -835,15 +832,15 @@ mod tests {
835832
}
836833

837834
#[test]
838-
fn header_provider_auth_tag_prefers_openai_oauth_over_api_key() {
835+
fn header_provider_auth_tag_reports_openai_oauth_and_api_key() {
839836
let auth = AuthStatus {
840837
openai: AuthState::Available,
841838
openai_has_oauth: true,
842839
openai_has_api_key: true,
843840
..AuthStatus::default()
844841
};
845842

846-
assert_eq!(header_provider_auth_tag("openai", &auth), "oauth");
843+
assert_eq!(header_provider_auth_tag("openai", &auth), "oauth+key");
847844
}
848845

849846
#[test]

0 commit comments

Comments
 (0)