🚧 edit settings
This commit is contained in:
parent
6ebc6272a7
commit
c61aebd3d4
6 changed files with 28 additions and 26 deletions
|
|
@ -2,6 +2,7 @@ import * as io from "socket.io-client";
|
|||
import * as vscode from "vscode";
|
||||
import { FileEdit } from "../schema/FileEdit";
|
||||
import { ideProtocolClient, windowId } from "./activation/activate";
|
||||
import { getConfigJsonPath } from "./activation/environmentSetup";
|
||||
import { getContinueServerUrl } from "./bridge";
|
||||
import historyManager from "./history";
|
||||
import VsCodeIde from "./ideProtocol";
|
||||
|
|
@ -150,6 +151,10 @@ export function getSidebarContent(
|
|||
ideProtocolClient.openFile(data.filepath);
|
||||
break;
|
||||
}
|
||||
case "openConfigJson": {
|
||||
ideProtocolClient.openFile(getConfigJsonPath());
|
||||
break;
|
||||
}
|
||||
case "readRangeInFile": {
|
||||
vscode.workspace.openTextDocument(data.filepath).then((document) => {
|
||||
let start = new vscode.Position(0, 0);
|
||||
|
|
|
|||
|
|
@ -3,12 +3,14 @@ import {
|
|||
QuestionMarkCircleIcon,
|
||||
SparklesIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { postToIde } from "core/ide/messaging";
|
||||
import { useEffect } from "react";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { Outlet, useLocation, useNavigate } from "react-router-dom";
|
||||
import styled from "styled-components";
|
||||
import { defaultBorderRadius, secondaryDark, vscForeground } from ".";
|
||||
import useHistory from "../hooks/useHistory";
|
||||
import { defaultModelSelector } from "../redux/selectors/modelSelectors";
|
||||
import {
|
||||
setBottomMessage,
|
||||
setBottomMessageCloseTimeout,
|
||||
|
|
@ -109,9 +111,7 @@ const Layout = () => {
|
|||
(state: RootStore) => state.serverState.indexingProgress
|
||||
);
|
||||
|
||||
const defaultModel = useSelector(
|
||||
(state: RootStore) => (state.serverState.config as any).models?.default
|
||||
);
|
||||
const defaultModel = useSelector(defaultModelSelector);
|
||||
// #region Selectors
|
||||
|
||||
const bottomMessage = useSelector(
|
||||
|
|
@ -159,7 +159,8 @@ const Layout = () => {
|
|||
if (event.data.type === "addModel") {
|
||||
navigate("/models");
|
||||
} else if (event.data.type === "openSettings") {
|
||||
navigate("/settings");
|
||||
// navigate("/settings");
|
||||
postToIde("openConfigJson", {});
|
||||
} else if (event.data.type === "viewHistory") {
|
||||
// Toggle the history page / main page
|
||||
if (location.pathname === "/history") {
|
||||
|
|
@ -231,8 +232,8 @@ const Layout = () => {
|
|||
)}
|
||||
<ModelSelect />
|
||||
{indexingProgress >= 1 && // Would take up too much space together with indexing progress
|
||||
defaultModel?.class_name === "OpenAIFreeTrial" &&
|
||||
defaultModel?.api_key === "" &&
|
||||
defaultModel?.providerName === "openai-free-trial" &&
|
||||
defaultModel?.apiKey === "" &&
|
||||
(location.pathname === "/settings" ||
|
||||
parseInt(localStorage.getItem("ftc") || "0") >= 125) && (
|
||||
<ProgressBar
|
||||
|
|
@ -258,7 +259,8 @@ const Layout = () => {
|
|||
</HeaderButtonWithText>
|
||||
<HeaderButtonWithText
|
||||
onClick={() => {
|
||||
navigate("/settings");
|
||||
// navigate("/settings");
|
||||
postToIde("openConfigJson", {});
|
||||
}}
|
||||
text="Settings"
|
||||
>
|
||||
|
|
|
|||
|
|
@ -443,7 +443,7 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
|
|||
}, [currentlyInContextQuery]);
|
||||
|
||||
const contextProviders = useSelector(
|
||||
(state: RootStore) => state.serverState.contextProviders
|
||||
(state: RootStore) => state.state.config.contextProviders
|
||||
) as any[];
|
||||
|
||||
const goBackToContextProviders = () => {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import {
|
|||
} from "@heroicons/react/24/outline";
|
||||
import { Fragment, useEffect, useState } from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import { useSelector } from "react-redux";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import styled from "styled-components";
|
||||
import {
|
||||
|
|
@ -18,6 +18,7 @@ import {
|
|||
vscForeground,
|
||||
} from "..";
|
||||
import { defaultModelSelector } from "../../redux/selectors/modelSelectors";
|
||||
import { setDefaultModel } from "../../redux/slices/stateSlice";
|
||||
import { RootStore } from "../../redux/store";
|
||||
import { getMetaKeyLabel } from "../../util";
|
||||
import HeaderButtonWithText from "../HeaderButtonWithText";
|
||||
|
|
@ -195,26 +196,20 @@ interface Option {
|
|||
}
|
||||
|
||||
function ModelSelect(props: {}) {
|
||||
const dispatch = useDispatch();
|
||||
const defaultModel = useSelector(defaultModelSelector);
|
||||
const allModels = useSelector(
|
||||
(state: RootStore) => state.serverState.config.models
|
||||
(state: RootStore) => state.state.config.models
|
||||
);
|
||||
|
||||
const navigate = useNavigate();
|
||||
|
||||
const DEFAULT_OPTION = {
|
||||
value: "GPT-4",
|
||||
title: "GPT-4",
|
||||
};
|
||||
const [options, setOptions] = useState<Option[]>([DEFAULT_OPTION]);
|
||||
const [options, setOptions] = useState<Option[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!allModels) {
|
||||
setOptions([DEFAULT_OPTION]);
|
||||
return;
|
||||
}
|
||||
setOptions(
|
||||
allModels.map((model) => {
|
||||
console.log(modelSelectTitle(model));
|
||||
return {
|
||||
value: model.title,
|
||||
title: modelSelectTitle(model),
|
||||
|
|
@ -232,8 +227,7 @@ function ModelSelect(props: {}) {
|
|||
(option) => option.value === defaultModel?.title
|
||||
);
|
||||
const nextIndex = (currentIndex + 1) % options.length;
|
||||
// TODO
|
||||
// client?.setModelForRoleFromTitle("default", options[nextIndex].value);
|
||||
dispatch(setDefaultModel(options[nextIndex].value));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -250,6 +244,7 @@ function ModelSelect(props: {}) {
|
|||
value={"GPT-4"}
|
||||
onChange={(val: string) => {
|
||||
if (val === defaultModel?.title) return;
|
||||
dispatch(setDefaultModel(val));
|
||||
// TODO
|
||||
// client?.setModelForRoleFromTitle("default", val);
|
||||
}}
|
||||
|
|
@ -257,7 +252,7 @@ function ModelSelect(props: {}) {
|
|||
>
|
||||
<div className="relative">
|
||||
<StyledListboxButton>
|
||||
<div>{modelSelectTitle(defaultModel) || "GPT-4"}</div>
|
||||
<div>{modelSelectTitle(defaultModel)}</div>
|
||||
<div className="pointer-events-none flex items-center">
|
||||
<ChevronUpDownIcon
|
||||
className="h-5 w-5 text-gray-400"
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ function Settings() {
|
|||
const onSubmit = (data: ContinueConfig) => console.log(data);
|
||||
|
||||
const navigate = useNavigate();
|
||||
const config = useSelector((state: RootStore) => state.serverState.config);
|
||||
const config = useSelector((state: RootStore) => state.state.config);
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const submitChanges = () => {
|
||||
|
|
|
|||
|
|
@ -337,14 +337,14 @@ export const stateSlice = createSlice({
|
|||
};
|
||||
}
|
||||
},
|
||||
setDefaultModel: (state, action) => {
|
||||
setDefaultModel: (state, { payload }: { payload: string }) => {
|
||||
const model = state.config.models.find(
|
||||
(model) => model.title === action.payload
|
||||
(model) => model.title === payload
|
||||
);
|
||||
if (!model) return;
|
||||
return {
|
||||
...state,
|
||||
defaultModelTitle: action.payload,
|
||||
defaultModelTitle: payload,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue