fix edit tool
This commit is contained in:
parent
275e116d9c
commit
d68deaf6fc
11 changed files with 57 additions and 73 deletions
4
extensions/vscode/package-lock.json
generated
4
extensions/vscode/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"version": "1.1.24",
|
||||
"version": "1.1.26",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "continue",
|
||||
"version": "1.1.24",
|
||||
"version": "1.1.26",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/fetch": "^1.0.3",
|
||||
|
|
|
|||
|
|
@ -47,15 +47,12 @@ export function ApplyActions(props: ApplyActionsProps) {
|
|||
</button>
|
||||
);
|
||||
|
||||
console.log(props.applyState);
|
||||
|
||||
switch (props.applyState ? props.applyState.status : null) {
|
||||
case "not-started":
|
||||
return (
|
||||
<div className="flex select-none items-center rounded bg-zinc-700 pl-2 pr-1">
|
||||
<span className="text-lightgray inline-flex w-min items-center gap-2 text-center text-xs">
|
||||
Pending
|
||||
<Spinner />
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -3,22 +3,24 @@ import Spinner from "../../gui/Spinner";
|
|||
export interface GeneratingCodeLoaderProps {
|
||||
showLineCount: boolean;
|
||||
codeBlockContent: string;
|
||||
isPending: boolean;
|
||||
}
|
||||
|
||||
export function GeneratingCodeLoader({
|
||||
showLineCount,
|
||||
codeBlockContent,
|
||||
isPending,
|
||||
}: GeneratingCodeLoaderProps) {
|
||||
const numLinesCodeBlock = codeBlockContent.split("\n").length;
|
||||
const linesGeneratedText =
|
||||
numLinesCodeBlock === 1
|
||||
? `1 line generated`
|
||||
: `${numLinesCodeBlock} lines generated`;
|
||||
: `${numLinesCodeBlock} lines ${isPending ? "pending" : "generated"}`;
|
||||
|
||||
return (
|
||||
<span className="text-lightgray inline-flex items-center gap-2">
|
||||
{showLineCount ? linesGeneratedText : "Generating"}
|
||||
<Spinner />
|
||||
{!isPending && <Spinner />}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ export interface StepContainerPreToolbarProps {
|
|||
codeBlockContent: string;
|
||||
language: string | null;
|
||||
relativeFilepath?: string;
|
||||
isGeneratingCodeBlock: boolean;
|
||||
isFinalCodeblock: boolean;
|
||||
codeBlockIndex: number; // To track which codeblock we are applying
|
||||
codeBlockStreamId: string;
|
||||
range?: string;
|
||||
|
|
@ -65,7 +65,7 @@ export function StepContainerPreToolbar({
|
|||
codeBlockContent,
|
||||
language,
|
||||
relativeFilepath,
|
||||
isGeneratingCodeBlock,
|
||||
isFinalCodeblock,
|
||||
codeBlockIndex,
|
||||
codeBlockStreamId,
|
||||
range,
|
||||
|
|
@ -115,6 +115,9 @@ export function StepContainerPreToolbar({
|
|||
const hasFileExtension =
|
||||
relativeFilepath && /\.[0-9a-z]+$/i.test(relativeFilepath);
|
||||
|
||||
const isStreaming = useAppSelector((store) => store.session.isStreaming);
|
||||
const isGeneratingCodeBlock = isFinalCodeblock && isStreaming;
|
||||
|
||||
// If we are creating a file, we already render that in the button
|
||||
// so we don't want to dispaly it twice here
|
||||
const displayFilepath = relativeFilepath ?? appliedFileUri;
|
||||
|
|
@ -217,12 +220,7 @@ export function StepContainerPreToolbar({
|
|||
});
|
||||
}
|
||||
}
|
||||
console.log(
|
||||
isLoadingFileExists,
|
||||
fileExists,
|
||||
relativeFilepath,
|
||||
isGeneratingCodeBlock,
|
||||
);
|
||||
|
||||
const renderActionButtons = () => {
|
||||
if (isTerminalCodeBlock(language, codeBlockContent)) {
|
||||
return <RunInTerminalButton command={codeBlockContent} />;
|
||||
|
|
@ -277,20 +275,23 @@ export function StepContainerPreToolbar({
|
|||
</div>
|
||||
|
||||
<div className="flex items-center gap-2.5">
|
||||
{isGeneratingCodeBlock ? (
|
||||
{!isGeneratingCodeBlock && (
|
||||
<div className="xs:flex hidden items-center gap-2.5">
|
||||
<InsertButton onInsert={onClickInsertAtCursor} />
|
||||
<CopyButton text={codeBlockContent} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{isGeneratingCodeBlock || applyState?.status === "not-started" ? (
|
||||
<GeneratingCodeLoader
|
||||
showLineCount={!isExpanded}
|
||||
codeBlockContent={codeBlockContent}
|
||||
isPending={
|
||||
applyState?.status === "not-started" && !isGeneratingCodeBlock
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
<div className="xs:flex hidden items-center gap-2.5">
|
||||
<InsertButton onInsert={onClickInsertAtCursor} />
|
||||
<CopyButton text={codeBlockContent} />
|
||||
</div>
|
||||
|
||||
{renderActionButtons()}
|
||||
</>
|
||||
renderActionButtons()
|
||||
)}
|
||||
</div>
|
||||
</ToolbarDiv>
|
||||
|
|
|
|||
|
|
@ -199,23 +199,12 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview(
|
|||
}, [history.length, props.itemIndex]);
|
||||
const isLastItemRef = useUpdatingRef(isLastItem);
|
||||
|
||||
const isStreaming = useAppSelector((store) => store.session.isStreaming);
|
||||
const isStreamingRef = useUpdatingRef(isStreaming);
|
||||
|
||||
const codeblockState = useRef<{ streamId: string; isGenerating: boolean }[]>(
|
||||
[],
|
||||
);
|
||||
|
||||
const codeblockStreamIds = useRef<string[]>([]);
|
||||
useEffect(() => {
|
||||
if (props.forceStreamId) {
|
||||
codeblockState.current = [
|
||||
{
|
||||
streamId: props.forceStreamId,
|
||||
isGenerating: false,
|
||||
},
|
||||
];
|
||||
codeblockStreamIds.current = [props.forceStreamId];
|
||||
}
|
||||
}, [props.forceStreamId]);
|
||||
}, [props.forceStreamId, codeblockStreamIds]);
|
||||
|
||||
const [reactContent, setMarkdownSource] = useRemark({
|
||||
remarkPlugins: [
|
||||
|
|
@ -310,34 +299,23 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview(
|
|||
|
||||
const language = getLanguageFromClassName(className);
|
||||
|
||||
const isGeneratingCodeBlock =
|
||||
preChildProps["data-islastcodeblock"] &&
|
||||
isLastItemRef.current &&
|
||||
isStreamingRef.current;
|
||||
const isFinalCodeblock =
|
||||
preChildProps["data-islastcodeblock"] && isLastItemRef.current;
|
||||
|
||||
if (codeblockState.current[codeBlockIndex] === undefined) {
|
||||
codeblockState.current[codeBlockIndex] = {
|
||||
streamId: props.forceStreamId ?? uuidv4(),
|
||||
isGenerating: isGeneratingCodeBlock,
|
||||
};
|
||||
} else {
|
||||
codeblockState.current[codeBlockIndex].isGenerating =
|
||||
isGeneratingCodeBlock;
|
||||
if (codeblockStreamIds.current[codeBlockIndex] === undefined) {
|
||||
codeblockStreamIds.current[codeBlockIndex] =
|
||||
props.forceStreamId ?? uuidv4();
|
||||
}
|
||||
|
||||
console.log(props.forceStreamId);
|
||||
|
||||
return (
|
||||
<StepContainerPreToolbar
|
||||
codeBlockContent={codeBlockContent}
|
||||
codeBlockIndex={codeBlockIndex}
|
||||
language={language}
|
||||
relativeFilepath={relativeFilePath}
|
||||
isGeneratingCodeBlock={isGeneratingCodeBlock}
|
||||
isFinalCodeblock={isFinalCodeblock}
|
||||
range={range}
|
||||
codeBlockStreamId={
|
||||
codeblockState.current[codeBlockIndex].streamId
|
||||
}
|
||||
codeBlockStreamId={codeblockStreamIds.current[codeBlockIndex]}
|
||||
expanded={props.expandCodeblocks}
|
||||
disableManualApply={props.disableManualApply}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -101,7 +101,9 @@ export function LumpToolbar() {
|
|||
if (toolCallState?.status === "generated") {
|
||||
return (
|
||||
<Container>
|
||||
<GeneratingIndicator />
|
||||
<div className="flex flex-row items-center pb-0.5 pr-1 text-xs text-gray-400">
|
||||
<span className="hidden sm:flex">Pending tool call</span>
|
||||
</div>
|
||||
|
||||
<div className="flex gap-2 pb-0.5">
|
||||
<StopButton
|
||||
|
|
|
|||
|
|
@ -30,7 +30,10 @@ import { IdeMessengerContext } from "../../context/IdeMessenger";
|
|||
import { useWebviewListener } from "../../hooks/useWebviewListener";
|
||||
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
|
||||
import { selectUseHub } from "../../redux/selectors";
|
||||
import { selectCurrentToolCall } from "../../redux/selectors/selectCurrentToolCall";
|
||||
import {
|
||||
selectCurrentToolCall,
|
||||
selectCurrentToolCallApplyState,
|
||||
} from "../../redux/selectors/selectCurrentToolCall";
|
||||
import { selectSelectedChatModel } from "../../redux/slices/configSlice";
|
||||
import { submitEdit } from "../../redux/slices/editModeState";
|
||||
import {
|
||||
|
|
@ -151,6 +154,10 @@ export function Chat() {
|
|||
|
||||
const { widget, highlights } = useFindWidget(stepsDivRef);
|
||||
|
||||
const currentToolCallApplyState = useAppSelector(
|
||||
selectCurrentToolCallApplyState,
|
||||
);
|
||||
|
||||
const sendInput = useCallback(
|
||||
(
|
||||
editorState: JSONContent,
|
||||
|
|
@ -163,6 +170,14 @@ export function Chat() {
|
|||
"Cannot submit message while awaiting tool confirmation",
|
||||
);
|
||||
}
|
||||
if (
|
||||
currentToolCallApplyState &&
|
||||
currentToolCallApplyState.status !== "closed"
|
||||
) {
|
||||
return console.error(
|
||||
"Cannot submit message while awaiting tool call apply",
|
||||
);
|
||||
}
|
||||
if (selectedChatModel?.provider === "free-trial") {
|
||||
const newCount = incrementFreeTrialCount();
|
||||
|
||||
|
|
|
|||
|
|
@ -40,8 +40,6 @@ export function EditFile(props: EditToolCallProps) {
|
|||
return null;
|
||||
}
|
||||
|
||||
console.log("APPLY STATE", applyState);
|
||||
|
||||
return (
|
||||
<>
|
||||
<StyledMarkdownPreview
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ export const callCurrentTool = createAsyncThunk<void, undefined, ThunkApiType>(
|
|||
(state) =>
|
||||
state.toolCallId && state.toolCallId === toolCallState.toolCallId,
|
||||
)?.streamId,
|
||||
getState,
|
||||
});
|
||||
output = clientToolOuput;
|
||||
errorMessage = clientToolError;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
import { ContextItem, ToolCall } from "core";
|
||||
import { BuiltInToolNames } from "core/tools/builtIn";
|
||||
import { IIdeMessenger } from "../../context/IdeMessenger";
|
||||
import { AppThunkDispatch } from "../../redux/store";
|
||||
import { AppThunkDispatch, RootState } from "../../redux/store";
|
||||
import { editToolImpl } from "./editImpl";
|
||||
|
||||
export interface ClientToolExtras {
|
||||
getState: () => RootState;
|
||||
dispatch: AppThunkDispatch;
|
||||
ideMessenger: IIdeMessenger;
|
||||
streamId?: string;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { resolveRelativePathInDir } from "core/util/ideUtils";
|
||||
import { updateApplyState } from "../../redux/slices/sessionSlice";
|
||||
import { ClientToolImpl } from "./callClientTool";
|
||||
|
||||
export const editToolImpl: ClientToolImpl = async (
|
||||
|
|
@ -26,17 +25,7 @@ export const editToolImpl: ClientToolImpl = async (
|
|||
if (apply.status === "error") {
|
||||
throw new Error(apply.error);
|
||||
}
|
||||
if (extras.streamId) {
|
||||
extras.dispatch(
|
||||
updateApplyState({
|
||||
streamId: extras.streamId,
|
||||
status: "done",
|
||||
toolCallId,
|
||||
numDiffs: 0,
|
||||
filepath: args.filepath,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
respondImmediately: false,
|
||||
output: undefined, // No immediate output.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue