sync accept/reject with edit sidebar

This commit is contained in:
Nate 2024-11-01 21:41:03 -07:00
parent 06dd270d7f
commit ca6770833c
3 changed files with 21 additions and 1 deletions

View file

@ -281,7 +281,7 @@ export class VsCodeMessenger {
await verticalDiffManager.streamEdit(
stripImages(prompt),
modelTitle,
undefined,
"edit",
undefined,
undefined,
new vscode.Range(

View file

@ -79,6 +79,7 @@ function Edit() {
const [showCode, setShowCode] = useState(false);
// Reusing the applyState logic which was just the fastest way to get this working
useEffect(() => {
if (editModeState.editStatus === "done") {
ideMessenger.request("edit/escape", undefined);
@ -86,6 +87,18 @@ function Edit() {
}
}, [editModeState.editStatus]);
const applyState = useSelector(
(store: RootState) =>
store.uiState.applyStates.find((state) => state.streamId === "edit")
?.status ?? "closed",
);
useEffect(() => {
if (applyState === "closed" && editModeState.editStatus === "accepting") {
dispatch(dispatch(setEditDone()));
}
}, [applyState, editModeState.editStatus]);
return (
<>
<TopDiv>
@ -178,6 +191,9 @@ function Edit() {
range: editModeState.highlightedCode,
});
dispatch(submitEdit(prompt));
// Move cursor to end of editor (it's already focused)
editor.commands.selectTextblockEnd();
}}
></TipTapEditor>
</div>

View file

@ -11,6 +11,10 @@ type UiState = {
dialogEntryOn: boolean;
nextCodeBlockToApplyIndex: number;
onboardingCard: OnboardingCardState;
/**
* Syncs the sidebar with the accepted/rejected blocks in the editor. Reused for Edit as well.
*/
applyStates: ApplyState[];
};