fix(pilot): persist Apply — stamp applied_at on click

Issue #2 from phase-8-review-issues.md. Apply was client-side-only via
a bannerApplied flag. Refresh / chat reselect / multi-tab would drop
Verifying state back to Proposed.

- New POST /ai-sessions/{sid}/suggested-fixes/{fid}/apply stamps
  applied_at without changing status (still 'proposed'). Idempotent
  if already stamped; 409 if fix is past proposed (a terminal outcome
  was already recorded).
- Bumps state_version so resolve/escalate preview bundles reflect that
  the fix has entered verifying.
- Frontend handleApplyFix calls the endpoint and uses the returned
  applied_at directly. bannerApplied client flag is removed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-23 22:10:52 -04:00
parent 362c7b1d79
commit de2bef3175
4 changed files with 209 additions and 22 deletions

View File

@@ -111,6 +111,19 @@ export const sessionSuggestedFixesApi = {
return r.data
},
/**
* Stamp applied_at when the engineer clicks Apply in the ProposalBanner.
* Does NOT change status (fix remains 'proposed'). Status flips only on
* a subsequent PATCH /outcome. Idempotent if applied_at is already set.
* Returns 409 if the fix is no longer in 'proposed' status.
*/
async applyFix(sessionId: string, fixId: string): Promise<SessionSuggestedFix> {
const r = await apiClient.post<SessionSuggestedFix>(
`/ai-sessions/${sessionId}/suggested-fixes/${fixId}/apply`,
)
return r.data
},
/**
* Record the outcome of applying a suggested fix. Transition rules:
* - from `proposed` or `applied_partial`: any outcome is valid (partial is