Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: alphabetize provider model pickers and preset filters
Adam Eivy023dcc3c2a9b
diff --git a/client/src/components/ProviderModelSelector.jsx b/client/src/components/ProviderModelSelector.jsxindex 392552ddc0..6bf6bcb8a1 100644--- a/client/src/components/ProviderModelSelector.jsx+++ b/client/src/components/ProviderModelSelector.jsx@@ -121,6 +121,7 @@ import {isProviderModelHardwareCompatible,providerModelList,selectableProviders,+ sortProviderModels,localToolUseHint,withModelCapabilityOptionLabel,} from '../utils/providers.js';@@ -279,10 +280,10 @@ export default function ProviderModelSelector({|| !isProviderModelHardwareCompatible(selectedProvider, selectedModel)|| (modelAllowed && !modelAllowed(selectedModel, selectedProvider)));- const modelOptions = preserveSelectedModel+ const modelOptions = sortProviderModels(preserveSelectedModel&& !compatibleModels.some((model) => modelOption(model)?.value === selectedModel)? [selectedModel, ...compatibleModels]- : compatibleModels;+ : compatibleModels);// A model select with no `onModelChange` is a dead control: its `onChange`// reaches nobody. Provider-only callers keep their own model field (a table// cell, a free-text pin), and a composite's catalog models would otherwisediff --git a/client/src/components/ProviderModelSelector.test.jsx b/client/src/components/ProviderModelSelector.test.jsxindex bf14268111..1d9bc5e6e7 100644--- a/client/src/components/ProviderModelSelector.test.jsx+++ b/client/src/components/ProviderModelSelector.test.jsx@@ -36,6 +36,18 @@ function renderSelector(props = {}) {}describe('ProviderModelSelector', () => {+ it('alphabetizes string and named model options without changing the selected model or catalog', () => {+ const models = Object.freeze(['Zulu', { id: 'z-id', name: 'alpha' }, 'Beta']);+ const onModelChange = vi.fn();+ renderSelector({ availableModels: models, selectedModel: 'Beta', emptyModelOption: 'Default model', onModelChange });+ const select = screen.getByRole('combobox', { name: 'Model' });+ expect([...select.options].map(option => option.textContent)).toEqual(['Default model', 'alpha', 'Beta', 'Zulu']);+ expect(select.value).toBe('Beta');+ expect(onModelChange).not.toHaveBeenCalled();+ fireEvent.change(select, { target: { value: 'z-id' } });+ expect(onModelChange).toHaveBeenCalledWith('z-id');+ });+it('shows inherited provider, model and effort without writing overrides on mount', () => {const onProviderChange = vi.fn();const onModelChange = vi.fn();@@ -124,7 +136,7 @@ describe('ProviderModelSelector', () => {availableModels: codexModels,});const modelSelect = screen.getAllByRole('combobox')[1];- expect([...modelSelect.querySelectorAll('option')].map((option) => option.value)).toEqual(codexModels);+ expect([...modelSelect.querySelectorAll('option')].map((option) => option.value)).toEqual([...codexModels].sort((a, b) => a.localeCompare(b, 'en', { sensitivity: 'base' })));expect(modelSelect.value).toBe('gpt-6.1-sol');});@@ -160,9 +172,9 @@ describe('ProviderModelSelector', () => {});const modelSelect = screen.getAllByRole('combobox')[1];const opts = [...modelSelect.querySelectorAll('option')];- expect(opts.map((o) => o.value)).toEqual(['mid', 'bare']);+ expect(opts.map((o) => o.value)).toEqual(['bare', 'mid']);// `{ id }` with no name falls back to the id as the label.- expect(opts.map((o) => o.textContent)).toEqual(['Pretty Name', 'bare']);+ expect(opts.map((o) => o.textContent)).toEqual(['bare', 'Pretty Name']);});it('skips nullish model entries instead of crashing (sparse/empty provider list)', () => {@@ -271,7 +283,7 @@ it('keeps a saved TUI pin visible with a reason under a CLI/API-only caller poliselectionPolicy: { model: (model) => model !== 'tool-model' },});const modelSelect = screen.getAllByRole('combobox')[1];- expect([...modelSelect.options].map((option) => option.value)).toEqual(['tool-model', 'safe-model']);+ expect([...modelSelect.options].map((option) => option.value)).toEqual(['safe-model', 'tool-model']);expect(modelSelect.querySelector('option[value="tool-model"]').disabled).toBe(true);expect(modelSelect.querySelector('option[value="tool-model"]').textContent).toMatch(/not permitted/i);});@@ -288,7 +300,7 @@ it('keeps a saved TUI pin visible with a reason under a CLI/API-only caller poli});const [providerSelect, modelSelect] = screen.getAllByRole('combobox');expect(presetOptions(providerSelect).map((option) => option.value)).toEqual(['p1', 'p3']);- expect([...modelSelect.querySelectorAll('option')].map((option) => option.value)).toEqual(['too-large', 'small']);+ expect([...modelSelect.querySelectorAll('option')].map((option) => option.value)).toEqual(['small', 'too-large']);expect(modelSelect.querySelector('option[value="too-large"]').disabled).toBe(true);});@@ -319,7 +331,7 @@ it('keeps a saved TUI pin visible with a reason under a CLI/API-only caller polihighlightToolUse: true,});await waitFor(() =>- expect(modelLabels()).toEqual(['qwen3.6:35b · 🔧 tool use', 'gemma3:4b · ⚠ no known tool use']));+ expect(modelLabels()).toEqual(['gemma3:4b · ⚠ no known tool use', 'qwen3.6:35b · 🔧 tool use']));});it('warns when the selected LOCAL model cannot call tools', async () => {@@ -380,7 +392,7 @@ it('keeps a saved TUI pin visible with a reason under a CLI/API-only caller poliselectedModel: 'gemma3:4b',availableModels: ['qwen3.6:35b', 'gemma3:4b'],});- expect(modelLabels()).toEqual(['qwen3.6:35b', 'gemma3:4b']);+ expect(modelLabels()).toEqual(['gemma3:4b', 'qwen3.6:35b']);expect(screen.queryByText(/recognized tool-calling model/i)).not.toBeInTheDocument();// An unannotated picker must not pay for the capability scan either.expect(getToolUseModels).not.toHaveBeenCalled();@@ -400,7 +412,7 @@ it('keeps a saved TUI pin visible with a reason under a CLI/API-only caller polihighlightToolUse: true,});await waitFor(() =>- expect(modelLabels()).toEqual(['phi4-mini:latest · 🔧 tool use', 'gemma3:4b · ⚠ no known tool use']));+ expect(modelLabels()).toEqual(['gemma3:4b · ⚠ no known tool use', 'phi4-mini:latest · 🔧 tool use']));expect(screen.queryByText(/recognized tool-calling model/i)).not.toBeInTheDocument();});@@ -435,7 +447,7 @@ it('keeps a saved TUI pin visible with a reason under a CLI/API-only caller poli// A failed scan still settles, so the annotation appears — regex-only is// the best answer available, not a reason to go silent forever.await waitFor(() =>- expect(modelLabels()).toEqual(['qwen3.6:35b · 🔧 tool use', 'gemma3:4b · ⚠ no known tool use']));+ expect(modelLabels()).toEqual(['gemma3:4b · ⚠ no known tool use', 'qwen3.6:35b · 🔧 tool use']));expect(screen.getByText(/recognized tool-calling model/i)).toBeInTheDocument();});});diff --git a/client/src/components/providers/ProviderComposePopover.jsx b/client/src/components/providers/ProviderComposePopover.jsxindex 38b9379da3..30cecd20a8 100644--- a/client/src/components/providers/ProviderComposePopover.jsx+++ b/client/src/components/providers/ProviderComposePopover.jsx@@ -37,6 +37,7 @@*/import { useEffect, useId, useMemo, useState } from 'react';import Modal from '../ui/Modal.jsx';+import { sortProviderModels } from '../../utils/providerModels.js';import { FormField } from '../ui/FormField.jsx';import EffortSelect from '../cos/EffortSelect.jsx';import useProviderCatalog from '../../hooks/useProviderCatalog.js';@@ -104,7 +105,7 @@ export default function ProviderComposePopover({return compatible ? initialService : '';};const selectedService = services.find((service) => service.slug === serviceSlug) || null;- const models = catalog.modelsFor(serviceSlug);+ const models = sortProviderModels(catalog.modelsFor(serviceSlug));const effortLevels = catalog.effortLevelsFor(harnessId, model || null);const bootstraps = catalog.bootstraps || [];const bootstrapEligible = (method === 'cli' || method === 'tui') && bootstraps.length > 0;diff --git a/client/src/components/providers/ProviderComposePopover.test.jsx b/client/src/components/providers/ProviderComposePopover.test.jsxindex 8505df5ac2..2908380306 100644--- a/client/src/components/providers/ProviderComposePopover.test.jsx+++ b/client/src/components/providers/ProviderComposePopover.test.jsx@@ -39,6 +39,15 @@ async function composePiTui() {}describe('ProviderComposePopover', () => {+ it('alphabetizes custom-combination model options by displayed name', async () => {+ const models = Object.freeze(['Zulu', { id: 'z-id', name: 'alpha' }, 'Beta']);+ mocked.useProviderCatalog.mockReturnValue({ ...CATALOG, modelsFor: () => models });+ render(<ProviderComposePopover open onClose={vi.fn()} onCompose={vi.fn()} />);+ await composePiTui();+ expect([...screen.getByLabelText('Model').options].map(option => option.textContent))+ .toEqual(['Default model', 'alpha', 'Beta', 'Zulu']);+ });+it('renders nothing while closed', () => {const { container } = render(<ProviderComposePopover open={false} onClose={vi.fn()} onCompose={vi.fn()} />);expect(container.textContent).toBe('');diff --git a/client/src/components/providers/ProviderForm.jsx b/client/src/components/providers/ProviderForm.jsxindex e59d8987b0..4920f519c1 100644--- a/client/src/components/providers/ProviderForm.jsx+++ b/client/src/components/providers/ProviderForm.jsx@@ -4,7 +4,7 @@ import { Link } from 'react-router';import { AlertTriangle, Braces, Cpu, Link2, Plug, SlidersHorizontal } from 'lucide-react';import toast from '../ui/Toast';import * as api from '../../services/api';-import { filterHardwareCompatibleProviderModels, filterGenerationModels, isEmbeddingModel, isProviderHardwareCompatible, isProviderModelHardwareCompatible, mergeModelLists, configuredDefaultIn, localBackendForProvider, mergeObservedContextWindows, withRuntimeContextWindow, modelOptionLabel, isProcessProvider, isLocalEndpoint, effectiveModelContextWindow, isRunnerAllowedCommand, effortLevelsForProvider, isOllamaBackedProvider, gatewayForProvider, isClaudeCommandProvider, generationControlsFor, isCodexProvider } from '../../utils/providers';+import { sortProviderModels, filterHardwareCompatibleProviderModels, filterGenerationModels, isEmbeddingModel, isProviderHardwareCompatible, isProviderModelHardwareCompatible, mergeModelLists, configuredDefaultIn, localBackendForProvider, mergeObservedContextWindows, withRuntimeContextWindow, modelOptionLabel, isProcessProvider, isLocalEndpoint, effectiveModelContextWindow, isRunnerAllowedCommand, effortLevelsForProvider, isOllamaBackedProvider, gatewayForProvider, isClaudeCommandProvider, generationControlsFor, isCodexProvider } from '../../utils/providers';import Banner from '../ui/Banner';import {formatDurationMs,@@ -253,13 +253,14 @@ export default function ProviderForm({ provider, daemonReadiness = null, onClose// meaning differs: no Default Model is "None", while an empty tier INHERITS// the Default Model (resolveProviderModelTier) — so a preset only sets the// tiers it wants on a different model (#8149).+ const sortedTierModels = sortProviderModels([...new Set([...configuredModels, ...availableModels])]);const modelSelectOptions = (emptyLabel = 'None') => (<><option value="">{emptyLabel}</option>{configuredDefault && (<option value={configuredDefault}>Use the CLI's configured default</option>)}- {[...new Set([...configuredModels, ...availableModels])].map(model => (+ {sortedTierModels.map(model => (<option key={model} value={model} disabled={!availableModels.includes(model)}>{modelOptionLabel(model, localModels.ctxById, capabilityProvider)}{!availableModels.includes(model) ? ' (unavailable on this machine)' : ''}@@ -288,10 +289,10 @@ export default function ProviderForm({ provider, daemonReadiness = null, onCloseconst fallbackModelOptions = filterGenerationModels(mergeModelLists(selectedFallbackProvider?.models, liveModelsFor(selectedFallbackProvider)),);- const compatibleFallbackModelOptions = filterHardwareCompatibleProviderModels(+ const compatibleFallbackModelOptions = sortProviderModels(filterHardwareCompatibleProviderModels(fallbackModelOptions,fallbackCapabilityProvider,- );+ ));const fallbackModelIsUnavailable = Boolean(formData.fallbackModel&& !isEmbeddingModel(formData.fallbackModel)diff --git a/client/src/components/providers/ProviderForm.test.jsx b/client/src/components/providers/ProviderForm.test.jsxindex 690c72256a..d9cba9752c 100644--- a/client/src/components/providers/ProviderForm.test.jsx+++ b/client/src/components/providers/ProviderForm.test.jsx@@ -310,6 +310,25 @@ describe('ProviderForm model access', () => {modelAccessHiddenCount: 1,};+ it('alphabetizes preset model selects and access rows while preserving saved catalog order', async () => {+ const catalog = Object.freeze(['Zulu', 'alpha', 'Beta']);+ renderForm({ provider: {+ ...scopedProvider, models: catalog, modelCatalog: catalog, defaultModel: 'Beta',+ modelAccess: { mode: 'allow', patterns: ['*'] },+ } });+ switchTab('Models');+ const select = screen.getByLabelText('Default Model');+ expect([...select.options].map(option => option.value)).toEqual(['', 'alpha', 'Beta', 'Zulu']);+ expect(select.value).toBe('Beta');+ expect(screen.getAllByRole('button').filter(button => button.hasAttribute('aria-pressed'))+ .map(button => button.textContent)).toEqual(['alpha', 'Beta', 'Zulu']);+ fireEvent.click(screen.getByRole('button', { name: /Update Provider|Save/i }));+ await waitFor(() => expect(api.updateProvider).toHaveBeenCalled());+ expect(api.updateProvider.mock.calls[0][1].models).toEqual(['Zulu', 'alpha', 'Beta']);+ expect(api.updateProvider.mock.calls[0][1].defaultModel).toBe('Beta');+ expect(api.updateProvider.mock.calls[0][1].modelAccess.patterns).toEqual(['*']);+ });+it('saves the full advertised catalog, not the scoped view', async () => {renderForm({ provider: scopedProvider });switchTab('Models');diff --git a/client/src/components/providers/ProviderModelAccess.jsx b/client/src/components/providers/ProviderModelAccess.jsxindex 3b2323ccd1..5d055c93c2 100644--- a/client/src/components/providers/ProviderModelAccess.jsx+++ b/client/src/components/providers/ProviderModelAccess.jsx@@ -2,6 +2,7 @@ import { useMemo, useState } from 'react';import { Check, Square, CheckSquare } from 'lucide-react';import { FormField } from '../ui/FormField';import { formatCount } from '../../utils/formatters';+import { sortProviderModels } from '../../utils/providerModels.js';import {MODEL_ACCESS_MODES,MODEL_ACCESS_MODE_LABELS,@@ -34,6 +35,7 @@ import {*/export default function ProviderModelAccess({ catalog, value, onChange, configuredModels }) {const [patternDraft, setPatternDraft] = useState(null);+ const sortedCatalog = useMemo(() => sortProviderModels(catalog), [catalog]);const policy = value || NO_MODEL_ACCESS;const patterns = policy.patterns || NO_MODEL_ACCESS.patterns;@@ -126,7 +128,7 @@ export default function ProviderModelAccess({ catalog, value, onChange, configur>Clear</button></div><div className="max-h-64 overflow-y-auto border border-port-border rounded-lg divide-y divide-port-border">- {catalog.map(model => (+ {sortedCatalog.map(model => (<buttonkey={model}type="button"diff --git a/client/src/utils/README.md b/client/src/utils/README.mdindex 3a60f80e96..f5cce14128 100644--- a/client/src/utils/README.md+++ b/client/src/utils/README.md@@ -60,7 +60,7 @@ is where each shared table is re-exported from its `server/lib` leaf.| `providerRef` | `parseProviderRef(id)` / `isCompositeProviderId(id)` / `isPresetProviderId(id)` / `formatCompositeId(parts)` / `PRESET_ID_RE` / `COMPOSITE_ID_RE` — the shared preset-vs-composite grammar (#7566): distinguishes a preset id from a `<harness>.<method>@<service-slug>[+<bootstrap-slug>]` composite so `useProviderCatalog`'s `resolveRef` and `ProviderComposePopover` recognize the same strings the server does. Re-exported from the pure leaf `server/lib/providerRef.js`, never copied. || `providerHarnesses` | `harnessLabel(harnessId)` — the display name for an agent program PortOS drives (Claude Code, OpenCode, Codex, …), used wherever a harness is named (the preset-first pickers, the composition catalog hook), where `null` means Direct API and an unknown id renders verbatim rather than disappearing. Read through `harnessById` from the pure leaf `server/lib/providerHarnesses.js`, so a harness added to the registry is named here without a second edit. Also `providerHarnessId(provider)` (a derived preset's own `harnessId`, else the server's `harnessForProvider` classification) and `groupProvidersByHarness(providers)` — the `{ harnessId, label, providers }` buckets in registry order (Direct API after the agent harnesses, an `Other` bucket last) that the preset-first `ProviderModelSelector` renders as `<optgroup>`s (#7566) and the AI Providers page renders as its preset sections (#7567). `presetEditPath(presetId)` — the preset editor URL (`/ai/presets/:id`), falling back to the kept `/ai/edit/:id` alias for the one id (`new`) the static create route shadows. || `providerEndpoints` | WHERE a provider's endpoint points. `isLocalEndpoint` (loopback), `isPrivateNetworkEndpoint` (RFC1918 / tailnet address, or a `.local` / `.ts.net` / single-label host — somewhere an unauthenticated OpenAI-compatible server is a normal setup rather than a missing API key), `isLocalInstanceProvider` (talks to a daemon on THIS machine; mirror of `server/lib/localProviderRuntime.js#isLocalInstanceEndpoint` — gate anything that explains a provider by inspecting the host PortOS runs on), `isFleetProvider` / `isFleetHostConfigured` (another machine inside the private network), and `localBackendForProvider` (`'ollama'` / `'lmstudio'` / `null` by id, endpoint or name — it matches by NAME, so pair it with `isLocalInstanceProvider` before claiming this machine's install state). |-| `providerModels` | Which MODEL and EFFORT a run resolves to, and what a picker may list. The configured-default sentinels (`CODEX_CONFIGURED_DEFAULT` …, `isConfiguredDefaultModel`, `configuredDefaultIn` — so a picker can render an option matching a sentinel-valued tier instead of a blank select) and `filterSelectableModels`; the per-CLI effort ladders, `effortLevelsForProvider`, `resolveCliEffort` (what a stored effort actually runs as, so the picker can name a clamped level), `effortSurvivingModel` and `seedModelEffort`; the Antigravity base-model ↔ effort-suffix split (`splitAntigravityModel`, `antigravityBaseModels`, `antigravityModelEffortLevels`, `withStaleAntigravityPin`); the account-aware option list (`providerModelList`, `resolveProviderModelOptions`, `effortAwareModelOptions`, `MODEL_SOURCE` — the one place a Codex-subscription account catalog enters a picker); `effectiveModelFor`; `mergeModelLists` / `mergeProviderUpdate`; and `generationControlsFor` (which temperature / top-p / thinking controls a provider forwards at all). The sentinels, effort ladders and the Antigravity split are re-exported from the pure leaf `server/lib/providerModels.js`; `effortLevelsForProvider` / `resolveCliEffort` delegate to the server's and add the ladder a sanitized provider inventory publishes, clamped through the server's `clampEffortToLadder`. The generation-control tables still mirror `server/lib/opencodeConfig.js`. |+| `providerModels` | Which MODEL and EFFORT a run resolves to, and what a picker may list. `sortProviderModels` alphabetizes display options by name/id without mutating the catalog. The configured-default sentinels (`CODEX_CONFIGURED_DEFAULT` …, `isConfiguredDefaultModel`, `configuredDefaultIn` — so a picker can render an option matching a sentinel-valued tier instead of a blank select) and `filterSelectableModels`; the per-CLI effort ladders, `effortLevelsForProvider`, `resolveCliEffort` (what a stored effort actually runs as, so the picker can name a clamped level), `effortSurvivingModel` and `seedModelEffort`; the Antigravity base-model ↔ effort-suffix split (`splitAntigravityModel`, `antigravityBaseModels`, `antigravityModelEffortLevels`, `withStaleAntigravityPin`); the account-aware option list (`providerModelList`, `resolveProviderModelOptions`, `effortAwareModelOptions`, `MODEL_SOURCE` — the one place a Codex-subscription account catalog enters a picker); `effectiveModelFor`; `mergeModelLists` / `mergeProviderUpdate`; and `generationControlsFor` (which temperature / top-p / thinking controls a provider forwards at all). The sentinels, effort ladders and the Antigravity split are re-exported from the pure leaf `server/lib/providerModels.js`; `effortLevelsForProvider` / `resolveCliEffort` delegate to the server's and add the ladder a sanitized provider inventory publishes, clamped through the server's `clampEffortToLadder`. The generation-control tables still mirror `server/lib/opencodeConfig.js`. || `providerSelection` | Which providers and models a picker may OFFER on this install: `isProviderHardwareCompatible` / `isProviderModelHardwareCompatible` / `filterHardwareCompatibleProviderModels` (server-annotated, fail-open), `selectableProviders` (the single rule `ProviderModelSelector` renders from), `filterRunnableProviders` (agent jobs need a CLI/TUI harness), `supportsToolFreeOneShot` / `toolFreeOneShotSelectionPolicy` (API or server-verified tool-free CLI authoring; excludes TUI and unverified composite routes), the fail-closed tool-free local policy (`TOOL_FREE_LOCAL_PROVIDER_IDS`, `TOOL_FREE_LOCAL_TEXT_CAPABILITIES`, `isToolFreeLocalProvider`, `isToolFreeLocalModel`, `toolFreeLocalSelectionPolicy`) used by security-sensitive pickers, and the pr-reviewer postures (`PUBLIC_REVIEW_NO_TOOL_POSTURE` / `PUBLIC_REVIEW_ACTIONS_POSTURE`, `supportsPublicReviewPosture`, `enforcesPublicReviewPosture`, `publicReviewSelectionPolicy` — mirror of `server/lib/agentExecutionProfiles.js`: a pipeline stage names a POSTURE, the server publishes each provider's `publicReviewPostures` and `publicReviewEnforcedPostures` on `GET /api/providers`, and the picker offers exactly the providers this install can run the stage on, so no vendor is named on either side). Also the caller EXECUTION-MODE picker rule (`callerModeList`, `providerModeSelectionPolicy` — whose `modes` also bound the selector's compose flow) and `COMPOSE_OPTION_VALUE`, the "Custom combination…" action sentinel outside both provider-id grammars (#7566), over `server/lib/callerModePolicy.js` — the server enforces the policy on the pin, on `activeProvider` inheritance and on every fallback candidate; this only lets a picker SHOW the rule, keeping an ineligible saved value visible-but-disabled instead of hidden or silently replaced — read off `CALLER_MODE_POLICIES` in that pure leaf, so it cannot drift). || `localModelHeuristics` | What an untyped LOCAL model can do, judged from its id: `isEmbeddingModel` / `isVisionModel` / `isToolUseModel` (re-exported from the pure leaf `server/lib/localModelHeuristics.js` — one regex per family; a model card's explicit capability metadata outranks the id regex), `isVisionCapableCliProvider`, `filterGenerationModels` (sentinels and embedding-only models dropped), `visionLocalModelFilter` and `localToolUseHint` / `withToolUseOptionLabel` (unioned with the server's authoritative per-provider capability maps from `useVisionModelIds` / `useToolUseModelIds`; tool-use is an annotation plus warning, never a filter), and `modelCapabilityInfo` (capability badges for a selected model without over-sharing a local runtime's answer with another provider). || `providerContextWindows` | How large a context window a provider/model gets for planning and where the number came from: the vendor constants and the `KNOWN_MODEL_CONTEXT_WINDOWS` ladder (`knownModelContextWindow`, `knownProviderContextWindow`), `catalogModelContextWindow` (the window the provider's own `/models` catalog reported), `resolveModelContextWindow` → `{ tokens, source }` with `CONTEXT_WINDOW_SOURCE` (`override` / `reported` / `assumed` — the state a card has to label rather than print as fact), `effectiveModelContextWindow`, and `modelOptionLabel` ("id (32K ctx)"). The constants and the known-model / known-provider / catalog rungs are re-exported from the pure leaf `server/lib/providerContextWindows.js`, the same rungs the server's `effectiveContextWindow` budgets with — including `mergeObservedContextWindows`, which folds a local daemon's live window (off the readiness payload) onto the catalog rung so the card shows what the dispatch gate enforces, and holds every resolved window down to an Ollama daemon's launch `num_ctx` through `clampToRuntimeContextWindow` (applied internally, from `server/lib/aiToolkit/internal/ollamaBacked.js` — the same module the server's budgeter and pre-dispatch gate use), so the meter can't promise a budget a run would be refused for (#7466). `withRuntimeContextWindow(provider, ceiling)` stamps that ceiling's second rung — the ambient `OLLAMA_CONTEXT_LENGTH` the server launched the daemon with, which the browser cannot read and so takes off the readiness payload as `runtimeContextWindow` (#7472). |diff --git a/client/src/utils/providerModels.js b/client/src/utils/providerModels.jsindex 9e182350b8..daaaf83489 100644--- a/client/src/utils/providerModels.js+++ b/client/src/utils/providerModels.js@@ -56,6 +56,17 @@ export {antigravityModelEffortLevels,} from '../../../server/lib/providerModels.js';+/**+ * Alphabetize model options by their displayed name (or id), without changing+ * the provider's catalog or the caller's array. Accepts strings and { id, name }+ * entries, matching the shared picker and custom-combination model options.+ * CLIENT-ONLY — presentation order must not change default-model resolution.+ */+export const sortProviderModels = (models) => [...models].sort((a, b) => {+ const label = (model) => typeof model === 'string' ? model : model?.name || model?.id || '';+ return label(a).localeCompare(label(b), 'en', { sensitivity: 'base' });+});+/*** The configured-default sentinel carried in a provider's model list, or null.*