fix(admin): hide deprecated/stale models on the Models page by default #46
@@ -193,6 +193,10 @@ header.navbar{padding-top:2px!important;padding-bottom:2px!important}
|
||||
<h3 class="card-title mb-0">Model Availability</h3>
|
||||
</div>
|
||||
<div class="card-subtitle text-muted ms-2">Change the override dropdown to mark a model active, deprecated, or stale</div>
|
||||
<div class="ms-auto form-check form-switch mb-0">
|
||||
<input class="form-check-input" type="checkbox" id="show-deprecated-toggle" onchange="renderModels(_modelsCache)">
|
||||
<label class="form-check-label small text-muted" for="show-deprecated-toggle">Show deprecated / stale</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-vcenter table-hover card-table">
|
||||
@@ -302,13 +306,24 @@ function connectSSE() {
|
||||
MODEL AVAILABILITY TABLE
|
||||
═══════════════════════════════════════ */
|
||||
|
||||
let _modelsCache = [];
|
||||
|
||||
function renderModels(models) {
|
||||
_modelsCache = models || [];
|
||||
const tbody = document.getElementById('model-tbody');
|
||||
if (!models || !models.length) {
|
||||
tbody.innerHTML = '<tr><td colspan="5" class="text-muted text-center">No models</td></tr>';
|
||||
return;
|
||||
}
|
||||
const html = models.filter(m => (m.access_level === 'public') || !m.access_level).map(m => {
|
||||
const toggleEl = document.getElementById('show-deprecated-toggle');
|
||||
const showDeprecated = toggleEl ? toggleEl.checked : false;
|
||||
const visible = models.filter(m => (m.access_level === 'public') || !m.access_level)
|
||||
.filter(m => showDeprecated || (m.effective_availability !== 'deprecated' && m.effective_availability !== 'stale'));
|
||||
if (!visible.length) {
|
||||
tbody.innerHTML = '<tr><td colspan="5" class="text-muted text-center">No models match the current filter</td></tr>';
|
||||
return;
|
||||
}
|
||||
const html = visible.map(m => {
|
||||
const availClass = { active: 'var(--tblr-success)', deprecated: 'var(--tblr-danger)', stale: 'var(--tblr-warning)' }[m.effective_availability] || 'var(--tblr-secondary)';
|
||||
const selectOpts = ['active','deprecated','stale'].map(a =>
|
||||
`<option value="${a}"${m.effective_availability===a?' selected':''}>${a}</option>`
|
||||
|
||||
@@ -142,6 +142,19 @@ def test_admin_models_returns_html_with_availability_marker(admin_client):
|
||||
assert "Model Availability" in resp.text
|
||||
|
||||
|
||||
def test_admin_models_hides_deprecated_by_default_with_a_toggle_to_show_them(admin_client):
|
||||
"""The models page defaults to hiding deprecated/stale rows (e.g. after
|
||||
the OpenRouter allowlist prunes 425 down to 30) behind a toggle, rather
|
||||
than always rendering every row regardless of availability."""
|
||||
resp = admin_client.get("/admin/models")
|
||||
text = resp.text
|
||||
assert 'id="show-deprecated-toggle"' in text
|
||||
# Default unchecked: renderModels must read the toggle's checked state
|
||||
# and exclude deprecated/stale unless it's on.
|
||||
assert "effective_availability !== 'deprecated'" in text
|
||||
assert "effective_availability !== 'stale'" in text
|
||||
|
||||
|
||||
def test_admin_profiles_returns_html_with_profiles_marker(admin_client):
|
||||
"""GET /admin/profiles returns 200, text/html, and contains the Chart.js
|
||||
tag and the Profiles page marker."""
|
||||
|
||||
Reference in New Issue
Block a user