refresh profiles button on 401
This commit is contained in:
parent
dc482e231c
commit
bd6cfb047f
8 changed files with 72 additions and 32 deletions
|
|
@ -353,11 +353,7 @@ export class ConfigHandler {
|
|||
Promise.resolve(sessionInfo),
|
||||
this.ideSettingsPromise,
|
||||
);
|
||||
this.fetchControlPlaneProfiles().catch(async (e) => {
|
||||
console.error("Failed to fetch control plane profiles: ", e);
|
||||
await this.updateAvailableProfiles([this.localProfileManager]);
|
||||
await this.reloadConfig();
|
||||
});
|
||||
await this.refreshProfiles();
|
||||
}
|
||||
|
||||
private profilesListeners: ((
|
||||
|
|
@ -435,6 +431,14 @@ export class ConfigHandler {
|
|||
return this.profiles?.map((p) => p.profileDescription) ?? null;
|
||||
}
|
||||
|
||||
async refreshProfiles() {
|
||||
this.fetchControlPlaneProfiles().catch(async (e) => {
|
||||
console.error("Failed to fetch control plane profiles: ", e);
|
||||
await this.updateAvailableProfiles([this.localProfileManager]);
|
||||
await this.reloadConfig();
|
||||
});
|
||||
}
|
||||
|
||||
async loadConfig(): Promise<ConfigResult<ContinueConfig>> {
|
||||
if (!this.currentProfile) {
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -306,6 +306,10 @@ export class Core {
|
|||
return this.configHandler.listProfiles();
|
||||
});
|
||||
|
||||
on("config/refreshProfiles", async (msg) => {
|
||||
await this.configHandler.refreshProfiles();
|
||||
});
|
||||
|
||||
on("config/addContextProvider", async (msg) => {
|
||||
addContextProvider(msg.data, this.configHandler);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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": [
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ class MessageTypes {
|
|||
"config/getSerializedProfileInfo",
|
||||
"config/deleteModel",
|
||||
"config/listProfiles",
|
||||
"config/refreshProfiles",
|
||||
"config/openProfile",
|
||||
"config/updateSharedConfig",
|
||||
"config/updateSelectedModel",
|
||||
|
|
|
|||
|
|
@ -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,14 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||
});
|
||||
}, []);
|
||||
|
||||
const refreshProfiles = () => {
|
||||
try {
|
||||
ideMessenger.post("config/refreshProfiles", undefined);
|
||||
} catch (e) {
|
||||
console.error("Failed to refresh profiles", e);
|
||||
}
|
||||
};
|
||||
|
||||
useWebviewListener(
|
||||
"didChangeAvailableProfiles",
|
||||
async (data) => {
|
||||
|
|
@ -196,6 +205,7 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||
login,
|
||||
selectedProfile,
|
||||
profiles,
|
||||
refreshProfiles,
|
||||
selectedOrganization,
|
||||
organizations: orgs,
|
||||
controlServerBetaEnabled,
|
||||
|
|
|
|||
|
|
@ -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,11 @@ 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();
|
||||
|
||||
// Collect model information to display useful error info
|
||||
let modelTitle = "Chat model";
|
||||
|
|
@ -139,7 +147,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>
|
||||
<span>{`If your hub secret values may have changed, refresh your profiles`}</span>
|
||||
<SecondaryButton onClick={refreshProfiles}>
|
||||
Refresh profile 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}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue