add Docs wrong values

This commit is contained in:
Justin Milner 2024-05-19 23:28:32 -04:00
parent 96b7374917
commit 7d7f6bf4ec
5 changed files with 16 additions and 20 deletions

6
core/index.d.ts vendored
View file

@ -135,6 +135,8 @@ export interface LoadSubmenuItemsArgs {
export interface CustomContextProvider {
title: string;
startUrl: string,
maxDepth: number
displayTitle?: string;
description?: string;
renderInlineAs?: string;
@ -146,6 +148,10 @@ export interface CustomContextProvider {
loadSubmenuItems?: (
args: LoadSubmenuItemsArgs,
) => Promise<ContextSubmenuItem[]>;
addDocs(
startUrl: string,
maxDepth: number
)
}
export interface ContextSubmenuItem {

View file

@ -63,7 +63,7 @@ export type Protocol = {
{ title: string },
Promise<ContextSubmenuItem[]>,
];
"context/addDocs": [siteIndexingConfig: SiteIndexingConfig, Promise<void>];
"context/addDocs": [siteIndexingConfig: SiteIndexingConfig, void];
"autocomplete/complete": [AutocompleteInput, Promise<string[]>];
"autocomplete/cancel": [undefined, void];
"autocomplete/accept": [{ completionId: string }, void];
@ -116,6 +116,7 @@ export type Protocol = {
},
ProtocolGeneratorType<DiffLine>,
];
};
export interface IdeSettings {

View file

@ -14,7 +14,6 @@ import { RangeInFileWithContents } from "../commands/util.js";
import { Protocol } from "../protocol.js";
export type IdeProtocol = {
listWorkspaceContents: [undefined, string[]];
getWorkspaceDirs: [undefined, string[]];
listFolders: [undefined, string[]];
writeFile: [{ path: string; contents: string }, void];
@ -72,8 +71,6 @@ export type WebviewProtocol = Protocol &
vscMediaUrl: string;
},
];
errorPopup: [{ message: string }, void];
"index/setPaused": [boolean, void];
"index/forceReIndex": [undefined, void];
openUrl: [string, void];
@ -105,7 +102,6 @@ export type WebviewProtocol = Protocol &
};
export type ReverseWebviewProtocol = {
addDocs: [{ startUrl: string, rootUrl: string; title: string; maxDepth?: number;}]
setInactive: [undefined, void];
configUpdate: [undefined, void];
submitMessage: [{ message: any }, void]; // any -> JSONContent from TipTap

View file

@ -557,15 +557,14 @@ export async function showTutorial() {
});
this.on("context/addDocs", (msg) => {
const siteIndexingConfig: SiteIndexingConfig = {
startUrl: msg.data.url,
rootUrl: msg.data.url,
startUrl: msg.data.startUrl,
rootUrl: msg.data.rootUrl,
title: msg.data.title,
maxDepth: 4
maxDepth: msg.data.maxDepth
};
// const siteIndexingConfig = msg.data
const embeddingsProvider = new TransformersJsEmbeddingsProvider();
console.log("In vscode addDocs")
console.log("In vscode addDocs. maxDepth", siteIndexingConfig.maxDepth, " startUrl: ", siteIndexingConfig.startUrl)
vscode.window.withProgress(
{
location: vscode.ProgressLocation.Notification,

View file

@ -8,13 +8,6 @@ import { setShowDialog } from "../../redux/slices/uiStateSlice";
import { postToIde } from "../../util/ide";
import { SiteIndexingConfig } from "core/index";
// export interface SiteIndexingConfig {
// startUrl: string;
// rootUrl: string;
// title: string;
// maxDepth?: number;
// }
const GridDiv = styled.div`
display: grid;
grid-template-columns: 1fr 1fr;
@ -28,7 +21,6 @@ function AddDocsDialog() {
const [docsTitle, setDocsTitle] = React.useState("");
const [urlValid, setUrlValid] = React.useState(false);
const [maxDepth, setMaxDepth] = React.useState(defaultMaxDepth);
const [maxDepthValid, setMaxDepthValid] = React.useState(false) // ToDo
const dispatch = useDispatch();
@ -76,7 +68,9 @@ function AddDocsDialog() {
type="text"
placeholder={`Max Depth (Default=${defaultMaxDepth})`}
value={maxDepth}
onChange={(e) => setMaxDepth(Number(e.target.value))}
onChange={(e) => {
setMaxDepth(Number(e.target.value))
}}
/>
<Button
disabled={!docsUrl || !urlValid}
@ -88,7 +82,7 @@ function AddDocsDialog() {
title: docsTitle,
maxDepth: maxDepth
};
console.log("triggering addDocs. maxDepth: ", maxDepth)
console.log("triggering addDocs. maxDepth: ", maxDepth, " docsUrl: ", docsUrl, " title: ", docsTitle)
postToIde("context/addDocs", siteIndexingConfig);
setDocsTitle("");
setDocsUrl("");