fix(ui): honor Project visibility on Kanban cards

The task collection reads the saved Project column setting for list
rows, but the board received neither the setting nor the project
metadata. Pass both to the board from the streamlined and legacy
collections.

A card shows a token-styled badge with the project color, a truncated
name and the full name in its title. Regular cards, compact cards and
the drag preview use the same setting. Tasks without a known project
show no badge.

Co-Authored-By: Codex <codex@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandCodex committed 2026-11-11 20:26:05 +02:00
1 parent 14cb69245f
commit ed056871a8
6 files changed
+174 -2

No files matched your search

+26
View File
@@ -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(
<IssuesList issues={[]} projects={[project]} viewStateKey="paperclip:test-issues" onUpdateIssue={() => 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",
+2
View File
@@ -2130,6 +2130,8 @@ function StreamlinedIssuesList({
<KanbanBoard
issues={filtered}
agents={agents}
projectById={projectById}
showProjects={visibleIssueColumnSet.has("project")}
liveIssueIds={liveIssueIds}
compactCards={boardCompactCards}
collapsedStatuses={boardCollapsedStatuses}
+67
View File
@@ -3,10 +3,25 @@
import { createRoot, type Root } from "react-dom/client";
import { flushSync } from "react-dom";
import type { Issue, IssueStatus } from "@paperclipai/shared";
import type { DragStartEvent } from "@dnd-kit/core";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { getKanbanColumnTone, KanbanBoard, resolveKanbanTargetStatus } from "./KanbanBoard";
import { applyOptimisticIssueFieldUpdate } from "../lib/optimistic-issue-comments";
const dragState = vi.hoisted(() => ({ start: undefined as ((event: DragStartEvent) => void) | undefined }));
vi.mock("@dnd-kit/core", async (importOriginal) => {
const actual = await importOriginal<typeof import("@dnd-kit/core")>();
return {
...actual,
DndContext: (props: React.ComponentProps<typeof actual.DndContext>) => {
dragState.start = props.onDragStart;
return <actual.DndContext {...props} />;
},
DragOverlay: ({ children }: { children: React.ReactNode }) => <div data-testid="drag-preview">{children}</div>,
};
});
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<HTMLElement>('[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<HTMLElement>('[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");
});
});
+29 -2
View File
@@ -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<string, Pick<Project, "name" | "color">>;
showProjects?: boolean;
liveIssueIds?: Set<string>;
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<string>;
subtreeLiveCounts?: ReadonlyMap<string, number>;
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<Project, "name" | "color">;
isLive?: boolean;
subtreeLiveCount?: number;
isOverlay?: boolean;
@@ -382,6 +390,16 @@ function KanbanCard({
);
})()}
</div>
{project ? (
<Badge variant="outline" className={cn(brandChipBadge.gray, "mt-2 max-w-full min-w-0")} title={project.name}>
<span
aria-hidden="true"
className="h-1.5 w-1.5 shrink-0 rounded-full"
style={{ backgroundColor: project.color ?? "var(--muted-foreground)" }}
/>
<span className="truncate">{project.name}</span>
</Badge>
) : null}
</Link>
</Card>
);
@@ -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({
<KanbanColumn
key={status}
status={status}
projectById={showProjects ? projectById : undefined}
issues={columnIssues[status] ?? []}
agents={agents}
liveIssueIds={liveIssueIds}
@@ -497,7 +518,13 @@ export function KanbanBoard({
: <div className="flex gap-3 overflow-x-auto pb-4 -mx-2 px-2">{columns}</div>}
<DragOverlay>
{activeIssue ? (
<KanbanCard issue={activeIssue} agents={agents} isOverlay compact={compactCards} />
<KanbanCard
issue={activeIssue}
agents={agents}
project={showProjects && activeIssue.projectId ? projectById?.get(activeIssue.projectId) : undefined}
isOverlay
compact={compactCards}
/>
) : null}
</DragOverlay>
</DndContext>
+2
View File
@@ -1985,6 +1985,8 @@ export function IssuesList({
<KanbanBoard
issues={filtered}
agents={agents}
projectById={projectById}
showProjects={visibleIssueColumnSet.has("project")}
liveIssueIds={liveIssueIds}
compactCards={boardCompactCards}
collapsedStatuses={boardCollapsedStatuses}
@@ -0,0 +1,48 @@
import type { Meta, StoryObj } from "@storybook/react-vite";
import { KanbanBoard } from "@/components/KanbanBoard";
import { storybookIssues, storybookProjects } from "../../fixtures/paperclipData";
const project = storybookProjects[0]!;
const longProject = {
name: "A project with a long name that must stay inside the board card",
color: null,
};
const meta = {
id: "product-kanban-projects",
title: "Tasks and conversations/Task creation and lifecycle/Product/Kanban projects",
component: KanbanBoard,
parameters: {
paperclip: {
capabilities: ["tasks/organize"],
implementation: "production",
boundary: "fixtures",
notes: "Project badges enabled and disabled, compact cards, long neutral project names, and tasks without projects. This fixture does not prove live collection persistence or API access.",
},
},
args: {
issues: [
{ ...storybookIssues[0]!, id: "board-project", status: "todo", projectId: project.id },
{ ...storybookIssues[1]!, id: "board-long-project", status: "todo", projectId: "long-project" },
{ ...storybookIssues[2]!, id: "board-no-project", status: "todo", projectId: null },
],
projectById: new Map([
[project.id, { name: project.name, color: project.color }],
["long-project", longProject],
]),
showProjects: true,
collapsedStatuses: ["backlog", "done", "cancelled"],
onUpdateIssue: () => undefined,
},
argTypes: {
projectById: { control: false },
onUpdateIssue: { control: false },
},
} satisfies Meta<typeof KanbanBoard>;
export default meta;
type Story = StoryObj<typeof meta>;
export const ProjectEnabled: Story = {};
export const CompactCards: Story = { args: { compactCards: true } };
export const ProjectDisabled: Story = { args: { showProjects: false } };