refactor(git-sync): drop dead DebounceEntry.workspaceId field (PR #119 review)

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<string, NodeJS.Timeout>` (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 <noreply@anthropic.com>
This commit is contained in:
claude code agent 227
2026-06-24 01:05:59 +03:00
parent a0e1cde063
commit f923accc3d

View File

@@ -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<string, DebounceEntry>();
// 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<string, NodeJS.Timeout>();
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);
}
}