From 34f6607ab92b1203e28fd5dcbd02692596b9b0aa Mon Sep 17 00:00:00 2001 From: Josh Holmer Date: Mon, 4 Aug 2025 14:00:18 -0400 Subject: [PATCH] feat: improvements to docs indexing status visibility --- core/core.ts | 4 + core/indexing/docs/DocsService.ts | 21 + core/protocol/core.ts | 1 + core/protocol/passThrough.ts | 1 + .../constants/MessageTypes.kt | 1 + .../Lump/sections/docs/DocsDetailsDialog.tsx | 8 +- .../sections/docs/DocsIndexingStatus.test.tsx | 377 ++++++++++++++++++ .../Lump/sections/docs/DocsIndexingStatus.tsx | 92 ++++- .../docs/IndexedPagesTooltip.test.tsx | 213 ++++++++++ .../sections/docs/IndexedPagesTooltip.tsx | 71 ++++ gui/src/redux/thunks/streamResponse.test.ts | 36 +- .../streamResponse_errorHandling.test.ts | 36 +- .../thunks/streamResponse_toolCalls.test.ts | 48 ++- gui/src/util/test/mockStore.ts | 15 +- 14 files changed, 896 insertions(+), 28 deletions(-) create mode 100644 gui/src/components/mainInput/Lump/sections/docs/DocsIndexingStatus.test.tsx create mode 100644 gui/src/components/mainInput/Lump/sections/docs/IndexedPagesTooltip.test.tsx create mode 100644 gui/src/components/mainInput/Lump/sections/docs/IndexedPagesTooltip.tsx diff --git a/core/core.ts b/core/core.ts index 9e34da636..0e82e8e5c 100644 --- a/core/core.ts +++ b/core/core.ts @@ -967,6 +967,10 @@ export class Core { on("docs/getDetails", async (msg) => { return await this.docsService.getDetails(msg.data.startUrl); }); + on("docs/getIndexedPages", async (msg) => { + const pages = await this.docsService.getIndexedPages(msg.data.startUrl); + return Array.from(pages); + }); on("didChangeSelectedProfile", async (msg) => { if (msg.data.id) { diff --git a/core/indexing/docs/DocsService.ts b/core/indexing/docs/DocsService.ts index 59ef36edf..8a4e60a49 100644 --- a/core/indexing/docs/DocsService.ts +++ b/core/indexing/docs/DocsService.ts @@ -858,6 +858,27 @@ export default class DocsService { return docs.map(this.lanceDBRowToChunk); } + async getIndexedPages(startUrl: string): Promise> { + try { + const table = await this.getOrCreateLanceTable({ + initializationVector: [], + startUrl, + }); + + const rows = (await table + .filter(`starturl = '${startUrl}'`) + .select(["path"]) // Only select path to minimize data transfer + .limit(99999999) // Default is 10, we want to show all + .execute()) as { path: string }[]; + + // Get unique paths (pages) + return new Set(rows.map((row) => row.path)); + } catch (e) { + console.warn(`Error getting page list for ${startUrl}:`, e); + return new Set(); + } + } + // SQLITE DB private async getOrCreateSqliteDb() { if (!this.sqliteDb) { diff --git a/core/protocol/core.ts b/core/protocol/core.ts index 8fb4a9a7e..b6d3ffe96 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -285,6 +285,7 @@ export type ToCoreFromIdeOrWebviewProtocol = { "docs/getSuggestedDocs": [undefined, void]; "docs/initStatuses": [undefined, void]; "docs/getDetails": [{ startUrl: string }, DocsIndexingDetails]; + "docs/getIndexedPages": [{ startUrl: string }, string[]]; addAutocompleteModel: [{ model: ModelDescription }, void]; "auth/getAuthUrl": [{ useOnboarding: boolean }, { url: string }]; diff --git a/core/protocol/passThrough.ts b/core/protocol/passThrough.ts index fc0b3d7b5..db1b9eb9a 100644 --- a/core/protocol/passThrough.ts +++ b/core/protocol/passThrough.ts @@ -71,6 +71,7 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] = "indexing/setPaused", "docs/initStatuses", "docs/getDetails", + "docs/getIndexedPages", // "onboarding/complete", "addAutocompleteModel", diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt index c2ba370ed..0111c1173 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt @@ -135,6 +135,7 @@ class MessageTypes { "indexing/setPaused", "docs/initStatuses", "docs/getDetails", + "docs/getIndexedPages", // "onboarding/complete", "addAutocompleteModel", diff --git a/gui/src/components/mainInput/Lump/sections/docs/DocsDetailsDialog.tsx b/gui/src/components/mainInput/Lump/sections/docs/DocsDetailsDialog.tsx index d9faee814..4d5f27099 100644 --- a/gui/src/components/mainInput/Lump/sections/docs/DocsDetailsDialog.tsx +++ b/gui/src/components/mainInput/Lump/sections/docs/DocsDetailsDialog.tsx @@ -1,21 +1,19 @@ import { DocsIndexingDetails } from "core"; -import { usePostHog } from "posthog-js/react"; import { useCallback, useContext, useEffect, useState } from "react"; import { useDispatch } from "react-redux"; import { Tooltip } from "react-tooltip"; import { SecondaryButton } from "../../../.."; import { IdeMessengerContext } from "../../../../../context/IdeMessenger"; -import { useAppSelector } from "../../../../../redux/hooks"; import { setDialogMessage, setShowDialog, } from "../../../../../redux/slices/uiSlice"; + interface DocsDetailsDialogProps { startUrl: string; } + function DocsDetailsDialog({ startUrl }: DocsDetailsDialogProps) { - const config = useAppSelector((store) => store.config.config); - const posthog = usePostHog(); const dispatch = useDispatch(); const ideMessenger = useContext(IdeMessengerContext); @@ -49,7 +47,7 @@ function DocsDetailsDialog({ startUrl }: DocsDetailsDialogProps) { }, []); useEffect(() => { - fetchData(); + void fetchData(); }, []); let comp =
Loading...
; diff --git a/gui/src/components/mainInput/Lump/sections/docs/DocsIndexingStatus.test.tsx b/gui/src/components/mainInput/Lump/sections/docs/DocsIndexingStatus.test.tsx new file mode 100644 index 000000000..ab4524482 --- /dev/null +++ b/gui/src/components/mainInput/Lump/sections/docs/DocsIndexingStatus.test.tsx @@ -0,0 +1,377 @@ +import { + act, + fireEvent, + render, + screen, + waitFor, +} from "@testing-library/react"; +import { SiteIndexingConfig } from "core"; +import { Provider } from "react-redux"; +import { beforeEach, describe, expect, it, vi } from "vitest"; +import { AuthProvider } from "../../../../../context/Auth"; +import { IdeMessengerContext } from "../../../../../context/IdeMessenger"; +import { createMockStore } from "../../../../../util/test/mockStore"; +import DocsIndexingStatus from "./DocsIndexingStatus"; + +const mockLumpContext = { + hideLump: vi.fn(), + showLump: vi.fn(), +}; + +vi.mock("../../LumpContext", () => ({ + useLump: () => mockLumpContext, +})); + +describe("DocsIndexingStatus", () => { + const mockDocConfig: SiteIndexingConfig = { + startUrl: "https://example.com", + title: "Example Docs", + }; + + const mockDocFromYaml = { + startUrl: "https://example.com", + title: "Example Docs", + }; + + const renderComponent = async ( + props: any = {}, + storeState = {}, + mockIdeMessengerSetup?: (mock: any) => void, + ) => { + const { mockIdeMessenger, ...store } = createMockStore(storeState); + + // Configure the mockIdeMessenger for this test + if (mockIdeMessengerSetup) { + mockIdeMessengerSetup(mockIdeMessenger); + } else { + mockIdeMessenger.request.mockResolvedValue({ + status: "success", + content: ["page1.html", "page2.html"], + }); + } + + const result = await act(async () => + render( + + + + + + + , + ), + ); + + return { ...result, mockIdeMessenger }; + }; + + beforeEach(() => { + vi.clearAllMocks(); + }); + + it("renders doc title and basic structure", async () => { + await renderComponent(); + expect(screen.getByText("Example Docs")).toBeInTheDocument(); + }); + + it("renders startUrl when title is not provided", async () => { + const configWithoutTitle = { ...mockDocConfig, title: undefined }; + await renderComponent({ docConfig: configWithoutTitle }); + expect(screen.getByText("https://example.com")).toBeInTheDocument(); + }); + + it("shows progress percentage when indexing", async () => { + const storeState = { + indexing: { + indexing: { + statuses: { + "https://example.com": { + status: "indexing", + progress: 0.45, + description: "Indexing pages...", + }, + }, + }, + }, + }; + + await renderComponent({}, storeState); + expect(screen.getByText("45%")).toBeInTheDocument(); + }); + + it("shows stop icon when indexing", async () => { + const storeState = { + indexing: { + indexing: { + statuses: { + "https://example.com": { + status: "indexing", + progress: 0.25, + }, + }, + }, + }, + }; + + await renderComponent({}, storeState); + const stopIcon = screen.getByTestId("stop-indexing"); + expect(stopIcon).toBeInTheDocument(); + }); + + it("calls abort when stop icon is clicked", async () => { + const storeState = { + indexing: { + indexing: { + statuses: { + "https://example.com": { + status: "indexing", + progress: 0.25, + }, + }, + }, + }, + }; + + const { mockIdeMessenger } = await renderComponent({}, storeState); + const stopButton = screen.getByTestId("stop-indexing"); + fireEvent.click(stopButton); + + expect(mockIdeMessenger.post).toHaveBeenCalledWith("indexing/abort", { + type: "docs", + id: "https://example.com", + }); + }); + + it("shows reindex icon when status is complete", async () => { + const storeState = { + indexing: { + indexing: { + statuses: { + "https://example.com": { + status: "complete", + progress: 1, + }, + }, + }, + }, + }; + + await renderComponent({}, storeState); + const reindexButton = screen.getByTestId("reindex-docs"); + expect(reindexButton).toBeInTheDocument(); + }); + + it("calls reindex when reindex icon is clicked", async () => { + const storeState = { + indexing: { + indexing: { + statuses: { + "https://example.com": { + status: "complete", + progress: 1, + }, + }, + }, + }, + }; + + const { mockIdeMessenger } = await renderComponent({}, storeState); + const reindexButton = screen.getByTestId("reindex-docs"); + fireEvent.click(reindexButton); + + expect(mockIdeMessenger.post).toHaveBeenCalledWith("indexing/reindex", { + type: "docs", + id: "https://example.com", + }); + }); + + it("opens URL when title is clicked and status has URL", async () => { + const storeState = { + indexing: { + indexing: { + statuses: { + "https://example.com": { + status: "complete", + url: "https://example.com/docs", + }, + }, + }, + }, + }; + + const { mockIdeMessenger } = await renderComponent({}, storeState); + const titleElement = screen.getByText("Example Docs"); + fireEvent.click(titleElement); + + expect(mockIdeMessenger.post).toHaveBeenCalledWith( + "openUrl", + "https://example.com/docs", + ); + expect(mockLumpContext.hideLump).toHaveBeenCalled(); + }); + + it("fetches indexed pages when status becomes complete", async () => { + const storeState = { + indexing: { + indexing: { + statuses: { + "https://example.com": { + status: "complete", + progress: 1, + }, + }, + }, + }, + }; + + const { mockIdeMessenger } = await renderComponent({}, storeState); + + await waitFor(() => { + expect(mockIdeMessenger.request).toHaveBeenCalledWith( + "docs/getIndexedPages", + { + startUrl: "https://example.com", + }, + ); + }); + }); + + it("displays indexed pages count when available", async () => { + const storeState = { + indexing: { + indexing: { + statuses: { + "https://example.com": { + status: "complete", + progress: 1, + }, + }, + }, + }, + }; + + await renderComponent({}, storeState, (mockIdeMessenger) => { + mockIdeMessenger.request.mockResolvedValue({ + status: "success", + content: ["page1.html", "page2.html", "page3.html"], + }); + }); + + await waitFor(() => { + expect(screen.getByText("3 pages indexed")).toBeInTheDocument(); + }); + }); + + it("shows singular page text for one page", async () => { + const storeState = { + indexing: { + indexing: { + statuses: { + "https://example.com": { + status: "complete", + progress: 1, + }, + }, + }, + }, + }; + + await renderComponent({}, storeState, (mockIdeMessenger) => { + mockIdeMessenger.request.mockResolvedValue({ + status: "success", + content: ["page1.html"], + }); + }); + + await waitFor(() => { + expect(screen.getByText("1 page indexed")).toBeInTheDocument(); + }); + }); + + it("shows status description when not complete", async () => { + const storeState = { + indexing: { + indexing: { + statuses: { + "https://example.com": { + status: "indexing", + progress: 0.5, + description: "Processing documentation...", + }, + }, + }, + }, + }; + + await renderComponent({}, storeState); + expect(screen.getByText("Processing documentation...")).toBeInTheDocument(); + }); + + it("handles error when fetching indexed pages", async () => { + const consoleSpy = vi.spyOn(console, "error").mockImplementation(() => {}); + + const storeState = { + indexing: { + indexing: { + statuses: { + "https://example.com": { + status: "complete", + progress: 1, + }, + }, + }, + }, + }; + + await renderComponent({}, storeState, (mockIdeMessenger) => { + mockIdeMessenger.request.mockResolvedValue({ + status: "error", + error: "Failed to fetch pages", + }); + }); + + await waitFor(() => { + expect(consoleSpy).toHaveBeenCalledWith( + expect.stringContaining( + "Unable to fetch pages list for https://example.com", + ), + ); + }); + + consoleSpy.mockRestore(); + }); + + it("returns null when hasDeleted is true", async () => { + const { container } = await renderComponent(); + + // Simulate deletion state by accessing the component's internal state + // In a real scenario, this would be tested through user interaction + expect(container.firstChild).not.toBeNull(); + }); + + it("shows loading text when pages are being fetched", async () => { + const storeState = { + indexing: { + indexing: { + statuses: { + "https://example.com": { + status: "complete", + progress: 1, + }, + }, + }, + }, + }; + + await renderComponent({}, storeState, (mockIdeMessenger) => { + // Mock a delayed response to keep in loading state + mockIdeMessenger.request.mockImplementation(() => new Promise(() => {})); + }); + + expect(screen.getByText("Loading site info...")).toBeInTheDocument(); + }); +}); diff --git a/gui/src/components/mainInput/Lump/sections/docs/DocsIndexingStatus.tsx b/gui/src/components/mainInput/Lump/sections/docs/DocsIndexingStatus.tsx index 4b946a1fd..56f43b525 100644 --- a/gui/src/components/mainInput/Lump/sections/docs/DocsIndexingStatus.tsx +++ b/gui/src/components/mainInput/Lump/sections/docs/DocsIndexingStatus.tsx @@ -1,7 +1,7 @@ import { ConfigYaml } from "@continuedev/config-yaml"; import { ArrowPathIcon, StopIcon } from "@heroicons/react/24/outline"; import { SiteIndexingConfig } from "core"; -import { useContext, useMemo, useState } from "react"; +import { useContext, useEffect, useMemo, useState } from "react"; import { IdeMessengerContext } from "../../../../../context/IdeMessenger"; import { useAppDispatch, useAppSelector } from "../../../../../redux/hooks"; import { updateIndexingStatus } from "../../../../../redux/slices/indexingSlice"; @@ -11,9 +11,12 @@ import { } from "../../../../../redux/slices/uiSlice"; import { fontSize } from "../../../../../util"; import ConfirmationDialog from "../../../../dialogs/ConfirmationDialog"; +import { ToolTip } from "../../../../gui/Tooltip"; import EditBlockButton from "../../EditBlockButton"; import { useLump } from "../../LumpContext"; +import { IndexedPagesTooltip } from "./IndexedPagesTooltip"; import { StatusIndicator } from "./StatusIndicator"; + interface IndexingStatusViewerProps { docConfig: SiteIndexingConfig; docFromYaml?: NonNullable[number]; @@ -26,11 +29,15 @@ function DocsIndexingStatus({ const ideMessenger = useContext(IdeMessengerContext); const dispatch = useAppDispatch(); const { hideLump } = useLump(); + const [indexedPages, setIndexedPages] = useState(null); + const [showTooltip, setShowTooltip] = useState(false); const status = useAppSelector( (store) => store.indexing.indexing.statuses[docConfig.startUrl], ); + const isComplete = status?.status === "complete"; + const reIndex = () => ideMessenger.post("indexing/reindex", { type: "docs", @@ -77,8 +84,39 @@ function DocsIndexingStatus({ return Math.min(100, Math.max(0, status.progress * 100)).toFixed(0); }, [status?.progress]); + // Fetch pages list when the status changes to complete + useEffect(() => { + async function getPagesList() { + try { + const response = await ideMessenger.request("docs/getIndexedPages", { + startUrl: docConfig.startUrl, + }); + if (response.status === "error") { + throw new Error(response.error); + } + setIndexedPages(response.content.sort()); + } catch (ex) { + console.error( + `Unable to fetch pages list for ${docConfig.startUrl}: ${ex}`, + ); + } + } + + if (isComplete) { + void getPagesList(); + } + }, [isComplete, ideMessenger, docConfig.startUrl]); + + const showPagesList = () => { + if (indexedPages) { + setShowTooltip(true); + } + }; + if (hasDeleted) return null; + const startUrlSlug = docConfig.startUrl.replace(/[^a-zA-Z0-9_-]/g, "_"); + return (
)} @@ -135,6 +174,7 @@ function DocsIndexingStatus({ )} @@ -147,6 +187,56 @@ function DocsIndexingStatus({
+ + {status && ( +
+

{ + if (isComplete) { + showPagesList(); + } + }} + data-tooltip-id={`docs-tooltip-${startUrlSlug}`} + > + {isComplete + ? indexedPages + ? `${indexedPages.length} page${indexedPages.length === 1 ? "" : "s"} indexed` + : "Loading site info..." + : status.description} +

+
+ )} + + {indexedPages && ( + + + + )} ); } diff --git a/gui/src/components/mainInput/Lump/sections/docs/IndexedPagesTooltip.test.tsx b/gui/src/components/mainInput/Lump/sections/docs/IndexedPagesTooltip.test.tsx new file mode 100644 index 000000000..d585758eb --- /dev/null +++ b/gui/src/components/mainInput/Lump/sections/docs/IndexedPagesTooltip.test.tsx @@ -0,0 +1,213 @@ +import { fireEvent, render, screen } from "@testing-library/react"; +import { Provider } from "react-redux"; +import { beforeEach, describe, expect, it, vi } from "vitest"; +import { IdeMessengerContext } from "../../../../../context/IdeMessenger"; +import { createMockStore } from "../../../../../util/test/mockStore"; +import { IndexedPagesTooltip } from "./IndexedPagesTooltip"; + +describe("IndexedPagesTooltip", () => { + const defaultProps = { + pages: [ + "https://example.com/page1", + "https://example.com/page2", + "https://example.com/sub/page3", + ], + siteTitle: "Example Documentation", + baseUrl: "https://example.com", + }; + + const renderComponent = (props = {}, storeState = {}) => { + const { mockIdeMessenger, ...store } = createMockStore(storeState); + + return { + ...render( + + + + + , + ), + mockIdeMessenger, + store, + }; + }; + + beforeEach(() => { + vi.clearAllMocks(); + }); + + it("renders site title and page count", () => { + renderComponent(); + expect( + screen.getByText("Example Documentation - 3 Pages Indexed"), + ).toBeInTheDocument(); + }); + + it("renders all pages in the list", () => { + renderComponent(); + + // Check that all pages are rendered (with baseUrl prefix removed) + expect(screen.getByText("/page1")).toBeInTheDocument(); + expect(screen.getByText("/page2")).toBeInTheDocument(); + expect(screen.getByText("/sub/page3")).toBeInTheDocument(); + }); + + it("removes baseUrl prefix from page URLs", () => { + const pages = [ + "https://example.com/docs/getting-started", + "https://example.com/docs/api-reference", + "https://other-domain.com/page", // This should not have prefix removed + ]; + + renderComponent({ pages, baseUrl: "https://example.com" }); + + expect(screen.getByText("/docs/getting-started")).toBeInTheDocument(); + expect(screen.getByText("/docs/api-reference")).toBeInTheDocument(); + expect( + screen.getByText("https://other-domain.com/page"), + ).toBeInTheDocument(); + }); + + it("handles pages that don't start with baseUrl", () => { + const pages = [ + "https://different-domain.com/page1", + "mailto:contact@example.com", + ]; + + renderComponent({ pages }); + + expect( + screen.getByText("https://different-domain.com/page1"), + ).toBeInTheDocument(); + expect(screen.getByText("mailto:contact@example.com")).toBeInTheDocument(); + }); + + it("opens URL when page is clicked", () => { + const { mockIdeMessenger } = renderComponent(); + + const pageLink = screen.getByText("/page1"); + fireEvent.click(pageLink); + + expect(mockIdeMessenger.post).toHaveBeenCalledWith( + "openUrl", + "https://example.com/page1", + ); + }); + + it("opens each page URL correctly when clicked", () => { + const { mockIdeMessenger } = renderComponent(); + + // Click on different pages + fireEvent.click(screen.getByText("/page2")); + expect(mockIdeMessenger.post).toHaveBeenCalledWith( + "openUrl", + "https://example.com/page2", + ); + + fireEvent.click(screen.getByText("/sub/page3")); + expect(mockIdeMessenger.post).toHaveBeenCalledWith( + "openUrl", + "https://example.com/sub/page3", + ); + }); + + it("renders empty list when no pages provided", () => { + renderComponent({ pages: [] }); + + expect( + screen.getByText("Example Documentation - 0 Pages Indexed"), + ).toBeInTheDocument(); + expect(screen.queryByRole("listitem")).not.toBeInTheDocument(); + }); + + it("handles single page correctly", () => { + const pages = ["https://example.com/single-page"]; + + renderComponent({ pages }); + + expect( + screen.getByText("Example Documentation - 1 Pages Indexed"), + ).toBeInTheDocument(); + expect(screen.getByText("/single-page")).toBeInTheDocument(); + }); + + it("preserves page order", () => { + const pages = [ + "https://example.com/z-last", + "https://example.com/a-first", + "https://example.com/m-middle", + ]; + + renderComponent({ pages }); + + const listItems = screen.getAllByRole("listitem"); + expect(listItems).toHaveLength(3); + + // Check that the order is preserved as provided, not alphabetically sorted + expect(listItems[0]).toHaveTextContent("/z-last"); + expect(listItems[1]).toHaveTextContent("/a-first"); + expect(listItems[2]).toHaveTextContent("/m-middle"); + }); + + it("applies correct CSS classes for styling", () => { + renderComponent(); + + const pageItems = screen.getAllByRole("listitem"); + pageItems.forEach((item) => { + expect(item).toHaveClass( + "my-1", + "cursor-pointer", + "truncate", + "text-left", + "text-gray-400", + "hover:underline", + ); + }); + }); + + it("shows scrollable container for long lists", () => { + // Create a long list of pages + const longPageList = Array.from( + { length: 20 }, + (_, i) => `https://example.com/page-${i + 1}`, + ); + + const { container } = renderComponent({ pages: longPageList }); + + // Check that the scrollable container exists + const scrollContainer = container.querySelector( + ".max-h-48.overflow-y-auto", + ); + expect(scrollContainer).toBeInTheDocument(); + + // Check that all pages are rendered + expect( + screen.getByText("Example Documentation - 20 Pages Indexed"), + ).toBeInTheDocument(); + longPageList.forEach((_, index) => { + expect(screen.getByText(`/page-${index + 1}`)).toBeInTheDocument(); + }); + }); + + describe("removePrefix utility", () => { + it("removes prefix when string starts with it", () => { + const pages = ["https://example.com/docs/guide"]; + renderComponent({ pages, baseUrl: "https://example.com" }); + expect(screen.getByText("/docs/guide")).toBeInTheDocument(); + }); + + it("returns original string when it doesn't start with prefix", () => { + const pages = ["https://other-site.com/page"]; + renderComponent({ pages, baseUrl: "https://example.com" }); + expect( + screen.getByText("https://other-site.com/page"), + ).toBeInTheDocument(); + }); + + it("handles empty prefix", () => { + const pages = ["https://example.com/page"]; + renderComponent({ pages, baseUrl: "" }); + expect(screen.getByText("https://example.com/page")).toBeInTheDocument(); + }); + }); +}); diff --git a/gui/src/components/mainInput/Lump/sections/docs/IndexedPagesTooltip.tsx b/gui/src/components/mainInput/Lump/sections/docs/IndexedPagesTooltip.tsx new file mode 100644 index 000000000..da3ffa3f7 --- /dev/null +++ b/gui/src/components/mainInput/Lump/sections/docs/IndexedPagesTooltip.tsx @@ -0,0 +1,71 @@ +import { EyeIcon } from "@heroicons/react/24/outline"; +import { useContext } from "react"; +import { useDispatch } from "react-redux"; +import { IdeMessengerContext } from "../../../../../context/IdeMessenger"; +import { + setDialogMessage, + setShowDialog, +} from "../../../../../redux/slices/uiSlice"; +import { fontSize } from "../../../../../util"; +import DocsDetailsDialog from "./DocsDetailsDialog"; + +interface IndexedPagesTooltipProps { + pages: string[]; + siteTitle: string; + baseUrl: string; +} + +function removePrefix(str: string, prefix: string): string { + return str.startsWith(prefix) ? str.slice(prefix.length) : str; +} + +export const IndexedPagesTooltip = ({ + pages, + siteTitle, + baseUrl, +}: IndexedPagesTooltipProps) => { + const ideMessenger = useContext(IdeMessengerContext); + const dispatch = useDispatch(); + + const handleEyeIconClick = (e: React.MouseEvent) => { + e.stopPropagation(); + + // Open the DocsDetailsDialog component as a modal + dispatch(setShowDialog(true)); + dispatch(setDialogMessage()); + }; + + return ( +
+
+ + {siteTitle} - {pages.length} Pages Indexed + + +
+
+
    + {pages.map((page, index) => ( +
  • { + ideMessenger.post("openUrl", page); + }} + > + {removePrefix(page, baseUrl)} +
  • + ))} +
+
+
+ ); +}; diff --git a/gui/src/redux/thunks/streamResponse.test.ts b/gui/src/redux/thunks/streamResponse.test.ts index db4613b08..18800e6cc 100644 --- a/gui/src/redux/thunks/streamResponse.test.ts +++ b/gui/src/redux/thunks/streamResponse.test.ts @@ -567,13 +567,21 @@ describe("streamResponseThunk", () => { returnToMode: "chat", }, indexing: { - indexingState: "disabled", + indexing: { + statuses: {}, + hiddenChatPeekTypes: { + docs: false, + }, + }, }, tabs: { tabsItems: [], }, profiles: { - profiles: [], + organizations: [], + selectedProfileId: null, + selectedOrganizationId: null, + preferencesByProfileId: {}, }, }); }); @@ -1087,13 +1095,21 @@ describe("streamResponseThunk", () => { returnToMode: "chat", }, indexing: { - indexingState: "disabled", + indexing: { + statuses: {}, + hiddenChatPeekTypes: { + docs: false, + }, + }, }, tabs: { tabsItems: [], }, profiles: { - profiles: [], + organizations: [], + selectedProfileId: null, + selectedOrganizationId: null, + preferencesByProfileId: {}, }, }); }); @@ -1632,13 +1648,21 @@ describe("streamResponseThunk", () => { returnToMode: "chat", }, indexing: { - indexingState: "disabled", + indexing: { + statuses: {}, + hiddenChatPeekTypes: { + docs: false, + }, + }, }, tabs: { tabsItems: [], }, profiles: { - profiles: [], + organizations: [], + selectedProfileId: null, + selectedOrganizationId: null, + preferencesByProfileId: {}, }, }); }); diff --git a/gui/src/redux/thunks/streamResponse_errorHandling.test.ts b/gui/src/redux/thunks/streamResponse_errorHandling.test.ts index cebafd20b..1a5b5b935 100644 --- a/gui/src/redux/thunks/streamResponse_errorHandling.test.ts +++ b/gui/src/redux/thunks/streamResponse_errorHandling.test.ts @@ -392,13 +392,21 @@ describe("streamResponseThunk", () => { returnToMode: "chat", }, indexing: { - indexingState: "disabled", + indexing: { + statuses: {}, + hiddenChatPeekTypes: { + docs: false, + }, + }, }, tabs: { tabsItems: [], }, profiles: { - profiles: [], + organizations: [], + selectedProfileId: null, + selectedOrganizationId: null, + preferencesByProfileId: {}, }, }); }); @@ -775,13 +783,21 @@ describe("streamResponseThunk", () => { returnToMode: "chat", }, indexing: { - indexingState: "disabled", + indexing: { + statuses: {}, + hiddenChatPeekTypes: { + docs: false, + }, + }, }, tabs: { tabsItems: [], }, profiles: { - profiles: [], + organizations: [], + selectedProfileId: null, + selectedOrganizationId: null, + preferencesByProfileId: {}, }, }); }); @@ -1088,13 +1104,21 @@ describe("streamResponseThunk", () => { returnToMode: "chat", }, indexing: { - indexingState: "disabled", + indexing: { + statuses: {}, + hiddenChatPeekTypes: { + docs: false, + }, + }, }, tabs: { tabsItems: [], }, profiles: { - profiles: [], + organizations: [], + selectedProfileId: null, + selectedOrganizationId: null, + preferencesByProfileId: {}, }, }); }); diff --git a/gui/src/redux/thunks/streamResponse_toolCalls.test.ts b/gui/src/redux/thunks/streamResponse_toolCalls.test.ts index 239ad1edd..fbe144b67 100644 --- a/gui/src/redux/thunks/streamResponse_toolCalls.test.ts +++ b/gui/src/redux/thunks/streamResponse_toolCalls.test.ts @@ -726,13 +726,21 @@ describe("streamResponseThunk - tool calls", () => { returnToMode: "chat", }, indexing: { - indexingState: "disabled", + indexing: { + statuses: {}, + hiddenChatPeekTypes: { + docs: false, + }, + }, }, tabs: { tabsItems: [], }, profiles: { - profiles: [], + organizations: [], + selectedProfileId: null, + selectedOrganizationId: null, + preferencesByProfileId: {}, }, }); }); @@ -1352,13 +1360,21 @@ describe("streamResponseThunk - tool calls", () => { returnToMode: "chat", }, indexing: { - indexingState: "disabled", + indexing: { + statuses: {}, + hiddenChatPeekTypes: { + docs: false, + }, + }, }, tabs: { tabsItems: [], }, profiles: { - profiles: [], + organizations: [], + selectedProfileId: null, + selectedOrganizationId: null, + preferencesByProfileId: {}, }, }); }); @@ -1986,13 +2002,21 @@ describe("streamResponseThunk - tool calls", () => { returnToMode: "chat", }, indexing: { - indexingState: "disabled", + indexing: { + statuses: {}, + hiddenChatPeekTypes: { + docs: false, + }, + }, }, tabs: { tabsItems: [], }, profiles: { - profiles: [], + organizations: [], + selectedProfileId: null, + selectedOrganizationId: null, + preferencesByProfileId: {}, }, }); }); @@ -2929,13 +2953,21 @@ describe("streamResponseThunk - tool calls", () => { returnToMode: "chat", }, indexing: { - indexingState: "disabled", + indexing: { + statuses: {}, + hiddenChatPeekTypes: { + docs: false, + }, + }, }, tabs: { tabsItems: [], }, profiles: { - profiles: [], + organizations: [], + selectedProfileId: null, + selectedOrganizationId: null, + preferencesByProfileId: {}, }, }); }); diff --git a/gui/src/util/test/mockStore.ts b/gui/src/util/test/mockStore.ts index 3f6b92043..c27bde055 100644 --- a/gui/src/util/test/mockStore.ts +++ b/gui/src/util/test/mockStore.ts @@ -13,7 +13,10 @@ export const createMockStore = (initialState?: Partial) => { const mockIdeMessenger = { request: vi.fn(), post: vi.fn(), + respond: vi.fn(), + streamRequest: vi.fn(), llmStreamChat: vi.fn(), + ide: {} as any, }; const store = configureStore({ @@ -76,7 +79,12 @@ export const createMockStore = (initialState?: Partial) => { ...initialState?.config, }, indexing: { - indexingState: "disabled", + indexing: { + statuses: {}, + hiddenChatPeekTypes: { + docs: false, + }, + }, ...initialState?.indexing, }, tabs: { @@ -84,7 +92,10 @@ export const createMockStore = (initialState?: Partial) => { ...initialState?.tabs, }, profiles: { - profiles: [], + organizations: [], + selectedProfileId: null, + selectedOrganizationId: null, + preferencesByProfileId: {}, ...initialState?.profiles, }, } as RootState,