🐛 fix meilisearch filtering by workspace

This commit is contained in:
Nate Sesti 2023-11-05 14:16:58 -08:00
parent f6a4cc9b24
commit 190969581d
12 changed files with 12 additions and 2649 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -327,9 +327,7 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => {
const client = useContext(GUIClientContext);
const dispatch = useDispatch();
const workspacePaths = useSelector(
(state: RootStore) => state.config.workspacePaths
);
const workspacePaths = (window as any).workspacePaths || [];
const sessionState = useSelector((state: RootStore) => state.sessionState);
const [history, setHistory] = React.useState<string[]>([]);

View file

@ -127,9 +127,7 @@ const Layout = () => {
const timeline = useSelector(
(state: RootStore) => state.sessionState.history
);
const workspacePaths = useSelector(
(state: RootStore) => state.config.workspacePaths
);
const workspacePaths = (window as any).workspacePaths || [];
const sessionState = useSelector((state: RootStore) => state.sessionState);
// #endregion

View file

@ -18,11 +18,7 @@ import {
setIndexingProgress,
setSlashCommands,
} from "../redux/slices/serverStateReducer";
import {
setApiUrl,
setVscMachineId,
setWorkspacePaths,
} from "../redux/slices/configSlice";
import { setApiUrl, setVscMachineId } from "../redux/slices/configSlice";
function useSetup(
client: ContinueGUIClientProtocol | undefined,
@ -107,7 +103,6 @@ function useSetup(
(window as any).vscMachineId = event.data.vscMachineId;
(window as any).vscMediaUrl = event.data.vscMediaUrl;
dispatch(setApiUrl(event.data.serverUrl));
dispatch(setWorkspacePaths(event.data.workspacePaths));
dispatch(setVscMachineId(event.data.vscMachineId));
// dispatch(setVscMediaUrl(event.data.vscMediaUrl));

View file

@ -153,9 +153,7 @@ function GUI(props: GUIProps) {
// #region Selectors
const sessionState = useSelector((state: RootStore) => state.sessionState);
const workspacePaths = useSelector(
(state: RootStore) => state.config.workspacePaths
);
const workspacePaths = (window as any).workspacePaths || [];
const defaultModel = useSelector(
(state: RootStore) => (state.serverState.config as any).models?.default

View file

@ -65,9 +65,7 @@ function TableRow({
const client = useContext(GUIClientContext);
const apiUrl = useSelector((state: RootStore) => state.config.apiUrl);
const currentSession = useSelector((state: RootStore) => state.sessionState);
const workspaceDirectory = useSelector(
(state: RootStore) => state.config.workspacePaths?.[0] || ""
);
const workspacePaths = (window as any).workspacePaths || [""];
const [hovered, setHovered] = useState(false);
return (
@ -79,7 +77,7 @@ function TableRow({
<TdDiv
onClick={async () => {
// Save current session
client?.persistSession(currentSession, workspaceDirectory);
client?.persistSession(currentSession, workspacePaths[0]);
// Load new session
const response = await fetch(
@ -139,9 +137,7 @@ function History() {
>([]);
const client = useContext(GUIClientContext);
const apiUrl = useSelector((state: RootStore) => state.config.apiUrl);
const workspacePaths = useSelector(
(state: RootStore) => state.config.workspacePaths
);
const workspacePaths = (window as any).workspacePaths || [];
const deleteSessionInUI = async (sessionId: string) => {
setSessions((prev) =>

View file

@ -7,19 +7,9 @@ export const configSlice = createSlice({
name: "config",
initialState: {
apiUrl: windowAny.serverUrl || "http://localhost:8000",
workspacePaths: windowAny.workspacePaths || [],
vscMachineId: windowAny.vscMachineId || undefined,
} as RootStore["config"],
reducers: {
setWorkspacePaths: (
state: RootStore["config"],
action: { type: string; payload: string[] }
) => {
return {
...state,
workspacePaths: action.payload,
};
},
setApiUrl: (
state: RootStore["config"],
action: { type: string; payload: string }
@ -51,11 +41,6 @@ export const configSlice = createSlice({
},
});
export const {
setVscMachineId,
setApiUrl,
setWorkspacePaths,
setSessionId,
setDataSwitchOn,
} = configSlice.actions;
export const { setVscMachineId, setApiUrl, setSessionId, setDataSwitchOn } =
configSlice.actions;
export default configSlice.reducer;

View file

@ -21,7 +21,6 @@ export interface ChatMessage {
export interface RootStore {
config: {
workspacePaths: string[] | undefined;
apiUrl: string;
vscMachineId: string | undefined;
};

View file

@ -18,6 +18,7 @@ from ..server.meilisearch_server import (
poll_meilisearch_running,
restart_meilisearch,
start_meilisearch,
remove_meilisearch_disallowed_chars,
)
from .main import (
ChatMessage,
@ -349,7 +350,8 @@ class ContextManager:
context_items = await provider.provide_context_items(workspace_dir)
documents = [
{
"id": item.description.id.to_string(),
"id": item.description.id.to_string()
+ remove_meilisearch_disallowed_chars(workspace_dir),
"name": item.description.name,
"description": item.description.description,
"content": item.content,