From 1151372e5c2c8ea551628cc80aef23183489b64c Mon Sep 17 00:00:00 2001 From: boyang-zhang <497256303zby@gmail.com> Date: Sat, 27 Dec 2025 12:03:18 -0600 Subject: [PATCH] Dev branch improvements and bug fixes (#42) * Add agentic mode support for LlamaParse and fix eligibility extraction - Add agenticMode option to ParseOptions interface and Zod schema - Enable agentic parsing by default for better multi-sheet Excel support - Fix eligibility extraction to gracefully handle documents without eligibility criteria by returning empty array instead of throwing error * Refactor project index selection to single-select with auto-save - Change ProjectIndexSelector from multi-select checkboxes to single-select clickable rows with radio-style indicators - Implement debounced auto-save (800ms) when selection changes - Remove Edit/Save/Cancel buttons in favor of automatic persistence - Add refreshKey prop to ProjectDocuments for efficient refetch on changes - Update DocumentsSection to wire components with onSaveSuccess callback - Simplify Questions page index selector to show index name with Active badge * Fix ESLint configuration and resolve all lint errors - Add eslint and eslint-config-next as dev dependencies - Create .eslintrc.json with next/core-web-vitals preset - Fix 43 unescaped entity errors by replacing quotes and apostrophes with HTML entities across 14 component files - Fix 9 react-hooks/exhaustive-deps warnings by wrapping fetch functions in useCallback with proper dependency arrays * Add Vitest testing infrastructure with 173 unit tests - Configure Vitest with coverage reporting and path aliases - Add test scripts (test, test:run, test:coverage) to package.json - Install vitest, @vitest/coverage-v8, vite-tsconfig-paths, vitest-mock-extended Test coverage includes: - validators: extract-questions, generate-response, llamaparse, multi-step-response - errors: all API error classes with type guard - services: FileValidator (file type/size validation), DefaultResponseService - middleware: apiHandler and withApiHandler request validation Add mock infrastructure for Prisma, OpenAI, and test fixtures * Fix missing agenticMode in LlamaParse processing service Add agentic_mode field to request schema and form data parser to ensure the agenticMode option is properly passed through the parsing pipeline. This resolves TypeScript compilation error where agenticMode was required in LlamaParseOptions but not provided by the processing service. * Fix Add Manually button routing and improve Vercel preview URL handling - Fix 404 error when clicking Add Manually button by using correct route path /projects/{projectId}/questions/create instead of /questions/create?projectId= - Update magic link auth to use VERCEL_URL for preview deployments * Simplify IndexSelector to display-only mode Remove index configuration UI since only single file selection is now supported: - Remove Configure/Hide toggle button and collapsible panel - Remove Select All/Deselect All functionality - Remove checkbox selection grid for indexes - Clean up handleIndexToggle and handleSelectAllIndexes from provider - Keep project card display showing active index name and status --- .eslintrc.json | 3 + app/help/page.tsx | 6 +- app/login/actions.ts | 15 +- app/login/confirmation/page.tsx | 4 +- app/login/page.tsx | 2 +- app/organizations/[orgId]/page.tsx | 18 +- app/organizations/page.tsx | 12 +- .../questions/components/index-selector.tsx | 136 +- .../components/no-questions-available.tsx | 2 +- .../components/questions-provider.tsx | 26 - .../components/questions-section.tsx | 6 +- .../components/ai-suggestions-panel.tsx | 6 +- app/projects/components/documents-section.tsx | 18 +- app/projects/components/project-timeline.tsx | 12 +- components/FileUploader.tsx | 2 +- components/ProcessingModal.tsx | 2 +- components/TestimonialsSection.tsx | 6 +- .../organizations/KnowledgeBaseContent.tsx | 14 +- .../LlamaCloudConnectionDialog.tsx | 2 +- .../organizations/LlamaCloudDocuments.tsx | 22 +- components/organizations/SettingsContent.tsx | 2 +- components/projects/ProjectDocuments.tsx | 35 +- components/projects/ProjectIndexSelector.tsx | 237 +- components/ui/delete-confirmation-dialog.tsx | 2 +- lib/llamaparse-service.ts | 7 +- lib/services/llamaparse-processing-service.ts | 1 + lib/services/openai-question-extractor.ts | 15 +- lib/utils/form-data-parser.ts | 6 +- lib/validators/llamaparse.ts | 2 + package.json | 14 +- pnpm-lock.yaml | 4004 ++++++++++++++++- tests/mocks/fixtures/index.ts | 68 + tests/mocks/openai.ts | 40 + tests/mocks/prisma.ts | 26 + tests/unit/errors/api-errors.test.ts | 216 + tests/unit/middleware/api-handler.test.ts | 298 ++ .../services/default-response-service.test.ts | 161 + tests/unit/services/file-validator.test.ts | 185 + .../unit/validators/extract-questions.test.ts | 201 + .../unit/validators/generate-response.test.ts | 204 + tests/unit/validators/llamaparse.test.ts | 220 + .../validators/multi-step-response.test.ts | 394 ++ vitest.config.ts | 41 + vitest.setup.ts | 22 + 44 files changed, 6316 insertions(+), 399 deletions(-) create mode 100644 .eslintrc.json create mode 100644 tests/mocks/fixtures/index.ts create mode 100644 tests/mocks/openai.ts create mode 100644 tests/mocks/prisma.ts create mode 100644 tests/unit/errors/api-errors.test.ts create mode 100644 tests/unit/middleware/api-handler.test.ts create mode 100644 tests/unit/services/default-response-service.test.ts create mode 100644 tests/unit/services/file-validator.test.ts create mode 100644 tests/unit/validators/extract-questions.test.ts create mode 100644 tests/unit/validators/generate-response.test.ts create mode 100644 tests/unit/validators/llamaparse.test.ts create mode 100644 tests/unit/validators/multi-step-response.test.ts create mode 100644 vitest.config.ts create mode 100644 vitest.setup.ts diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 00000000..bffb357a --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "next/core-web-vitals" +} diff --git a/app/help/page.tsx b/app/help/page.tsx index 9877c4b5..0fd5d631 100644 --- a/app/help/page.tsx +++ b/app/help/page.tsx @@ -128,7 +128,7 @@ export default function HelpPage() {