diff --git a/core/http/react-ui/src/pages/ImportModel.jsx b/core/http/react-ui/src/pages/ImportModel.jsx index 340cb292a..9154737f2 100644 --- a/core/http/react-ui/src/pages/ImportModel.jsx +++ b/core/http/react-ui/src/pages/ImportModel.jsx @@ -106,23 +106,161 @@ parameters: model: /path/to/model.gguf ` +const DEFAULT_PREFS = { + backend: '', name: '', description: '', quantizations: '', + mmproj_quantizations: '', embeddings: false, type: '', + pipeline_type: '', scheduler_type: '', enable_parameters: '', cuda: false, +} + +// Preference keys considered "advanced" — anything the Simple-mode Options +// disclosure does NOT expose. `hasCustomPrefs` uses this list to decide +// whether switching Power -> Simple should warn the user. +const ADVANCED_PREF_KEYS = [ + 'quantizations', 'mmproj_quantizations', 'embeddings', 'type', + 'pipeline_type', 'scheduler_type', 'enable_parameters', 'cuda', +] + const hintStyle = { marginTop: '4px', fontSize: '0.75rem', color: 'var(--color-text-muted)' } +// hasCustomPrefs returns true when the user has set any preference beyond +// backend/name/description, added a custom key-value pref with a non-empty +// key, or edited the YAML away from its default. That triggers the switch +// warning so Simple mode never silently hides state. +function hasCustomPrefs(prefs, customPrefs, yamlContent) { + for (const key of ADVANCED_PREF_KEYS) { + const v = prefs[key] + if (typeof v === 'boolean' ? v : (typeof v === 'string' ? v.trim() !== '' : v != null && v !== '')) { + return true + } + } + if (Array.isArray(customPrefs) && customPrefs.some(cp => (cp.key || '').trim() !== '')) { + return true + } + if (typeof yamlContent === 'string' && yamlContent !== DEFAULT_YAML) { + return true + } + return false +} + +// PowerTabs renders the in-page Preferences/YAML tab strip. Kept inline +// (not a separate component) — the strip is tiny and lives inside the +// Power-mode card so extracting it would just add indirection. +function PowerTabs({ value, onChange }) { + return ( +
+