From a7f998907ce83f4713fea0d244868dce4ca71c09 Mon Sep 17 00:00:00 2001 From: claude code agent 227 Date: Wed, 24 Jun 2026 01:05:59 +0300 Subject: [PATCH] refactor(git-sync): drop dead DebounceEntry.workspaceId field (PR #119 review) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The debounce map value carried `workspaceId`, but the scheduled cycle closes over the `workspaceId` argument directly — the field was written and never read. Replace the entry struct with `Map` (the timer handle is all the map tracks). No behavior change. (page-change.listener.spec is in the repo's pre-existing set of jest suites that can't load locally via the react-dom/tiptap transform chain — unaffected by this change; tsc clean.) Co-Authored-By: Claude Opus 4.8 --- .../git-sync/listeners/page-change.listener.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/apps/server/src/integrations/git-sync/listeners/page-change.listener.ts b/apps/server/src/integrations/git-sync/listeners/page-change.listener.ts index 5596c2f8..474eb990 100644 --- a/apps/server/src/integrations/git-sync/listeners/page-change.listener.ts +++ b/apps/server/src/integrations/git-sync/listeners/page-change.listener.ts @@ -21,12 +21,6 @@ interface PageEventLike { node?: { id: string; spaceId: string }; } -/** Per-space debounce bookkeeping. */ -interface DebounceEntry { - timer: NodeJS.Timeout; - workspaceId: string; -} - /** * Event-driven trigger for the git-sync control plane (plan §10). Subscribes to * the page lifecycle events and, for an enabled space, schedules a DEBOUNCED @@ -45,7 +39,9 @@ interface DebounceEntry { @Injectable() export class PageChangeListener { private readonly logger = new Logger(PageChangeListener.name); - private readonly debounce = new Map(); + // spaceId -> pending debounce timer. The cycle closes over its own + // workspaceId, so the timer handle is all the map needs to track. + private readonly debounce = new Map(); constructor( private readonly environmentService: EnvironmentService, @@ -126,7 +122,7 @@ export class PageChangeListener { */ private schedule(spaceId: string, workspaceId: string): void { const existing = this.debounce.get(spaceId); - if (existing) clearTimeout(existing.timer); + if (existing) clearTimeout(existing); const timer = setTimeout(() => { this.debounce.delete(spaceId); @@ -143,6 +139,6 @@ export class PageChangeListener { // Do not keep the event loop alive solely for a pending sync. timer.unref?.(); - this.debounce.set(spaceId, { timer, workspaceId }); + this.debounce.set(spaceId, timer); } }