Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-8121 feat(issues): offer Default workflow statuses for issues outside a project (#9389)
Multica Eve37d360063475
diff --git a/packages/core/issue-workflows/hooks.ts b/packages/core/issue-workflows/hooks.tsindex 144a5ec229..7cbfad0665 100644--- a/packages/core/issue-workflows/hooks.ts+++ b/packages/core/issue-workflows/hooks.ts@@ -2,7 +2,7 @@ import { useQuery } from "@tanstack/react-query";import { useMemo } from "react";import { projectListOptions } from "../projects/queries";import type { IssueWorkflow, Project } from "../types";-import { issueWorkflowListOptions, resolveProjectWorkflow } from "./queries";+import { defaultWorkflow, issueWorkflowListOptions, resolveProjectWorkflow } from "./queries";const EMPTY: IssueWorkflow[] = [];@@ -16,11 +16,15 @@ export function useIssueWorkflows(wsId: string): { workflows: IssueWorkflow[]; i* A project and the workflow it uses. `workflow` is null for the Default* workflow — including while either list is still loading, which renders the* Default behavior rather than an empty board.+ *+ * `defaultWorkflow` is the workspace Default itself, null until loaded or on a+ * server without workflows. An issue outside any project offers its statuses.+ * (MUL-8121)*/export function useProjectWithWorkflow(wsId: string,projectId: string | null | undefined,-): { project: Project | null; workflow: IssueWorkflow | null } {+): { project: Project | null; workflow: IssueWorkflow | null; defaultWorkflow: IssueWorkflow | null } {const { workflows } = useIssueWorkflows(wsId);const { data: projects } = useQuery({...projectListOptions(wsId),@@ -28,7 +32,11 @@ export function useProjectWithWorkflow(});return useMemo(() => {const project = projectId ? projects?.find((p) => p.id === projectId) ?? null : null;- return { project, workflow: resolveProjectWorkflow(workflows, project) };+ return {+ project,+ workflow: resolveProjectWorkflow(workflows, project),+ defaultWorkflow: defaultWorkflow(workflows),+ };}, [projectId, projects, workflows]);}diff --git a/packages/views/issues/actions/issue-actions-menu-items.tsx b/packages/views/issues/actions/issue-actions-menu-items.tsxindex a1a390d1f8..a9ec3d220c 100644--- a/packages/views/issues/actions/issue-actions-menu-items.tsx+++ b/packages/views/issues/actions/issue-actions-menu-items.tsx@@ -113,7 +113,7 @@ export function IssueActionsMenuItems({const wsId = useWorkspaceId();// Only the statuses the issue's workflow allows; entering a step that hands// the issue off confirms first, as in the status picker. (MUL-7420)- const { options: statusOptions, workflow } = useIssueStatusOptions(wsId, issue.project_id);+ const { options: statusOptions, workflow } = useIssueStatusOptions(wsId, issue.project_id, issue.status);const openModal = useModalStore((s) => s.open);const setStatus = (status: string) => {if (workflow && status !== issue.status && stepHandsOff(workflowStep(workflow, status))) {diff --git a/packages/views/issues/components/batch-action-toolbar.tsx b/packages/views/issues/components/batch-action-toolbar.tsxindex 1423a7acf3..40c68da9ba 100644--- a/packages/views/issues/components/batch-action-toolbar.tsx+++ b/packages/views/issues/components/batch-action-toolbar.tsx@@ -243,7 +243,9 @@ export function BatchActionToolbar({{/* Status */}<StatusPickerstatus={common.status}- projectId={sharedProjectId}+ // No shared project spans projects (or none): not the Default-only+ // list of a single issue outside a project. (MUL-8121)+ projectId={sharedProjectId ?? undefined}allowedStatuses={allowedStatuses}onUpdate={handleBatchStatus}open={statusOpen}diff --git a/packages/views/issues/components/issue-property-pills.tsx b/packages/views/issues/components/issue-property-pills.tsxindex 3a960bfe4a..c013cc4b56 100644--- a/packages/views/issues/components/issue-property-pills.tsx+++ b/packages/views/issues/components/issue-property-pills.tsx@@ -36,6 +36,8 @@ export function IssuePropertyPills({<div className="flex flex-wrap items-center gap-1.5"><StatusPickerstatus={issue.status}+ projectId={issue.project_id}+ issue={issue}onUpdate={onUpdate}triggerRender={<PillButton />}align="start"diff --git a/packages/views/issues/components/pickers/status-picker.test.tsx b/packages/views/issues/components/pickers/status-picker.test.tsxindex dbcc1cd090..6e95d00f55 100644--- a/packages/views/issues/components/pickers/status-picker.test.tsx+++ b/packages/views/issues/components/pickers/status-picker.test.tsx@@ -24,10 +24,11 @@ vi.mock("@multica/core/issue-statuses/hooks", () => ({// Project workflows (MUL-7420): the picker resolves the issue's project and its// workflow through one hook, fed directly here like the catalog.let projectWorkflow: IssueWorkflow | null = null;+let workspaceDefault: IssueWorkflow | null = null;vi.mock("@multica/core/issue-workflows", async (importOriginal) => ({...(await importOriginal<typeof import("@multica/core/issue-workflows")>()),- useProjectWithWorkflow: () => ({ project: null, workflow: projectWorkflow }),+ useProjectWithWorkflow: () => ({ project: null, workflow: projectWorkflow, defaultWorkflow: workspaceDefault }),}));vi.mock("../../../common/actor-avatar", () => ({@@ -89,6 +90,7 @@ afterEach(() => {cleanup();catalogEntries = undefined;projectWorkflow = null;+ workspaceDefault = null;});describe("StatusPicker trigger color", () => {@@ -227,3 +229,84 @@ describe("StatusPicker in a project that uses a workflow", () => {expect(screen.queryByText(/Hands off to/)).toBeNull();});});++describe("StatusPicker on an issue outside any project (MUL-8121)", () => {+ const TODO = entry({ id: "todo", key: "todo", name: "Todo", category: "unstarted", is_system: true, position: 0 });+ const DONE = entry({ id: "done", key: "done", name: "Done", category: "done", is_system: true, position: 0 });+ const MERGED = entry({ id: "merged", key: "merged", name: "Merged", position: 2 });++ const DEFAULT: IssueWorkflow = {+ id: "wf-default",+ workspace_id: "workspace-1",+ name: "Default",+ description: "",+ is_default: true,+ steps: [+ { status_key: "todo", handler: { type: "none" }, instructions: "" },+ // A handoff on Default never fires outside a project, so it is not hinted.+ { status_key: "in_review", handler: { type: "agent", id: "agent-1" }, instructions: "" },+ { status_key: "done", handler: { type: "none" }, instructions: "" },+ ],+ project_ids: [],+ created_at: "",+ updated_at: "",+ };++ function rows(): (string | undefined)[] {+ return Array.from(document.querySelectorAll("button[data-picker-item]")).map((el) => el.textContent?.trim());+ }++ it("offers only the Default workflow's statuses, headed as such, without handoff hints", () => {+ catalogEntries = [TODO, IN_REVIEW, QA, MERGED, DONE];+ workspaceDefault = DEFAULT;+ renderWithI18n(+ <StatusPicker status="todo" projectId={null} onUpdate={() => {}} open onOpenChange={() => {}} />,+ );+ expect(rows()).toEqual(["Todo", "In Review", "Done"]);+ expect(screen.getByText("Default statuses · no project")).toBeTruthy();+ expect(screen.queryByText(/Hands off to/)).toBeNull();+ });++ it("keeps a current status Default leaves out, checked, in its category's place", () => {+ catalogEntries = [TODO, IN_REVIEW, QA, MERGED, DONE];+ workspaceDefault = DEFAULT;+ renderWithI18n(+ <StatusPicker status="merged" projectId={null} onUpdate={() => {}} open onOpenChange={() => {}} />,+ );+ expect(rows()).toEqual(["Todo", "In Review", "Merged", "Done"]);+ // The check mark is the last svg in a row; it is hidden on the others.+ const checkOf = (label: string) => Array.from(optionRow(label).querySelectorAll("svg")).at(-1);+ expect(checkOf("Merged")?.getAttribute("class")).not.toContain("invisible");+ expect(checkOf("Todo")?.getAttribute("class")).toContain("invisible");+ });++ it("still reaches every status through search", () => {+ catalogEntries = [TODO, IN_REVIEW, QA, MERGED, DONE];+ workspaceDefault = DEFAULT;+ const onUpdate = vi.fn();+ renderWithI18n(+ <StatusPicker status="todo" projectId={null} onUpdate={onUpdate} open onOpenChange={() => {}} />,+ );+ fireEvent.change(screen.getByPlaceholderText("Search status..."), { target: { value: "merg" } });+ expect(rows()).toEqual(["Merged"]);+ fireEvent.click(optionRow("Merged"));+ expect(onUpdate).toHaveBeenCalledWith({ status: "merged" });+ });++ it("offers the whole catalog when the surface spans projects", () => {+ catalogEntries = [TODO, IN_REVIEW, QA, MERGED, DONE];+ workspaceDefault = DEFAULT;+ renderWithI18n(<StatusPicker status="todo" onUpdate={() => {}} open onOpenChange={() => {}} />);+ // Cancelled is the built-in stand-in for a category the fixture omits.+ expect(rows()).toEqual(["Todo", "In Review", "QA", "Merged", "Done", "Cancelled"]);+ });++ it("offers the whole catalog while Default is unknown", () => {+ catalogEntries = [TODO, IN_REVIEW, QA, MERGED, DONE];+ renderWithI18n(+ <StatusPicker status="todo" projectId={null} onUpdate={() => {}} open onOpenChange={() => {}} />,+ );+ // Cancelled is the built-in stand-in for a category the fixture omits.+ expect(rows()).toEqual(["Todo", "In Review", "QA", "Merged", "Done", "Cancelled"]);+ });+});diff --git a/packages/views/issues/components/pickers/status-picker.tsx b/packages/views/issues/components/pickers/status-picker.tsxindex 9d4b759658..80c1b0123c 100644--- a/packages/views/issues/components/pickers/status-picker.tsx+++ b/packages/views/issues/components/pickers/status-picker.tsx@@ -58,7 +58,9 @@ export function StatusPicker({/*** The issue's project. When it uses a workflow, only that workflow's steps* are offered, in workflow order, each naming who entering it hands the- * issue to. Omit when the surface spans projects. (MUL-7420)+ * issue to. (MUL-7420) `null` is an issue outside any project: it offers+ * the Default workflow's statuses, and search still reaches every status.+ * (MUL-8121) Omit (`undefined`) when the surface spans projects.*/projectId?: string | null;/**@@ -87,7 +89,13 @@ export function StatusPicker({// The project workflow's steps, or the catalog in canonical category order// without archived statuses (MUL-6243).- const { options: projectOptions, workflow, project } = useIssueStatusOptions(wsId, projectId);+ const {+ options: projectOptions,+ workflow,+ project,+ defaultScope,+ catalog,+ } = useIssueStatusOptions(wsId, projectId, status);const allOptions = useMemo(() => (allowedStatuses ? projectOptions.filter((o) => allowedStatuses.has(o.key)) : projectOptions),[projectOptions, allowedStatuses],@@ -96,10 +104,13 @@ export function StatusPicker({const options = useMemo(() => {const q = query.trim().toLowerCase();if (!q) return allOptions;- return allOptions.filter((o) => o.label.toLowerCase().includes(q));- }, [allOptions, query]);+ // Outside a project only the list is narrowed to Default, not what the+ // issue may take: search reaches every status. (MUL-8121)+ const pool = defaultScope ? catalog : allOptions;+ return pool.filter((o) => o.label.toLowerCase().includes(q));+ }, [allOptions, catalog, defaultScope, query]);- const searchable = !!workflow || allOptions.length > SEARCH_THRESHOLD;+ const searchable = !!workflow || !!defaultScope || allOptions.length > SEARCH_THRESHOLD;const [pendingStatus, setPendingStatus] = useState<IssueStatus | null>(null);const markDuplicate = onMarkDuplicate ? (@@ -131,7 +142,7 @@ export function StatusPicker({if (!v) setQuery("");setOpen(v);}}- width={workflow ? "w-60" : "w-52"}+ width={workflow || defaultScope ? "w-60" : "w-52"}align={align}triggerRender={triggerRender}searchable={searchable}@@ -144,6 +155,10 @@ export function StatusPicker({? t(($) => $.workflows.picker.header, { workflow: workflow.name, project: project.title }): workflow.name}</div>+ ) : defaultScope ? (+ <div className="truncate px-2 pb-1 pt-1.5 text-caption text-muted-foreground">+ {t(($) => $.workflows.picker.header_no_project, { workflow: defaultScope.name })}+ </div>) : undefined}footer={markDuplicate ?? undefined}diff --git a/packages/views/issues/utils/status-options.ts b/packages/views/issues/utils/status-options.tsindex a14086f952..753a7f2b0b 100644--- a/packages/views/issues/utils/status-options.ts+++ b/packages/views/issues/utils/status-options.ts@@ -85,33 +85,64 @@ export function useStatusOptions();}+const CATEGORY_RANK = new Map<IssueStatusCategory, number>(ALL_STATUSES.map((c, i) => [c, i]));+/*** The statuses an issue in `projectId` may take: its project workflow's steps* in workflow order, or the whole catalog when the project has none. Every* single-issue status control offers this set, so a status the workflow* refuses is never on offer. (MUL-7420)+ *+ * `projectId` is three-valued:+ * - a project id: that project's workflow;+ * - `null`: an issue outside any project. It offers the workspace Default+ * workflow's statuses, as a project on Default does, so statuses another+ * project's workflow added stay out of its list. Default has no handoffs+ * here — the server applies none outside a project — so `workflow` stays+ * null and `defaultScope` names the Default instead. The server still+ * accepts any status, so `catalog` keeps the full set reachable by search,+ * and `currentStatus` stays listed even when Default leaves it out.+ * (MUL-8121)+ * - `undefined`: a surface spanning projects; the whole catalog.*/export function useIssueStatusOptions(wsId: string,projectId: string | null | undefined,-): { options: StatusOption[]; workflow: IssueWorkflow | null; project: Project | null } {+ currentStatus?: IssueStatus | null,+): {+ options: StatusOption[];+ workflow: IssueWorkflow | null;+ project: Project | null;+ defaultScope: IssueWorkflow | null;+ catalog: StatusOption[];+} {const catalogOptions = useStatusOptions(wsId);const { categoryOf, colorOf, iconOf } = useIssueStatuses(wsId);const labelOf = useStatusLabel(wsId);- const { workflow, project } = useProjectWithWorkflow(wsId, projectId);+ const { workflow, project, defaultWorkflow } = useProjectWithWorkflow(wsId, projectId);+ const defaultScope = projectId === null && !workflow ? defaultWorkflow ?? null : null;const options = useMemo<StatusOption[]>(() => {- if (!workflow) return catalogOptions;+ const listed = workflow ?? defaultScope;+ if (!listed) return catalogOptions;const byKey = new Map(catalogOptions.map((o) => [o.key, o]));- return workflow.steps.map(- (step) =>- byKey.get(step.status_key) ?? {- key: step.status_key,- category: categoryOf(step.status_key),- label: labelOf(step.status_key),- color: colorOf(step.status_key),- icon: iconOf(step.status_key),- },- );- }, [catalogOptions, categoryOf, colorOf, iconOf, labelOf, workflow]);- return { options, workflow, project };+ const optionOf = (key: IssueStatus): StatusOption =>+ byKey.get(key) ?? {+ key,+ category: categoryOf(key),+ label: labelOf(key),+ color: colorOf(key),+ icon: iconOf(key),+ };+ const steps = listed.steps.map((step) => optionOf(step.status_key));+ if (!defaultScope || !currentStatus || steps.some((o) => o.key === currentStatus)) return steps;+ // The current status is outside Default (e.g. the issue left a project+ // whose workflow added it): keep it visible and checked, after the last+ // step of its category, so it can still be seen and moved off.+ const current = optionOf(currentStatus);+ const rank = CATEGORY_RANK.get(current.category) ?? ALL_STATUSES.length;+ let at = steps.length;+ while (at > 0 && (CATEGORY_RANK.get(steps[at - 1]!.category) ?? 0) > rank) at -= 1;+ return [...steps.slice(0, at), current, ...steps.slice(at)];+ }, [catalogOptions, categoryOf, colorOf, currentStatus, defaultScope, iconOf, labelOf, workflow]);+ return { options, workflow, project, defaultScope, catalog: catalogOptions };}diff --git a/packages/views/locales/en/issues.json b/packages/views/locales/en/issues.jsonindex 82678362e6..654918e040 100644--- a/packages/views/locales/en/issues.json+++ b/packages/views/locales/en/issues.json@@ -1633,6 +1633,7 @@},"picker": {"header": "{{workflow}} · from project “{{project}}”",+ "header_no_project": "{{workflow}} statuses · no project","footer": "Only this issue’s workflow statuses are shown. The right side is who entering the status hands it to."},"confirm": {diff --git a/packages/views/locales/fr/issues.json b/packages/views/locales/fr/issues.jsonindex d78c872f78..d3cafc3fb3 100644--- a/packages/views/locales/fr/issues.json+++ b/packages/views/locales/fr/issues.json@@ -1633,6 +1633,7 @@},"picker": {"header": "{{workflow}} · selon le projet « {{project}} »",+ "header_no_project": "Statuts {{workflow}} · sans projet","footer": "Seuls les états du workflow de cette tâche sont affichés. À droite : à qui elle est confiée en entrant dans l’état."},"confirm": {diff --git a/packages/views/locales/ja/issues.json b/packages/views/locales/ja/issues.jsonindex 7809876e46..ff957a0519 100644--- a/packages/views/locales/ja/issues.json+++ b/packages/views/locales/ja/issues.json@@ -1570,6 +1570,7 @@},"picker": {"header": "{{workflow}} · プロジェクト「{{project}}」に従う",+ "header_no_project": "{{workflow}} のステータス · プロジェクトなし","footer": "このタスクのワークフローのステータスだけを表示しています。右側はそのステータスに入ったときの引き継ぎ先です。"},"confirm": {diff --git a/packages/views/locales/ko/issues.json b/packages/views/locales/ko/issues.jsonindex 12ca619b1b..b0efd72351 100644--- a/packages/views/locales/ko/issues.json+++ b/packages/views/locales/ko/issues.json@@ -1570,6 +1570,7 @@},"picker": {"header": "{{workflow}} · 프로젝트 “{{project}}” 기준",+ "header_no_project": "{{workflow}} 상태 · 프로젝트 없음","footer": "이 태스크 워크플로의 상태만 표시합니다. 오른쪽은 해당 상태에 들어갈 때의 처리자입니다."},"confirm": {diff --git a/packages/views/locales/zh-Hans/issues.json b/packages/views/locales/zh-Hans/issues.jsonindex d0f36f71f2..406ba88da5 100644--- a/packages/views/locales/zh-Hans/issues.json+++ b/packages/views/locales/zh-Hans/issues.json@@ -1570,6 +1570,7 @@},"picker": {"header": "{{workflow}} · 跟随项目「{{project}}」",+ "header_no_project": "{{workflow}} 状态 · 无项目","footer": "只显示这个任务所在工作流里的状态。右侧是进入该状态时的处理人。"},"confirm": {