fix: update streamId matching

This commit is contained in:
Test 2024-11-30 20:07:14 -06:00
parent 5921bfac67
commit 8a1ce0f1f0
5 changed files with 72 additions and 30 deletions

View file

@ -760,6 +760,34 @@ function TipTapEditor(props: TipTapEditorProps) {
],
);
useWebviewListener(
"focusEdit",
async () => {
if (!props.isMainInput) {
return;
}
setTimeout(() => {
editor?.commands.focus("end");
}, 20);
},
[editor, props.isMainInput],
);
useWebviewListener(
"focusEditWithoutClear",
async () => {
if (!props.isMainInput) {
return;
}
setTimeout(() => {
editor?.commands.focus("end");
}, 2000);
},
[editor, props.isMainInput],
);
useWebviewListener(
"isContinueInputFocused",
async () => {

View file

@ -15,7 +15,7 @@ import GeneratingCodeLoader from "./GeneratingCodeLoader";
import RunInTerminalButton from "./RunInTerminalButton";
import { useAppSelector } from "../../../redux/hooks";
import { selectDefaultModel } from "../../../redux/slices/configSlice";
import { selectApplyStateBySessionId } from "../../../redux/slices/sessionSlice";
import { selectApplyStateByStreamId } from "../../../redux/slices/sessionSlice";
const TopDiv = styled.div`
outline: 1px solid rgba(153, 153, 152);
@ -70,7 +70,7 @@ export default function StepContainerPreToolbar(
);
const applyState = useAppSelector((state) =>
selectApplyStateBySessionId(state, streamIdRef.current),
selectApplyStateByStreamId(state, streamIdRef.current),
);
// This handles an edge case when the last node in the markdown syntax tree is a codeblock.

View file

@ -38,13 +38,19 @@ export default function CodeToEditListItem({
const filepath = code.filepath.split("/").pop() || code.filepath;
const fileSubpath = getLastNPathParts(code.filepath, 2);
let isInsertion = false;
let title = filepath;
if ("range" in code) {
const start = code.range.start.line + 1;
const end = code.range.end.line + 1;
title +=
start === end ? ` - Inserting at line ${start}` : ` (${start} - ${end})`;
isInsertion = start === end;
title += isInsertion
? ` - Inserting at line ${start}`
: ` (${start} - ${end})`;
}
const source =
@ -64,23 +70,6 @@ export default function CodeToEditListItem({
className={`hover:bg-lightgray hover:text-vsc-foreground flex justify-between rounded px-2 py-0.5 transition-colors hover:bg-opacity-20 ${showCodeSnippet && "text-vsc-foreground bg-lightgray bg-opacity-20"}`}
>
<div className="flex items-center gap-0.5">
{showCodeSnippet ? (
<ChevronDownIcon
onClick={(e) => {
e.stopPropagation();
setShowCodeSnippet(false);
}}
className="text-lightgray hover:bg-lightgray hover:text-vsc-foreground h-3.5 w-3.5 cursor-pointer rounded-md rounded-sm p-0.5 hover:bg-opacity-20"
/>
) : (
<ChevronRightIcon
onClick={(e) => {
e.stopPropagation();
setShowCodeSnippet(true);
}}
className="text-lightgray hover:bg-lightgray hover:text-vsc-foreground h-3.5 w-3.5 cursor-pointer rounded-md rounded-sm p-0.5 hover:bg-opacity-20"
/>
)}
<FileIcon filename={code.filepath} height={"18px"} width={"18px"} />
<div className="flex gap-1.5">
<span
@ -98,6 +87,25 @@ export default function CodeToEditListItem({
</div>
</div>
<div className="invisible flex gap-1.5 group-hover:visible">
<div className={isInsertion && "hidden"}>
{showCodeSnippet ? (
<ChevronDownIcon
onClick={(e) => {
e.stopPropagation();
setShowCodeSnippet(false);
}}
className="text-lightgray hover:bg-lightgray hover:text-vsc-foreground h-3.5 w-3.5 cursor-pointer rounded-md rounded-sm p-0.5 hover:bg-opacity-20"
/>
) : (
<ChevronRightIcon
onClick={(e) => {
e.stopPropagation();
setShowCodeSnippet(true);
}}
className="text-lightgray hover:bg-lightgray hover:text-vsc-foreground h-3.5 w-3.5 cursor-pointer rounded-md rounded-sm p-0.5 hover:bg-opacity-20"
/>
)}
</div>
<XMarkIcon
onClick={(e) => {
e.stopPropagation();

View file

@ -19,7 +19,7 @@ import getMultifileEditPrompt from "./getMultifileEditPrompt";
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
import {
clearCodeToEdit,
selectApplyStateBySessionId,
selectApplyStateByStreamId,
} from "../../redux/slices/sessionSlice";
const EDIT_DISALLOWED_CONTEXT_PROVIDERS = [
@ -60,7 +60,7 @@ export default function Edit() {
);
const applyState = useAppSelector(
(state) => selectApplyStateBySessionId(state, "edit")?.status ?? "closed",
(state) => selectApplyStateByStreamId(state, "edit")?.status ?? "closed",
);
const isSingleRangeEdit =
codeToEdit.length === 0 ||

View file

@ -23,6 +23,7 @@ import { renderChatMessage } from "core/util/messageContent";
import { v4 as uuidv4 } from "uuid";
import { streamResponseThunk } from "../thunks/streamResponse";
import { findCurrentToolCall } from "../util";
import { RootState } from "../store";
// 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.
@ -498,15 +499,20 @@ function addPassthroughCases(
});
}
// TODO: this is supposed to be by streamID not sessoinId
export const selectApplyStateBySessionId = createSelector(
export const selectCurrentToolCall = createSelector(
(store: RootState) => store.session.messages,
(history) => {
return findCurrentToolCall(history);
},
);
export const selectApplyStateByStreamId = createSelector(
[
(state: { session: SessionState }) =>
state.session.codeBlockApplyStates.states,
(_state: { session: SessionState }, sessionId: string) => sessionId,
(state: RootState) => state.session.codeBlockApplyStates.states,
(state: RootState, streamId: string) => streamId,
],
(states, sessionId) => {
return states.find((state) => state.streamId === sessionId);
(states, streamId) => {
return states.find((state) => state.streamId === streamId);
},
);