⚡ 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
fix(board): guard partial list drags and complete live updates
Tinf5ff90ca9d0a
diff --git a/apps/api/src/plugins/gitea/webhooks/issue-edited.ts b/apps/api/src/plugins/gitea/webhooks/issue-edited.tsindex b609982eb..cbd66b218 100644--- a/apps/api/src/plugins/gitea/webhooks/issue-edited.ts+++ b/apps/api/src/plugins/gitea/webhooks/issue-edited.ts@@ -1,3 +1,4 @@+import { publishEvent } from "../../../events";import { eq } from "drizzle-orm";import db from "../../../database";import { taskTable } from "../../../database/schema";@@ -153,6 +154,9 @@ export async function handleGiteaIssueEdited(title: issue.title,metadata: updatedMetadata,});+ await publishEvent("project.updated", {+ projectId: integration.projectId,+ });}return;diff --git a/apps/api/src/plugins/gitea/webhooks/issue-labeled.ts b/apps/api/src/plugins/gitea/webhooks/issue-labeled.tsindex f0057cba4..57f859996 100644--- a/apps/api/src/plugins/gitea/webhooks/issue-labeled.ts+++ b/apps/api/src/plugins/gitea/webhooks/issue-labeled.ts@@ -190,15 +190,26 @@ export async function handleGiteaIssueLabeled(task.project.workspaceId,giteaLabelsForSync(issue.labels),);+ await publishEvent("project.updated", {+ projectId: integration.projectId,+ });}continue;}if (!addedLabel) {+ if (priority)+ await publishEvent("project.updated", {+ projectId: integration.projectId,+ });continue;}if (isSystemLabelName(addedLabel.name)) {+ if (priority)+ await publishEvent("project.updated", {+ projectId: integration.projectId,+ });continue;}@@ -252,6 +263,9 @@ export async function handleGiteaIssueLabeled(await db.delete(labelTable).where(eq(labelTable.id, label.id));}}+ await publishEvent("project.updated", {+ projectId: integration.projectId,+ });} catch (error) {console.error("Gitea issue_labeled handler failed for integration", {integrationId: integration.id,diff --git a/apps/api/src/plugins/github/webhooks/issue-edited.ts b/apps/api/src/plugins/github/webhooks/issue-edited.tsindex 8847206bc..86bcc2312 100644--- a/apps/api/src/plugins/github/webhooks/issue-edited.ts+++ b/apps/api/src/plugins/github/webhooks/issue-edited.ts@@ -1,3 +1,4 @@+import { publishEvent } from "../../../events";import { eq } from "drizzle-orm";import db from "../../../database";import { taskTable } from "../../../database/schema";@@ -181,6 +182,9 @@ export async function handleIssueEdited(payload: IssueEditedPayload) {title: issue.title,metadata: updatedMetadata,});+ await publishEvent("project.updated", {+ projectId: integration.projectId,+ });console.log(`Synced ${Object.keys(updateData).join(", ")} from GitHub issue #${issue.number} to task ${task.id}`,diff --git a/apps/api/src/plugins/github/webhooks/issue-labeled.ts b/apps/api/src/plugins/github/webhooks/issue-labeled.tsindex 63252bec6..d2a98c398 100644--- a/apps/api/src/plugins/github/webhooks/issue-labeled.ts+++ b/apps/api/src/plugins/github/webhooks/issue-labeled.ts@@ -76,6 +76,10 @@ export async function handleIssueLabeled(payload: IssueLabeledPayload) {}if (!addedLabel) {+ if (priority)+ await publishEvent("project.updated", {+ projectId: integration.projectId,+ });return;}@@ -84,6 +88,10 @@ export async function handleIssueLabeled(payload: IssueLabeledPayload) {addedLabel.name.startsWith("status:");if (isSystemLabel) {+ if (priority)+ await publishEvent("project.updated", {+ projectId: integration.projectId,+ });return;}@@ -136,6 +144,7 @@ export async function handleIssueLabeled(payload: IssueLabeledPayload) {}}+ await publishEvent("project.updated", { projectId: integration.projectId });return;}}diff --git a/apps/api/src/plugins/gitlab/webhooks/issue-updated.ts b/apps/api/src/plugins/gitlab/webhooks/issue-updated.tsindex ba3375d71..f471f51f8 100644--- a/apps/api/src/plugins/gitlab/webhooks/issue-updated.ts+++ b/apps/api/src/plugins/gitlab/webhooks/issue-updated.ts@@ -216,6 +216,9 @@ export async function handleGitlabIssueUpdated(title: issue.title,metadata,});+ await publishEvent("project.updated", {+ projectId: integration.projectId,+ });}}@@ -266,6 +269,9 @@ export async function handleGitlabIssueUpdated(nonSystemLabels(currentLabels),changes?.labels?.previous,);+ await publishEvent("project.updated", {+ projectId: integration.projectId,+ });}} catch (error) {console.error("GitLab issue update handler failed for integration", {diff --git a/apps/web/src/components/list-view/index.test.tsx b/apps/web/src/components/list-view/index.test.tsxnew file mode 100644index 000000000..bb6dc1dee--- /dev/null+++ b/apps/web/src/components/list-view/index.test.tsx@@ -0,0 +1,71 @@+import { act, cleanup, render } from "@testing-library/react";+import { afterEach, expect, it, vi } from "vite-plus/test";+import type { DragEndEvent } from "@dnd-kit/core";+import type { ProjectWithTasks } from "@/types/project";+import ListView from "./index";+const m = vi.hoisted(() => ({+ props: {} as {+ sensors?: unknown[];+ onDragEnd?: (event: DragEndEvent) => void;+ },+ mutate: vi.fn(),+ setProject: vi.fn(),+}));+vi.mock("@dnd-kit/core", async (original) => ({+ ...(await original<typeof import("@dnd-kit/core")>()),+ DndContext: (props: typeof m.props & { children: React.ReactNode }) => {+ m.props = props;+ return props.children;+ },+}));+vi.mock("@tanstack/react-router", () => ({ useNavigate: () => vi.fn() }));+vi.mock("@/hooks/use-keyboard-shortcuts", () => ({+ useRegisterShortcuts: () => {},+}));+vi.mock("@/hooks/mutations/task/use-update-task", () => ({+ useUpdateTask: () => ({ mutate: m.mutate }),+}));+vi.mock("@/store/project", () => ({+ default: () => ({ setProject: m.setProject }),+}));+vi.mock("./task-row", () => ({ default: () => null }));+vi.mock("../bulk-selection/bulk-toolbar", () => ({ default: () => null }));+vi.mock("../shared/modals/create-task-modal", () => ({ default: () => null }));+vi.mock("../shared/modals/archive-tasks-modal", () => ({+ ArchiveTasksModal: () => null,+}));+afterEach(() => {+ cleanup();+ vi.clearAllMocks();+});+it("disables keyboard sensors and rejects drag completion on a partial board", () => {+ const project = {+ id: "p",+ workspaceId: "w",+ columns: [+ {+ id: "todo",+ slug: "todo",+ name: "To do",+ tasks: [+ { id: "a", position: 0 },+ { id: "b", position: 1 },+ ],+ },+ ],+ plannedTasks: [],+ archivedTasks: [],+ } as unknown as ProjectWithTasks;+ const { rerender } = render(<ListView project={project} />);+ expect(m.props.sensors?.length).toBeGreaterThan(0);+ rerender(<ListView project={project} disableDragDrop />);+ expect(m.props.sensors).toEqual([]);+ act(() =>+ m.props.onDragEnd?.({+ active: { id: "a" },+ over: { id: "b" },+ } as DragEndEvent),+ );+ expect(m.mutate).not.toHaveBeenCalled();+ expect(m.setProject).not.toHaveBeenCalled();+});diff --git a/apps/web/src/components/list-view/index.tsx b/apps/web/src/components/list-view/index.tsxindex 9246252a5..42ed9e905 100644--- a/apps/web/src/components/list-view/index.tsx+++ b/apps/web/src/components/list-view/index.tsx@@ -133,6 +133,7 @@ function ListView({ project, disableDragDrop = false }: ListViewProps) {);const handleDragStart = (event: DragStartEvent) => {+ if (disableDragDrop) return;setActiveId(event.active.id);};@@ -165,7 +166,7 @@ function ListView({ project, disableDragDrop = false }: ListViewProps) {setActiveId(null);setOverColumnId(null);- if (!over || !project?.columns) return;+ if (disableDragDrop || !over || !project?.columns) return;const activeTaskId = active.id.toString();const overId = over.id.toString();@@ -397,7 +398,7 @@ function ListView({ project, disableDragDrop = false }: ListViewProps) {return (<DndContext- sensors={sensors}+ sensors={disableDragDrop ? [] : sensors}collisionDetection={closestCorners}onDragStart={handleDragStart}onDragOver={handleDragOver}diff --git a/apps/web/src/hooks/use-project-websocket-cache.test.tsx b/apps/web/src/hooks/use-project-websocket-cache.test.tsxindex b4ec76e64..b4086c6f7 100644--- a/apps/web/src/hooks/use-project-websocket-cache.test.tsx+++ b/apps/web/src/hooks/use-project-websocket-cache.test.tsx@@ -414,3 +414,17 @@ it.each(["TASK_CREATED", "TASK_DELETED", "TASK_MOVED", "TASKS_REORDERED"])(expect(mocks.getTask).not.toHaveBeenCalled();},);++it.each(["TASK_UPDATED", "TASK_CREATED", "TASK_MOVED", "TASK_LABEL_UPDATED"])(+ "keeps detail invalidation without board-only reads for %s",+ (type) => {+ mocks.board = undefined;+ mocks.getTask.mockReset();+ renderHook(() => useProjectWebSocket("p"));+ Socket.current.message(type, { taskId: "a" });+ expect(mocks.getTask).not.toHaveBeenCalled();+ expect(mocks.client.invalidateQueries).toHaveBeenCalledWith({+ queryKey: ["task", "a"],+ });+ },+);diff --git a/apps/web/src/hooks/use-project-websocket.test.ts b/apps/web/src/hooks/use-project-websocket.test.tsindex e5c876a15..b0eeb7e9b 100644--- a/apps/web/src/hooks/use-project-websocket.test.ts+++ b/apps/web/src/hooks/use-project-websocket.test.ts@@ -22,6 +22,7 @@ vi.mock("@tanstack/react-query", () => ({invalidateQueries,getQueryCache: () => ({ subscribe: () => () => {} }),getQueryState,+ getQueryData: () => undefined,cancelQueries,}),}));diff --git a/apps/web/src/hooks/use-project-websocket.ts b/apps/web/src/hooks/use-project-websocket.tsindex 618b76516..4c6c52f26 100644--- a/apps/web/src/hooks/use-project-websocket.ts+++ b/apps/web/src/hooks/use-project-websocket.ts@@ -246,6 +246,9 @@ export function useProjectWebSocket(projectId: string) {(board) =>board ? (patchBoardTask(board, taskId) ?? board) : board,);+ } else if (!queryClient.getQueryData(["tasks", projectId])) {+ // Calendar, backlog and detail-only views have no board to+ // patch. Their active detail queries are invalidated below.} else if (refreshingTasks.size >= 4 ||refreshingTasks.has(taskId) ||diff --git a/tests/api-integration/provider-board-live-updates.test.ts b/tests/api-integration/provider-board-live-updates.test.tsnew file mode 100644index 000000000..a7abe0b80--- /dev/null+++ b/tests/api-integration/provider-board-live-updates.test.ts@@ -0,0 +1,193 @@+import { beforeEach, expect, it, vi } from "vite-plus/test";+import { eq } from "drizzle-orm";+import db, { schema } from "../../apps/api/src/database";+import { handleIssueEdited } from "../../apps/api/src/plugins/github/webhooks/issue-edited";+import { handleIssueLabeled } from "../../apps/api/src/plugins/github/webhooks/issue-labeled";+import { handleGiteaIssueEdited } from "../../apps/api/src/plugins/gitea/webhooks/issue-edited";+import { handleGiteaIssueLabeled } from "../../apps/api/src/plugins/gitea/webhooks/issue-labeled";+import { handleGitlabIssueUpdated } from "../../apps/api/src/plugins/gitlab/webhooks/issue-updated";+import { resetTestDatabase } from "./helpers/database";+import {+ createWorkspaceMember,+ createProjectFixture,+} from "./helpers/fixtures";+const m = vi.hoisted(() => ({+ integrations: [] as unknown[],+ publish: vi.fn(async () => {}),+}));+vi.mock("../../apps/api/src/events", () => ({ publishEvent: m.publish }));+vi.mock(+ "../../apps/api/src/plugins/github/services/task-service",+ async (original) => ({+ ...(await original<+ typeof import("../../apps/api/src/plugins/github/services/task-service")+ >()),+ findAllIntegrationsByRepo: async () => m.integrations,+ }),+);+vi.mock(+ "../../apps/api/src/plugins/gitea/services/integration-lookup",+ async (original) => ({+ ...(await original<+ typeof import("../../apps/api/src/plugins/gitea/services/integration-lookup")+ >()),+ findAllIntegrationsByGiteaRepo: async () => m.integrations,+ }),+);+vi.mock(+ "../../apps/api/src/plugins/gitlab/services/integration-lookup",+ async (original) => ({+ ...(await original<+ typeof import("../../apps/api/src/plugins/gitlab/services/integration-lookup")+ >()),+ findAllIntegrationsByGitlabProject: async () => m.integrations,+ }),+);+beforeEach(async () => {+ await resetTestDatabase();+ m.publish.mockClear();+});+it.each([+ ["github", "text"],+ ["gitea", "text"],+ ["gitlab", "text"],+ ["github", "priority"],+ ["gitea", "priority"],+ ["gitlab", "priority"],+ ["github", "label"],+ ["gitea", "label"],+ ["gitlab", "label"],+ ["github", "label-delete"],+ ["gitea", "label-delete"],+ ["gitlab", "label-delete"],+])(+ "announces committed %s %s edits to observing boards",+ async (provider, kind) => {+ const { workspace } = await createWorkspaceMember();+ const { project } = await createProjectFixture({+ workspaceId: workspace.id,+ });+ const [task] = await db+ .insert(schema.taskTable)+ .values({+ projectId: project.id,+ number: 1,+ title: "Before",+ description: "Before body",+ priority: "low",+ })+ .returning();+ const [integration] = await db+ .insert(schema.integrationTable)+ .values({+ projectId: project.id,+ type: provider,+ config: "{}",+ isActive: true,+ })+ .returning();+ m.integrations = [integration];+ await db.insert(schema.externalLinkTable).values({+ taskId: task.id,+ integrationId: integration.id,+ resourceType: "issue",+ externalId: "1",+ url: "https://provider.example/issues/1",+ metadata: "{}",+ });+ if (kind === "label-delete")+ await db.insert(schema.labelTable).values({+ taskId: task.id,+ workspaceId: workspace.id,+ name: "bug",+ color: "#ff0000",+ });+ const issue = {+ number: 1,+ title: "After",+ body: "After body",+ html_url: "https://gitea.example/owner/repo/issues/1",+ };+ const repository = {+ id: 2,+ name: "repo",+ full_name: "owner/repo",+ owner: { login: "owner" },+ html_url: "https://gitea.example/owner/repo",+ };+ if (provider === "github" || provider === "gitea") {+ if (kind === "text") {+ const payload = {+ action: "edited",+ issue,+ repository,+ changes: { title: { from: "Before" }, body: { from: "Before body" } },+ };+ if (provider === "github") await handleIssueEdited(payload);+ else await handleGiteaIssueEdited(payload);+ } else {+ const label = {+ name: kind === "priority" ? "priority:high" : "bug",+ color: "ff0000",+ };+ const payload = {+ action: kind === "label-delete" ? "unlabeled" : "labeled",+ issue: { ...issue, labels: kind === "label-delete" ? [] : [label] },+ label,+ repository,+ };+ if (provider === "github") await handleIssueLabeled(payload);+ else await handleGiteaIssueLabeled(payload);+ }+ } else {+ const label = {+ title: kind === "priority" ? "priority:high" : "bug",+ color: "#ff0000",+ };+ await handleGitlabIssueUpdated({+ object_attributes: {+ iid: 1,+ title: "After",+ description: "After body",+ url: "https://gitlab.example/owner/repo/-/issues/1",+ action: "update",+ },+ changes:+ kind === "text"+ ? {+ title: { previous: "Before", current: "After" },+ description: { previous: "Before body", current: "After body" },+ }+ : {+ labels: {+ previous: kind === "label-delete" ? [label] : [],+ current: kind === "label-delete" ? [] : [label],+ },+ },+ project: {+ name: "repo",+ web_url: "https://gitlab.example/owner/repo",+ path_with_namespace: "owner/repo",+ },+ });+ }+ const saved = await db.query.taskTable.findFirst({+ where: eq(schema.taskTable.id, task.id),+ });+ if (kind === "text") {+ expect(saved?.title).toBe("After");+ expect(saved?.description).toBe("After body");+ } else if (kind === "priority") expect(saved?.priority).toBe("high");+ else {+ const labels = await db.query.labelTable.findMany({+ where: eq(schema.labelTable.taskId, task.id),+ });+ expect(labels.map((label) => label.name)).toEqual(+ kind === "label-delete" ? [] : ["bug"],+ );+ }+ expect(+ m.publish.mock.calls.filter(([name]) => name === "project.updated"),+ ).toEqual([["project.updated", { projectId: project.id }]]);+ },+);