Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(views): clear manual draft when packing into agent prompt (#2370)

Boynn933f417dacc5
diff --git a/packages/views/modals/create-issue.test.tsx b/packages/views/modals/create-issue.test.tsx
index b7996c811a..3edc53ec94 100644
--- a/packages/views/modals/create-issue.test.tsx
+++ b/packages/views/modals/create-issue.test.tsx
@@ -554,4 +554,31 @@ describe("CreateIssueModal", () => {
}),
);
});
+
+ // Title + description are packed into the agent prompt on switch; if we
+ // leave them in the shared draft store, the next agent→manual switch
+ // surfaces the stale manual draft on top of the prompt-as-description,
+ // duplicating the user's text on every round-trip.
+ it("clears the manual draft when packing title and description into the agent prompt", async () => {
+ const user = userEvent.setup();
+
+ renderModal(
+ <ManualCreatePanel
+ onClose={vi.fn()}
+ onSwitchMode={vi.fn()}
+ isExpanded={false}
+ setIsExpanded={vi.fn()}
+ backlogHintIssueId={null}
+ setBacklogHintIssueId={vi.fn()}
+ />,
+ );
+
+ await user.type(screen.getByPlaceholderText("Issue title"), "Update");
+ await user.type(screen.getByPlaceholderText("Add description..."), "Some body");
+
+ mockSetDraft.mockClear();
+ await user.click(screen.getByRole("button", { name: /Switch to Agent/i }));
+
+ expect(mockSetDraft).toHaveBeenCalledWith({ title: "", description: "" });
+ });
});
diff --git a/packages/views/modals/create-issue.tsx b/packages/views/modals/create-issue.tsx
index fb5060b50c..dc47aa111a 100644
--- a/packages/views/modals/create-issue.tsx
+++ b/packages/views/modals/create-issue.tsx
@@ -349,6 +349,11 @@ export function ManualCreatePanel({
const switchToAgent = () => {
const desc = descEditorRef.current?.getMarkdown()?.trim() ?? "";
const prompt = [title.trim(), desc].filter(Boolean).join("\n\n");
+ // Title + description have been packed into the agent prompt — clear them
+ // from the shared draft so a later agent→manual switch doesn't surface
+ // stale manual state on top of the prompt-as-description, which would
+ // duplicate content on every round-trip.
+ setDraft({ title: "", description: "" });
setLastMode("agent");
onSwitchMode?.({
prompt,