isGenerating logic fix
This commit is contained in:
parent
34ae653841
commit
1c4ee082d4
5 changed files with 38 additions and 23 deletions
|
|
@ -69,7 +69,6 @@ export default function StepContainerPreToolbar(
|
|||
props.expanded ?? (isInEditMode ? false : true),
|
||||
);
|
||||
const [codeBlockContent, setCodeBlockContent] = useState("");
|
||||
const isStreaming = useAppSelector((state) => state.session.isStreaming);
|
||||
|
||||
const nextCodeBlockIndex = useAppSelector(
|
||||
(state) => state.session.codeBlockApplyStates.curIndex,
|
||||
|
|
@ -79,15 +78,6 @@ export default function StepContainerPreToolbar(
|
|||
selectApplyStateByStreamId(state, props.codeBlockStreamId),
|
||||
);
|
||||
|
||||
// This handles an edge case when the last node in the markdown syntax tree is a codeblock.
|
||||
// In this scenario, `isGeneratingCodeBlock` is never set to false since we determine if
|
||||
// we are done generating based on whether the next node in the tree is not a codeblock.
|
||||
// The tree parsing logic for Remark is defined on page load, so we can't access state
|
||||
// during the actual tree parsing.
|
||||
const isGeneratingCodeBlock = !isStreaming
|
||||
? false
|
||||
: props.isGeneratingCodeBlock;
|
||||
|
||||
const isNextCodeBlock = nextCodeBlockIndex === props.codeBlockIndex;
|
||||
const hasFileExtension = /\.[0-9a-z]+$/i.test(props.relativeFilepath);
|
||||
|
||||
|
|
@ -196,7 +186,7 @@ export default function StepContainerPreToolbar(
|
|||
</div>
|
||||
|
||||
<div className="flex items-center gap-3 max-sm:gap-1.5">
|
||||
{isGeneratingCodeBlock ? (
|
||||
{props.isGeneratingCodeBlock ? (
|
||||
<GeneratingCodeLoader
|
||||
showLineCount={!isExpanded}
|
||||
codeBlockContent={codeBlockContent}
|
||||
|
|
|
|||
|
|
@ -132,6 +132,7 @@ interface StyledMarkdownPreviewProps {
|
|||
useParentBackgroundColor?: boolean;
|
||||
disableManualApply?: boolean;
|
||||
singleCodeblockStreamId?: string;
|
||||
expandCodeblocks?: boolean;
|
||||
}
|
||||
|
||||
const HLJS_LANGUAGE_CLASSNAME_PREFIX = "language-";
|
||||
|
|
@ -198,9 +199,18 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview(
|
|||
}, [props.itemIndex, history, allSymbols]);
|
||||
const pastFileInfoRef = useUpdatingRef(pastFileInfo);
|
||||
|
||||
const isLastItem = useMemo(() => {
|
||||
return props.itemIndex && props.itemIndex === history.length - 1;
|
||||
}, [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 }[]>(
|
||||
[],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (props.singleCodeblockStreamId) {
|
||||
codeblockState.current = [
|
||||
|
|
@ -235,8 +245,7 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview(
|
|||
node.data = node.data || {};
|
||||
node.data.hProperties = node.data.hProperties || {};
|
||||
|
||||
node.data.hProperties["data-isgeneratingcodeblock"] =
|
||||
lastCodeNode === node;
|
||||
node.data.hProperties["data-islastcodeblock"] = lastCodeNode === node;
|
||||
node.data.hProperties["data-codeblockcontent"] = node.value;
|
||||
|
||||
if (node.meta) {
|
||||
|
|
@ -318,7 +327,9 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview(
|
|||
}
|
||||
|
||||
const isGeneratingCodeBlock =
|
||||
preChildProps["data-isgeneratingcodeblock"];
|
||||
preChildProps["data-islastcodeblock"] &&
|
||||
isLastItemRef.current &&
|
||||
!isStreamingRef.current;
|
||||
|
||||
if (codeblockState.current[codeBlockIndex] === undefined) {
|
||||
codeblockState.current[codeBlockIndex] = {
|
||||
|
|
@ -342,6 +353,7 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview(
|
|||
codeBlockStreamId={
|
||||
codeblockState.current[codeBlockIndex].streamId
|
||||
}
|
||||
expanded={props.expandCodeblocks}
|
||||
disableManualApply={props.disableManualApply}
|
||||
>
|
||||
<SyntaxHighlightedPre {...preProps} />
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { VSC_THEME_COLOR_VARS } from "../components";
|
|||
import { IdeMessengerContext } from "../context/IdeMessenger";
|
||||
|
||||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import { BrowserSerializedContinueConfig, ContextItem } from "core";
|
||||
import { BrowserSerializedContinueConfig } from "core";
|
||||
import {
|
||||
initializeProfilePreferencesThunk,
|
||||
selectProfileThunk,
|
||||
|
|
@ -268,17 +268,17 @@ function useSetup() {
|
|||
state.streamId === activeToolStreamId[0] &&
|
||||
state.status === "closed"
|
||||
) {
|
||||
const output: ContextItem = {
|
||||
name: "Edit tool output",
|
||||
content: "Completed edit",
|
||||
description: "",
|
||||
};
|
||||
// const output: ContextItem = {
|
||||
// name: "Edit tool output",
|
||||
// content: "Completed edit",
|
||||
// description: "",
|
||||
// };
|
||||
dispatch(acceptToolCall());
|
||||
dispatch(setToolCallOutput([output]));
|
||||
dispatch(setToolCallOutput([]));
|
||||
dispatch(
|
||||
streamResponseAfterToolCall({
|
||||
toolCallId: activeToolStreamId[1],
|
||||
toolOutput: [output],
|
||||
toolOutput: [],
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ export function EditFile(props: EditToolCallProps) {
|
|||
source={src}
|
||||
disableManualApply={true}
|
||||
singleCodeblockStreamId={applyState?.streamId}
|
||||
expandCodeblocks={false}
|
||||
/>
|
||||
{/* TODO better indicator of generation at bottom */}
|
||||
{/* {isStreaming && applyState?.status === "streaming" && (
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import {
|
|||
cancelToolCall,
|
||||
setCalling,
|
||||
setToolCallOutput,
|
||||
updateApplyState,
|
||||
} from "../slices/sessionSlice";
|
||||
import { ThunkApiType } from "../store";
|
||||
import { streamResponseAfterToolCall } from "./streamResponseAfterToolCall";
|
||||
|
|
@ -61,6 +62,17 @@ export const callTool = createAsyncThunk<void, undefined, ThunkApiType>(
|
|||
if (e instanceof Error) {
|
||||
errorMessage = e.message;
|
||||
}
|
||||
if (state.session.activeToolStreamId?.[0]) {
|
||||
dispatch(
|
||||
updateApplyState({
|
||||
streamId: state.session.activeToolStreamId[0],
|
||||
status: "closed",
|
||||
toolCallId: toolCallState.toolCallId,
|
||||
numDiffs: 0,
|
||||
filepath: args.filepath,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const result = await extra.ideMessenger.request("tools/call", {
|
||||
|
|
@ -128,7 +140,7 @@ async function customGuiEditImpl(
|
|||
text: args.new_contents,
|
||||
curSelectedModelTitle: modelTitle,
|
||||
toolCallId,
|
||||
filepath: firstUriMatch
|
||||
filepath: firstUriMatch,
|
||||
});
|
||||
if (apply.status === "error") {
|
||||
throw new Error(apply.error);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue