@arbidocs/react 0.5.72 → 0.5.73

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2495,6 +2495,13 @@ function DocumentCardMenu({
2495
2495
  ] })
2496
2496
  ] });
2497
2497
  }
2498
+ var PARSED_STATUSES = /* @__PURE__ */ new Set(["completed", "low-content"]);
2499
+ function noTextMessage(status) {
2500
+ if (status === "failed")
2501
+ return "This document could not be processed, so it has no text to review.";
2502
+ if (status === "empty" || status === "skipped") return "No readable content.";
2503
+ return "Still processing. The text appears here when it is ready.";
2504
+ }
2498
2505
  function DocumentReview({
2499
2506
  docId,
2500
2507
  doc,
@@ -2504,7 +2511,19 @@ function DocumentReview({
2504
2511
  onClose,
2505
2512
  className
2506
2513
  }) {
2507
- const parsedQuery = chunkRS6UUPD2_cjs.useParsedDocument(docId, stage);
2514
+ const processingInProp = !!doc?.status && !chunkZNQPUPX6_cjs.FINISHED_DOCUMENT_STATUSES.has(doc.status);
2515
+ const { data: polled } = chunkZNQPUPX6_cjs.useDocument(docId, {
2516
+ enabled: processingInProp,
2517
+ pollWhileProcessing: true
2518
+ });
2519
+ const status = processingInProp ? polled?.status ?? doc?.status : doc?.status;
2520
+ const noTextYet = stage === "final" && !!status && !PARSED_STATUSES.has(status);
2521
+ const parsedQuery = chunkRS6UUPD2_cjs.useParsedDocument(docId, stage, { enabled: !noTextYet });
2522
+ const { isError: parsedFailed, refetch: refetchParsed } = parsedQuery;
2523
+ const readable = !!status && !noTextYet;
2524
+ React__default.default.useEffect(() => {
2525
+ if (readable && parsedFailed) void refetchParsed();
2526
+ }, [readable]);
2508
2527
  const tagsQuery = chunkRS6UUPD2_cjs.useTags(workspaceId);
2509
2528
  const tagNameById = React__default.default.useMemo(() => {
2510
2529
  const map = /* @__PURE__ */ new Map();
@@ -2568,11 +2587,11 @@ function DocumentReview({
2568
2587
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
2569
2588
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "truncate text-sm font-semibold", title, children: title }),
2570
2589
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-xs text-muted-foreground", children: [
2571
- parsedQuery.data?.metadata?.total_number_of_pages ? `${parsedQuery.data.metadata.total_number_of_pages} pages` : `${pages.length} pages`,
2590
+ noTextYet ? "" : parsedQuery.data?.metadata?.total_number_of_pages ? `${parsedQuery.data.metadata.total_number_of_pages} pages` : `${pages.length} pages`,
2572
2591
  findings.length ? ` \xB7 ${findings.length} findings` : ""
2573
2592
  ] })
2574
2593
  ] }),
2575
- doc?.status ? /* @__PURE__ */ jsxRuntime.jsx(chunk3BFSALPC_cjs.Badge, { variant: "secondary", children: doc.status }) : null,
2594
+ status ? /* @__PURE__ */ jsxRuntime.jsx(chunk3BFSALPC_cjs.Badge, { variant: "secondary", children: status }) : null,
2576
2595
  onClose ? /* @__PURE__ */ jsxRuntime.jsx(
2577
2596
  "button",
2578
2597
  {
@@ -2625,7 +2644,14 @@ function DocumentReview({
2625
2644
  ]
2626
2645
  }
2627
2646
  ) : null,
2628
- /* @__PURE__ */ jsxRuntime.jsx("div", { ref: scrollRef, className: "min-w-0 flex-1 overflow-y-auto px-6 py-4", children: parsedQuery.isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full items-center justify-center text-sm text-muted-foreground", children: "Loading document\u2026" }) : parsedQuery.isError ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full items-center justify-center text-sm text-muted-foreground", children: "Could not load this document\u2019s content." }) : pages.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full items-center justify-center text-sm text-muted-foreground", children: "No readable content." }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mx-auto max-w-3xl space-y-8", children: pages.map(([pageNum, chunks]) => /* @__PURE__ */ jsxRuntime.jsxs("section", { children: [
2647
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: scrollRef, className: "min-w-0 flex-1 overflow-y-auto px-6 py-4", children: noTextYet ? /* @__PURE__ */ jsxRuntime.jsx(
2648
+ "div",
2649
+ {
2650
+ className: "flex h-full items-center justify-center text-sm text-muted-foreground",
2651
+ "data-testid": "document-review-no-text",
2652
+ children: noTextMessage(status)
2653
+ }
2654
+ ) : parsedQuery.isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full items-center justify-center text-sm text-muted-foreground", children: "Loading document\u2026" }) : parsedQuery.isError ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full items-center justify-center text-sm text-muted-foreground", children: "Could not load this document\u2019s content." }) : pages.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full items-center justify-center text-sm text-muted-foreground", children: "No readable content." }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mx-auto max-w-3xl space-y-8", children: pages.map(([pageNum, chunks]) => /* @__PURE__ */ jsxRuntime.jsxs("section", { children: [
2629
2655
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-3 flex items-center gap-3", children: [
2630
2656
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs font-medium uppercase tracking-wide text-muted-foreground", children: [
2631
2657
  "Page ",