diff --git a/ui/src/components/IssuesList.test.tsx b/ui/src/components/IssuesList.test.tsx index 604596d4161..ff67d6f6335 100644 --- a/ui/src/components/IssuesList.test.tsx +++ b/ui/src/components/IssuesList.test.tsx @@ -1624,6 +1624,32 @@ describe("IssuesList", () => { }); }); + it.each([[true, true], [false, true], [true, false], [false, false]])("passes saved Project visibility (%s) and project metadata to the board (streamlined=%s)", async (showProjects, streamlined) => { + mockInstanceSettingsApi.getExperimental.mockResolvedValue({ enableStreamlinedUi: streamlined }); + localStorage.setItem( + taskCollectionPreferencesStorageKey({ companyId: "company-1", collectionKey: "paperclip:test-issues" }), + JSON.stringify({ + version: 1, + companyId: "company-1", + collectionKey: "paperclip:test-issues", + viewState: { viewMode: "board" }, + columns: showProjects ? ["project"] : [], + }), + ); + const project = { id: "project-1", name: "Commerce platform", color: "royalblue" }; + const { root } = renderWithQueryClient( + undefined} />, + container, + ); + await waitForAssertion(() => { + expect(mockKanbanBoard).toHaveBeenLastCalledWith(expect.objectContaining({ + showProjects, + projectById: new Map([[project.id, { name: project.name, color: project.color }]]), + })); + }); + act(() => root.unmount()); + }); + it("uses compact cards and collapsed cold lanes for high-volume boards", async () => { localStorage.setItem( "paperclip:test-issues:company-1", diff --git a/ui/src/components/IssuesList.tsx b/ui/src/components/IssuesList.tsx index 48c6881f6ab..e567544443b 100644 --- a/ui/src/components/IssuesList.tsx +++ b/ui/src/components/IssuesList.tsx @@ -2130,6 +2130,8 @@ function StreamlinedIssuesList({ ({ start: undefined as ((event: DragStartEvent) => void) | undefined })); + +vi.mock("@dnd-kit/core", async (importOriginal) => { + const actual = await importOriginal(); + return { + ...actual, + DndContext: (props: React.ComponentProps) => { + dragState.start = props.onDragStart; + return ; + }, + DragOverlay: ({ children }: { children: React.ReactNode }) =>
{children}
, + }; +}); + vi.mock("@/lib/router", () => ({ Link: ({ children, @@ -26,6 +41,10 @@ vi.mock("@/lib/router", () => ({ const mountedRoots: Root[] = []; +const projectById = new Map([ + ["project-1", { name: "Commerce platform", color: "royalblue" }], +]); + function act(callback: () => void): void { flushSync(callback); } @@ -242,6 +261,54 @@ describe("KanbanBoard", () => { render({ issues: [applyOptimisticIssueFieldUpdate(issue, { status: "done" })!] }); expect(column()?.textContent).toContain("Done"); }); + + it.each([[false, false], [false, true], [true, false], [true, true]])( + "shows project badges with compactCards=%s and overflow fades=%s", + (compactCards, showOverflowFades) => { + const issue = { ...createIssue(1, "todo"), projectId: "project-1" }; + const { container, render } = renderBoard({ issues: [issue], projectById, showProjects: true, compactCards, showOverflowFades }); + + const badge = container.querySelector('[title="Commerce platform"]'); + expect(badge?.textContent).toBe("Commerce platform"); + expect(badge?.querySelector('[aria-hidden="true"]')?.style.backgroundColor).toBe("royalblue"); + expect(container.querySelector('a[href="/issues/PAP-1"]')?.contains(badge)).toBe(true); + + render({ issues: [issue], projectById, showProjects: false, compactCards, showOverflowFades }); + expect(container.textContent).not.toContain("Commerce platform"); + }, + ); + + it("omits badges for unset or unknown projects and when visibility is not enabled", () => { + const issues = [createIssue(1, "todo"), { ...createIssue(2, "todo"), projectId: "unknown" }]; + const { container, render } = renderBoard({ issues, projectById, showProjects: true }); + expect(container.querySelector('[data-slot="badge"][title]')).toBeNull(); + + render({ issues: [{ ...createIssue(1, "todo"), projectId: "project-1" }], projectById }); + expect(container.textContent).not.toContain("Commerce platform"); + }); + + it("keeps long project names readable without expanding the card", () => { + const name = "A project name long enough to overflow the fixed-width board card"; + const { container } = renderBoard({ + issues: [{ ...createIssue(1, "todo"), projectId: "project-1" }], + projectById: new Map([["project-1", { name, color: null }]]), + showProjects: true, + }); + const badge = container.querySelector(`[title="${name}"]`); + expect(badge?.className).toContain("max-w-full"); + expect(badge?.querySelector(".truncate")?.textContent).toBe(name); + expect(badge?.querySelector('[aria-hidden="true"]')?.style.backgroundColor).toBe("var(--muted-foreground)"); + }); + + it("keeps project visibility in sync in the drag preview", () => { + const issue = { ...createIssue(1, "todo"), projectId: "project-1" }; + const { container, render } = renderBoard({ issues: [issue], projectById, showProjects: true }); + act(() => dragState.start?.({ active: { id: issue.id } } as DragStartEvent)); + expect(container.querySelector('[data-testid="drag-preview"]')?.textContent).toContain("Commerce platform"); + + render({ issues: [issue], projectById, showProjects: false }); + expect(container.querySelector('[data-testid="drag-preview"]')?.textContent).not.toContain("Commerce platform"); + }); }); diff --git a/ui/src/components/KanbanBoard.tsx b/ui/src/components/KanbanBoard.tsx index 1407ad679ac..306a16f87c0 100644 --- a/ui/src/components/KanbanBoard.tsx +++ b/ui/src/components/KanbanBoard.tsx @@ -22,13 +22,14 @@ import { StatusIcon } from "./StatusIcon"; import { PriorityIcon } from "./PriorityIcon"; import { SHOW_TASK_PRIORITY_UI } from "../lib/ui-flags"; import { Identity } from "./Identity"; -import type { Issue, IssueDisplayStatus, IssueStatus } from "@paperclipai/shared"; +import type { Issue, IssueDisplayStatus, IssueStatus, Project } from "@paperclipai/shared"; import { AlertTriangle } from "lucide-react"; import { isSuccessfulRunHandoffRequired } from "../lib/successful-run-handoff"; import { collectSubtreeLiveCounts } from "../lib/liveIssueIds"; import { cn } from "../lib/utils"; import { Card } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; +import { brandChipBadge } from "@/lib/status-colors"; import { HorizontalScrollViewport } from "./HorizontalScrollViewport"; export const KANBAN_BOARD_HIGH_VOLUME_THRESHOLD = 100; @@ -153,6 +154,8 @@ interface Agent { interface KanbanBoardProps { issues: Issue[]; agents?: Agent[]; + projectById?: ReadonlyMap>; + showProjects?: boolean; liveIssueIds?: Set; compactCards?: boolean; collapsedStatuses?: string[]; @@ -169,6 +172,7 @@ function KanbanColumn({ status, issues, agents, + projectById, liveIssueIds, subtreeLiveCounts, compactCards = false, @@ -180,6 +184,7 @@ function KanbanColumn({ status: IssueDisplayStatus; issues: Issue[]; agents?: Agent[]; + projectById?: KanbanBoardProps["projectById"]; liveIssueIds?: Set; subtreeLiveCounts?: ReadonlyMap; compactCards?: boolean; @@ -246,6 +251,7 @@ function KanbanColumn({ key={issue.id} issue={issue} agents={agents} + project={issue.projectId ? projectById?.get(issue.projectId) : undefined} isLive={liveIssueIds?.has(issue.id)} subtreeLiveCount={subtreeLiveCounts?.get(issue.id) ?? 0} compact={compactCards} @@ -277,6 +283,7 @@ function KanbanColumn({ function KanbanCard({ issue, agents, + project, isLive, subtreeLiveCount = 0, isOverlay, @@ -285,6 +292,7 @@ function KanbanCard({ }: { issue: Issue; agents?: Agent[]; + project?: Pick; isLive?: boolean; subtreeLiveCount?: number; isOverlay?: boolean; @@ -382,6 +390,16 @@ function KanbanCard({ ); })()} + {project ? ( + + + ) : null} ); @@ -392,6 +410,8 @@ function KanbanCard({ export function KanbanBoard({ issues, agents, + projectById, + showProjects = false, liveIssueIds, compactCards = false, collapsedStatuses = [], @@ -467,6 +487,7 @@ export function KanbanBoard({ {columns}} {activeIssue ? ( - + ) : null} diff --git a/ui/src/components/LegacyIssuesList.tsx b/ui/src/components/LegacyIssuesList.tsx index 91751bdb049..5715cae4951 100644 --- a/ui/src/components/LegacyIssuesList.tsx +++ b/ui/src/components/LegacyIssuesList.tsx @@ -1985,6 +1985,8 @@ export function IssuesList({ undefined, + }, + argTypes: { + projectById: { control: false }, + onUpdateIssue: { control: false }, + }, +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +export const ProjectEnabled: Story = {}; +export const CompactCards: Story = { args: { compactCards: true } }; +export const ProjectDisabled: Story = { args: { showProjects: false } };