Skip to content

Commit

Permalink
Handle bug with initial connector page display (onyx-dot-app#2727)
Browse files Browse the repository at this point in the history
* Handle bug with initial connector page display

* Casing consistency
  • Loading branch information
Weves authored Oct 8, 2024
1 parent 672f5cc commit 78e7710
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions web/src/app/admin/connector/[ccPairId]/IndexingAttemptsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
TableBody,
TableCell,
Text,
Callout,
} from "@tremor/react";
import { CCPairFullInfo, PaginatedIndexAttempts } from "./types";
import { IndexAttemptStatus } from "@/components/Status";
Expand All @@ -23,6 +24,7 @@ import Link from "next/link";
import ExceptionTraceModal from "@/components/modals/ExceptionTraceModal";
import { useRouter } from "next/navigation";
import { Tooltip } from "@/components/tooltip/Tooltip";
import { FiInfo } from "react-icons/fi";

// This is the number of index attempts to display per page
const NUM_IN_PAGE = 8;
Expand Down Expand Up @@ -61,7 +63,9 @@ export function IndexingAttemptsTable({ ccPair }: { ccPair: CCPairFullInfo }) {

const batchRetrievalUrlBuilder = useCallback(
(batchNum: number) => {
return `${buildCCPairInfoUrl(ccPair.id)}/index-attempts?page=${batchNum}&page_size=${BATCH_SIZE * NUM_IN_PAGE}`;
return `${buildCCPairInfoUrl(
ccPair.id
)}/index-attempts?page=${batchNum}&page_size=${BATCH_SIZE * NUM_IN_PAGE}`;
},
[ccPair.id]
);
Expand Down Expand Up @@ -124,9 +128,9 @@ export function IndexingAttemptsTable({ ccPair }: { ccPair: CCPairFullInfo }) {
setIsCurrentPageLoading(false);
}

const nextBatchNum = Math.min(
batchNum + 1,
Math.ceil(totalPages / BATCH_SIZE) - 1
const nextBatchNum = Math.max(
Math.min(batchNum + 1, Math.ceil(totalPages / BATCH_SIZE) - 1),
0
);
if (!cachedBatches[nextBatchNum]) {
fetchBatchData(nextBatchNum);
Expand Down Expand Up @@ -182,6 +186,26 @@ export function IndexingAttemptsTable({ ccPair }: { ccPair: CCPairFullInfo }) {
);
}

// if no indexing attempts have been scheduled yet, let the user know why
if (
Object.keys(cachedBatches).length === 0 ||
Object.values(cachedBatches).every((batch) =>
batch.every((page) => page.index_attempts.length === 0)
)
) {
return (
<Callout
className="mt-4"
title="No indexing attempts scheduled yet"
icon={FiInfo}
color="blue"
>
Index attempts are scheduled in the background, and may take some time
to appear. Try refreshing the page in ~30 seconds!
</Callout>
);
}

// This is the index attempt that the user wants to view the trace for
const indexAttemptToDisplayTraceFor = currentPageData?.index_attempts?.find(
(indexAttempt) => indexAttempt.id === indexAttemptTracePopupId
Expand Down

0 comments on commit 78e7710

Please sign in to comment.