Files
multica/packages/views/modals/registry.tsx
Bohan Jiang 2a59236575 refactor(create-issue): unify agent/manual modes under one Dialog shell (#1826)
Recasts Quick/Advanced as Agent/Manual and lets users flip between modes
in-place from a footer switch button instead of a separate Advanced
shortcut. The two old modal types now route through one CreateIssueDialog
shell that owns the single <Dialog> and <DialogContent> — only the inner
panel body swaps on mode change, so the Portal/Backdrop/Popup stay
mounted and the switch is instant (no close→open animation flash).

Mode preference is persisted globally in localStorage via a small
useCreateModeStore, so the `c` shortcut always opens whichever mode the
user last used (or switched to). Carry payload (description / agent /
prompt) hands off through the shell's local state plus the existing
issue-draft store, so nothing the user typed is lost across switches.

Also drops the Shift+C → manual branch — `c` is now mode-agnostic and
the in-modal switch covers the same intent without users having to
remember a second shortcut.

Visible labels: "Quick create" → "Create with agent",
"New issue" → "Create manually".
2026-04-29 14:57:36 +08:00

43 lines
1.7 KiB
TypeScript

"use client";
import { useModalStore } from "@multica/core/modals";
import { CreateWorkspaceModal } from "./create-workspace";
import { CreateIssueDialog } from "./create-issue-dialog";
import { CreateProjectModal } from "./create-project";
import { FeedbackModal } from "./feedback";
import { SetParentIssueModal } from "./set-parent-issue";
import { AddChildIssueModal } from "./add-child-issue";
import { DeleteIssueConfirmModal } from "./delete-issue-confirm";
import { BacklogAgentHintModal } from "./backlog-agent-hint";
export function ModalRegistry() {
const modal = useModalStore((s) => s.modal);
const data = useModalStore((s) => s.data);
const close = useModalStore((s) => s.close);
switch (modal) {
case "create-workspace":
return <CreateWorkspaceModal onClose={close} />;
// Both modal types open the same shell so the in-modal mode switch is
// instant — only the inner panel swaps, the Dialog Root stays mounted.
case "create-issue":
return <CreateIssueDialog onClose={close} initialMode="manual" data={data} />;
case "quick-create-issue":
return <CreateIssueDialog onClose={close} initialMode="agent" data={data} />;
case "create-project":
return <CreateProjectModal onClose={close} />;
case "feedback":
return <FeedbackModal onClose={close} />;
case "issue-set-parent":
return <SetParentIssueModal onClose={close} data={data} />;
case "issue-add-child":
return <AddChildIssueModal onClose={close} data={data} />;
case "issue-delete-confirm":
return <DeleteIssueConfirmModal onClose={close} data={data} />;
case "issue-backlog-agent-hint":
return <BacklogAgentHintModal onClose={close} data={data} />;
default:
return null;
}
}