⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.
TypeScript honoissue-managementissue-trackerjira-alternativekanbanlinear-alternativemcpproject-managementreactself-hostedtypescript
feat: clickable task PR list, task link matching, and reopen completed tasks for new work (#1864)
Andrejdf58e85204af
diff --git a/AGENTS.md b/AGENTS.mdindex c0c46b8a6..4b6df9b93 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -9,6 +9,7 @@ Treat this guide as a set of defaults. The developer's request takes precedence.## What matters- Keep routine work simple. Solve the user's problem with the smallest model that makes the behavior clear. Read the relevant code first, but do not keep complexity just because it is already there.+- Keep modules small. Across the whole repo, give each file one responsibility: one component per file, and pure helpers and types in their own modules next to the code that uses them, with tests beside them. When a file grows a second concern, split it into a folder. Do not extract one-line wrappers; inline those.- Keep boards fast. Task-heavy views and realtime updates should not move or render more data than they need.- Keep self-hosting easy. A single instance must work without Redis or another managed service. Support both bundled same-origin and separately hosted API and web deployments.- Respect workspace boundaries. The API enforces authentication and permissions; a hidden UI control is not an authorization check. Never leak secrets or private workspace data through responses, logs, events, WebSockets, or MCP.diff --git a/apps/api/src/gitlab-integration/controllers/import-gitlab-issues.ts b/apps/api/src/gitlab-integration/controllers/import-gitlab-issues.tsindex afcef8dfb..55deb9420 100644--- a/apps/api/src/gitlab-integration/controllers/import-gitlab-issues.ts+++ b/apps/api/src/gitlab-integration/controllers/import-gitlab-issues.ts@@ -13,13 +13,12 @@ import {createExternalLink,findExternalLink,} from "../../plugins/github/services/link-manager";-import { findTaskByNumber } from "../../plugins/github/services/task-service";import {extractIssuePriority,extractIssueStatus,} from "../../plugins/github/utils/extract-priority";import type { GitlabConfig } from "../../plugins/gitlab/config";-import { extractTaskNumberGitlab } from "../../plugins/gitlab/utils/branch-matcher";+import { resolveMergeRequestTask } from "../../plugins/gitlab/services/resolve-merge-request-task";import {createGitlabClient,type GitlabIssue,@@ -366,19 +365,12 @@ async function linkMergeRequestToTask(return;}- const taskNumber = extractTaskNumberGitlab(- branchName,- mergeRequest.title,- mergeRequest.description ?? undefined,- config,+ const task = await resolveMergeRequestTask({+ projectId,projectSlug,- );-- if (!taskNumber) {- return;- }-- const task = await findTaskByNumber(projectId, taskNumber);+ config,+ mergeRequest: { ...mergeRequest, source_branch: branchName },+ });if (!task) {return;diff --git a/apps/api/src/plugins/gitea/webhooks/pull-request-opened.ts b/apps/api/src/plugins/gitea/webhooks/pull-request-opened.tsindex ff28c1a56..8cd4bf129 100644--- a/apps/api/src/plugins/gitea/webhooks/pull-request-opened.ts+++ b/apps/api/src/plugins/gitea/webhooks/pull-request-opened.ts@@ -4,10 +4,7 @@ import {findExternalLink,} from "../../github/services/link-manager";import { resolvePullRequestTask } from "../../github/services/resolve-pull-request-task";-import {- isTaskInFinalState,- updateTaskStatus,-} from "../../github/services/task-service";+import { updateTaskStatus } from "../../github/services/task-service";import type { GiteaConfig } from "../config";import {findAllIntegrationsByGiteaRepo,@@ -117,9 +114,7 @@ export async function handleGiteaPullRequestOpened(config.statusTransitions?.onPROpen || "in-review",);- const isTaskFinal = await isTaskInFinalState(task);-- if (task.status !== targetStatus && !isTaskFinal) {+ if (task.status !== targetStatus) {const statusResult = await updateTaskStatus(task.id, targetStatus);if (statusResult.applied &&diff --git a/apps/api/src/plugins/gitea/webhooks/push.ts b/apps/api/src/plugins/gitea/webhooks/push.tsindex 781a2c72f..ede741dba 100644--- a/apps/api/src/plugins/gitea/webhooks/push.ts+++ b/apps/api/src/plugins/gitea/webhooks/push.ts@@ -15,6 +15,7 @@ import { resolveTargetStatus } from "../utils/resolve-column";import { baseUrlFromRepositoryHtmlUrl } from "../utils/webhook-repo";type PushPayload = {+ after?: string;ref: string;head_commit?: {id: string;@@ -49,6 +50,10 @@ export async function handleGiteaPush() {const { ref, repository } = payload;+ if (/^0+$/.test(payload.after ?? "")) {+ return;+ }+if (!ref.startsWith("refs/heads/")) {console.log(`[Gitea Push] Skipping non-branch ref: ${ref}`);return;@@ -116,7 +121,7 @@ export async function handleGiteaPush(const treeUrl = `${repository.html_url}/src/branch/${branchName}`;- await createOrUpdateExternalLink({+ const branchLink = await createOrUpdateExternalLink({taskId: task.id,integrationId: integration.id,resourceType: "branch",@@ -142,9 +147,9 @@ export async function handleGiteaPush(config.statusTransitions?.onBranchPush || "in-progress",);- const isTaskFinal = await isTaskInFinalState(task);+ const canMove = branchLink.created || !(await isTaskInFinalState(task));- if (task.status !== targetStatus && !isTaskFinal) {+ if (task.status !== targetStatus && canMove) {const statusResult = await updateTaskStatus(task.id, targetStatus);if (statusResult.applied &&diff --git a/apps/api/src/plugins/github/services/resolve-pull-request-task.ts b/apps/api/src/plugins/github/services/resolve-pull-request-task.tsindex bcf55e46e..0637d8f1f 100644--- a/apps/api/src/plugins/github/services/resolve-pull-request-task.ts+++ b/apps/api/src/plugins/github/services/resolve-pull-request-task.ts@@ -4,6 +4,7 @@ import { externalLinkTable, taskTable } from "../../../database/schema";import type { GitHubConfig } from "../config";import { extractTaskNumber } from "../utils/branch-matcher";import { extractIssueReferences } from "../utils/issue-references";+import { findTaskByLink } from "./task-service";export async function resolvePullRequestTask({integrationId,@@ -34,35 +35,45 @@ export async function resolvePullRequestTask({config,projectSlug,);- if (taskNumber !== null) {- return database.query.taskTable.findFirst({- where: and(- eq(taskTable.projectId, projectId),- eq(taskTable.number, taskNumber),- ),- });- }+ const numberedTask =+ taskNumber === null+ ? undefined+ : await database.query.taskTable.findFirst({+ where: and(+ eq(taskTable.projectId, projectId),+ eq(taskTable.number, taskNumber),+ ),+ });+ if (numberedTask) return numberedTask;const issueNumbers = extractIssueReferences(pullRequest.title,pullRequest.body,repositoryUrl,);- if (issueNumbers.length === 0) return;-- const matches = await database- .selectDistinct({ task: taskTable })- .from(externalLinkTable)- .innerJoin(taskTable, eq(taskTable.id, externalLinkTable.taskId))- .where(- and(- eq(externalLinkTable.integrationId, integrationId),- eq(externalLinkTable.resourceType, "issue"),- inArray(externalLinkTable.externalId, issueNumbers),- eq(taskTable.projectId, projectId),- ),- )- .limit(2);+ const matches =+ issueNumbers.length === 0+ ? []+ : await database+ .selectDistinct({ task: taskTable })+ .from(externalLinkTable)+ .innerJoin(taskTable, eq(taskTable.id, externalLinkTable.taskId))+ .where(+ and(+ eq(externalLinkTable.integrationId, integrationId),+ eq(externalLinkTable.resourceType, "issue"),+ inArray(externalLinkTable.externalId, issueNumbers),+ eq(taskTable.projectId, projectId),+ ),+ )+ .limit(2);+ if (matches.length > 0) {+ return matches.length === 1 ? matches[0]?.task : undefined;+ }- return matches.length === 1 ? matches[0]?.task : undefined;+ return findTaskByLink(+ projectId,+ [pullRequest.title, pullRequest.body],+ database,+ );}diff --git a/apps/api/src/plugins/github/services/task-service.ts b/apps/api/src/plugins/github/services/task-service.tsindex ac0a2d591..7d49daa2c 100644--- a/apps/api/src/plugins/github/services/task-service.ts+++ b/apps/api/src/plugins/github/services/task-service.ts@@ -7,6 +7,7 @@ import {taskTable,} from "../../../database/schema";import { type GitHubConfig, hasVerifiedGitHubBinding } from "../config";+import { extractTaskLinks } from "../utils/task-references";export type TaskRow = InferSelectModel<typeof taskTable>;@@ -25,6 +26,23 @@ export async function findTaskByNumber(projectId: string, taskNumber: number) {});}+export async function findTaskByLink(+ projectId: string,+ texts: (string | null | undefined)[],+ database: Pick<typeof db, "query"> = db,+) {+ const links = extractTaskLinks(...texts);+ const link = links.length === 1 ? links[0] : undefined;+ if (link?.projectId !== projectId) return;++ return database.query.taskTable.findFirst({+ where: and(+ eq(taskTable.projectId, projectId),+ eq(taskTable.id, link.taskId),+ ),+ });+}+export async function findTaskById(taskId: string) {return db.query.taskTable.findFirst({where: eq(taskTable.id, taskId),diff --git a/apps/api/src/plugins/github/utils/task-references.ts b/apps/api/src/plugins/github/utils/task-references.tsnew file mode 100644index 000000000..49f8b12ae--- /dev/null+++ b/apps/api/src/plugins/github/utils/task-references.ts@@ -0,0 +1,14 @@+const taskLinkPattern =+ /\/dashboard\/workspace\/[\w-]+\/project\/([\w-]+)\/task\/([\w-]+)(?![\w-])/g;++export function extractTaskLinks(...texts: (string | null | undefined)[]) {+ const links = new Map<string, { projectId: string; taskId: string }>();+ for (const text of texts) {+ for (const [, projectId, taskId] of (text ?? "").matchAll(+ taskLinkPattern,+ )) {+ if (projectId && taskId) links.set(taskId, { projectId, taskId });+ }+ }+ return [...links.values()];+}diff --git a/apps/api/src/plugins/github/webhooks/issue-reopened.ts b/apps/api/src/plugins/github/webhooks/issue-reopened.tsindex e2fb54779..ffc08b920 100644--- a/apps/api/src/plugins/github/webhooks/issue-reopened.ts+++ b/apps/api/src/plugins/github/webhooks/issue-reopened.ts@@ -58,7 +58,10 @@ export async function handleIssueReopened(payload: IssueReopenedPayload) {source: "issue_reopened",});- if (existingMetadata.createdFrom === "kaneo") {+ if (+ existingMetadata.createdFrom === "kaneo" ||+ existingMetadata.state === "open"+ ) {continue;}diff --git a/apps/api/src/plugins/github/webhooks/pull-request-opened.ts b/apps/api/src/plugins/github/webhooks/pull-request-opened.tsindex 5534e164f..71f2506b3 100644--- a/apps/api/src/plugins/github/webhooks/pull-request-opened.ts+++ b/apps/api/src/plugins/github/webhooks/pull-request-opened.ts@@ -4,7 +4,6 @@ import { createExternalLink, findExternalLink } from "../services/link-manager";import { resolvePullRequestTask } from "../services/resolve-pull-request-task";import {findAllIntegrationsByRepo,- isTaskInFinalState,updateTaskStatus,} from "../services/task-service";import { resolveTargetStatus } from "../utils/resolve-column";@@ -89,9 +88,7 @@ export async function handlePullRequestOpened(payload: PROpenedPayload) {config.statusTransitions?.onPROpen || "in-review",);- const isTaskFinal = await isTaskInFinalState(task);-- if (task.status !== targetStatus && !isTaskFinal) {+ if (task.status !== targetStatus) {const statusResult = await updateTaskStatus(task.id, targetStatus);if (statusResult.applied &&diff --git a/apps/api/src/plugins/github/webhooks/push.ts b/apps/api/src/plugins/github/webhooks/push.tsindex f3e41d3b1..6d6333a15 100644--- a/apps/api/src/plugins/github/webhooks/push.ts+++ b/apps/api/src/plugins/github/webhooks/push.ts@@ -11,6 +11,7 @@ import { extractTaskNumberFromBranch } from "../utils/branch-matcher";import { resolveTargetStatus } from "../utils/resolve-column";type PushPayload = {+ after?: string;ref: string;head_commit?: {id: string;@@ -38,7 +39,15 @@ const PROTECTED_BRANCHES = [export async function handlePush(payload: PushPayload) {const { ref, repository, head_commit } = payload;- const branchName = ref.replace("refs/heads/", "");+ if (/^0+$/.test(payload.after ?? "")) {+ return;+ }++ if (!ref.startsWith("refs/heads/")) {+ return;+ }++ const branchName = ref.slice("refs/heads/".length);console.log(`[Push] Processing branch: ${branchName}`);if (PROTECTED_BRANCHES.includes(branchName)) {@@ -100,7 +109,7 @@ export async function handlePush(payload: PushPayload) {`[Push] Found task: ${task.id}, current status: ${task.status}`,);- await createOrUpdateExternalLink({+ const branchLink = await createOrUpdateExternalLink({taskId: task.id,integrationId: integration.id,resourceType: "branch",@@ -128,9 +137,9 @@ export async function handlePush(payload: PushPayload) {`[Push] Target status: ${targetStatus}, current: ${task.status}`,);- const isTaskFinal = await isTaskInFinalState(task);+ const canMove = branchLink.created || !(await isTaskInFinalState(task));- if (task.status !== targetStatus && !isTaskFinal) {+ if (task.status !== targetStatus && canMove) {console.log(`[Push] Updating task ${task.id} status from ${task.status} to ${targetStatus}`,);diff --git a/apps/api/src/plugins/gitlab/services/resolve-merge-request-task.ts b/apps/api/src/plugins/gitlab/services/resolve-merge-request-task.tsnew file mode 100644index 000000000..caae838ff--- /dev/null+++ b/apps/api/src/plugins/gitlab/services/resolve-merge-request-task.ts@@ -0,0 +1,38 @@+import {+ findTaskByLink,+ findTaskByNumber,+} from "../../github/services/task-service";+import type { GitlabConfig } from "../config";+import { extractTaskNumberGitlab } from "../utils/branch-matcher";++export async function resolveMergeRequestTask({+ projectId,+ projectSlug,+ config,+ mergeRequest,+}: {+ projectId: string;+ projectSlug: string;+ config: GitlabConfig;+ mergeRequest: {+ title: string;+ description: string | null;+ source_branch: string;+ };+}) {+ const taskNumber = extractTaskNumberGitlab(+ mergeRequest.source_branch,+ mergeRequest.title,+ mergeRequest.description ?? undefined,+ config,+ projectSlug,+ );+ const numberedTask = taskNumber+ ? await findTaskByNumber(projectId, taskNumber)+ : undefined;++ return (+ numberedTask ??+ findTaskByLink(projectId, [mergeRequest.title, mergeRequest.description])+ );+}diff --git a/apps/api/src/plugins/gitlab/webhooks/merge-request-opened.ts b/apps/api/src/plugins/gitlab/webhooks/merge-request-opened.tsindex 417de6019..135d28b58 100644--- a/apps/api/src/plugins/gitlab/webhooks/merge-request-opened.ts+++ b/apps/api/src/plugins/gitlab/webhooks/merge-request-opened.ts@@ -5,13 +5,14 @@ import {updateExternalLink,} from "../../github/services/link-manager";import {- findTaskByNumber,+ findTaskById,isTaskInFinalState,updateTaskStatus,} from "../../github/services/task-service";+import { parseLinkMetadata } from "../../github/utils/parse-link-metadata";import type { GitlabConfig } from "../config";import { findAllIntegrationsByGitlabProject } from "../services/integration-lookup";-import { extractTaskNumberGitlab } from "../utils/branch-matcher";+import { resolveMergeRequestTask } from "../services/resolve-merge-request-task";import type { GitlabWebhookProject, GitlabWebhookUser } from "../utils/payload";import { resolveTargetStatus } from "../utils/resolve-column";import { baseUrlFromProjectWebUrl } from "../utils/webhook-project";@@ -72,30 +73,31 @@ export async function handleGitlabMergeRequestOpened(continue;}- const taskNumber = extractTaskNumberGitlab(- branchName,- mergeRequest.title,- mergeRequest.description ?? undefined,- config,- integration.project.slug,+ const existingLink = await findExternalLink(+ integration.id,+ "pull_request",+ mergeRequest.iid.toString(),);- if (!taskNumber) {+ const linkedTask =+ existingLink && (await findTaskById(existingLink.taskId));+ if (existingLink && linkedTask?.projectId !== integration.projectId) {continue;}- const task = await findTaskByNumber(integration.projectId, taskNumber);+ const task =+ linkedTask ||+ (await resolveMergeRequestTask({+ projectId: integration.projectId,+ projectSlug: integration.project.slug,+ config,+ mergeRequest: { ...mergeRequest, source_branch: branchName },+ }));if (!task) {continue;}- const existingLink = await findExternalLink(- integration.id,- "pull_request",- mergeRequest.iid.toString(),- );-const metadata = {state: mergeRequest.state,draft: mergeRequest.draft === true,@@ -133,9 +135,15 @@ export async function handleGitlabMergeRequestOpened(config.statusTransitions?.onPROpen || "in-review",);- const isTaskFinal = await isTaskInFinalState(task);+ const wasDraft =+ parseLinkMetadata<{ draft: boolean }>(existingLink?.metadata, {+ externalLinkId: existingLink?.id ?? "",+ source: "gitlab-merge-request-opened",+ }).draft === true;+ const canMove =+ !existingLink || wasDraft || !(await isTaskInFinalState(task));- if (task.status !== targetStatus && !isTaskFinal) {+ if (task.status !== targetStatus && canMove) {const statusResult = await updateTaskStatus(task.id, targetStatus);if (statusResult.applied &&diff --git a/apps/api/src/plugins/gitlab/webhooks/push.ts b/apps/api/src/plugins/gitlab/webhooks/push.tsindex 2111233e7..6388f352d 100644--- a/apps/api/src/plugins/gitlab/webhooks/push.ts+++ b/apps/api/src/plugins/gitlab/webhooks/push.ts@@ -13,6 +13,7 @@ import { resolveTargetStatus } from "../utils/resolve-column";import { baseUrlFromProjectWebUrl } from "../utils/webhook-project";type PushPayload = {+ after?: string;ref: string;commits?: Array<{id: string;@@ -42,6 +43,10 @@ export async function handleGitlabPush() {const { ref, project } = payload;+ if (/^0+$/.test(payload.after ?? "")) {+ return;+ }+if (!ref.startsWith("refs/heads/")) {console.log(`[GitLab Push] Skipping non-branch ref: ${ref}`);return;@@ -107,7 +112,7 @@ export async function handleGitlabPush(continue;}- await createOrUpdateExternalLink({+ const branchLink = await createOrUpdateExternalLink({taskId: task.id,integrationId: integration.id,resourceType: "branch",@@ -132,9 +137,9 @@ export async function handleGitlabPush(config.statusTransitions?.onBranchPush || "in-progress",);- const isTaskFinal = await isTaskInFinalState(task);+ const canMove = branchLink.created || !(await isTaskInFinalState(task));- if (task.status !== targetStatus && !isTaskFinal) {+ if (task.status !== targetStatus && canMove) {const statusResult = await updateTaskStatus(task.id, targetStatus);if (statusResult.applied &&diff --git a/apps/docs/core/integrations/github/configuration.mdx b/apps/docs/core/integrations/github/configuration.mdxindex a525e2e1d..a7b52566a 100644--- a/apps/docs/core/integrations/github/configuration.mdx+++ b/apps/docs/core/integrations/github/configuration.mdx@@ -126,6 +126,8 @@ Kaneo checks the configured branch pattern first, then explicit task referencesIssue references use the remote repository's numbering. A title containing `#61` or a body containing `Closes #61` resolves through the issue link recorded by this integration. If GitHub issue 61 is linked to Kaneo task `PROJ-42`, the PR belongs to `PROJ-42`, even if `PROJ-61` also exists. Same-repository `owner/repo#61` references and issue URLs are also supported. References to another repository are ignored.+If none of those match, Kaneo looks for a task link in the PR title or body. Paste the link from **Copy task link** on the task, and the PR is linked to that task. A PR that links to more than one task, or to a task in another project, is not linked.+Without an explicit task reference, unmapped issues do not create PR associations. References that map to multiple tasks within the integration are skipped. Repeated issue links to the same task are accepted. Bare numeric title shortcuts such as `[42]`, `(42)`, or `42: ...` are not task identifiers; use the project key instead.GitHub webhooks also skip conflicting candidates or an existing PR association across projects connected to the repository. Signed Gitea webhooks resolve only within their authenticated integration; another project's mappings or PR links do not block that integration. Direct Gitea handler calls without an integration ID use the repository-wide checks. Imports for both providers remain scoped to the selected project.@@ -145,7 +147,7 @@ Customize when tasks automatically change status:Configure these in your project's GitHub integration settings to match your workflow.<Warning>-Status transitions only apply if the task is not already in "done" status. This prevents accidentally reopening completed tasks.+A completed task moves again only when new work starts on it: the first push to a branch that is not yet linked to the task, or a pull request that is not yet linked to it. More pushes to a linked branch, or reopening a pull request, leave a completed task where it is.</Warning>### Label Synchronizationdiff --git a/apps/docs/core/integrations/github/troubleshooting.mdx b/apps/docs/core/integrations/github/troubleshooting.mdxindex 59450ebad..59f3ddf2e 100644--- a/apps/docs/core/integrations/github/troubleshooting.mdx+++ b/apps/docs/core/integrations/github/troubleshooting.mdx@@ -55,7 +55,7 @@ Then check:1. The app can read pull requests and repository contents.2. Push and pull-request events are subscribed and arriving.3. **Workflow → Automation Rules** maps the event to the intended column.-4. The task is eligible for the transition. Completed tasks are protected from automatic reopening by the integration.+4. The task is eligible for the transition. A completed task only moves for new work: a branch or pull request that is not yet linked to it.Try one branch push and inspect its webhook delivery before testing another event.diff --git a/apps/web/src/components/kanban-board/task-card.tsx b/apps/web/src/components/kanban-board/task-card.tsxindex 745b04fb4..2ec92801d 100644--- a/apps/web/src/components/kanban-board/task-card.tsx+++ b/apps/web/src/components/kanban-board/task-card.tsx@@ -6,13 +6,12 @@ import {Calendar,CalendarClock,CalendarX,- GitMerge,- GitPullRequest,SlidersHorizontal,} from "lucide-react";import { type CSSProperties, useMemo, useState } from "react";import { useTranslation } from "react-i18next";import { TaskProgressBadges } from "@/components/task/task-progress-badges";+import { TaskPullRequests } from "@/components/task/task-pull-requests";import {AlertDialog,AlertDialogClose,@@ -39,7 +38,6 @@ import {getDueDateStatus,isTaskCompleted,} from "@/lib/due-date-status";-import { getExternalWebUrl, openExternalWebUrl } from "@/lib/external-url";import { getInitials } from "@/lib/get-initials";import { getPriorityIcon } from "@/lib/priority";import { toast } from "@/lib/toast";@@ -82,41 +80,6 @@ function TaskCard({ task, disableDragDrop = false }: TaskCardProps) {const isTaskSelected = isSelected(task.id);const isTaskFocused = isFocused(task.id);- const pullRequests = useMemo(() => {- return (task.externalLinks ?? []).filter(- (link) =>- link.resourceType === "pull_request" &&- getExternalWebUrl(link.url) !== null,- );- }, [task.externalLinks]);-- const getPRInfo = (pr: (typeof pullRequests)[number]) => {- const isMerged = pr.metadata?.merged === true;- const isDraft = pr.metadata?.draft === true;-- if (isMerged) {- return {- icon: <GitMerge className="h-3 w-3 text-info-foreground" />,- status: t("tasks:pr.merged"),- statusClass: "text-info-foreground",- };- }-- if (isDraft) {- return {- icon: <GitPullRequest className="h-3 w-3 text-muted-foreground" />,- status: t("tasks:pr.draft"),- statusClass: "text-muted-foreground",- };- }-- return {- icon: <GitPullRequest className="h-3 w-3 text-success-foreground" />,- status: t("tasks:pr.open"),- statusClass: "text-success-foreground",- };- };-const { data: projectCustomFieldValues = [] } =useGetCustomFieldValuesByProject(task.projectId);@@ -375,114 +338,7 @@ function TaskCard({ task, disableDragDrop = false }: TaskCardProps) {</div>)}- {pullRequests.length === 1 && (- <HoverCard openDelay={200} closeDelay={100}>- <HoverCardTrigger asChild>- <button- type="button"- onClick={(e) => {- e.stopPropagation();- openExternalWebUrl(pullRequests[0].url);- }}- className="inline-flex items-center gap-1.5 rounded border border-border/70 bg-muted/55 px-2 py-1 text-[10px] font-medium text-muted-foreground"- >- {getPRInfo(pullRequests[0]).icon}- <span>#{pullRequests[0].externalId}</span>- </button>- </HoverCardTrigger>- <HoverCardContent- className="w-72 p-3"- side="bottom"- onClick={(e) => e.stopPropagation()}- onPointerDown={(e) => e.stopPropagation()}- >- <div className="space-y-2">- <div className="flex items-center gap-2 text-xs text-muted-foreground">- {getPRInfo(pullRequests[0]).icon}- <span>{getPRInfo(pullRequests[0]).status}</span>- <span className="text-muted-foreground/50">•</span>- <span>#{pullRequests[0].externalId}</span>- </div>- <p className="text-sm font-medium leading-snug">- {pullRequests[0].title || t("tasks:pr.label")}- </p>- </div>- </HoverCardContent>- </HoverCard>- )}-- {pullRequests.length > 1 &&- (() => {- const hasOpen = pullRequests.some(- (pr) => !pr.metadata?.merged && !pr.metadata?.draft,- );- const allMerged = pullRequests.every(- (pr) => pr.metadata?.merged,- );- const iconColor = allMerged- ? "text-info-foreground"- : hasOpen- ? "text-success-foreground"- : "text-muted-foreground";-- return (- <HoverCard openDelay={200} closeDelay={100}>- <HoverCardTrigger asChild>- <button- type="button"- onClick={(e) => e.stopPropagation()}- className="inline-flex items-center gap-1.5 rounded border border-border/70 bg-muted/55 px-2 py-1 text-[10px] font-medium text-muted-foreground"- >- <GitPullRequest className={`h-3 w-3 ${iconColor}`} />- <span>- {t("tasks:pr.count", {- count: pullRequests.length,- })}- </span>- </button>- </HoverCardTrigger>- <HoverCardContent- className="w-auto min-w-56 max-w-96 p-1"- side="bottom"- onClick={(e) => e.stopPropagation()}- onPointerDown={(e) => e.stopPropagation()}- >- {pullRequests.map((pr, index) => {- const prInfo = getPRInfo(pr);- const repoMatch = pr.url.match(- /github\.com\/([^/]+\/[^/]+)\/pull/,- );- const repoName = repoMatch ? repoMatch[1] : null;- return (- <div key={pr.id}>- {index > 0 && (- <hr className="border-border my-1" />- )}- <button- type="button"- onClick={() => openExternalWebUrl(pr.url)}- className="w-full px-2 py-1.5 text-left hover:bg-muted/50 rounded transition-colors"- >- <div className="flex items-center gap-1.5 text-[11px] text-muted-foreground">- {prInfo.icon}- <span>- {repoName}#{pr.externalId}- </span>- </div>- <p className="text-xs leading-tight line-clamp-2 mt-0.5">- {pr.title || t("tasks:pr.label")}- </p>- <span className="text-[10px] text-muted-foreground">- {prInfo.status}- </span>- </button>- </div>- );- })}- </HoverCardContent>- </HoverCard>- );- })()}+ <TaskPullRequests externalLinks={task.externalLinks} /></div></div></ContextMenuTrigger>diff --git a/apps/web/src/components/list-view/task-row.tsx b/apps/web/src/components/list-view/task-row.tsxindex 2cc1c937d..084443a31 100644--- a/apps/web/src/components/list-view/task-row.tsx+++ b/apps/web/src/components/list-view/task-row.tsx@@ -2,16 +2,11 @@ import { useSortable } from "@dnd-kit/sortable";import { CSS } from "@dnd-kit/utilities";import { useNavigate } from "@tanstack/react-router";import { format } from "date-fns";-import {- Calendar,- CalendarClock,- CalendarX,- GitMerge,- GitPullRequest,-} from "lucide-react";+import { Calendar, CalendarClock, CalendarX } from "lucide-react";import { type CSSProperties, useMemo, useState } from "react";import { useTranslation } from "react-i18next";import { TaskProgressBadges } from "@/components/task/task-progress-badges";+import { TaskPullRequests } from "@/components/task/task-pull-requests";import {AlertDialog,AlertDialogClose,@@ -23,11 +18,6 @@ import {} from "@/components/ui/alert-dialog";import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";import { Button } from "@/components/ui/button";-import {- HoverCard,- HoverCardContent,- HoverCardTrigger,-} from "@/components/ui/preview-card";import { useDeleteTask } from "@/hooks/mutations/task/use-delete-task";import useActiveWorkspace from "@/hooks/queries/workspace/use-active-workspace";import { useGetActiveWorkspaceUsers } from "@/hooks/queries/workspace-users/use-get-active-workspace-users";@@ -37,7 +27,6 @@ import {getDueDateStatus,isTaskCompleted,} from "@/lib/due-date-status";-import { getExternalWebUrl, openExternalWebUrl } from "@/lib/external-url";import { getInitials } from "@/lib/get-initials";import { getPriorityIcon } from "@/lib/priority";import { toast } from "@/lib/toast";@@ -92,41 +81,6 @@ function TaskRow({ task, projectSlug }: TaskRowProps) {);}, [workspaceUsers, task.userId]);- const pullRequests = useMemo(() => {- return (task.externalLinks ?? []).filter(- (link) =>- link.resourceType === "pull_request" &&- getExternalWebUrl(link.url) !== null,- );- }, [task.externalLinks]);-- const getPRInfo = (pr: (typeof pullRequests)[number]) => {- const isMerged = pr.metadata?.merged === true;- const isDraft = pr.metadata?.draft === true;-- if (isMerged) {- return {- icon: <GitMerge className="h-3 w-3 text-info-foreground" />,- status: t("tasks:pr.merged"),- statusClass: "text-info-foreground",- };- }-- if (isDraft) {- return {- icon: <GitPullRequest className="h-3 w-3 text-muted-foreground" />,- status: t("tasks:pr.draft"),- statusClass: "text-muted-foreground",- };- }-- return {- icon: <GitPullRequest className="h-3 w-3 text-success-foreground" />,- status: t("tasks:pr.open"),- statusClass: "text-success-foreground",- };- };-const style: CSSProperties = {transform: CSS.Transform.toString(transform),transition: transition || "transform 200ms cubic-bezier(0.23, 1, 0.32, 1)",@@ -221,114 +175,10 @@ function TaskRow({ task, projectSlug }: TaskRowProps) {<TaskProgressBadges task={task} />{showLabels && <TaskLabels labels={task.labels ?? []} />}- {pullRequests.length === 1 && (- <HoverCard openDelay={200} closeDelay={100}>- <HoverCardTrigger asChild>- <button- type="button"- onClick={(e) => {- e.stopPropagation();- openExternalWebUrl(pullRequests[0].url);- }}- className="inline-flex items-center gap-1.5 px-2 py-1 rounded border border-border bg-sidebar text-[10px] font-medium text-muted-foreground"- >- {getPRInfo(pullRequests[0]).icon}- <span>#{pullRequests[0].externalId}</span>- </button>- </HoverCardTrigger>- <HoverCardContent- className="w-72 p-3"- side="bottom"- onClick={(e) => e.stopPropagation()}- >- <div className="space-y-2">- <div className="flex items-center gap-2 text-xs text-muted-foreground">- {getPRInfo(pullRequests[0]).icon}- <span>{getPRInfo(pullRequests[0]).status}</span>- <span className="text-muted-foreground/50">•</span>- <span>#{pullRequests[0].externalId}</span>- </div>- <p className="text-sm font-medium leading-snug">- {pullRequests[0].title || t("tasks:pr.label")}- </p>- </div>- </HoverCardContent>- </HoverCard>- )}-- {pullRequests.length > 1 &&- (() => {- const hasOpen = pullRequests.some(- (pr) => !pr.metadata?.merged && !pr.metadata?.draft,- );- const allMerged = pullRequests.every(- (pr) => pr.metadata?.merged,- );- const iconColor = allMerged- ? "text-info-foreground"- : hasOpen- ? "text-success-foreground"- : "text-muted-foreground";-- return (- <HoverCard openDelay={200} closeDelay={100}>- <HoverCardTrigger asChild>- <button- type="button"- onClick={(e) => e.stopPropagation()}- className="inline-flex items-center gap-1.5 px-2 py-1 rounded border border-border bg-sidebar text-[10px] font-medium text-muted-foreground"- >- <GitPullRequest- className={`h-3 w-3 ${iconColor}`}- />- <span>- {t("tasks:pr.count", {- count: pullRequests.length,- })}- </span>- </button>- </HoverCardTrigger>- <HoverCardContent- className="w-auto min-w-56 max-w-96 p-1"- side="bottom"- onClick={(e) => e.stopPropagation()}- >- {pullRequests.map((pr, index) => {- const prInfo = getPRInfo(pr);- const repoMatch = pr.url.match(- /github\.com\/([^/]+\/[^/]+)\/pull/,- );- const repoName = repoMatch ? repoMatch[1] : null;- return (- <div key={pr.id}>- {index > 0 && (- <hr className="border-border my-1" />- )}- <button- type="button"- onClick={() => openExternalWebUrl(pr.url)}- className="w-full px-2 py-1.5 text-left hover:bg-muted/50 rounded transition-colors"- >- <div className="flex items-center gap-1.5 text-[11px] text-muted-foreground">- {prInfo.icon}- <span>- {repoName}#{pr.externalId}- </span>- </div>- <p className="text-xs leading-tight line-clamp-2 mt-0.5">- {pr.title || t("tasks:pr.label")}- </p>- <span className="text-[10px] text-muted-foreground">- {prInfo.status}- </span>- </button>- </div>- );- })}- </HoverCardContent>- </HoverCard>- );- })()}+ <TaskPullRequests+ externalLinks={task.externalLinks}+ className="border-border bg-sidebar"+ /></div></div></div>diff --git a/apps/web/src/components/public-project/public-pr-badge.tsx b/apps/web/src/components/public-project/public-pr-badge.tsxdeleted file mode 100644index c8ee19701..000000000--- a/apps/web/src/components/public-project/public-pr-badge.tsx+++ /dev/null@@ -1,155 +0,0 @@-import { GitMerge, GitPullRequest } from "lucide-react";-import { useMemo } from "react";-import { useTranslation } from "react-i18next";-import {- HoverCard,- HoverCardContent,- HoverCardTrigger,-} from "@/components/ui/preview-card";-import { getExternalWebUrl, openExternalWebUrl } from "@/lib/external-url";-import type { ExternalLink } from "@/types/external-link";--type PublicPRBadgeProps = {- externalLinks: ExternalLink[];-};--export function PublicPRBadge({ externalLinks }: PublicPRBadgeProps) {- const { t } = useTranslation();- const pullRequests = useMemo(() => {- if (!externalLinks) return [];- return externalLinks.filter(- (link) =>- link.resourceType === "pull_request" &&- getExternalWebUrl(link.url) !== null,- );- }, [externalLinks]);-- if (pullRequests.length === 0) return null;-- const getPRInfo = (pr: (typeof pullRequests)[number]) => {- const isMerged = pr.metadata?.merged === true;- const isDraft = pr.metadata?.draft === true;-- if (isMerged) {- return {- icon: <GitMerge className="h-3 w-3 text-info-foreground" />,- status: t("tasks:pr.merged"),- statusClass: "text-info-foreground",- };- }-- if (isDraft) {- return {- icon: <GitPullRequest className="h-3 w-3 text-muted-foreground" />,- status: t("tasks:pr.draft"),- statusClass: "text-muted-foreground",- };- }-- return {- icon: <GitPullRequest className="h-3 w-3 text-success-foreground" />,- status: t("tasks:pr.open"),- statusClass: "text-success-foreground",- };- };-- if (pullRequests.length === 1) {- return (- <HoverCard openDelay={200} closeDelay={100}>- <HoverCardTrigger asChild>- <button- type="button"- onClick={(e) => {- e.stopPropagation();- openExternalWebUrl(pullRequests[0].url);- }}- className="inline-flex items-center gap-1.5 px-2 py-1 rounded border border-border bg-sidebar text-[10px] font-medium text-muted-foreground hover:bg-muted/50 transition-colors"- >- {getPRInfo(pullRequests[0]).icon}- <span>#{pullRequests[0].externalId}</span>- </button>- </HoverCardTrigger>- <HoverCardContent- className="w-72 p-3"- side="bottom"- onClick={(e) => e.stopPropagation()}- >- <div className="space-y-2">- <div className="flex items-center gap-2 text-xs text-muted-foreground">- {getPRInfo(pullRequests[0]).icon}- <span>{getPRInfo(pullRequests[0]).status}</span>- <span className="text-muted-foreground/50">•</span>- <span>#{pullRequests[0].externalId}</span>- </div>- <p className="text-sm font-medium leading-snug">- {pullRequests[0].title || t("tasks:pr.label")}- </p>- </div>- </HoverCardContent>- </HoverCard>- );- }-- if (pullRequests.length > 1) {- const hasOpen = pullRequests.some(- (pr) => !pr.metadata?.merged && !pr.metadata?.draft,- );- const allMerged = pullRequests.every((pr) => pr.metadata?.merged);- const iconColor = allMerged- ? "text-info-foreground"- : hasOpen- ? "text-success-foreground"- : "text-muted-foreground";-- return (- <HoverCard openDelay={200} closeDelay={100}>- <HoverCardTrigger asChild>- <button- type="button"- onClick={(e) => e.stopPropagation()}- className="inline-flex items-center gap-1.5 px-2 py-1 rounded border border-border bg-sidebar text-[10px] font-medium text-muted-foreground hover:bg-muted/50 transition-colors"- >- <GitPullRequest className={`h-3 w-3 ${iconColor}`} />- <span>{t("tasks:pr.count", { count: pullRequests.length })}</span>- </button>- </HoverCardTrigger>- <HoverCardContent- className="w-auto min-w-56 max-w-96 p-1"- side="bottom"- onClick={(e) => e.stopPropagation()}- >- {pullRequests.map((pr, index) => {- const prInfo = getPRInfo(pr);- const repoMatch = pr.url.match(/github\.com\/([^/]+\/[^/]+)\/pull/);- const repoName = repoMatch ? repoMatch[1] : null;- return (- <div key={pr.id}>- {index > 0 && <hr className="border-border my-1" />}- <button- type="button"- onClick={() => openExternalWebUrl(pr.url)}- className="w-full px-2 py-1.5 text-left hover:bg-muted/50 rounded transition-colors"- >- <div className="flex items-center gap-1.5 text-[11px] text-muted-foreground">- {prInfo.icon}- <span>- {repoName}#{pr.externalId}- </span>- </div>- <p className="text-xs leading-tight line-clamp-2 mt-0.5">- {pr.title || t("tasks:pr.label")}- </p>- <span className="text-[10px] text-muted-foreground">- {prInfo.status}- </span>- </button>- </div>- );- })}- </HoverCardContent>- </HoverCard>- );- }-- return null;-}diff --git a/apps/web/src/components/public-project/task-card.tsx b/apps/web/src/components/public-project/task-card.tsxindex c1410ad0f..84a7e2273 100644--- a/apps/web/src/components/public-project/task-card.tsx+++ b/apps/web/src/components/public-project/task-card.tsx@@ -12,7 +12,7 @@ import { getInitials } from "@/lib/get-initials";import { getPriorityIcon } from "@/lib/priority";import type { ExternalLink } from "@/types/external-link";import type Task from "@/types/task";-import { PublicPRBadge } from "./public-pr-badge";+import { TaskPullRequests } from "@/components/task/task-pull-requests";import { PublicTaskLabels } from "./public-task-labels";type PublicTaskCardProps = {@@ -67,92 +67,93 @@ export function PublicTaskCard({onTaskClick(task);};- const handleClick = (e: React.MouseEvent) => {- if (e.detail === 0) return;- onTaskClick(task);- };-return (- <button- type="button"- className="group w-full text-left p-3 bg-card border border-border rounded-lg cursor-pointer transition-[background-color,border-color,box-shadow] duration-150 ease-out hover:border-border/70 hover:shadow-sm focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background"- onTouchStart={handleTouchStart}- onTouchEnd={handleTouchEnd}- onClick={handleClick}- aria-label={`View details for task ${task.title}`}- >- <div className="text-[10px] font-mono text-muted-foreground mb-2">- {projectSlug}-{task.number}- </div>-- {task.assigneeName && (- <div className="flex items-center gap-1.5 mb-2">- <Avatar className="h-5 w-5">- <AvatarImage- src={task.assigneeImage ?? ""}- alt={task.assigneeName ?? ""}- />- <AvatarFallback className="text-[10px] font-medium border border-border/30">- {getInitials(task.assigneeName)}- </AvatarFallback>- </Avatar>- <span className="text-[10px] text-muted-foreground font-medium truncate">- {task.assigneeName}- </span>+ <div className="group relative w-full text-left p-3 bg-card border border-border rounded-lg cursor-pointer transition-[background-color,border-color,box-shadow] duration-150 ease-out hover:border-border/70 hover:shadow-sm">+ <button+ type="button"+ className="absolute inset-0 rounded-lg focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"+ onTouchStart={handleTouchStart}+ onTouchEnd={handleTouchEnd}+ onClick={() => onTaskClick(task)}+ aria-label={`View details for task ${task.title}`}+ />+ <div className="pointer-events-none">+ <div className="text-[10px] font-mono text-muted-foreground mb-2">+ {projectSlug}-{task.number}</div>- )}- <div className="mb-3">- <h3- className="font-medium text-foreground text-sm leading-relaxed overflow-hidden break-words"- style={{- display: "-webkit-box",- WebkitLineClamp: 3,- WebkitBoxOrient: "vertical",- wordBreak: "break-word",- hyphens: "auto",- }}- >- {task.title}- </h3>- </div>+ {task.assigneeName && (+ <div className="flex items-center gap-1.5 mb-2">+ <Avatar className="h-5 w-5">+ <AvatarImage+ src={task.assigneeImage ?? ""}+ alt={task.assigneeName ?? ""}+ />+ <AvatarFallback className="text-[10px] font-medium border border-border/30">+ {getInitials(task.assigneeName)}+ </AvatarFallback>+ </Avatar>+ <span className="text-[10px] text-muted-foreground font-medium truncate">+ {task.assigneeName}+ </span>+ </div>+ )}- {labels.length > 0 && (<div className="mb-3">- <PublicTaskLabels labels={labels} />+ <h3+ className="font-medium text-foreground text-sm leading-relaxed overflow-hidden break-words"+ style={{+ display: "-webkit-box",+ WebkitLineClamp: 3,+ WebkitBoxOrient: "vertical",+ wordBreak: "break-word",+ hyphens: "auto",+ }}+ >+ {task.title}+ </h3></div>- )}-- <div className="flex flex-wrap items-center gap-2">- <TaskProgressBadges task={task} asText />- {task.priority && (- <span className="inline-flex items-center gap-1.5 px-2 py-1 rounded border border-border bg-sidebar text-[10px] font-medium text-muted-foreground">- {getPriorityIcon(task.priority ?? "")}- </span>- )}- {task.dueDate && (- <div- className={`flex items-center gap-1 text-[10px] px-2 py-1 rounded ${dueDateStatusColors[getDueDateStatus(task.dueDate, taskIsCompleted)]}`}- >- {getDueDateStatus(task.dueDate, taskIsCompleted) === "overdue" && (- <CalendarX className="w-3 h-3" />- )}- {getDueDateStatus(task.dueDate, taskIsCompleted) === "due-soon" && (- <CalendarClock className="w-3 h-3" />- )}- {(getDueDateStatus(task.dueDate, taskIsCompleted) ===- "far-future" ||- getDueDateStatus(task.dueDate, taskIsCompleted) ===- "no-due-date") && <Calendar className="w-3 h-3" />}- <span>{formatDateShort(task.dueDate)}</span>+ {labels.length > 0 && (+ <div className="mb-3">+ <PublicTaskLabels labels={labels} /></div>)}- {externalLinks.length > 0 && (- <PublicPRBadge externalLinks={externalLinks} />- )}+ <div className="flex flex-wrap items-center gap-2">+ <TaskProgressBadges task={task} asText />+ {task.priority && (+ <span className="inline-flex items-center gap-1.5 px-2 py-1 rounded border border-border bg-sidebar text-[10px] font-medium text-muted-foreground">+ {getPriorityIcon(task.priority ?? "")}+ </span>+ )}++ {task.dueDate && (+ <div+ className={`flex items-center gap-1 text-[10px] px-2 py-1 rounded ${dueDateStatusColors[getDueDateStatus(task.dueDate, taskIsCompleted)]}`}+ >+ {getDueDateStatus(task.dueDate, taskIsCompleted) ===+ "overdue" && <CalendarX className="w-3 h-3" />}+ {getDueDateStatus(task.dueDate, taskIsCompleted) ===+ "due-soon" && <CalendarClock className="w-3 h-3" />}+ {(getDueDateStatus(task.dueDate, taskIsCompleted) ===+ "far-future" ||+ getDueDateStatus(task.dueDate, taskIsCompleted) ===+ "no-due-date") && <Calendar className="w-3 h-3" />}+ <span>{formatDateShort(task.dueDate)}</span>+ </div>+ )}++ {externalLinks.length > 0 && (+ <div className="pointer-events-auto relative">+ <TaskPullRequests+ externalLinks={externalLinks}+ className="border-border bg-sidebar"+ />+ </div>+ )}+ </div></div>- </button>+ </div>);}diff --git a/apps/web/src/components/public-project/task-row.tsx b/apps/web/src/components/public-project/task-row.tsxindex 6adb57785..32e6f47c0 100644--- a/apps/web/src/components/public-project/task-row.tsx+++ b/apps/web/src/components/public-project/task-row.tsx@@ -12,7 +12,7 @@ import { getInitials } from "@/lib/get-initials";import { getPriorityIcon } from "@/lib/priority";import type { ExternalLink } from "@/types/external-link";import type Task from "@/types/task";-import { PublicPRBadge } from "./public-pr-badge";+import { TaskPullRequests } from "@/components/task/task-pull-requests";import { PublicTaskLabels } from "./public-task-labels";type PublicTaskRowProps = {@@ -39,15 +39,16 @@ export function PublicTaskRow({const externalLinks = task.externalLinks || [];return (- <button- type="button"- className="group w-full text-left px-4 py-3 rounded-lg flex items-center gap-4 bg-card border border-border shadow-sm hover:shadow-md transition-[background-color,border-color,box-shadow] duration-200 ease-out hover:border-border/70 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background"- onClick={() => onTaskClick(task)}- aria-label={t("publicProject:taskCard.viewDetailsAria", {- title: task.title,- })}- >- <div className="flex-1 min-w-0 flex items-center gap-3">+ <div className="group relative w-full text-left px-4 py-3 rounded-lg flex items-center gap-4 bg-card border border-border shadow-sm hover:shadow-md transition-[background-color,border-color,box-shadow] duration-200 ease-out hover:border-border/70 cursor-pointer">+ <button+ type="button"+ className="absolute inset-0 rounded-lg focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"+ onClick={() => onTaskClick(task)}+ aria-label={t("publicProject:taskCard.viewDetailsAria", {+ title: task.title,+ })}+ />+ <div className="pointer-events-none flex-1 min-w-0 flex items-center gap-3"><div className="text-xs font-mono text-muted-foreground shrink-0 font-medium">{projectSlug}-{task.number}</div>@@ -59,7 +60,7 @@ export function PublicTaskRow({</div></div>- <div className="flex flex-wrap items-center gap-2">+ <div className="pointer-events-none flex flex-wrap items-center gap-2"><TaskProgressBadges task={task} asText />{task.assigneeName && (<div className="flex items-center gap-1.5">@@ -103,9 +104,14 @@ export function PublicTaskRow({)}{externalLinks.length > 0 && (- <PublicPRBadge externalLinks={externalLinks} />+ <div className="pointer-events-auto relative">+ <TaskPullRequests+ externalLinks={externalLinks}+ className="border-border bg-sidebar"+ />+ </div>)}</div>- </button>+ </div>);}diff --git a/apps/web/src/components/task/task-properties-sidebar.tsx b/apps/web/src/components/task/task-properties-sidebar.tsxindex a6cb545e4..8055e35ad 100644--- a/apps/web/src/components/task/task-properties-sidebar.tsx+++ b/apps/web/src/components/task/task-properties-sidebar.tsx@@ -115,6 +115,10 @@ export default function TaskPropertiesSidebar({giteaIntegration?.branchPattern ||gitlabIntegration?.branchPattern ||"{slug}-{number}";+ const copiedBranchPattern =+ branchPattern === "{slug}-{number}"+ ? "{slug}-{number}-{title}"+ : branchPattern;const assignee = workspaceUsers?.members?.find((member) => member.userId === task?.userId,@@ -124,18 +128,18 @@ export default function TaskPropertiesSidebar({navigator.clipboard.writeText(`${window.location.origin}/dashboard/workspace/${workspaceId}/project/${projectId}/task/${taskId}`,);- toast.message(t("tasks:properties.copyTaskLink"));+ toast.message(t("tasks:properties.taskLinkCopied"));};const handleCopyTaskBranch = () => {const branchName = generateBranchName(- branchPattern,+ copiedBranchPattern,projectSlug,taskNumber,task?.title,);navigator.clipboard.writeText(branchName);- toast.message(t("tasks:properties.copyTaskBranch"));+ toast.message(t("tasks:properties.taskBranchCopied"));};return (@@ -149,7 +153,7 @@ export default function TaskPropertiesSidebar({<TaskMovePopovertask={task}workspaceId={workspaceId}- triggerClassName="rounded-l-md rounded-r-none border-r-0"+ triggerClassName="rounded-e-none border-e-0 before:rounded-e-none"/>)}<TooltipProvider>@@ -160,7 +164,9 @@ export default function TaskPropertiesSidebar({size="sm"className={cn("text-foreground border-r-0",- canMoveTask ? "rounded-none" : "rounded-r-none",+ canMoveTask+ ? "rounded-none before:rounded-none"+ : "rounded-e-none before:rounded-e-none",)}onClick={() => handleCopyTaskLink()}>@@ -180,7 +186,7 @@ export default function TaskPropertiesSidebar({<Buttonvariant="outline"size="sm"- className="text-foreground rounded-l-none"+ className="text-foreground rounded-s-none before:rounded-s-none"onClick={() => handleCopyTaskBranch()}><GitBranch className="size-4" />@@ -340,7 +346,7 @@ export default function TaskPropertiesSidebar({<TaskMovePopovertask={task}workspaceId={workspaceId}- triggerClassName="rounded-l-md rounded-r-none border-r-0"+ triggerClassName="rounded-e-none border-e-0 before:rounded-e-none"/>)}<TooltipProvider>@@ -351,7 +357,9 @@ export default function TaskPropertiesSidebar({size="sm"className={cn("text-foreground border-r-0",- canMoveTask ? "rounded-none" : "rounded-r-none",+ canMoveTask+ ? "rounded-none before:rounded-none"+ : "rounded-e-none before:rounded-e-none",)}onClick={() => handleCopyTaskLink()}>@@ -371,7 +379,7 @@ export default function TaskPropertiesSidebar({<Buttonvariant="outline"size="sm"- className="text-foreground rounded-l-none"+ className="text-foreground rounded-s-none before:rounded-s-none"onClick={() => handleCopyTaskBranch()}><GitBranch className="size-4" />@@ -532,7 +540,7 @@ export default function TaskPropertiesSidebar({<TaskMovePopovertask={task}workspaceId={workspaceId}- triggerClassName="rounded-l-md rounded-r-none border-r-0"+ triggerClassName="rounded-e-none border-e-0 before:rounded-e-none"/>)}<TooltipProvider>@@ -543,7 +551,9 @@ export default function TaskPropertiesSidebar({size="sm"className={cn("text-foreground border-r-0",- canMoveTask ? "rounded-none" : "rounded-r-none",+ canMoveTask+ ? "rounded-none before:rounded-none"+ : "rounded-e-none before:rounded-e-none",)}onClick={() => handleCopyTaskLink()}>@@ -563,7 +573,7 @@ export default function TaskPropertiesSidebar({<Buttonvariant="outline"size="sm"- className="text-foreground rounded-l-none"+ className="text-foreground rounded-s-none before:rounded-s-none"onClick={() => handleCopyTaskBranch()}><GitBranch className="size-4" />diff --git a/apps/web/src/components/task/task-pull-requests/index.test.tsx b/apps/web/src/components/task/task-pull-requests/index.test.tsxnew file mode 100644index 000000000..0d20427fa--- /dev/null+++ b/apps/web/src/components/task/task-pull-requests/index.test.tsx@@ -0,0 +1,118 @@+import { cleanup, fireEvent, render, screen } from "@testing-library/react";+import {+ afterAll,+ afterEach,+ beforeAll,+ describe,+ expect,+ it,+ vi,+} from "vite-plus/test";+import { PublicTaskCard } from "@/components/public-project/task-card";+import { PublicTaskRow } from "@/components/public-project/task-row";+import type { ExternalLink } from "@/types/external-link";+import type Task from "@/types/task";+import { TaskPullRequests } from ".";++const onParentClick = vi.fn();++beforeAll(() => document.body.addEventListener("click", onParentClick));+afterAll(() => document.body.removeEventListener("click", onParentClick));+afterEach(() => {+ cleanup();+ onParentClick.mockClear();+});++function pullRequest(externalId: string, title: string): ExternalLink {+ return {+ id: `link-${externalId}`,+ taskId: "task-1",+ integrationId: "integration-1",+ resourceType: "pull_request",+ externalId,+ url: `https://github.com/o/r/pull/${externalId}`,+ title,+ metadata: { merged: false, draft: false },+ } as ExternalLink;+}++const task = {+ id: "task-1",+ title: "Linked task",+ number: 1,+ status: "in-progress",+ priority: null,+ dueDate: null,+ userId: null,+ assigneeId: null,+ assigneeName: null,+ projectId: "project-1",+} as unknown as Task;++describe("TaskPullRequests", () => {+ it("links a single pull request without activating its parent", () => {+ render(<TaskPullRequests externalLinks={[pullRequest("42", "Fix it")]} />);++ const link = screen.getByRole("link", { name: /#42/ });+ expect(link).toHaveAttribute("href", "https://github.com/o/r/pull/42");+ expect(link).toHaveAttribute("target", "_blank");+ expect(link).toHaveAttribute("rel", "noopener noreferrer");++ fireEvent.click(link);+ expect(onParentClick).not.toHaveBeenCalled();+ });++ it("lists every pull request in the hover card", async () => {+ render(+ <TaskPullRequests+ externalLinks={[+ pullRequest("42", "Fix it"),+ pullRequest("43", "Follow up"),+ ]}+ />,+ );++ const trigger = screen.getByRole("button", { name: "2 PRs" });+ fireEvent.click(trigger);+ expect(onParentClick).not.toHaveBeenCalled();++ fireEvent.focus(trigger);+ fireEvent.pointerEnter(trigger);+ fireEvent.mouseEnter(trigger);++ const first = await screen.findByRole("link", { name: /Fix it/ });+ const second = screen.getByRole("link", { name: /Follow up/ });+ expect(first).toHaveAttribute("href", "https://github.com/o/r/pull/42");+ expect(second).toHaveAttribute("href", "https://github.com/o/r/pull/43");++ fireEvent.click(second);+ expect(onParentClick).not.toHaveBeenCalled();+ });++ it.each([PublicTaskCard, PublicTaskRow])(+ "keeps pull request links outside the public task button",+ (Component) => {+ const onTaskClick = vi.fn();+ render(+ <Component+ task={{ ...task, externalLinks: [pullRequest("42", "Fix it")] }}+ projectSlug="kan"+ onTaskClick={onTaskClick}+ />,+ );++ const taskButton = screen.getByRole("button");+ const link = screen.getByRole("link", { name: /#42/ });+ expect(taskButton).not.toContainElement(link);+ expect(link.closest("button, [role='button']")).toBeNull();++ fireEvent.click(link);+ expect(onTaskClick).not.toHaveBeenCalled();++ fireEvent.click(taskButton);+ expect(onTaskClick).toHaveBeenCalledWith(+ expect.objectContaining({ id: "task-1" }),+ );+ },+ );+});diff --git a/apps/web/src/components/task/task-pull-requests/index.tsx b/apps/web/src/components/task/task-pull-requests/index.tsxnew file mode 100644index 000000000..40af14a63--- /dev/null+++ b/apps/web/src/components/task/task-pull-requests/index.tsx@@ -0,0 +1,87 @@+import { useMemo } from "react";+import { useTranslation } from "react-i18next";+import {+ HoverCard,+ HoverCardContent,+ HoverCardTrigger,+} from "@/components/ui/preview-card";+import { cn } from "@/lib/cn";+import {+ getPullRequestStatus,+ getPullRequests,+ getPullRequestsStatus,+} from "@/lib/pull-request";+import type { ExternalLink } from "@/types/external-link";+import { PullRequestRow } from "./pull-request-row";+import { PullRequestStatusIcon } from "./pull-request-status-icon";++type TaskPullRequestsProps = {+ externalLinks: ExternalLink[] | null | undefined;+ className?: string;+};++export function TaskPullRequests({+ externalLinks,+ className,+}: TaskPullRequestsProps) {+ const { t } = useTranslation();+ const pullRequests = useMemo(+ () => getPullRequests(externalLinks),+ [externalLinks],+ );++ if (pullRequests.length === 0) return null;++ const single = pullRequests.length === 1 ? pullRequests[0] : null;+ const badgeClassName = cn(+ "inline-flex h-5.5 items-center gap-1.5 rounded border border-border/70 bg-muted/55 px-2 py-1 text-[10px] font-medium text-muted-foreground transition-colors hover:bg-muted",+ className,+ );++ return (+ <HoverCard openDelay={200} closeDelay={100}>+ <HoverCardTrigger asChild>+ {single ? (+ <a+ href={single.href}+ target="_blank"+ rel="noopener noreferrer"+ onClick={(e) => e.stopPropagation()}+ onPointerDown={(e) => e.stopPropagation()}+ onTouchEnd={(e) => e.stopPropagation()}+ className={badgeClassName}+ >+ <PullRequestStatusIcon status={getPullRequestStatus(single)} />+ <span>#{single.externalId}</span>+ </a>+ ) : (+ <button+ type="button"+ onClick={(e) => e.stopPropagation()}+ onPointerDown={(e) => e.stopPropagation()}+ onTouchEnd={(e) => e.stopPropagation()}+ className={badgeClassName}+ >+ <PullRequestStatusIcon+ status={getPullRequestsStatus(pullRequests)}+ />+ <span>{t("tasks:pr.count", { count: pullRequests.length })}</span>+ </button>+ )}+ </HoverCardTrigger>+ <HoverCardContent+ className="w-80 flex-col gap-px p-1"+ side="bottom"+ align="start"+ onClick={(e) => e.stopPropagation()}+ onPointerDown={(e) => e.stopPropagation()}+ onTouchEnd={(e) => e.stopPropagation()}+ onKeyDown={(e) => e.stopPropagation()}+ >+ {pullRequests.map((pr) => (+ <PullRequestRow key={pr.id} pullRequest={pr} />+ ))}+ </HoverCardContent>+ </HoverCard>+ );+}diff --git a/apps/web/src/components/task/task-pull-requests/pull-request-row.tsx b/apps/web/src/components/task/task-pull-requests/pull-request-row.tsxnew file mode 100644index 000000000..1209668fc--- /dev/null+++ b/apps/web/src/components/task/task-pull-requests/pull-request-row.tsx@@ -0,0 +1,41 @@+import { useTranslation } from "react-i18next";+import {+ getPullRequestRepoName,+ getPullRequestStatus,+ type PullRequest,+} from "@/lib/pull-request";+import { PullRequestStatusIcon } from "./pull-request-status-icon";++type PullRequestRowProps = {+ pullRequest: PullRequest;+};++export function PullRequestRow({ pullRequest }: PullRequestRowProps) {+ const { t } = useTranslation();+ const status = getPullRequestStatus(pullRequest);+ const repoName = getPullRequestRepoName(pullRequest.url);+ const statusLabel = {+ merged: t("tasks:pr.merged"),+ draft: t("tasks:pr.draft"),+ open: t("tasks:pr.open"),+ }[status];++ return (+ <a+ href={pullRequest.href}+ target="_blank"+ rel="noopener noreferrer"+ title={repoName ? `${repoName}#${pullRequest.externalId}` : undefined}+ className="flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent"+ >+ <PullRequestStatusIcon status={status} className="size-3.5" />+ <span className="sr-only">{statusLabel}</span>+ <span className="min-w-0 flex-1 truncate text-foreground">+ {pullRequest.title || t("tasks:pr.label")}+ </span>+ <span className="shrink-0 tabular-nums text-muted-foreground">+ #{pullRequest.externalId}+ </span>+ </a>+ );+}diff --git a/apps/web/src/components/task/task-pull-requests/pull-request-status-icon.tsx b/apps/web/src/components/task/task-pull-requests/pull-request-status-icon.tsxnew file mode 100644index 000000000..25fa26370--- /dev/null+++ b/apps/web/src/components/task/task-pull-requests/pull-request-status-icon.tsx@@ -0,0 +1,27 @@+import { GitMerge, GitPullRequest } from "lucide-react";+import { cn } from "@/lib/cn";+import type { PullRequestStatus } from "@/lib/pull-request";++const statusClassName: Record<PullRequestStatus, string> = {+ merged: "text-info-foreground",+ draft: "text-muted-foreground",+ open: "text-success-foreground",+};++type PullRequestStatusIconProps = {+ status: PullRequestStatus;+ className?: string;+};++export function PullRequestStatusIcon({+ status,+ className,+}: PullRequestStatusIconProps) {+ const Icon = status === "merged" ? GitMerge : GitPullRequest;+ return (+ <Icon+ aria-hidden+ className={cn("size-3 shrink-0", statusClassName[status], className)}+ />+ );+}diff --git a/apps/web/src/lib/pull-request.test.ts b/apps/web/src/lib/pull-request.test.tsnew file mode 100644index 000000000..3570f6d91--- /dev/null+++ b/apps/web/src/lib/pull-request.test.ts@@ -0,0 +1,53 @@+import { describe, expect, it } from "vite-plus/test";+import type { ExternalLink } from "@/types/external-link";+import {+ getPullRequestRepoName,+ getPullRequests,+ getPullRequestsStatus,+} from "./pull-request";++const link = (overrides: Partial<ExternalLink>): ExternalLink => ({+ id: "1",+ taskId: "t1",+ integrationId: null,+ resourceType: "pull_request",+ externalId: "1",+ url: "https://github.com/acme/repo/pull/1",+ title: null,+ metadata: null,+ ...overrides,+});++describe("getPullRequests", () => {+ it("keeps pull requests with safe web URLs", () => {+ expect(+ getPullRequests([+ link({ id: "pr" }),+ link({ id: "issue", resourceType: "issue" }),+ link({ id: "unsafe", url: "javascript:alert(1)" }),+ ]).map((pr) => pr.id),+ ).toEqual(["pr"]);+ });+});++describe("getPullRequestsStatus", () => {+ it("is merged only when every pull request is merged", () => {+ const merged = link({ metadata: { merged: true } });+ expect(getPullRequestsStatus([merged, merged])).toBe("merged");+ expect(getPullRequestsStatus([merged, link({})])).toBe("open");+ expect(+ getPullRequestsStatus([merged, link({ metadata: { draft: true } })]),+ ).toBe("draft");+ });+});++describe("getPullRequestRepoName", () => {+ it("reads the owner and repository from a GitHub URL", () => {+ expect(getPullRequestRepoName("https://github.com/acme/repo/pull/9")).toBe(+ "acme/repo",+ );+ expect(+ getPullRequestRepoName("https://gitlab.com/acme/repo/-/merge_requests/9"),+ ).toBeNull();+ });+});diff --git a/apps/web/src/lib/pull-request.ts b/apps/web/src/lib/pull-request.tsnew file mode 100644index 000000000..cac8992e8--- /dev/null+++ b/apps/web/src/lib/pull-request.ts@@ -0,0 +1,35 @@+import { getExternalWebUrl } from "@/lib/external-url";+import type { ExternalLink } from "@/types/external-link";++export type PullRequest = ExternalLink & { href: string };++export type PullRequestStatus = "merged" | "draft" | "open";++export function getPullRequests(+ externalLinks: ExternalLink[] | null | undefined,+): PullRequest[] {+ return (externalLinks ?? []).flatMap((link) => {+ if (link.resourceType !== "pull_request") return [];+ const href = getExternalWebUrl(link.url);+ return href ? [{ ...link, href }] : [];+ });+}++export function getPullRequestStatus(pr: ExternalLink): PullRequestStatus {+ if (pr.metadata?.merged === true) return "merged";+ if (pr.metadata?.draft === true) return "draft";+ return "open";+}++export function getPullRequestsStatus(+ pullRequests: ExternalLink[],+): PullRequestStatus {+ const statuses = pullRequests.map(getPullRequestStatus);+ if (statuses.every((status) => status === "merged")) return "merged";+ if (statuses.includes("open")) return "open";+ return "draft";+}++export function getPullRequestRepoName(url: string) {+ return url.match(/github\.com\/([^/]+\/[^/]+)\/pull/)?.[1] ?? null;+}diff --git a/i18n/az-AZ.json b/i18n/az-AZ.jsonindex ecdacb575..511309f3a 100644--- a/i18n/az-AZ.json+++ b/i18n/az-AZ.json@@ -2340,6 +2340,8 @@"labels": "Etiketlər","copyTaskLink": "Tapşırığın keçidini kopyala","copyTaskBranch": "Tapşırığın budağını kopyala",+ "taskLinkCopied": "Tapşırıq keçidi kopyalandı",+ "taskBranchCopied": "Branch adı kopyalandı","start": "Başlat","startDate": "Başlama tarixi","noDate": "Tarix yoxdur"diff --git a/i18n/de-DE.json b/i18n/de-DE.jsonindex acc98feac..78976fae4 100644--- a/i18n/de-DE.json+++ b/i18n/de-DE.json@@ -2340,6 +2340,8 @@"labels": "Labels","copyTaskLink": "Aufgabenlink kopieren","copyTaskBranch": "Aufgaben-Branch kopieren",+ "taskLinkCopied": "Aufgabenlink kopiert",+ "taskBranchCopied": "Branch-Name kopiert","start": "Start","startDate": "Startdatum","noDate": "Kein Datum"diff --git a/i18n/el-GR.json b/i18n/el-GR.jsonindex 1f256b198..2107b5fad 100644--- a/i18n/el-GR.json+++ b/i18n/el-GR.json@@ -2340,6 +2340,8 @@"labels": "Ετικέτες","copyTaskLink": "Αντιγραφή συνδέσμου εργασίας","copyTaskBranch": "Αντιγραφή κλάδου εργασίας",+ "taskLinkCopied": "Ο σύνδεσμος της εργασίας αντιγράφηκε",+ "taskBranchCopied": "Το όνομα του branch αντιγράφηκε","start": "Έναρξη","startDate": "Ημερομηνία έναρξης","noDate": "Χωρίς ημερομηνία"diff --git a/i18n/en-US.json b/i18n/en-US.jsonindex 6db38721b..9148b497c 100644--- a/i18n/en-US.json+++ b/i18n/en-US.json@@ -2341,6 +2341,8 @@"labels": "Labels","copyTaskLink": "Copy task link","copyTaskBranch": "Copy task branch",+ "taskLinkCopied": "Copied task link",+ "taskBranchCopied": "Copied branch name","start": "Start","startDate": "Start date","noDate": "No date"diff --git a/i18n/es-ES.json b/i18n/es-ES.jsonindex 3e2f98adc..044d951bf 100644--- a/i18n/es-ES.json+++ b/i18n/es-ES.json@@ -2351,6 +2351,8 @@"labels": "Etiquetas","copyTaskLink": "Copiar enlace a tarea","copyTaskBranch": "Copiar la rama de la tarea",+ "taskLinkCopied": "Enlace de la tarea copiado",+ "taskBranchCopied": "Nombre de la rama copiado","start": "Comenzar","startDate": "Fecha de inicio","noDate": "Sin fecha"diff --git a/i18n/fr-FR.json b/i18n/fr-FR.jsonindex 6f1f97e99..bf7307262 100644--- a/i18n/fr-FR.json+++ b/i18n/fr-FR.json@@ -2351,6 +2351,8 @@"labels": "Labels","copyTaskLink": "Copier le lien de la tâche","copyTaskBranch": "Copier la branche de la tâche",+ "taskLinkCopied": "Lien de la tâche copié",+ "taskBranchCopied": "Nom de la branche copié","start": "Début","startDate": "Date de début","noDate": "Pas de date"diff --git a/i18n/hi-IN.json b/i18n/hi-IN.jsonindex 50ed4b8e1..90912789c 100644--- a/i18n/hi-IN.json+++ b/i18n/hi-IN.json@@ -2340,6 +2340,8 @@"labels": "लेबल","copyTaskLink": "कार्य लिंक कॉपी करें","copyTaskBranch": "कार्य शाखा कॉपी करें",+ "taskLinkCopied": "कार्य का लिंक कॉपी किया गया",+ "taskBranchCopied": "ब्रांच का नाम कॉपी किया गया","start": "शुरू","startDate": "शुरू की तारीख","noDate": "कोई तारीख नहीं"diff --git a/i18n/id-ID.json b/i18n/id-ID.jsonindex e8204be15..65a8da5e0 100644--- a/i18n/id-ID.json+++ b/i18n/id-ID.json@@ -2329,6 +2329,8 @@"labels": "Label","copyTaskLink": "Salin tautan tugas","copyTaskBranch": "Salin branch tugas",+ "taskLinkCopied": "Tautan tugas disalin",+ "taskBranchCopied": "Nama branch disalin","start": "Mulai","startDate": "Tanggal mulai","noDate": "Tanpa tanggal"diff --git a/i18n/it-IT.json b/i18n/it-IT.jsonindex d6757f4ea..33e59a91d 100644--- a/i18n/it-IT.json+++ b/i18n/it-IT.json@@ -2351,6 +2351,8 @@"labels": "Etichette","copyTaskLink": "Copia link attività","copyTaskBranch": "Copia ramo attività",+ "taskLinkCopied": "Link dell'attività copiato",+ "taskBranchCopied": "Nome del branch copiato","start": "Inizio","startDate": "Data inizio","noDate": "Nessuna data"diff --git a/i18n/ja-JP.json b/i18n/ja-JP.jsonindex 9bd196d1b..b860a9bf2 100644--- a/i18n/ja-JP.json+++ b/i18n/ja-JP.json@@ -2329,6 +2329,8 @@"labels": "ラベル","copyTaskLink": "タスクのリンクをコピー","copyTaskBranch": "タスクのブランチ名をコピー",+ "taskLinkCopied": "タスクのリンクをコピーしました",+ "taskBranchCopied": "ブランチ名をコピーしました","start": "開始","startDate": "開始日","noDate": "日付なし"diff --git a/i18n/ko-KR.json b/i18n/ko-KR.jsonindex c11853e5c..e89f87898 100644--- a/i18n/ko-KR.json+++ b/i18n/ko-KR.json@@ -2329,6 +2329,8 @@"labels": "라벨","copyTaskLink": "작업 링크 복사","copyTaskBranch": "작업 브랜치 복사",+ "taskLinkCopied": "작업 링크를 복사했습니다",+ "taskBranchCopied": "브랜치 이름을 복사했습니다","start": "시작","startDate": "시작일","noDate": "날짜 없음"diff --git a/i18n/mk-MK.json b/i18n/mk-MK.jsonindex 3f9b59ddb..504167dcd 100644--- a/i18n/mk-MK.json+++ b/i18n/mk-MK.json@@ -2340,6 +2340,8 @@"labels": "Етикети","copyTaskLink": "Копирај линк на задача","copyTaskBranch": "Копирај гранка на задача",+ "taskLinkCopied": "Врската до задачата е копирана",+ "taskBranchCopied": "Името на гранката е копирано","start": "Почеток","startDate": "Почетен датум","noDate": "Без датум"diff --git a/i18n/nl-NL.json b/i18n/nl-NL.jsonindex b74b33a17..73bd3a324 100644--- a/i18n/nl-NL.json+++ b/i18n/nl-NL.json@@ -2340,6 +2340,8 @@"labels": "Labels","copyTaskLink": "Taaklink kopiëren","copyTaskBranch": "Taakbranch kopiëren",+ "taskLinkCopied": "Taaklink gekopieerd",+ "taskBranchCopied": "Branchnaam gekopieerd","start": "Start","startDate": "Startdatum","noDate": "Geen datum"diff --git a/i18n/pl-PL.json b/i18n/pl-PL.jsonindex b4d4d926d..bfc8a0d7c 100644--- a/i18n/pl-PL.json+++ b/i18n/pl-PL.json@@ -2731,6 +2731,8 @@},"properties": {"copyTaskBranch": "Kopiuj gałąź zadania",+ "taskLinkCopied": "Skopiowano link do zadania",+ "taskBranchCopied": "Skopiowano nazwę gałęzi","copyTaskLink": "Kopiuj link do zadania","labels": "Etykiety","noDate": "Brak daty",diff --git a/i18n/pt-BR.json b/i18n/pt-BR.jsonindex d91b738f4..90e54db86 100644--- a/i18n/pt-BR.json+++ b/i18n/pt-BR.json@@ -2351,6 +2351,8 @@"labels": "Etiquetas","copyTaskLink": "Copiar link da tarefa","copyTaskBranch": "Copiar branch da tarefa",+ "taskLinkCopied": "Link da tarefa copiado",+ "taskBranchCopied": "Nome da branch copiado","start": "Início","startDate": "Data de início","noDate": "Sem data"diff --git a/i18n/ru-RU.json b/i18n/ru-RU.jsonindex 4127b0a76..de084055b 100644--- a/i18n/ru-RU.json+++ b/i18n/ru-RU.json@@ -2370,6 +2370,8 @@"labels": "Метки","copyTaskLink": "Скопировать ссылку на задачу","copyTaskBranch": "Скопировать ветку задачи",+ "taskLinkCopied": "Ссылка на задачу скопирована",+ "taskBranchCopied": "Название ветки скопировано","start": "Начало","startDate": "Дата начала","noDate": "Без даты"diff --git a/i18n/schema.json b/i18n/schema.jsonindex 727fa2e46..0f5f109d4 100644--- a/i18n/schema.json+++ b/i18n/schema.json@@ -9446,6 +9446,12 @@"copyTaskBranch": {"type": "string"},+ "taskLinkCopied": {+ "type": "string"+ },+ "taskBranchCopied": {+ "type": "string"+ },"start": {"type": "string"},@@ -9461,6 +9467,8 @@"labels","copyTaskLink","copyTaskBranch",+ "taskLinkCopied",+ "taskBranchCopied","start","startDate","noDate"diff --git a/i18n/tr-TR.json b/i18n/tr-TR.jsonindex b3affd384..b76519a7c 100644--- a/i18n/tr-TR.json+++ b/i18n/tr-TR.json@@ -2340,6 +2340,8 @@"labels": "Etiketler","copyTaskLink": "Talep bağlantısını kopyala","copyTaskBranch": "Talep dalını kopyala",+ "taskLinkCopied": "Görev bağlantısı kopyalandı",+ "taskBranchCopied": "Branch adı kopyalandı","start": "Başlat","startDate": "Başlangıç tarihi","noDate": "Tarih yok"diff --git a/i18n/uk-UA.json b/i18n/uk-UA.jsonindex 8a0d1daae..8a0237103 100644--- a/i18n/uk-UA.json+++ b/i18n/uk-UA.json@@ -2362,6 +2362,8 @@"labels": "Мітки","copyTaskLink": "Копіювати посилання на завдання","copyTaskBranch": "Копіювати гілку завдання",+ "taskLinkCopied": "Посилання на завдання скопійовано",+ "taskBranchCopied": "Назву гілки скопійовано","start": "Початок","startDate": "Дата початку","noDate": "Немає дати"diff --git a/i18n/vi-VN.json b/i18n/vi-VN.jsonindex 40a078eee..56ff846c5 100644--- a/i18n/vi-VN.json+++ b/i18n/vi-VN.json@@ -2329,6 +2329,8 @@"labels": "Nhãn","copyTaskLink": "Sao chép liên kết công việc","copyTaskBranch": "Sao chép nhánh công việc",+ "taskLinkCopied": "Đã sao chép liên kết công việc",+ "taskBranchCopied": "Đã sao chép tên nhánh","start": "Bắt đầu","startDate": "Ngày bắt đầu","noDate": "Không có ngày"diff --git a/i18n/zh-CN.json b/i18n/zh-CN.jsonindex 5cf3d45f4..d7fe4a9a4 100644--- a/i18n/zh-CN.json+++ b/i18n/zh-CN.json@@ -2329,6 +2329,8 @@"labels": "标签","copyTaskLink": "复制任务链接","copyTaskBranch": "复制任务分支",+ "taskLinkCopied": "已复制任务链接",+ "taskBranchCopied": "已复制分支名称","start": "开始","startDate": "开始日期","noDate": "无日期"diff --git a/tests/api-integration/gitlab-completed-task-status.test.ts b/tests/api-integration/gitlab-completed-task-status.test.tsnew file mode 100644index 000000000..a992f2855--- /dev/null+++ b/tests/api-integration/gitlab-completed-task-status.test.ts@@ -0,0 +1,194 @@+import { eq } from "drizzle-orm";+import { beforeEach, describe, expect, it } from "vite-plus/test";+import db, { schema } from "../../apps/api/src/database";+import { handleGitlabMergeRequestOpened } from "../../apps/api/src/plugins/gitlab/webhooks/merge-request-opened";+import { handleGitlabPush } from "../../apps/api/src/plugins/gitlab/webhooks/push";+import { resetTestDatabase } from "./helpers/database";+import {+ createProjectFixture,+ createWorkspaceMember,+} from "./helpers/fixtures";++async function createFixture() {+ const member = await createWorkspaceMember();+ const { project, columns } = await createProjectFixture({+ workspaceId: member.workspace.id,+ slug: "KAN",+ });+ const [integration] = await db+ .insert(schema.integrationTable)+ .values({+ projectId: project.id,+ type: "gitlab",+ isActive: true,+ config: JSON.stringify({+ baseUrl: "https://gitlab.example",+ projectPath: "group/project",+ accessToken: "fake-test-token",+ branchPattern: "{slug}-{number}",+ }),+ })+ .returning();+ const [task] = await db+ .insert(schema.taskTable)+ .values({+ projectId: project.id,+ number: 42,+ title: "Task 42",+ status: "done",+ columnId: columns.done.id,+ priority: "medium",+ position: 0,+ })+ .returning();+ return { project, columns, integration, task };+}++describe("GitLab merge requests on a completed task", () => {+ let fixture: Awaited<ReturnType<typeof createFixture>>;++ const mergeRequest = (+ overrides: { draft?: boolean; branch?: string; description?: string } = {},+ ) => ({+ object_attributes: {+ iid: 7,+ title: "Slice 2",+ description: overrides.description ?? null,+ url: "https://gitlab.example/group/project/-/merge_requests/7",+ state: "opened",+ draft: overrides.draft ?? false,+ source_branch: overrides.branch ?? "kan-42-slice-2",+ },+ project: {+ name: "project",+ web_url: "https://gitlab.example/group/project",+ path_with_namespace: "group/project",+ },+ });+ const status = async () =>+ (+ await db.query.taskTable.findFirst({+ where: eq(schema.taskTable.id, fixture.task.id),+ })+ )?.status;+ const complete = () =>+ db+ .update(schema.taskTable)+ .set({ status: "done", columnId: fixture.columns.done.id })+ .where(eq(schema.taskTable.id, fixture.task.id));++ beforeEach(async () => {+ await resetTestDatabase();+ fixture = await createFixture();+ });++ it("moves the task to review when a draft becomes ready", async () => {+ await handleGitlabMergeRequestOpened(+ mergeRequest({ draft: true }),+ fixture.integration.id,+ { moveTask: false },+ );+ expect(await status()).toBe("done");++ await handleGitlabMergeRequestOpened(+ mergeRequest(),+ fixture.integration.id,+ );+ expect(await status()).toBe("in-review");+ });++ it("keeps the task done for a repeated ready delivery", async () => {+ await handleGitlabMergeRequestOpened(+ mergeRequest(),+ fixture.integration.id,+ );+ await complete();+ await handleGitlabMergeRequestOpened(+ mergeRequest(),+ fixture.integration.id,+ );+ expect(await status()).toBe("done");+ });++ it("links a merge request through the task link", async () => {+ const taskLink = `https://kaneo.example.com/dashboard/workspace/w/project/${fixture.project.id}/task/${fixture.task.id}`;+ await handleGitlabMergeRequestOpened(+ mergeRequest({ branch: "unrelated", description: taskLink }),+ fixture.integration.id,+ );+ expect(await status()).toBe("in-review");+ });++ it("does not move a task that moved to another project", async () => {+ await handleGitlabMergeRequestOpened(+ mergeRequest({ draft: true }),+ fixture.integration.id,+ { moveTask: false },+ );+ const other = await createProjectFixture({+ workspaceId: fixture.project.workspaceId,+ slug: "OTHER",+ });+ await db+ .update(schema.taskTable)+ .set({ projectId: other.project.id, columnId: other.columns.done.id })+ .where(eq(schema.taskTable.id, fixture.task.id));++ await handleGitlabMergeRequestOpened(+ mergeRequest(),+ fixture.integration.id,+ );+ expect(await status()).toBe("done");+ });+});++describe("GitLab pushes to a completed task", () => {+ let fixture: Awaited<ReturnType<typeof createFixture>>;++ const push = (after?: string) =>+ handleGitlabPush(+ {+ after,+ ref: "refs/heads/kan-42-slice-2",+ project: {+ name: "project",+ web_url: "https://gitlab.example/group/project",+ path_with_namespace: "group/project",+ },+ },+ fixture.integration.id,+ );+ const status = async () =>+ (+ await db.query.taskTable.findFirst({+ where: eq(schema.taskTable.id, fixture.task.id),+ })+ )?.status;+ const complete = () =>+ db+ .update(schema.taskTable)+ .set({ status: "done", columnId: fixture.columns.done.id })+ .where(eq(schema.taskTable.id, fixture.task.id));++ beforeEach(async () => {+ await resetTestDatabase();+ fixture = await createFixture();+ });++ it("moves the task back to progress for a new branch", async () => {+ await push();+ expect(await status()).toBe("in-progress");+ });++ it("keeps the task done for a push to an already linked branch", async () => {+ await push();+ await complete();+ await push();+ expect(await status()).toBe("done");+ });++ it("ignores a push that deletes the branch", async () => {+ await push("0".repeat(40));+ expect(await status()).toBe("done");+ });+});diff --git a/tests/api-integration/gitlab-sync-boundaries.test.ts b/tests/api-integration/gitlab-sync-boundaries.test.tsindex 2eb3294dc..91eac1404 100644--- a/tests/api-integration/gitlab-sync-boundaries.test.ts+++ b/tests/api-integration/gitlab-sync-boundaries.test.ts@@ -105,6 +105,26 @@ describe("GitLab import authorization", () => {});},);+ it("links an imported merge request through its task link", async () => {+ const { project, task, request } = await setup();+ mocks.listMergeRequests.mockResolvedValueOnce([+ {+ iid: 7,+ title: "Unrelated title",+ description: `https://kaneo.example.com/dashboard/workspace/w/project/${project.id}/task/${task.id}`,+ web_url: "https://gitlab.example/group/project/-/merge_requests/7",+ state: "opened",+ source_branch: "unrelated",+ },+ ]);+ expect((await request()).status).toBe(200);+ expect(+ await db.query.externalLinkTable.findFirst({+ where: eq(schema.externalLinkTable.resourceType, "pull_request"),+ }),+ ).toMatchObject({ taskId: task.id, externalId: "7" });+ });+it("allows a custom role with both permissions to refresh an existing task", async () => {const { task, request } = await setup();const response = await request();diff --git a/tests/api-integration/pull-request-task-links.test.ts b/tests/api-integration/pull-request-task-links.test.tsindex 53c990c4d..cf5795dc5 100644--- a/tests/api-integration/pull-request-task-links.test.ts+++ b/tests/api-integration/pull-request-task-links.test.ts@@ -10,6 +10,8 @@ import { handleGiteaPullRequestOpened } from "../../apps/api/src/plugins/gitea/wimport { resolvePullRequestTask } from "../../apps/api/src/plugins/github/services/resolve-pull-request-task";import { handlePullRequestClosed } from "../../apps/api/src/plugins/github/webhooks/pull-request-closed";import { handlePullRequestOpened } from "../../apps/api/src/plugins/github/webhooks/pull-request-opened";+import { handlePush } from "../../apps/api/src/plugins/github/webhooks/push";+import { handleGiteaPush } from "../../apps/api/src/plugins/gitea/webhooks/push";import { resetTestDatabase } from "./helpers/database";import {createProjectFixture,@@ -344,6 +346,59 @@ describe.each(["github", "gitea"] as const)(expect((await task(fixture.unrelated.id))?.status).toBe("to-do");});+ it("links a PR whose description contains the task link", async () => {+ const taskLink = `https://kaneo.example.com/dashboard/workspace/w/project/${fixture.project.id}/task/${fixture.intended.id}`;+ await open(payload("Copy message text", `Implements ${taskLink}`));+ expect(await links()).toMatchObject([{ taskId: fixture.intended.id }]);+ expect((await task(fixture.unrelated.id))?.status).toBe("to-do");+ });++ it("prefers a mapped issue reference over a task link", async () => {+ await linkIssue(fixture.intended.id);+ const taskLink = `https://kaneo.example.com/dashboard/workspace/w/project/${fixture.project.id}/task/${fixture.unrelated.id}`;+ await open(payload("Copy message text", `Closes #61\n\n${taskLink}`));+ expect(await links()).toMatchObject([{ taskId: fixture.intended.id }]);+ });++ it("skips a PR that links two tasks", async () => {+ const taskLink = (id: string) =>+ `https://kaneo.example.com/dashboard/workspace/w/project/${fixture.project.id}/task/${id}`;+ await open(+ payload(+ "Copy message text",+ `${taskLink(fixture.intended.id)} ${taskLink(fixture.unrelated.id)}`,+ ),+ );+ await expectUnchanged();+ });++ it("skips a PR that also links a task in another project", async () => {+ const other = await createFixture(provider, "OTHER", "other-repo");+ const taskLink = (projectId: string, taskId: string) =>+ `https://kaneo.example.com/dashboard/workspace/w/project/${projectId}/task/${taskId}`;+ await open(+ payload(+ "Copy message text",+ `${taskLink(fixture.project.id, fixture.intended.id)} ${taskLink(other.project.id, other.intended.id)}`,+ ),+ );+ await expectUnchanged();+ });++ it("falls back to the task link when the task key is stale", async () => {+ const taskLink = `https://kaneo.example.com/dashboard/workspace/w/project/${fixture.project.id}/task/${fixture.intended.id}`;+ await open(payload("KAN-999: copy message text", taskLink));+ expect(await links()).toMatchObject([{ taskId: fixture.intended.id }]);+ });++ it("does not follow a task link into another project", async () => {+ const other = await createFixture(provider, "OTHER", "other-repo");+ const taskLink = `https://kaneo.example.com/dashboard/workspace/w/project/${other.project.id}/task/${other.intended.id}`;+ await open(payload("Copy message text", taskLink));+ await expectUnchanged();+ expect((await task(other.intended.id))?.status).toBe("to-do");+ });+it("does not infer a local task from an unmapped remote issue", async () => {await open();await expectUnchanged();@@ -418,7 +473,7 @@ describe.each(["github", "gitea"] as const)(expect((await task(fixture.unrelated.id))?.status).toBe("to-do");});- it("links a final task without moving it back to review", async () => {+ it("moves a completed task back to review when a new PR opens", async () => {await linkIssue(fixture.intended.id);await db.update(schema.taskTable)@@ -426,7 +481,59 @@ describe.each(["github", "gitea"] as const)(.where(eq(schema.taskTable.id, fixture.intended.id));await open();expect(await links()).toMatchObject([{ taskId: fixture.intended.id }]);- expect((await task(fixture.intended.id))?.status).toBe("done");+ expect(await task(fixture.intended.id)).toMatchObject({+ status: "in-review",+ columnId: fixture.columns.inReview.id,+ });+ });++ describe("pushes to a completed task", () => {+ const branch = "kan-42-slice-2";+ const push = (after?: string) => {+ const { installation, repository } = payload();+ const event = {+ after,+ ref: `refs/heads/${branch}`,+ installation,+ repository,+ };+ return provider === "github"+ ? handlePush(event)+ : handleGiteaPush(event, fixture.integration.id);+ };+ const complete = () =>+ db+ .update(schema.taskTable)+ .set({ status: "done", columnId: fixture.columns.done.id })+ .where(eq(schema.taskTable.id, fixture.intended.id));++ beforeEach(complete);++ it("moves the task back to progress for a new branch", async () => {+ await push();+ expect((await task(fixture.intended.id))?.status).toBe("in-progress");+ });++ it("ignores a tag push", async () => {+ const { installation, repository } = payload();+ const event = { ref: "refs/tags/kan-42", installation, repository };+ await (provider === "github"+ ? handlePush(event)+ : handleGiteaPush(event, fixture.integration.id));+ expect((await task(fixture.intended.id))?.status).toBe("done");+ });++ it("ignores a push that deletes the branch", async () => {+ await push("0".repeat(40));+ expect((await task(fixture.intended.id))?.status).toBe("done");+ });++ it("keeps the task done for a push to an already linked branch", async () => {+ await push();+ await complete();+ await push();+ expect((await task(fixture.intended.id))?.status).toBe("done");+ });});it("skips ambiguous candidates across repository integrations for an unscoped delivery", async () => {diff --git a/tests/api/plugins/github/issue-reopened.test.ts b/tests/api/plugins/github/issue-reopened.test.tsindex 8f360ce5c..a65535a44 100644--- a/tests/api/plugins/github/issue-reopened.test.ts+++ b/tests/api/plugins/github/issue-reopened.test.ts@@ -88,3 +88,14 @@ it("retains the Kaneo-origin skip rule for valid metadata", async () => {expect(m.update).not.toHaveBeenCalled();expect(m.status).not.toHaveBeenCalled();});+it("skips a reopen that Kaneo already applied", async () => {+ m.find.mockResolvedValue([{ id: "integration-1" }]);+ m.links.mockResolvedValue({+ id: "first",+ taskId: "task",+ metadata: '{"state":"open"}',+ });+ await handleIssueReopened(payload);+ expect(m.update).not.toHaveBeenCalled();+ expect(m.status).not.toHaveBeenCalled();+});diff --git a/tests/api/plugins/github/utils/task-references.test.ts b/tests/api/plugins/github/utils/task-references.test.tsnew file mode 100644index 000000000..98c1d7922--- /dev/null+++ b/tests/api/plugins/github/utils/task-references.test.ts@@ -0,0 +1,34 @@+import { describe, expect, it } from "vite-plus/test";+import { extractTaskLinks } from "../../../../../apps/api/src/plugins/github/utils/task-references";++const link = (projectId: string, taskId: string) =>+ `https://kaneo.example.com/dashboard/workspace/ws1/project/${projectId}/task/${taskId}`;++describe("extractTaskLinks", () => {+ it("extracts task links from every text", () => {+ expect(+ extractTaskLinks(+ "Title",+ `Implements ${link("p1", "t1")}.\n\nSee (${link("p2", "t2")})`,+ ),+ ).toEqual([+ { projectId: "p1", taskId: "t1" },+ { projectId: "p2", taskId: "t2" },+ ]);+ });++ it("ignores paths that are not task links", () => {+ expect(+ extractTaskLinks(+ "https://example.com/docs/project/p1/task/t1",+ "/workspace/ws1/project/p1/task/t1",+ ),+ ).toEqual([]);+ });++ it("deduplicates and tolerates missing text", () => {+ expect(extractTaskLinks(link("p1", "t1"), null, link("p1", "t1"))).toEqual([+ { projectId: "p1", taskId: "t1" },+ ]);+ });+});