Skip to content

🐛 fully reset workflow state when batch review completes (#1363) (#1386)#1397

Open
konveyor-ci-bot[bot] wants to merge 1 commit intorelease-0.4from
cherry-pick-pr1386-release-0.4
Open

🐛 fully reset workflow state when batch review completes (#1363) (#1386)#1397
konveyor-ci-bot[bot] wants to merge 1 commit intorelease-0.4from
cherry-pick-pr1386-release-0.4

Conversation

@konveyor-ci-bot
Copy link
Copy Markdown

Summary

Fixes the extension getting stuck in "resolution is in progress" after
accepting a solution and reverting the file, preventing analysis from
running.

Problem

When the user completes a batch review (accepts/rejects all files),
checkBatchReviewComplete only cleared pendingBatchReview but did
not reset the workflow state flags:

  • isFetchingSolution stayed true
  • solutionState stayed on "started" or "received"
  • isWaitingForUserInteraction could be stuck true
  • isProcessingQueuedMessages could be stuck true

This caused SolutionWorkflowOrchestrator.validatePreconditions() to
reject new solution requests ("Solution already being fetched"), and
the UI to report resolution was in progress indefinitely.

Why this happens:

  1. SolutionWorkflowOrchestrator.workflowCleanup() runs when
    workflow.run() completes AND the queue drains
  2. But the batch review UI outlives the workflow — individual file
    accept/reject/continue actions go through webviewMessageHandler
  3. After the orchestrator cleans up, the webview message handler removes
    files from pendingBatchReview one at a time
  4. When the last file is removed, checkBatchReviewComplete fires — but
    it only cleared the array, not the workflow flags
  5. If the orchestrator's cleanup missed any flags (race condition, error
    path, etc.), they stay stuck forever

Fix

checkBatchReviewComplete now performs a full workflow state reset
when the batch is done:

  1. Reset all solution workflow flagsisFetchingSolution=false,
    solutionState="none", isWaitingForUserInteraction=false,
    isProcessingQueuedMessages=false
  2. Reset analysis flagsisAnalyzing=false,
    isAnalysisScheduled=false
  3. Dispose stale workflow resources — queue manager, pending
    interactions map, resolver function
  4. Clear cachesmodifiedFiles, kaiFsCache

This acts as a safety net: even if the orchestrator's cleanup missed
something, the batch review completion guarantees a clean slate.

Testing

  1. Run analysis and receive a solution suggestion
  2. Open the solution in review mode
  3. Accept the solution (or Accept All)
  4. Revert the file (git checkout, undo, etc.)
  5. Attempt to run analysis again
  6. ✅ Analysis should run without issues — no "resolution in progress"
    error

Also verify normal flow still works:

  1. Run analysis → get solution → accept/reject all files → batch review
    completes
  2. ✅ Can immediately start a new solution workflow

Fixes: #1363
Jira: MTA-6862


Signed-off-by: ibolton336 ibolton@redhat.com
Signed-off-by: Ian Bolton ibolton@redhat.com
Signed-off-by: Cherry Picker noreply@github.com

## Summary

Fixes the extension getting stuck in "resolution is in progress" after
accepting a solution and reverting the file, preventing analysis from
running.

## Problem

When the user completes a batch review (accepts/rejects all files),
`checkBatchReviewComplete` only cleared `pendingBatchReview` but did
**not** reset the workflow state flags:

- `isFetchingSolution` stayed `true`
- `solutionState` stayed on `"started"` or `"received"`
- `isWaitingForUserInteraction` could be stuck `true`
- `isProcessingQueuedMessages` could be stuck `true`

This caused `SolutionWorkflowOrchestrator.validatePreconditions()` to
reject new solution requests (`"Solution already being fetched"`), and
the UI to report resolution was in progress indefinitely.

### Why this happens:

1. `SolutionWorkflowOrchestrator.workflowCleanup()` runs when
`workflow.run()` completes AND the queue drains
2. But the batch review UI **outlives** the workflow — individual file
accept/reject/continue actions go through `webviewMessageHandler`
3. After the orchestrator cleans up, the webview message handler removes
files from `pendingBatchReview` one at a time
4. When the last file is removed, `checkBatchReviewComplete` fires — but
it only cleared the array, not the workflow flags
5. If the orchestrator's cleanup missed any flags (race condition, error
path, etc.), they stay stuck forever

## Fix

`checkBatchReviewComplete` now performs a **full workflow state reset**
when the batch is done:

1. **Reset all solution workflow flags** — `isFetchingSolution=false`,
`solutionState="none"`, `isWaitingForUserInteraction=false`,
`isProcessingQueuedMessages=false`
2. **Reset analysis flags** — `isAnalyzing=false`,
`isAnalysisScheduled=false`
3. **Dispose stale workflow resources** — queue manager, pending
interactions map, resolver function
4. **Clear caches** — `modifiedFiles`, `kaiFsCache`

This acts as a safety net: even if the orchestrator's cleanup missed
something, the batch review completion guarantees a clean slate.

## Testing

1. Run analysis and receive a solution suggestion
2. Open the solution in review mode
3. Accept the solution (or Accept All)
4. Revert the file (`git checkout`, undo, etc.)
5. Attempt to run analysis again
6. ✅ Analysis should run without issues — no "resolution in progress"
error

Also verify normal flow still works:
1. Run analysis → get solution → accept/reject all files → batch review
completes
2. ✅ Can immediately start a new solution workflow

Fixes: #1363
Jira: [MTA-6862](https://redhat.atlassian.net/browse/MTA-6862)

---------

Signed-off-by: ibolton336 <ibolton@redhat.com>
Signed-off-by: Ian Bolton <ibolton@redhat.com>
Signed-off-by: Cherry Picker <noreply@github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants