⚡ 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(integrations): refresh comparisons and repair paused rules
Tin5f8045634d09
diff --git a/apps/api/src/integration-sync/controllers/resume-sync.ts b/apps/api/src/integration-sync/controllers/resume-sync.tsindex 7c94f5165..d4795b309 100644--- a/apps/api/src/integration-sync/controllers/resume-sync.ts+++ b/apps/api/src/integration-sync/controllers/resume-sync.ts@@ -106,6 +106,9 @@ async function resumeWithLease(await updateExternalLink(linkId,{+ ...(field === "title"+ ? { title: review[source === "kaneo" ? "local" : "remote"].title }+ : {}),...(source === "kaneo" && provider !== "gitlab"? {outbound: {@@ -158,7 +161,11 @@ async function resumeWithLease(},}: {}),- state: review[source === "kaneo" ? "local" : "remote"].state,+ state:+ provider === "gitlab" &&+ review[source === "kaneo" ? "local" : "remote"].state === "open"+ ? "opened"+ : review[source === "kaneo" ? "local" : "remote"].state,},retireUncertainOutbound: field,},diff --git a/apps/web/src/components/project/sync-rules/label-rule-editor.tsx b/apps/web/src/components/project/sync-rules/label-rule-editor.tsxindex 545d2f239..9d59f2c18 100644--- a/apps/web/src/components/project/sync-rules/label-rule-editor.tsx+++ b/apps/web/src/components/project/sync-rules/label-rule-editor.tsx@@ -29,6 +29,7 @@ export function LabelRuleEditor({const id = useId();const [labelName, setLabelName] = useState("");const outgoing = direction === "outgoing";+ const availableLabelIds = new Set(labels.map((label) => label.id));const addLabel = () => {const name = labelName.trim();if (@@ -118,6 +119,22 @@ export function LabelRuleEditor({{t("settings:syncRules.noLabels")}</p>)}+ {rule.labels.some((id) => !availableLabelIds.has(id)) && (+ <Button+ size="xs"+ variant="outline"+ onClick={() =>+ onChange({+ ...rule,+ labels: rule.labels.filter((id) =>+ availableLabelIds.has(id),+ ),+ })+ }+ >+ {t("settings:syncRules.removeMissingLabels")}+ </Button>+ )}{labels.map((label) => (<Labelkey={label.id}diff --git a/apps/web/src/components/project/sync-rules/sync-rules.test.tsx b/apps/web/src/components/project/sync-rules/sync-rules.test.tsxindex 77010245e..2ac7fd782 100644--- a/apps/web/src/components/project/sync-rules/sync-rules.test.tsx+++ b/apps/web/src/components/project/sync-rules/sync-rules.test.tsx@@ -107,6 +107,83 @@ function mount(node = <SyncRulesSection {...param} />) {}describe("advanced sync settings", () => {+ it("removes unavailable labels without resetting valid selections or match mode", async () => {+ useUserPreferencesStore.setState({ advancedSettings: true });+ mocks.get.mockResolvedValue({+ ...saved,+ missingLabels: ["deleted-label"],+ rules: {+ ...saved.rules,+ outgoing: {+ mode: "labels",+ match: "all",+ labels: ["label-1", "deleted-label"],+ },+ },+ });+ mount();+ fireEvent.click(+ await screen.findByRole("button", {+ name: "settings:syncRules.removeMissingLabels",+ }),+ );+ expect(screen.getByRole("checkbox", { name: "sync" })).toBeChecked();+ const apply = screen.getByRole("button", {+ name: "settings:syncRules.apply",+ });+ await waitFor(() => expect(apply).toBeEnabled());+ fireEvent.click(apply);+ await waitFor(() =>+ expect(mocks.save).toHaveBeenCalledWith(+ param,+ {+ ...saved.rules,+ outgoing: { mode: "labels", match: "all", labels: ["label-1"] },+ },+ "b".repeat(64),+ ),+ );+ });++ it("refreshes an open comparison and submits its new token after invalidation", async () => {+ const { client } = mount(+ <ResumeSyncDialog param={param} linkId="link-1" onClose={vi.fn()} />,+ );+ await screen.findByText("Kaneo title");+ mocks.review.mockResolvedValueOnce({+ task: { id: "task-1", number: 1, title: "Kaneo task" },+ local: {+ title: "Live Kaneo title",+ description: "Local body",+ state: "open",+ },+ remote: {+ title: "Repository title",+ description: "Remote body",+ state: "closed",+ },+ token: "d".repeat(64),+ });+ await act(async () => {+ await client.invalidateQueries({+ queryKey: ["integration-sync-review", param.projectId],+ });+ });+ expect(await screen.findByText("Live Kaneo title")).toBeVisible();+ expect(screen.queryByText("Kaneo title")).toBeNull();+ fireEvent.click(+ screen.getByRole("button", { name: "settings:syncRules.useKaneo" }),+ );+ await waitFor(() =>+ expect(mocks.resume).toHaveBeenCalledWith(+ param,+ "link-1",+ "d".repeat(64),+ "kaneo",+ ),+ );+ });+it("refreshes cached issue metadata after saving rules", async () => {useUserPreferencesStore.setState({ advancedSettings: true });mocks.get.mockResolvedValue({ ...saved, willCreate: 1 });diff --git a/apps/web/src/hooks/use-project-websocket-cache.test.tsx b/apps/web/src/hooks/use-project-websocket-cache.test.tsxindex aaf3578ad..3f3610a1a 100644--- a/apps/web/src/hooks/use-project-websocket-cache.test.tsx+++ b/apps/web/src/hooks/use-project-websocket-cache.test.tsx@@ -503,5 +503,8 @@ it.each([expect(mocks.client.invalidateQueries).toHaveBeenCalledWith({queryKey: ["integration-sync-preview", "p"],});+ expect(mocks.client.invalidateQueries).toHaveBeenCalledWith({+ queryKey: ["integration-sync-review", "p"],+ });});});diff --git a/apps/web/src/hooks/use-project-websocket.ts b/apps/web/src/hooks/use-project-websocket.tsindex 503918ec0..34980613a 100644--- a/apps/web/src/hooks/use-project-websocket.ts+++ b/apps/web/src/hooks/use-project-websocket.ts@@ -86,6 +86,9 @@ export function useProjectWebSocket(projectId: string) {queryClient.invalidateQueries({queryKey: ["integration-sync-preview", projectId],});+ queryClient.invalidateQueries({+ queryKey: ["integration-sync-review", projectId],+ });}if (message.type === "PROJECT_UPDATED") {queryClient.invalidateQueries({ queryKey: ["projects"] });diff --git a/i18n/az-AZ.json b/i18n/az-AZ.jsonindex a0f2529e0..34ae6a912 100644--- a/i18n/az-AZ.json+++ b/i18n/az-AZ.json@@ -1895,6 +1895,7 @@"loading": "Loading sync rules…","matchLabels": "Label matching","missingLabels": "A selected workspace label is unavailable. Sync stays paused until the rule is repaired.",+ "removeMissingLabels": "Əlçatan olmayan etiketləri sil","next": "Next","noDescription": "No description","noLabels": "Create workspace labels before configuring a task filter.",diff --git a/i18n/de-DE.json b/i18n/de-DE.jsonindex 9fe2fcec2..22ba25580 100644--- a/i18n/de-DE.json+++ b/i18n/de-DE.json@@ -1895,6 +1895,7 @@"loading": "Synchronisierungsregeln werden geladen…","matchLabels": "Labelübereinstimmung","missingLabels": "Ein ausgewähltes Workspace-Label ist nicht verfügbar. Die Synchronisierung bleibt pausiert, bis die Regel korrigiert wird.",+ "removeMissingLabels": "Nicht verfügbare Labels entfernen","next": "Weiter","noDescription": "Keine Beschreibung","noLabels": "Erstelle zuerst Workspace-Labels, um einen Aufgabenfilter einzurichten.",diff --git a/i18n/el-GR.json b/i18n/el-GR.jsonindex 17710cd3b..fd6eab7f6 100644--- a/i18n/el-GR.json+++ b/i18n/el-GR.json@@ -1895,6 +1895,7 @@"loading": "Loading sync rules…","matchLabels": "Label matching","missingLabels": "A selected workspace label is unavailable. Sync stays paused until the rule is repaired.",+ "removeMissingLabels": "Αφαίρεση μη διαθέσιμων ετικετών","next": "Next","noDescription": "No description","noLabels": "Create workspace labels before configuring a task filter.",diff --git a/i18n/en-US.json b/i18n/en-US.jsonindex c1059f8d4..1c29a3db1 100644--- a/i18n/en-US.json+++ b/i18n/en-US.json@@ -452,6 +452,7 @@"saveError": "Could not apply these rules. The integration or task scope may have changed. Refresh the preview and try again.","refreshPreview": "Refresh preview","missingLabels": "A selected workspace label is unavailable. Sync stays paused until the rule is repaired.",+ "removeMissingLabels": "Remove unavailable labels","apply": "Apply sync rules","saved": "Sync rules saved","loading": "Loading sync rules…",diff --git a/i18n/es-ES.json b/i18n/es-ES.jsonindex 2b3275d2e..4b5e9e0a4 100644--- a/i18n/es-ES.json+++ b/i18n/es-ES.json@@ -1902,6 +1902,7 @@"loading": "Loading sync rules…","matchLabels": "Label matching","missingLabels": "A selected workspace label is unavailable. Sync stays paused until the rule is repaired.",+ "removeMissingLabels": "Eliminar etiquetas no disponibles","next": "Next","noDescription": "No description","noLabels": "Create workspace labels before configuring a task filter.",diff --git a/i18n/fr-FR.json b/i18n/fr-FR.jsonindex ec10040fa..d7911b094 100644--- a/i18n/fr-FR.json+++ b/i18n/fr-FR.json@@ -1902,6 +1902,7 @@"loading": "Loading sync rules…","matchLabels": "Label matching","missingLabels": "A selected workspace label is unavailable. Sync stays paused until the rule is repaired.",+ "removeMissingLabels": "Supprimer les étiquettes indisponibles","next": "Next","noDescription": "No description","noLabels": "Create workspace labels before configuring a task filter.",diff --git a/i18n/hi-IN.json b/i18n/hi-IN.jsonindex c1293d270..7e98a45a5 100644--- a/i18n/hi-IN.json+++ b/i18n/hi-IN.json@@ -1895,6 +1895,7 @@"loading": "Loading sync rules…","matchLabels": "Label matching","missingLabels": "A selected workspace label is unavailable. Sync stays paused until the rule is repaired.",+ "removeMissingLabels": "अनुपलब्ध लेबल हटाएँ","next": "Next","noDescription": "No description","noLabels": "Create workspace labels before configuring a task filter.",diff --git a/i18n/id-ID.json b/i18n/id-ID.jsonindex 250beaf0d..9faf5bd9b 100644--- a/i18n/id-ID.json+++ b/i18n/id-ID.json@@ -1888,6 +1888,7 @@"loading": "Loading sync rules…","matchLabels": "Label matching","missingLabels": "A selected workspace label is unavailable. Sync stays paused until the rule is repaired.",+ "removeMissingLabels": "Hapus label yang tidak tersedia","next": "Next","noDescription": "No description","noLabels": "Create workspace labels before configuring a task filter.",diff --git a/i18n/it-IT.json b/i18n/it-IT.jsonindex d8caa3ccd..3eaddb124 100644--- a/i18n/it-IT.json+++ b/i18n/it-IT.json@@ -1902,6 +1902,7 @@"loading": "Loading sync rules…","matchLabels": "Label matching","missingLabels": "A selected workspace label is unavailable. Sync stays paused until the rule is repaired.",+ "removeMissingLabels": "Rimuovi etichette non disponibili","next": "Next","noDescription": "No description","noLabels": "Create workspace labels before configuring a task filter.",diff --git a/i18n/ja-JP.json b/i18n/ja-JP.jsonindex a6b6ec41f..f1b78048c 100644--- a/i18n/ja-JP.json+++ b/i18n/ja-JP.json@@ -1888,6 +1888,7 @@"loading": "Loading sync rules…","matchLabels": "Label matching","missingLabels": "A selected workspace label is unavailable. Sync stays paused until the rule is repaired.",+ "removeMissingLabels": "利用できないラベルを削除","next": "Next","noDescription": "No description","noLabels": "Create workspace labels before configuring a task filter.",diff --git a/i18n/ko-KR.json b/i18n/ko-KR.jsonindex 5db079387..915817bff 100644--- a/i18n/ko-KR.json+++ b/i18n/ko-KR.json@@ -1888,6 +1888,7 @@"loading": "Loading sync rules…","matchLabels": "Label matching","missingLabels": "A selected workspace label is unavailable. Sync stays paused until the rule is repaired.",+ "removeMissingLabels": "사용할 수 없는 라벨 제거","next": "Next","noDescription": "No description","noLabels": "Create workspace labels before configuring a task filter.",diff --git a/i18n/mk-MK.json b/i18n/mk-MK.jsonindex e7d1fa4fa..c85ee6d00 100644--- a/i18n/mk-MK.json+++ b/i18n/mk-MK.json@@ -1895,6 +1895,7 @@"loading": "Loading sync rules…","matchLabels": "Label matching","missingLabels": "A selected workspace label is unavailable. Sync stays paused until the rule is repaired.",+ "removeMissingLabels": "Отстрани недостапни ознаки","next": "Next","noDescription": "No description","noLabels": "Create workspace labels before configuring a task filter.",diff --git a/i18n/nl-NL.json b/i18n/nl-NL.jsonindex 523d469e6..89f6c4c77 100644--- a/i18n/nl-NL.json+++ b/i18n/nl-NL.json@@ -1895,6 +1895,7 @@"loading": "Loading sync rules…","matchLabels": "Label matching","missingLabels": "A selected workspace label is unavailable. Sync stays paused until the rule is repaired.",+ "removeMissingLabels": "Niet-beschikbare labels verwijderen","next": "Next","noDescription": "No description","noLabels": "Create workspace labels before configuring a task filter.",diff --git a/i18n/pl-PL.json b/i18n/pl-PL.jsonindex 113d511af..88dab863a 100644--- a/i18n/pl-PL.json+++ b/i18n/pl-PL.json@@ -2466,6 +2466,7 @@"loading": "Loading sync rules…","matchLabels": "Label matching","missingLabels": "A selected workspace label is unavailable. Sync stays paused until the rule is repaired.",+ "removeMissingLabels": "Usuń niedostępne etykiety","next": "Next","noDescription": "No description","noLabels": "Create workspace labels before configuring a task filter.",diff --git a/i18n/pt-BR.json b/i18n/pt-BR.jsonindex e400cb49e..9aa753720 100644--- a/i18n/pt-BR.json+++ b/i18n/pt-BR.json@@ -1902,6 +1902,7 @@"loading": "Loading sync rules…","matchLabels": "Label matching","missingLabels": "A selected workspace label is unavailable. Sync stays paused until the rule is repaired.",+ "removeMissingLabels": "Remover etiquetas indisponíveis","next": "Next","noDescription": "No description","noLabels": "Create workspace labels before configuring a task filter.",diff --git a/i18n/ru-RU.json b/i18n/ru-RU.jsonindex 489fdd286..66c968119 100644--- a/i18n/ru-RU.json+++ b/i18n/ru-RU.json@@ -1917,6 +1917,7 @@"loading": "Loading sync rules…","matchLabels": "Label matching","missingLabels": "A selected workspace label is unavailable. Sync stays paused until the rule is repaired.",+ "removeMissingLabels": "Удалить недоступные метки","next": "Next","noDescription": "No description","noLabels": "Create workspace labels before configuring a task filter.",diff --git a/i18n/schema.json b/i18n/schema.jsonindex b3cb2cc8b..8e23154e0 100644--- a/i18n/schema.json+++ b/i18n/schema.json@@ -1774,6 +1774,9 @@"missingLabels": {"type": "string"},+ "removeMissingLabels": {+ "type": "string"+ },"apply": {"type": "string"},@@ -1893,6 +1896,7 @@"saveError","refreshPreview","missingLabels",+ "removeMissingLabels","apply","saved","loading",diff --git a/i18n/tr-TR.json b/i18n/tr-TR.jsonindex 954639956..c7e3ffefe 100644--- a/i18n/tr-TR.json+++ b/i18n/tr-TR.json@@ -1895,6 +1895,7 @@"loading": "Loading sync rules…","matchLabels": "Label matching","missingLabels": "A selected workspace label is unavailable. Sync stays paused until the rule is repaired.",+ "removeMissingLabels": "Kullanılamayan etiketleri kaldır","next": "Next","noDescription": "No description","noLabels": "Create workspace labels before configuring a task filter.",diff --git a/i18n/uk-UA.json b/i18n/uk-UA.jsonindex 887732c71..7badbaef8 100644--- a/i18n/uk-UA.json+++ b/i18n/uk-UA.json@@ -1909,6 +1909,7 @@"loading": "Loading sync rules…","matchLabels": "Label matching","missingLabels": "A selected workspace label is unavailable. Sync stays paused until the rule is repaired.",+ "removeMissingLabels": "Видалити недоступні мітки","next": "Next","noDescription": "No description","noLabels": "Create workspace labels before configuring a task filter.",diff --git a/i18n/vi-VN.json b/i18n/vi-VN.jsonindex 13d171edf..bf5007f33 100644--- a/i18n/vi-VN.json+++ b/i18n/vi-VN.json@@ -1888,6 +1888,7 @@"loading": "Loading sync rules…","matchLabels": "Label matching","missingLabels": "A selected workspace label is unavailable. Sync stays paused until the rule is repaired.",+ "removeMissingLabels": "Xóa nhãn không khả dụng","next": "Next","noDescription": "No description","noLabels": "Create workspace labels before configuring a task filter.",diff --git a/i18n/zh-CN.json b/i18n/zh-CN.jsonindex 411333c1e..a853c9e9e 100644--- a/i18n/zh-CN.json+++ b/i18n/zh-CN.json@@ -1888,6 +1888,7 @@"loading": "Loading sync rules…","matchLabels": "Label matching","missingLabels": "A selected workspace label is unavailable. Sync stays paused until the rule is repaired.",+ "removeMissingLabels": "移除不可用的标签","next": "Next","noDescription": "No description","noLabels": "Create workspace labels before configuring a task filter.",diff --git a/tests/api-integration/integration-sync-rules.test.ts b/tests/api-integration/integration-sync-rules.test.tsindex 3ec8d842d..6f4d02ff0 100644--- a/tests/api-integration/integration-sync-rules.test.ts+++ b/tests/api-integration/integration-sync-rules.test.ts@@ -2,6 +2,7 @@ import { and, eq, sql } from "drizzle-orm";import { beforeEach, describe, expect, it, vi } from "vite-plus/test";import * as events from "../../apps/api/src/events";import * as assets from "../../apps/api/src/storage/cleanup-assets";+import { handleGitlabIssueReopened } from "../../apps/api/src/plugins/gitlab/webhooks/issue-reopened";import db, { schema } from "../../apps/api/src/database";import { createApp } from "../../apps/api/src/index";import { getSyncIntegration } from "../../apps/api/src/integration-sync/controllers/get-integration";@@ -609,6 +610,13 @@ describe("reviewed sync resume", () => {where: eq(schema.externalLinkTable.taskId, f.task.id),}),).toHaveLength(1);+ expect(+ (+ await db.query.externalLinkTable.findFirst({+ where: eq(schema.externalLinkTable.id, f.link.id),+ })+ )?.title,+ ).toBe("Repository title");});it("keeps Kaneo values only after the repository update succeeds", async () => {const f = await paused();@@ -620,6 +628,66 @@ describe("reviewed sync resume", () => {state: "open",});expect(await canSyncTask(f.task.id, f.integration.id)).toBe(true);+ expect(+ (+ await db.query.externalLinkTable.findFirst({+ where: eq(schema.externalLinkTable.id, f.link.id),+ })+ )?.title,+ ).toBe("Kaneo title");+ });+ it("preserves a GitLab task's chosen column through its reopen echo", async () => {+ const f = await paused();+ await db+ .update(schema.integrationTable)+ .set({+ type: "gitlab",+ config: JSON.stringify({+ baseUrl: "https://git.example",+ accessToken: "test-only",+ projectPath: "team/repo",+ syncRules: f.rules,+ }),+ })+ .where(eq(schema.integrationTable.id, f.integration.id));+ await db+ .update(schema.taskTable)+ .set({+ status: f.columns.inProgress.slug,+ columnId: f.columns.inProgress.id,+ })+ .where(eq(schema.taskTable.id, f.task.id));+ const review = await reviewSyncResume(f.project.id, "gitlab", f.link.id);+ await resumeSync(f.project.id, "gitlab", f.link.id, review.token, "kaneo");+ const link = await db.query.externalLinkTable.findFirst({+ where: eq(schema.externalLinkTable.id, f.link.id),+ });+ expect(JSON.parse(link!.metadata!)).toMatchObject({ state: "opened" });+ await handleGitlabIssueReopened(+ {+ object_attributes: {+ iid: 9,+ title: "Kaneo title",+ url: link!.url,+ state: "opened",+ action: "reopen",+ updated_at: new Date().toISOString(),+ },+ project: {+ path_with_namespace: "team/repo",+ web_url: "https://git.example/team/repo",+ },+ },+ f.integration.id,+ );+ expect(+ await db.query.taskTable.findFirst({+ where: eq(schema.taskTable.id, f.task.id),+ }),+ ).toMatchObject({+ status: f.columns.inProgress.slug,+ columnId: f.columns.inProgress.id,+ });});it("runs mention notifications and asset cleanup when adopting repository text", async () => {vi.spyOn(events, "publishEvent").mockResolvedValue(undefined);