Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions apps/web/src/components/upstream-editor/config-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { DeleteRegular } from '@fluentui/react-icons';
import { useId, useMemo } from 'react';
import { Controller, useFieldArray, useFormContext, useWatch } from 'react-hook-form';

import type { EditorAuxData, RuntimeInfo, UpstreamEditorValues } from './data';
import { modelPrefixIsValid, publicModelId } from './data';
import type { EditorAuxData, RuntimeInfo, UpstreamEditLevel, UpstreamEditorValues } from './data';
import { modelPrefixIsValid, modelsEditable, publicModelId } from './data';
import { ApiPathsSection, ProviderConfigSection } from './provider-config';
import { EditorSection } from './section';
import type { UpstreamRecord } from '../../api/types';
Expand All @@ -29,7 +29,7 @@ const COMMON_COLO_LOCATIONS = [
'SYD', 'AKL', 'GRU', 'JNB', 'DXB', 'BOM', 'DEL',
] as const;

export const configReadOnly = (editLevel: 'off' | 'models' | 'full') => ({
export const configReadOnly = (editLevel: UpstreamEditLevel) => ({
connection: editLevel !== 'full',
modelsFetch: editLevel === 'off',
});
Expand All @@ -48,7 +48,7 @@ export function UpstreamConfigSidebar({
discovered: UpstreamModelConfig[];
onPatch: (patch: { config?: unknown; state?: unknown }, persisted?: boolean) => void;
onRefreshModels: () => void;
editLevel: 'off' | 'models' | 'full';
editLevel: UpstreamEditLevel;
proxies: EditorAuxData['proxies'];
record: UpstreamRecord;
runtime: RuntimeInfo;
Expand Down Expand Up @@ -153,7 +153,7 @@ export function UpstreamConfigSidebar({
<ModelPrefixEditor readOnly={immutable} />
</EditorSection>
<EditorSection title={t('dashboard.upstreamEditor.sections.disabledModels')} description={t('dashboard.upstreamEditor.disabledModelsHint')}>
<DisabledModelsCombobox catalogAvailable={catalogAvailable} discovered={discovered} readOnly={immutable} />
<DisabledModelsCombobox catalogAvailable={catalogAvailable} discovered={discovered} readOnly={!modelsEditable(editLevel)} />
</EditorSection>
</aside>
</div>
Expand Down
13 changes: 12 additions & 1 deletion apps/web/src/components/upstream-editor/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ export interface EditorAuxData {
runtime: RuntimeInfo;
}

export type UpstreamEditLevel = 'off' | 'models' | 'full';

interface UpstreamEditorLoaderDataBase extends EditorAuxData {
audit?: boolean;
editLevel: 'off' | 'models' | 'full';
editLevel: UpstreamEditLevel;
record: UpstreamRecord;
discovered: UpstreamModelConfig[] | null;
}
Expand Down Expand Up @@ -119,6 +121,15 @@ export const canFetchModelCatalog = (record: UpstreamRecord, config: UpstreamEdi
}
};

// Turning a listed model on or off is a catalog edit rather than a structural
// one: an editor who may change the catalog may set it, and only an audit-only
// editor may not. The sidebar's disabled-models combobox and the workspace's
// per-row switch are two presentations of that one field, so both read this
// predicate instead of deriving read-only flags of their own -- each derived
// from a different restriction (connection editability on one side, catalog
// ownership on the other) and the two drifted apart.
export const modelsEditable = (editLevel: UpstreamEditLevel): boolean => editLevel !== 'off';

// Manual entries exist only for the kinds whose stored config carries a model
// list. For the rest the catalog is the provider's, and the editor can only
// enable and disable what it lists.
Expand Down
Loading
Loading