Skip to content

fix(indexing): WebSocket race condition, NaN stats, file streaming (#154)#160

Merged
DevanshuNEU merged 2 commits into
OpenCodeIntel:mainfrom
DevanshuNEU:fix/154-indexing-bugs
Jan 6, 2026
Merged

fix(indexing): WebSocket race condition, NaN stats, file streaming (#154)#160
DevanshuNEU merged 2 commits into
OpenCodeIntel:mainfrom
DevanshuNEU:fix/154-indexing-bugs

Conversation

@DevanshuNEU

@DevanshuNEU DevanshuNEU commented Jan 6, 2026

Copy link
Copy Markdown
Collaborator

Fix Indexing Bugs (#154)

Summary

Fixes critical bugs in the playground indexing flow that caused:

  1. Blank screen after indexing completes
  2. NaN values in completion stats
  3. Missing file names during progress streaming

Root Cause

Backend was closing WebSocket immediately after sending 'completed' event. Due to network/event loop timing, frontend's onclose handler fired before onmessage could process the completion event → state never updated → blank screen.

Additionally, backend and frontend had mismatched field names for stats.

Changes

Backend

File Fix
ws_playground.py Add 200ms delay before WS close to ensure completion event received
anonymous_indexer.py Fix field names: files_indexedfiles_processed, functions_foundfunctions_indexed, time_taken_secondsindexing_time_seconds
anonymous_indexer.py Add current_file parameter to progress callback
indexer_optimized.py Pass current_file to progress events

Frontend

File Fix
useIndexingWebSocket.ts Preserve completed state when WS disconnects
useIndexingWebSocket.ts Add debug logging for completion events

Testing

  1. Go to playground at http://localhost:3000
  2. Enter any GitHub repo URL (e.g., https://github.com/pallets/flask)
  3. Click "Start Indexing"
  4. ✅ Progress updates show correctly
  5. ✅ Completion screen shows correct stats (83 files, 1,616 functions, 81.1s)
  6. ✅ No blank screen after completion
  7. ✅ No NaN values

Before/After

Before:

  • Stats: NaN, NaN, NaNs
  • Screen goes blank after completion

After:

  • Stats: 83 Files, 1,616 Functions, 81.1s
  • Completion screen shows properly

Closes #154

…#154)

Bug fixes:
1. NaN/division by zero - Added safe value guards in IndexingProgress
   - safePercent, safeFilesProcessed, safeFilesTotal, safeFunctionsFound
   - Shows 'Starting...' when filesTotal is 0
   - Stats show '—' instead of NaN/0/0

2. AnimatePresence warnings - Moved error state inside AnimatePresence
   - Error state now has proper key and exit animation
   - Visibility conditions properly exclude simultaneous renders
   - Changed error styling from red to amber (friendlier)

3. Session state - Error states now properly clear other states
   - showUrlInput excludes error state
   - showValidation excludes error state
   - showIndexing excludes wsHasError

Closes OpenCodeIntel#154
@vercel

vercel Bot commented Jan 6, 2026

Copy link
Copy Markdown

@DevanshuNEU is attempting to deploy a commit to the Dev's projects Team on Vercel.

A member of the Team first needs to authorize it.

@DevanshuNEU DevanshuNEU changed the title fix(frontend): Bug fixes - NaN errors and AnimatePresence warnings (#154) fix(indexing): WebSocket race condition, NaN stats, file streaming (#154) Jan 6, 2026
@DevanshuNEU DevanshuNEU force-pushed the fix/154-indexing-bugs branch 2 times, most recently from 38afd04 to 95e6681 Compare January 6, 2026 05:44
Fixes:
- Add delay before WS close to ensure client receives completion event
- Align stat field names between backend and frontend
- Add current_file to progress events for streaming display
- Preserve completed state when WebSocket disconnects

Root cause: Backend closed WebSocket immediately after sending completion
event, causing race condition where frontend's onclose fired before
onmessage could process the completion.

Closes OpenCodeIntel#154
@DevanshuNEU DevanshuNEU force-pushed the fix/154-indexing-bugs branch from 95e6681 to 85f229f Compare January 6, 2026 05:53
@vercel

vercel Bot commented Jan 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
opencodeintel Ready Ready Preview, Comment Jan 6, 2026 5:55am

@DevanshuNEU DevanshuNEU merged commit 741796e into OpenCodeIntel:main Jan 6, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug fixes: Indexing flow technical issues

1 participant