diff --git a/gui/package-lock.json b/gui/package-lock.json
index a1e4cbb66..a6d1a60d4 100644
--- a/gui/package-lock.json
+++ b/gui/package-lock.json
@@ -7,7 +7,7 @@
"name": "gui",
"license": "Apache-2.0",
"dependencies": {
- "@continuedev/config-yaml": "^1.0.0",
+ "@continuedev/config-yaml": "^1.0.7",
"@headlessui/react": "^1.7.17",
"@heroicons/react": "^2.0.18",
"@reduxjs/toolkit": "^2.3.0",
@@ -546,9 +546,9 @@
"dev": true
},
"node_modules/@continuedev/config-yaml": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.0.tgz",
- "integrity": "sha512-NwagzzpnPLbMC3delzFSjWiFv5fp8ReFjdMQF0ko0Xg+U0Myja90k/J7JWGegF/SZMABxc/OJchElJFr58TwGA==",
+ "version": "1.0.7",
+ "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.7.tgz",
+ "integrity": "sha512-qng9yj5m54b5UHfdTYBM+rEINWs+S+IOm/dzm/PMlmz3CmpRt3OiBZaHLl/iYRCSB4xeOqFKoBPird58sxQ8YA==",
"dependencies": {
"yaml": "^2.6.1",
"zod": "^3.23.8"
diff --git a/gui/package.json b/gui/package.json
index d0150d999..3e6b910d7 100644
--- a/gui/package.json
+++ b/gui/package.json
@@ -15,7 +15,7 @@
"test:watch": "vitest"
},
"dependencies": {
- "@continuedev/config-yaml": "^1.0.0",
+ "@continuedev/config-yaml": "^1.0.7",
"@headlessui/react": "^1.7.17",
"@heroicons/react": "^2.0.18",
"@reduxjs/toolkit": "^2.3.0",
diff --git a/gui/src/components/index.ts b/gui/src/components/index.ts
index 95e178480..071900b51 100644
--- a/gui/src/components/index.ts
+++ b/gui/src/components/index.ts
@@ -1,4 +1,4 @@
-import styled, { keyframes } from "styled-components";
+import styled from "styled-components";
import { getFontSize, isJetBrains } from "../util";
export const VSC_INPUT_BACKGROUND_VAR = "--vscode-input-background";
@@ -298,11 +298,6 @@ export const HeaderButton = styled.button<{
padding: 2px;
`;
-export const Divider = styled.div`
- height: 1px;
- background-color: ${lightGray};
-`;
-
export const StyledActionButton = styled.div`
display: flex;
justify-content: space-between;
diff --git a/gui/src/components/mainInput/InputToolbar.tsx b/gui/src/components/mainInput/InputToolbar.tsx
index 93b437fdc..23e62f07e 100644
--- a/gui/src/components/mainInput/InputToolbar.tsx
+++ b/gui/src/components/mainInput/InputToolbar.tsx
@@ -1,5 +1,6 @@
import { AtSymbolIcon, PhotoIcon } from "@heroicons/react/24/outline";
import { InputModifiers } from "core";
+import { USE_PLATFORM } from "core/control-plane/flags";
import { modelSupportsImages, modelSupportsTools } from "core/llm/autodetect";
import { useRef } from "react";
import styled from "styled-components";
@@ -26,6 +27,7 @@ import {
} from "../../util";
import { ToolTip } from "../gui/Tooltip";
import ModelSelect from "../modelSelection/ModelSelect";
+import AssistantAndModelSelect from "../modelSelection/platform/AssistantAndModelSelect";
import HoverItem from "./InputToolbar/HoverItem";
import ToggleToolsButton from "./InputToolbar/ToggleToolsButton";
@@ -114,7 +116,7 @@ function InputToolbar(props: InputToolbarProps) {
className="find-widget-skip flex"
>
-
+ {USE_PLATFORM ?
:
}
{props.toolbarOptions?.hideImageUpload ||
(supportsImages && (
diff --git a/gui/src/components/mainInput/InputToolbar/PopoverTransition.tsx b/gui/src/components/mainInput/InputToolbar/PopoverTransition.tsx
new file mode 100644
index 000000000..24b64c27b
--- /dev/null
+++ b/gui/src/components/mainInput/InputToolbar/PopoverTransition.tsx
@@ -0,0 +1,26 @@
+import { Transition } from "@headlessui/react";
+
+export default function PopoverTransition({
+ children,
+ show,
+ afterLeave,
+}: {
+ children: React.ReactNode;
+ show?: boolean;
+ afterLeave?: () => void;
+}) {
+ return (
+
+ {children}
+
+ );
+}
diff --git a/gui/src/components/mainInput/InputToolbar/ToggleToolsButton.tsx b/gui/src/components/mainInput/InputToolbar/ToggleToolsButton.tsx
index 9dae27363..cb6a05666 100644
--- a/gui/src/components/mainInput/InputToolbar/ToggleToolsButton.tsx
+++ b/gui/src/components/mainInput/InputToolbar/ToggleToolsButton.tsx
@@ -1,4 +1,4 @@
-import { Listbox, Transition } from "@headlessui/react";
+import { Listbox } from "@headlessui/react";
import {
EllipsisHorizontalCircleIcon as EllipsisHorizontalIcon,
WrenchScrewdriverIcon as WrenchScrewdriverIconOutline,
@@ -6,15 +6,14 @@ import {
import { WrenchScrewdriverIcon as WrenchScrewdriverIconSolid } from "@heroicons/react/24/solid";
import { useEffect, useRef, useState } from "react";
import { useDispatch } from "react-redux";
-import styled from "styled-components";
-import { defaultBorderRadius, lightGray, vscForeground } from "../..";
+import { lightGray, vscForeground } from "../..";
+import { useAppSelector } from "../../../redux/hooks";
import { toggleUseTools } from "../../../redux/slices/uiSlice";
-import { getFontSize } from "../../../util";
+import { ToolTip } from "../../gui/Tooltip";
import InfoHover from "../../InfoHover";
import HoverItem from "./HoverItem";
+import PopoverTransition from "./PopoverTransition";
import ToolDropdownItem from "./ToolDropdownItem";
-import { useAppSelector } from "../../../redux/hooks";
-import { ToolTip } from "../../gui/Tooltip";
export default function ToolDropdown() {
const buttonRef = useRef
(null);
@@ -87,14 +86,8 @@ export default function ToolDropdown() {
>
- setDropdownOpen(false)}
>
-
+
>
)}
diff --git a/gui/src/components/modelSelection/ModelSelect.tsx b/gui/src/components/modelSelection/ModelSelect.tsx
index c5edb5d7b..f70d2c96e 100644
--- a/gui/src/components/modelSelection/ModelSelect.tsx
+++ b/gui/src/components/modelSelection/ModelSelect.tsx
@@ -7,16 +7,16 @@ import {
TrashIcon,
} from "@heroicons/react/24/outline";
import { useContext, useEffect, useRef, useState } from "react";
-import { useDispatch, useSelector } from "react-redux";
+import { useDispatch } from "react-redux";
import styled from "styled-components";
-import {
- defaultBorderRadius,
- Divider,
- lightGray,
- vscInputBackground,
-} from "..";
+import { defaultBorderRadius, lightGray, vscInputBackground } from "..";
import { IdeMessengerContext } from "../../context/IdeMessenger";
import AddModelForm from "../../forms/AddModelForm";
+import { useAppSelector } from "../../redux/hooks";
+import {
+ selectDefaultModel,
+ setDefaultModel,
+} from "../../redux/slices/configSlice";
import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice";
import {
getFontSize,
@@ -24,11 +24,7 @@ import {
isMetaEquivalentKeyPressed,
} from "../../util";
import ConfirmationDialog from "../dialogs/ConfirmationDialog";
-import { useAppSelector } from "../../redux/hooks";
-import {
- selectDefaultModel,
- setDefaultModel,
-} from "../../redux/slices/configSlice";
+import { Divider } from "./platform/shared";
interface ModelOptionProps {
option: Option;
diff --git a/gui/src/components/modelSelection/platform/AssistantAndModelSelect.tsx b/gui/src/components/modelSelection/platform/AssistantAndModelSelect.tsx
new file mode 100644
index 000000000..955f770f9
--- /dev/null
+++ b/gui/src/components/modelSelection/platform/AssistantAndModelSelect.tsx
@@ -0,0 +1,162 @@
+import { Popover } from "@headlessui/react";
+import { ChevronDownIcon } from "@heroicons/react/24/outline";
+import { useEffect, useRef, useState } from "react";
+import { useDispatch } from "react-redux";
+import styled from "styled-components";
+import { defaultBorderRadius, lightGray, vscInputBackground } from "../..";
+import AddModelForm from "../../../forms/AddModelForm";
+import { useAppSelector } from "../../../redux/hooks";
+import {
+ cycleDefaultModel,
+ selectDefaultModel,
+} from "../../../redux/slices/configSlice";
+import { cycleSelectedProfileId } from "../../../redux/slices/sessionSlice";
+import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice";
+import { getFontSize, isMetaEquivalentKeyPressed } from "../../../util";
+import PopoverTransition from "../../mainInput/InputToolbar/PopoverTransition";
+import { AssistantSelect } from "./AssistantSelect";
+import { ModelSelect, modelSelectTitle } from "./ModelSelect";
+import { MAX_HEIGHT_PX } from "./shared";
+
+const StyledPopoverButton = styled(Popover.Button)`
+ font-family: inherit;
+ display: flex;
+ align-items: center;
+ gap: 2px;
+ border: none;
+ cursor: pointer;
+ font-size: ${getFontSize() - 2}px;
+ background: transparent;
+ color: ${lightGray};
+ &:focus {
+ outline: none;
+ }
+`;
+
+const StyledPopoverPanel = styled(Popover.Panel)<{ $showabove: boolean }>`
+ margin-top: 4px;
+ position: absolute;
+ padding: 0px;
+ cursor: default;
+
+ display: flex;
+ flex-direction: row;
+
+ border-radius: ${defaultBorderRadius};
+ border: 0.5px solid ${lightGray};
+ background-color: ${vscInputBackground};
+
+ ${(props) => (props.$showabove ? "bottom: 100%;" : "top: 100%;")}
+`;
+
+function AssistantAndModelSelect() {
+ const dispatch = useDispatch();
+ const defaultModel = useAppSelector(selectDefaultModel);
+ const [showAbove, setShowAbove] = useState(false);
+ const buttonRef = useRef(null);
+ const selectedProfileId = useAppSelector(
+ (store) => store.session.selectedProfileId,
+ );
+
+ useEffect(() => {
+ const handleResize = () => calculatePosition();
+ window.addEventListener("resize", handleResize);
+ return () => window.removeEventListener("resize", handleResize);
+ }, []);
+
+ function calculatePosition() {
+ if (!buttonRef.current) {
+ return;
+ }
+ const rect = buttonRef.current.getBoundingClientRect();
+ const spaceBelow = window.innerHeight - rect.bottom;
+ const spaceAbove = rect.top;
+ const dropdownHeight = MAX_HEIGHT_PX;
+
+ setShowAbove(spaceBelow < dropdownHeight && spaceAbove > spaceBelow);
+ }
+
+ function onClickAddModel(e) {
+ e.stopPropagation();
+ e.preventDefault();
+
+ // Close the dropdown
+ if (buttonRef.current) {
+ buttonRef.current.click();
+ }
+ dispatch(setShowDialog(true));
+ dispatch(
+ setDialogMessage(
+ {
+ dispatch(setShowDialog(false));
+ }}
+ />,
+ ),
+ );
+ }
+
+ useEffect(() => {
+ let lastToggleTime = 0;
+ const DEBOUNCE_MS = 500;
+
+ const handleKeyDown = (event: KeyboardEvent) => {
+ if (event.key === "'" && isMetaEquivalentKeyPressed(event as any)) {
+ const now = Date.now();
+
+ if (event.shiftKey) {
+ dispatch(cycleDefaultModel("next"));
+ } else {
+ if (now - lastToggleTime >= DEBOUNCE_MS) {
+ dispatch(cycleSelectedProfileId());
+ lastToggleTime = now;
+ }
+ }
+ }
+ };
+
+ window.addEventListener("keydown", handleKeyDown);
+ return () => {
+ window.removeEventListener("keydown", handleKeyDown);
+ };
+ }, []);
+
+ return (
+
+
+
+
+
+ {modelSelectTitle(defaultModel) || "Select model"}{" "}
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+}
+
+export default AssistantAndModelSelect;
diff --git a/gui/src/components/modelSelection/platform/AssistantSelect.tsx b/gui/src/components/modelSelection/platform/AssistantSelect.tsx
new file mode 100644
index 000000000..cde44669a
--- /dev/null
+++ b/gui/src/components/modelSelection/platform/AssistantSelect.tsx
@@ -0,0 +1,85 @@
+import {
+ DocumentIcon,
+ PlusIcon,
+ SparklesIcon,
+} from "@heroicons/react/24/outline";
+import { useContext } from "react";
+import { useDispatch } from "react-redux";
+import { lightGray } from "../..";
+import { useAuth } from "../../../context/Auth";
+import { IdeMessengerContext } from "../../../context/IdeMessenger";
+import { setSelectedProfileId } from "../../../redux/slices/sessionSlice";
+import { getFontSize, getMetaKeyLabel } from "../../../util";
+import { Divider, Option, OptionDiv } from "./shared";
+
+interface AssistantSelectProps {}
+
+export function AssistantSelect(props: AssistantSelectProps) {
+ const ideMessenger = useContext(IdeMessengerContext);
+ const { profiles, selectedProfile } = useAuth();
+
+ const dispatch = useDispatch();
+
+ const changeProfileId = (id: string) => {
+ ideMessenger.post("didChangeSelectedProfile", { id });
+ dispatch(setSelectedProfileId(id));
+ };
+
+ function onNewAssistant() {
+ ideMessenger.post("openUrl", "https://app.continue.dev/new");
+ }
+
+ return (
+
+ {profiles.map((option, idx) => (
+
+ ))}
+
+
+
+
+
+
+
+
+
+ {getMetaKeyLabel()}' toggle assistant
+
+
+
+ );
+}
diff --git a/gui/src/components/modelSelection/platform/ModelSelect.tsx b/gui/src/components/modelSelection/platform/ModelSelect.tsx
new file mode 100644
index 000000000..4f1551b6f
--- /dev/null
+++ b/gui/src/components/modelSelection/platform/ModelSelect.tsx
@@ -0,0 +1,121 @@
+import { CubeIcon, PlusIcon } from "@heroicons/react/24/outline";
+import { useContext, useEffect, useState } from "react";
+import { lightGray } from "../..";
+import { IdeMessengerContext } from "../../../context/IdeMessenger";
+import { useAppDispatch, useAppSelector } from "../../../redux/hooks";
+import {
+ selectDefaultModel,
+ setDefaultModel,
+} from "../../../redux/slices/configSlice";
+import { getFontSize, getMetaKeyLabel } from "../../../util";
+import { Divider, Option, OptionDiv } from "./shared";
+
+export interface ModelOption {
+ value: string;
+ title: string;
+ apiKey?: string;
+}
+
+export function modelSelectTitle(model: any): string {
+ if (model?.title) return model?.title;
+ if (model?.model !== undefined && model?.model.trim() !== "") {
+ if (model?.class_name) {
+ return `${model?.class_name} - ${model?.model}`;
+ }
+ return model?.model;
+ }
+ return model?.class_name;
+}
+
+interface ModelSelectProps {
+ selectedProfileId: string;
+ onClickAddModel: (e: any) => void;
+}
+
+export function ModelSelect(props: ModelSelectProps) {
+ const dispatch = useAppDispatch();
+ const ideMessenger = useContext(IdeMessengerContext);
+ const defaultModel = useAppSelector(selectDefaultModel);
+ const allModels = useAppSelector((state) => state.config.config.models);
+ const [options, setOptions] = useState([]);
+ const [sortedOptions, setSortedOptions] = useState([]);
+
+ // Sort so that options without an API key are at the end
+ useEffect(() => {
+ const enabledOptions = options.filter((option) => option.apiKey !== "");
+ const disabledOptions = options.filter((option) => option.apiKey === "");
+
+ const sorted = [...enabledOptions, ...disabledOptions];
+
+ setSortedOptions(sorted);
+ }, [options]);
+
+ useEffect(() => {
+ setOptions(
+ allModels.map((model) => {
+ return {
+ value: model.title,
+ title: modelSelectTitle(model),
+ apiKey: model.apiKey,
+ };
+ }),
+ );
+ }, [allModels]);
+
+ function onModelChange(modelTitle: string) {
+ if (modelTitle === defaultModel?.title) return;
+ dispatch(setDefaultModel({ title: modelTitle }));
+ }
+
+ return (
+
+
+ {sortedOptions.map((option, idx) => (
+
+ ))}
+
+
+
+ {props.selectedProfileId === "local" && (
+ <>
+
+
+
+ >
+ )}
+
+
+
+
+ {getMetaKeyLabel()}⇧' toggle model
+
+
+
+ );
+}
diff --git a/gui/src/components/modelSelection/platform/shared.tsx b/gui/src/components/modelSelection/platform/shared.tsx
new file mode 100644
index 000000000..1d45fafd9
--- /dev/null
+++ b/gui/src/components/modelSelection/platform/shared.tsx
@@ -0,0 +1,113 @@
+import { Cog6ToothIcon } from "@heroicons/react/24/outline";
+import { useState } from "react";
+import styled from "styled-components";
+import { defaultBorderRadius, lightGray } from "../..";
+
+export const OptionDiv = styled.div<{
+ isDisabled?: boolean;
+ isSelected?: boolean;
+}>`
+ border-radius: ${defaultBorderRadius};
+ padding: 6px 12px;
+
+ min-width: 0px;
+
+ ${({ isDisabled, isSelected }) =>
+ !isDisabled &&
+ `
+ cursor: pointer;
+
+ &:hover {
+ background: ${lightGray}33;
+ }
+
+ ${
+ isSelected &&
+ `
+ background: ${lightGray}22;
+ `
+ }
+ `}
+
+ ${({ isDisabled }) =>
+ isDisabled &&
+ `
+ opacity: 0.5;
+ `}
+`;
+
+export const MAX_HEIGHT_PX = 300;
+
+export const Divider = styled.div`
+ height: 0.5px;
+ background-color: ${lightGray};
+`;
+
+interface ModelOptionProps {
+ children: React.ReactNode;
+ idx: number;
+ disabled: boolean;
+ selected: boolean;
+ showConfigure: boolean;
+ onConfigure: (e: any) => void;
+ onClick: () => void;
+}
+
+const IconBase = styled.div<{ $hovered: boolean }>`
+ width: 1.2em;
+ height: 1.2em;
+ cursor: pointer;
+ padding: 4px;
+ border-radius: ${defaultBorderRadius};
+ opacity: ${(props) => (props.$hovered ? 0.75 : 0)};
+ visibility: ${(props) => (props.$hovered ? "visible" : "hidden")};
+
+ &:hover {
+ opacity: 1;
+ background-color: ${lightGray}33;
+ }
+`;
+
+const StyledCog6ToothIcon = styled(IconBase).attrs({ as: Cog6ToothIcon })``;
+
+export function Option({
+ onConfigure,
+ children,
+ idx,
+ disabled,
+ onClick,
+ showConfigure,
+ selected,
+}: ModelOptionProps) {
+ const [hovered, setHovered] = useState(false);
+
+ function handleOptionClick(e) {
+ if (disabled) {
+ e.preventDefault();
+ e.stopPropagation();
+ }
+ onClick();
+ }
+
+ return (
+ setHovered(true)}
+ onMouseLeave={() => setHovered(false)}
+ isSelected={selected}
+ onClick={handleOptionClick}
+ >
+
+
+ {children}
+
+ {showConfigure && (
+
+ )}
+
+
+
+
+ );
+}
diff --git a/gui/src/context/Auth.tsx b/gui/src/context/Auth.tsx
index ca5d4f207..19d70f589 100644
--- a/gui/src/context/Auth.tsx
+++ b/gui/src/context/Auth.tsx
@@ -13,6 +13,10 @@ import ConfirmationDialog from "../components/dialogs/ConfirmationDialog";
import { useWebviewListener } from "../hooks/useWebviewListener";
import { useAppSelector } from "../redux/hooks";
import { setLastControlServerBetaEnabledStatus } from "../redux/slices/miscSlice";
+import {
+ selectAvailableProfiles,
+ setAvailableProfiles,
+} from "../redux/slices/sessionSlice";
import { setDialogMessage, setShowDialog } from "../redux/slices/uiSlice";
import { getLocalStorage, setLocalStorage } from "../util/localStorage";
import { IdeMessengerContext } from "./IdeMessenger";
@@ -34,7 +38,9 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
const [session, setSession] = useState(
undefined,
);
- const [profiles, setProfiles] = useState([]);
+
+ const profiles = useAppSelector(selectAvailableProfiles);
+
const selectedProfileId = useAppSelector(
(store) => store.session.selectedProfileId,
);
@@ -151,14 +157,16 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
ideMessenger
.request("config/listProfiles", undefined)
.then(
- (result) => result.status === "success" && setProfiles(result.content),
+ (result) =>
+ result.status === "success" &&
+ dispatch(setAvailableProfiles(result.content)),
);
}, []);
useWebviewListener(
"didChangeAvailableProfiles",
async (data) => {
- setProfiles(data.profiles);
+ dispatch(setAvailableProfiles(data.profiles));
},
[],
);
diff --git a/gui/src/redux/slices/configSlice.ts b/gui/src/redux/slices/configSlice.ts
index 35e530e47..64ab59817 100644
--- a/gui/src/redux/slices/configSlice.ts
+++ b/gui/src/redux/slices/configSlice.ts
@@ -74,6 +74,20 @@ export const configSlice = createSlice({
defaultModelTitle: payload.title,
};
},
+ cycleDefaultModel: (state, { payload }: PayloadAction<"next" | "prev">) => {
+ const currentIndex = state.config.models.findIndex(
+ (model) => model.title === state.defaultModelTitle,
+ );
+ const nextIndex =
+ (currentIndex +
+ (payload === "next" ? 1 : -1) +
+ state.config.models.length) %
+ state.config.models.length;
+ return {
+ ...state,
+ defaultModelTitle: state.config.models[nextIndex].title,
+ };
+ },
},
selectors: {
selectDefaultModel: (state) => {
@@ -93,8 +107,12 @@ export const configSlice = createSlice({
},
});
-export const { setDefaultModel, setConfigResult, setConfigError } =
- configSlice.actions;
+export const {
+ setDefaultModel,
+ cycleDefaultModel,
+ setConfigResult,
+ setConfigError,
+} = configSlice.actions;
export const {
selectDefaultModel,
diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts
index 6f91202ba..05ab1c316 100644
--- a/gui/src/redux/slices/sessionSlice.ts
+++ b/gui/src/redux/slices/sessionSlice.ts
@@ -20,14 +20,15 @@ import {
SessionMetadata,
ToolCall,
} from "core";
+import { ProfileDescription } from "core/config/ConfigHandler";
import { NEW_SESSION_TITLE } from "core/util/constants";
import { incrementalParseJson } from "core/util/incrementalParseJson";
import { renderChatMessage } from "core/util/messageContent";
+import { findUriInDirs, getUriPathBasename } from "core/util/uri";
import { v4 as uuidv4 } from "uuid";
import { RootState } from "../store";
import { streamResponseThunk } from "../thunks/streamResponse";
import { findCurrentToolCall } from "../util";
-import { findUriInDirs, getUriPathBasename } from "core/util/uri";
// We need this to handle reorderings (e.g. a mid-array deletion) of the messages array.
// The proper fix is adding a UUID to all chat messages, but this is the temp workaround.
@@ -43,6 +44,7 @@ type SessionState = {
title: string;
id: string;
selectedProfileId: string;
+ availableProfiles: ProfileDescription[];
streamAborter: AbortController;
codeToEdit: CodeToEdit[];
curCheckpointIndex: number;
@@ -82,6 +84,12 @@ const initialState: SessionState = {
title: NEW_SESSION_TITLE,
id: uuidv4(),
selectedProfileId: "local",
+ availableProfiles: [
+ {
+ id: "local",
+ title: "Local",
+ },
+ ],
curCheckpointIndex: 0,
streamAborter: new AbortController(),
codeToEdit: [],
@@ -465,8 +473,28 @@ export const sessionSlice = createSlice({
selectedProfileId: payload,
};
},
- setCurCheckpointIndex: (state, { payload }: PayloadAction) => {
- state.curCheckpointIndex = payload;
+ cycleSelectedProfileId: (state) => {
+ const profileIds = state.availableProfiles.map((profile) => profile.id);
+ const curIndex = profileIds.indexOf(state.selectedProfileId);
+ const nextIndex = (curIndex + 1) % profileIds.length;
+ return {
+ ...state,
+ selectedProfileId: profileIds[nextIndex],
+ };
+ },
+ setAvailableProfiles: (
+ state,
+ { payload }: PayloadAction,
+ ) => {
+ return {
+ ...state,
+ availableProfiles: payload,
+ selectedProfileId: payload.find(
+ (profile) => profile.id === state.selectedProfileId,
+ )
+ ? state.selectedProfileId
+ : payload[0]?.id,
+ };
},
updateCurCheckpoint: (
state,
@@ -475,6 +503,9 @@ export const sessionSlice = createSlice({
state.history[state.curCheckpointIndex].checkpoint[payload.filepath] =
payload.content;
},
+ setCurCheckpointIndex: (state, { payload }: PayloadAction) => {
+ state.curCheckpointIndex = payload;
+ },
updateApplyState: (state, { payload }: PayloadAction) => {
const applyState = state.codeBlockApplyStates.states.find(
(state) => state.streamId === payload.streamId,
@@ -577,6 +608,9 @@ export const sessionSlice = createSlice({
selectHasCodeToEdit: (state) => {
return state.codeToEdit.length > 0;
},
+ selectAvailableProfiles: (state) => {
+ return state.availableProfiles;
+ },
},
extraReducers: (builder) => {
addPassthroughCases(builder, [streamResponseThunk]);
@@ -640,6 +674,8 @@ export const {
removeCodeToEdit,
setCalling,
cancelToolCall,
+ cycleSelectedProfileId,
+ setAvailableProfiles,
acceptToolCall,
setToolGenerated,
setToolCallOutput,
@@ -655,6 +691,7 @@ export const {
selectIsInEditMode,
selectIsSingleRangeEditOrInsertion,
selectHasCodeToEdit,
+ selectAvailableProfiles,
} = sessionSlice.selectors;
export default sessionSlice.reducer;