After running an evaluation and remediating issues, users currently have no way to measure the impact without manually re-running a full analysis on their patched repo. This feature adds an "Evaluate Impact" button on each remediation card that clones the repo, applies the remediation patch, runs a full 17-evaluator analysis, and displays a before/after score comparison directly on the Remediate tab.
Implementation Plan
1. Database Schema — src/api/db/database.ts
Add 3 new columns using the existing try/catch ALTER TABLE pattern at the end of initializeDatabase():
remediations.result_evaluation_id TEXT — links to the evaluation created from this remediation
evaluations.parent_evaluation_id TEXT — marks this evaluation as a remediation re-evaluation
evaluations.source_remediation_id TEXT — which remediation triggered this evaluation
Add index: CREATE INDEX IF NOT EXISTS idx_evaluations_source_remediation ON evaluations(source_remediation_id)
2. Types — src/shared/types/api.ts
Extend IEvaluateRequest with optional internal metadata fields:
typescript
// Internal fields for remediation impact evaluation (not serialized to DB)
_cleanupFn?: () => Promise<void>;
_parentEvaluationId?: string;
_sourceRemediationId?: string;
Add parentEvaluationId and sourceRemediationId to EvaluationRow, IEvaluationHistoryItem, and IEvaluationRecord
Update saveEvaluation() to accept and persist parentEvaluationId and sourceRemediationId (read from the request's _parentEvaluationId / _sourceRemediationId)
Update saveFailedEvaluation() similarly
Update rowToHistoryItem() to map the new columns
Update the INSERT SQL statements to include the new columns
I'll implement this plan step by step. Let me start by reading the key files I need to modify.
Assistant
Now let me read the remaining files I need.
Assistant
Now let me read the frontend components I need to modify.
Assistant
Now let me check the clone repository function since we'll need it for the impact evaluation.
Assistant
Good, I have all the context I need. Now let me implement the changes step by step. I'll start with the backend changes.
Step 1: Database Schema
Assistant
Step 2: Extend IEvaluateRequest
Assistant
Step 3: Evaluation Repository — add new columns
Assistant
Now update saveEvaluation() to persist the new columns:
Assistant
Now update saveFailedEvaluation():
Assistant
Now update rowToHistoryItem() to map the new columns:
Assistant
Step 4: Remediation Repository — add resultEvaluationId and linkResultEvaluation()
Assistant
Now add linkResultEvaluation() method and update rowToRecord():
Assistant
Now update rowToRecord() to include resultEvaluationId:
Assistant
Step 5: Job Manager — cleanup hook + linking
Assistant
Now add the linking and cleanup logic after saveEvaluation():
Assistant
Now add cleanup function call in the finally block:
Assistant
Step 6: Git Operations — applyPatch()
Assistant
Step 7: API Endpoint — evaluateImpact()
Assistant
Now add the evaluateImpact() method to the class:
Assistant
Step 8: Route Registration
Assistant
Step 9: Frontend Types — resultEvaluationId
Assistant
Step 10: Frontend API Hook — new functions
Assistant
Add the new methods to the return interface:
Assistant
Now add the implementations before the clearError callback:
Assistant
Now add them to the useMemo return:
Assistant
Step 11: Frontend — RemediationHistoryCard.tsx
Assistant
Now add the Evaluate Impact button and score comparison in the card header area, after the quick actions div:
Assistant
Now add the ScoreComparison component at the end of the file:
Assistant
Step 12: Frontend — RemediationHistory.tsx
Assistant
Now add the impact evaluation state management and SSE handler:
Assistant
Now pass the new props to RemediationHistoryCard:
Assistant
Step 13: Frontend — RemediateTab.tsx
Pass parentScore, parentGrade, and hasRepoUrl down to RemediationHistory:
Assistant
Now let me check if repositoryUrl is available in EvaluationOutput.metadata:
Assistant
Good, repositoryUrl exists in the metadata. Let me check the frontend types for EvaluationOutput:
Assistant
The Metadata interface doesn't have repositoryUrl but the contextScore field has the score data. Let me check how evaluationData.metadata.repositoryUrl might be available — looking at the RemediateTab, the prop evaluationData comes from the parent and it's the actual evaluation output. Let me check if repositoryUrl is in the metadata:
Assistant
Good, repositoryUrl is in the backend metadata. But the frontend Metadata type doesn't have it. Instead of modifying that, I can derive the repo URL from the evaluation's history item. Actually, the simplest approach is that the parent RemediateTab already has evaluationData which has the actual result from the API - it may contain repositoryUrl in metadata at runtime even if it's not in the frontend type. Let me take a different approach - I'll check the evaluation history item instead.
Let me look at how RemediateTab is used to understand how evaluationData is obtained:
Assistant
The evaluationData is the full EvaluationOutput from the API. At runtime, the metadata will have repositoryUrl even though the frontend type doesn't declare it. Instead of modifying the frontend type, I'll use a safer runtime check. The hasRepoUrl calculation in the RemediateTab already casts safely. But I should use the proper field. Let me check what the actual metadata looks like in the backend:
Assistant
The data exists at runtime. For the frontend, I'll use a type assertion. Let me update the hasRepoUrl calculation in RemediateTab.tsx to be more robust:
Assistant
Now let's run the tests to see if everything compiles:
Assistant
All 1274 tests pass. Now let's run lint:
Assistant
Let me verify lint passes now:
Assistant
Let me also run typecheck:
Assistant
All checks pass. Let me run tests one final time to confirm:
Assistant
All 1274 tests pass, lint is clean, and typecheck passes. Here's a summary of what was implemented across 13 files:
Backend (8 files):
src/api/db/database.ts — Added 3 new columns via ALTER TABLE: , , , plus an index on
User
commit and update @changelog
Assistant
I see there are already staged files from a previous operation (the logo SVGs). Let me also check the changelog file:
Assistant
No project-level changelog file exists. Let me check if there's a custom one somewhere:
Assistant
There's no project-level changelog. You mentioned @changelog — could you clarify what changelog file you'd like me to update? There's no CHANGELOG.md in the project root. Would you like me to:
Assistant
Now I'll update the changelog and commit. I need to only commit the files related to this feature (not the already-staged logo SVGs or other unrelated changes).
Assistant
Now stage only the files changed by this feature and commit:
Assistant
The pre-commit hook caught lint errors in files that are already staged from a previous commit (ContextTab.tsx, ContextTreeView.tsx, etc.) — these aren't from my changes but they're staged. Let me fix all lint issues:
Assistant
Now re-stage those fixed files too and commit:
Assistant
Committed successfully. The commit 345c4c3 includes:
13 feature files: database schema, types, repositories, job manager, git operations, API endpoint, route registration, and 5 frontend files
5 lint-fixed files: pre-existing formatting issues in ContextTab, ContextTreeView, ContentBrowserModal, LinkedDocsBrowserModal, and build-context-tree
CHANGELOG.md: updated with the new "Remediation impact evaluation" entry
resultEvaluationId: string | null
IRemediationRecord
Add result_evaluation_id: string | null to RemediationRow
Add method linkResultEvaluation(remediationId: string, evaluationId: string): void — runs UPDATE remediations SET result_evaluation_id = ? WHERE id = ?
Update rowToRecord() to map result_evaluation_id
5. Job Manager — src/api/jobs/job-manager.ts
In executeJob(), after the saveEvaluation() call (line ~386):
Pass _parentEvaluationId and _sourceRemediationId through to saveEvaluation() (the request object already carries them)
If job.request._sourceRemediationId is set, call remediationRepository.linkResultEvaluation() to update the remediation record
In the finally block, call job.request._cleanupFn?.() (with try/catch) to clean up the patched clone directory
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
evaluations.parent_evaluation_id
evaluations.source_remediation_id
remediations.result_evaluation_id
source_remediation_id
src/shared/types/api.ts — Extended IEvaluateRequest with _cleanupFn, _parentEvaluationId, _sourceRemediationId internal fields
src/api/db/evaluation-repository.ts — Added new columns to EvaluationRow, IEvaluationHistoryItem, IEvaluationRecord; updated saveEvaluation(), saveFailedEvaluation(), and rowToHistoryItem() to persist/read the new fields
src/api/jobs/job-manager.ts — After saveEvaluation(), calls linkResultEvaluation() when _sourceRemediationId is set; calls _cleanupFn() in the finally block
src/shared/remediation/git-operations.ts — Added applyPatch() function (writes patch to temp file, runs git apply --whitespace=fix, cleans up)
src/api/routes/remediation.ts — Added evaluateImpact() method: fetches remediation, checks idempotency, clones repo at same commit, applies patch, submits evaluation job
src/api/index.ts — Registered POST /api/remediation/:id/evaluate route
Frontend (5 files):
frontend/src/types/remediation.ts — Added resultEvaluationId: string | null to RemediationHistoryItem
frontend/src/hooks/useEvaluationApi.ts — Added evaluateRemediationImpact() and getEvaluationScore() API functions
frontend/src/components/RemediationHistoryCard.tsx — Added "Evaluate Impact" button, spinner during evaluation, score comparison display (before → after (+delta))
frontend/src/components/RemediationHistory.tsx — Added impact evaluation state management (Map<remediationId, ImpactEvalState>), SSE connection handling for real-time progress, auto-loads scores for existing result evaluations
frontend/src/components/RemediateTab.tsx — Passes parentScore, parentGrade, hasRepoUrl, and onRefresh down to RemediationHistory