feat: bugfixes on redux schema updates
This commit is contained in:
parent
438cba4501
commit
4efd661375
12 changed files with 46 additions and 60 deletions
|
|
@ -10,13 +10,13 @@ import {
|
|||
IGNORE_PATH_PATTERNS,
|
||||
LanguageName,
|
||||
} from "../../../util/treeSitter";
|
||||
import { AstPath } from "../../util/ast";
|
||||
import { ImportDefinitionsService } from "../ImportDefinitionsService";
|
||||
import { AutocompleteSnippetDeprecated } from "../../types";
|
||||
import {
|
||||
AutocompleteCodeSnippet,
|
||||
AutocompleteSnippetType,
|
||||
} from "../../snippets/types";
|
||||
import { AutocompleteSnippetDeprecated } from "../../types";
|
||||
import { AstPath } from "../../util/ast";
|
||||
import { ImportDefinitionsService } from "../ImportDefinitionsService";
|
||||
|
||||
function getSyntaxTreeString(
|
||||
node: Parser.SyntaxNode,
|
||||
|
|
@ -112,7 +112,6 @@ export class RootPathContextService {
|
|||
);
|
||||
snippets.push(...newSnippets);
|
||||
} catch (e) {
|
||||
debugger;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,7 +96,6 @@ class HistoryManager {
|
|||
title: session.title,
|
||||
workspaceDirectory: session.workspaceDirectory,
|
||||
history: session.history,
|
||||
checkpoints: session.checkpoints,
|
||||
};
|
||||
fs.writeFileSync(
|
||||
getSessionFilePath(session.sessionId),
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ export default function FeedbackButtons({ item }: FeedbackButtonsProps) {
|
|||
<HandThumbDownIcon
|
||||
className={`h-3.5 w-3.5 ${feedback === false ? "text-red-400" : "text-gray-500"}`}
|
||||
/>
|
||||
</HeaderButtonWithToolTip>{" "}
|
||||
</HeaderButtonWithToolTip>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ export default function StepContainer(props: StepContainerProps) {
|
|||
// );
|
||||
const uiConfig = useAppSelector(selectUIConfig);
|
||||
const shouldHideActions = isStreaming && props.isLast;
|
||||
|
||||
// const isStepAheadOfCurCheckpoint =
|
||||
// isInEditMode && Math.floor(props.index / 2) > curCheckpointIndex;
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ function ChatIndexingPeek({ state }: ChatIndexingPeekProps) {
|
|||
>
|
||||
<div className="group flex flex-1 cursor-pointer flex-row items-center gap-2">
|
||||
<div className={`flex flex-row items-center gap-2`}>
|
||||
<p className="m-0 p-0 text-stone-500 group-hover:underline">
|
||||
<p className="m-0 p-0 text-xs text-stone-500 group-hover:underline">
|
||||
{state.displayName}
|
||||
</p>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
import { Editor, JSONContent } from "@tiptap/react";
|
||||
import { ContextItemWithId, InputModifiers } from "core";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { useDispatch } from "react-redux";
|
||||
import styled, { keyframes } from "styled-components";
|
||||
import { defaultBorderRadius, vscBackground } from "..";
|
||||
import { useWebviewListener } from "../../hooks/useWebviewListener";
|
||||
import { selectSlashCommands } from "../../redux/selectors";
|
||||
import { newSession, setMessageAtIndex } from "../../redux/slices/sessionSlice";
|
||||
import { RootState } from "../../redux/store";
|
||||
import ContextItemsPeek from "./ContextItemsPeek";
|
||||
import TipTapEditor from "./TipTapEditor";
|
||||
import { useAppSelector } from "../../redux/hooks";
|
||||
|
|
|
|||
|
|
@ -190,7 +190,6 @@ function TipTapEditor(props: TipTapEditorProps) {
|
|||
const isInEditMode = useAppSelector(
|
||||
(state) => state.editModeState.isInEditMode,
|
||||
);
|
||||
|
||||
const shouldAddFileForEditing = useAppSelector(
|
||||
(state) => state.ui.shouldAddFileForEditing,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { ChevronDownIcon } from "@heroicons/react/24/outline";
|
||||
import { debounce } from "lodash";
|
||||
import { useContext, useEffect, useRef, useState } from "react";
|
||||
import styled, { css, keyframes } from "styled-components";
|
||||
import styled from "styled-components";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { defaultBorderRadius, lightGray, vscEditorBackground } from "../..";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
|
|
@ -16,28 +16,13 @@ import { useAppSelector } from "../../../redux/hooks";
|
|||
import { selectDefaultModel } from "../../../redux/slices/configSlice";
|
||||
import { selectApplyStateBySessionId } from "../../../redux/slices/sessionSlice";
|
||||
|
||||
const fadeInAnimation = keyframes`
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
`;
|
||||
|
||||
const TopDiv = styled.div<{ active?: boolean }>`
|
||||
const TopDiv = styled.div`
|
||||
outline: 1px solid rgba(153, 153, 152);
|
||||
outline-offset: -0.5px;
|
||||
border-radius: ${defaultBorderRadius};
|
||||
margin-bottom: 8px !important;
|
||||
background-color: ${vscEditorBackground};
|
||||
min-width: 0;
|
||||
${(props) =>
|
||||
props.active
|
||||
? "animation: none;"
|
||||
: css`
|
||||
animation: ${fadeInAnimation} 300ms ease-out forwards;
|
||||
`}
|
||||
`;
|
||||
|
||||
const ToolbarDiv = styled.div<{ isExpanded: boolean }>`
|
||||
|
|
@ -168,7 +153,7 @@ export default function StepContainerPreToolbar(
|
|||
}
|
||||
|
||||
return (
|
||||
<TopDiv active={active}>
|
||||
<TopDiv>
|
||||
<ToolbarDiv isExpanded={isExpanded} className="find-widget-skip">
|
||||
<div className="flex min-w-0 max-w-[45%] items-center">
|
||||
<ChevronDownIcon
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ export function Chat() {
|
|||
const mainTextInputRef = useRef<HTMLInputElement>(null);
|
||||
const stepsDivRef = useRef<HTMLDivElement>(null);
|
||||
const [isAtBottom, setIsAtBottom] = useState<boolean>(false);
|
||||
const sessionState = useAppSelector((state) => state.session);
|
||||
const messages = useAppSelector((state) => state.session.messages);
|
||||
const showChatScrollbar = useAppSelector(
|
||||
(state) => state.config.config.ui?.showChatScrollbar,
|
||||
);
|
||||
|
|
@ -292,7 +292,7 @@ export function Chat() {
|
|||
setLocalStorage("mainTextEntryCounter", 1);
|
||||
}
|
||||
},
|
||||
[sessionState.messages, defaultModel, sessionState, streamResponse],
|
||||
[messages, defaultModel, streamResponse],
|
||||
);
|
||||
|
||||
useWebviewListener(
|
||||
|
|
@ -306,11 +306,11 @@ export function Chat() {
|
|||
|
||||
const isLastUserInput = useCallback(
|
||||
(index: number): boolean => {
|
||||
return !sessionState.messages
|
||||
return !messages
|
||||
.slice(index + 1)
|
||||
.some((entry) => entry.message.role === "user");
|
||||
},
|
||||
[sessionState.messages],
|
||||
[messages],
|
||||
);
|
||||
|
||||
const showScrollbar = showChatScrollbar || window.innerHeight > 5000;
|
||||
|
|
@ -320,11 +320,11 @@ export function Chat() {
|
|||
{widget}
|
||||
<StepsDiv
|
||||
ref={stepsDivRef}
|
||||
className={`overflow-y-scroll pt-[8px] ${showScrollbar ? "thin-scrollbar" : "no-scrollbar"} ${sessionState.messages.length > 0 ? "flex-1" : ""}`}
|
||||
className={`overflow-y-scroll pt-[8px] ${showScrollbar ? "thin-scrollbar" : "no-scrollbar"} ${messages.length > 0 ? "flex-1" : ""}`}
|
||||
onScroll={handleScroll}
|
||||
>
|
||||
{highlights}
|
||||
{sessionState.messages.map((item, index: number) => (
|
||||
{messages.map((item, index: number) => (
|
||||
<Fragment key={item.message.id}>
|
||||
<ErrorBoundary
|
||||
FallbackComponent={fallbackRender}
|
||||
|
|
@ -370,7 +370,7 @@ export function Chat() {
|
|||
>
|
||||
<StepContainer
|
||||
index={index}
|
||||
isLast={index === sessionState.messages.length - 1}
|
||||
isLast={index === messages.length - 1}
|
||||
item={item}
|
||||
/>
|
||||
</TimelineItem>
|
||||
|
|
@ -423,7 +423,7 @@ export function Chat() {
|
|||
>
|
||||
<div className="flex flex-row items-center justify-between pb-1 pl-0.5 pr-2">
|
||||
<div className="xs:inline hidden">
|
||||
{sessionState.messages.length === 0 && getLastSessionId() ? (
|
||||
{messages.length === 0 && getLastSessionId() ? (
|
||||
<div className="xs:inline hidden">
|
||||
<NewSessionButton
|
||||
onClick={async () => {
|
||||
|
|
@ -442,7 +442,7 @@ export function Chat() {
|
|||
<ConfigErrorIndicator />
|
||||
</div>
|
||||
|
||||
{sessionState.messages.length === 0 && (
|
||||
{messages.length === 0 && (
|
||||
<>
|
||||
{onboardingCard.show && (
|
||||
<div className="mx-2 mt-10">
|
||||
|
|
@ -460,7 +460,7 @@ export function Chat() {
|
|||
</div>
|
||||
</div>
|
||||
<div
|
||||
className={`${sessionState.messages.length === 0 ? "h-full" : ""} flex flex-col justify-end`}
|
||||
className={`${messages.length === 0 ? "h-full" : ""} flex flex-col justify-end`}
|
||||
>
|
||||
<ChatIndexingPeeks />
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ export const editModeStateSlice = createSlice({
|
|||
initialState,
|
||||
reducers: {
|
||||
focusEdit: (state) => {
|
||||
state.isInEditMode = true;
|
||||
// state.isInEditMode = true;
|
||||
state.editStatus = "not-started";
|
||||
state.previousInputs = [];
|
||||
state.fileAfterEdit = undefined;
|
||||
|
|
|
|||
|
|
@ -40,18 +40,20 @@ function isCodeToEditEqual(a: CodeToEdit, b: CodeToEdit) {
|
|||
return a.filepath === b.filepath && a.contents === b.contents;
|
||||
}
|
||||
|
||||
const defaultMessage: ChatHistoryItemWithMessageId = {
|
||||
message: {
|
||||
id: uuidv4(),
|
||||
role: "assistant",
|
||||
content: "",
|
||||
},
|
||||
contextItems: [],
|
||||
mode: "chat",
|
||||
isGatheringContext: false,
|
||||
checkpoint: {},
|
||||
isBeforeCheckpoint: false,
|
||||
};
|
||||
function getDefaultMessage(): ChatHistoryItemWithMessageId {
|
||||
return {
|
||||
message: {
|
||||
id: uuidv4(),
|
||||
role: "assistant",
|
||||
content: "",
|
||||
},
|
||||
contextItems: [],
|
||||
mode: "chat",
|
||||
isGatheringContext: false,
|
||||
checkpoint: {},
|
||||
isBeforeCheckpoint: false,
|
||||
};
|
||||
}
|
||||
|
||||
const initialState: SessionState = {
|
||||
messages: [],
|
||||
|
|
@ -147,7 +149,9 @@ export const sessionSlice = createSlice({
|
|||
// Cut off history after the resubmitted message
|
||||
state.messages = state.messages
|
||||
.slice(0, payload.index + 1)
|
||||
.concat(defaultMessage);
|
||||
.concat(getDefaultMessage());
|
||||
|
||||
state.isStreaming = true;
|
||||
},
|
||||
deleteMessage: (state, action: PayloadAction<number>) => {
|
||||
// Deletes the current assistant message and the previous user message
|
||||
|
|
@ -162,14 +166,14 @@ export const sessionSlice = createSlice({
|
|||
}>,
|
||||
) => {
|
||||
state.messages.push({
|
||||
...defaultMessage,
|
||||
message: { role: "user", ...defaultMessage.message },
|
||||
...getDefaultMessage(),
|
||||
message: { role: "user", ...getDefaultMessage().message },
|
||||
editorState: payload.editorState,
|
||||
});
|
||||
|
||||
state.messages.push({
|
||||
...defaultMessage,
|
||||
message: { role: "assistant", ...defaultMessage.message },
|
||||
...getDefaultMessage(),
|
||||
message: { role: "assistant", ...getDefaultMessage().message },
|
||||
editorState: payload.editorState,
|
||||
});
|
||||
|
||||
|
|
@ -188,8 +192,8 @@ export const sessionSlice = createSlice({
|
|||
) => {
|
||||
if (payload.index >= state.messages.length) {
|
||||
state.messages.push({
|
||||
...defaultMessage,
|
||||
message: { ...defaultMessage.message, ...payload.message },
|
||||
...getDefaultMessage(),
|
||||
message: { ...getDefaultMessage().message, ...payload.message },
|
||||
editorState: {
|
||||
type: "doc",
|
||||
content: stripImages(payload.message.content)
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ export type RootState = ReturnType<typeof rootReducer>;
|
|||
export type AppDispatch = typeof store.dispatch;
|
||||
|
||||
const saveSubsetFilters = [
|
||||
createFilter("state", ["messages", "sessionId", "defaultModelTitle"]),
|
||||
createFilter("session", ["messages", "sessionId", "defaultModelTitle"]),
|
||||
];
|
||||
|
||||
const loadSubsetFilter = createFilter("state", null, [
|
||||
|
|
@ -37,7 +37,7 @@ const loadSubsetFilter = createFilter("state", null, [
|
|||
"ui",
|
||||
"editModeState",
|
||||
"config",
|
||||
"indexing"
|
||||
"indexing",
|
||||
]);
|
||||
|
||||
const persistConfig = {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue