Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-8119 fix(views): keep workflow name visible in project sidebar (#9387)
Multica Evea69021482fde
diff --git a/packages/views/workflows/project-workflow-row.test.tsx b/packages/views/workflows/project-workflow-row.test.tsxnew file mode 100644index 0000000000..c884bce286--- /dev/null+++ b/packages/views/workflows/project-workflow-row.test.tsx@@ -0,0 +1,49 @@+import { cleanup, screen } from "@testing-library/react";+import { afterEach, describe, expect, it, vi } from "vitest";+import type { IssueWorkflow, Project } from "@multica/core/types";+import { renderWithI18n } from "../test/i18n";+import { ProjectWorkflowControl } from "./project-workflow-row";++const releaseWorkflow = {+ id: "wf-release",+ workspace_id: "workspace-1",+ name: "版本发布",+ description: "",+ is_default: false,+ steps: [],+ project_ids: ["project-1"],+ created_at: "",+ updated_at: "",+} as IssueWorkflow;++vi.mock("@tanstack/react-query", () => ({ useQuery: () => ({ data: [] }) }));+vi.mock("@multica/core/api", () => ({ api: {}, clientErrorMessage: () => null }));+vi.mock("@multica/core/config", () => ({ useFeatureEnabled: () => true }));+vi.mock("@multica/core/hooks", () => ({ useWorkspaceId: () => "workspace-1" }));+vi.mock("@multica/core/paths", () => ({ useWorkspacePaths: () => ({ settings: () => "/settings" }) }));+vi.mock("@multica/core/projects/queries", () => ({ projectListOptions: () => ({}) }));+vi.mock("@multica/core/issue-workflows", () => ({+ useIssueWorkflows: () => ({ workflows: [releaseWorkflow] }),+ resolveProjectWorkflow: () => releaseWorkflow,+ handoffStepCount: () => 3,+ useSetProjectWorkflow: () => ({ isPending: false, mutateAsync: vi.fn() }),+}));+vi.mock("../navigation", () => ({ useNavigation: () => ({ push: vi.fn() }) }));+vi.mock("./permissions", () => ({ useWorkflowPermissions: () => ({ canManageProject: true }) }));+vi.mock("./workflow-mapping-dialog", () => ({ WorkflowMappingDialog: () => null }));++afterEach(cleanup);++const project = { id: "project-1", title: "Multica 线上发布", workflow_id: "wf-release" } as Project;++describe("ProjectWorkflowControl", () => {+ // MUL-8119: in the narrow project sidebar the handoff count used to keep its+ // width and squeeze the workflow name down to a single glyph.+ it("gives the whole row to the workflow name and moves the handoff count to the title", () => {+ renderWithI18n(<ProjectWorkflowControl project={project} />);++ const trigger = screen.getByRole("button", { name: /版本发布/ });+ expect(trigger.getAttribute("title")).toBe("版本发布 · 3 handoff steps");+ expect(trigger.textContent).toBe("版本发布");+ });+});diff --git a/packages/views/workflows/project-workflow-row.tsx b/packages/views/workflows/project-workflow-row.tsxindex 02ffa4d07e..0a943f9df6 100644--- a/packages/views/workflows/project-workflow-row.tsx+++ b/packages/views/workflows/project-workflow-row.tsx@@ -140,6 +140,8 @@ export function WorkflowChoiceItems({</span><span className="mt-0.5 block text-caption text-muted-foreground">{t(($) => $.workflows.settings.statuses, { count: workflow.steps.length })}+ {handoffStepCount(workflow) > 0 &&+ ` · ${t(($) => $.workflows.settings.handoffs, { count: handoffStepCount(workflow) })}`}</span><span className="block truncate text-caption text-muted-foreground">{usedBy@@ -173,10 +175,11 @@ export function ProjectWorkflowControl({ project }: { project: Project }) {if (!enabled && !project.workflow_id) return null;const name = current?.name ?? t(($) => $.workflows.default_name);const handoffs = current ? handoffStepCount(current) : 0;+ const handoffLabel = handoffs > 0 ? t(($) => $.workflows.settings.handoffs, { count: handoffs }) : null;if (!canManageProject) {return (- <span className="-ml-1 inline-flex min-w-0 items-center gap-1.5 px-1 py-0.5 text-caption">+ <span title={name} className="-ml-1 inline-flex min-w-0 items-center gap-1.5 px-1 py-0.5 text-caption"><Workflow aria-hidden className="size-3.5 shrink-0 text-muted-foreground" /><span className="truncate font-medium">{name}</span></span>@@ -191,15 +194,15 @@ export function ProjectWorkflowControl({ project }: { project: Project }) {render={<buttontype="button"- className="-ml-1 inline-flex min-w-0 items-center gap-1.5 rounded-md px-1 py-0.5 text-caption transition-colors hover:bg-accent data-popup-open:bg-accent"+ title={handoffLabel ? `${name} · ${handoffLabel}` : name}+ className="-ml-1 inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-md px-1 py-0.5 text-caption transition-colors hover:bg-accent data-popup-open:bg-accent"><Workflow aria-hidden className="size-3.5 shrink-0 text-muted-foreground" />- <span className="truncate font-medium">{name}</span>- {handoffs > 0 && (- <span className="shrink-0 text-muted-foreground">- · {t(($) => $.workflows.settings.handoffs, { count: handoffs })}- </span>- )}+ {/* Only the name competes for the narrow sidebar row (MUL-8119):+ a sibling summary, however it is weighted, still takes width+ from the name. The handoff count lives in the title and the+ picker items instead. */}+ <span className="min-w-0 truncate font-medium">{name}</span><ChevronDown aria-hidden className="size-3 shrink-0 text-muted-foreground" /></button>}