Skip to content

fix(inbox): raise "Load more" scan cap past loaded backlog in one click - #35117

Closed
detail-app[bot] wants to merge 1 commit into
mainfrom
detail/bug-fix/fix-inbox-raise-load-more-scan-cap-past-loaded-bac-754627
Closed

detail-app[bot] wants to merge 1 commit into
mainfrom
detail/bug-fix/fix-inbox-raise-load-more-scan-cap-past-loaded-bac-754627

Conversation

@detail-app

@detail-app detail-app Bot commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Detail bug report: View on Detail
Closes #35054

Summary

  • Context: TasksTab renders the personal/entity inbox's task list with an IntersectionObserver-driven infinite scroll gated by a client-side "bounded scan" cap (MAX_NARROWED_SCAN = 200) applied whenever the list is narrowed by Type filter, Status filter, or title-search; a "Load more" button in the no-match empty state is supposed to let the user raise that cap and continue scanning.
  • Bug: The cap raise in handleScanFurther advances scanLimit by a fixed MAX_NARROWED_SCAN step, but canLoadMore compares that cap against the total already-loaded task count (tasks.length), not against the number of tasks loaded since the narrowing was applied; so when more than MAX_NARROWED_SCAN raw tasks were already loaded before narrowing, the raise is smaller than the load and canLoadMore stays false, so the IntersectionObserver in useInboxInfiniteList never calls fetchNextPage.
  • Actual vs. expected: Clicking the "Load more" button should trigger one extra page fetch on the first click; instead it is silent — multiple consecutive clicks produce no fetch, no UI change, and no visible feedback, until the accumulated cap finally overtakes tasks.length.
  • Impact: When a user has already loaded ≥ 400 raw tasks (≥ 16 pages of TASK_LIMIT = 25) before narrowing — e.g. scrolling a long Open queue and then picking a Type/Status filter whose matches are none of the loaded rows — the "Load more" button is dead for floor((tasks.length - 200) / 200) clicks before the next page loads: 1 dead click at 400 loaded, 4 at 1000, 24 at 5000. Below 400 loaded the buggy and fixed code paths are behaviourally indistinguishable.

Code with Bug

openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/InboxPage/tabs/TasksTab.tsx:

const scanKey = JSON.stringify([
  status,
  searchQuery,
  typeFilter,
  statusFilter,
]);
const [scanRaise, setScanRaise] = useState({ key: scanKey, extra: 0 });
const scanLimit =
  MAX_NARROWED_SCAN + (scanRaise.key === scanKey ? scanRaise.extra : 0);
const canLoadMore = useCallback(
  (loaded: Task[]) => !isClientNarrowed || loaded.length < scanLimit, // <-- BUG 🔴 cap is compared against ALL loaded raw tasks, not the count scanned under this narrow
  [isClientNarrowed, scanLimit]
);
const handleScanFurther = useCallback(
  () =>
    setScanRaise((raise) => ({
      key: scanKey,
      // <-- BUG 🔴 raise is fixed +MAX step regardless of how far loaded.length already exceeds it
      extra: (raise.key === scanKey ? raise.extra : 0) + MAX_NARROWED_SCAN,
    })),
  [scanKey]
);

Also in TasksTab.tsx (empty state wiring):

emptyState={
  showEmptyState ? (
    <TasksEmptyState
      isNarrowed={isNarrowed}
      scannedCount={hasMore ? tasks.length : undefined}
      status={status}
      onClearFilters={handleClearFilters}
      onLoadMore={handleScanFurther} // <-- BUG 🔴 dead clicks when tasks.length > MAX_NARROWED_SCAN at narrow time
    />
  ) : undefined
}

Explanation

  • useInboxInfiniteList only calls fetchNextPage() when canLoadMore(items) !== false. With a narrowed list, canLoadMore returns loaded.length < scanLimit.
  • If the user scrolls first (e.g., tasks.length = 1000) and then applies a Type/Status filter that yields zero matches among already-loaded tasks, scanLimit starts at 200 and canLoadMore is false.
  • Each "Load more" click only increases scanLimit by 200, so canLoadMore remains false until scanLimit exceeds the entire already-loaded backlog (e.g., 5 clicks to pass 1000). While canLoadMore is false, the IntersectionObserver-triggered loadMore no-ops and no network request is sent.
  • The UI provides no loading/disabled feedback for the dead clicks, so the button appears broken.

Codebase Inconsistency

openmetadata-ui/src/main/resources/ui/src/hooks/useInboxInfiniteList.ts gates fetching on canLoadMore:

const loadMore = useCallback(() => {
  const allowed = canLoadMore?.(items) !== false;
  if (hasNextPage && !isFetchingNextPage && allowed) {
    fetchNextPage();
  }
}, [hasNextPage, isFetchingNextPage, canLoadMore, items, fetchNextPage]);

Recommended Fix

Raise the scan cap past the already-loaded backlog in one click when it is already exceeded, so the next page fetch can happen immediately.

openmetadata-ui/src/main/resources/ui/src/components/discovery/personal-space/InboxPage/tabs/TasksTab.tsx:

const handleScanFurther = useCallback(
  () =>
    setScanRaise((raise) => {
      const base = raise.key === scanKey ? raise.extra : 0;
      return {
        key: scanKey,
        extra: Math.max(base, tasks.length),
      };
    }),
  [scanKey, tasks.length]
);

History

This bug was introduced in commit 36729ad (PR #33578), which added the client-side bounded-scan feature (MAX_NARROWED_SCAN, scanRaise, scanLimit, canLoadMore, handleScanFurther).


Automatic Fixes PRs can be configured here.

@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@detail-app detail-app Bot added the safe to test Add this label to run secure Github workflows on PRs label Oct 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 76%
76.34% (120483/157818) 62.33% (74616/119700) 63.74% (24939/39123)

@sonarqubecloud

Copy link
Copy Markdown

@harsh-vador

Copy link
Copy Markdown
Contributor

Thanks — the root cause and the Math.max fix are right. Closing in favour of #34820, which moves this scan logic out of TasksTab.tsx into useTaskQueue.ts (shared by the Inbox and the entity Activity Feed), so the fix has to land there. Ported in 346df48 with regression tests in useTaskQueue.test.tsx; #35054 is linked from #34820 and closes when it merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Detail Bug] Inbox Tasks: "Load more" does nothing after scrolling then applying Type/Status filter

1 participant