- {useHub ? (
+ {true ? (
+ // For now we are excluding local onboarding options other than ollama
diff --git a/gui/src/pages/gui/StreamError.tsx b/gui/src/pages/gui/StreamError.tsx
index d098d2bc4..3d89a6245 100644
--- a/gui/src/pages/gui/StreamError.tsx
+++ b/gui/src/pages/gui/StreamError.tsx
@@ -11,7 +11,6 @@ import { useAuth } from "../../context/Auth";
import { IdeMessengerContext } from "../../context/IdeMessenger";
import { selectSelectedProfile } from "../../redux/";
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
-import { selectUseHub } from "../../redux/selectors";
import { selectSelectedChatModel } from "../../redux/slices/configSlice";
import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice";
import { isLocalProfile } from "../../util";
@@ -36,7 +35,6 @@ const StreamErrorDialog = ({ error }: StreamErrorProps) => {
const dispatch = useAppDispatch();
const ideMessenger = useContext(IdeMessengerContext);
const selectedModel = useAppSelector(selectSelectedChatModel);
- const hubEnabled = useAppSelector(selectUseHub);
const selectedProfile = useAppSelector(selectSelectedProfile);
const { session, refreshProfiles } = useAuth();
@@ -180,17 +178,14 @@ const StreamErrorDialog = ({ error }: StreamErrorProps) => {
if (statusCode === 401) {
errorContent = (
- {hubEnabled &&
- session &&
- selectedProfile &&
- !isLocalProfile(selectedProfile) && (
-
- {`If your hub secret values may have changed, refresh your assistants`}
-
- Refresh assistant secrets
-
-
- )}
+ {session && selectedProfile && !isLocalProfile(selectedProfile) && (
+
+ {`If your hub secret values may have changed, refresh your assistants`}
+
+ Refresh assistant secrets
+
+
+ )}
{`It's possible that your API key is invalid.`}
{checkKeysButton}
diff --git a/gui/src/redux/selectors/index.ts b/gui/src/redux/selectors/index.ts
index bbfea5364..aa24f87b3 100644
--- a/gui/src/redux/selectors/index.ts
+++ b/gui/src/redux/selectors/index.ts
@@ -46,6 +46,3 @@ export const selectUseActiveFile = createSelector(
[(state: RootState) => state.config.config.experimental?.defaultContext],
(defaultContext) => defaultContext?.includes("activeFile" as any),
);
-
-export const selectUseHub = (state: RootState) =>
- state.config.config.usePlatform;
diff --git a/gui/src/redux/slices/editModeState.ts b/gui/src/redux/slices/editModeState.ts
index b0283a0ab..391da9200 100644
--- a/gui/src/redux/slices/editModeState.ts
+++ b/gui/src/redux/slices/editModeState.ts
@@ -1,15 +1,19 @@
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
-import { EditStatus, MessageContent } from "core";
+import { CodeToEdit, EditStatus, MessageContent } from "core";
export interface EditModeState {
+ codeToEdit: CodeToEdit[];
editStatus: EditStatus;
previousInputs: MessageContent[];
fileAfterEdit?: string;
+ enteredEditModeFromEditor: boolean;
}
const initialState: EditModeState = {
editStatus: "not-started",
previousInputs: [],
+ codeToEdit: [],
+ enteredEditModeFromEditor: false,
};
export const editModeStateSlice = createSlice({
@@ -69,6 +73,36 @@ export const editModeStateSlice = createSlice({
state.editStatus = "done";
state.previousInputs = [];
},
+ addCodeToEdit: (
+ state,
+ { payload }: PayloadAction,
+ ) => {
+ const entries = Array.isArray(payload) ? payload : [payload];
+
+ const newEntries = entries.filter(
+ (entry) =>
+ !state.codeToEdit.some((existingEntry) =>
+ isCodeToEditEqual(existingEntry, entry),
+ ),
+ );
+
+ if (newEntries.length > 0) {
+ state.codeToEdit.push(...newEntries);
+ }
+ },
+ removeCodeToEdit: (state, { payload }: PayloadAction) => {
+ state.codeToEdit = state.codeToEdit.filter(
+ (entry) => !isCodeToEditEqual(entry, payload),
+ );
+ },
+ clearCodeToEdit: (state) => {
+ state.codeToEdit = [];
+ },
+ },
+ selectors: {
+ selectHasCodeToEdit: (state) => {
+ return state.codeToEdit.length > 0;
+ },
},
});
@@ -78,5 +112,41 @@ export const {
setEditDone,
submitEdit,
focusEdit,
+ clearCodeToEdit,
+ addCodeToEdit,
+ removeCodeToEdit,
} = editModeStateSlice.actions;
export default editModeStateSlice.reducer;
+
+function isCodeToEditEqual(a: CodeToEdit, b: CodeToEdit) {
+ if (a.filepath !== b.filepath || a.contents !== b.contents) {
+ return false;
+ }
+
+ if ("range" in a && "range" in b) {
+ const rangeA = a.range;
+ const rangeB = b.range;
+
+ return (
+ rangeA.start.line === rangeB.start.line &&
+ rangeA.end.line === rangeB.end.line
+ );
+ }
+
+ // If neither has a range, they are considered equal in this context
+ return !("range" in a) && !("range" in b);
+}
+
+export const { selectHasCodeToEdit } = editModeStateSlice.selectors;
+
+// selectIsSingleRangeEditOrInsertion: (state) => {
+// if (state.mode !== "edit") {
+// return false;
+// }
+
+// const isInsertion = state.codeToEdit.length === 0;
+// const selectIsSingleRangeEdit =
+// state.codeToEdit.length === 1 && "range" in state.codeToEdit[0];
+
+// return selectIsSingleRangeEdit || isInsertion;
+// },
diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts
index 5f74e0c50..5ef58dfff 100644
--- a/gui/src/redux/slices/sessionSlice.ts
+++ b/gui/src/redux/slices/sessionSlice.ts
@@ -10,7 +10,6 @@ import {
ApplyState,
ChatHistoryItem,
ChatMessage,
- CodeToEdit,
ContextItem,
ContextItemWithId,
FileSymbolMap,
@@ -44,7 +43,6 @@ type SessionState = {
title: string;
id: string;
streamAborter: AbortController;
- codeToEdit: CodeToEdit[];
curCheckpointIndex: number;
mainEditorContentTrigger?: JSONContent | undefined;
symbols: FileSymbolMap;
@@ -56,25 +54,6 @@ type SessionState = {
newestToolbarPreviewForInput: Record;
};
-function isCodeToEditEqual(a: CodeToEdit, b: CodeToEdit) {
- if (a.filepath !== b.filepath || a.contents !== b.contents) {
- return false;
- }
-
- if ("range" in a && "range" in b) {
- const rangeA = a.range;
- const rangeB = b.range;
-
- return (
- rangeA.start.line === rangeB.start.line &&
- rangeA.end.line === rangeB.end.line
- );
- }
-
- // If neither has a range, they are considered equal in this context
- return !("range" in a) && !("range" in b);
-}
-
const initialState: SessionState = {
allSessionMetadata: [],
history: [],
@@ -83,7 +62,6 @@ const initialState: SessionState = {
id: uuidv4(),
curCheckpointIndex: 0,
streamAborter: new AbortController(),
- codeToEdit: [],
symbols: {},
mode: "chat",
codeBlockApplyStates: {
@@ -584,31 +562,7 @@ export const sessionSlice = createSlice({
resetNextCodeBlockToApplyIndex: (state) => {
state.codeBlockApplyStates.curIndex = 0;
},
- addCodeToEdit: (
- state,
- { payload }: PayloadAction,
- ) => {
- const entries = Array.isArray(payload) ? payload : [payload];
- const newEntries = entries.filter(
- (entry) =>
- !state.codeToEdit.some((existingEntry) =>
- isCodeToEditEqual(existingEntry, entry),
- ),
- );
-
- if (newEntries.length > 0) {
- state.codeToEdit.push(...newEntries);
- }
- },
- removeCodeToEdit: (state, { payload }: PayloadAction) => {
- state.codeToEdit = state.codeToEdit.filter(
- (entry) => !isCodeToEditEqual(entry, payload),
- );
- },
- clearCodeToEdit: (state) => {
- state.codeToEdit = [];
- },
// TOOL CALL STATE
setToolGenerated: (
state,
@@ -724,26 +678,6 @@ export const sessionSlice = createSlice({
const curHistoryItem = state.history.at(-1);
return curHistoryItem?.isGatheringContext || false;
},
- selectIsInEditMode: (state) => {
- return state.mode === "edit";
- },
- selectCurrentMode: (state) => {
- return state.mode;
- },
- selectIsSingleRangeEditOrInsertion: (state) => {
- if (state.mode !== "edit") {
- return false;
- }
-
- const isInsertion = state.codeToEdit.length === 0;
- const selectIsSingleRangeEdit =
- state.codeToEdit.length === 1 && "range" in state.codeToEdit[0];
-
- return selectIsSingleRangeEdit || isInsertion;
- },
- selectHasCodeToEdit: (state) => {
- return state.codeToEdit.length > 0;
- },
},
extraReducers: (builder) => {
addPassthroughCases(builder, [streamResponseThunk]);
@@ -811,9 +745,6 @@ export const {
resetNextCodeBlockToApplyIndex,
updateApplyState,
abortStream,
- clearCodeToEdit,
- addCodeToEdit,
- removeCodeToEdit,
setToolCallCalling,
cancelToolCall,
errorToolCall,
@@ -829,12 +760,6 @@ export const {
cycleMode,
} = sessionSlice.actions;
-export const {
- selectIsGatheringContext,
- selectIsInEditMode,
- selectCurrentMode,
- selectIsSingleRangeEditOrInsertion,
- selectHasCodeToEdit,
-} = sessionSlice.selectors;
+export const { selectIsGatheringContext } = sessionSlice.selectors;
export default sessionSlice.reducer;
diff --git a/gui/src/redux/store.ts b/gui/src/redux/store.ts
index aa7c2bb5c..6a15431e0 100644
--- a/gui/src/redux/store.ts
+++ b/gui/src/redux/store.ts
@@ -47,7 +47,6 @@ const saveSubsetFilters = [
// Persist edit mode in case closes in middle
"mode",
- "codeToEdit",
// higher risk to persist
// codeBlockApplyStates
@@ -55,7 +54,7 @@ const saveSubsetFilters = [
// curCheckpointIndex
]),
// Don't persist any of the edit state for now
- createFilter("editModeState", []),
+ createFilter("editModeState", ["codeToEdit"]),
createFilter("config", ["defaultModelTitle"]),
createFilter("ui", ["toolSettings", "toolGroupSettings"]),
createFilter("indexing", []),
diff --git a/gui/src/redux/thunks/exitEditMode.ts b/gui/src/redux/thunks/exitEditMode.ts
index 438783499..9e5452e68 100644
--- a/gui/src/redux/thunks/exitEditMode.ts
+++ b/gui/src/redux/thunks/exitEditMode.ts
@@ -1,24 +1,17 @@
import { createAsyncThunk } from "@reduxjs/toolkit";
-import {
- clearCodeToEdit,
- selectIsInEditMode,
- selectIsSingleRangeEditOrInsertion,
- setMainEditorContentTrigger,
- setMode,
-} from "../slices/sessionSlice";
+import { clearCodeToEdit, setEditDone } from "../slices/editModeState";
+import { setMainEditorContentTrigger, setMode } from "../slices/sessionSlice";
import { ThunkApiType } from "../store";
-import { setEditDone } from "../slices/editModeState";
export const exitEditMode = createAsyncThunk(
"edit/complete",
async (_, { dispatch, extra, getState }) => {
const state = getState();
- const isInEditMode = selectIsInEditMode(state);
- const codeToEdit = state.session.codeToEdit;
- const isSingleRangeEditOrInsertion =
- selectIsSingleRangeEditOrInsertion(state);
+ const codeToEdit = state.editModeState.codeToEdit;
+ const enteredEditModeFromEditor =
+ state.editModeState.enteredEditModeFromEditor;
- if (!isInEditMode) {
+ if (state.session.mode !== "edit") {
return;
}
@@ -35,7 +28,7 @@ export const exitEditMode = createAsyncThunk(
dispatch(setMainEditorContentTrigger(undefined));
extra.ideMessenger.post("edit/exit", {
- shouldFocusEditor: isSingleRangeEditOrInsertion,
+ shouldFocusEditor: enteredEditModeFromEditor,
});
},
);
diff --git a/gui/src/util/getMultifileEditPrompt.ts b/gui/src/util/getMultifileEditPrompt.ts
deleted file mode 100644
index 13ee8ac78..000000000
--- a/gui/src/util/getMultifileEditPrompt.ts
+++ /dev/null
@@ -1,62 +0,0 @@
-import { CodeToEdit, IDE } from "core";
-import { findUriInDirs } from "core/util/uri";
-
-export default function getMultifileEditPrompt(
- codeToEdit: CodeToEdit[],
- dirs?: string[],
-): string {
- const codeToEditStr = codeToEdit
- .map((code) => {
- const { relativePathOrBasename } = findUriInDirs(
- code.filepath,
- dirs ?? window.workspacePaths ?? [],
- );
- return `
-\`\`\` ${relativePathOrBasename}
-${code.contents}
-\`\`\`
- `;
- })
- .join("\n");
-
- return `
-You are an AI assistant designed to help software engineers make multi-file edits in their codebase. Your task is to generate the necessary code changes for multiple files based on the engineer's request. Follow these guidelines:
-
-1. Start with a brief introduction of the task you're about to perform. Do not start with any other preamble, such as "Certainly!"
-2. When providing instructions, if a user needs to interact with a CLI, walk them through each step
-2. Perform file edits in a logical, sequential ordering
-3. For each file edit, provide a brief explanation of the changes
-4. If the user submits a code block that contains a filename in the language specifier, always include the filename in any code block you generate based on that file. The filename should be on the same line as the language specifier in your code block.
- a. When creating new files, also inlcude the filname in the language specifier of the code block.
-6. After providing all file changes, include a brief, sequential overview of the most important 3-5 edits
-
-Remember to be concise and focus on the code changes and their impact.
-
-Here's an example of how your response should be structured:
-
-
-I'll make the following changes to implement feature X:
-
-1. First, I'll modify file1.js to add a new function:
-\`\`\`javascript /path/to/file1.js
-// Entire content of file1.js or changes to be made
-\`\`\`
-
-2. Next, let's create a new test file:
-\`\`\`javascript /path/to/file1.test.js
-# Entire content of file2.py or changes to be made
-\`\`\`
-
-Summary:
-- [Sequential overview of the most important 3-5 edits]
-
-
-Here are the files to base your edits on:
-
-
-${codeToEditStr}
-
-
-Please provide the multi-file edit details based on the engineer's request below:
- `;
-}