apply state fixes
This commit is contained in:
parent
41791cd51f
commit
577af64909
8 changed files with 64 additions and 56 deletions
|
|
@ -282,7 +282,7 @@ async function processDiff(
|
|||
});
|
||||
}
|
||||
|
||||
await sidebar.webviewProtocol.request("exitEditMode", undefined);
|
||||
// await sidebar.webviewProtocol.request("exitEditMode", undefined);
|
||||
|
||||
// Save the file
|
||||
await ide.saveFile(newOrCurrentUri);
|
||||
|
|
|
|||
|
|
@ -40,17 +40,20 @@ export default function AcceptRejectAllButtons({
|
|||
}
|
||||
|
||||
return (
|
||||
<div className="flex justify-center gap-2 border-b p-1 px-3">
|
||||
<div className="flex flex-row items-center justify-evenly gap-2 p-1 px-3">
|
||||
<button
|
||||
className="flex cursor-pointer items-center space-x-1 border-none bg-transparent px-2 py-1 text-xs text-gray-300 opacity-80 hover:opacity-100 hover:brightness-125"
|
||||
className="flex cursor-pointer flex-row flex-wrap justify-center gap-1 border-none bg-transparent px-2 py-1 text-xs text-gray-300 opacity-80 hover:opacity-100 hover:brightness-125"
|
||||
onClick={() => handleAcceptOrReject("rejectDiff")}
|
||||
data-testid="edit-reject-button"
|
||||
>
|
||||
<XMarkIcon className="h-4 w-4 text-red-600" />
|
||||
<span>Reject</span>
|
||||
<span className="xs:inline-block hidden">All</span>
|
||||
<div className="flex flex-row items-center gap-1">
|
||||
<XMarkIcon className="h-4 w-4 text-red-600" />
|
||||
<span>Reject</span>
|
||||
<span className="xs:inline-block hidden">All</span>
|
||||
</div>
|
||||
|
||||
<span
|
||||
className="text-gray-400"
|
||||
className="xs:inline-block hidden text-gray-400"
|
||||
style={{
|
||||
fontSize: tinyFont,
|
||||
}}
|
||||
|
|
@ -59,15 +62,17 @@ export default function AcceptRejectAllButtons({
|
|||
</span>
|
||||
</button>
|
||||
<button
|
||||
className="flex cursor-pointer items-center space-x-1 border-none bg-transparent px-2 py-1 text-xs text-gray-300 opacity-80 hover:opacity-100 hover:brightness-125"
|
||||
className="flex cursor-pointer flex-row flex-wrap justify-center gap-1 border-none bg-transparent px-2 py-1 text-xs text-gray-300 opacity-80 hover:opacity-100 hover:brightness-125"
|
||||
onClick={() => handleAcceptOrReject("acceptDiff")}
|
||||
data-testid="edit-accept-button"
|
||||
>
|
||||
<CheckIcon className="mr-1 h-4 w-4 text-green-600" />
|
||||
<span>Accept</span>
|
||||
<span className="xs:inline-block hidden">All</span>
|
||||
<div className="flex flex-row items-center gap-1">
|
||||
<CheckIcon className="h-4 w-4 text-green-600" />
|
||||
<span>Accept</span>
|
||||
<span className="xs:inline-block hidden">All</span>
|
||||
</div>
|
||||
<span
|
||||
className="text-gray-400"
|
||||
className="xs:inline-block hidden text-gray-400"
|
||||
style={{
|
||||
fontSize: tinyFont,
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -10,18 +10,27 @@ const EditModeDetails = () => {
|
|||
(store) => store.editModeState.applyState,
|
||||
);
|
||||
|
||||
if (isStreaming || mode !== "edit") {
|
||||
if (isStreaming || mode !== "edit" || editApplyState.status !== "done") {
|
||||
return null;
|
||||
}
|
||||
|
||||
const plural = editApplyState.numDiffs === 1 ? "" : "s";
|
||||
|
||||
return (
|
||||
<AcceptRejectAllButtons
|
||||
applyStates={[editApplyState]}
|
||||
onAcceptOrReject={async (outcome) => {
|
||||
if (outcome === "acceptDiff") {
|
||||
dispatch(exitEditMode({}));
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<>
|
||||
<div className="h-2"></div>
|
||||
<AcceptRejectAllButtons
|
||||
applyStates={[editApplyState]}
|
||||
onAcceptOrReject={async (outcome) => {
|
||||
if (outcome === "acceptDiff") {
|
||||
dispatch(exitEditMode({}));
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<div className="flex flex-col items-center justify-center pt-2 text-gray-400">
|
||||
<span className="">{`${editApplyState.numDiffs} diff${plural} remaining`}</span>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ export const ErrorsSectionTooltip = () => {
|
|||
const configError = useAppSelector((store) => store.config.configError);
|
||||
|
||||
const numErrors = configError?.length ?? 0;
|
||||
const plural = numErrors > 1 ? "s" : "";
|
||||
const plural = numErrors === 1 ? "" : "s";
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ import { useAppDispatch, useAppSelector } from "../redux/hooks";
|
|||
import { selectCurrentToolCallApplyState } from "../redux/selectors/selectCurrentToolCall";
|
||||
import { setConfigResult } from "../redux/slices/configSlice";
|
||||
import {
|
||||
setEditStateApplyState,
|
||||
setLastNonEditSessionEmpty,
|
||||
updateEditStateApplyState,
|
||||
} from "../redux/slices/editModeState";
|
||||
import { updateIndexingStatus } from "../redux/slices/indexingSlice";
|
||||
import {
|
||||
|
|
@ -263,7 +263,7 @@ function useSetup() {
|
|||
async (state) => {
|
||||
if (state.streamId === EDIT_MODE_STREAM_ID) {
|
||||
console.log(state);
|
||||
dispatch(setEditStateApplyState(state));
|
||||
dispatch(updateEditStateApplyState(state));
|
||||
} else {
|
||||
// chat or agent
|
||||
dispatch(updateApplyState(state));
|
||||
|
|
|
|||
|
|
@ -40,23 +40,13 @@ export function EditFile(props: EditToolCallProps) {
|
|||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<StyledMarkdownPreview
|
||||
isRenderingInStepContainer
|
||||
disableManualApply
|
||||
source={src}
|
||||
forceStreamId={applyState?.streamId}
|
||||
expandCodeblocks={false}
|
||||
itemIndex={props.historyIndex}
|
||||
/>
|
||||
{/* {!isStreaming && applyState?.status === "done" && (
|
||||
<div className={`m-2 flex items-center justify-center`}>
|
||||
<AcceptRejectAllButtons
|
||||
pendingApplyStates={[applyState]}
|
||||
onAcceptOrReject={async (outcome) => {}}
|
||||
/>
|
||||
</div>
|
||||
)} */}
|
||||
</>
|
||||
<StyledMarkdownPreview
|
||||
isRenderingInStepContainer
|
||||
disableManualApply
|
||||
source={src}
|
||||
forceStreamId={applyState?.streamId}
|
||||
expandCodeblocks={false}
|
||||
itemIndex={props.historyIndex}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,10 +11,13 @@ export interface EditModeState {
|
|||
lastNonEditSessionWasEmpty: boolean;
|
||||
}
|
||||
|
||||
export const INITIAL_EDIT_APPLY_STATE: ApplyState = {
|
||||
streamId: EDIT_MODE_STREAM_ID,
|
||||
status: "not-started",
|
||||
};
|
||||
|
||||
const initialState: EditModeState = {
|
||||
applyState: {
|
||||
streamId: EDIT_MODE_STREAM_ID,
|
||||
},
|
||||
applyState: INITIAL_EDIT_APPLY_STATE,
|
||||
codeToEdit: [],
|
||||
returnCursorToEditorAfterEdit: false,
|
||||
returnToMode: "chat",
|
||||
|
|
@ -37,8 +40,14 @@ export const editModeStateSlice = createSlice({
|
|||
) => {
|
||||
state.returnToMode = payload;
|
||||
},
|
||||
setEditStateApplyState: (state, { payload }: PayloadAction<ApplyState>) => {
|
||||
state.applyState = payload;
|
||||
updateEditStateApplyState: (
|
||||
state,
|
||||
{ payload }: PayloadAction<ApplyState>,
|
||||
) => {
|
||||
state.applyState = {
|
||||
...state.applyState,
|
||||
...payload,
|
||||
};
|
||||
},
|
||||
setCodeToEdit: (
|
||||
state,
|
||||
|
|
@ -72,7 +81,7 @@ export const {
|
|||
setReturnCursorToEditorAfterEdit,
|
||||
clearCodeToEdit,
|
||||
setCodeToEdit,
|
||||
setEditStateApplyState,
|
||||
updateEditStateApplyState,
|
||||
setLastNonEditSessionEmpty,
|
||||
} = editModeStateSlice.actions;
|
||||
export default editModeStateSlice.reducer;
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
import { createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { JSONContent } from "@tiptap/core";
|
||||
import { CodeToEdit, MessageModes, RangeInFileWithContents } from "core";
|
||||
import { EDIT_MODE_STREAM_ID } from "core/edit/constants";
|
||||
import { stripImages } from "core/util/messageContent";
|
||||
import { resolveEditorContent } from "../../components/mainInput/TipTapEditor";
|
||||
import {
|
||||
clearCodeToEdit,
|
||||
setEditStateApplyState,
|
||||
INITIAL_EDIT_APPLY_STATE,
|
||||
setReturnCursorToEditorAfterEdit,
|
||||
setReturnToModeAfterEdit,
|
||||
updateEditStateApplyState,
|
||||
} from "../slices/editModeState";
|
||||
import { newSession, setActive, setMode } from "../slices/sessionSlice";
|
||||
import { ThunkApiType } from "../store";
|
||||
|
|
@ -125,12 +125,7 @@ export const enterEditMode = createAsyncThunk<
|
|||
generateTitle: false,
|
||||
}),
|
||||
);
|
||||
dispatch(
|
||||
setEditStateApplyState({
|
||||
streamId: EDIT_MODE_STREAM_ID,
|
||||
status: "not-started",
|
||||
}),
|
||||
);
|
||||
dispatch(updateEditStateApplyState(INITIAL_EDIT_APPLY_STATE));
|
||||
dispatch(setMode("edit"));
|
||||
},
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue