fix(pilot): persist AI-proposal rejection + clear on outcome write
Issue #3 from phase-8-review-issues.md. 'Not yet' on the AI-confirming banner was a local-state hide; the proposal re-surfaced on the next refreshSessionDerived call. Two-part fix: - PATCH /outcome now clears ai_outcome_proposal on any terminal action (engineer has taken a decision; stale AI proposal is moot). - New DELETE /ai-sessions/:sid/suggested-fixes/:fid/ai-outcome-proposal endpoint for explicit 'Not yet' rejection. Does not touch status or state_version — pure UI state. Frontend handleRejectAIProposal now calls the DELETE and setActiveFix with the server response. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -338,6 +338,9 @@ async def patch_suggested_fix_outcome(
|
||||
if fix.applied_at is None and body.outcome != "dismissed":
|
||||
fix.applied_at = now
|
||||
|
||||
# Clear any pending AI outcome proposal — engineer has taken a terminal action.
|
||||
fix.ai_outcome_proposal = None
|
||||
|
||||
# Outcome changes the bundle that resolution-note/escalation-package
|
||||
# previews see, so bump state_version inside the same transaction —
|
||||
# mirrors the pattern in record_decision above.
|
||||
@@ -352,6 +355,48 @@ async def patch_suggested_fix_outcome(
|
||||
return SessionSuggestedFixResponse.model_validate(fix)
|
||||
|
||||
|
||||
# ── Suggested fix: clear AI outcome proposal ("Not yet") ─────────────────────
|
||||
|
||||
@router.delete(
|
||||
"/suggested-fixes/{fix_id}/ai-outcome-proposal",
|
||||
response_model=SessionSuggestedFixResponse,
|
||||
)
|
||||
async def clear_ai_outcome_proposal(
|
||||
session_id: UUID,
|
||||
fix_id: UUID,
|
||||
current_user: Annotated[User, Depends(get_current_active_user)],
|
||||
db: Annotated[AsyncSession, Depends(get_db)],
|
||||
_: None = Depends(require_engineer_or_admin),
|
||||
) -> SessionSuggestedFixResponse:
|
||||
"""Explicitly dismiss the AI-proposed outcome banner ("Not yet").
|
||||
|
||||
Clears `ai_outcome_proposal` without touching status or state_version
|
||||
(this is pure UI state, not outcome data). Idempotent: returns 200 even
|
||||
when the field is already null. After this call the banner will not
|
||||
re-surface on the next refreshSessionDerived unless the AI emits a new
|
||||
proposal.
|
||||
"""
|
||||
await _load_session_or_404(db, session_id)
|
||||
|
||||
result = await db.execute(
|
||||
select(SessionSuggestedFix).where(
|
||||
SessionSuggestedFix.id == fix_id,
|
||||
SessionSuggestedFix.session_id == session_id,
|
||||
)
|
||||
)
|
||||
fix = result.scalar_one_or_none()
|
||||
if fix is None:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND, detail="Suggested fix not found"
|
||||
)
|
||||
|
||||
fix.ai_outcome_proposal = None
|
||||
|
||||
await db.commit()
|
||||
await db.refresh(fix)
|
||||
return SessionSuggestedFixResponse.model_validate(fix)
|
||||
|
||||
|
||||
async def _summarize_session_for_extraction(
|
||||
db: AsyncSession, session_id: UUID,
|
||||
) -> str:
|
||||
|
||||
Reference in New Issue
Block a user