Fix screenshot state persistence bug in task modals (#1235)

* fix(ui): reset all form fields when opening task modal without draft (qa-requested)

When opening the task creation modal after previously creating a task with
attachments (screenshots, referenced files, etc.), the old data would persist
due to incomplete state reset in the draft-loading useEffect hook.

The else branch (when no draft exists) now resets ALL form state fields to
their defaults, ensuring a clean slate for new task creation. This matches
the behavior of the existing resetForm() function.

Fixes:
- Images/screenshots persisting after task creation
- Referenced files persisting after task creation
- Form content (title, description) persisting
- Classification fields persisting

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(ui): reset baseBranch, useWorktree, and UI toggles when opening modal without draft

Addresses PR review findings: when opening the task creation modal without
a saved draft, the following state variables were not being reset to their
defaults (while resetForm() correctly resets all of them):

- baseBranch: now resets to PROJECT_DEFAULT_BRANCH
- useWorktree: now resets to true (safe default)
- showFileExplorer: now resets to false
- showGitOptions: now resets to false

This ensures consistent form state when reopening the modal after closing
without saving a draft.

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Test User <test@example.com>
This commit is contained in:
Andy
2026-01-17 20:47:43 +01:00
committed by GitHub
parent e27ff3447d
commit 3024d547a8
@@ -177,8 +177,12 @@ export function TaskCreationWizard({
setImages([]);
setReferencedFiles([]);
setRequireReviewBeforeCoding(false);
setBaseBranch(PROJECT_DEFAULT_BRANCH);
setUseWorktree(true);
setIsDraftRestored(false);
setShowClassification(false);
setShowFileExplorer(false);
setShowGitOptions(false);
}
}
}, [open, projectId, settings.selectedAgentProfile, settings.customPhaseModels, settings.customPhaseThinking, selectedProfile.model, selectedProfile.thinkingLevel, selectedProfile.phaseModels, selectedProfile.phaseThinking]);