Skip to content

Commit 0a0b7da

Browse files
committed
ensure transient state is reset on successive tool calls
1 parent 46c7267 commit 0a0b7da

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

ui/src/apps/issue-write/App.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,22 @@ function CreateIssueApp() {
426426
}
427427
const [existingIssueData, setExistingIssueData] = useState<ExistingIssueData | null>(null);
428428

429-
// Reset prefill tracking when toolInput changes (new invocation)
429+
// Reset all transient form/result state when toolInput changes (new invocation).
430+
// Without this, the SuccessView from a previous submit stays visible and stale
431+
// form values (e.g. body) bleed through because prefill effects use truthy guards
432+
// that won't overwrite with empty values.
430433
useEffect(() => {
431434
prefillApplied.current = { title: false, body: false, labels: false, assignees: false, milestone: false, type: false };
432435
setExistingIssueData(null);
436+
setTitle("");
437+
setBody("");
438+
setSelectedLabels([]);
439+
setSelectedAssignees([]);
440+
setSelectedMilestone(null);
441+
setSelectedIssueType(null);
442+
setSuccessIssue(null);
443+
setError(null);
444+
setSelectedRepo(null);
433445
}, [toolInput]);
434446

435447
// Load existing issue data when in update mode

ui/src/apps/pr-write/App.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,23 @@ function CreatePRApp() {
178178
}
179179
}, [toolInput, selectedRepo]);
180180

181+
// Reset all transient form/result state when toolInput changes (new invocation).
182+
// Without this, the SuccessView from a previous submit stays visible and stale
183+
// form values bleed through because the prefill effect below only sets when
184+
// toolInput has truthy values and never clears.
185+
useEffect(() => {
186+
setTitle("");
187+
setBody("");
188+
setHeadBranch("");
189+
setBaseBranch("");
190+
setIsDraft(false);
191+
setMaintainerCanModify(true);
192+
setSuccessPR(null);
193+
setError(null);
194+
setSubmittedTitle("");
195+
setSelectedRepo(null);
196+
}, [toolInput]);
197+
181198
// Pre-fill from toolInput
182199
useEffect(() => {
183200
if (toolInput?.title) setTitle(toolInput.title as string);

0 commit comments

Comments
 (0)