assistants toggle

This commit is contained in:
Nate 2025-01-07 17:22:19 -08:00
parent a57b5efa26
commit 3acffa445c
14 changed files with 602 additions and 46 deletions

8
gui/package-lock.json generated
View file

@ -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"

View file

@ -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",

View file

@ -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;

View file

@ -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"
>
<div className="flex items-center justify-start gap-2 whitespace-nowrap">
<ModelSelect />
{USE_PLATFORM ? <AssistantAndModelSelect /> : <ModelSelect />}
<div className="xs:flex -mb-1 hidden items-center text-gray-400 transition-colors duration-200">
{props.toolbarOptions?.hideImageUpload ||
(supportsImages && (

View file

@ -0,0 +1,26 @@
import { Transition } from "@headlessui/react";
export default function PopoverTransition({
children,
show,
afterLeave,
}: {
children: React.ReactNode;
show?: boolean;
afterLeave?: () => void;
}) {
return (
<Transition
show={show}
enter="transition duration-100 ease-out"
enterFrom="transform scale-95 opacity-0"
enterTo="transform scale-100 opacity-100"
leave="transition duration-75 ease-out"
leaveFrom="transform scale-100 opacity-100"
leaveTo="transform scale-95 opacity-0"
afterLeave={afterLeave}
>
{children}
</Transition>
);
}

View file

@ -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<HTMLButtonElement>(null);
@ -87,14 +86,8 @@ export default function ToolDropdown() {
>
<EllipsisHorizontalIcon className="h-3 w-3 cursor-pointer hover:brightness-125" />
</Listbox.Button>
<Transition
<PopoverTransition
show={open}
enter="transition duration-100 ease-out"
enterFrom="transform scale-95 opacity-0"
enterTo="transform scale-100 opacity-100"
leave="transition duration-75 ease-out"
leaveFrom="transform scale-100 opacity-100"
leaveTo="transform scale-95 opacity-0"
afterLeave={() => setDropdownOpen(false)}
>
<Listbox.Options
@ -153,7 +146,7 @@ export default function ToolDropdown() {
))}
</div>
</Listbox.Options>
</Transition>
</PopoverTransition>
</>
)}
</Listbox>

View file

@ -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;

View file

@ -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<HTMLButtonElement>(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(
<AddModelForm
onDone={() => {
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 (
<Popover>
<div className="relative">
<StyledPopoverButton
data-testid="model-select-button"
ref={buttonRef}
className="h-[18px] overflow-hidden"
style={{ padding: 0 }}
onClick={calculatePosition}
>
<div className="flex max-w-[33vw] items-center gap-0.5 text-gray-400 transition-colors duration-200">
<span className="truncate">
{modelSelectTitle(defaultModel) || "Select model"}{" "}
</span>
<ChevronDownIcon
className="h-3 w-3 flex-shrink-0"
aria-hidden="true"
/>
</div>
</StyledPopoverButton>
<PopoverTransition>
<StyledPopoverPanel
$showabove={showAbove}
className="flex max-w-[90vw] overflow-hidden"
style={{ zIndex: 1000 }}
>
<AssistantSelect />
<ModelSelect
selectedProfileId={selectedProfileId}
onClickAddModel={onClickAddModel}
/>
</StyledPopoverPanel>
</PopoverTransition>
</div>
</Popover>
);
}
export default AssistantAndModelSelect;

View file

@ -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 (
<div className="border-lightgray flex min-w-0 flex-col border-0 border-r-[0.5px] border-solid pt-0">
{profiles.map((option, idx) => (
<Option
idx={idx}
disabled={false}
showConfigure={true}
selected={option.id === selectedProfile?.id}
onConfigure={(e) => {
e.stopPropagation();
e.preventDefault();
ideMessenger.post("config/openProfile", {
profileId: option.id,
});
}}
onClick={() => changeProfileId(option.id)}
>
<div className="flex flex-grow items-center">
{option.id === "local" ? (
<DocumentIcon className="mr-2 h-4 w-4 flex-shrink-0" />
) : (
<SparklesIcon
className="mr-2 h-4 w-4 flex-shrink-0"
color={option.id === selectedProfile?.id ? "yellow" : undefined}
/>
)}
<span className="lines lines-1 relative flex h-5 items-center justify-between gap-3 overflow-hidden text-ellipsis pr-2 text-xs sm:max-w-32">
{option.title}
</span>
</div>
</Option>
))}
<div className="mt-auto w-full">
<OptionDiv key={profiles.length} onClick={onNewAssistant}>
<div className="flex items-center py-0.5">
<PlusIcon className="mr-2 h-4 w-4" />
New Assistant
</div>
</OptionDiv>
<Divider className="!my-0" />
<span
className="block px-3 py-2"
style={{ color: lightGray, fontSize: getFontSize() - 4 }}
>
<code>{getMetaKeyLabel()}'</code> toggle assistant
</span>
</div>
</div>
);
}

View file

@ -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<ModelOption[]>([]);
const [sortedOptions, setSortedOptions] = useState<ModelOption[]>([]);
// 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 (
<div className="xs:flex hidden h-full min-w-0 flex-col">
<div>
{sortedOptions.map((option, idx) => (
<Option
idx={idx}
key={idx}
onClick={() => onModelChange(option.title)}
disabled={option.apiKey === ""}
selected={option.title === defaultModel?.title}
showConfigure={false}
onConfigure={() => {}}
>
<div className="flex flex-grow items-center">
<CubeIcon className="mr-2 h-4 w-4 flex-shrink-0" />
<span className="flex-grow">
{option.title}
{option.apiKey === "" && (
<span className="ml-2 text-[10px] italic">
(Missing API key)
</span>
)}
</span>
</div>
</Option>
))}
</div>
<div className="mt-auto">
{props.selectedProfileId === "local" && (
<>
<OptionDiv key={options.length} onClick={props.onClickAddModel}>
<div className="flex items-center py-0.5">
<PlusIcon className="mr-2 h-4 w-4" />
Add Chat model
</div>
</OptionDiv>
</>
)}
<Divider className="!my-0" />
<span
className="block px-3 py-2"
style={{ color: lightGray, fontSize: getFontSize() - 4 }}
>
<code>{getMetaKeyLabel()}⇧'</code> toggle model
</span>
</div>
</div>
);
}

View file

@ -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 (
<OptionDiv
key={idx}
isDisabled={disabled}
onMouseEnter={() => setHovered(true)}
onMouseLeave={() => setHovered(false)}
isSelected={selected}
onClick={handleOptionClick}
>
<div className="flex w-full flex-col gap-0.5">
<div className="flex w-full items-center justify-between">
{children}
<div className="ml-5 flex items-center">
{showConfigure && (
<StyledCog6ToothIcon $hovered={hovered} onClick={onConfigure} />
)}
</div>
</div>
</div>
</OptionDiv>
);
}

View file

@ -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<ControlPlaneSessionInfo | undefined>(
undefined,
);
const [profiles, setProfiles] = useState<ProfileDescription[]>([]);
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));
},
[],
);

View file

@ -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,

View file

@ -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<number>) => {
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<ProfileDescription[]>,
) => {
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<number>) => {
state.curCheckpointIndex = payload;
},
updateApplyState: (state, { payload }: PayloadAction<ApplyState>) => {
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;