Skip to content

feat: add loading state, error handling, and tests (closes #2)#5

Merged
JarvisX-Z merged 1 commit into
JarvisX-Z:mainfrom
SurbhiAgarwal1:feat/loading-state-error-handling
May 13, 2026
Merged

feat: add loading state, error handling, and tests (closes #2)#5
JarvisX-Z merged 1 commit into
JarvisX-Z:mainfrom
SurbhiAgarwal1:feat/loading-state-error-handling

Conversation

@SurbhiAgarwal1
Copy link
Copy Markdown
Collaborator

Summary

Closes #2

Implements loading indicators and structured error handling during the AI context analysis process.

Changes

UI — analyzer.tsx

  • Animated multi-step progress bar with named steps:
    Tokenising query → Scanning files → Tracing imports → Scoring relevance → Ranking results
  • Skeleton result cards replace the plain spinner during loading
  • Classified error messages (network / validation / server / unknown)
    with matching icons and user-friendly text
  • Retry button on the error panel — no need to retype the query
  • Validation errors show an actionable hint list

App.tsx

  • ErrorBoundary catches unexpected render crashes with a recovery screen
  • QueryClient configured with retry: false for mutations, retry: 1 for queries

API server — analyze.ts

  • Structured error responses with Zod field-level details on 400s
  • try/catch around analyzeFiles so runtime errors return a clean 500

Tests

Added 14 Vitest unit tests for analyzeFiles (analyzer.test.ts) — all pass locally.

# Test
1 returns an array (never undefined/null)
2 returns empty array when no files match
3 ranks most relevant file first
4 filename matches score higher than content-only
5 matchedKeywords populated in results
6 non-empty reason string in every result
7 scores are between 0 and 100
8 respects the topN limit
9 boosts score of files imported by a matched file
10 handles empty files array without throwing
11 handles single-word query
12 case-insensitive keyword matching
13 filters out zero-score files
14 handles files with empty content gracefully

Test run output

- analyzer.tsx: animated multi-step progress bar with named steps,
  skeleton result cards during loading, classified error messages
  (network/validation/server/unknown) with icons and Retry button
- App.tsx: ErrorBoundary for unexpected render crashes, QueryClient
  configured with retry:false for mutations
- analyze.ts: structured error responses with Zod field-level details,
  try/catch around analyzeFiles for 500 safety net
- analyzer.test.ts: 14 Vitest tests covering analyzeFiles logic
  (scoring, ranking, dependency tracing, edge cases)
- vitest.config.ts: test runner config for api-server
- pnpm-workspace.yaml: re-enable rollup-win32-x64-msvc for local dev
@vercel
Copy link
Copy Markdown

vercel Bot commented May 10, 2026

@SurbhiAgarwal1 is attempting to deploy a commit to the jarvisx-z's projects Team on Vercel.

A member of the Team first needs to authorize it.

@JarvisX-Z
Copy link
Copy Markdown
Owner

Thank you for the excellent contribution. The loading state, structured error handling, and comprehensive unit tests are valuable improvements. I’m reviewing the failed CI build, and if the issue is minor I’ll merge this PR.

@JarvisX-Z JarvisX-Z merged commit ca985bf into JarvisX-Z:main May 13, 2026
0 of 2 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.

Enhancement: Add Loading State and Error Handling

2 participants