feat: add "Gathering context..." indicator

This commit is contained in:
Test 2024-09-26 17:02:39 -07:00
parent da2c3d5189
commit dd865eadea
16 changed files with 245 additions and 215 deletions

View file

@ -13,6 +13,7 @@ import { getModelQuickPickVal } from "./ModelSelectionQuickPick";
import { ConfigHandler } from "core/config/ConfigHandler";
// @ts-ignore
import { getModelByRole } from "core/config/util";
// @ts-ignore
import MiniSearch from "minisearch";
/**

View file

@ -1,4 +1,4 @@
import React, { useState } from "react";
import React from "react";
import ReactDOM from "react-dom";
import { type PlacesType } from "react-tooltip";
import { HeaderButton } from ".";
@ -25,7 +25,6 @@ const ButtonWithTooltip = React.forwardRef<
HTMLButtonElement,
HeaderButtonWithTextProps
>((props: HeaderButtonWithTextProps, ref) => {
const [hover, setHover] = useState(false);
const id = uuidv4();
const tooltipPortalDiv = document.getElementById("tooltip-portal-div");
@ -39,14 +38,6 @@ const ButtonWithTooltip = React.forwardRef<
data-tooltip-id={tooltipId}
inverted={props.inverted}
disabled={props.disabled}
onMouseEnter={() => {
if (!props.disabled) {
setHover(true);
}
}}
onMouseLeave={() => {
setHover(false);
}}
onClick={props.onClick}
onKeyDown={props.onKeyDown}
className={props.className}

View file

@ -10,7 +10,7 @@ import { stripImages } from "core/llm/images";
import { useContext, useEffect, useState } from "react";
import { useSelector } from "react-redux";
import styled from "styled-components";
import { defaultBorderRadius, vscBackground, vscInputBackground } from "..";
import { vscBackground, vscInputBackground } from "..";
import { IdeMessengerContext } from "../../context/IdeMessenger";
import useUIConfig from "../../hooks/useUIConfig";
import { RootState } from "../../redux/store";
@ -34,18 +34,15 @@ interface StepContainerProps {
}
const ContentDiv = styled.div<{ isUserInput: boolean; fontSize?: number }>`
padding: 4px 0px 8px 0px;
padding-top: 4px;
background-color: ${(props) =>
props.isUserInput ? vscInputBackground : vscBackground};
font-size: ${(props) => props.fontSize || getFontSize()}px;
// border-radius: ${defaultBorderRadius};
overflow: hidden;
`;
function StepContainer(props: StepContainerProps) {
const [isHovered, setIsHovered] = useState(false);
const active = useSelector((store: RootState) => store.state.active);
const history = useSelector((state: RootState) => state.state.history);
const [truncatedEarly, setTruncatedEarly] = useState(false);
const ideMessenger = useContext(IdeMessengerContext);
const [feedback, setFeedback] = useState<boolean | undefined>(undefined);
@ -53,6 +50,8 @@ function StepContainer(props: StepContainerProps) {
const isUserInput = props.item.message.role === "user";
const uiConfig = useUIConfig();
const shouldRenderActions = !props.isLast || (props.isLast && !active);
useEffect(() => {
if (!active) {
const content = stripImages(props.item.message.content).trim();
@ -85,98 +84,72 @@ function StepContainer(props: StepContainerProps) {
};
return (
<div
onMouseEnter={() => {
setIsHovered(true);
}}
onMouseLeave={() => {
setIsHovered(false);
}}
>
<div className="relative">
<ContentDiv
hidden={!props.open}
isUserInput={isUserInput}
fontSize={getFontSize()}
>
{uiConfig?.displayRawMarkdown ? (
<pre
className="whitespace-pre-wrap break-words p-4 max-w-full overflow-x-auto"
style={{ fontSize: getFontSize() - 2 }}
<div className="relative">
<ContentDiv
hidden={!props.open}
isUserInput={isUserInput}
fontSize={getFontSize()}
>
{uiConfig?.displayRawMarkdown ? (
<pre
className="whitespace-pre-wrap break-words p-4 max-w-full overflow-x-auto"
style={{ fontSize: getFontSize() - 2 }}
>
{stripImages(props.item.message.content)}
</pre>
) : (
<StyledMarkdownPreview
showCodeBorder
source={stripImages(props.item.message.content)}
/>
)}
</ContentDiv>
{shouldRenderActions && (
<div className="flex items-center justify-end gap-0.5 xs:flex text-xs text-gray-400 p-2 cursor-default">
{truncatedEarly && (
<ButtonWithTooltip
tabIndex={-1}
text="Continue generation"
onClick={props.onContinueGeneration}
>
{stripImages(props.item.message.content)}
</pre>
) : (
<StyledMarkdownPreview
source={stripImages(props.item.message.content)}
showCodeBorder={true}
/>
<BarsArrowDownIcon className="h-3.5 w-3.5 text-gray-500" />
</ButtonWithTooltip>
)}
</ContentDiv>
{(props.isLast || isHovered || typeof feedback !== "undefined") &&
!active && (
<div className="flex items-center gap-1 absolute -bottom-2 right-2 hidden xs:flex text-xs text-gray-400">
{props.modelTitle && (
<div className="hidden sm:flex">
<div className="flex items-center truncate max-w-[40vw]">
{props.modelTitle}
</div>
<div className="ml-2 mr-1 w-px h-5 bg-gray-400" />
</div>
)}
{truncatedEarly && (
<ButtonWithTooltip
tabIndex={-1}
text="Continue generation"
onClick={props.onContinueGeneration}
>
<BarsArrowDownIcon className="h-4 w-4" />
</ButtonWithTooltip>
)}
<CopyButton
tabIndex={-1}
text={stripImages(props.item.message.content)}
/>
<ButtonWithTooltip
tabIndex={-1}
text="Regenerate"
onClick={props.onRetry}
>
<ArrowPathIcon className="h-4 w-4" />
</ButtonWithTooltip>
{feedback === false || (
<ButtonWithTooltip text="Helpful" tabIndex={-1}>
<HandThumbUpIcon
className="h-4 w-4"
onClick={() => {
sendFeedback(true);
}}
/>
</ButtonWithTooltip>
)}
{feedback === true || (
<ButtonWithTooltip text="Unhelpful" tabIndex={-1}>
<HandThumbDownIcon
className="h-4 w-4"
onClick={() => {
sendFeedback(false);
}}
/>
</ButtonWithTooltip>
)}
{props.index !== 1 && (
<ButtonWithTooltip text="Delete" tabIndex={-1}>
<TrashIcon className="h-4 w-4" onClick={props.onDelete} />
</ButtonWithTooltip>
)}
</div>
{props.index !== 1 && (
<ButtonWithTooltip
text="Delete"
tabIndex={-1}
onClick={props.onDelete}
>
<TrashIcon className="h-3.5 w-3.5 text-gray-500" />
</ButtonWithTooltip>
)}
</div>
<CopyButton
tabIndex={-1}
text={stripImages(props.item.message.content)}
clipboardIconClassName="h-3.5 w-3.5 text-gray-500"
/>
<ButtonWithTooltip
text="Helpful"
tabIndex={-1}
onClick={() => sendFeedback(true)}
>
<HandThumbUpIcon className="h-3.5 w-3.5 text-gray-500 mx-0.5" />
</ButtonWithTooltip>
<ButtonWithTooltip
text="Unhelpful"
tabIndex={-1}
onClick={() => sendFeedback(false)}
>
<HandThumbDownIcon className="h-3.5 w-3.5 text-gray-500" />
</ButtonWithTooltip>
</div>
)}
</div>
);
}

View file

@ -1,7 +1,7 @@
import { ChevronDownIcon, ChevronRightIcon } from "@heroicons/react/24/outline";
import { ContextItemWithId } from "core";
import { contextItemToRangeInFileWithContents } from "core/commands/util";
import React, { useContext } from "react";
import { useContext, useState } from "react";
import { lightGray, vscBackground } from "..";
import { IdeMessengerContext } from "../../context/IdeMessenger";
import { getFontSize } from "../../util";
@ -9,15 +9,39 @@ import FileIcon from "../FileIcon";
import SafeImg from "../SafeImg";
import { INSTRUCTIONS_BASE_ITEM } from "core/context/providers/utils";
import { getIconFromDropdownItem } from "./MentionList";
import styled from "styled-components";
interface ContextItemsPeekProps {
contextItems?: ContextItemWithId[];
isGatheringContext: boolean;
}
interface ContextItemsPeekItemProps {
contextItem: ContextItemWithId;
}
const AnimatedEllipsis = styled.span`
&::after {
content: ".";
animation: ellipsis 2.5s infinite;
display: inline-block;
width: 12px;
text-align: left;
}
@keyframes ellipsis {
0% {
content: ".";
}
33% {
content: "..";
}
66% {
content: "...";
}
}
`;
function ContextItemsPeekItem({ contextItem }: ContextItemsPeekItemProps) {
const ideMessenger = useContext(IdeMessengerContext);
@ -116,53 +140,49 @@ function ContextItemsPeekItem({ contextItem }: ContextItemsPeekItemProps) {
);
}
function ContextItemsPeek({ contextItems }: ContextItemsPeekProps) {
const [open, setOpen] = React.useState(false);
function ContextItemsPeek({
contextItems,
isGatheringContext,
}: ContextItemsPeekProps) {
const [open, setOpen] = useState(false);
const ctxItems = contextItems?.filter(
(ctxItem) => !ctxItem.name.includes(INSTRUCTIONS_BASE_ITEM.name),
);
if (!ctxItems || ctxItems.length === 0) {
if ((!ctxItems || ctxItems.length === 0) && !isGatheringContext) {
return null;
}
const contextItemsText = `${ctxItems.length} context ${
ctxItems.length > 1 ? "items" : "item"
}`;
return (
<div
className="pl-2 pt-2"
style={{
backgroundColor: vscBackground,
}}
>
<div className={`pl-2 pt-2 bg-[${vscBackground}]`}>
<div
className="text-gray-300 cursor-pointer flex justify-start items-center"
style={{
fontSize: `${getFontSize() - 3}px`,
}}
className="text-gray-300 cursor-pointer flex justify-start items-center text-xs"
onClick={() => setOpen((prev) => !prev)}
>
<div className="relative w-4 h-4 mr-1">
<ChevronRightIcon
className={`absolute h-4 w-4 transition-all duration-200 ease-in-out ${
className={`absolute h-4 w-4 transition-all duration-200 ease-in-out text-[${lightGray}] ${
open ? "opacity-0 rotate-90" : "opacity-100 rotate-0"
}`}
style={{ color: lightGray }}
/>
<ChevronDownIcon
className={`absolute h-4 w-4 transition-all duration-200 ease-in-out ${
className={`absolute h-4 w-4 transition-all duration-200 ease-in-out text-[${lightGray}] ${
open ? "opacity-100 rotate-0" : "opacity-0 -rotate-90"
}`}
style={{ color: lightGray }}
/>
</div>
<span
className={`ml-1 text-xs text-gray-400 hover:text-gray-300 transition-colors duration-200`}
>
{contextItemsText}
<span className="ml-1 text-xs text-gray-400 transition-colors duration-200">
{isGatheringContext ? (
<>
Gathering context
<AnimatedEllipsis />
</>
) : (
`${ctxItems.length} context ${
ctxItems.length > 1 ? "items" : "item"
}`
)}
</span>
</div>
@ -171,9 +191,10 @@ function ContextItemsPeek({ contextItems }: ContextItemsPeekProps) {
open ? "max-h-[50vh] opacity-100" : "max-h-0 opacity-0"
}`}
>
{ctxItems.map((contextItem, idx) => (
<ContextItemsPeekItem key={idx} contextItem={contextItem} />
))}
{ctxItems &&
ctxItems.map((contextItem, idx) => (
<ContextItemsPeekItem key={idx} contextItem={contextItem} />
))}
</div>
</div>
);

View file

@ -9,6 +9,16 @@ import { newSession, setMessageAtIndex } from "../../redux/slices/stateSlice";
import { RootState } from "../../redux/store";
import ContextItemsPeek from "./ContextItemsPeek";
import TipTapEditor from "./TipTapEditor";
import { useState, useRef, useEffect } from "react";
interface ContinueInputBoxProps {
isLastUserInput: boolean;
isMainInput?: boolean;
onEnter: (editorState: JSONContent, modifiers: InputModifiers) => void;
editorState?: JSONContent;
contextItems?: ContextItemWithId[];
hidden?: boolean;
}
const gradient = keyframes`
0% {
@ -22,8 +32,6 @@ const gradient = keyframes`
const GradientBorder = styled.div<{
borderRadius?: string;
borderColor?: string;
isFirst: boolean;
isLast: boolean;
loading: 0 | 1;
}>`
border-radius: ${(props) => props.borderRadius || "0"};
@ -47,18 +55,8 @@ const GradientBorder = styled.div<{
display: flex;
flex-direction: row;
align-items: center;
margin-top: 8px;
`;
interface ContinueInputBoxProps {
isLastUserInput: boolean;
isMainInput?: boolean;
onEnter: (editorState: JSONContent, modifiers: InputModifiers) => void;
editorState?: JSONContent;
contextItems?: ContextItemWithId[];
hidden?: boolean;
}
function ContinueInputBox(props: ContinueInputBoxProps) {
const dispatch = useDispatch();
@ -67,6 +65,12 @@ function ContinueInputBox(props: ContinueInputBoxProps) {
const availableContextProviders = useSelector(
(store: RootState) => store.state.config.contextProviders,
);
const isGatheringContextStore = useSelector(
(store: RootState) => store.state.isGatheringContext,
);
const [isGatheringContext, setIsGatheringContext] = useState(false);
const timeoutRef = useRef<NodeJS.Timeout | null>(null);
useWebviewListener(
"newSessionWithPrompt",
@ -84,24 +88,31 @@ function ContinueInputBox(props: ContinueInputBoxProps) {
[props.isMainInput],
);
console.log({ isGatheringContext, isGatheringContextStore });
useEffect(() => {
if (isGatheringContextStore && !isGatheringContext) {
// 500ms delay when going from false -> true to prevent flashing loading indicator
timeoutRef.current = setTimeout(() => setIsGatheringContext(true), 500);
} else {
// Update immediately otherwise (i.e. true -> false)
setIsGatheringContext(isGatheringContextStore);
}
return () => {
if (timeoutRef.current) {
clearTimeout(timeoutRef.current);
}
};
}, [isGatheringContextStore]);
return (
<div
style={{
paddingTop: "4px",
backgroundColor: vscBackground,
display: props.hidden ? "none" : "inherit",
}}
className={`pt-1 bg-[${vscBackground}] ${props.hidden ? "hidden" : ""}`}
>
<div
className="flex px-2 relative"
style={{
backgroundColor: vscBackground,
}}
>
<div className={`flex px-2 relative bg-[${vscBackground}]`}>
<GradientBorder
loading={active && props.isLastUserInput ? 1 : 0}
isFirst={false}
isLast={false}
borderColor={
active && props.isLastUserInput ? undefined : vscBackground
}
@ -113,10 +124,13 @@ function ContinueInputBox(props: ContinueInputBoxProps) {
isMainInput={props.isMainInput ?? false}
availableContextProviders={availableContextProviders ?? []}
availableSlashCommands={availableSlashCommands}
></TipTapEditor>
/>
</GradientBorder>
</div>
<ContextItemsPeek contextItems={props.contextItems}></ContextItemsPeek>
<ContextItemsPeek
contextItems={props.contextItems}
isGatheringContext={isGatheringContext && props.isLastUserInput}
></ContextItemsPeek>
</div>
);
}

View file

@ -59,11 +59,6 @@ const EnterButton = styled.div`
border-radius: ${defaultBorderRadius};
color: ${vscForeground};
cursor: pointer;
&:hover {
background-color: ${vscBadgeBackground};
color: ${vscBadgeForeground};
}
`;
interface InputToolbarProps {
@ -100,7 +95,7 @@ function InputToolbar(props: InputToolbarProps) {
>
<div className="flex gap-2 items-center whitespace-nowrap justify-start">
<ModelSelect />
<div className="items-center hidden xs:flex gap-1 text-gray-400 transition-colors duration-200">
<div className="items-center hidden xs:flex gap-1 text-gray-400 transition-colors duration-200 -mb-1">
{supportsImages && (
<>
<input
@ -114,7 +109,7 @@ function InputToolbar(props: InputToolbarProps) {
}
}}
/>
<HoverItem className="hover:text-gray-300">
<HoverItem>
<PhotoIcon
className="h-4 w-4"
onClick={(e) => {
@ -125,37 +120,22 @@ function InputToolbar(props: InputToolbarProps) {
</>
)}
<HoverItem
className="hover:text-gray-300"
onClick={props.onAddContextItem}
>
<HoverItem onClick={props.onAddContextItem}>
<AtSymbolIcon className="h-4 w-4" />
</HoverItem>
<HoverItem
className="hover:text-gray-300"
onClick={props.onAddSlashCommand}
style={{ paddingLeft: 0 }}
>
<SlashIcon className="h-4 w-4" />
</HoverItem>
</div>
</div>
<div className="flex items-center gap-2 whitespace-nowrap text-gray-400 ">
<div className="hidden sm:flex transition-colors duration-200">
<div className="hidden sm:flex transition-colors duration-200 hover:underline">
{props.activeKey === "Alt" ? (
<HoverItem className="text-gray-300 ">
<HoverItem className="underline">
{`${getAltKeyLabel()}⏎
${useActiveFile ? "No active file" : "Active file"}`}
</HoverItem>
) : (
<HoverItem
className={
props.activeKey === "Meta"
? "text-gray-300"
: "hover:text-gray-300"
}
className={props.activeKey === "Meta" && "underline"}
onClick={(e) =>
props.onEnter({
useCodebase: true,

View file

@ -207,4 +207,30 @@ function resolveParagraph(p: JSONContent): [string, MentionAttrs[], string] {
return [text, contextItems, slashCommand];
}
export function hasSlashCommandOrContextProvider(
editorState: JSONContent,
): boolean {
if (!editorState.content) {
return false;
}
for (const p of editorState.content) {
if (p.type === "paragraph" && p.content) {
for (const child of p.content) {
if (child.type === "slashcommand") {
return true;
}
if (
child.type === "mention" &&
child.attrs?.itemType === "contextProvider"
) {
return true;
}
}
}
}
return false;
}
export default resolveEditorContent;

View file

@ -18,12 +18,7 @@ import {
import { IdeMessengerContext } from "../../context/IdeMessenger";
import { useWebviewListener } from "../../hooks/useWebviewListener";
import { incrementNextCodeBlockToApplyIndex } from "../../redux/slices/uiStateSlice";
import {
getAltKeyLabel,
getFontSize,
getMetaKeyLabel,
isJetBrains,
} from "../../util";
import { getFontSize, getMetaKeyLabel, isJetBrains } from "../../util";
import FileIcon from "../FileIcon";
import ButtonWithTooltip from "../ButtonWithTooltip";
import { CopyButton as CopyButtonHeader } from "./CopyButton";

View file

@ -6,11 +6,17 @@ import ButtonWithTooltip from "../ButtonWithTooltip";
interface CopyButtonProps {
text: string | (() => string);
color?: string;
tabIndex?: number;
checkIconClassName?: string;
clipboardIconClassName?: string;
}
export function CopyButton(props: CopyButtonProps) {
export function CopyButton({
text,
tabIndex,
checkIconClassName = "h-4 w-4 text-green-400",
clipboardIconClassName = "h-4 w-4 text-gray-400",
}: CopyButtonProps) {
const [copied, setCopied] = useState<boolean>(false);
const ideMessenger = useContext(IdeMessengerContext);
@ -18,15 +24,14 @@ export function CopyButton(props: CopyButtonProps) {
return (
<>
<ButtonWithTooltip
tabIndex={props.tabIndex}
tabIndex={tabIndex}
text={copied ? "Copied!" : "Copy"}
onClick={(e) => {
const text =
typeof props.text === "string" ? props.text : props.text();
const textVal = typeof text === "string" ? text : text();
if (isJetBrains()) {
ideMessenger.request("copyText", { text });
ideMessenger.request("copyText", { text: textVal });
} else {
navigator.clipboard.writeText(text);
navigator.clipboard.writeText(textVal);
}
setCopied(true);
@ -34,9 +39,9 @@ export function CopyButton(props: CopyButtonProps) {
}}
>
{copied ? (
<CheckIcon className="w-4 h-4 text-green-500" />
<CheckIcon className={checkIconClassName} />
) : (
<ClipboardIcon className="w-4 h-4 text-inherit" />
<ClipboardIcon className={clipboardIconClassName} />
)}
</ButtonWithTooltip>
</>

View file

@ -29,8 +29,7 @@ const StyledMarkdown = styled.div<{
overflow-x: scroll;
overflow-y: hidden;
padding: 6px;
margin: 0px;
padding: 6px 8px;
}
code {
@ -64,6 +63,14 @@ const StyledMarkdown = styled.div<{
ul {
line-height: 1.5;
}
> *:first-child {
margin-top: 8px;
}
> *:last-child {
margin-bottom: 0;
}
`;
interface StyledMarkdownPreviewProps {

View file

@ -9,6 +9,7 @@ const StyledPre = styled.pre<{ theme: any }>`
}
margin-top: 0;
margin-bottom: 0;
border-radius: 0 0 ${defaultBorderRadius} ${defaultBorderRadius} !important;
${(props) =>

View file

@ -318,7 +318,7 @@ function ModelSelect() {
style={{ padding: 0 }}
onClick={calculatePosition}
>
<div className="text-gray-400 hover:text-gray-300 transition-colors duration-200 flex items-center gap-0.5 max-w-[33vw]">
<div className="text-gray-400 transition-colors duration-200 flex items-center gap-0.5 max-w-[33vw]">
<span className="truncate">
{modelSelectTitle(defaultModel) || "Select model"}{" "}
</span>

View file

@ -141,11 +141,7 @@ function ModelSelectionListbox({
<StyledListboxOption
selected={selectedProvider.title === option.title}
key={index}
className={({ active }: { active: boolean }) =>
`relative cursor-default select-none py-2 pl-10 pr-4 ${
active ? "bg-amber-100 text-amber-900" : "text-gray-900"
}`
}
className="relative cursor-default select-none py-2 pl-10 pr-4 text-gray-900"
value={option}
>
{({ selected }) => (

View file

@ -17,7 +17,9 @@ import { getBasename, getRelativePath } from "core/util";
import { usePostHog } from "posthog-js/react";
import { useEffect, useRef } from "react";
import { useSelector } from "react-redux";
import resolveEditorContent from "../components/mainInput/resolveInput";
import resolveEditorContent, {
hasSlashCommandOrContextProvider,
} from "../components/mainInput/resolveInput";
import { IIdeMessenger } from "../context/IdeMessenger";
import { defaultModelSelector } from "../redux/selectors/modelSelectors";
import {
@ -27,6 +29,7 @@ import {
initNewActiveMessage,
resubmitAtIndex,
setInactive,
setIsGatheringContext,
setMessageAtIndex,
streamUpdate,
} from "../redux/slices/stateSlice";
@ -52,6 +55,7 @@ function useChatHandler(dispatch: Dispatch, ideMessenger: IIdeMessenger) {
const history = useSelector((store: RootState) => store.state.history);
const active = useSelector((store: RootState) => store.state.active);
const activeRef = useRef(active);
useEffect(() => {
activeRef.current = active;
}, [active]);
@ -182,6 +186,13 @@ function useChatHandler(dispatch: Dispatch, ideMessenger: IIdeMessenger) {
// Reset current code block index
dispatch(resetNextCodeBlockToApplyIndex());
const shouldGatherContext =
modifiers.useCodebase || hasSlashCommandOrContextProvider(editorState);
if (shouldGatherContext) {
dispatch(setIsGatheringContext(true));
}
// Resolve context providers and construct new history
const [selectedContextItems, selectedCode, content] =
await resolveEditorContent(
@ -191,14 +202,17 @@ function useChatHandler(dispatch: Dispatch, ideMessenger: IIdeMessenger) {
defaultContextProviders,
);
dispatch(setIsGatheringContext(false));
// Automatically use currently open file
if (!modifiers.noContext) {
const usingFreeTrial = defaultModel?.provider === "free-trial";
const currentFilePath = await ideMessenger.ide.getCurrentFile();
if (typeof currentFilePath === "string") {
let currentFileContents =
await ideMessenger.ide.readFile(currentFilePath);
let currentFileContents = await ideMessenger.ide.readFile(
currentFilePath,
);
if (usingFreeTrial) {
currentFileContents = currentFileContents
.split("\n")
@ -219,18 +233,17 @@ function useChatHandler(dispatch: Dispatch, ideMessenger: IIdeMessenger) {
});
}
}
dispatch(addContextItems(contextItems));
const message: ChatMessage = {
role: "user",
content,
};
const historyItem: ChatHistoryItem = {
message,
contextItems: selectedContextItems,
// : typeof index === "number"
// ? history[index].contextItems
// : contextItems,
editorState,
};

View file

@ -102,7 +102,6 @@ const StepsDiv = styled.div`
.thread-message {
margin: 8px 4px 0 4px;
padding-bottom: 8px;
}
`;

View file

@ -37,6 +37,7 @@ type State = {
contextItems: ContextItemWithId[];
ttsActive: boolean;
active: boolean;
isGatheringContext: boolean;
config: BrowserSerializedContinueConfig;
title: string;
sessionId: string;
@ -50,6 +51,7 @@ const initialState: State = {
contextItems: [],
ttsActive: false,
active: false,
isGatheringContext: false,
config: {
slashCommands: [
{
@ -113,6 +115,9 @@ export const stateSlice = createSlice({
setActive: (state) => {
state.active = true;
},
setIsGatheringContext: (state, { payload }: PayloadAction<boolean>) => {
state.isGatheringContext = payload;
},
clearLastResponse: (state) => {
if (state.history.length < 2) {
return;
@ -264,6 +269,7 @@ export const stateSlice = createSlice({
historyItem.contextItems.push(...payload.contextItems);
},
setInactive: (state) => {
state.isGatheringContext = false;
state.active = false;
},
streamUpdate: (state, action: PayloadAction<string>) => {
@ -453,5 +459,7 @@ export const {
consumeMainEditorContent,
setSelectedProfileId,
deleteMessage,
setIsGatheringContext,
} = stateSlice.actions;
export default stateSlice.reducer;