add model button in settings page

This commit is contained in:
Nate 2025-08-12 20:43:08 -04:00
parent 37b33fda81
commit 8eca6d3cf5
3 changed files with 62 additions and 46 deletions

View file

@ -1,13 +1,9 @@
import { BlockType } from "@continuedev/config-yaml";
import {
ArrowTopRightOnSquareIcon,
PlusIcon,
} from "@heroicons/react/24/outline";
import { useContext } from "react";
import { GhostButton } from "../../..";
import { useAuth } from "../../../../context/Auth";
import { IdeMessengerContext } from "../../../../context/IdeMessenger";
import { fontSize } from "../../../../util";
import { BaseIconButton } from "./BaseIconButton";
import { getExploreBlocksConfig } from "./exploreBlocksLogic";
export function ExploreBlocksButton(props: { blockType: string }) {
const { selectedProfile } = useAuth();
@ -15,41 +11,31 @@ export function ExploreBlocksButton(props: { blockType: string }) {
const isLocal = selectedProfile?.profileType === "local";
const Icon = isLocal ? PlusIcon : ArrowTopRightOnSquareIcon;
const text = `${isLocal ? "Add" : "Explore"} ${
props.blockType === "mcpServers"
? "MCP Servers"
: props.blockType.charAt(0).toUpperCase() + props.blockType.slice(1)
}`;
const handleClick = () => {
if (isLocal) {
void ideMessenger.request("config/addLocalWorkspaceBlock", {
blockType: props.blockType as BlockType,
});
} else {
void ideMessenger.request("controlPlane/openUrl", {
path: `new?type=block&blockType=${props.blockType}`,
orgSlug: undefined,
});
}
const handleLocalAdd = (blockType: BlockType) => {
void ideMessenger.request("config/addLocalWorkspaceBlock", {
blockType,
});
};
const handleExplore = (blockType: string) => {
void ideMessenger.request("controlPlane/openUrl", {
path: `new?type=block&blockType=${blockType}`,
orgSlug: undefined,
});
};
const config = getExploreBlocksConfig(
props.blockType,
isLocal,
handleLocalAdd,
handleExplore
);
return (
<GhostButton
className="w-full cursor-pointer rounded px-2 py-0.5 text-center"
style={{
fontSize: fontSize(-3),
}}
onClick={(e) => {
e.preventDefault();
handleClick();
}}
>
<div className="flex items-center justify-center gap-1">
<Icon className="h-3 w-3 pr-1" />
<span className="text-[11px]">{text}</span>
</div>
</GhostButton>
<BaseIconButton
icon={config.icon}
text={config.text}
onClick={config.action}
/>
);
}

View file

@ -1,10 +1,14 @@
import { ModelRole } from "@continuedev/config-yaml";
import { PlusIcon } from "@heroicons/react/24/outline";
import { ModelDescription } from "core";
import { useAuth } from "../../../../context/Auth";
import { AddModelForm } from "../../../../forms/AddModelForm";
import ModelRoleSelector from "../../../../pages/config/ModelRoleSelector";
import { useAppDispatch, useAppSelector } from "../../../../redux/hooks";
import { setDialogMessage, setShowDialog } from "../../../../redux/slices/uiSlice";
import { updateSelectedModelByRole } from "../../../../redux/thunks/updateSelectedModelByRole";
import { isJetBrains } from "../../../../util";
import { BaseIconButton } from "./BaseIconButton";
export function ModelsSection() {
const { selectedProfile } = useAuth();
@ -27,9 +31,25 @@ export function ModelsSection() {
);
}
function handleAddModel(e: React.MouseEvent) {
e.stopPropagation();
e.preventDefault();
dispatch(setShowDialog(true));
dispatch(
setDialogMessage(
<AddModelForm
onDone={() => {
dispatch(setShowDialog(false));
}}
/>,
),
);
}
return (
<div>
<div className="text-[${getFontSize() - 1}px] grid grid-cols-1 gap-x-2 gap-y-1 sm:grid-cols-[auto_1fr]">
<div className="grid grid-cols-1 gap-x-2 gap-y-1 sm:grid-cols-[auto_1fr]">
<ModelRoleSelector
displayName="Chat"
description="Used in the chat interface"
@ -82,6 +102,16 @@ export function ModelsSection() {
setupURL="https://docs.continue.dev/customize/model-roles/reranking"
/>
</div>
{selectedProfile?.profileType === "local" && (
<div className="mt-2">
<BaseIconButton
icon={PlusIcon}
text="Add Model"
onClick={handleAddModel}
/>
</div>
)}
</div>
);
}

View file

@ -86,6 +86,12 @@ function ConfigPage() {
// ),
// icon: <ChatBubbleLeftIcon className="xs:h-4 xs:w-4 h-3 w-3 flex-shrink-0" />,
// },
{
id: "mcp",
label: "MCP",
component: <MCPSection />,
icon: <Squares2X2Icon className="xs:h-4 xs:w-4 h-3 w-3 flex-shrink-0" />,
},
{
id: "tools",
label: "Tools",
@ -99,12 +105,6 @@ function ConfigPage() {
<WrenchScrewdriverIcon className="xs:h-4 xs:w-4 h-3 w-3 flex-shrink-0" />
),
},
{
id: "mcp",
label: "MCP",
component: <MCPSection />,
icon: <Squares2X2Icon className="xs:h-4 xs:w-4 h-3 w-3 flex-shrink-0" />,
},
{
id: "indexing",
label: "Indexing",