File size: 5,676 Bytes
5e17e07 6c0127c 5e17e07 6c0127c 5e17e07 6c0127c 5e17e07 6c0127c 5e17e07 6c0127c 5e17e07 6c0127c 5e17e07 eb89325 5e17e07 6c0127c 5e17e07 6c0127c 5e17e07 eb89325 5e17e07 eb89325 5e17e07 eb89325 6c0127c eb89325 ac50275 eb89325 ac50275 eb89325 ac50275 6c0127c 5e17e07 6c0127c 5e17e07 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | import type { ModelState } from '../types';
interface ModelStatusProps {
models: ModelState[];
}
const STATUS_COLOR: Record<ModelState['status'], string> = {
pending: '#9e9e9e',
downloading: '#1976d2',
loading: '#f9a825',
ready: '#388e3c',
error: '#d32f2f',
};
const STATUS_LABEL: Record<ModelState['status'], string> = {
pending: 'Pending',
downloading: 'Downloading',
loading: 'Loading',
ready: 'Ready',
error: 'Error',
};
function ProgressBar({ progress, color }: { progress: number; color: string }) {
return (
<div style={{
height: '4px',
background: 'var(--border)',
borderRadius: '2px',
overflow: 'hidden',
marginTop: '4px',
}}>
<div style={{
height: '100%',
width: `${Math.round(progress * 100)}%`,
background: color,
borderRadius: '2px',
transition: 'width 0.3s ease',
}} />
</div>
);
}
function ModelRow({ model }: { model: ModelState }) {
const color = STATUS_COLOR[model.status];
const showProgress = model.status === 'downloading' || model.status === 'loading';
return (
<div style={{
padding: '0.5rem 0.75rem',
background: 'var(--bg-card)',
border: '1px solid var(--border)',
borderRadius: '6px',
marginBottom: '0.4rem',
}}>
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
<span style={{
fontFamily: "'SF Mono', 'Fira Code', 'Cascadia Code', monospace",
fontSize: '0.78rem',
color: 'var(--text)',
}}>
{model.name}
</span>
<span style={{
fontSize: '0.72rem',
fontFamily: 'system-ui, -apple-system, sans-serif',
fontWeight: 600,
color,
display: 'flex',
alignItems: 'center',
gap: '0.3rem',
}}>
{model.status === 'ready' && (
<span style={{ fontSize: '0.85rem' }}>{'\u2713'}</span>
)}
{model.status === 'error' && (
<span style={{ fontSize: '0.85rem' }}>{'\u2717'}</span>
)}
{STATUS_LABEL[model.status]}
{showProgress && (
<span style={{ color: 'var(--text-secondary)', fontWeight: 400 }}>
{Math.round(model.progress * 100)}%
</span>
)}
</span>
</div>
{showProgress && <ProgressBar progress={model.progress} color={color} />}
{model.status === 'error' && model.error && (
<div style={{
marginTop: '4px',
fontSize: '0.72rem',
color: '#d32f2f',
fontFamily: 'system-ui, -apple-system, sans-serif',
}}>
{model.error}
</div>
)}
</div>
);
}
export default function ModelStatus({ models }: ModelStatusProps) {
const coreModels = models.filter((model) => model.name !== 'expansion');
const expansionModel = models.find((model) => model.name === 'expansion');
const coreReady = coreModels.length > 0 && coreModels.every((model) => model.status === 'ready');
const expansionReady = expansionModel?.status === 'ready';
const expansionUnavailable = expansionModel?.status === 'error';
return (
<div style={{
padding: '1rem',
background: 'var(--bg-section)',
border: '1px solid var(--border)',
borderRadius: '8px',
marginBottom: '1.5rem',
}}>
<div style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
marginBottom: '0.6rem',
}}>
<h3 style={{
margin: 0,
fontSize: '0.85rem',
fontFamily: 'system-ui, -apple-system, sans-serif',
fontWeight: 600,
color: 'var(--text-secondary)',
textTransform: 'uppercase',
letterSpacing: '0.05em',
}}>
Models
</h3>
{coreReady && (
<span style={{
fontSize: '0.75rem',
fontFamily: 'system-ui, -apple-system, sans-serif',
color: '#388e3c',
fontWeight: 600,
}}>
Search ready
</span>
)}
</div>
{!coreReady && (
<p style={{
margin: '0 0 0.5rem',
fontSize: '0.75rem',
fontFamily: 'system-ui, -apple-system, sans-serif',
color: 'var(--text-secondary)',
lineHeight: 1.4,
}}>
First load downloads several GB of model weights. Subsequent visits use the browser cache.
</p>
)}
{coreReady && !expansionReady && !expansionUnavailable && (
<p style={{
margin: '0 0 0.5rem',
fontSize: '0.75rem',
fontFamily: 'system-ui, -apple-system, sans-serif',
color: 'var(--text-secondary)',
lineHeight: 1.4,
}}>
Embedding and reranker ready. Compact expansion model (single-file download) loading...
</p>
)}
{coreReady && expansionUnavailable && (
<p style={{
margin: '0 0 0.5rem',
fontSize: '0.75rem',
fontFamily: 'system-ui, -apple-system, sans-serif',
color: 'var(--text-secondary)',
lineHeight: 1.4,
}}>
Expansion model unavailable. Search uses the original query directly.
</p>
)}
{models.map(m => (
<ModelRow key={m.name} model={m} />
))}
{models.length === 0 && (
<div style={{
color: 'var(--text-muted)',
fontSize: '0.85rem',
fontFamily: 'system-ui, -apple-system, sans-serif',
}}>
No models configured.
</div>
)}
</div>
);
}
|