Skip to content

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

Go

feat(issues): reopen the create-issue dialog at the size it was last left at (#10554)

小妍儿 ✨107e30394f27
diff --git a/packages/core/issues/stores/create-mode-store.test.ts b/packages/core/issues/stores/create-mode-store.test.ts
index cf892fd969..4daad36d4b 100644
--- a/packages/core/issues/stores/create-mode-store.test.ts
+++ b/packages/core/issues/stores/create-mode-store.test.ts
@@ -42,3 +42,20 @@ describe("openCreateIssueWithPreference", () => {
expect(useModalStore.getState().data).toEqual({ project_id: "p2" });
});
});
+
+describe("useCreateModeStore expanded", () => {
+ afterEach(() => {
+ useCreateModeStore.getState().setExpanded(false);
+ });
+
+ it("defaults to the compact dialog", () => {
+ expect(useCreateModeStore.getState().expanded).toBe(false);
+ });
+
+ it("remembers the last dialog size", () => {
+ useCreateModeStore.getState().setExpanded(true);
+ expect(useCreateModeStore.getState().expanded).toBe(true);
+ useCreateModeStore.getState().setExpanded(false);
+ expect(useCreateModeStore.getState().expanded).toBe(false);
+ });
+});
diff --git a/packages/core/issues/stores/create-mode-store.ts b/packages/core/issues/stores/create-mode-store.ts
index 9d14b0088c..9b73cfd24f 100644
--- a/packages/core/issues/stores/create-mode-store.ts
+++ b/packages/core/issues/stores/create-mode-store.ts
@@ -15,12 +15,19 @@ import { useModalStore } from "../../modals";
* file an issue" doesn't change per workspace, so this lives in plain
* localStorage rather than the workspace-aware StateStorage that scopes
* per-workspace stores like quick-create-store / draft-store.
+ *
+ * `expanded` is the dialog size the user last left it at (the ⤢ button), so
+ * someone who writes long descriptions or pastes screenshots doesn't have to
+ * expand the dialog again on every open. Same scope as the mode: it's how this
+ * person likes to write, not a property of the workspace.
*/
export type CreateMode = "agent" | "manual";
interface CreateModeState {
lastMode: CreateMode;
setLastMode: (mode: CreateMode) => void;
+ expanded: boolean;
+ setExpanded: (expanded: boolean) => void;
}
export const useCreateModeStore = create<CreateModeState>()(
@@ -28,6 +35,8 @@ export const useCreateModeStore = create<CreateModeState>()(
(set) => ({
lastMode: "agent",
setLastMode: (mode) => set({ lastMode: mode }),
+ expanded: false,
+ setExpanded: (expanded) => set({ expanded }),
}),
{
name: "multica_create_mode",
diff --git a/packages/views/modals/create-issue-dialog.test.tsx b/packages/views/modals/create-issue-dialog.test.tsx
index 4ed8d90f41..f54dc8cb68 100644
--- a/packages/views/modals/create-issue-dialog.test.tsx
+++ b/packages/views/modals/create-issue-dialog.test.tsx
@@ -37,9 +37,12 @@ vi.mock("@multica/core/issues/stores/draft-store", () => ({
},
}));
+const mockSetExpanded = vi.hoisted(() => vi.fn());
const mockCreateModeStore = {
lastMode: "agent" as "agent" | "manual",
setLastMode: mockSetLastMode,
+ expanded: false,
+ setExpanded: mockSetExpanded,
};
vi.mock("@multica/core/issues/stores/create-mode-store", () => ({
@@ -92,11 +95,18 @@ vi.mock("./create-issue", () => ({
ManualCreatePanel: ({
data,
onSwitchMode,
+ isExpanded,
+ setIsExpanded,
}: {
data?: Record<string, unknown> | null;
onSwitchMode?: (carry?: Record<string, unknown> | null) => void;
+ isExpanded?: boolean;
+ setIsExpanded?: (v: boolean) => void;
}) => (
<div>
+ <button type="button" onClick={() => setIsExpanded?.(!isExpanded)}>
+ toggle size
+ </button>
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 })}>
@@ -110,7 +120,8 @@ vi.mock("./create-issue", () => ({
</button>
</div>
),
- manualDialogContentClass: () => "manual-dialog-class",
+ manualDialogContentClass: (isExpanded: boolean) =>
+ `manual-dialog-class ${isExpanded ? "manual-expanded" : "manual-compact"}`,
}));
// `cn` is deliberately NOT mocked here: the whole point of these assertions is
@@ -125,6 +136,24 @@ function contentClass() {
describe("CreateIssueDialog sizing", () => {
beforeEach(() => {
vi.clearAllMocks();
+ mockCreateModeStore.expanded = false;
+ });
+
+ it("opens at the size the dialog was last left at", () => {
+ mockCreateModeStore.expanded = true;
+ render(<CreateIssueDialog onClose={vi.fn()} initialMode="manual" />);
+ expect(contentClass()).toContain("manual-expanded");
+
+ fireEvent.click(screen.getByRole("button", { name: "toggle size" }));
+ expect(mockSetExpanded).toHaveBeenCalledWith(false);
+ });
+
+ it("opens compact when the dialog was last left compact", () => {
+ render(<CreateIssueDialog onClose={vi.fn()} initialMode="manual" />);
+ expect(contentClass()).toContain("manual-compact");
+
+ fireEvent.click(screen.getByRole("button", { name: "toggle size" }));
+ expect(mockSetExpanded).toHaveBeenCalledWith(true);
});
it("leaves ordinary create outside the isolated source-context path", () => {
diff --git a/packages/views/modals/create-issue-dialog.tsx b/packages/views/modals/create-issue-dialog.tsx
index e9c22add32..0c5c08bcf0 100644
--- a/packages/views/modals/create-issue-dialog.tsx
+++ b/packages/views/modals/create-issue-dialog.tsx
@@ -30,9 +30,10 @@ import { useWorkspaceId } from "@multica/core/hooks";
* `onSwitchMode`; the shell stores it as the next panel's `data` so seeding
* works exactly like a fresh open.
*
- * Manual-mode `isExpanded` is lifted up because it drives `DialogContent`'s
- * className — the className lives here in the shell since the Popup is here,
- * but the toggle for that state lives in the manual panel body.
+ * `isExpanded` is lifted up because it drives `DialogContent`'s className —
+ * the className lives here in the shell since the Popup is here, but the
+ * toggle for that state lives in the panel bodies. It is persisted in the
+ * create-mode store, so the dialog reopens at the size it was last left at.
*/
export function CreateIssueDialog({
onClose,
@@ -122,7 +123,9 @@ function CreateIssueDialogBody({
const [mode, setMode] = useState<CreateMode>(initialMode);
const [manualOpened, setManualOpened] = useState(initialMode === "manual");
const [panelData, setPanelData] = useState(data ?? null);
- const [isExpanded, setIsExpanded] = useState(false);
+ // Remembered across opens: the dialog reopens at the size it was left at.
+ const isExpanded = useCreateModeStore((s) => s.expanded);
+ const setIsExpanded = useCreateModeStore((s) => s.setExpanded);
const effectiveData = {
...(panelData ?? {}),
...sourceContextData,