Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-8649 feat(issues): add selective parent field copying for sub-issues (#9988)
SUBARUAWA486a0842256b5cb
diff --git a/apps/docs/content/docs/issues.mdx b/apps/docs/content/docs/issues.mdxindex e3dbba47b2..1826bd9fc6 100644--- a/apps/docs/content/docs/issues.mdx+++ b/apps/docs/content/docs/issues.mdx@@ -140,6 +140,8 @@ An issue belongs to at most one [project](/projects); the project provides shareLarger work can be split into sub-issues: the parent issue keeps the overall goal while sub-issues progress independently. Parent and child statuses do not affect each other.+Creating a sub-issue from a parent prefills its project and, when set, its assignee. In manual create, **Copy parent fields** lets you choose priority, labels, dates, or individual custom properties to copy. Only the selected values replace your form values, once; later parent changes do not sync. The child keeps its own description and status. Labels, start date, and custom properties stay in the manual draft when switching to Create with agent.+Sub-issues can be given a **stage** to advance in batches — 1, 2, 3. When every sub-issue in the earliest unfinished stage reaches `done` or `cancelled`, the parent issue receives a "sub-issues completed" notification; when the parent's assignee is an agent, it wakes up and decides whether to start the next stage. Sub-issues without a stage count as one batch and notify once when they all finish. The system triggers this wakeup; see [Issue wakeups](/issue-wakeups) for its rules and the other kinds of wakeup.## Views and display settings [#switch-views]diff --git a/apps/docs/content/docs/issues.zh.mdx b/apps/docs/content/docs/issues.zh.mdxindex 50cd530fe0..6561f7c0cb 100644--- a/apps/docs/content/docs/issues.zh.mdx+++ b/apps/docs/content/docs/issues.zh.mdx@@ -140,6 +140,8 @@ import { DeliverablesDemo } from "@/components/demos/deliverables-demo";较大的工作可以拆成子任务:父任务保留整体目标,子任务各自独立推进。父子状态互不联动。+从父任务创建子任务时,会预填项目;父任务已指派时,也会预填负责人。手动创建中可通过**复制父任务字段**选择优先级、标签、日期或某个自定义属性。仅覆盖选中的字段,复制一次,父任务后续修改不再同步。子任务的描述和状态独立。切换到智能体创建时,标签、开始日期和自定义属性保留在手动草稿中。+子任务可以设置**阶段**(stage),按 1、2、3 分批推进。当前最早未完成阶段的全部子任务到达 `done` 或 `cancelled` 时,父任务会收到"子任务完成"通知;父任务的负责人是智能体时,它会被唤醒并决定是否推进下一阶段。未设置阶段的子任务视为同一批,全部结束时通知一次。这次唤醒由系统发起,规则和其他唤醒方式见[任务唤醒](/issue-wakeups)。## 视图和显示设置 [#切换视图]diff --git a/packages/core/issues/index.ts b/packages/core/issues/index.tsindex e26ef2d778..8c56dc6193 100644--- a/packages/core/issues/index.ts+++ b/packages/core/issues/index.ts@@ -20,3 +20,5 @@ export {normalizeStatusPatch,} from "./status-category";export * from "./wakeups";++export * from "./sub-issue-create";diff --git a/packages/core/issues/sub-issue-create.test.ts b/packages/core/issues/sub-issue-create.test.tsnew file mode 100644index 0000000000..3ab98e3a25--- /dev/null+++ b/packages/core/issues/sub-issue-create.test.ts@@ -0,0 +1,50 @@+// @vitest-environment node+import { describe, expect, it } from "vitest";+import type { Issue, IssueProperty } from "../types";+import { copyableParentProperties, copyParentIssueFields, subIssueCreateDefaults } from "./sub-issue-create";++const parent = {+ id: "parent", identifier: "TEST-1", project_id: "project",+ assignee_type: "member", assignee_id: "owner", status: "in_progress",+ priority: "high", description: "Parent scope", start_date: "2026-11-05", due_date: "2026-11-20",+ labels: [{ id: "label", name: "Product" }],+ properties: { customer: "Acme", budget: 100000, targets: ["A", "B"], approved: false, zero: 0, archived: "old", future: "unknown" },+} as unknown as Issue;+const property = (id: string, type = "text", archived = false) => ({ id, name: id, type, archived }) as IssueProperty;+const catalog = [property("customer"), property("budget", "number"), property("targets", "multi_text"), property("approved", "checkbox"), property("zero", "number"), property("archived", "text", true), property("future", "future")];++describe("sub-issue create context", () => {+ it.each(["member", "agent", "squad"] as const)("seeds project and %s assignee, never unrelated fields", (type) => {+ expect(subIssueCreateDefaults({ ...parent, assignee_type: type })).toEqual({+ parent_issue_id: "parent", parent_issue_identifier: "TEST-1", project_id: "project", assignee_type: type, assignee_id: "owner",+ });+ });+ it("omits absent or incomplete assignees rather than clearing sticky defaults", () => {+ expect(subIssueCreateDefaults({ id: "parent", assignee_type: "member", assignee_id: null })).toEqual({ parent_issue_id: "parent", parent_issue_identifier: undefined });+ });+});++describe("explicit parent field copies", () => {+ it("copies nothing by default", () => expect(copyParentIssueFields(parent, [], catalog)).toEqual({}));+ it("copies only selected fields and custom properties", () => {+ expect(copyParentIssueFields(parent, ["priority", "labels", "property:customer"], catalog)).toEqual({ priority: "high", label_ids: ["label"], properties: { customer: "Acme" } });+ });+ it("supports dates, false and zero without copying description, status or assignee", () => {+ expect(copyParentIssueFields(parent, ["start_date", "due_date", "property:approved", "property:zero"], catalog)).toEqual({ start_date: "2026-11-05", due_date: "2026-11-20", properties: { approved: false, zero: 0 } });+ });+ it("does not offer archived, unavailable or unknown property definitions", () => {+ expect(copyableParentProperties(parent, catalog).map((p) => p.id)).toEqual(["customer", "budget", "targets", "approved", "zero"]);+ expect(copyParentIssueFields(parent, ["property:archived", "property:future", "property:deleted"], catalog)).toEqual({});+ });+ it("excludes single-actor values this client cannot edit", () => {+ const source = { ...parent, properties: { external: "agent:remote" } };+ expect(copyParentIssueFields(source, ["property:external"], [property("external", "actor")])).toEqual({});+ });+ it("detaches arrays from the parent and retains explicit empty label copies", () => {+ const copy = copyParentIssueFields(parent, ["labels", "property:targets"], catalog);+ expect(copy.properties?.targets).not.toBe(parent.properties.targets);+ copy.label_ids?.push("new");+ expect(parent.labels).toHaveLength(1);+ expect(copyParentIssueFields({ ...parent, labels: [], start_date: null }, ["labels", "start_date"], catalog)).toEqual({ label_ids: [] });+ });+});diff --git a/packages/core/issues/sub-issue-create.ts b/packages/core/issues/sub-issue-create.tsnew file mode 100644index 0000000000..ad6cdbe2f7--- /dev/null+++ b/packages/core/issues/sub-issue-create.ts@@ -0,0 +1,49 @@+import type { CreateIssueRequest, Issue, IssueProperty, IssuePropertyValues } from "../types";+import { hasUnknownActorRef, isKnownPropertyType } from "../types/property";++type ParentContext = Pick<Issue, "id"> & Partial<Pick<Issue,+ "project_id" | "assignee_type" | "assignee_id"+>> & { identifier?: string | null };++/** Contextual defaults, not a backend inheritance contract. */+export function subIssueCreateDefaults(parent: ParentContext) {+ return {+ parent_issue_id: parent.id,+ parent_issue_identifier: parent.identifier ?? undefined,+ ...(parent.project_id ? { project_id: parent.project_id } : {}),+ // Omit the pair for an unassigned parent: preserve the last-used owner.+ ...(parent.assignee_type && parent.assignee_id+ ? { assignee_type: parent.assignee_type, assignee_id: parent.assignee_id }+ : {}),+ };+}++export type ParentCopyField = "priority" | "labels" | "start_date" | "due_date" | `property:${string}`;+export type ParentFieldCopy = Pick<CreateIssueRequest, "priority" | "label_ids" | "start_date" | "due_date" | "properties">;++export function copyableParentProperties(parent: Issue, catalog: IssueProperty[]) {+ return catalog.filter((property) =>+ !property.archived && isKnownPropertyType(property.type)+ && Object.hasOwn(parent.properties ?? {}, property.id)+ && !(property.type === "actor" && hasUnknownActorRef(parent.properties?.[property.id])),+ );+}++/** A detached snapshot of only explicitly selected, currently available fields. */+export function copyParentIssueFields(parent: Issue, fields: ParentCopyField[], catalog: IssueProperty[]): ParentFieldCopy {+ const selected = new Set(fields);+ const copy: ParentFieldCopy = {};+ if (selected.has("priority")) copy.priority = parent.priority;+ if (selected.has("labels")) copy.label_ids = (parent.labels ?? []).map((label) => label.id);+ if (selected.has("start_date") && parent.start_date) copy.start_date = parent.start_date;+ if (selected.has("due_date") && parent.due_date) copy.due_date = parent.due_date;+ const properties: IssuePropertyValues = {};+ for (const property of copyableParentProperties(parent, catalog)) {+ if (!selected.has(`property:${property.id}`)) continue;+ const value = parent.properties[property.id];+ if (value === undefined) continue;+ properties[property.id] = Array.isArray(value) ? [...value] : value;+ }+ if (Object.keys(properties).length > 0) copy.properties = properties;+ return copy;+}diff --git a/packages/views/issues/actions/use-issue-actions.ts b/packages/views/issues/actions/use-issue-actions.tsindex 4fbd83ac28..669d43cfcb 100644--- a/packages/views/issues/actions/use-issue-actions.ts+++ b/packages/views/issues/actions/use-issue-actions.ts@@ -1,5 +1,6 @@"use client";+import { subIssueCreateDefaults } from "@multica/core/issues";import { useCallback } from "react";import { useQuery } from "@tanstack/react-query";import { toast } from "sonner";@@ -194,21 +195,13 @@ export function useIssueActions(issue: Issue | null): UseIssueActionsResult {const openCreateSubIssue = useCallback(() => {if (!issueId) return;- openModal("create-issue", {- parent_issue_id: issueId,- parent_issue_identifier: issueIdentifier,- ...(issueProjectId ? { project_id: issueProjectId } : {}),- // Inherit the parent's assignee (member/agent/squad) so a sub-issue- // created from the "Add sub-issue" entry starts with the same owner- // (discussion #1728). The modal keys off whether these fields are- // present, not their value, so a seed overrides the sticky last-used- // assignee it would otherwise fall back to, while omitting both for- // an unassigned parent leaves that fallback intact. Seed the two- // together — assignee_type is meaningless without assignee_id.- ...(issueAssigneeType && issueAssigneeId- ? { assignee_type: issueAssigneeType, assignee_id: issueAssigneeId }- : {}),- });+ openModal("create-issue", subIssueCreateDefaults({+ id: issueId,+ identifier: issueIdentifier,+ project_id: issueProjectId,+ assignee_type: issueAssigneeType,+ assignee_id: issueAssigneeId,+ }));}, [openModal,issueId,diff --git a/packages/views/issues/components/issue-detail.tsx b/packages/views/issues/components/issue-detail.tsxindex 45694b76ed..c5d7d32dca 100644--- a/packages/views/issues/components/issue-detail.tsx+++ b/packages/views/issues/components/issue-detail.tsx@@ -1,5 +1,6 @@"use client";+import { subIssueCreateDefaults } from "@multica/core/issues";import {issueBehavesAs,issueBehavesAsAny,@@ -1583,13 +1584,8 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = trconst openCommentSubIssue = useCallback((commentId: string) => {if (!issue) return;openModal("quick-create-issue", {+ ...subIssueCreateDefaults(issue),anchor_comment_id: commentId,- parent_issue_id: issue.id,- parent_issue_identifier: issue.identifier,- ...(issue.project_id ? { project_id: issue.project_id } : {}),- ...(issue.assignee_type && issue.assignee_id- ? { assignee_type: issue.assignee_type, assignee_id: issue.assignee_id }- : {}),});}, [issue, openModal]);diff --git a/packages/views/issues/components/table-view.tsx b/packages/views/issues/components/table-view.tsxindex 0aa30229b6..f68a8b166f 100644--- a/packages/views/issues/components/table-view.tsx+++ b/packages/views/issues/components/table-view.tsx@@ -1,5 +1,6 @@"use client";+import { subIssueCreateDefaults } from "@multica/core/issues";import { useStatusLabel } from "../utils/status-label";import {useCallback,@@ -2214,11 +2215,7 @@ export function TableView({const createSubIssue = useCallback((issue: Issue) =>- onCreateIssue({- parent_issue_id: issue.id,- parent_issue_identifier: issue.identifier,- ...(issue.project_id ? { project_id: issue.project_id } : {}),- }),+ onCreateIssue(subIssueCreateDefaults(issue)),[onCreateIssue],);diff --git a/packages/views/locales/en/modals.json b/packages/views/locales/en/modals.jsonindex a882b1e7ba..770a2a3177 100644--- a/packages/views/locales/en/modals.json+++ b/packages/views/locales/en/modals.json@@ -273,5 +273,13 @@"toast_failed": "Failed to mark as duplicate","error_target_is_duplicate": "{{identifier}} is itself a duplicate. Pick its original instead.","error_has_duplicates": "Other issues are marked as duplicates of this one. Remove those marks first."+ },+ "copy_parent_fields": {+ "trigger": "Copy parent fields",+ "title": "Copy parent fields",+ "description": "From {{identifier}}. Replaces selected draft values once; later changes do not sync.",+ "apply": "Copy {{count}} fields",+ "no_labels": "No labels",+ "manual_only": "Labels, start date and custom properties apply only to manual creation."}}diff --git a/packages/views/locales/es/modals.json b/packages/views/locales/es/modals.jsonindex 535a9f234c..0a918f7fa8 100644--- a/packages/views/locales/es/modals.json+++ b/packages/views/locales/es/modals.json@@ -273,5 +273,13 @@"description": "Busca una tarea para moverla a este proyecto","toast_success": "{{identifier}} movida al proyecto","toast_failed": "No se ha podido mover la tarea"+ },+ "copy_parent_fields": {+ "trigger": "Copiar campos de la tarea principal",+ "title": "Copiar campos de la tarea principal",+ "description": "Desde {{identifier}}. Sustituye una vez los valores seleccionados; los cambios posteriores no se sincronizan.",+ "apply": "Copiar {{count}} campos",+ "no_labels": "Sin etiquetas",+ "manual_only": "Las etiquetas, la fecha de inicio y las propiedades personalizadas solo se aplican a la creación manual."}}diff --git a/packages/views/locales/fr/modals.json b/packages/views/locales/fr/modals.jsonindex 4f5c0b874d..c3e605cb97 100644--- a/packages/views/locales/fr/modals.json+++ b/packages/views/locales/fr/modals.json@@ -273,5 +273,13 @@"toast_failed": "Échec du marquage comme doublon","error_target_is_duplicate": "{{identifier}} est elle-même un doublon. Choisissez plutôt sa tâche d'origine.","error_has_duplicates": "D'autres tâches sont marquées comme doublons de celle-ci. Retirez d'abord ces marques."+ },+ "copy_parent_fields": {+ "trigger": "Copier les champs du parent",+ "title": "Copier les champs du parent",+ "description": "Depuis {{identifier}}. Remplace une fois les valeurs sélectionnées ; les modifications ultérieures ne sont pas synchronisées.",+ "apply": "Copier {{count}} champs",+ "no_labels": "Aucune étiquette",+ "manual_only": "Les étiquettes, la date de début et les propriétés personnalisées ne concernent que la création manuelle."}}diff --git a/packages/views/locales/ja/modals.json b/packages/views/locales/ja/modals.jsonindex 9f405d670c..f70648c392 100644--- a/packages/views/locales/ja/modals.json+++ b/packages/views/locales/ja/modals.json@@ -271,5 +271,13 @@"toast_failed": "重複としてマークできませんでした","error_target_is_duplicate": "{{identifier}} 自体が重複です。元のタスクを選択してください","error_has_duplicates": "他のタスクがこのタスクの重複としてマークされています。先にそのマークを解除してください"+ },+ "copy_parent_fields": {+ "trigger": "親タスクのフィールドをコピー",+ "title": "親タスクのフィールドをコピー",+ "description": "{{identifier}} から選択した値を一度だけ上書きします。以降の変更は同期されません。",+ "apply": "{{count}} 項目をコピー",+ "no_labels": "ラベルなし",+ "manual_only": "ラベル、開始日、カスタムプロパティは手動作成にのみ適用されます。"}}diff --git a/packages/views/locales/ko/modals.json b/packages/views/locales/ko/modals.jsonindex 2bc18a399a..a56bd87e19 100644--- a/packages/views/locales/ko/modals.json+++ b/packages/views/locales/ko/modals.json@@ -271,5 +271,13 @@"toast_failed": "중복으로 표시하지 못했습니다","error_target_is_duplicate": "{{identifier}}은(는) 이미 중복입니다. 원본 태스크를 선택하세요","error_has_duplicates": "다른 태스크가 이 태스크의 중복으로 표시되어 있습니다. 먼저 해당 표시를 해제하세요"+ },+ "copy_parent_fields": {+ "trigger": "상위 태스크 필드 복사",+ "title": "상위 태스크 필드 복사",+ "description": "{{identifier}}에서 선택한 값을 한 번 덮어씁니다. 이후 변경 사항은 동기화되지 않습니다.",+ "apply": "{{count}}개 필드 복사",+ "no_labels": "라벨 없음",+ "manual_only": "라벨, 시작일, 사용자 지정 속성은 수동 생성에만 적용됩니다."}}diff --git a/packages/views/locales/zh-Hans/modals.json b/packages/views/locales/zh-Hans/modals.jsonindex 7d8ae881cd..dfcc7d0544 100644--- a/packages/views/locales/zh-Hans/modals.json+++ b/packages/views/locales/zh-Hans/modals.json@@ -271,5 +271,13 @@"toast_failed": "无法标记为重复","error_target_is_duplicate": "{{identifier}} 本身是重复任务,请选择它的原始任务","error_has_duplicates": "已有任务被标记为此任务的重复,请先解除这些标记"+ },+ "copy_parent_fields": {+ "trigger": "复制父任务字段",+ "title": "复制父任务字段",+ "description": "从 {{identifier}} 复制所选字段,覆盖当前值;后续不联动。",+ "apply": "复制所选 {{count}} 项",+ "no_labels": "无标签",+ "manual_only": "标签、开始日期和自定义属性仅用于手动创建。"}}diff --git a/packages/views/locales/zh-Hant/modals.json b/packages/views/locales/zh-Hant/modals.jsonindex 8ed679b8d0..4ba4392ab2 100644--- a/packages/views/locales/zh-Hant/modals.json+++ b/packages/views/locales/zh-Hant/modals.json@@ -271,5 +271,13 @@"toast_failed": "無法標記為重複","error_target_is_duplicate": "{{identifier}} 本身是重複任務,請選擇它的原始任務","error_has_duplicates": "已有任務被標記為此任務的重複,請先解除這些標記"+ },+ "copy_parent_fields": {+ "trigger": "複製父任務欄位",+ "title": "複製父任務欄位",+ "description": "從 {{identifier}} 複製所選欄位,覆蓋目前值;後續不連動。",+ "apply": "複製所選 {{count}} 項",+ "no_labels": "無標籤",+ "manual_only": "標籤、開始日期和自訂屬性僅用於手動建立。"}}diff --git a/packages/views/modals/copy-parent-fields.test.tsx b/packages/views/modals/copy-parent-fields.test.tsxnew file mode 100644index 0000000000..5c42ecd511--- /dev/null+++ b/packages/views/modals/copy-parent-fields.test.tsx@@ -0,0 +1,42 @@+import { describe, expect, it, vi } from "vitest";+import { render, screen, waitFor } from "@testing-library/react";+import userEvent from "@testing-library/user-event";+import { I18nProvider } from "@multica/core/i18n/react";+import type { Issue, IssueProperty } from "@multica/core/types";+import enIssues from "../locales/en/issues.json";+import enModals from "../locales/en/modals.json";+import { CopyParentFields } from "./copy-parent-fields";++const parent = { id: "parent", identifier: "TEST-1", priority: "high", labels: [{ id: "label", name: "Product" }], start_date: "2026-11-05", due_date: null, properties: { customer: "Acme", budget: 100000 } } as unknown as Issue;+const properties = ["customer", "budget"].map((id) => ({ id, name: id, type: id === "budget" ? "number" : "text", config: {}, archived: false })) as IssueProperty[];+function setup(onCopy = vi.fn()) {+ const user = userEvent.setup();+ const view = render(<I18nProvider locale="en" resources={{ en: { issues: enIssues, modals: enModals } }}><CopyParentFields parent={parent} properties={properties} onCopy={onCopy} /></I18nProvider>);+ return { ...view, user, onCopy };+}++describe("CopyParentFields", () => {+ it("requires an explicit selection, applies it once, and resets on reopen", async () => {+ const { user, onCopy } = setup();+ await user.click(screen.getByRole("button", { name: "Copy parent fields" }));+ expect(screen.getByRole("button", { name: "Copy 0 fields" })).toBeDisabled();+ expect(screen.getAllByRole("checkbox").every((el) => el.getAttribute("aria-checked") === "false")).toBe(true);+ await user.click(screen.getByRole("checkbox", { name: /Priority/ }));+ await user.click(screen.getByRole("checkbox", { name: /customer/ }));+ await user.click(screen.getByRole("button", { name: "Copy 2 fields" }));+ expect(onCopy).toHaveBeenCalledExactlyOnceWith({ priority: "high", properties: { customer: "Acme" } });+ await waitFor(() => expect(screen.queryByRole("checkbox")).not.toBeInTheDocument());+ await user.click(screen.getByRole("button", { name: "Copy parent fields" }));+ expect(screen.getByRole("button", { name: "Copy 0 fields" })).toBeDisabled();+ });+ it("Escape cancels without modifying the draft and restores the trigger focus", async () => {+ const { user, onCopy } = setup();+ const trigger = screen.getByRole("button", { name: "Copy parent fields" });+ await user.click(trigger);+ await user.click(screen.getByRole("checkbox", { name: /Labels/ }));+ await user.keyboard("{Escape}");+ await waitFor(() => expect(screen.queryByRole("checkbox")).not.toBeInTheDocument());+ expect(onCopy).not.toHaveBeenCalled();+ expect(trigger).toHaveFocus();+ });+});diff --git a/packages/views/modals/copy-parent-fields.tsx b/packages/views/modals/copy-parent-fields.tsxnew file mode 100644index 0000000000..33fd4b70cf--- /dev/null+++ b/packages/views/modals/copy-parent-fields.tsx@@ -0,0 +1,67 @@+"use client";++import { useState, type ReactNode } from "react";+import type { Issue, IssueProperty } from "@multica/core/types";+import { copyableParentProperties, copyParentIssueFields, type ParentCopyField, type ParentFieldCopy } from "@multica/core/issues";+import { Button } from "@multica/ui/components/ui/button";+import { Checkbox } from "@multica/ui/components/ui/checkbox";+import { Popover, PopoverContent, PopoverDescription, PopoverTitle, PopoverTrigger } from "@multica/ui/components/ui/popover";+import { CustomPropertyValueDisplay } from "../issues/components/pickers/custom-property-picker";+import { useT } from "../i18n";++export function CopyParentFields({ parent, properties, onCopy, disabled }: {+ parent: Issue;+ properties: IssueProperty[];+ onCopy: (copy: ParentFieldCopy) => void;+ disabled?: boolean;+}) {+ const { t } = useT("modals");+ const { t: tIssues } = useT("issues");+ const [open, setOpen] = useState(false);+ const [selected, setSelected] = useState<ParentCopyField[]>([]);+ const rows: { key: ParentCopyField; label: string; value: ReactNode }[] = [+ { key: "priority", label: tIssues(($) => $.detail.prop_priority), value: tIssues(($) => $.priority[parent.priority]) },+ { key: "labels", label: tIssues(($) => $.detail.prop_labels), value: (parent.labels ?? []).map((label) => label.name).join(", ") || t(($) => $.copy_parent_fields.no_labels) },+ ...(parent.start_date ? [{ key: "start_date" as const, label: tIssues(($) => $.detail.prop_start_date), value: parent.start_date }] : []),+ ...(parent.due_date ? [{ key: "due_date" as const, label: tIssues(($) => $.detail.prop_due_date), value: parent.due_date }] : []),+ ...copyableParentProperties(parent, properties).map((property) => ({+ key: `property:${property.id}` as const,+ label: property.name,+ value: <CustomPropertyValueDisplay property={property} value={parent.properties[property.id]} />,+ })),+ ];+ return (+ <Popover open={open} onOpenChange={(next) => { setOpen(next); if (next) setSelected([]); }}>+ <PopoverTrigger render={<Button type="button" variant="ghost" size="xs" disabled={disabled} />}>+ {t(($) => $.copy_parent_fields.trigger)}+ </PopoverTrigger>+ <PopoverContent align="end" className="w-80 max-w-[calc(100vw-2rem)] gap-3 p-3">+ <PopoverTitle>{t(($) => $.copy_parent_fields.title)}</PopoverTitle>+ <PopoverDescription>+ {t(($) => $.copy_parent_fields.description, { identifier: parent.identifier })}+ </PopoverDescription>+ <div className="max-h-64 overflow-y-auto">+ {rows.map((row) => (+ <label key={row.key} className="flex min-h-9 cursor-pointer items-center gap-2 rounded-sm px-1 py-1.5 hover:bg-accent">+ <Checkbox+ aria-label={row.label}+ checked={selected.includes(row.key)}+ onCheckedChange={(checked) => setSelected((current) => checked ? [...current, row.key] : current.filter((key) => key !== row.key))}+ />+ <span className="min-w-0 flex-1 break-words text-caption">{row.label}</span>+ <span className="min-w-0 max-w-40 break-words text-right text-caption text-muted-foreground">{row.value}</span>+ </label>+ ))}+ </div>+ <p className="text-micro text-muted-foreground">{t(($) => $.copy_parent_fields.manual_only)}</p>+ <div className="flex justify-end gap-2">+ <Button type="button" variant="ghost" size="sm" onClick={() => setOpen(false)}>{t(($) => $.common.cancel)}</Button>+ <Button type="button" size="sm" disabled={selected.length === 0 || disabled} onClick={() => {+ onCopy(copyParentIssueFields(parent, selected, properties));+ setOpen(false);+ }}>{t(($) => $.copy_parent_fields.apply, { count: selected.length })}</Button>+ </div>+ </PopoverContent>+ </Popover>+ );+}diff --git a/packages/views/modals/create-issue-batch-continuation.test.tsx b/packages/views/modals/create-issue-batch-continuation.test.tsxindex cf10860252..cb5ba32826 100644--- a/packages/views/modals/create-issue-batch-continuation.test.tsx+++ b/packages/views/modals/create-issue-batch-continuation.test.tsx@@ -88,6 +88,16 @@ vi.mock("@multica/core/hooks", () => ({useWorkspaceId: () => "ws-test",}));+vi.mock("@multica/core/auth", () => {+ const state = { user: { id: "user-1" } };+ return {+ useAuthStore: Object.assign(+ (selector: (s: typeof state) => unknown) => selector(state),+ { getState: () => state },+ ),+ };+});+vi.mock("./use-issue-limit-upgrade-prompt", () => ({useIssueLimitUpgradePrompt: () => vi.fn(),}));@@ -150,6 +160,14 @@ vi.mock("@multica/core/api", async () => {return {api: {listProperties: mockListProperties,+ listAgents: async () => [+ { id: "agent-default", name: "Default Agent", owner_id: "user-1", runtime_id: "runtime-1", archived_at: null },+ { id: "agent-x", name: "Agent X", owner_id: "user-1", runtime_id: "runtime-1", archived_at: null },+ ],+ listMembers: async () => [{ user_id: "user-1", role: "admin" }],+ listSquads: async () => [],+ listRuntimes: async () => [{ id: "runtime-1", metadata: { cli_version: "1.2.3" } }],+ listProjects: async () => ({ projects: [] }),uploadFile: vi.fn(),},ApiError,@@ -186,6 +204,7 @@ vi.mock("../editor", async () => {setValue("");},hasActiveUploads: () => false,+ focus: vi.fn(),insertUploadPlaceholder: () => true,settleUploadPlaceholder: () => false,}));@@ -253,8 +272,17 @@ vi.mock("../issues/components", () => ({PriorityPicker: ({ onUpdate }: { onUpdate: (u: { priority: string }) => void }) => (<button type="button" data-testid="priority-picker" onClick={() => onUpdate({ priority: "high" })} />),+ PriorityIcon: () => null,StagePicker: () => <div data-testid="stage-picker" />,- AssigneePicker: () => <div data-testid="assignee-picker" />,+ AssigneePicker: ({ assigneeId, onUpdate }: {+ assigneeId: string | null;+ onUpdate: (u: { assignee_type: "member" | null; assignee_id: string | null }) => void;+ }) => (+ <div data-testid="assignee-picker" data-assignee-id={assigneeId ?? "none"}>+ <button type="button" onClick={() => onUpdate({ assignee_type: null, assignee_id: null })}>Clear assignee</button>+ <button type="button" onClick={() => onUpdate({ assignee_type: "member", assignee_id: "alice" })}>Assign Alice</button>+ </div>+ ),StartDatePicker: () => <div data-testid="start-date-picker" />,DueDatePicker: () => <div data-testid="due-date-picker" />,LabelPicker: () => <div data-testid="label-picker" />,@@ -407,7 +435,7 @@ beforeEach(() => {lastAssigneeType: undefined,lastAssigneeId: undefined,});- useQuickCreateStore.setState({ keepOpen: false });+ useQuickCreateStore.setState({ keepOpen: false, lastActorType: null, lastActorId: null });mockListProperties.mockResolvedValue({ properties: [] });const createdIssue = {id: "issue-1",@@ -449,6 +477,49 @@ async function submitAndKeepOpen(user: ReturnType<typeof userEvent.setup>) {expect(screen.getByPlaceholderText("Issue title")).toHaveValue("");}+describe("assignee across create-mode switches", () => {+ it("prefills the selected agent when manual create started without an assignee", async () => {+ const user = userEvent.setup();+ renderUi(<CreateIssueDialog onClose={vi.fn()} initialMode="manual" />);+ await user.type(screen.getByPlaceholderText("Issue title"), "Review payment callback");+ await user.click(screen.getByRole("button", { name: /Switch to Agent/i }));+ await user.click(await screen.findByRole("button", { name: /Created by/ }));+ await user.click(await screen.findByRole("button", { name: /^Agent X$/ }));+ await user.click(screen.getByRole("button", { name: /Switch to Manual/i }));+ expect(screen.getByTestId("assignee-picker")).toHaveAttribute("data-assignee-id", "agent-x");+ await user.click(screen.getByRole("button", { name: "Create Issue" }));+ await waitFor(() => expect(mockCreateIssue).toHaveBeenCalledWith(expect.objectContaining({+ assignee_type: "agent", assignee_id: "agent-x",+ })));+ });++ it("preserves an explicit clear over repeated switches and allows assigning again", async () => {+ const user = userEvent.setup();+ renderUi(<CreateIssueDialog onClose={vi.fn()} initialMode="manual" data={{ assignee_type: "member", assignee_id: "alice" }} />);+ await user.click(screen.getByRole("button", { name: "Clear assignee" }));+ for (let i = 0; i < 2; i++) {+ await user.click(screen.getByRole("button", { name: /Switch to Agent/i }));+ await screen.findByRole("button", { name: /Created by.*Default Agent/ });+ await user.click(screen.getByRole("button", { name: /Switch to Manual/i }));+ expect(screen.getByTestId("assignee-picker")).toHaveAttribute("data-assignee-id", "none");+ }+ await user.click(screen.getByRole("button", { name: "Assign Alice" }));+ await user.click(screen.getByRole("button", { name: /Switch to Agent/i }));+ await user.click(screen.getByRole("button", { name: /Switch to Manual/i }));+ expect(screen.getByTestId("assignee-picker")).toHaveAttribute("data-assignee-id", "alice");+ });++ it("keeps an existing manual assignee when another filing agent is selected", async () => {+ const user = userEvent.setup();+ renderUi(<CreateIssueDialog onClose={vi.fn()} initialMode="manual" data={{ assignee_type: "member", assignee_id: "alice" }} />);+ await user.click(screen.getByRole("button", { name: /Switch to Agent/i }));+ await user.click(await screen.findByRole("button", { name: /Created by/ }));+ await user.click(await screen.findByRole("button", { name: /^Agent X$/ }));+ await user.click(screen.getByRole("button", { name: /Switch to Manual/i }));+ expect(screen.getByTestId("assignee-picker")).toHaveAttribute("data-assignee-id", "alice");+ });+});+describe("keep-open continuation cleanup", () => {it("closes a continuation that was only switched to agent mode as a fresh todo create", async () => {const user = userEvent.setup();diff --git a/packages/views/modals/create-issue-dialog.test.tsx b/packages/views/modals/create-issue-dialog.test.tsxindex ce43ae9e13..4ed8d90f41 100644--- a/packages/views/modals/create-issue-dialog.test.tsx+++ b/packages/views/modals/create-issue-dialog.test.tsx@@ -98,6 +98,7 @@ vi.mock("./create-issue", () => ({}) => (<div>manual panel · {String(data?.anchor_comment_id ?? "ordinary")} · {data?.source_context_expanded ? "expanded" : "collapsed"}+ <span data-testid="manual-owner">{String(data?.assignee_id ?? "draft")}</span><button type="button" onClick={() => onSwitchMode?.({ parent_issue_id: data?.parent_issue_id })}>switch agent</button>@@ -141,6 +142,15 @@ describe("CreateIssueDialog sizing", () => {expect(screen.getByText(/manual panel · ordinary/)).toBeInTheDocument();});+ it("seeds the parent owner on the first agent-to-manual switch only", () => {+ render(<CreateIssueDialog onClose={vi.fn()} initialMode="agent" data={{ parent_issue_id: "parent", assignee_type: "member", assignee_id: "parent-owner" }} />);+ fireEvent.click(screen.getByRole("button", { name: "switch manual" }));+ expect(screen.getByTestId("manual-owner")).toHaveTextContent("parent-owner");+ fireEvent.click(screen.getByRole("button", { name: "switch agent" }));+ fireEvent.click(screen.getByRole("button", { name: "switch manual" }));+ expect(screen.getByTestId("manual-owner")).toHaveTextContent("draft");+ });+it("isolates source-context drafts and preserves source identity across mode switches", () => {const view = render(<CreateIssueDialogdiff --git a/packages/views/modals/create-issue-dialog.tsx b/packages/views/modals/create-issue-dialog.tsxindex 35aa6a2bad..e9c22add32 100644--- a/packages/views/modals/create-issue-dialog.tsx+++ b/packages/views/modals/create-issue-dialog.tsx@@ -120,15 +120,28 @@ function CreateIssueDialogBody({}) {const setLastMode = useCreateModeStore((s) => s.setLastMode);const [mode, setMode] = useState<CreateMode>(initialMode);+ const [manualOpened, setManualOpened] = useState(initialMode === "manual");const [panelData, setPanelData] = useState(data ?? null);const [isExpanded, setIsExpanded] = useState(false);- const effectiveData = sourceContextData- ? { ...(panelData ?? {}), ...sourceContextData }- : panelData;+ const effectiveData = {+ ...(panelData ?? {}),+ ...sourceContextData,+ };const switchTo = (next: CreateMode) => (carry?: Record<string, unknown> | null) => {setLastMode(next);- setPanelData(carry ?? null);+ // Apply contextual owner defaults only on the first visit to manual mode.+ // Later visits must preserve the user's edits, including an explicit clear.+ const seedParentOwner = next === "manual" && !manualOpened+ && typeof data?.parent_issue_id === "string"+ && carry?.parent_issue_id === data?.parent_issue_id+ && data?.assignee_type && data?.assignee_id;+ setPanelData(seedParentOwner ? {+ ...carry,+ assignee_type: data.assignee_type,+ assignee_id: data.assignee_id,+ } : carry ?? null);+ if (next === "manual") setManualOpened(true);setMode(next);};diff --git a/packages/views/modals/create-issue.test.tsx b/packages/views/modals/create-issue.test.tsxindex 66fe7ed8a3..ad1b258519 100644--- a/packages/views/modals/create-issue.test.tsx+++ b/packages/views/modals/create-issue.test.tsx@@ -11,6 +11,7 @@ import { describe, it, expect, vi, beforeEach, onTestFinished } from "vitest";import { act, fireEvent, render, screen, waitFor } from "@testing-library/react";import userEvent from "@testing-library/user-event";import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import type { Issue } from "@multica/core/types";import { I18nProvider } from "@multica/core/i18n/react";import enCommon from "../locales/en/common.json";import enModals from "../locales/en/modals.json";@@ -30,6 +31,7 @@ function I18nWrapper({ children }: { children: ReactNode }) {);}+const mockParentIssue = vi.hoisted(() => ({ value: null as Issue | null }));const mockPush = vi.hoisted(() => vi.fn());const mockCreateIssue = vi.hoisted(() => vi.fn());const mockCreateCommentSubIssue = vi.hoisted(() => vi.fn());@@ -231,7 +233,7 @@ vi.mock("./use-issue-limit-upgrade-prompt", () => ({vi.mock("@multica/core/issues/queries", () => ({issueDetailOptions: (wsId: string, id: string) => ({queryKey: ["issues", wsId, "detail", id],- queryFn: () => Promise.resolve(null),+ queryFn: () => Promise.resolve(mockParentIssue.value),}),childIssuesOptions: (wsId: string, id: string) => ({queryKey: ["issues", wsId, "children", id],@@ -650,6 +652,7 @@ function renderModal(element: React.ReactElement) {describe("CreateIssueModal", () => {beforeEach(() => {vi.clearAllMocks();+ mockParentIssue.value = null;mockQuickCreateStore.keepOpen = false;mockCreateSettingsStore.manualCreateFields = DEFAULT_MANUAL_FIELDS;mockSetKeepOpen.mockImplementation((v: boolean) => {@@ -777,6 +780,29 @@ describe("CreateIssueModal", () => {});});+ it("applies selected parent fields to the submitted issue without replacing its scope", async () => {+ const user = userEvent.setup();+ mockParentIssue.value = {+ id: "parent-copy", identifier: "TES-10", priority: "high", labels: [],+ start_date: "2026-11-05", due_date: "2026-11-20", description: "Parent scope",+ properties: { "property-tier": "option-enterprise" },+ } as unknown as Issue;+ mockDraftStore.draft.manual.title = "Child scope";+ mockDraftStore.draft.manual.description = "Only implement validation";+ renderModal(<CreateIssueModal onClose={vi.fn()} data={{ parent_issue_id: "parent-copy" }} />);+ await user.click(await screen.findByRole("button", { name: "Copy parent fields" }));+ await user.click(screen.getByRole("checkbox", { name: /Priority/ }));+ await user.click(screen.getByRole("checkbox", { name: /Start date/ }));+ await user.click(await screen.findByRole("checkbox", { name: /Customer tier/ }));+ await user.click(screen.getByRole("button", { name: "Copy 3 fields" }));+ await user.click(screen.getByRole("button", { name: "Create Issue" }));+ expect(mockCreateIssue).toHaveBeenCalledWith(expect.objectContaining({+ title: "Child scope", description: "Only implement validation", status: "todo",+ priority: "high", start_date: "2026-11-05", due_date: undefined,+ properties: { "property-tier": "option-enterprise" }, parent_issue_id: "parent-copy",+ }));+ });+it("uses the same compact attachment control as agent mode", () => {renderModal(<CreateIssueModal onClose={vi.fn()} />);diff --git a/packages/views/modals/create-issue.tsx b/packages/views/modals/create-issue.tsxindex 623616b41c..1c13ebd20e 100644--- a/packages/views/modals/create-issue.tsx+++ b/packages/views/modals/create-issue.tsx@@ -101,6 +101,7 @@ import { IssuePickerModal } from "./issue-picker-modal";import { useT } from "../i18n";import { SourceContextPreviewCard, useSourceContextFailureMessage } from "./source-context-preview";import { useIssueLimitUpgradePrompt } from "./use-issue-limit-upgrade-prompt";+import { CopyParentFields } from "./copy-parent-fields";// ManualCreatePanel — manual-mode body of the create-issue dialog. Renders// DialogContent + everything inside; the surrounding `<Dialog>` is owned by@@ -295,6 +296,7 @@ export function ManualCreatePanel({}return draft.manual.assigneeId;});+ const [assigneeCleared, setAssigneeCleared] = useState(data?.manual_assignee_cleared === true);const [startDate, setStartDate] = useState<string | null>(draft.manual.startDate);const [dueDate, setDueDate] = useState<string | null>((data?.due_date as string | undefined) ?? draft.shared.dueDate,@@ -408,6 +410,7 @@ export function ManualCreatePanel({const updatePriority = (v: IssuePriority) => { setPriority(v); setShared({ priority: v }); };const updateAssignee = (type?: IssueAssigneeType, id?: string) => {setAssigneeType(type); setAssigneeId(id);+ setAssigneeCleared(!id);setManual({ assigneeType: type, assigneeId: id });};const updateProject = (id?: string) => { setProjectId(id); setShared({ projectId: id }); };@@ -866,6 +869,7 @@ export function ManualCreatePanel({// project) that was never written through a picker, so a plain flip would// otherwise drop it.setShared({ projectId, priority, dueDate });+ setManual({ assigneeType, assigneeId });const existingPrompt = draft.agent.prompt;if (!existingPrompt.trim()) {const desc = descEditorRef.current?.getMarkdown()?.trim() ?? "";@@ -892,6 +896,7 @@ export function ManualCreatePanel({const carry: Record<string, unknown> = {};if (parentIssueId) carry.parent_issue_id = parentIssueId;if (carryParentIdentifier) carry.parent_issue_identifier = carryParentIdentifier;+ if (assigneeCleared) carry.manual_assignee_cleared = true;onSwitchMode?.(Object.keys(carry).length > 0 ? carry : null);};@@ -957,13 +962,31 @@ export function ManualCreatePanel({<DialogTitle className="sr-only">{t(($) => $.create_issue.sr_manual)}</DialogTitle>{/* Header */}- <div className="flex items-center justify-between px-5 pt-3 pb-2 shrink-0">+ <div className="flex flex-wrap items-center justify-between gap-y-1 px-5 pt-3 pb-2 shrink-0"><div className="flex items-center gap-1.5 text-caption"><span className="text-muted-foreground">{workspaceName}</span><ChevronRight className="size-3 text-faint-foreground" /><span className="font-medium">{t(($) => $.create_issue.manual_breadcrumb)}</span></div>- <div className="flex items-center gap-1">+ <div className="ml-auto flex min-w-0 items-center gap-1">+ {parentIssue && (+ <CopyParentFields+ key={parentIssue.id}+ parent={parentIssue}+ properties={workspaceProperties}+ disabled={submitBusy}+ onCopy={(copy) => {+ if (copy.priority !== undefined) updatePriority(copy.priority);+ if (copy.label_ids !== undefined) updateLabelIds(copy.label_ids);+ if (copy.start_date !== undefined) updateStartDate(copy.start_date);+ if (copy.due_date !== undefined) updateDueDate(copy.due_date);+ if (copy.properties) {+ setPropertyValues((current) => ({ ...current, ...copy.properties }));+ setManual({ propertyValues: { ...useIssueDraftStore.getState().draft.manual.propertyValues, ...copy.properties } });+ }+ }}+ />+ )}<Tooltip><TooltipTriggerrender={diff --git a/packages/views/modals/quick-create-issue.test.tsx b/packages/views/modals/quick-create-issue.test.tsxindex 7151fce173..d2a60bd139 100644--- a/packages/views/modals/quick-create-issue.test.tsx+++ b/packages/views/modals/quick-create-issue.test.tsx@@ -500,6 +500,14 @@ function renderPanel(props: React.ComponentProps<typeof AgentCreatePanel>) {}describe("AgentCreatePanel", () => {+ it("does not replace an explicitly cleared manual assignee with the filing agent", async () => {+ const user = userEvent.setup();+ renderPanel({ onClose: vi.fn(), onSwitchMode: vi.fn(), isExpanded: false, setIsExpanded: vi.fn(), data: { manual_assignee_cleared: true } });+ await user.click(screen.getByRole("button", { name: /Switch to Manual/i }));+ expect(mockIssueDraftStore.draft.manual.assigneeId).toBeUndefined();+ expect(mockSetManual.mock.calls.some(([patch]) => "assigneeId" in patch)).toBe(false);+ });+it("selects Qoder agents without the daemon CLI version gate", () => {mockRuntimesData.list = [{ id: "runtime-1", provider: "qoder_cloud", metadata: {} }];mockQuickCreateStore.lastActorType = "agent";diff --git a/packages/views/modals/quick-create-issue.tsx b/packages/views/modals/quick-create-issue.tsxindex 387f57d68c..a07934c0e6 100644--- a/packages/views/modals/quick-create-issue.tsx+++ b/packages/views/modals/quick-create-issue.tsx@@ -608,7 +608,7 @@ export function AgentCreatePanel({const md = editorRef.current?.getMarkdown() ?? "";if (md) setManual({ description: md });}- if (!draft.manual.assigneeId && actor) {+ if (data?.manual_assignee_cleared !== true && !draft.manual.assigneeId && actor) {setManual({ assigneeType: actor.type, assigneeId: actor.id });}setLastMode("manual");@@ -616,6 +616,7 @@ export function AgentCreatePanel({const carry: Record<string, unknown> = {};if (parentIssueId) carry.parent_issue_id = parentIssueId;if (parentIssueIdentifier) carry.parent_issue_identifier = parentIssueIdentifier;+ if (data?.manual_assignee_cleared === true) carry.manual_assignee_cleared = true;onSwitchMode?.(Object.keys(carry).length > 0 ? carry : null);};