Implement the following plan: Plan: Upload JSON Reports in Web UI Context Users can…
- User
Implement the following plan:
Plan: Upload JSON Reports in Web UI
Context
Users can generate JSON evaluation reports via the CLI (
--report json), but currently there's no way to view these reports in the Web UI without re-running the evaluation. This feature allows users to upload CLI-generated JSON reports into the Web UI for viewing and persistence, available only in non-cloud instances.The
IJsonReportformat (from--report json) contains all necessary data: metadata, issues, statistics, context score, project context, curation, and cost analysis. This data needs to be converted back toEvaluationOutput(the internal format the UI expects) before storage and display.
Implementation
1. Backend: Add
POST /api/evaluations/importendpointFile:
src/api/routes/evaluation.ts- Add
importReport(req: Request)method toEvaluationRoutes - Gate behind
!cloudMode(return 403 if cloud mode) - Accept JSON body with the
IJsonReportstructure - Validate required fields:
metadata,issues(array),statistics - Convert
IJsonReport→EvaluationOutput(see step 2) - Generate a UUID for the imported evaluation
- Mark the evaluation as
source: "imported"in metadata - Save via
evaluationRepository.saveImportedEvaluation()(see step 3) - Return
{ evaluationId, repositoryUrl, status: "imported" }
2. Backend: Convert
IJsonReport→EvaluationOutputFile:
src/cli/output/report-formatters.ts(add reverse function)Add
convertJsonReportToEvaluationOutput(report: IJsonReport): EvaluationOutputThe
IJsonReporthasmetadata(typeMetadata) which is the same type used inEvaluationOutput. The key mapping:metadata→ copy directly (it's already theMetadatatype)issues→ need to be put into a unified format structure (create a syntheticresultsarray with a single entry, or better: store issues directly in a minimal unified structure)- → copy directly (same type)
- Add
Assistant
I'll start by reading the key files I need to understand before implementing the plan.
Assistant
Now let me read the frontend files I need to modify.
Assistant
Now let me read the remaining frontend files and check existing patterns.
Assistant
Let me read more of App.tsx to see how evaluations are handled and the import handler area.
Assistant
Now let me also check how the
useEvaluationHistoryhook works to understand the refresh mechanism.Assistant
Good, I now have a thorough understanding of the codebase. Let me create tasks to track progress and start implementing.
Assistant
Let me start implementing. First, the database migration and backend changes.
Assistant
Now the report converter function.
Assistant
Now let me add the converter function to report-formatters.ts.
Assistant
Now update the evaluation repository to add
saveImportedEvaluationandisImportedsupport.Assistant
First, add
is_importedtoEvaluationRowandisImportedtoIEvaluationHistoryItem:Assistant
Now add
is_importedtoEvaluationRow:Assistant
Now add
isImportedmapping inrowToHistoryItem:Assistant
Now add the
saveImportedEvaluationmethod. I'll add it aftersaveFailedEvaluation:Assistant
Now I need to add
is_importedto the SELECT queries ingetRecentEvaluations. Let me update those:Assistant
Now add the import endpoint and register the route.
Assistant
Now add the
importReportmethod. I'll add it aftergetEvaluationPrompts:Assistant
Now I need to check if
metadataon the shared type hasrepositoryUrlandlocalPathfields:Assistant
Good,
repositoryUrlandlocalPathare in theMetadatatype. Now let me check the frontend Metadata type too:Assistant
The frontend
Metadatatype doesn't haverepositoryUrlorlocalPath— those are on other interfaces. Let me check what the metadata type looks like in the frontend around line 259:The frontend
Metadatadoesn't include those, but that's fine since we read them frombody.metadatawhich is the backendIJsonReportthat uses the sharedMetadatatype.Now register the route in
api/index.ts. I need to add it before the existing/api/evaluations/:idpattern:Assistant
Now the frontend changes.
Assistant
First, add
isImportedto the frontendIEvaluationHistoryItem:Assistant
Now add
importReporttouseEvaluationApi:Assistant
Now add
importReportto the return type interface:Assistant
Now add the implementation inside the hook, before
clearError:Assistant
Now add
importReportto the returned object and its deps:Assistant
Now update
RepositoryUrlInput.tsxto add the "Import JSON" mode:Assistant
Now destructure
onImport:Assistant
Now add a ref for the file input and a handler for import. I'll add it after the existing state declarations:
Assistant
Now add a handler for file selection and for import submit. I'll add it after
handleBatchTextChange:Assistant
Now I need to update the mode toggle to include "Import JSON", and add the import file input UI. Let me update the mode toggle section:
Assistant
Now update the URL/textarea input section to include the import file input. Let me read the current area:
Assistant
Update the submit disabled logic to handle import mode:
Assistant
Now update the form to use
handleImportSubmitwhen in import mode, and update the text content and input area:Assistant
Now add the import file input UI in the URL Input / Batch Textarea section. Let me find the exact area:
Assistant
Now update the submit button text for import mode. Let me find it:
Assistant
Now I need to hide the options row (evaluator selector, provider, concurrency) when in import mode, since those aren't needed. Let me check the current code:
Assistant
Now update
EvaluationInputPanel.tsxto add theonImportprop:Assistant
Now add
handleImportReportinApp.tsxand pass it toEvaluationInputPanel. Let me read the relevant section:Assistant
I'll add
handleImportReportright afterhandleDismissFailure:Assistant
Now pass
handleImportReporttoEvaluationInputPanel:Assistant
Now add the "Imported" badge to
RecentEvaluationsPage.tsx:Assistant
Now let me check if the
@cli/*path alias works from the API routes. Let me check the tsconfig:Assistant
Good, the
@cli/*path alias is configured. Now let's run the tests.Assistant
There are 2 test failures — both because the test database doesn't have the
is_importedcolumn. The test database is initialized without running the migration. Let me look at the test setup:Assistant
The test creates the table directly without the
is_importedcolumn. I need to add it to the test schema:Assistant
Now run the tests again:
Assistant
All 1219 tests pass. Now let me run lint:
Assistant
Three formatting issues. Let me fix them:
Assistant
All three files auto-fixed. Let me verify lint passes now:
Assistant
Lint passes. Let me also run typecheck:
Assistant
There's a type error. The
UnifiedEvaluationOutputrequirescrossFileIssues. Let me check the type:Assistant
crossFileIssuesis required on the backend type but optional on the frontend type. I need to add it:Assistant
Typecheck passes. Let me run the full test suite one more time to be sure:
Assistant
All 1219 tests pass, lint is clean, and typecheck passes.
Assistant
Here's a summary of all changes made:
Summary
Backend
- User
Verification
- Unit tests: Run
bun run test- ensure no regressions - Manual testing:
- Generate a JSON report via CLI:
bun run src/index.ts cli evaluate --report json -o test-report.json <repo-url> - Start the dev server:
bun run dev - Navigate to the home page, select "Import JSON" mode
- Upload the
test-report.jsonfile - Verify it redirects to the evaluation view with full report display
- Verify the evaluation appears in history with "Imported" badge
- Verify cloud mode hides the import option (set
CLOUD_MODE=true)
- Generate a JSON report via CLI:
- Lint/typecheck: Run
bun run lintandbun run typecheck
If you need specific details from before exiting plan mode (like exact code snippets, error messages, or content you generated), read the full transcript at: /Users/cedricteyton/.REDACTED.jsonl
- Unit tests: Run
- User
Files to modify
File Change src/api/routes/evaluation.tsAdd importReport()methodsrc/cli/output/report-formatters.tsAdd convertJsonReportToEvaluationOutput()src/api/db/evaluation-repository.tsAdd saveImportedEvaluation(), addisImportedto interfaces/queriessrc/api/db/database.tsAdd is_importedcolumn migrationsrc/api/index.tsRegister POST /api/evaluations/importroutefrontend/src/hooks/useEvaluationApi.tsAdd importReport()methodfrontend/src/types/evaluation.tsAdd isImportedto history item typefrontend/src/components/RepositoryUrlInput.tsxAdd "Import JSON" mode toggle and file input frontend/src/components/EvaluationInputPanel.tsxAdd onImportpropfrontend/src/App.tsxAdd handler, pass to panel - User
- User
commit and update changelog
Assistant
Now let me find and update the changelog:
Assistant
Now let's stage and commit:
Assistant
Commit succeeded - pre-commit hooks ran all tests (1219 pass), lint, and typecheck, all green.
Committed as
7238eaawith changelog updated. The commit includes:- Backend:
POST /api/evaluations/importendpoint,convertJsonReportToEvaluationOutput()converter,saveImportedEvaluation()repository method,is_importedDB column migration - Frontend: "Import JSON" input mode tab,
importReport()API hook,handleImportReporthandler in App, "Imported" badge in history list - Changelog: New entry under
## Addedin[Unreleased]
- Backend: