Self-hosted AI workspace.
Python
fix(cookbook): sort by Fit when the Fit header is clicked (#842) (#860)
Tatlatat5e042bfc4fb4
diff --git a/static/js/cookbook-hwfit.js b/static/js/cookbook-hwfit.jsindex e6445f865..425355395 100644--- a/static/js/cookbook-hwfit.js+++ b/static/js/cookbook-hwfit.js@@ -519,6 +519,11 @@ export async function _hwfitFetch(fresh = false) {const asc = sortSel?.dataset.reverse === '1'; // reversed → ascending (lowest first)const field = { score: 'score', vram: 'required_gb', speed: 'speed_tps', params: 'params_b', context: 'context' }[sortKey] || 'score';data.models.sort((a, b) => {+ if (sortKey === 'fit') {+ const rank = { perfect: 4, good: 3, marginal: 2, too_tight: 1, no_fit: 0 };+ const av = rank[a.fit_level] || 0, bv = rank[b.fit_level] || 0;+ return asc ? av - bv : bv - av;+ }const av = Number(a[field]) || 0, bv = Number(b[field]) || 0;return asc ? av - bv : bv - av;});@@ -717,7 +722,7 @@ function _wireManualHardwareControls(el) {export const _fitColors = { perfect: 'var(--green, #50fa7b)', good: 'var(--yellow, #f1fa8c)', marginal: 'var(--orange, #ffb86c)', too_tight: 'var(--red, #ff5555)' };export const _hwfitColumns = [- { key: 'score', label: 'Fit', cls: 'hwfit-fit' },+ { key: 'fit', label: 'Fit', cls: 'hwfit-fit' },{ key: null, label: 'Model', cls: 'hwfit-name' },{ key: 'params',label: 'Param', cls: 'hwfit-c-params' },{ key: null, label: 'Quant', cls: 'hwfit-c-quant' },diff --git a/static/js/cookbook.js b/static/js/cookbook.jsindex 98f5dc769..8eb914a7b 100644--- a/static/js/cookbook.js+++ b/static/js/cookbook.js@@ -1434,7 +1434,7 @@ function _renderRecipes() {html += '<button type="button" class="hwfit-gpu-btn" id="hwfit-rescan" title="Re-scan hardware" style="flex-shrink:0;position:relative;top:-3px;left:-1px;">↻ RESCAN</button>';html += '<button type="button" class="hwfit-gpu-btn hwfit-hw-manual-btn" id="hwfit-hw-manual-btn" title="Set hardware manually" style="flex-shrink:0;position:relative;top:-3px;left:-1px;">EDIT</button>';html += '<select class="cookbook-field-input hwfit-sort" id="hwfit-sort" style="display:none">';- html += '<option value="score">Score</option><option value="vram">VRAM</option>';+ html += '<option value="fit">Fit</option><option value="score">Score</option><option value="vram">VRAM</option>';html += '<option value="speed">Speed</option><option value="params">Params</option>';html += '<option value="context">Context</option></select>';html += '</div>';