-
+
);
@@ -28,14 +32,14 @@ function KanbanCardPreviewLayout({
export function KanbanCardPreview({ task }: { task: Task }) {
const repositoriesByWorkspace = useAppStore((state) => state.repositories.itemsByWorkspaceId);
- const repositoryNames = useMemo(
+ const repositoryChips = useMemo(
() =>
- resolveTaskRepositoryNames(
+ resolveTaskRepositoryChips(
task,
Object.values(repositoriesByWorkspace).flat() as Repository[],
),
[repositoriesByWorkspace, task],
);
- return ;
+ return ;
}
diff --git a/apps/web/components/kanban-card.test.ts b/apps/web/components/kanban-card.test.ts
new file mode 100644
index 0000000000..8619814ef9
--- /dev/null
+++ b/apps/web/components/kanban-card.test.ts
@@ -0,0 +1,115 @@
+import { describe, expect, it } from "vitest";
+import { resolveTaskRepositoryChips, type Task } from "./kanban-card";
+import { repositoryId, workspaceId, type Repository } from "@/lib/types/http";
+
+function repo(overrides: Partial): Repository {
+ return {
+ id: repositoryId("repo-1"),
+ workspace_id: workspaceId("workspace-1"),
+ name: "",
+ source_type: "github",
+ local_path: "/home/carlos/.kandev/repos/NBCUDTC/olisipo-jenkins-job-dsl",
+ provider: "github",
+ provider_repo_id: "123",
+ provider_owner: "NBCUDTC",
+ provider_name: "olisipo-jenkins-job-dsl",
+ default_branch: "main",
+ scripts: [],
+ worktree_branch_prefix: "",
+ pull_before_worktree: false,
+ setup_script: "",
+ cleanup_script: "",
+ dev_script: "",
+ copy_files: "",
+ created_at: "",
+ updated_at: "",
+ ...overrides,
+ };
+}
+
+function task(overrides: Partial): Task {
+ return {
+ id: "task-1",
+ title: "Review Pull Request",
+ workflowStepId: "step-1",
+ repositoryId: "repo-1",
+ repositories: [],
+ ...overrides,
+ };
+}
+
+describe("resolveTaskRepositoryChips", () => {
+ it("uses the provider owner/name slug instead of the local clone path", () => {
+ expect(resolveTaskRepositoryChips(task({}), [repo({})])).toEqual([
+ {
+ label: "NBCUDTC/olisipo-jenkins-job-dsl",
+ path: "~/.kandev/repos/NBCUDTC/olisipo-jenkins-job-dsl",
+ },
+ ]);
+ });
+
+ it("falls back to the configured repository name for local repos", () => {
+ expect(
+ resolveTaskRepositoryChips(task({}), [
+ repo({
+ name: "olisipo-jenkins-job-dsl",
+ source_type: "local",
+ provider: "",
+ provider_repo_id: "",
+ provider_owner: "",
+ provider_name: "",
+ }),
+ ]),
+ ).toEqual([
+ {
+ label: "olisipo-jenkins-job-dsl",
+ path: "~/.kandev/repos/NBCUDTC/olisipo-jenkins-job-dsl",
+ },
+ ]);
+ });
+
+ it("keeps multiple repositories in task order", () => {
+ expect(
+ resolveTaskRepositoryChips(
+ task({
+ repositoryId: "repo-1",
+ repositories: [
+ { id: "link-2", repository_id: "repo-2", position: 2 },
+ { id: "link-1", repository_id: "repo-1", position: 1 },
+ ],
+ }),
+ [
+ repo({}),
+ repo({
+ id: repositoryId("repo-2"),
+ local_path: "/home/carlos/src/api",
+ provider_owner: "NBCUDTC",
+ provider_name: "api",
+ }),
+ ],
+ ),
+ ).toEqual([
+ {
+ label: "NBCUDTC/olisipo-jenkins-job-dsl",
+ path: "~/.kandev/repos/NBCUDTC/olisipo-jenkins-job-dsl",
+ },
+ { label: "NBCUDTC/api", path: "~/src/api" },
+ ]);
+ });
+
+ it("renders no repo chips for repo-less local-folder tasks", () => {
+ expect(
+ resolveTaskRepositoryChips(
+ task({
+ repositoryId: undefined,
+ repositories: [],
+ }),
+ [repo({})],
+ ),
+ ).toEqual([]);
+ });
+
+ it("renders no repo chips when the task has no repository information", () => {
+ expect(resolveTaskRepositoryChips(task({ repositoryId: undefined }), [])).toEqual([]);
+ });
+});
diff --git a/apps/web/components/kanban-card.tsx b/apps/web/components/kanban-card.tsx
index 999861d6b9..d6d8d419f7 100644
--- a/apps/web/components/kanban-card.tsx
+++ b/apps/web/components/kanban-card.tsx
@@ -14,7 +14,8 @@ import { TaskDeleteConfirmDialog } from "@/components/task/task-delete-confirm-d
import { TaskGitHubIssueDialog } from "@/components/task/task-github-issue-dialog";
import { TaskGitHubPRDialog } from "@/components/task/task-github-pr-dialog";
import { useTaskWorkflowMove } from "@/hooks/use-task-workflow-move";
-import { getRepositoryDisplayName } from "@/lib/utils";
+import { repositorySlug } from "@/lib/repository-slug";
+import { formatUserHomePath } from "@/lib/utils";
import { repositoryId as toRepositoryId, type Repository, type TaskState } from "@/lib/types/http";
export interface Task {
@@ -47,6 +48,11 @@ export interface Task {
issueNumber?: number;
}
+export type RepositoryChip = {
+ label: string;
+ path?: string;
+};
+
export interface WorkflowStep {
id: string;
title: string;
@@ -61,8 +67,8 @@ export interface WorkflowStep {
interface KanbanCardProps {
task: Task;
- /** Display names of every repository linked to the task, primary first. */
- repositoryNames?: string[];
+ /** Display labels and hover paths of every repository linked to the task, primary first. */
+ repositoryChips?: RepositoryChip[];
onClick?: (task: Task) => void;
onEdit?: (task: Task) => void;
onDelete?: (task: Task, opts?: { cascade?: boolean }) => void;
@@ -254,7 +260,7 @@ function useActiveWorkspaceRepositories() {
export function KanbanCard({
task,
- repositoryNames,
+ repositoryChips,
onClick,
onEdit,
onDelete,
@@ -318,7 +324,7 @@ export function KanbanCard({
[repo.id, repo]));
const seen = new Set();
- const names: string[] = [];
+ const chips: RepositoryChip[] = [];
const push = (id: string | undefined) => {
if (!id || seen.has(id)) return;
const repo = byId.get(toRepositoryId(id));
if (!repo) return;
seen.add(id);
- const display = getRepositoryDisplayName(repo.local_path);
- if (display) names.push(display);
+ const label = repositorySlug(repo);
+ if (!label) return;
+ chips.push({
+ label,
+ ...(repo.local_path ? { path: formatUserHomePath(repo.local_path) } : {}),
+ });
};
push(task.repositoryId);
const ordered = [...(task.repositories ?? [])].sort((a, b) => a.position - b.position);
for (const link of ordered) push(link.repository_id);
- return names;
+ return chips;
+}
+
+export function resolveTaskRepositoryNames(task: Task, repositories: Repository[]): string[] {
+ return resolveTaskRepositoryChips(task, repositories).map((chip) => chip.label);
}
diff --git a/apps/web/components/kanban-column.tsx b/apps/web/components/kanban-column.tsx
index 96e203e87c..a6bff312f0 100644
--- a/apps/web/components/kanban-column.tsx
+++ b/apps/web/components/kanban-column.tsx
@@ -2,7 +2,7 @@
import { useMemo } from "react";
import { useDroppable } from "@dnd-kit/core";
-import { KanbanCard, resolveTaskRepositoryNames, Task } from "./kanban-card";
+import { KanbanCard, resolveTaskRepositoryChips, Task } from "./kanban-card";
import { Badge } from "@kandev/ui/badge";
import { cn } from "@/lib/utils";
import { useAppStore } from "@/components/state-provider";
@@ -95,7 +95,7 @@ export function KanbanColumn({