diff --git a/gui/src/components/mainInput/TipTapEditor.tsx b/gui/src/components/mainInput/TipTapEditor.tsx
index 4b845b33e..0fc404ab5 100644
--- a/gui/src/components/mainInput/TipTapEditor.tsx
+++ b/gui/src/components/mainInput/TipTapEditor.tsx
@@ -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 () => {
diff --git a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx
index 8b0573122..58707f5eb 100644
--- a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx
+++ b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx
@@ -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.
diff --git a/gui/src/pages/edit/CodeToEditListItem.tsx b/gui/src/pages/edit/CodeToEditListItem.tsx
index c8b38ce9d..cc4170f5a 100644
--- a/gui/src/pages/edit/CodeToEditListItem.tsx
+++ b/gui/src/pages/edit/CodeToEditListItem.tsx
@@ -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"}`}
>
- {showCodeSnippet ? (
-
{
- 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"
- />
- ) : (
- {
- 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"
- />
- )}
+
+ {showCodeSnippet ? (
+ {
+ 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"
+ />
+ ) : (
+ {
+ 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"
+ />
+ )}
+
{
e.stopPropagation();
diff --git a/gui/src/pages/edit/Edit.tsx b/gui/src/pages/edit/Edit.tsx
index 89921bf94..ce084db9d 100644
--- a/gui/src/pages/edit/Edit.tsx
+++ b/gui/src/pages/edit/Edit.tsx
@@ -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 ||
diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts
index 1b3079f5f..72f121394 100644
--- a/gui/src/redux/slices/sessionSlice.ts
+++ b/gui/src/redux/slices/sessionSlice.ts
@@ -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);
},
);