Merge branch 'main' into nate/blocks-front-and-center

This commit is contained in:
Nate 2025-03-23 01:02:21 -07:00
commit 7ccf9d814c
14 changed files with 31 additions and 793 deletions

3
.gitignore vendored
View file

@ -163,6 +163,9 @@ extensions/intellij/.idea/**
**/.idea/workspace.xml
**/.idea/usage.statistics.xml
**/.idea/shelf/
**/.idea/inspectionProfiles/Project_Default.xml
**/.idea/php.xml
extensions/intellij/bin
extensions/.continue-debug/

View file

@ -22,7 +22,6 @@ import { DataLogger } from "./data/log";
import { streamDiffLines } from "./edit/streamDiffLines";
import { CodebaseIndexer, PauseToken } from "./indexing/CodebaseIndexer";
import DocsService from "./indexing/docs/DocsService";
import { getAllSuggestedDocs } from "./indexing/docs/suggestions";
import Ollama from "./llm/llms/Ollama";
import { createNewPromptFileV2 } from "./promptFiles/v2/createNewPromptFile";
import { callTool } from "./tools/callTool";
@ -807,14 +806,6 @@ export class Core {
// this.docsService.setPaused(msg.data.id, msg.data.paused); // not supported yet
}
});
on("docs/getSuggestedDocs", async (msg) => {
if (hasRequestedDocs) {
return;
} // TODO, remove, hack because of rerendering
hasRequestedDocs = true;
const suggestedDocs = await getAllSuggestedDocs(this.ide);
this.messenger.send("docs/suggestions", suggestedDocs);
});
on("docs/initStatuses", async (msg) => {
void this.docsService.initStatuses();
});
@ -989,4 +980,3 @@ export class Core {
// private
}
let hasRequestedDocs = false;

View file

@ -1,129 +0,0 @@
import {
PackageDocsResult,
FilePathAndName,
PackageFilePathAndName,
IDE,
PackageDetails,
ParsedPackageInfo,
} from "../../..";
import { getUriPathBasename } from "../../../util/uri";
import { walkDir, walkDirs } from "../../walkDir";
import { PythonPackageCrawler } from "./packageCrawlers/Python";
import { NodePackageCrawler } from "./packageCrawlers/TsJs";
const PACKAGE_CRAWLERS = [NodePackageCrawler, PythonPackageCrawler];
export interface PackageCrawler {
packageRegistry: string;
getPackageFiles(files: FilePathAndName[]): PackageFilePathAndName[];
parsePackageFile(
file: PackageFilePathAndName,
contents: string,
): ParsedPackageInfo[];
getPackageDetails(packageInfo: ParsedPackageInfo): Promise<PackageDetails>;
}
export async function getAllSuggestedDocs(ide: IDE) {
const allFileUris = await walkDirs(ide);
const allFiles = allFileUris.map((uri) => ({
path: uri,
name: getUriPathBasename(uri),
}));
// Build map of language -> package files
const packageFilesByRegistry: Record<string, PackageFilePathAndName[]> = {};
for (const Crawler of PACKAGE_CRAWLERS) {
const crawler = new Crawler();
const packageFilePaths = crawler.getPackageFiles(allFiles);
packageFilesByRegistry[crawler.packageRegistry] = packageFilePaths;
}
// Get file contents for all unique package files
const uniqueFilePaths = Array.from(
new Set(
Object.values(packageFilesByRegistry).flatMap((files) =>
files.map((file) => file.path),
),
),
);
const fileContentsArray = await Promise.all(
uniqueFilePaths.map(async (path) => {
const contents = await ide.readFile(path);
return { path, contents };
}),
);
const fileContents = new Map(
fileContentsArray.map(({ path, contents }) => [path, contents]),
);
// Parse package files and build map of language -> packages
const packagesByCrawler: Record<string, ParsedPackageInfo[]> = {};
PACKAGE_CRAWLERS.forEach((Crawler) => {
const crawler = new Crawler();
packagesByCrawler[crawler.packageRegistry] = [];
const packageFiles = packageFilesByRegistry[crawler.packageRegistry];
packageFiles.forEach((file) => {
const contents = fileContents.get(file.path);
if (!contents) {
return;
}
const packages = crawler.parsePackageFile(file, contents);
packagesByCrawler[crawler.packageRegistry].push(...packages);
});
});
// Deduplicate packages per language
// TODO - this is where you would allow docs for different versions
// by e.g. using "name-version" as the map key instead of just name
// For now have not allowed
const registries = Object.keys(packagesByCrawler);
registries.forEach((registry) => {
const packages = packagesByCrawler[registry];
const uniquePackages = Array.from(
new Map(packages.map((pkg) => [pkg.name, pkg])).values(),
);
packagesByCrawler[registry] = uniquePackages;
});
// Get documentation links for all packages
const allDocsResults: PackageDocsResult[] = [];
await Promise.all(
PACKAGE_CRAWLERS.map(async (Crawler) => {
const crawler = new Crawler();
const packages = packagesByCrawler[crawler.packageRegistry];
const docsByRegistry = await Promise.all(
packages.map(async (packageInfo) => {
try {
const details = await crawler.getPackageDetails(packageInfo);
if (!details.docsLink) {
return {
packageInfo,
error: `No documentation link found for ${packageInfo.name}`,
};
}
return {
packageInfo,
details: {
...details,
docsLink: details.docsLink,
docsLinkWarning: details.docsLink.includes("github.com")
? "Github docs not supported, find the docs site"
: details.docsLink.includes("docs")
? undefined
: "May not be a docs site, check the URL",
},
};
} catch (error) {
return {
packageInfo,
error: `Error getting package details for ${packageInfo.name}`,
};
}
}),
);
allDocsResults.push(...docsByRegistry);
}),
);
return allDocsResults;
}

View file

@ -1,63 +0,0 @@
import { PackageCrawler } from "..";
import {
FilePathAndName,
PackageDetails,
PackageFilePathAndName,
ParsedPackageInfo,
} from "../../../..";
export class PythonPackageCrawler implements PackageCrawler {
packageRegistry = "pypi";
getPackageFiles(files: FilePathAndName[]): PackageFilePathAndName[] {
// For Python, we typically look for files like requirements.txt or Pipfile
return files
.filter(
(file) => file.name === "requirements.txt" || file.name === "Pipfile",
)
.map((file) => ({
...file,
packageRegistry: "pypi",
}));
}
parsePackageFile(
file: PackageFilePathAndName,
contents: string,
): ParsedPackageInfo[] {
// Assume the fileContent is a string from a requirements.txt formatted file
return contents
.split("\n")
.map((line) => {
const [name, version] = line.split("==");
return { name, version, packageFile: file, language: "py" };
})
.filter((pkg) => pkg.name && pkg.version);
}
async getPackageDetails(
packageInfo: ParsedPackageInfo,
): Promise<PackageDetails> {
// Fetch metadata from PyPI to find the documentation link
const response = await fetch(
`https://pypi.org/pypi/${packageInfo.name}/json`,
);
if (!response.ok) {
throw new Error(`Could not fetch data for package ${packageInfo.name}`);
}
const data = await response.json();
const homePage = data?.info?.home_page as string | undefined;
return {
docsLink:
(data?.info?.project_urls?.Documentation as string | undefined) ??
homePage,
title: data?.info?.name as string | undefined,
description: data?.info?.summary as string | undefined,
repo:
(data?.info?.project_urls?.Repository as string | undefined) ??
homePage,
license: data?.info?.license as string | undefined,
};
}
}

View file

@ -1,77 +0,0 @@
import { PackageCrawler } from "..";
import {
FilePathAndName,
PackageDetails,
PackageFilePathAndName,
ParsedPackageInfo,
} from "../../../..";
export class NodePackageCrawler implements PackageCrawler {
packageRegistry = "npm";
getPackageFiles(files: FilePathAndName[]): PackageFilePathAndName[] {
// For Javascript/TypeScript, we look for package.json file
return files
.filter((file) => file.name === "package.json")
.map((file) => ({
...file,
packageRegistry: this.packageRegistry,
}));
}
parsePackageFile(
file: PackageFilePathAndName,
contents: string,
): ParsedPackageInfo[] {
// Parse the package.json content
const jsonData = JSON.parse(contents) as Record<string, Object>;
const dependencies = Object.entries(jsonData.dependencies || {}).concat(
Object.entries(jsonData.devDependencies || {}),
);
// Filter out types packages and check if typescript is present
let foundTypes = false;
const filtered = dependencies.filter(([name, _]) => {
if (name.startsWith("@types/")) {
foundTypes = true;
return false;
}
if (name.includes("typescript")) {
foundTypes = true;
}
return true;
});
return filtered.map(([name, version]) => ({
name,
version,
packageFile: file,
language: foundTypes ? "ts" : "js",
}));
}
async getPackageDetails(
packageInfo: ParsedPackageInfo,
): Promise<PackageDetails> {
const { name } = packageInfo;
// Fetch metadata from the NPM registry to find the documentation link
const response = await fetch(`https://registry.npmjs.org/${name}`);
if (!response.ok) {
throw new Error(`Could not fetch data for package ${name}`);
}
const data = await response.json();
// const dependencies = Object.keys(packageContentData.dependencies || {})
// .concat(Object.keys(packageContentData.devDependencies || {}));
// const usesTypescript = dependencies.includes("typescript");
return {
docsLink: data.homepage as string | undefined,
title: name, // package.json doesn't have specific title field
description: data.description as string | undefined,
repo: Array.isArray(data.repository)
? (data.respository[0]?.url as string | undefined)
: undefined,
license: data.license as string | undefined,
};
}
}

View file

@ -1,283 +0,0 @@
// Generated by continue
import { getAllSuggestedDocs } from "./index";
import { testIde } from "../../../test/fixtures";
import {
setUpTestDir,
tearDownTestDir,
addToTestDir,
} from "../../../test/testDir";
import fetch, { RequestInfo } from "node-fetch";
jest.mock("node-fetch", undefined, {
virtual: false,
});
describe.skip("getAllSuggestedDocs", () => {
beforeEach(() => {
setUpTestDir();
jest.clearAllMocks();
});
afterEach(() => {
tearDownTestDir();
jest.restoreAllMocks();
});
it("should return package docs for JavaScript and Python projects", async () => {
// Set up test files
addToTestDir([
[
"package.json",
JSON.stringify({
dependencies: {
express: "^4.17.1",
lodash: "^4.17.21",
},
devDependencies: {
typescript: "^4.0.0",
},
}),
],
["requirements.txt", "requests==2.25.1\nflask==1.1.2"],
]);
const mockedFetch = fetch as jest.MockedFunction<typeof fetch>;
mockedFetch.mockImplementation((url: URL | RequestInfo) => {
if (url.toString().includes("registry.npmjs.org/express")) {
return Promise.resolve({
ok: true,
json: jest.fn().mockResolvedValue({
homepage: "https://expressjs.com/",
name: "express",
description: "Fast, unopinionated, minimalist web framework",
license: "MIT",
}),
}) as any;
} else if (url.toString().includes("registry.npmjs.org/lodash")) {
return Promise.resolve({
ok: true,
json: jest.fn().mockResolvedValue({
homepage: "https://lodash.com/",
name: "lodash",
description: "Lodash modular utilities.",
license: "MIT",
}),
}) as any;
} else if (url.toString().includes("pypi.org/pypi/requests/json")) {
return Promise.resolve({
ok: true,
json: jest.fn().mockResolvedValue({
info: {
home_page: "https://docs.python-requests.org/",
name: "requests",
summary: "Python HTTP for Humans.",
license: "Apache 2.0",
},
}),
}) as any;
} else if (url.toString().includes("pypi.org/pypi/flask/json")) {
return Promise.resolve({
ok: true,
json: jest.fn().mockResolvedValue({
info: {
home_page: "https://palletsprojects.com/p/flask/",
name: "flask",
summary:
"A simple framework for building complex web applications.",
license: "BSD-3-Clause",
},
}),
}) as any;
} else {
return Promise.reject(new Error(`Unhandled URL: ${url}`));
}
});
const results = await getAllSuggestedDocs(testIde);
expect(results).toHaveLength(4);
expect(results).toEqual(
expect.arrayContaining([
expect.objectContaining({
packageInfo: expect.objectContaining({ name: "express" }),
details: expect.objectContaining({
docsLink: "https://expressjs.com/",
}),
}),
expect.objectContaining({
packageInfo: expect.objectContaining({ name: "lodash" }),
details: expect.objectContaining({
docsLink: "https://lodash.com/",
}),
}),
expect.objectContaining({
packageInfo: expect.objectContaining({ name: "requests" }),
details: expect.objectContaining({
docsLink: "https://docs.python-requests.org/",
}),
}),
expect.objectContaining({
packageInfo: expect.objectContaining({ name: "flask" }),
details: expect.objectContaining({
docsLink: "https://palletsprojects.com/p/flask/",
}),
}),
]),
);
// Verify no errors are present
results.forEach((result) => {
expect(result.error).toBeUndefined();
});
});
it("should handle packages without documentation links", async () => {
addToTestDir([
[
"package.json",
JSON.stringify({
dependencies: {
"no-docs-package": "^1.0.0",
},
}),
],
]);
// Mock fetch
const mockedFetch = fetch as jest.MockedFunction<typeof fetch>;
mockedFetch.mockImplementation((url: RequestInfo | URL) => {
if (url.toString().includes("registry.npmjs.org/no-docs-package")) {
return Promise.resolve({
ok: true,
json: jest.fn().mockResolvedValue({
name: "no-docs-package",
description: "A package without docs",
license: "MIT",
// No homepage provided
}),
}) as any;
} else {
return Promise.reject(new Error(`Unhandled URL: ${url}`));
}
});
const results = await getAllSuggestedDocs(testIde);
expect(results).toHaveLength(1);
expect(results[0].error).toContain(
"No documentation link found for no-docs-package",
);
expect(results[0].details).toBeUndefined();
});
it("should handle errors when fetching package details", async () => {
addToTestDir([
[
"package.json",
JSON.stringify({
dependencies: {
"error-package": "^1.0.0",
},
}),
],
]);
// Mock fetch
const mockedFetch = fetch as jest.MockedFunction<typeof fetch>;
mockedFetch.mockImplementation((url: URL | RequestInfo) => {
if (url.toString().includes("registry.npmjs.org/error-package")) {
return Promise.resolve({
ok: false,
}) as any;
} else {
return Promise.reject(new Error(`Unhandled URL: ${url}`));
}
});
const results = await getAllSuggestedDocs(testIde);
expect(results).toHaveLength(1);
expect(results[0].error).toContain(
"Error getting package details for error-package",
);
expect(results[0].details).toBeUndefined();
});
it("should handle workspaces with no package files", async () => {
const results = await getAllSuggestedDocs(testIde);
expect(results).toEqual([]);
});
it("should handle packages with GitHub documentation links", async () => {
addToTestDir([
[
"package.json",
JSON.stringify({
dependencies: {
"github-docs-package": "^1.0.0",
},
}),
],
]);
// Mock fetch
const mockedFetch = fetch as jest.MockedFunction<typeof fetch>;
mockedFetch.mockImplementation((url: URL | RequestInfo) => {
if (url.toString().includes("registry.npmjs.org/github-docs-package")) {
return Promise.resolve({
ok: true,
json: jest.fn().mockResolvedValue({
homepage: "https://github.com/user/repo",
name: "github-docs-package",
description: "A package with GitHub docs",
license: "MIT",
}),
}) as any;
} else {
return Promise.reject(new Error(`Unhandled URL: ${url}`));
}
});
const results = await getAllSuggestedDocs(testIde);
expect(results).toHaveLength(1);
expect(results[0].details?.docsLink).toBe("https://github.com/user/repo");
expect(results[0].details?.docsLinkWarning).toBe(
"Github docs not supported, find the docs site",
);
});
it("should handle packages with non-docs links", async () => {
addToTestDir([["requirements.txt", "non-docs-package==1.0.0"]]);
// Mock fetch
const mockedFetch = fetch as jest.MockedFunction<typeof fetch>;
mockedFetch.mockImplementation((url: URL | RequestInfo) => {
if (url.toString().includes("pypi.org/pypi/non-docs-package/json")) {
return Promise.resolve({
ok: true,
json: jest.fn().mockResolvedValue({
info: {
home_page: "https://somewebsite.com",
name: "non-docs-package",
summary: "A package with non-docs homepage",
license: "MIT",
},
}),
}) as any;
} else {
return Promise.reject(new Error(`Unhandled URL: ${url}`));
}
});
const results = await getAllSuggestedDocs(testIde);
expect(results).toHaveLength(1);
expect(results[0].details?.docsLink).toBe("https://somewebsite.com");
expect(results[0].details?.docsLinkWarning).toBe(
"May not be a docs site, check the URL",
);
});
});

View file

@ -52,7 +52,6 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] =
"indexing/reindex",
"indexing/abort",
"indexing/setPaused",
"docs/getSuggestedDocs",
"docs/initStatuses",
"docs/getDetails",
//
@ -81,7 +80,6 @@ export const CORE_TO_WEBVIEW_PASS_THROUGH: (keyof ToWebviewFromCoreProtocol)[] =
"setTTSActive",
"getWebviewHistoryLength",
"getCurrentSessionId",
"docs/suggestions",
"didCloseFiles",
"didSelectOrganization",
];

View file

@ -37,6 +37,5 @@ export type ToWebviewFromIdeOrCoreProtocol = {
setTTSActive: [boolean, void];
getWebviewHistoryLength: [undefined, number];
getCurrentSessionId: [undefined, string];
"docs/suggestions": [PackageDocsResult[], void];
"jetbrains/setColors": [Record<string, string>, void];
};

View file

@ -69,7 +69,6 @@ class MessageTypes {
"setTTSActive",
"getWebviewHistoryLength",
"getCurrentSessionId",
"docs/suggestions",
"didCloseFiles",
"didSelectOrganization"
)
@ -121,7 +120,6 @@ class MessageTypes {
"indexing/reindex",
"indexing/abort",
"indexing/setPaused",
"docs/getSuggestedDocs",
"docs/initStatuses",
"docs/getDetails",
//

View file

@ -1,6 +1,7 @@
const esbuild = require("esbuild");
const fs = require("fs");
const esbuild = require("esbuild");
const flags = process.argv.slice(2);
const esbuildConfig = {
@ -59,9 +60,9 @@ const esbuildConfig = {
// The watcher automatically notices changes to source files
// so the only thing it needs to be notified about is if the
// output file gets removed.
if (fs.existsSync (outFile)) {
console.log("VS Code Extension esbuild up to date");
return;
if (fs.existsSync(outFile)) {
console.log("VS Code Extension esbuild up to date");
return;
}
fs.watchFile(outFile, (current, previous) => {

View file

@ -1,26 +1,17 @@
import {
CheckIcon,
InformationCircleIcon,
PencilIcon,
PlusIcon,
} from "@heroicons/react/24/outline";
import { IndexingStatus, PackageDocsResult, SiteIndexingConfig } from "core";
import preIndexedDocs from "core/indexing/docs/preIndexedDocs";
import { InformationCircleIcon } from "@heroicons/react/24/outline";
import { IndexingStatus, SiteIndexingConfig } from "core";
import { usePostHog } from "posthog-js/react";
import { useContext, useLayoutEffect, useMemo, useRef, useState } from "react";
import { useDispatch } from "react-redux";
import { Input, SecondaryButton } from "..";
import { IdeMessengerContext } from "../../context/IdeMessenger";
import { useAppSelector } from "../../redux/hooks";
import { updateConfig } from "../../redux/slices/configSlice";
import { updateIndexingStatus } from "../../redux/slices/indexingSlice";
import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice";
import FileIcon from "../FileIcon";
import { ToolTip } from "../gui/Tooltip";
import DocsIndexingPeeks from "../mainInput/Lump/sections/docs/DocsIndexingPeeks";
function AddDocsDialog() {
const config = useAppSelector((store) => store.config.config);
const posthog = usePostHog();
const dispatch = useDispatch();
@ -42,36 +33,6 @@ function AddDocsDialog() {
);
}, [indexingStatuses]);
const docsSuggestions = useAppSelector((store) => store.misc.docsSuggestions);
const configDocs = useAppSelector((store) => store.config.config.docs);
const sortedDocsSuggestions = useMemo(() => {
const docsFromConfig = configDocs ?? [];
// Don't show suggestions that are already in the config, indexing, and/or pre-indexed
const filtered = docsSuggestions.filter((sug) => {
const startUrl = sug.details?.docsLink;
return (
!docsFromConfig.find((d) => d.startUrl === startUrl) &&
!docsIndexingStatuses.find((s) => s.id === startUrl) &&
(startUrl ? !preIndexedDocs[startUrl] : true)
);
});
filtered.sort((a, b) => {
const rank = (result: PackageDocsResult) => {
if (result.error) {
return 2;
} else if (result.details?.docsLinkWarning) {
return 1;
} else {
return 0;
}
};
return rank(a) - rank(b);
});
return filtered;
}, [docsSuggestions, configDocs, docsIndexingStatuses]);
const isFormValid = startUrl && title;
useLayoutEffect(() => {
@ -118,59 +79,6 @@ function AddDocsDialog() {
);
}
const handleSelectSuggestion = (docsResult: PackageDocsResult) => {
if (docsResult.error || !docsResult.details) {
setTitle(docsResult.packageInfo.name);
setStartUrl("");
urlRef.current?.focus();
return;
}
const suggestedTitle =
docsResult.details.title ?? docsResult.packageInfo.name;
if (docsResult.details?.docsLinkWarning) {
setTitle(suggestedTitle);
setStartUrl(docsResult.details.docsLink);
urlRef.current?.focus();
return;
}
const siteIndexingConfig: SiteIndexingConfig = {
startUrl: docsResult.details.docsLink,
title: suggestedTitle,
faviconUrl: undefined,
};
ideMessenger.post("context/addDocs", siteIndexingConfig);
posthog.capture("add_docs_gui", { url: startUrl });
// Optimistic status update
dispatch(
updateConfig({
...config,
docs: [
...(config.docs?.filter(
(doc) => doc.startUrl !== docsResult.details.docsLink,
) ?? []),
{
startUrl: docsResult.details.docsLink,
title: suggestedTitle,
faviconUrl: undefined,
},
],
}),
updateIndexingStatus({
type: "docs",
description: "Initializing",
id: docsResult.details.docsLink,
progress: 0,
status: "indexing",
title: docsResult.details.title ?? docsResult.packageInfo.name,
url: docsResult.details.docsLink,
}),
);
};
return (
<div className="px-2 pt-4 sm:px-4">
<div className="">
@ -179,91 +87,10 @@ function AddDocsDialog() {
<p className="m-0 mt-2 p-0 text-stone-500">
For the @docs context provider
</p>
{!!sortedDocsSuggestions.length && (
<p className="m-0 mb-1 mt-4 p-0 font-semibold">Suggestions</p>
)}
<div className="border-lightgray max-h-[145px] overflow-y-scroll rounded-sm py-1 pr-2">
{sortedDocsSuggestions.map((docsResult) => {
const { error, details } = docsResult;
const { language, name, version } = docsResult.packageInfo;
const id = `${language}-${name}-${version}`;
return (
<div
key={id}
className="grid cursor-pointer grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center px-1 py-1 hover:bg-gray-200/10"
onClick={() => {
handleSelectSuggestion(docsResult);
}}
>
<div className="pr-1">
{error || details?.docsLinkWarning ? (
<div>
<PencilIcon
data-tooltip-id={id + "-edit"}
className="text-lightgray h-3 w-3"
/>
<ToolTip id={id + "-edit"} place="bottom">
This may not be a docs page
</ToolTip>
</div>
) : (
<PlusIcon className="text-lightgray h-3.5 w-3.5" />
)}
</div>
<div className="flex items-center gap-0.5">
<div className="hidden sm:block">
<FileIcon
filename={`x.${language}`}
height="1rem"
width="1rem"
/>
</div>
<span className="lines lines-1">{name}</span>
</div>
<div>
{error || !details?.docsLink ? (
<span className="text-lightgray italic">
No docs link found
</span>
) : (
<div className="flex items-center gap-2">
{/* <div>
<LinkIcon className="h-2 w-2" />
</div> */}
<p
className="lines lines-1 m-0 p-0 hover:underline"
onClick={(e) => {
e.stopPropagation();
ideMessenger.post("openUrl", details.docsLink);
}}
>
{details.docsLink}
</p>
</div>
)}
</div>
<div
onClick={(e) => {
e.stopPropagation();
}}
>
<InformationCircleIcon
data-tooltip-id={id + "-info"}
className="text-lightgray h-3.5 w-3.5 select-none"
/>
<ToolTip id={id + "-info"} place="bottom">
<p className="m-0 p-0">{`Version: ${version}`}</p>
<p className="m-0 p-0">{`Found in ${docsResult.packageInfo.packageFile.path}`}</p>
</ToolTip>
</div>
</div>
);
})}
</div>
<div className="mt-3">
<form onSubmit={onSubmit} className="flex flex-col gap-1">
<div className="flex flex-row gap-2">
<label className="flex min-w-16 basis-1/4 flex-col gap-1">
<div className="flex flex-col gap-2">
<label className="flex w-full flex-col gap-1">
<div className="flex flex-row items-center gap-1">
<span>Title</span>
<div>
@ -287,7 +114,7 @@ function AddDocsDialog() {
/>
</label>
<label className="flex basis-3/4 flex-col gap-1">
<label className="flex w-full flex-col gap-1">
<div className="flex flex-row items-center gap-1">
<span className="lines lines-1 whitespace-nowrap">
Start URL
@ -313,9 +140,6 @@ function AddDocsDialog() {
}}
/>
</label>
{/* <div>
<PlusCircleIcon className="h-5 w-5 self-end" />
</div> */}
</div>
<div className="flex flex-row justify-end gap-2">
<SecondaryButton
@ -330,20 +154,19 @@ function AddDocsDialog() {
</div>
</div>
<DocsIndexingPeeks statuses={docsIndexingStatuses} />
<div className="flex flex-row items-end justify-between pb-3">
<div>
{docsIndexingStatuses.length ? (
<p className="mt-2 flex flex-row items-center gap-1 p-0 px-1 text-xs text-stone-500">
<CheckIcon className="h-3 w-3" />
It is safe to close this form while indexing
</p>
) : null}
</div>
{/* <Button className="min-w-16" onClick={closeDialog}>
Done
</Button> */}
</div>
{docsIndexingStatuses.length > 0 && (
<>
<DocsIndexingPeeks statuses={docsIndexingStatuses} />
<div className="flex flex-row items-end justify-between pb-3">
<div>
<InformationCircleIcon className="h-3 w-3" />
<p className="mt-2 flex flex-row items-center gap-1 p-0 px-1 text-xs text-stone-500">
Closing this dialog will not affect indexing progress
</p>
</div>
</div>
</>
)}
</div>
);
}

View file

@ -58,17 +58,10 @@ interface DocsIndexingPeeksProps {
function DocsIndexingPeekList({ statuses }: DocsIndexingPeeksProps) {
return (
<div className="border-vsc-input-border mt-2 flex flex-col border-0 border-t border-solid pt-2">
<p className="mx-0 my-1.5 p-0 px-1 font-semibold text-stone-500">
Currently Indexing:
</p>
<div className="max-h-[100px] overflow-y-auto pr-2">
{statuses.length ? (
statuses.map((status) => {
return <DocsIndexingPeek key={status.id} status={status} />;
})
) : (
<p className="m-0 pl-1 font-semibold text-stone-500">None</p>
)}
{statuses.map((status) => {
return <DocsIndexingPeek key={status.id} status={status} />;
})}
</div>
</div>
);

View file

@ -11,7 +11,6 @@ import {
setConfigResult,
} from "../redux/slices/configSlice";
import { updateIndexingStatus } from "../redux/slices/indexingSlice";
import { updateDocsSuggestions } from "../redux/slices/miscSlice";
import {
addContextItemsAtIndex,
setInactive,
@ -77,7 +76,6 @@ function useSetup() {
const interval = setInterval(() => {
if (hasLoadedConfig.current) {
// Init to run on initial config load
ideMessenger.post("docs/getSuggestedDocs", undefined);
ideMessenger.post("docs/initStatuses", undefined);
dispatch(updateFileSymbolsFromHistory());
dispatch(refreshSessionMetadata({}));
@ -181,10 +179,6 @@ function useSetup() {
[],
);
useWebviewListener("docs/suggestions", async (data) => {
dispatch(updateDocsSuggestions(data));
});
// IDE event listeners
useWebviewListener(
"getWebviewHistoryLength",

View file

@ -2,12 +2,10 @@ import { PayloadAction, createSlice } from "@reduxjs/toolkit";
import { PackageDocsResult } from "core";
export type MiscState = {
docsSuggestions: PackageDocsResult[];
lastControlServerBetaEnabledStatus: boolean;
};
const initialState: MiscState = {
docsSuggestions: [],
lastControlServerBetaEnabledStatus: false,
};
@ -20,17 +18,10 @@ export const miscSlice = createSlice({
action: PayloadAction<boolean>,
) => {
state.lastControlServerBetaEnabledStatus = action.payload;
},
updateDocsSuggestions: (
state,
{ payload }: PayloadAction<PackageDocsResult[]>,
) => {
state.docsSuggestions = payload;
},
}
},
});
export const { setLastControlServerBetaEnabledStatus, updateDocsSuggestions } =
miscSlice.actions;
export const { setLastControlServerBetaEnabledStatus } = miscSlice.actions;
export default miscSlice.reducer;