only enabled ai models for all users
This commit is contained in:
@@ -33,8 +33,6 @@ export const AIModels = () => {
|
||||
const piModels = useEnabledPiModels();
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
|
||||
console.log('[AIModels] enabledModels:', settings.ai?.enabledModels?.length, 'filtered:', piModels.length);
|
||||
|
||||
const [chatModel, setChatModel] = useState<string | null>(settings.chat.defaultModel);
|
||||
const [projectModel, setProjectModel] = useState<string | null>(settings.chat.defaultProjectModel);
|
||||
const [taskModel, setTaskModel] = useState<string | null>(settings.tasks.defaultModel);
|
||||
|
||||
@@ -16,6 +16,7 @@ import { createSettingsPanelComponents, type SettingsSectionGroup } from './Sett
|
||||
import { useSettings } from 'state/useSettings';
|
||||
import { useUserState } from 'state/useUserState';
|
||||
import { usePiModels, useVisiblePiModels, modelKey, getProviderDisplayName, type ModelOption } from 'state/useModels';
|
||||
import { useAccessPolicy } from 'state/useAccessPolicy';
|
||||
import type { UserSettings } from 'state/useSettings';
|
||||
import { AIHarnessesSection } from './ServerSettings/AIHarnessesSection';
|
||||
import { RUN_COMMAND_CHANNEL, type RunCommandState } from './ServerSettings/run-command-channel';
|
||||
@@ -337,11 +338,11 @@ const DropZone = ({ label, children, onDrop }: DropZoneProps) => {
|
||||
};
|
||||
|
||||
function ModelVisibilitySection() {
|
||||
const { settings, saveSettings } = useSettings();
|
||||
const { policy, savePolicy } = useAccessPolicy();
|
||||
const piModels = usePiModels();
|
||||
const [activeProvider, setActiveProvider] = useUserState<string>('model-visibility-provider', '');
|
||||
|
||||
const enabledModels = settings.ai?.enabledModels ?? [];
|
||||
const enabledModels = policy.allowedModels;
|
||||
|
||||
const providerGroups = useMemo(() => {
|
||||
const groups: Record<string, { id: string; name: string }[]> = {};
|
||||
@@ -383,9 +384,9 @@ function ModelVisibilitySection() {
|
||||
const enableModel = useCallback(
|
||||
async (key: string) => {
|
||||
if (enabledModels.includes(key)) return;
|
||||
await saveSettings({ ...settings, ai: { ...settings.ai, enabledModels: [...enabledModels, key] } });
|
||||
await savePolicy({ allowedModels: [...enabledModels, key] });
|
||||
},
|
||||
[settings, enabledModels, saveSettings],
|
||||
[enabledModels, savePolicy],
|
||||
);
|
||||
|
||||
const disableModel = useCallback(
|
||||
@@ -401,9 +402,9 @@ function ModelVisibilitySection() {
|
||||
base = [...base, ...newProviderKeys];
|
||||
}
|
||||
}
|
||||
await saveSettings({ ...settings, ai: { ...settings.ai, enabledModels: base.filter((id) => id !== key) } });
|
||||
await savePolicy({ allowedModels: base.filter((id) => id !== key) });
|
||||
},
|
||||
[settings, enabledModels, piModels, saveSettings],
|
||||
[enabledModels, piModels, savePolicy],
|
||||
);
|
||||
|
||||
const onDragStart = useCallback((ev: DragEvent, key: string) => {
|
||||
|
||||
Reference in New Issue
Block a user