Skip to content

fix(website): show loading feedback on Scan & Visualize - #1757

Merged
Shashankss1205 merged 1 commit into
CodeGraphContext:mainfrom
milinkanu:fix/scan-visualize-loading-state
Oct 15, 2026
Merged

Shashankss1205 merged 1 commit into
CodeGraphContext:mainfrom
milinkanu:fix/scan-visualize-loading-state

Conversation

@milinkanu

Copy link
Copy Markdown
Contributor

Problem

On the Client Indexer -> GitHub / GitLab tab, clicking Scan & Visualize gave no feedback. The button only called navigate() to the /explore route, which does the actual fetch + index work in a separate page (Explore.tsx). Nothing in LocalUploader.tsx tracked an in-flight state for that click, so the button stayed enabled with unchanged text for the whole gap between click and the next page rendering. Rapid clicks could queue multiple navigations (confirmed: two clicks grew browser history by 2 entries instead of 1).

Fix

Wrap the navigate() call in React's useTransition, and drive the button's disabled state and a "Scanning repository..." spinner off its pending flag:

- navigate(getExploreRoute(ref));
+ startScan(() => navigate(getExploreRoute(ref)));

useTransition was chosen over a plain isScanning boolean because navigate() is synchronous (no promise to await/finally on), and some paths never reach a success/error callback that could reset a manual flag — e.g. a route segment that causes Explore to skip auto-indexing, or the user pressing Back while the lazy Explore chunk is still loading. The transition's pending state always resolves itself once navigation settles, so the button can't get stuck disabled.

Also added a re-entry guard (if (isScanning) return;) at the top of the handler as defense in depth alongside the disabled button.

This only touches website/src/components/LocalUploader.tsx (16 lines added / 4 changed). No backend/API or fetch/index logic was touched, and the existing success/error handling in Explore.tsx (loader, error screen with Retry) is unchanged.

Testing

  • Ran the dev server in headless Chrome and compared before/after on: home page widget and /explore page, double-click, invalid/empty input, a route segment that skips auto-indexing, pressing Back mid-load, and retry after a simulated fetch failure. Button now disables immediately and shows the spinner in every case, and re-enables correctly after both success and failure paths.
  • tsc --noEmit: same pre-existing errors elsewhere in the website package, none in this file.
  • eslint on the changed file: same pre-existing errors (unrelated any usages etc.), no new ones.
  • vite build: passes.
  • No test framework exists in website/ (no vitest/testing-library configured), so no automated test was added for this UI-only change.

🤖 Generated with Claude Code

The Scan & Visualize button in the Client Indexer GitHub/GitLab tab
only called navigate() to the Explore route, which does the actual
fetch/index work. Nothing tracked an in-flight state for that click,
so the button stayed enabled with no spinner or text change while
waiting for the next page to render, and rapid clicks could queue
multiple navigations.

Wrap the navigate() call in useTransition so its pending flag drives
disabled and a "Scanning repository..." spinner on the button, and
guard the handler against re-entry while a scan is pending. A plain
boolean was avoided because navigate() is synchronous (no
await/finally to reset it on) and some paths (e.g. a route segment
that skips auto-indexing, or the user pressing Back mid-load) never
reach a success/error callback that could flip it back off — the
transition's pending state always resolves on its own once
navigation settles.

Verified in headless Chrome against the dev server (home page and
/explore, double-click, invalid input, Back mid-load, retry after a
simulated failure) and confirmed no new tsc/eslint errors and a
clean vite build.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@vercel

vercel Bot commented Oct 5, 2026

Copy link
Copy Markdown

@milinkanu is attempting to deploy a commit to the shashankss1205's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Shashankss1205 Shashankss1205 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change is scoped to LocalUploader and separates navigation pending state from the existing parse progress. Before merge, verify the transition actually stays pending across a delayed lazy Explore route and prevents duplicate navigation, then resets for Back/retry. The parent Explore loader still owns fetch/index progress; this should not imply that network indexing is finished when navigation commits. Please also run the currently awaiting CI workflows. Tracking the related acceptance in #1447; no automatic issue closure yet.

@Shashankss1205 Shashankss1205 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-tested the actual LocalUploader component under React 18 and a MemoryRouter with the same v7_startTransition setting as App. A deliberately unresolved lazy destination keeps the button disabled with the Scanning repository label; extra clicks do not navigate twice; resolving the route completes navigation; Back restores an enabled Scan & Visualize button. Production Vite build passes. This covers navigation pending state, while Explore continues to own actual fetch/index progress. Ready for merge after current integrated CI acceptance.

@Shashankss1205
Shashankss1205 merged commit ed58faa into CodeGraphContext:main Oct 15, 2026
1 check failed
@github-project-automation github-project-automation Bot moved this from Backlog tasks to Done in CGC Progress Board Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants