update symbols from codeblocks
This commit is contained in:
parent
113ee6b13b
commit
81d1236a02
3 changed files with 17 additions and 23 deletions
|
|
@ -6,14 +6,10 @@ import {
|
|||
MessageContent,
|
||||
RangeInFile,
|
||||
} from "core";
|
||||
import resolveEditorContent, {
|
||||
hasSlashCommandOrContextProvider,
|
||||
} from "../../components/mainInput/resolveInput";
|
||||
import resolveEditorContent from "../../components/mainInput/resolveInput";
|
||||
import { ThunkApiType } from "../store";
|
||||
import { selectDefaultModel } from "../slices/configSlice";
|
||||
import { setIsGatheringContext } from "../slices/sessionSlice";
|
||||
import { findUriInDirs, getUriPathBasename } from "core/util/uri";
|
||||
import { updateFileSymbolsFromNewContextItems } from "./updateFileSymbols";
|
||||
|
||||
export const gatherContext = createAsyncThunk<
|
||||
{
|
||||
|
|
@ -95,8 +91,6 @@ export const gatherContext = createAsyncThunk<
|
|||
}
|
||||
}
|
||||
|
||||
dispatch(updateFileSymbolsFromNewContextItems(selectedContextItems));
|
||||
|
||||
if (promptPreamble) {
|
||||
if (typeof content === "string") {
|
||||
content = promptPreamble + content;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import { resetStateForNewMessage } from "./resetStateForNewMessage";
|
|||
import { streamNormalInput } from "./streamNormalInput";
|
||||
import { streamSlashCommand } from "./streamSlashCommand";
|
||||
import { streamThunkWrapper } from "./streamThunkWrapper";
|
||||
import { updateFileSymbolsFromFiles } from "./updateFileSymbols";
|
||||
|
||||
const getSlashCommandForInput = (
|
||||
input: MessageContent,
|
||||
|
|
@ -79,6 +80,15 @@ export const streamResponseThunk = createAsyncThunk<
|
|||
const unwrapped = unwrapResult(result);
|
||||
const { selectedContextItems, selectedCode, content } = unwrapped;
|
||||
|
||||
// symbols for both context items AND selected codeblocks
|
||||
const filesForSymbols = [
|
||||
...selectedContextItems
|
||||
.filter((item) => item.uri?.type === "file" && item?.uri?.value)
|
||||
.map((item) => item.uri!.value),
|
||||
...selectedCode.map((rif) => rif.filepath),
|
||||
];
|
||||
dispatch(updateFileSymbolsFromFiles(filesForSymbols));
|
||||
|
||||
dispatch(
|
||||
updateHistoryItemAtIndex({
|
||||
index: inputIndex,
|
||||
|
|
|
|||
|
|
@ -1,28 +1,22 @@
|
|||
import { createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { ThunkApiType } from "../store";
|
||||
import { updateFileSymbols } from "../slices/sessionSlice";
|
||||
import { ContextItemWithId } from "core";
|
||||
import { ContextItemWithId, RangeInFile } from "core";
|
||||
|
||||
/*
|
||||
Get file symbols for given context items
|
||||
Overwrite symbols for existing file matches
|
||||
*/
|
||||
export const updateFileSymbolsFromNewContextItems = createAsyncThunk<
|
||||
export const updateFileSymbolsFromFiles = createAsyncThunk<
|
||||
void,
|
||||
ContextItemWithId[],
|
||||
string[],
|
||||
ThunkApiType
|
||||
>(
|
||||
"symbols/updateFromContextItems",
|
||||
async (contextItems, { dispatch, extra, getState }) => {
|
||||
async (filepaths, { dispatch, extra, getState }) => {
|
||||
try {
|
||||
// Get unique file uris from context items
|
||||
const uniqueUris = Array.from(
|
||||
new Set(
|
||||
contextItems
|
||||
.filter((item) => item.uri?.type === "file" && item?.uri?.value)
|
||||
.map((item) => item.uri!.value),
|
||||
),
|
||||
);
|
||||
const uniqueUris = Array.from(new Set(filepaths));
|
||||
|
||||
// Update symbols for those files
|
||||
if (uniqueUris.length > 0) {
|
||||
|
|
@ -36,11 +30,7 @@ export const updateFileSymbolsFromNewContextItems = createAsyncThunk<
|
|||
dispatch(updateFileSymbols(result.content));
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(
|
||||
"Error updating file symbols from context items",
|
||||
e,
|
||||
contextItems,
|
||||
);
|
||||
console.error("Error updating file symbols from filepaths", e, filepaths);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue