Merge pull request #4384 from continuedev/dallin/refresh-profiles-button

Refresh profiles button
This commit is contained in:
Nate Sesti 2025-02-26 18:34:59 -08:00 • committed by GitHub
commit ff066f4986
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 156 additions and 99 deletions

View file

@ -306,6 +306,10 @@ export class Core {
return this.configHandler.listProfiles();
});
on("config/refreshProfiles", async (msg) => {
await this.configHandler.loadAssistantsForSelectedOrg();
});
on("config/addContextProvider", async (msg) => {
addContextProvider(msg.data, this.configHandler);
});

View file

@ -69,6 +69,7 @@ export type ToCoreFromIdeOrWebviewProtocol = {
"config/addContextProvider": [ContextProviderWithParams, void];
"config/reload": [undefined, ConfigResult<BrowserSerializedContinueConfig>];
"config/listProfiles": [undefined, ProfileDescription[] | null];
"config/refreshProfiles": [undefined, void];
"config/openProfile": [{ profileId: string | undefined }, void];
"config/updateSharedConfig": [SharedConfigSchema, SharedConfigSchema];
"config/updateSelectedModel": [

View file

@ -22,6 +22,7 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] =
"config/getSerializedProfileInfo",
"config/deleteModel",
"config/listProfiles",
"config/refreshProfiles",
"config/openProfile",
"config/updateSharedConfig",
"config/updateSelectedModel",

View file

@ -69,7 +69,7 @@ Note that hub secrets can be passed as inputs, using the a similar mustache form
### Overrides
Block properties can be also be directly overriden using `overrides`. For example:
Block properties can be also be directly overriden using `override`. For example:
```yaml title="Assistant config.yaml"
name: myprofile/custom-assistant
@ -78,7 +78,7 @@ models:
with:
ANTHROPIC_API_KEY: ${{ secrets.MY_ANTHROPIC_API_KEY }}
TEMP: 0.9
overrides:
override:
roles:
- chat
```
@ -350,7 +350,7 @@ models:
- uses: anthropic/claude-3.5-sonnet
with:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
overrides:
override:
defaultCompletionOptions:
temperature: 0.8
- name: GPT-4
@ -435,26 +435,26 @@ model_defaults: &model_defaults
apiBase: https://api.example.com/llm
models:
- name: mistral
<<: *model_defaults
model: mistral-7b-instruct
roles:
- chat
- edit
- name: mistral
<<: *model_defaults
model: mistral-7b-instruct
roles:
- chat
- edit
- name: qwen2.5-coder-7b-instruct
<<: *model_defaults
model: qwen2.5-coder-7b-instruct
roles:
- chat
- edit
- name: qwen2.5-coder-7b-instruct
<<: *model_defaults
model: qwen2.5-coder-7b-instruct
roles:
- chat
- edit
- name: qwen2.5-coder-7b
<<: *model_defaults
model: qwen2.5-coder-7b
useLegacyCompletionsEndpoint: false
roles:
- autocomplete
- name: qwen2.5-coder-7b
<<: *model_defaults
model: qwen2.5-coder-7b
useLegacyCompletionsEndpoint: false
roles:
- autocomplete
```
### Fully deprecated settings

View file

@ -89,6 +89,7 @@ class MessageTypes {
"config/getSerializedProfileInfo",
"config/deleteModel",
"config/listProfiles",
"config/refreshProfiles",
"config/openProfile",
"config/updateSharedConfig",
"config/updateSelectedModel",

View file

@ -126,7 +126,7 @@ function InputToolbar(props: InputToolbarProps) {
}
}}
/>
<HoverItem>
<HoverItem className="">
<PhotoIcon
className="h-4 w-4 hover:brightness-125"
data-tooltip-id="image-tooltip"
@ -160,7 +160,7 @@ function InputToolbar(props: InputToolbarProps) {
<div className="flex items-center gap-2 whitespace-nowrap text-gray-400">
{!props.toolbarOptions?.hideUseCodebase && !isInEditMode && (
<div
className={`${toolsSupported ? "md:flex" : "sm:flex"} hover:underline" hidden transition-colors duration-200`}
className={`${toolsSupported ? "md:flex" : "int:flex"} hover:underline" hidden transition-colors duration-200`}
>
{props.activeKey === "Alt" ? (
<HoverItem className="underline">

View file

@ -27,6 +27,7 @@ interface AuthContextType {
login: (useOnboarding: boolean) => Promise<boolean>;
selectedProfile: ProfileDescription | null;
profiles: ProfileDescription[] | null;
refreshProfiles: () => void;
controlServerBetaEnabled: boolean;
organizations: OrganizationDescription[];
selectedOrganization: OrganizationDescription | null;
@ -175,6 +176,16 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
});
}, []);
const refreshProfiles = async () => {
try {
await ideMessenger.request("config/refreshProfiles", undefined);
ideMessenger.post("showToast", ["info", "Config refreshed"]);
} catch (e) {
console.error("Failed to refresh profiles", e);
ideMessenger.post("showToast", ["error", "Failed to refresh config"]);
}
};
useWebviewListener(
"didChangeAvailableProfiles",
async (data) => {
@ -196,6 +207,7 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
login,
selectedProfile,
profiles,
refreshProfiles,
selectedOrganization,
organizations: orgs,
controlServerBetaEnabled,

View file

@ -224,70 +224,76 @@ function ConfigPage() {
<h2 className="mb-1 mt-0">Configuration</h2>
{profiles ? (
<>
<Listbox value={selectedProfile?.id} onChange={changeProfileId}>
{({ open }) => (
<div className="relative w-full">
<Listbox.Button className="border-vsc-input-border bg-vsc-background hover:bg-vsc-input-background text-vsc-foreground relative m-0 flex w-full cursor-pointer items-center justify-between rounded-md border border-solid px-3 py-2 text-left">
<span className="lines lines-1">
{selectedProfile?.title ?? "No Assistant Selected"}
</span>
<div className="pointer-events-none flex items-center">
<ChevronUpDownIcon
className="h-5 w-5"
aria-hidden="true"
/>
</div>
</Listbox.Button>
<div className="flex flex-col gap-1.5">
<span className="text-lightgray">{`${hubEnabled ? "Assistant" : "Profile"}`}</span>
<Listbox
value={selectedProfile?.id}
onChange={changeProfileId}
>
{({ open }) => (
<div className="relative w-full">
<Listbox.Button className="border-vsc-input-border bg-vsc-background hover:bg-vsc-input-background text-vsc-foreground relative m-0 flex w-full cursor-pointer items-center justify-between rounded-md border border-solid px-3 py-2 text-left">
<span className="lines lines-1">
{selectedProfile?.title ?? "No Assistant Selected"}
</span>
<div className="pointer-events-none flex items-center">
<ChevronUpDownIcon
className="h-5 w-5"
aria-hidden="true"
/>
</div>
</Listbox.Button>
<Transition
as={Fragment}
show={open}
enter="transition ease-out duration-100"
enterFrom="transform opacity-0 scale-95"
enterTo="transform opacity-100 scale-100"
leave="transition ease-in duration-75"
leaveFrom="transform opacity-100 scale-100"
leaveTo="transform opacity-0 scale-95"
>
<Listbox.Options className="bg-vsc-background max-h-80vh absolute z-50 mt-0.5 w-full overflow-y-scroll rounded-sm p-0">
{profiles.map((option, idx) => (
<Listbox.Option
key={idx}
value={option.id}
className={`text-vsc-foreground hover:text-list-active-foreground flex cursor-pointer flex-row items-center gap-3 px-3 py-2 ${selectedProfile?.id === option.id ? "bg-list-active" : "bg-vsc-input-background"}`}
>
<span className="lines lines-1 relative flex h-5 items-center justify-between gap-3 pr-2 text-xs">
{option.title}
</span>
</Listbox.Option>
))}
{hubEnabled && (
<Listbox.Option
key={"no-profiles"}
value={null}
className={`text-vsc-foreground hover:bg-list-active bg-vsc-input-background flex cursor-pointer flex-row items-center gap-2 px-3 py-2`}
onClick={() => {
if (session) {
ideMessenger.post("controlPlane/openUrl", {
path: "new",
orgSlug: selectedOrganization?.slug,
});
} else {
login(false);
}
}}
>
<PlusCircleIcon className="h-4 w-4" />
<span className="lines lines-1 flex items-center justify-between text-xs">
Create new Assistant
</span>
</Listbox.Option>
)}
</Listbox.Options>
</Transition>
</div>
)}
</Listbox>
<Transition
as={Fragment}
show={open}
enter="transition ease-out duration-100"
enterFrom="transform opacity-0 scale-95"
enterTo="transform opacity-100 scale-100"
leave="transition ease-in duration-75"
leaveFrom="transform opacity-100 scale-100"
leaveTo="transform opacity-0 scale-95"
>
<Listbox.Options className="bg-vsc-background max-h-80vh absolute z-50 mt-0.5 w-full overflow-y-scroll rounded-sm p-0">
{profiles.map((option, idx) => (
<Listbox.Option
key={idx}
value={option.id}
className={`text-vsc-foreground hover:text-list-active-foreground flex cursor-pointer flex-row items-center gap-3 px-3 py-2 ${selectedProfile?.id === option.id ? "bg-list-active" : "bg-vsc-input-background"}`}
>
<span className="lines lines-1 relative flex h-5 items-center justify-between gap-3 pr-2 text-xs">
{option.title}
</span>
</Listbox.Option>
))}
{hubEnabled && (
<Listbox.Option
key={"no-profiles"}
value={null}
className={`text-vsc-foreground hover:bg-list-active bg-vsc-input-background flex cursor-pointer flex-row items-center gap-2 px-3 py-2`}
onClick={() => {
if (session) {
ideMessenger.post("controlPlane/openUrl", {
path: "new",
orgSlug: selectedOrganization?.slug,
});
} else {
login(false);
}
}}
>
<PlusCircleIcon className="h-4 w-4" />
<span className="lines lines-1 flex items-center justify-between text-xs">
Create new Assistant
</span>
</Listbox.Option>
)}
</Listbox.Options>
</Transition>
</div>
)}
</Listbox>
</div>
{selectedProfile && (
<SecondaryButton onClick={handleOpenConfig}>
{selectedProfile.id === "local"
@ -297,14 +303,20 @@ function ConfigPage() {
: "Open Workspace"}
</SecondaryButton>
)}
{/* {hubEnabled && session && (
<div className="flex flex-col gap-1">
<span>{`If your hub secret values may have changed, refresh your assistants`}</span>
<SecondaryButton onClick={refreshProfiles}>
Refresh assistants
</SecondaryButton>
</div>
)} */}
</>
) : (
<div>Loading...</div>
)}
<div>
<h2 className="m-0 mb-3 p-0 text-center text-sm">
Active Models
</h2>
<h2 className="m-0 mb-3 p-0 text-center text-sm">Model Roles</h2>
<div className="grid grid-cols-1 gap-x-3 gap-y-2 sm:grid-cols-[auto_1fr]">
<ModelRoleSelector
displayName="Chat"

View file

@ -111,7 +111,7 @@ const StepsDiv = styled.div`
}
.thread-message {
margin: 0px 4px 0 4px;
margin: 0px 0px 0px 1px;
}
`;

View file

@ -1,14 +1,17 @@
import { Cog8ToothIcon, ListBulletIcon } from "@heroicons/react/24/outline";
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
import { useContext } from "react";
import { GithubIcon } from "../../components/svg/GithubIcon";
import { DiscordIcon } from "../../components/svg/DiscordIcon";
import { IdeMessengerContext } from "../../context/IdeMessenger";
import { Cog8ToothIcon } from "@heroicons/react/24/outline";
import { DISCORD_LINK, GITHUB_LINK } from "core/util/constants";
import { selectDefaultModel } from "../../redux/slices/configSlice";
import { providers } from "../AddNewModel/configs/providers";
import { useContext } from "react";
import { Button, SecondaryButton } from "../../components";
import { DiscordIcon } from "../../components/svg/DiscordIcon";
import { GithubIcon } from "../../components/svg/GithubIcon";
import { useAuth } from "../../context/Auth";
import { IdeMessengerContext } from "../../context/IdeMessenger";
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
import { selectUseHub } from "../../redux/selectors";
import { selectDefaultModel } from "../../redux/slices/configSlice";
import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice";
import { isLocalProfile } from "../../util";
import { providers } from "../AddNewModel/configs/providers";
interface StreamErrorProps {
error: unknown;
@ -17,6 +20,17 @@ const StreamErrorDialog = ({ error }: StreamErrorProps) => {
const dispatch = useAppDispatch();
const ideMessenger = useContext(IdeMessengerContext);
const selectedModel = useAppSelector(selectDefaultModel);
const hubEnabled = useAppSelector(selectUseHub);
const selectedProfile = useAppSelector(
(store) => store.session.selectedProfile,
);
const { session, refreshProfiles } = useAuth();
const handleRefreshProfiles = () => {
refreshProfiles();
dispatch(setShowDialog(false));
dispatch(setDialogMessage(undefined));
};
// Collect model information to display useful error info
let modelTitle = "Chat model";
@ -139,7 +153,18 @@ const StreamErrorDialog = ({ error }: StreamErrorProps) => {
if (statusCode === 401) {
errorContent = (
<div className="flex flex-col gap-2">
<span>{`Likely cause: your API key is invalid.`}</span>
{hubEnabled &&
session &&
selectedProfile &&
!isLocalProfile(selectedProfile) && (
<div className="flex flex-col gap-1">
<span>{`If your hub secret values may have changed, refresh your assistants`}</span>
<SecondaryButton onClick={handleRefreshProfiles}>
Refresh assistant secrets
</SecondaryButton>
</div>
)}
<span>{`It's possible that your API key is invalid.`}</span>
<div className="flex flex-row flex-wrap gap-2">
{checkKeysButton}
{configButton}

View file

@ -13,6 +13,7 @@ module.exports = {
"2xs": "170px", // Smallest width for Primary Sidebar in VS Code
xs: "250px", // Avg default sidebar width in VS Code
sm: "330px",
int: "380px",
md: "460px",
lg: "590px",
xl: "720px",