⚡ 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): identify older outbound echoes and stale events
Tindf37bcafa23f
diff --git a/apps/api/src/plugins/gitea/events/task-description-changed.ts b/apps/api/src/plugins/gitea/events/task-description-changed.tsindex 0e87d3c80..4aa249a18 100644--- a/apps/api/src/plugins/gitea/events/task-description-changed.ts+++ b/apps/api/src/plugins/gitea/events/task-description-changed.ts@@ -1,3 +1,6 @@+import db from "../../../database";+import { linkedTaskScope } from "../../github/services/integration-task-scope";+import { outboundStamp } from "../../github/utils/sync-echo";import {findExternalLinksByTask,updateExternalLink,@@ -7,11 +10,7 @@ import type { PluginContext, TaskDescriptionChangedEvent } from "../../types";import type { GiteaConfig } from "../config";import { createGiteaClient } from "../utils/gitea-api";-type LinkSyncState = {- timestamp: string;- source: string;- value: string;-};+type LinkSyncState = import("../../github/utils/sync-echo").SyncStamp;type LinkMetadata = {lastSync?: {@@ -32,6 +31,16 @@ export async function handleTaskDescriptionChanged(const { repositoryOwner, repositoryName } = config;try {+ const current = await db.query.taskTable.findFirst({+ where: linkedTaskScope(event.taskId, context.projectId),+ columns: { description: true },+ });+ if (+ !current ||+ (current.description || "") !== (event.newDescription || "")+ )+ return;+const links = await findExternalLinksByTask(event.taskId);const issueLink = links.find((link) =>@@ -86,20 +95,25 @@ export async function handleTaskDescriptionChanged(const formattedBody = formatIssueBody(event.newDescription, event.taskId);- await client.updateIssue(repositoryOwner, repositoryName, issueNumber, {- body: formattedBody,- });+ const response = await client.updateIssue(+ repositoryOwner,+ repositoryName,+ issueNumber,+ {+ body: formattedBody,+ },+ );await updateExternalLink(issueLink.id, {metadata: {...metadata,lastSync: {...metadata.lastSync,- description: {- timestamp: new Date().toISOString(),- source: "kaneo",- value: newDescNormalized,- },+ description: outboundStamp(+ metadata.lastSync?.description,+ newDescNormalized,+ response?.updated_at,+ ),},},});diff --git a/apps/api/src/plugins/gitea/events/task-status-changed.ts b/apps/api/src/plugins/gitea/events/task-status-changed.tsindex 957092960..6ca4f94f0 100644--- a/apps/api/src/plugins/gitea/events/task-status-changed.ts+++ b/apps/api/src/plugins/gitea/events/task-status-changed.ts@@ -1,3 +1,4 @@+import { outboundStamp } from "../../github/utils/sync-echo";import {findExternalLinksByTask,updateExternalLink,@@ -30,6 +31,7 @@ export async function handleTaskStatusChanged(return;}+ const metadata = issueLink.metadata ? JSON.parse(issueLink.metadata) : {};const client = createGiteaClient(config);const issueNumber = Number.parseInt(issueLink.externalId, 10);@@ -40,26 +42,52 @@ export async function handleTaskStatusChanged(]);if (event.newStatus === "done") {- await client.updateIssue(repositoryOwner, repositoryName, issueNumber, {- state: "closed",- });+ const response = await client.updateIssue(+ repositoryOwner,+ repositoryName,+ issueNumber,+ {+ state: "closed",+ },+ );await updateExternalLink(issueLink.id, {metadata: {...(issueLink.metadata ? JSON.parse(issueLink.metadata) : {}),state: "closed",+ lastSync: {+ ...metadata.lastSync,+ state: outboundStamp(+ metadata.lastSync?.state,+ "closed",+ response?.updated_at,+ ),+ },lastOutboundStateSyncAt: Date.now(),},});} else if (event.oldStatus === "done" && event.newStatus !== "done") {- await client.updateIssue(repositoryOwner, repositoryName, issueNumber, {- state: "open",- });+ const response = await client.updateIssue(+ repositoryOwner,+ repositoryName,+ issueNumber,+ {+ state: "open",+ },+ );await updateExternalLink(issueLink.id, {metadata: {...(issueLink.metadata ? JSON.parse(issueLink.metadata) : {}),state: "open",+ lastSync: {+ ...metadata.lastSync,+ state: outboundStamp(+ metadata.lastSync?.state,+ "open",+ response?.updated_at,+ ),+ },lastOutboundStateSyncAt: Date.now(),},});diff --git a/apps/api/src/plugins/gitea/events/task-title-changed.ts b/apps/api/src/plugins/gitea/events/task-title-changed.tsindex cdde38c92..371bb6bb5 100644--- a/apps/api/src/plugins/gitea/events/task-title-changed.ts+++ b/apps/api/src/plugins/gitea/events/task-title-changed.ts@@ -1,3 +1,6 @@+import db from "../../../database";+import { linkedTaskScope } from "../../github/services/integration-task-scope";+import { outboundStamp } from "../../github/utils/sync-echo";import {findExternalLinksByTask,updateExternalLink,@@ -6,11 +9,7 @@ import type { PluginContext, TaskTitleChangedEvent } from "../../types";import type { GiteaConfig } from "../config";import { createGiteaClient } from "../utils/gitea-api";-type LinkSyncState = {- timestamp: string;- source: string;- value: string;-};+type LinkSyncState = import("../../github/utils/sync-echo").SyncStamp;type LinkMetadata = {lastSync?: {@@ -31,6 +30,12 @@ export async function handleTaskTitleChanged(const { repositoryOwner, repositoryName } = config;try {+ const current = await db.query.taskTable.findFirst({+ where: linkedTaskScope(event.taskId, context.projectId),+ columns: { title: true },+ });+ if (!current || current.title !== event.newTitle) return;+const links = await findExternalLinksByTask(event.taskId);const issueLink = links.find((link) =>@@ -81,9 +86,14 @@ export async function handleTaskTitleChanged(return;}- await client.updateIssue(repositoryOwner, repositoryName, issueNumber, {- title: event.newTitle,- });+ const response = await client.updateIssue(+ repositoryOwner,+ repositoryName,+ issueNumber,+ {+ title: event.newTitle,+ },+ );await updateExternalLink(issueLink.id, {title: event.newTitle,@@ -91,11 +101,11 @@ export async function handleTaskTitleChanged(...metadata,lastSync: {...metadata.lastSync,- title: {- timestamp: new Date().toISOString(),- source: "kaneo",- value: event.newTitle,- },+ title: outboundStamp(+ metadata.lastSync?.title,+ event.newTitle,+ response?.updated_at,+ ),},},});diff --git a/apps/api/src/plugins/gitea/utils/gitea-api.ts b/apps/api/src/plugins/gitea/utils/gitea-api.tsindex 38c3c99df..01d1ced5e 100644--- a/apps/api/src/plugins/gitea/utils/gitea-api.ts+++ b/apps/api/src/plugins/gitea/utils/gitea-api.ts@@ -10,6 +10,7 @@ export type GiteaLabel = {};export type GiteaIssue = {+ updated_at?: string;id: number;number: number;title: string;diff --git a/apps/api/src/plugins/gitea/webhooks/issue-closed.ts b/apps/api/src/plugins/gitea/webhooks/issue-closed.tsindex 139924670..3ef4b48ac 100644--- a/apps/api/src/plugins/gitea/webhooks/issue-closed.ts+++ b/apps/api/src/plugins/gitea/webhooks/issue-closed.ts@@ -1,3 +1,4 @@+import { isOutboundEcho, type SyncStamp } from "../../github/utils/sync-echo";import {linkedTaskScope,withIntegrationTask,@@ -100,6 +101,10 @@ export async function handleGiteaIssueClosed(}}+ const stateStamp = (+ existingMetadata.lastSync as { state?: SyncStamp } | undefined+ )?.state;+ if (isOutboundEcho(stateStamp, "closed", issue.updated_at)) return;const lastOutbound = existingMetadata.lastOutboundStateSyncAt;if (typeof lastOutbound === "number" &&diff --git a/apps/api/src/plugins/gitea/webhooks/issue-edited.ts b/apps/api/src/plugins/gitea/webhooks/issue-edited.tsindex 2bb2ea69c..d96c51c43 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 { isOutboundEcho } from "../../github/utils/sync-echo";import {linkedTaskScope,withIntegrationTask,@@ -20,6 +21,7 @@ type IssueEditedPayload = {number: number;title: string;body: string | null;+ updated_at?: string;html_url: string;};changes?: {@@ -91,10 +93,7 @@ export async function handleGiteaIssueEdited(let shouldUpdateTitle = true;if (lastTitleSync) {- if (- lastTitleSync.value === issue.title &&- lastTitleSync.source === "kaneo"- ) {+ if (isOutboundEcho(lastTitleSync, issue.title, issue.updated_at)) {shouldUpdateTitle = false;}}@@ -102,6 +101,7 @@ export async function handleGiteaIssueEdited(if (shouldUpdateTitle) {updateData.title = issue.title;updatedMetadata.lastSync.title = {+ outbound: metadata.lastSync?.title?.outbound,timestamp: new Date().toISOString(),source: "gitea",value: issue.title,@@ -117,8 +117,7 @@ export async function handleGiteaIssueEdited(if (lastDescSync) {if (- lastDescSync.value === formattedDescription &&- lastDescSync.source === "kaneo"+ isOutboundEcho(lastDescSync, formattedDescription, issue.updated_at)) {shouldUpdateDescription = false;}@@ -127,6 +126,7 @@ export async function handleGiteaIssueEdited(if (shouldUpdateDescription) {updateData.description = formattedDescription;updatedMetadata.lastSync.description = {+ outbound: metadata.lastSync?.description?.outbound,timestamp: new Date().toISOString(),source: "gitea",value: formattedDescription,diff --git a/apps/api/src/plugins/gitea/webhooks/issue-reopened.ts b/apps/api/src/plugins/gitea/webhooks/issue-reopened.tsindex 7acb40128..12f9beb23 100644--- a/apps/api/src/plugins/gitea/webhooks/issue-reopened.ts+++ b/apps/api/src/plugins/gitea/webhooks/issue-reopened.ts@@ -1,3 +1,4 @@+import { isOutboundEcho, type SyncStamp } from "../../github/utils/sync-echo";import {linkedTaskScope,withIntegrationTask,@@ -101,6 +102,10 @@ export async function handleGiteaIssueReopened(}}+ const stateStamp = (+ existingMetadata.lastSync as { state?: SyncStamp } | undefined+ )?.state;+ if (isOutboundEcho(stateStamp, "open", issue.updated_at)) return;const lastOutbound = existingMetadata.lastOutboundStateSyncAt;if (typeof lastOutbound === "number" &&diff --git a/apps/api/src/plugins/github/events/task-description-changed.ts b/apps/api/src/plugins/github/events/task-description-changed.tsindex f8d2f1ace..7b1ff6e17 100644--- a/apps/api/src/plugins/github/events/task-description-changed.ts+++ b/apps/api/src/plugins/github/events/task-description-changed.ts@@ -1,3 +1,6 @@+import db from "../../../database";+import { linkedTaskScope } from "../services/integration-task-scope";+import { outboundStamp } from "../utils/sync-echo";import type { PluginContext, TaskDescriptionChangedEvent } from "../../types";import { type GitHubConfig, hasVerifiedGitHubBinding } from "../config";import {@@ -24,6 +27,16 @@ export async function handleTaskDescriptionChanged(const { repositoryOwner, repositoryName } = config;try {+ const current = await db.query.taskTable.findFirst({+ where: linkedTaskScope(event.taskId, context.projectId),+ columns: { description: true },+ });+ if (+ !current ||+ (current.description || "") !== (event.newDescription || "")+ )+ return;+const links = await findExternalLinksByTask(event.taskId);const issueLink = links.find((link) =>@@ -50,8 +63,6 @@ export async function handleTaskDescriptionChanged(console.log("Skipping description sync - already synced from GitHub");return;}-- // Skip if recent sync (within 2 seconds) to prevent rapid loops}const octokit = await getVerifiedInstallationOctokit(config);@@ -60,7 +71,7 @@ export async function handleTaskDescriptionChanged(// Format description with task ID footerconst formattedBody = formatIssueBody(event.newDescription, event.taskId);- await octokit.rest.issues.update({+ const response = await octokit.rest.issues.update({owner: repositoryOwner,repo: repositoryName,issue_number: issueNumber,@@ -73,11 +84,11 @@ export async function handleTaskDescriptionChanged(...metadata,lastSync: {...metadata.lastSync,- description: {- timestamp: new Date().toISOString(),- source: "kaneo",- value: newDescNormalized,- },+ description: outboundStamp(+ metadata.lastSync?.description,+ newDescNormalized,+ response?.data?.updated_at,+ ),},},});diff --git a/apps/api/src/plugins/github/events/task-title-changed.ts b/apps/api/src/plugins/github/events/task-title-changed.tsindex 4a1174055..b54806c2e 100644--- a/apps/api/src/plugins/github/events/task-title-changed.ts+++ b/apps/api/src/plugins/github/events/task-title-changed.ts@@ -1,3 +1,6 @@+import db from "../../../database";+import { linkedTaskScope } from "../services/integration-task-scope";+import { outboundStamp } from "../utils/sync-echo";import type { PluginContext, TaskTitleChangedEvent } from "../../types";import { type GitHubConfig, hasVerifiedGitHubBinding } from "../config";import {@@ -23,6 +26,12 @@ export async function handleTaskTitleChanged(const { repositoryOwner, repositoryName } = config;try {+ const current = await db.query.taskTable.findFirst({+ where: linkedTaskScope(event.taskId, context.projectId),+ columns: { title: true },+ });+ if (!current || current.title !== event.newTitle) return;+const links = await findExternalLinksByTask(event.taskId);const issueLink = links.find((link) =>@@ -47,14 +56,12 @@ export async function handleTaskTitleChanged(console.log("Skipping title sync - already synced from GitHub");return;}-- // Skip if recent sync (within 2 seconds) to prevent rapid loops}const octokit = await getVerifiedInstallationOctokit(config);const issueNumber = Number.parseInt(issueLink.externalId, 10);- await octokit.rest.issues.update({+ const response = await octokit.rest.issues.update({owner: repositoryOwner,repo: repositoryName,issue_number: issueNumber,@@ -68,11 +75,11 @@ export async function handleTaskTitleChanged(...metadata,lastSync: {...metadata.lastSync,- title: {- timestamp: new Date().toISOString(),- source: "kaneo",- value: event.newTitle,- },+ title: outboundStamp(+ metadata.lastSync?.title,+ event.newTitle,+ response?.data?.updated_at,+ ),},},});diff --git a/apps/api/src/plugins/github/utils/sync-echo.ts b/apps/api/src/plugins/github/utils/sync-echo.tsnew file mode 100644index 000000000..63c01f96c--- /dev/null+++ b/apps/api/src/plugins/github/utils/sync-echo.ts@@ -0,0 +1,57 @@+import { createHash } from "node:crypto";++export type SyncStamp = {+ timestamp?: string;+ source?: string;+ value?: string;+ outbound?: Array<{ hash: string; timestamp: string; updatedAt?: string }>;+};++const hash = (value: string) =>+ createHash("sha256").update(value).digest("hex");++export function outboundStamp(+ previous: SyncStamp | undefined,+ value: string,+ updatedAt?: string,+): SyncStamp {+ const timestamp = new Date().toISOString();+ const outbound = [...(previous?.outbound ?? [])];+ // Older installations have only the last value, without a provider timestamp.+ if (+ previous?.source === "kaneo" &&+ !previous.outbound?.length &&+ previous.value !== undefined &&+ previous.timestamp+ )+ outbound.push({+ hash: hash(previous.value),+ timestamp: previous.timestamp,+ });+ outbound.push({ hash: hash(value), timestamp, updatedAt });+ return { timestamp, source: "kaneo", value, outbound: outbound.slice(-32) };+}++export function isOutboundEcho(+ stamp: SyncStamp | undefined,+ value: string,+ updatedAt?: string,+): boolean {+ if (!stamp) return false;+ const entries = stamp.outbound ?? [];+ const valueHash = hash(value);+ if (+ entries.some(+ (entry) =>+ entry.hash === valueHash &&+ (entry.updatedAt && updatedAt+ ? entry.updatedAt === updatedAt+ : Date.now() - Date.parse(entry.timestamp) < 300_000),+ )+ )+ return true;+ // Preserve compatibility with stamps written before outbound history existed.+ return (+ entries.length === 0 && stamp.source === "kaneo" && stamp.value === value+ );+}diff --git a/apps/api/src/plugins/github/webhooks/issue-edited.ts b/apps/api/src/plugins/github/webhooks/issue-edited.tsindex 3fce6512b..3e3956d8d 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 { isOutboundEcho } from "../utils/sync-echo";import {linkedTaskScope,withIntegrationTask,@@ -10,11 +11,7 @@ import { parseLinkMetadata } from "../utils/parse-link-metadata";// What this handler reads back out of the row. Every field is optional,// because the row may predate any of them.-type SyncStamp = {- timestamp?: string;- source?: string;- value?: string;-};+type SyncStamp = import("../utils/sync-echo").SyncStamp;type IssueEditedMetadata = {lastSync?: {@@ -29,6 +26,7 @@ type IssueEditedPayload = {number: number;title: string;body: string | null;+ updated_at?: string;html_url: string;};changes?: {@@ -102,10 +100,7 @@ export async function handleIssueEdited(payload: IssueEditedPayload) {let shouldUpdateTitle = true;if (lastTitleSync) {- if (- lastTitleSync.value === issue.title &&- lastTitleSync.source === "kaneo"- ) {+ if (isOutboundEcho(lastTitleSync, issue.title, issue.updated_at)) {console.log("Skipping title update - already synced from Kaneo");shouldUpdateTitle = false;}@@ -114,6 +109,7 @@ export async function handleIssueEdited(payload: IssueEditedPayload) {if (shouldUpdateTitle) {updateData.title = issue.title;updatedMetadata.lastSync.title = {+ outbound: metadata.lastSync?.title?.outbound,timestamp: new Date().toISOString(),source: "github",value: issue.title,@@ -135,8 +131,7 @@ export async function handleIssueEdited(payload: IssueEditedPayload) {if (lastDescSync) {if (- lastDescSync.value === formattedDescription &&- lastDescSync.source === "kaneo"+ isOutboundEcho(lastDescSync, formattedDescription, issue.updated_at)) {console.log("Skipping description update - already synced from Kaneo",@@ -148,6 +143,7 @@ export async function handleIssueEdited(payload: IssueEditedPayload) {if (shouldUpdateDescription) {updateData.description = formattedDescription;updatedMetadata.lastSync.description = {+ outbound: metadata.lastSync?.description?.outbound,timestamp: new Date().toISOString(),source: "github",value: formattedDescription,diff --git a/tests/api/plugins/gitea/rapid-text-sync.test.ts b/tests/api/plugins/gitea/rapid-text-sync.test.tsindex 443c47cfe..7c9d5dc6a 100644--- a/tests/api/plugins/gitea/rapid-text-sync.test.ts+++ b/tests/api/plugins/gitea/rapid-text-sync.test.ts@@ -1,13 +1,22 @@+import { outboundStamp } from "../../../../apps/api/src/plugins/github/utils/sync-echo";import { beforeEach, describe, expect, it, vi } from "vite-plus/test";import { handleGiteaIssueEdited } from "../../../../apps/api/src/plugins/gitea/webhooks/issue-edited";const m = vi.hoisted(() => ({metadata: "",+ status: vi.fn(),writes: vi.fn(),linkWrites: vi.fn(),}));vi.mock("../../../../apps/api/src/database", () => ({default: {query: {+ externalLinkTable: {+ findFirst: async () => ({+ id: "link",+ taskId: "task",+ metadata: m.metadata,+ }),+ },taskTable: {findFirst: async () => ({ id: "task", projectId: "project" }),},@@ -102,3 +111,111 @@ describe("rapid gitea text edits", () => {expect(m.writes).not.toHaveBeenCalled();});});++it("ignores a delayed first echo after a newer outbound edit", async () => {+ m.metadata = JSON.stringify({+ lastSync: {+ title: outboundStamp(+ outboundStamp(undefined, "Earlier title", "2026-01-01T00:00:00Z"),+ "Newest title",+ "2026-01-01T00:00:01Z",+ ),+ description: outboundStamp(+ outboundStamp(undefined, "Earlier body", "2026-01-01T00:00:00Z"),+ "Newest body",+ "2026-01-01T00:00:01Z",+ ),+ },+ });+ await handleGiteaIssueEdited({+ ...payload,+ issue: {+ ...payload.issue,+ title: "Earlier title",+ body: "Earlier body",+ updated_at: "2026-01-01T00:00:00Z",+ },+ });+ expect(m.writes).not.toHaveBeenCalled();+});+it("allows a new remote edit back to an older outbound value", async () => {+ m.metadata = JSON.stringify({+ lastSync: {+ title: outboundStamp(+ outboundStamp(undefined, "Earlier title", "2026-01-01T00:00:00Z"),+ "Newest title",+ "2026-01-01T00:00:01Z",+ ),+ },+ });+ await handleGiteaIssueEdited({+ ...payload,+ changes: { title: { from: "Newest title" } },+ issue: {+ ...payload.issue,+ title: "Earlier title",+ updated_at: "2026-01-01T00:00:02Z",+ },+ });+ expect(m.writes).toHaveBeenCalledWith({ title: "Earlier title" });+});++vi.mock(+ "../../../../apps/api/src/plugins/github/services/task-service",+ () => ({ updateTaskStatus: m.status }),+);+vi.mock("../../../../apps/api/src/plugins/gitea/utils/resolve-column", () => ({+ resolveTargetStatus: async (+ _project: string,+ _event: string,+ fallback: string,+ ) => fallback,+}));+it("ignores an older close echo after a newer outbound reopen", async () => {+ const { handleGiteaIssueClosed } =+ await import("../../../../apps/api/src/plugins/gitea/webhooks/issue-closed");+ m.metadata = JSON.stringify({+ state: "open",+ lastSync: {+ state: outboundStamp(+ outboundStamp(undefined, "closed", "2026-01-01T00:00:00Z"),+ "open",+ "2026-01-01T00:00:01Z",+ ),+ },+ });+ await handleGiteaIssueClosed({+ ...payload,+ action: "closed",+ issue: {+ ...payload.issue,+ state: "closed",+ updated_at: "2026-01-01T00:00:00Z",+ },+ });+ expect(m.status).not.toHaveBeenCalled();+});+it("ignores an older reopen echo after a newer outbound close", async () => {+ const { handleGiteaIssueReopened } =+ await import("../../../../apps/api/src/plugins/gitea/webhooks/issue-reopened");+ m.metadata = JSON.stringify({+ state: "closed",+ lastSync: {+ state: outboundStamp(+ outboundStamp(undefined, "open", "2026-01-01T00:00:00Z"),+ "closed",+ "2026-01-01T00:00:01Z",+ ),+ },+ });+ await handleGiteaIssueReopened({+ ...payload,+ action: "reopened",+ issue: {+ ...payload.issue,+ state: "open",+ updated_at: "2026-01-01T00:00:00Z",+ },+ });+ expect(m.status).not.toHaveBeenCalled();+});diff --git a/tests/api/plugins/github/rapid-text-sync.test.ts b/tests/api/plugins/github/rapid-text-sync.test.tsindex 6c1ea2ef5..dc01551bb 100644--- a/tests/api/plugins/github/rapid-text-sync.test.ts+++ b/tests/api/plugins/github/rapid-text-sync.test.ts@@ -1,6 +1,7 @@import { beforeEach, describe, expect, it, vi } from "vite-plus/test";const m = vi.hoisted(() => ({+ current: { title: "", description: "" },links: vi.fn(),update: vi.fn(),save: vi.fn(),@@ -15,6 +16,9 @@ vi.mock("../../../../apps/api/src/plugins/github/utils/github-app", () => ({rest: { issues: { update: m.update } },}),}));+vi.mock("../../../../apps/api/src/database", () => ({+ default: { query: { taskTable: { findFirst: async () => m.current } } },+}));const { handleTaskTitleChanged } =await import("../../../../apps/api/src/plugins/github/events/task-title-changed");const { handleTaskDescriptionChanged } =@@ -48,6 +52,7 @@ function link(field: string, source: string, value: string) {}describe("rapid github text edits", () => {it("sends a second local title even immediately after the first sync", async () => {+ m.current.title = "Second title";m.links.mockResolvedValue([link("title", "kaneo", "First title")]);await handleTaskTitleChanged({@@ -64,6 +69,7 @@ describe("rapid github text edits", () => {);});it("sends a different title immediately after an incoming github title", async () => {+ m.current.title = "Local correction";m.links.mockResolvedValue([link("title", "github", "Remote title")]);await handleTaskTitleChanged({@@ -80,6 +86,7 @@ describe("rapid github text edits", () => {);});it("keeps suppressing an exact incoming echo", async () => {+ m.current.title = "Remote title";m.links.mockResolvedValue([link("title", "github", "Remote title")]);await handleTaskTitleChanged({@@ -94,6 +101,7 @@ describe("rapid github text edits", () => {expect(m.update).not.toHaveBeenCalled();});it("sends a second local description immediately after the first sync", async () => {+ m.current.description = "Second description";m.links.mockResolvedValue([link("description", "kaneo", "First description"),]);@@ -114,3 +122,19 @@ describe("rapid github text edits", () => {);});});++it("does not send a queued title after a newer task edit", async () => {+ m.current.title = "Newest";+ m.links.mockResolvedValue([link("title", "kaneo", "Old")]);+ await handleTaskTitleChanged(+ {+ taskId: "task",+ projectId: "project",+ userId: "user",+ oldTitle: "Old",+ newTitle: "Queued",+ },+ context,+ );+ expect(m.update).not.toHaveBeenCalled();+});