@gitkraken/core-gitlens 0.37.0 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +67 -1
- package/dist/git/cache.d.ts +128 -8
- package/dist/git/cache.js +425 -46
- package/dist/git/cache.js.map +1 -1
- package/dist/git/features.d.ts +1 -1
- package/dist/git/features.js +3 -0
- package/dist/git/features.js.map +1 -1
- package/dist/git/providers/branches.d.ts +42 -1
- package/dist/git/providers/diff.d.ts +17 -0
- package/dist/git/providers/provider.d.ts +7 -0
- package/dist/git/providers/shared/remotes.js +8 -4
- package/dist/git/providers/shared/remotes.js.map +1 -1
- package/dist/git/remotes/matcher.js +2 -2
- package/dist/git/remotes/matcher.js.map +1 -1
- package/dist/git/repositoryService.d.ts +16 -1
- package/dist/git/repositoryService.js +51 -3
- package/dist/git/repositoryService.js.map +1 -1
- package/dist/git/run.types.d.ts +1 -0
- package/dist/git/service.js +6 -2
- package/dist/git/service.js.map +1 -1
- package/dist/git/utils/fileStatus.utils.d.ts +5 -0
- package/dist/git/utils/fileStatus.utils.js +18 -1
- package/dist/git/utils/fileStatus.utils.js.map +1 -1
- package/dist/git/watching/changeEvent.d.ts +13 -3
- package/dist/git/watching/changeEvent.js +15 -4
- package/dist/git/watching/changeEvent.js.map +1 -1
- package/dist/git/watching/changeOrdinal.d.ts +9 -0
- package/dist/git/watching/changeOrdinal.js +14 -0
- package/dist/git/watching/changeOrdinal.js.map +1 -0
- package/dist/git/watching/unwatchedCacheValidator.d.ts +38 -5
- package/dist/git/watching/unwatchedCacheValidator.js +180 -36
- package/dist/git/watching/unwatchedCacheValidator.js.map +1 -1
- package/dist/git/watching/watchGroup.d.ts +63 -14
- package/dist/git/watching/watchGroup.js +213 -74
- package/dist/git/watching/watchGroup.js.map +1 -1
- package/dist/git/watching/watchService.js +4 -3
- package/dist/git/watching/watchService.js.map +1 -1
- package/dist/git/watching/watchSession.d.ts +10 -2
- package/dist/git/watching/watchSession.js +18 -4
- package/dist/git/watching/watchSession.js.map +1 -1
- package/dist/git/watching/watcherPatterns.d.ts +18 -4
- package/dist/git/watching/watcherPatterns.js +39 -8
- package/dist/git/watching/watcherPatterns.js.map +1 -1
- package/dist/git/watching/worktreeSummary.d.ts +23 -12
- package/dist/git/watching/worktreeSummary.js +164 -41
- package/dist/git/watching/worktreeSummary.js.map +1 -1
- package/dist/git-cli/cliGitProvider.d.ts +1 -0
- package/dist/git-cli/cliGitProvider.js +11 -2
- package/dist/git-cli/cliGitProvider.js.map +1 -1
- package/dist/git-cli/exec/git.d.ts +7 -2
- package/dist/git-cli/exec/git.js +46 -10
- package/dist/git-cli/exec/git.js.map +1 -1
- package/dist/git-cli/exec/headState.d.ts +24 -0
- package/dist/git-cli/exec/headState.js +46 -6
- package/dist/git-cli/exec/headState.js.map +1 -1
- package/dist/git-cli/parsers/logParser.js +6 -3
- package/dist/git-cli/parsers/logParser.js.map +1 -1
- package/dist/git-cli/providers/branches.d.ts +135 -10
- package/dist/git-cli/providers/branches.js +622 -80
- package/dist/git-cli/providers/branches.js.map +1 -1
- package/dist/git-cli/providers/commits.d.ts +16 -0
- package/dist/git-cli/providers/commits.js +80 -28
- package/dist/git-cli/providers/commits.js.map +1 -1
- package/dist/git-cli/providers/config.d.ts +10 -0
- package/dist/git-cli/providers/config.js +50 -12
- package/dist/git-cli/providers/config.js.map +1 -1
- package/dist/git-cli/providers/contributors.js +11 -7
- package/dist/git-cli/providers/contributors.js.map +1 -1
- package/dist/git-cli/providers/diff.d.ts +12 -0
- package/dist/git-cli/providers/diff.js +107 -15
- package/dist/git-cli/providers/diff.js.map +1 -1
- package/dist/git-cli/providers/graph.js +32 -25
- package/dist/git-cli/providers/graph.js.map +1 -1
- package/dist/git-cli/providers/operations.d.ts +37 -3
- package/dist/git-cli/providers/operations.js +124 -46
- package/dist/git-cli/providers/operations.js.map +1 -1
- package/dist/git-cli/providers/patch.js +1 -1
- package/dist/git-cli/providers/patch.js.map +1 -1
- package/dist/git-cli/providers/refs.d.ts +1 -1
- package/dist/git-cli/providers/refs.js +10 -11
- package/dist/git-cli/providers/refs.js.map +1 -1
- package/dist/git-cli/providers/status.d.ts +4 -5
- package/dist/git-cli/providers/status.js +36 -33
- package/dist/git-cli/providers/status.js.map +1 -1
- package/dist/git-cli/providers/tags.d.ts +8 -0
- package/dist/git-cli/providers/tags.js +53 -34
- package/dist/git-cli/providers/tags.js.map +1 -1
- package/dist/git-cli/service.d.ts +15 -0
- package/dist/git-cli/service.js +19 -1
- package/dist/git-cli/service.js.map +1 -1
- package/dist/plus/git-github/api/github.d.ts +4 -0
- package/dist/plus/git-github/api/github.js +11 -1
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/providers/github/diff.d.ts +1 -0
- package/dist/plus/git-github/providers/github/diff.js +6 -1
- package/dist/plus/git-github/providers/github/diff.js.map +1 -1
- package/dist/plus/integrations/integrationService.js +9 -0
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/providers/jira-server.js +1 -1
- package/dist/plus/integrations/providers/jira-server.js.map +1 -1
- package/dist/plus/integrations/providers/jira.d.ts +38 -6
- package/dist/plus/integrations/providers/jira.js +111 -69
- package/dist/plus/integrations/providers/jira.js.map +1 -1
- package/dist/plus/integrations/providers/linear.d.ts +31 -3
- package/dist/plus/integrations/providers/linear.js +77 -18
- package/dist/plus/integrations/providers/linear.js.map +1 -1
- package/dist/plus/integrations/providers/utils/discoveryCache.d.ts +41 -4
- package/dist/plus/integrations/providers/utils/discoveryCache.js +50 -11
- package/dist/plus/integrations/providers/utils/discoveryCache.js.map +1 -1
- package/dist/utils/env/node/exec.d.ts +5 -4
- package/dist/utils/env/node/exec.js +52 -9
- package/dist/utils/env/node/exec.js.map +1 -1
- package/dist/utils/holdOffMap.d.ts +23 -0
- package/dist/utils/holdOffMap.js +43 -0
- package/dist/utils/holdOffMap.js.map +1 -0
- package/dist/utils/promiseCache.d.ts +15 -2
- package/dist/utils/promiseCache.js +34 -4
- package/dist/utils/promiseCache.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watchSession.js","names":[],"sources":["../../../../git/src/watching/watchSession.ts"],"sourcesContent":["import type { UnifiedDisposable } from '@gitlens/utils/disposable.js';\nimport { createDisposable } from '@gitlens/utils/disposable.js';\nimport type { Event } from '@gitlens/utils/event.js';\nimport { Emitter } from '@gitlens/utils/event.js';\nimport type { RepositoryChange } from '../models/repository.js';\nimport type { RefChangeKind, WorkingTreeChangeEvent } from './changeEvent.js';\nimport { findCoveringRefName, getRefChangeKind, isRefChangeKind, WatcherRepoChangeEvent } from './changeEvent.js';\nimport { allWatchedRepositoryChanges } from './classifyChange.js';\n\nexport interface RepositorySubscription extends UnifiedDisposable {\n\treadonly onDidChange: Event<WatcherRepoChangeEvent>;\n}\n\nexport interface WorkingTreeSubscription extends UnifiedDisposable {\n\treadonly onDidChangeWorkingTree: Event<WorkingTreeChangeEvent>;\n}\n\n/**\n * Lifecycle callbacks fired by the session when subscriber counts\n * cross the 0↔1 boundary. The host (WatchService) uses these to\n * lazily create/destroy watchers.\n */\nexport interface WatchSessionLifecycle {\n\t/** Called when the first repo-change subscriber joins */\n\tonFirstRepoSubscriber?(): void;\n\t/** Called when the last repo-change subscriber leaves */\n\tonLastRepoSubscriber?(): void;\n\t/** Called when the first working-tree subscriber joins */\n\tonFirstWorkingTreeSubscriber?(): void;\n\t/** Called when the last working-tree subscriber leaves */\n\tonLastWorkingTreeSubscriber?(): void;\n}\n\nexport interface WatchSessionOptions {\n\treadonly repoPath: string;\n\t/** Default debounce for repo changes. Default: 250ms */\n\treadonly defaultRepoDelayMs?: number;\n\t/** Default debounce for working tree changes. Default: 2500ms */\n\treadonly defaultWorkingTreeDelayMs?: number;\n\t/**\n\t * Default cap on how long repo changes can be held back by continuous activity — a flush happens at most this long\n\t * after the first pending change, however long the burst lasts. `Infinity` disables the cap. Default: 2000ms\n\t */\n\treadonly defaultRepoMaxWaitMs?: number;\n\t/** Default cap on how long working tree changes can be held back by continuous activity. `Infinity` disables the cap. Default: 10000ms */\n\treadonly defaultWorkingTreeMaxWaitMs?: number;\n\treadonly lifecycle?: WatchSessionLifecycle;\n\t/** Initial suspended state — new sessions inherit the service-global suspend state. Default: false */\n\treadonly suspended?: boolean;\n\t/**\n\t * Called whenever a debounced repo change event is dispatched to subscribers.\n\t * Does NOT count as a subscriber — used by WatchService for\n\t * global event forwarding without affecting lifecycle callbacks.\n\t */\n\treadonly onDidFireRepoChange?: (event: WatcherRepoChangeEvent) => void;\n\t/**\n\t * Called whenever a debounced working-tree change is dispatched to subscribers. Like\n\t * {@link onDidFireRepoChange}, does NOT count as a subscriber — used by WatchService for global\n\t * event forwarding (the single point that drives the cache's status clock for working-tree edits).\n\t */\n\treadonly onDidFireWorkingTreeChange?: (repoPath: string) => void;\n}\n\n/** The debounce a repo subscriber gets when it names none */\nexport const defaultRepoDelay = 250;\nconst defaultWorkingTreeDelay = 2500;\nconst defaultRepoMaxWait = 2000;\nconst defaultWorkingTreeMaxWait = 10000;\n\n/** Largest delay `setTimeout` honors (a signed 32-bit int); anything longer fires immediately */\nconst maxTimerDelay = 0x7fffffff;\n\ninterface DebounceTiming {\n\treadonly delayMs: number;\n\treadonly maxWaitMs: number;\n}\n\n/**\n * Trailing-deadline debounce with a max-wait, shared by the repo and working-tree pipelines.\n *\n * Recording an event costs a `performance.now()` and, only when no timer is armed, one `setTimeout` — never a\n * `clearTimeout`/`setTimeout` pair per event, which is what made a busy repo allocate (and starve) on every raw\n * watcher event. The armed timer is a deadline, not a countdown: when it fires it recomputes the due time from the\n * latest timestamps and either flushes or re-arms for the remainder. The due time is\n * `min(lastEventAt + delay, firstPendingAt + maxWait)`, so continuous activity is flushed at the max-wait instead of\n * never. Monotonic time, so a wall-clock change can't push a deadline out.\n */\nclass DebounceClock {\n\tprivate active = false;\n\tprivate paused = false;\n\tprivate firstAt = 0;\n\tprivate lastAt = 0;\n\tprivate timer: ReturnType<typeof setTimeout> | undefined;\n\tprivate timerDueAt = 0;\n\t/** Absolute flush time set by {@link resume}; dropped by the next event, which returns to normal debounce */\n\tprivate resumeDueAt: number | undefined;\n\n\tconstructor(\n\t\tprivate readonly getDelayMs: () => number,\n\t\tprivate readonly getMaxWaitMs: () => number,\n\t\tprivate readonly onDue: () => void,\n\t) {}\n\n\t/** Records an event; arms the timer only if none is armed. Cheap enough to call per raw event. */\n\tnote(): void {\n\t\tconst now = performance.now();\n\t\tif (!this.active) {\n\t\t\tthis.active = true;\n\t\t\tthis.firstAt = now;\n\t\t}\n\t\tthis.lastAt = now;\n\n\t\tif (this.paused) return;\n\n\t\tif (this.resumeDueAt != null) {\n\t\t\t// The first event after a resume goes back to normal debounce — which may be due sooner than the resume deadline\n\t\t\tthis.resumeDueAt = undefined;\n\t\t\tthis.rearmIfEarlier();\n\t\t}\n\n\t\tif (this.timer == null) {\n\t\t\tthis.arm(this.getDueAt(), now);\n\t\t}\n\t}\n\n\t/** Moves the armed timer earlier when the due time shrank (a subscriber joined with a shorter delay or max-wait) */\n\trearmIfEarlier(): void {\n\t\tif (!this.active || this.paused || this.timer == null) return;\n\n\t\tconst dueAt = this.getDueAt();\n\t\tif (dueAt >= this.timerDueAt) return;\n\n\t\tclearTimeout(this.timer);\n\t\tthis.arm(dueAt, performance.now());\n\t}\n\n\t/** Cancels the timer; events keep accumulating but nothing is due until {@link resume} */\n\tsuspend(): void {\n\t\tthis.paused = true;\n\t\tthis.clearTimer();\n\t}\n\n\t/**\n\t * Restarts the max-wait window from now and schedules the flush for `delayMs` from now (the effective delay when\n\t * omitted). Does nothing if no events are pending.\n\t */\n\tresume(delayMs?: number): void {\n\t\tthis.paused = false;\n\t\tif (!this.active) return;\n\n\t\tconst now = performance.now();\n\t\tthis.firstAt = now;\n\t\tthis.resumeDueAt = now + (delayMs ?? this.getDelayMs());\n\t\tthis.clearTimer();\n\t\tthis.arm(this.resumeDueAt, now);\n\t}\n\n\t/** Drops the pending window and the timer */\n\tcancel(): void {\n\t\tthis.active = false;\n\t\tthis.resumeDueAt = undefined;\n\t\tthis.clearTimer();\n\t}\n\n\tprivate getDueAt(): number {\n\t\treturn this.resumeDueAt ?? Math.min(this.lastAt + this.getDelayMs(), this.firstAt + this.getMaxWaitMs());\n\t}\n\n\tprivate arm(dueAt: number, now: number): void {\n\t\tthis.timerDueAt = dueAt;\n\t\tthis.timer = setTimeout(() => this.onTimer(), Math.min(Math.max(0, dueAt - now), maxTimerDelay));\n\t}\n\n\tprivate onTimer(): void {\n\t\tthis.timer = undefined;\n\t\tif (!this.active || this.paused) return;\n\n\t\tconst now = performance.now();\n\t\tconst dueAt = this.getDueAt();\n\t\tif (dueAt > now) {\n\t\t\tthis.arm(dueAt, now);\n\t\t\treturn;\n\t\t}\n\n\t\t// Reset before firing so an event raised by a subscriber starts a fresh window\n\t\tthis.cancel();\n\t\tthis.onDue();\n\t}\n\n\tprivate clearTimer(): void {\n\t\tif (this.timer != null) {\n\t\t\tclearTimeout(this.timer);\n\t\t\tthis.timer = undefined;\n\t\t}\n\t}\n}\n\n/**\n * Cap on retained working-tree paths per flush. The set otherwise grows without bound — while the window\n * is unfocused the session is suspended, so a branch switch or build accumulates every touched path until\n * refocus. Set low deliberately: ordinary edits are a handful of paths, anything past this was a\n * refresh-everything event anyway, and dropping past it only costs the matching consumers a\n * conservative refresh.\n */\nconst maxWorkingTreePaths = 1000;\n\n/**\n * Cap on retained ref names per flush, for the same reason (a fetch of many refs while suspended). Past it, a ref kind\n * is recorded unnamed — any ref of that kind may have moved — which only makes `mayHaveChangedRef` more conservative.\n * A pending `config` confined to more branches than this is recorded unconfined, for the same reason.\n */\nconst maxPendingRefNames = 1000;\n\n/**\n * What core's announced writes in the pending window said about one kind: when it was first announced, and the full\n * ref names it was confined to (for `config`, the branches whose sections it changed; for `worktreeHead`, the admin ids\n * of the linked worktrees whose HEAD it moved); `names` is absent when an announcement left the kind open — any ref of\n * it, any part of the config, or any linked worktree's HEAD may have changed.\n */\ninterface PendingAnnouncement {\n\treadonly at: number;\n\tnames: Set<string> | undefined;\n}\n\n/**\n * Per-repository session that owns the debounce/coalesce/suspend\n * pipeline for both repo (.git) and working-tree changes.\n *\n * Multiple subscribers share the same pipeline — the shortest\n * requested debounce delay wins, and so does the shortest max-wait.\n */\nexport class RepositoryWatchSession implements UnifiedDisposable {\n\treadonly repoPath: string;\n\n\tprivate readonly repoEmitter = new Emitter<WatcherRepoChangeEvent>();\n\tprivate readonly repoSubscribers = new Map<number, DebounceTiming>(); // subscriberId → timing\n\tprivate repoNextId = 0;\n\t/** Each repo subscriber's `relevantRefs`, for {@link getRelevantRefs} */\n\tprivate readonly relevantRefsSources = new Map<number, () => Iterable<string>>(); // subscriberId → relevantRefs\n\tprivate readonly pendingRepoChanges = new Set<RepositoryChange>();\n\t/** Full ref names, ref directories and pseudo-refs whose files changed, flushed with {@link pendingRepoChanges} */\n\tprivate readonly pendingRepoRefs = new Set<string>();\n\t/** Ref kinds that changed without a name, flushed with {@link pendingRepoChanges} */\n\tprivate readonly pendingRepoUnnamedRefKinds = new Set<RefChangeKind>();\n\t/** Kinds among {@link pendingRepoChanges} injected or pushed unfenced, which an announcement never replaces */\n\tprivate readonly pendingRepoUnfencedChanges = new Set<RepositoryChange>();\n\t/**\n\t * Kinds among {@link pendingRepoChanges} that only core's announced writes, and their own echoes, reported (see\n\t * {@link noteSelfWrite})\n\t */\n\tprivate readonly pendingRepoAnnounced = new Map<RepositoryChange, PendingAnnouncement>();\n\t/**\n\t * Refs core's writes named since the last flush, kept when an outside report makes their kind unannounced: each is\n\t * a ref a write changed, never the echo of a ref directory\n\t */\n\tprivate readonly pendingRepoAnnouncedRefs = new Set<string>();\n\t/**\n\t * For a pending `config` change, the branches (full ref names) whose sections are all that every report of it\n\t * changed; `undefined` once any report may have changed anything else\n\t */\n\tprivate pendingRepoConfigBranches: Set<string> | undefined;\n\t/**\n\t * For a pending `worktreeHead` change, the admin ids of the linked worktrees whose HEAD moved outside core's announced\n\t * writes, as the reports not taken for a write's own named them; `undefined` once any such report, or an open\n\t * announcement, may have been any linked worktree's\n\t */\n\tprivate pendingRepoMovedWorktrees: Set<string> | undefined;\n\tprivate readonly repoClock: DebounceClock;\n\tprivate effectiveRepoMs: number;\n\tprivate effectiveRepoMaxWaitMs: number;\n\tprivate readonly defaultRepoMs: number;\n\tprivate readonly defaultRepoMaxWaitMs: number;\n\n\tprivate readonly workingTreeEmitter = new Emitter<WorkingTreeChangeEvent>();\n\tprivate readonly workingTreeSubscribers = new Map<number, DebounceTiming>();\n\tprivate workingTreeNextId = 0;\n\tprivate pendingWorkingTreePaths = new Set<string>();\n\tprivate pendingWorkingTreeIncomplete = false;\n\tprivate readonly workingTreeClock: DebounceClock;\n\tprivate effectiveWorkingTreeMs: number;\n\tprivate effectiveWorkingTreeMaxWaitMs: number;\n\tprivate readonly defaultWorkingTreeMs: number;\n\tprivate readonly defaultWorkingTreeMaxWaitMs: number;\n\n\tprivate _etagWorkingTree = 0;\n\tprivate _suspended: boolean;\n\tprivate _disposed = false;\n\n\tprivate readonly lifecycle?: WatchSessionLifecycle;\n\tprivate readonly onDidFireRepoChangeCallback?: (event: WatcherRepoChangeEvent) => void;\n\tprivate readonly onDidFireWorkingTreeChangeCallback?: (repoPath: string) => void;\n\n\tconstructor(options: WatchSessionOptions) {\n\t\tthis.repoPath = options.repoPath;\n\t\tthis.defaultRepoMs = options.defaultRepoDelayMs ?? defaultRepoDelay;\n\t\tthis.defaultWorkingTreeMs = options.defaultWorkingTreeDelayMs ?? defaultWorkingTreeDelay;\n\t\tthis.defaultRepoMaxWaitMs = options.defaultRepoMaxWaitMs ?? defaultRepoMaxWait;\n\t\tthis.defaultWorkingTreeMaxWaitMs = options.defaultWorkingTreeMaxWaitMs ?? defaultWorkingTreeMaxWait;\n\t\tthis.effectiveRepoMs = this.defaultRepoMs;\n\t\tthis.effectiveRepoMaxWaitMs = this.defaultRepoMaxWaitMs;\n\t\tthis.effectiveWorkingTreeMs = this.defaultWorkingTreeMs;\n\t\tthis.effectiveWorkingTreeMaxWaitMs = this.defaultWorkingTreeMaxWaitMs;\n\t\tthis.repoClock = new DebounceClock(\n\t\t\t() => this.effectiveRepoMs,\n\t\t\t() => this.effectiveRepoMaxWaitMs,\n\t\t\t() => this.flushRepo(),\n\t\t);\n\t\tthis.workingTreeClock = new DebounceClock(\n\t\t\t() => this.effectiveWorkingTreeMs,\n\t\t\t() => this.effectiveWorkingTreeMaxWaitMs,\n\t\t\t() => this.flushWorkingTree(),\n\t\t);\n\t\tthis.lifecycle = options.lifecycle;\n\t\tthis.onDidFireRepoChangeCallback = options.onDidFireRepoChange;\n\t\tthis.onDidFireWorkingTreeChangeCallback = options.onDidFireWorkingTreeChange;\n\t\tthis._suspended = options.suspended ?? false;\n\t\tif (this._suspended) {\n\t\t\tthis.repoClock.suspend();\n\t\t\tthis.workingTreeClock.suspend();\n\t\t}\n\t}\n\n\t[Symbol.dispose](): void {\n\t\tthis.dispose();\n\t}\n\n\tdispose(): void {\n\t\tif (this._disposed) return;\n\n\t\tthis._disposed = true;\n\n\t\tthis.repoClock.cancel();\n\t\tthis.workingTreeClock.cancel();\n\n\t\tthis.clearPendingRepoChanges();\n\t\tthis.pendingWorkingTreePaths.clear();\n\t\tthis.pendingWorkingTreeIncomplete = false;\n\t\tthis.repoSubscribers.clear();\n\t\tthis.relevantRefsSources.clear();\n\t\tthis.workingTreeSubscribers.clear();\n\n\t\tthis.repoEmitter.dispose();\n\t\tthis.workingTreeEmitter.dispose();\n\t}\n\n\tget suspended(): boolean {\n\t\treturn this._suspended;\n\t}\n\n\tget hasPendingChanges(): boolean {\n\t\treturn this.pendingRepoChanges.size > 0 || this.hasPendingWorkingTreeChanges;\n\t}\n\n\t/**\n\t * An incomplete batch with no surviving paths still has to fire: the caller dropped paths we never saw, so\n\t * gating the pipeline on the retained set alone would swallow the change entirely.\n\t */\n\tprivate get hasPendingWorkingTreeChanges(): boolean {\n\t\treturn this.pendingWorkingTreePaths.size > 0 || this.pendingWorkingTreeIncomplete;\n\t}\n\n\tget repoSubscriberCount(): number {\n\t\treturn this.repoSubscribers.size;\n\t}\n\n\tget workingTreeSubscriberCount(): number {\n\t\treturn this.workingTreeSubscribers.size;\n\t}\n\n\t/**\n\t * Monotonic counter incremented immediately when working tree changes\n\t * are pushed (before debounce). Used by `GitCommit.hasFullDetails()`\n\t * to detect staleness of uncommitted commit data.\n\t */\n\tget etagWorkingTree(): number {\n\t\treturn this._etagWorkingTree;\n\t}\n\n\t/**\n\t * Subscribe to .git directory changes with configurable debounce.\n\t * First subscribe fires `onFirstRepoSubscriber`, last dispose\n\t * fires `onLastRepoSubscriber`.\n\t *\n\t * When multiple subscribers exist, the shortest debounce wins —\n\t * all subscribers fire on the same (fastest) cadence. `maxWaitMs` bounds how long continuous\n\t * activity can defer a flush (the shortest wins too); `Infinity` means no cap.\n\t *\n\t * `relevantRefs` narrows THIS subscription's events to the refs it cares about, given as full ref names\n\t * (`refs/heads/main`, `refs/remotes/origin/main`, `refs/tags/v1`, `refs/stash`). It is read at delivery, so it can\n\t * return the subscriber's current list. A `heads`/`remotes`/`tags`/`stash` change is delivered only when a listed\n\t * ref of that kind may have moved, when the change isn't attributable to a name (e.g. a `packed-refs` rewrite),\n\t * or, for `heads`, when a pseudo-ref (`HEAD`, `ORIG_HEAD`) moved — so `stash` and `tags` changes are dropped unless\n\t * a ref of that kind is listed. A `config` change confined to some branches' `branch.<name>` sections\n\t * (`configBranches`) is delivered only when `HEAD` or one of those branches is listed. Other change kinds always\n\t * pass, and an event left with no changes isn't delivered.\n\t * The filter never affects other subscribers, the debounce, or the global `onDidFireRepoChange` forwarding.\n\t */\n\tsubscribe(opts?: {\n\t\tdelayMs?: number;\n\t\tmaxWaitMs?: number;\n\t\trelevantRefs?: () => Iterable<string>;\n\t}): RepositorySubscription {\n\t\tif (this._disposed) {\n\t\t\treturn Object.assign(\n\t\t\t\tcreateDisposable(() => {}),\n\t\t\t\t{\n\t\t\t\t\tonDidChange: this.repoEmitter.event,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tconst id = this.repoNextId++;\n\t\tconst wasEmpty = this.repoSubscribers.size === 0;\n\n\t\tthis.repoSubscribers.set(id, {\n\t\t\tdelayMs: opts?.delayMs ?? this.defaultRepoMs,\n\t\t\tmaxWaitMs: opts?.maxWaitMs ?? this.defaultRepoMaxWaitMs,\n\t\t});\n\t\tthis.recalcRepoTiming();\n\n\t\tconst relevantRefs = opts?.relevantRefs;\n\t\tif (relevantRefs != null) {\n\t\t\tthis.relevantRefsSources.set(id, relevantRefs);\n\t\t}\n\n\t\tif (wasEmpty) {\n\t\t\tthis.lifecycle?.onFirstRepoSubscriber?.();\n\t\t}\n\n\t\t// If the effective delay or max-wait got shorter while a flush is pending, move it sooner\n\t\tthis.repoClock.rearmIfEarlier();\n\n\t\tlet subDisposed = false;\n\t\treturn Object.assign(\n\t\t\tcreateDisposable(() => {\n\t\t\t\tif (subDisposed) return;\n\n\t\t\t\tsubDisposed = true;\n\n\t\t\t\tthis.repoSubscribers.delete(id);\n\t\t\t\tthis.relevantRefsSources.delete(id);\n\t\t\t\tthis.recalcRepoTiming();\n\n\t\t\t\tif (this.repoSubscribers.size === 0) {\n\t\t\t\t\tthis.repoClock.cancel();\n\t\t\t\t\tthis.clearPendingRepoChanges();\n\t\t\t\t\tthis.lifecycle?.onLastRepoSubscriber?.();\n\t\t\t\t}\n\t\t\t}),\n\t\t\t{\n\t\t\t\tonDidChange:\n\t\t\t\t\trelevantRefs != null\n\t\t\t\t\t\t? createRelevantRefsEvent(this.repoEmitter.event, relevantRefs)\n\t\t\t\t\t\t: this.repoEmitter.event,\n\t\t\t},\n\t\t);\n\t}\n\n\t/** Every repo subscriber's current `relevantRefs` (see {@link subscribe}), unioned */\n\tgetRelevantRefs(): Set<string> {\n\t\tconst refs = new Set<string>();\n\t\tfor (const relevantRefs of this.relevantRefsSources.values()) {\n\t\t\tfor (const ref of relevantRefs()) {\n\t\t\t\trefs.add(ref);\n\t\t\t}\n\t\t}\n\t\treturn refs;\n\t}\n\n\t/** Subscribe to working tree changes; `delayMs` and `maxWaitMs` behave as in {@link subscribe}. */\n\tsubscribeToWorkingTree(opts?: { delayMs?: number; maxWaitMs?: number }): WorkingTreeSubscription {\n\t\tif (this._disposed) {\n\t\t\treturn Object.assign(\n\t\t\t\tcreateDisposable(() => {}),\n\t\t\t\t{\n\t\t\t\t\tonDidChangeWorkingTree: this.workingTreeEmitter.event,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tconst id = this.workingTreeNextId++;\n\t\tconst wasEmpty = this.workingTreeSubscribers.size === 0;\n\n\t\tthis.workingTreeSubscribers.set(id, {\n\t\t\tdelayMs: opts?.delayMs ?? this.defaultWorkingTreeMs,\n\t\t\tmaxWaitMs: opts?.maxWaitMs ?? this.defaultWorkingTreeMaxWaitMs,\n\t\t});\n\t\tthis.recalcWorkingTreeTiming();\n\n\t\tif (wasEmpty) {\n\t\t\tthis.lifecycle?.onFirstWorkingTreeSubscriber?.();\n\t\t}\n\n\t\t// If the effective delay or max-wait got shorter while a flush is pending, move it sooner\n\t\tthis.workingTreeClock.rearmIfEarlier();\n\n\t\tlet subDisposed = false;\n\t\treturn Object.assign(\n\t\t\tcreateDisposable(() => {\n\t\t\t\tif (subDisposed) return;\n\n\t\t\t\tsubDisposed = true;\n\n\t\t\t\tthis.workingTreeSubscribers.delete(id);\n\t\t\t\tthis.recalcWorkingTreeTiming();\n\n\t\t\t\tif (this.workingTreeSubscribers.size === 0) {\n\t\t\t\t\tthis.workingTreeClock.cancel();\n\t\t\t\t\tthis.pendingWorkingTreePaths.clear();\n\t\t\t\t\t// Dropped with the paths it describes — a stale flag would make the next subscriber's\n\t\t\t\t\t// first ordinary flush claim a partial set and force needless full refreshes.\n\t\t\t\t\tthis.pendingWorkingTreeIncomplete = false;\n\t\t\t\t\tthis.lifecycle?.onLastWorkingTreeSubscriber?.();\n\t\t\t\t}\n\t\t\t}),\n\t\t\t{ onDidChangeWorkingTree: this.workingTreeEmitter.event },\n\t\t);\n\t}\n\n\tsuspend(): void {\n\t\tthis._suspended = true;\n\t\t// Cancel active timers — events continue to coalesce but don't fire\n\t\tthis.repoClock.suspend();\n\t\tthis.workingTreeClock.suspend();\n\t}\n\n\tresume(delayMs?: number): void {\n\t\tif (!this._suspended) return;\n\n\t\tthis._suspended = false;\n\n\t\t// Flush accumulated changes (a clock with nothing pending stays idle); the max-wait window restarts from now\n\t\tthis.repoClock.resume(delayMs);\n\t\tthis.workingTreeClock.resume(delayMs);\n\t}\n\n\t/**\n\t * Inject changes (e.g., after a git operation the caller performed). Goes through debounce + suspend. Ref kinds\n\t * among them are unnamed — any ref of that kind may have moved.\n\t */\n\tfireChange(...changes: RepositoryChange[]): void {\n\t\tif (this._disposed || changes.length === 0) return;\n\n\t\tthis.coalesceRepo(changes, undefined, 'unfenced');\n\t}\n\n\t/** Immediate fire, bypassing debounce + suspend (for Closed/Opened). Ref kinds among them are unnamed. */\n\tfireChangeImmediate(...changes: RepositoryChange[]): void {\n\t\tif (this._disposed || changes.length === 0) return;\n\n\t\tconst event = new WatcherRepoChangeEvent(this.repoPath, changes);\n\t\t// Same contract as `flushRepo`: notify the global forwarder (which advances the cache's status clock) BEFORE\n\t\t// subscribers. Skipping it here would route changes to subscribers that no one advanced the clock for —\n\t\t// subscribers see them as session-routed and (correctly) don't re-advance, so the cache would go stale.\n\t\tthis.onDidFireRepoChangeCallback?.(event);\n\t\tthis.repoEmitter.fire(event);\n\t}\n\n\t/**\n\t * Push interpreted repo changes into the pipeline. `ref` is the full ref name (or ref directory, or pseudo-ref) whose\n\t * file changed; a ref kind in `changes` is attributed to it when the kinds match, and is otherwise unnamed.\n\t * `false` preserves cache invalidations for a config edit without claiming any ref moved. `configBranches`, for a\n\t * `config` among `changes`, are the local branches (full ref names) whose `branch.<name>` sections are all that\n\t * changed in `.git/config`; without it, the config change may be anywhere. `movedWorktree`, for a `worktreeHead`\n\t * among `changes`, is the admin id of the linked worktree whose HEAD moved; without it, any linked worktree's may\n\t * have.\n\t */\n\tpushRepoChanges(\n\t\tchanges: RepositoryChange[],\n\t\tref?: string | false,\n\t\tconfigBranches?: ReadonlySet<string>,\n\t\tmovedWorktree?: string,\n\t): void {\n\t\tif (this._disposed) return;\n\n\t\tthis.coalesceRepo(\n\t\t\tchanges,\n\t\t\tref,\n\t\t\t'raw',\n\t\t\tconfigBranches,\n\t\t\tmovedWorktree != null ? new Set([movedWorktree]) : undefined,\n\t\t);\n\t}\n\n\t/**\n\t * Push watcher-observed repo changes that no write of core's can account for — an overflow's rescan, or an ignore\n\t * rule changed in the working tree — so {@link noteSelfWrite} never replaces them or takes them for its echo. Ref\n\t * kinds are unnamed.\n\t */\n\tpushUnfencedRepoChanges(changes: RepositoryChange[]): void {\n\t\tif (this._disposed) return;\n\n\t\tthis.coalesceRepo(changes, undefined, 'unfenced');\n\t}\n\n\t/**\n\t * Core announced one of its own writes for this repository: its caches were evicted and its host notified, both\n\t * after the write finished. The announcement becomes this session's one event for the write:\n\t *\n\t * - the announced kinds are pushed through the debounce and suspend like {@link fireChange}, and the event carries\n\t * them in `announced`. A ref kind is unnamed unless `refs` names refs of that kind (the full ref names the write\n\t * moved), in which case it carries those names and no other ref of the kind counts as changed by the write.\n\t * `config` is confined to the `branch.<name>` sections of the local branches `refs` names when\n\t * `options.configConfinedToRefs` says so, and the event carries them (`configBranches`). `worktreeHead` is\n\t * confined to the linked worktrees `options.movedWorktrees` names by admin id (none, for a write that moved only\n\t * the main checkout's HEAD), and is open without it;\n\t * - a raw change of an announced kind is the write's own report of it only when it is provably within what the\n\t * write announced: a ref the write named or a ref directory holding one, a config change confined to branches\n\t * the write's config was confined to, or a `worktreeHead` report of a worktree the write named, or of none (the\n\t * `worktrees` folder, a rescan). Pending when the announcement arrives, it is replaced, save the worktrees the\n\t * write didn't name, which stay as an outside move. Arriving later, it merges and the kind stays announced only\n\t * within the repo debounce delay of the announcement; a window can stay pending for minutes while the session is\n\t * suspended, and a later move of the same ref is as likely an outside one. Any other report of the kind is an\n\t * outside change: it stays, and the kind isn't `announced`, since the host has not handled the outside part. A\n\t * write never names `HEAD`, but a commit locks it to write its reflog, so under a write that announced `head`, a\n\t * report of the `HEAD` file within the same delay is the write's echo, its `heads` part included;\n\t * - a kind the write announced open (unnamed, or `config` unconfined) covers any change of the kind: raw changes\n\t * of it still pending are replaced, since the host evicts everything of the kind after the write. One arriving\n\t * within the repo debounce delay of the announcement, before its event fires, is taken for the write's own late\n\t * echo; any later report of the kind before the event fires clears the mark.\n\t *\n\t * Once the event fires, nothing is special: an echo the watcher delivers after it causes one extra, unannounced\n\t * event (a duplicate refresh, narrowed like any other), rather than risk losing an outside change of the same kind.\n\t *\n\t * Empty `changes`, or `'unknown'`, announces every kind a watcher can report (never `'unknown'` itself, which a\n\t * cache reads as a close), open whatever `refs` says; `'closed'` and `'opened'` are ignored. Only raw `.git` changes\n\t * are replaced or kept announced: {@link fireChange}, {@link fireChangeImmediate}, {@link pushUnfencedRepoChanges}\n\t * and working-tree changes always pass.\n\t */\n\tnoteSelfWrite(\n\t\tchanges: readonly RepositoryChange[],\n\t\trefs?: readonly string[],\n\t\toptions?: { readonly configConfinedToRefs?: boolean; readonly movedWorktrees?: readonly string[] },\n\t): void {\n\t\tif (this._disposed) return;\n\n\t\tconst all = changes.length === 0 || changes.includes('unknown');\n\t\tconst announced = all ? allWatchedRepositoryChanges : changes.filter(c => isAnnounceable(c));\n\t\tconst named = all ? undefined : groupNamedRefs(changes, refs);\n\t\tconst configBranches =\n\t\t\t!all && options?.configConfinedToRefs === true && changes.includes('config')\n\t\t\t\t? getBranchRefs(refs)\n\t\t\t\t: undefined;\n\t\tconst movedWorktrees =\n\t\t\t!all && options?.movedWorktrees != null && changes.includes('worktreeHead')\n\t\t\t\t? new Set(options.movedWorktrees)\n\t\t\t\t: undefined;\n\n\t\tfor (const change of this.pendingRepoChanges) {\n\t\t\tif (this.pendingRepoUnfencedChanges.has(change) || !isAnnounceable(change)) continue;\n\t\t\tif (!all && !changes.includes(change)) continue;\n\n\t\t\tif (change === 'config' && configBranches != null) {\n\t\t\t\t// An earlier announcement's config stays and merges with this one; a raw one is replaced only when it\n\t\t\t\t// is provably this write's own report\n\t\t\t\tif (this.pendingRepoAnnounced.has(change)) continue;\n\t\t\t\tif (!isSubsetOf(this.pendingRepoConfigBranches, configBranches)) continue;\n\t\t\t} else if (change === 'worktreeHead' && movedWorktrees != null) {\n\t\t\t\t// An earlier announcement's worktrees merge with this one's. What's left of the worktrees raw reports named\n\t\t\t\t// once this write's are taken out moved outside it, so it stays, unannounced\n\t\t\t\tif (this.pendingRepoAnnounced.has(change)) continue;\n\n\t\t\t\tconst outside = this.pendingRepoMovedWorktrees;\n\t\t\t\tif (outside != null) {\n\t\t\t\t\tfor (const id of movedWorktrees) {\n\t\t\t\t\t\toutside.delete(id);\n\t\t\t\t\t}\n\t\t\t\t\tif (outside.size) continue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst names = isRefChangeKind(change) ? named?.get(change) : undefined;\n\t\t\tif (names != null) {\n\t\t\t\tfor (const name of names) {\n\t\t\t\t\tthis.pendingRepoRefs.delete(name);\n\t\t\t\t}\n\t\t\t\t// Git reports the directory it creates or removes to hold the write's ref as well. Only a raw report can\n\t\t\t\t// be that echo: a name an earlier write announced is a ref it changed, and it can sit where this write's\n\t\t\t\t// directory is (delete `team`, then create `team/task`)\n\t\t\t\t// Walked from each name, as a write can name many refs (a fetch) while many outside ones are pending\n\t\t\t\tfor (const name of names) {\n\t\t\t\t\tfor (const dir of getRefDirectories(name)) {\n\t\t\t\t\t\tif (!this.pendingRepoAnnouncedRefs.has(dir)) {\n\t\t\t\t\t\t\tthis.pendingRepoRefs.delete(dir);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// What's left of the kind came from outside the write, so it stays, unannounced\n\t\t\t\tif (this.hasPendingRefOfKind(change)) continue;\n\t\t\t}\n\n\t\t\tthis.pendingRepoChanges.delete(change);\n\t\t\tthis.pendingRepoAnnounced.delete(change);\n\t\t\tif (change === 'config') {\n\t\t\t\tthis.pendingRepoConfigBranches = undefined;\n\t\t\t} else if (change === 'worktreeHead') {\n\t\t\t\tthis.pendingRepoMovedWorktrees = undefined;\n\t\t\t}\n\t\t\tif (!isRefChangeKind(change)) continue;\n\n\t\t\t// An unnamed announcement covers any ref of the kind, so the replaced kind takes its named refs with it\n\t\t\tthis.pendingRepoUnnamedRefKinds.delete(change);\n\t\t\tfor (const ref of this.pendingRepoRefs) {\n\t\t\t\tif (getRefChangeKind(ref) === change) {\n\t\t\t\t\tthis.pendingRepoRefs.delete(ref);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (announced.length !== 0) {\n\t\t\tthis.coalesceRepo(\n\t\t\t\tnamed != null ? announced.filter(c => !isRefChangeKind(c) || !named.has(c)) : announced,\n\t\t\t\tundefined,\n\t\t\t\t'announced',\n\t\t\t\tconfigBranches,\n\t\t\t\tmovedWorktrees,\n\t\t\t);\n\t\t\tif (named != null) {\n\t\t\t\tfor (const [kind, names] of named) {\n\t\t\t\t\tfor (const name of names) {\n\t\t\t\t\t\tthis.coalesceRepo([kind], name, 'announced');\n\t\t\t\t\t\t// Only a name kept among the pending refs can be taken for a directory's echo; past the cap\n\t\t\t\t\t\t// the kind went unnamed, which covers it, so the set stays as bounded as those refs\n\t\t\t\t\t\tif (this.pendingRepoRefs.has(name)) {\n\t\t\t\t\t\t\tthis.pendingRepoAnnouncedRefs.add(name);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (this.pendingRepoChanges.size === 0) {\n\t\t\t// Nothing left to flush: idle the clock rather than let it fire an empty window\n\t\t\tthis.repoClock.cancel();\n\t\t}\n\t}\n\n\t/** Push working tree file changes into the pipeline */\n\t/** `incomplete` marks the batch as partial when the caller already dropped paths of its own. */\n\tpushWorkingTreeChanges(paths: Iterable<string>, incomplete?: boolean): void {\n\t\tif (this._disposed) return;\n\n\t\tthis._etagWorkingTree++;\n\t\tif (incomplete) {\n\t\t\tthis.pendingWorkingTreeIncomplete = true;\n\t\t}\n\t\tthis.coalesceWorkingTrees(paths);\n\t}\n\n\tprivate static minDelay(subscribers: Map<number, DebounceTiming>, fallback: number): number {\n\t\tlet min = fallback;\n\t\tfor (const { delayMs } of subscribers.values()) {\n\t\t\tif (delayMs < min) {\n\t\t\t\tmin = delayMs;\n\t\t\t}\n\t\t}\n\t\treturn min;\n\t}\n\n\t/** Unlike the delay, the default isn't a ceiling — a subscriber can opt out of the cap with `Infinity` */\n\tprivate static minMaxWait(subscribers: Map<number, DebounceTiming>, fallback: number): number {\n\t\tif (subscribers.size === 0) return fallback;\n\n\t\tlet min = Infinity;\n\t\tfor (const { maxWaitMs } of subscribers.values()) {\n\t\t\tif (maxWaitMs < min) {\n\t\t\t\tmin = maxWaitMs;\n\t\t\t}\n\t\t}\n\t\treturn min;\n\t}\n\n\tprivate recalcRepoTiming(): void {\n\t\tthis.effectiveRepoMs = RepositoryWatchSession.minDelay(this.repoSubscribers, this.defaultRepoMs);\n\t\tthis.effectiveRepoMaxWaitMs = RepositoryWatchSession.minMaxWait(\n\t\t\tthis.repoSubscribers,\n\t\t\tthis.defaultRepoMaxWaitMs,\n\t\t);\n\t}\n\n\tprivate recalcWorkingTreeTiming(): void {\n\t\tthis.effectiveWorkingTreeMs = RepositoryWatchSession.minDelay(\n\t\t\tthis.workingTreeSubscribers,\n\t\t\tthis.defaultWorkingTreeMs,\n\t\t);\n\t\tthis.effectiveWorkingTreeMaxWaitMs = RepositoryWatchSession.minMaxWait(\n\t\t\tthis.workingTreeSubscribers,\n\t\t\tthis.defaultWorkingTreeMaxWaitMs,\n\t\t);\n\t}\n\n\tprivate flushRepo(): void {\n\t\tif (this.pendingRepoChanges.size === 0) return;\n\n\t\t// The event is built only here — raw events just add to the pending sets (which the event copies)\n\t\tconst event = new WatcherRepoChangeEvent(\n\t\t\tthis.repoPath,\n\t\t\t[...this.pendingRepoChanges],\n\t\t\t{\n\t\t\t\tnames: this.pendingRepoRefs,\n\t\t\t\tunnamed: this.pendingRepoUnnamedRefKinds,\n\t\t\t\tconfigBranches: this.pendingRepoConfigBranches,\n\t\t\t},\n\t\t\tthis.pendingRepoAnnounced.keys(),\n\t\t\tthis.pendingRepoMovedWorktrees,\n\t\t);\n\t\tthis.clearPendingRepoChanges();\n\t\t// Advance any cache clock BEFORE notifying subscribers (same rationale as `flushWorkingTree`): a subscriber\n\t\t// that synchronously reads status must see the post-change generation, not a joinable pre-change run.\n\t\tthis.onDidFireRepoChangeCallback?.(event);\n\t\tthis.repoEmitter.fire(event);\n\t}\n\n\t/**\n\t * `origin` is a raw `.git` event, a push no announcement replaces ({@link fireChange},\n\t * {@link pushUnfencedRepoChanges}), or core's announced write. A kind stays announced only while nothing else\n\t * reports it in the pending window, save the write's own report of it (see {@link noteSelfWrite}).\n\t * `configBranches` confines a `config` among `changes` to those branches' sections; without it, it may be anywhere.\n\t * `movedWorktrees` names the linked worktrees whose HEAD a `worktreeHead` among `changes` moved; without it, it may\n\t * be any linked worktree's.\n\t */\n\tprivate coalesceRepo(\n\t\tchanges: readonly RepositoryChange[],\n\t\tref: string | false | undefined,\n\t\torigin: 'raw' | 'unfenced' | 'announced',\n\t\tconfigBranches?: ReadonlySet<string>,\n\t\tmovedWorktrees?: ReadonlySet<string>,\n\t): void {\n\t\tif (changes.length === 0) return;\n\n\t\tconst now = performance.now();\n\t\tconst refKind = typeof ref === 'string' ? getRefChangeKind(ref) : undefined;\n\t\tfor (const change of changes) {\n\t\t\tconst pending = this.pendingRepoChanges.has(change);\n\t\t\t// What this report is confined to: the ref it names, or the branches whose config sections it changed\n\t\t\tlet names: ReadonlySet<string> | undefined;\n\t\t\tif (origin !== 'unfenced') {\n\t\t\t\tif (change === 'config') {\n\t\t\t\t\tnames = configBranches;\n\t\t\t\t} else if (change === 'worktreeHead') {\n\t\t\t\t\tnames = movedWorktrees;\n\t\t\t\t} else if (typeof ref === 'string' && refKind === change) {\n\t\t\t\t\tnames = new Set([ref]);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst announcement = this.pendingRepoAnnounced.get(change);\n\t\t\tlet own = false;\n\t\t\tif (origin === 'announced') {\n\t\t\t\tif (!pending) {\n\t\t\t\t\tthis.pendingRepoAnnounced.set(change, {\n\t\t\t\t\t\tat: now,\n\t\t\t\t\t\tnames: names != null ? new Set(names) : undefined,\n\t\t\t\t\t});\n\t\t\t\t} else if (announcement != null) {\n\t\t\t\t\t// Added in place: a write naming many refs arrives here once per name, and copying the set each\n\t\t\t\t\t// time would cost quadratic time in the number of refs it moved\n\t\t\t\t\tif (announcement.names != null && names != null) {\n\t\t\t\t\t\tfor (const name of names) {\n\t\t\t\t\t\t\tannouncement.names.add(name);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tannouncement.names = undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\town = origin === 'raw' && announcement != null && this.isOwnReport(change, announcement, names, now);\n\t\t\t\tif (announcement != null && !own) {\n\t\t\t\t\tthis.pendingRepoAnnounced.delete(change);\n\t\t\t\t} else if (!pending && origin === 'raw' && this.isHeadEcho(change, names, now)) {\n\t\t\t\t\t// A detached HEAD's move announces head without heads, and the HEAD file is all it wrote\n\t\t\t\t\tthis.pendingRepoAnnounced.set(change, { at: now, names: new Set(names) });\n\t\t\t\t}\n\t\t\t\tif (origin === 'unfenced') {\n\t\t\t\t\tthis.pendingRepoUnfencedChanges.add(change);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (change === 'config') {\n\t\t\t\tlet branches: Set<string> | undefined;\n\t\t\t\tif (!pending) {\n\t\t\t\t\tbranches = names != null ? new Set(names) : undefined;\n\t\t\t\t} else if (this.pendingRepoConfigBranches != null && names != null) {\n\t\t\t\t\tbranches = new Set([...this.pendingRepoConfigBranches, ...names]);\n\t\t\t\t}\n\t\t\t\tthis.pendingRepoConfigBranches =\n\t\t\t\t\tbranches != null && branches.size <= maxPendingRefNames ? branches : undefined;\n\t\t\t} else if (change === 'worktreeHead') {\n\t\t\t\tif (!pending) {\n\t\t\t\t\tthis.pendingRepoMovedWorktrees = new Set();\n\t\t\t\t}\n\t\t\t\t// The worktrees a write named, and its own reports of them, moved no HEAD outside it\n\t\t\t\tif (names == null && !own) {\n\t\t\t\t\tthis.pendingRepoMovedWorktrees = undefined;\n\t\t\t\t} else if (names != null && !own && origin !== 'announced') {\n\t\t\t\t\tfor (const id of names) {\n\t\t\t\t\t\tthis.pendingRepoMovedWorktrees?.add(id);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.pendingRepoChanges.add(change);\n\t\t\tif (ref === false || !isRefChangeKind(change)) continue;\n\n\t\t\tif (\n\t\t\t\tref != null &&\n\t\t\t\trefKind === change &&\n\t\t\t\t(this.pendingRepoRefs.size < maxPendingRefNames || this.pendingRepoRefs.has(ref))\n\t\t\t) {\n\t\t\t\tthis.pendingRepoRefs.add(ref);\n\t\t\t} else {\n\t\t\t\tthis.pendingRepoUnnamedRefKinds.add(change);\n\t\t\t}\n\t\t}\n\t\tthis.repoClock.note();\n\t}\n\n\t/**\n\t * Whether a raw report of `change`, confined to `names` (`undefined`: not confined), is the announced write's own.\n\t * It must arrive within the repo debounce delay of the announcement, as it always had to. An open announcement\n\t * asks nothing more; one confined to names also needs every name the report carries to be one the write announced,\n\t * save the `heads` part of a `HEAD` report under a write that announced `head` in time, which is a commit's echo. A\n\t * `worktreeHead` report naming no worktree (the `worktrees` folder, a rescan) can't be told apart from the write's.\n\t */\n\tprivate isOwnReport(\n\t\tchange: RepositoryChange,\n\t\tannouncement: PendingAnnouncement,\n\t\tnames: ReadonlySet<string> | undefined,\n\t\tnow: number,\n\t): boolean {\n\t\tif (now - announcement.at > this.effectiveRepoMs) return false;\n\t\tif (announcement.names == null) return true;\n\t\tif (names == null) return change === 'worktreeHead';\n\t\t// A ref and a directory of the same name can't coexist, which is what lets a directory report stand for its\n\t\t// refs; config sections `branch.team` and `branch.team/task` can\n\t\tif (isRefChangeKind(change) ? isCoveredBy(names, announcement.names) : isSubsetOf(names, announcement.names)) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn this.isHeadEcho(change, names, now);\n\t}\n\n\t/** Whether a raw `heads` report confined to `HEAD` is the echo of a write that announced `head` in time */\n\tprivate isHeadEcho(change: RepositoryChange, names: ReadonlySet<string> | undefined, now: number): boolean {\n\t\tif (change !== 'heads' || names?.size !== 1 || !names.has('HEAD')) return false;\n\n\t\tconst head = this.pendingRepoAnnounced.get('head');\n\t\treturn head != null && now - head.at <= this.effectiveRepoMs;\n\t}\n\n\t/** Whether a pending report of `kind` remains, unnamed or under a name */\n\tprivate hasPendingRefOfKind(kind: RepositoryChange): boolean {\n\t\tif (!isRefChangeKind(kind)) return false;\n\t\tif (this.pendingRepoUnnamedRefKinds.has(kind)) return true;\n\n\t\tfor (const ref of this.pendingRepoRefs) {\n\t\t\tif (getRefChangeKind(ref) === kind) return true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate clearPendingRepoChanges(): void {\n\t\tthis.pendingRepoChanges.clear();\n\t\tthis.pendingRepoRefs.clear();\n\t\tthis.pendingRepoUnnamedRefKinds.clear();\n\t\tthis.pendingRepoUnfencedChanges.clear();\n\t\tthis.pendingRepoAnnounced.clear();\n\t\tthis.pendingRepoAnnouncedRefs.clear();\n\t\tthis.pendingRepoConfigBranches = undefined;\n\t\tthis.pendingRepoMovedWorktrees = undefined;\n\t}\n\n\tprivate flushWorkingTree(): void {\n\t\tif (!this.hasPendingWorkingTreeChanges) return;\n\n\t\tconst paths = this.pendingWorkingTreePaths;\n\t\tconst incomplete = this.pendingWorkingTreeIncomplete;\n\t\tthis.pendingWorkingTreePaths = new Set();\n\t\tthis.pendingWorkingTreeIncomplete = false;\n\t\t// Advance the cache's status clock (via WatchService's global forwarding) BEFORE notifying subscribers,\n\t\t// so a subscriber that synchronously reads status sees the post-change generation, not a joinable pre-change run.\n\t\tthis.onDidFireWorkingTreeChangeCallback?.(this.repoPath);\n\t\tthis.workingTreeEmitter.fire({ repoPath: this.repoPath, paths: paths, incomplete: incomplete });\n\t}\n\n\tprivate coalesceWorkingTrees(paths: Iterable<string>): void {\n\t\tfor (const p of paths) {\n\t\t\t// Stop retaining paths past the cap, but keep draining the iterable — the flag is what makes the\n\t\t\t// partial set safe to consume, and dropping out early would leave later paths for the next window.\n\t\t\tif (this.pendingWorkingTreePaths.size >= maxWorkingTreePaths && !this.pendingWorkingTreePaths.has(p)) {\n\t\t\t\tthis.pendingWorkingTreeIncomplete = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tthis.pendingWorkingTreePaths.add(p);\n\t\t}\n\n\t\tif (this.hasPendingWorkingTreeChanges) {\n\t\t\tthis.workingTreeClock.note();\n\t\t}\n\t}\n}\n\n/** `'closed'` and `'opened'` are lifecycle, not a write's effect, so an announcement never replaces or names them */\nfunction isAnnounceable(change: RepositoryChange): boolean {\n\treturn change !== 'closed' && change !== 'opened';\n}\n\n/**\n * The names in `refs` grouped by their ref kind, for the ref kinds among `changes` only; `undefined` when none is named.\n * Pseudo-refs (`HEAD`) are left out: a write names the refs it moved, and those are full ref names.\n */\nfunction groupNamedRefs(\n\tchanges: readonly RepositoryChange[],\n\trefs: readonly string[] | undefined,\n): Map<RefChangeKind, Set<string>> | undefined {\n\tif (!refs?.length) return undefined;\n\n\tlet named: Map<RefChangeKind, Set<string>> | undefined;\n\tfor (const ref of refs) {\n\t\tif (!ref.startsWith('refs/')) continue;\n\n\t\tconst kind = getRefChangeKind(ref);\n\t\tif (kind == null || !changes.includes(kind)) continue;\n\n\t\tnamed ??= new Map();\n\t\tlet names = named.get(kind);\n\t\tif (names == null) {\n\t\t\tnames = new Set();\n\t\t\tnamed.set(kind, names);\n\t\t}\n\t\tnames.add(ref);\n\t}\n\treturn named;\n}\n\n/** The local branches among `refs` (full `refs/heads/` names), or `undefined` when there are none */\nfunction getBranchRefs(refs: readonly string[] | undefined): Set<string> | undefined {\n\tlet branches: Set<string> | undefined;\n\tfor (const ref of refs ?? []) {\n\t\tif (ref.startsWith('refs/heads/')) {\n\t\t\t(branches ??= new Set()).add(ref);\n\t\t}\n\t}\n\treturn branches;\n}\n\n/**\n * Whether `ref` is a ref directory holding one of `names` (compared on `/` boundaries). A namespace root\n * (`refs/heads`) or a pseudo-ref is no such directory, so a report of it is never a write's own by this rule.\n */\nfunction isRefDirectoryOfAny(ref: string, names: ReadonlySet<string>): boolean {\n\tif (!ref.startsWith('refs/') || getRefChangeKind(ref) == null) return false;\n\n\tconst prefix = `${ref}/`;\n\tfor (const name of names) {\n\t\tif (name.startsWith(prefix)) return true;\n\t}\n\treturn false;\n}\n\n/**\n * The ref directories holding `ref`, innermost first, each of `ref`'s own kind; never a namespace root (`refs/heads`),\n * as {@link isRefDirectoryOfAny} counts them\n */\nfunction* getRefDirectories(ref: string): Iterable<string> {\n\tfor (let index = ref.lastIndexOf('/'); index > 0; index = ref.lastIndexOf('/', index - 1)) {\n\t\tconst dir = ref.substring(0, index);\n\t\tif (!dir.startsWith('refs/') || getRefChangeKind(dir) == null) return;\n\n\t\tyield dir;\n\t}\n}\n\n/**\n * Whether every name in `names` is one in `of` or a ref directory holding one; never for `undefined`, which stands for\n * any name\n */\nfunction isCoveredBy(names: ReadonlySet<string> | undefined, of: ReadonlySet<string>): boolean {\n\tif (names == null) return false;\n\n\tfor (const name of names) {\n\t\tif (!of.has(name) && !isRefDirectoryOfAny(name, of)) return false;\n\t}\n\treturn true;\n}\n\n/** Whether every name in `names` is in `of`; never for `undefined`, which stands for any name */\nfunction isSubsetOf(names: ReadonlySet<string> | undefined, of: ReadonlySet<string>): boolean {\n\tif (names == null) return false;\n\n\tfor (const name of names) {\n\t\tif (!of.has(name)) return false;\n\t}\n\treturn true;\n}\n\n/** Wraps a session's repo event so each delivery is narrowed to the subscriber's relevant refs (see `subscribe`) */\nfunction createRelevantRefsEvent(\n\tevent: Event<WatcherRepoChangeEvent>,\n\trelevantRefs: () => Iterable<string>,\n): Event<WatcherRepoChangeEvent> {\n\treturn (listener, thisArgs, disposables) =>\n\t\tevent(\n\t\t\te => {\n\t\t\t\tconst narrowed = narrowToRelevantRefs(e, relevantRefs);\n\t\t\t\tif (narrowed != null) {\n\t\t\t\t\tlistener.call(thisArgs, narrowed);\n\t\t\t\t}\n\t\t\t},\n\t\t\tundefined,\n\t\t\tdisposables,\n\t\t);\n}\n\n/**\n * Narrows an event to the refs a subscriber cares about. Returns the event itself when no change kind is removed (the\n * kept names then stay a superset, which only makes `mayHaveChangedRef` more conservative), `undefined` when every kind\n * is removed, and otherwise a new event with the kept kinds, names and unnamed kinds. A `config` change confined to\n * some local branches' sections is removed unless a relevant ref is `HEAD` or one of those branches (see\n * `mayHaveChangedConfig`).\n */\nfunction narrowToRelevantRefs(\n\te: WatcherRepoChangeEvent,\n\trelevantRefs: () => Iterable<string>,\n): WatcherRepoChangeEvent | undefined {\n\t// Ref kinds that pass only if a relevant ref of that kind may have moved\n\tlet unresolved: Set<RefChangeKind> | undefined;\n\tfor (const change of e.changes) {\n\t\tif (!isRefChangeKind(change) || e.unnamedRefKinds.has(change)) continue;\n\n\t\t(unresolved ??= new Set()).add(change);\n\t}\n\t// A confined `config` passes only if a relevant ref is one of the branches it is confined to\n\tconst configBranches = e.configBranches;\n\tlet keepConfig = configBranches == null;\n\tif (unresolved == null && keepConfig) return e;\n\n\tunresolved ??= new Set();\n\n\tconst pseudoRefs: string[] = [];\n\tfor (const name of e.refs) {\n\t\tif (!name.startsWith('refs/')) {\n\t\t\tpseudoRefs.push(name);\n\t\t}\n\t}\n\tif (pseudoRefs.length !== 0) {\n\t\t// A pseudo-ref (`HEAD`, `ORIG_HEAD`) moving is a `heads` change for every subscriber\n\t\tunresolved.delete('heads');\n\t\tif (unresolved.size === 0 && keepConfig) return e;\n\t}\n\n\t// Names that equal or cover a relevant ref — collected as we go, since `relevantRefs` may be a one-shot iterable\n\tconst keptNames = new Set<string>(pseudoRefs);\n\tfor (const ref of relevantRefs()) {\n\t\t// `HEAD` is usually a symref to the checked-out branch, so any `heads` change may have moved it, and any branch's\n\t\t// config section may be its branch's\n\t\tif (ref === 'HEAD') {\n\t\t\tif (e.changes.has('heads')) {\n\t\t\t\tfor (const name of e.refs) {\n\t\t\t\t\tif (getRefChangeKind(name) === 'heads') {\n\t\t\t\t\t\tkeptNames.add(name);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tkeepConfig = true;\n\t\t\tunresolved.delete('heads');\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!keepConfig && configBranches?.has(ref)) {\n\t\t\tkeepConfig = true;\n\t\t}\n\n\t\tconst kind = getRefChangeKind(ref);\n\t\tif (kind == null || !e.changes.has(kind)) continue;\n\n\t\tconst covering = findCoveringRefName(e.refs, ref);\n\t\tif (covering == null) continue;\n\n\t\tkeptNames.add(covering);\n\t\tunresolved.delete(kind);\n\t}\n\tif (unresolved.size === 0 && keepConfig) return e;\n\n\tconst keptChanges: RepositoryChange[] = [];\n\tfor (const change of e.changes) {\n\t\tif (change === 'config' ? keepConfig : !isRefChangeKind(change) || !unresolved.has(change)) {\n\t\t\tkeptChanges.push(change);\n\t\t}\n\t}\n\tif (keptChanges.length === 0) return undefined;\n\n\treturn new WatcherRepoChangeEvent(\n\t\te.repoPath,\n\t\tkeptChanges,\n\t\t{ names: keptNames, unnamed: e.unnamedRefKinds, configBranches: configBranches },\n\t\te.announced,\n\t\te.movedWorktrees,\n\t);\n}\n"],"mappings":";;;;;;AAgEA,MAAa,mBAAmB;AAChC,MAAM,0BAA0B;AAChC,MAAM,qBAAqB;AAC3B,MAAM,4BAA4B;;AAGlC,MAAM,gBAAgB;;;;;;;;;;;AAiBtB,IAAM,gBAAN,MAAoB;CAWD;CACA;CACA;CAZlB,SAAiB;CACjB,SAAiB;CACjB,UAAkB;CAClB,SAAiB;CACjB;CACA,aAAqB;;CAErB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EAAE,UACF,aACA;EAAE,OAAO;EAAW,SAAS,EAAE;EAAiC;CAAe,GAC/E,EAAE,WACF,EAAE,cACH;AACD"}
|
|
1
|
+
{"version":3,"file":"watchSession.js","names":[],"sources":["../../../../git/src/watching/watchSession.ts"],"sourcesContent":["import type { UnifiedDisposable } from '@gitlens/utils/disposable.js';\nimport { createDisposable } from '@gitlens/utils/disposable.js';\nimport type { Event } from '@gitlens/utils/event.js';\nimport { Emitter } from '@gitlens/utils/event.js';\nimport type { RepositoryChange } from '../models/repository.js';\nimport type { RefChangeKind, WorkingTreeChangeEvent } from './changeEvent.js';\nimport { findCoveringRefName, getRefChangeKind, isRefChangeKind, WatcherRepoChangeEvent } from './changeEvent.js';\nimport { nextChangeOrdinal } from './changeOrdinal.js';\nimport { allWatchedRepositoryChanges } from './classifyChange.js';\n\nexport interface RepositorySubscription extends UnifiedDisposable {\n\treadonly onDidChange: Event<WatcherRepoChangeEvent>;\n}\n\nexport interface WorkingTreeSubscription extends UnifiedDisposable {\n\treadonly onDidChangeWorkingTree: Event<WorkingTreeChangeEvent>;\n}\n\n/**\n * Lifecycle callbacks fired by the session when subscriber counts\n * cross the 0↔1 boundary. The host (WatchService) uses these to\n * lazily create/destroy watchers.\n */\nexport interface WatchSessionLifecycle {\n\t/** Called when the first repo-change subscriber joins */\n\tonFirstRepoSubscriber?(): void;\n\t/** Called when the last repo-change subscriber leaves */\n\tonLastRepoSubscriber?(): void;\n\t/** Called when the first working-tree subscriber joins */\n\tonFirstWorkingTreeSubscriber?(): void;\n\t/** Called when the last working-tree subscriber leaves */\n\tonLastWorkingTreeSubscriber?(): void;\n}\n\nexport interface WatchSessionOptions {\n\treadonly repoPath: string;\n\t/** Default debounce for repo changes. Default: 250ms */\n\treadonly defaultRepoDelayMs?: number;\n\t/** Default debounce for working tree changes. Default: 2500ms */\n\treadonly defaultWorkingTreeDelayMs?: number;\n\t/**\n\t * Default cap on how long repo changes can be held back by continuous activity — a flush happens at most this long\n\t * after the first pending change, however long the burst lasts. `Infinity` disables the cap. Default: 2000ms\n\t */\n\treadonly defaultRepoMaxWaitMs?: number;\n\t/** Default cap on how long working tree changes can be held back by continuous activity. `Infinity` disables the cap. Default: 10000ms */\n\treadonly defaultWorkingTreeMaxWaitMs?: number;\n\treadonly lifecycle?: WatchSessionLifecycle;\n\t/** Initial suspended state — new sessions inherit the service-global suspend state. Default: false */\n\treadonly suspended?: boolean;\n\t/**\n\t * Called whenever a debounced repo change event is dispatched to subscribers.\n\t * Does NOT count as a subscriber — used by WatchService for\n\t * global event forwarding without affecting lifecycle callbacks.\n\t */\n\treadonly onDidFireRepoChange?: (event: WatcherRepoChangeEvent) => void;\n\t/**\n\t * Called whenever a debounced working-tree change is dispatched to subscribers. Like\n\t * {@link onDidFireRepoChange}, does NOT count as a subscriber — used by WatchService for global\n\t * event forwarding (the single point that drives the cache's status clock for working-tree edits).\n\t */\n\treadonly onDidFireWorkingTreeChange?: (repoPath: string) => void;\n}\n\n/** The debounce a repo subscriber gets when it names none */\nexport const defaultRepoDelay = 250;\nconst defaultWorkingTreeDelay = 2500;\nconst defaultRepoMaxWait = 2000;\nconst defaultWorkingTreeMaxWait = 10000;\n\n/** Largest delay `setTimeout` honors (a signed 32-bit int); anything longer fires immediately */\nconst maxTimerDelay = 0x7fffffff;\n\ninterface DebounceTiming {\n\treadonly delayMs: number;\n\treadonly maxWaitMs: number;\n}\n\n/**\n * Trailing-deadline debounce with a max-wait, shared by the repo and working-tree pipelines.\n *\n * Recording an event costs a `performance.now()` and, only when no timer is armed, one `setTimeout` — never a\n * `clearTimeout`/`setTimeout` pair per event, which is what made a busy repo allocate (and starve) on every raw\n * watcher event. The armed timer is a deadline, not a countdown: when it fires it recomputes the due time from the\n * latest timestamps and either flushes or re-arms for the remainder. The due time is\n * `min(lastEventAt + delay, firstPendingAt + maxWait)`, so continuous activity is flushed at the max-wait instead of\n * never. Monotonic time, so a wall-clock change can't push a deadline out.\n */\nclass DebounceClock {\n\tprivate active = false;\n\tprivate paused = false;\n\tprivate firstAt = 0;\n\tprivate lastAt = 0;\n\tprivate timer: ReturnType<typeof setTimeout> | undefined;\n\tprivate timerDueAt = 0;\n\t/** Absolute flush time set by {@link resume}; dropped by the next event, which returns to normal debounce */\n\tprivate resumeDueAt: number | undefined;\n\n\tconstructor(\n\t\tprivate readonly getDelayMs: () => number,\n\t\tprivate readonly getMaxWaitMs: () => number,\n\t\tprivate readonly onDue: () => void,\n\t) {}\n\n\t/** Records an event; arms the timer only if none is armed. Cheap enough to call per raw event. */\n\tnote(): void {\n\t\tconst now = performance.now();\n\t\tif (!this.active) {\n\t\t\tthis.active = true;\n\t\t\tthis.firstAt = now;\n\t\t}\n\t\tthis.lastAt = now;\n\n\t\tif (this.paused) return;\n\n\t\tif (this.resumeDueAt != null) {\n\t\t\t// The first event after a resume goes back to normal debounce — which may be due sooner than the resume deadline\n\t\t\tthis.resumeDueAt = undefined;\n\t\t\tthis.rearmIfEarlier();\n\t\t}\n\n\t\tif (this.timer == null) {\n\t\t\tthis.arm(this.getDueAt(), now);\n\t\t}\n\t}\n\n\t/** Moves the armed timer earlier when the due time shrank (a subscriber joined with a shorter delay or max-wait) */\n\trearmIfEarlier(): void {\n\t\tif (!this.active || this.paused || this.timer == null) return;\n\n\t\tconst dueAt = this.getDueAt();\n\t\tif (dueAt >= this.timerDueAt) return;\n\n\t\tclearTimeout(this.timer);\n\t\tthis.arm(dueAt, performance.now());\n\t}\n\n\t/** Cancels the timer; events keep accumulating but nothing is due until {@link resume} */\n\tsuspend(): void {\n\t\tthis.paused = true;\n\t\tthis.clearTimer();\n\t}\n\n\t/**\n\t * Restarts the max-wait window from now and schedules the flush for `delayMs` from now (the effective delay when\n\t * omitted). Does nothing if no events are pending.\n\t */\n\tresume(delayMs?: number): void {\n\t\tthis.paused = false;\n\t\tif (!this.active) return;\n\n\t\tconst now = performance.now();\n\t\tthis.firstAt = now;\n\t\tthis.resumeDueAt = now + (delayMs ?? this.getDelayMs());\n\t\tthis.clearTimer();\n\t\tthis.arm(this.resumeDueAt, now);\n\t}\n\n\t/** Drops the pending window and the timer */\n\tcancel(): void {\n\t\tthis.active = false;\n\t\tthis.resumeDueAt = undefined;\n\t\tthis.clearTimer();\n\t}\n\n\tprivate getDueAt(): number {\n\t\treturn this.resumeDueAt ?? Math.min(this.lastAt + this.getDelayMs(), this.firstAt + this.getMaxWaitMs());\n\t}\n\n\tprivate arm(dueAt: number, now: number): void {\n\t\tthis.timerDueAt = dueAt;\n\t\tthis.timer = setTimeout(() => this.onTimer(), Math.min(Math.max(0, dueAt - now), maxTimerDelay));\n\t}\n\n\tprivate onTimer(): void {\n\t\tthis.timer = undefined;\n\t\tif (!this.active || this.paused) return;\n\n\t\tconst now = performance.now();\n\t\tconst dueAt = this.getDueAt();\n\t\tif (dueAt > now) {\n\t\t\tthis.arm(dueAt, now);\n\t\t\treturn;\n\t\t}\n\n\t\t// Reset before firing so an event raised by a subscriber starts a fresh window\n\t\tthis.cancel();\n\t\tthis.onDue();\n\t}\n\n\tprivate clearTimer(): void {\n\t\tif (this.timer != null) {\n\t\t\tclearTimeout(this.timer);\n\t\t\tthis.timer = undefined;\n\t\t}\n\t}\n}\n\n/**\n * Cap on retained working-tree paths per flush. The set otherwise grows without bound — while the window\n * is unfocused the session is suspended, so a branch switch or build accumulates every touched path until\n * refocus. Set low deliberately: ordinary edits are a handful of paths, anything past this was a\n * refresh-everything event anyway, and dropping past it only costs the matching consumers a\n * conservative refresh.\n */\nconst maxWorkingTreePaths = 1000;\n\n/**\n * Cap on retained ref names per flush, for the same reason (a fetch of many refs while suspended). Past it, a ref kind\n * is recorded unnamed — any ref of that kind may have moved — which only makes `mayHaveChangedRef` more conservative.\n * A pending `config` confined to more branches than this is recorded unconfined, for the same reason.\n */\nconst maxPendingRefNames = 1000;\n\n/**\n * What core's announced writes in the pending window said about one kind: when it was first announced, and the full\n * ref names it was confined to (for `config`, the branches whose sections it changed; for `worktreeHead`, the admin ids\n * of the linked worktrees whose HEAD it moved); `names` is absent when an announcement left the kind open — any ref of\n * it, any part of the config, or any linked worktree's HEAD may have changed.\n */\ninterface PendingAnnouncement {\n\treadonly at: number;\n\tnames: Set<string> | undefined;\n}\n\n/**\n * Per-repository session that owns the debounce/coalesce/suspend\n * pipeline for both repo (.git) and working-tree changes.\n *\n * Multiple subscribers share the same pipeline — the shortest\n * requested debounce delay wins, and so does the shortest max-wait.\n */\nexport class RepositoryWatchSession implements UnifiedDisposable {\n\treadonly repoPath: string;\n\n\tprivate readonly repoEmitter = new Emitter<WatcherRepoChangeEvent>();\n\tprivate readonly repoSubscribers = new Map<number, DebounceTiming>(); // subscriberId → timing\n\tprivate repoNextId = 0;\n\t/** Each repo subscriber's `relevantRefs`, for {@link getRelevantRefs} */\n\tprivate readonly relevantRefsSources = new Map<number, () => Iterable<string>>(); // subscriberId → relevantRefs\n\tprivate readonly pendingRepoChanges = new Set<RepositoryChange>();\n\t/** Full ref names, ref directories and pseudo-refs whose files changed, flushed with {@link pendingRepoChanges} */\n\tprivate readonly pendingRepoRefs = new Set<string>();\n\t/** Ref kinds that changed without a name, flushed with {@link pendingRepoChanges} */\n\tprivate readonly pendingRepoUnnamedRefKinds = new Set<RefChangeKind>();\n\t/** Kinds among {@link pendingRepoChanges} injected or pushed unfenced, which an announcement never replaces */\n\tprivate readonly pendingRepoUnfencedChanges = new Set<RepositoryChange>();\n\t/**\n\t * Kinds among {@link pendingRepoChanges} that only core's announced writes, and their own echoes, reported (see\n\t * {@link noteSelfWrite})\n\t */\n\tprivate readonly pendingRepoAnnounced = new Map<RepositoryChange, PendingAnnouncement>();\n\t/**\n\t * Refs core's writes named since the last flush, kept when an outside report makes their kind unannounced: each is\n\t * a ref a write changed, never the echo of a ref directory\n\t */\n\tprivate readonly pendingRepoAnnouncedRefs = new Set<string>();\n\t/**\n\t * For a pending `config` change, the branches (full ref names) whose sections are all that every report of it\n\t * changed; `undefined` once any report may have changed anything else\n\t */\n\tprivate pendingRepoConfigBranches: Set<string> | undefined;\n\t/**\n\t * For a pending `worktreeHead` change, the admin ids of the linked worktrees whose HEAD moved outside core's announced\n\t * writes, as the reports not taken for a write's own named them; `undefined` once any such report, or an open\n\t * announcement, may have been any linked worktree's\n\t */\n\tprivate pendingRepoMovedWorktrees: Set<string> | undefined;\n\t/** The change ordinal taken when the newest report among {@link pendingRepoChanges} arrived */\n\tprivate pendingRepoObservedAt: number | undefined;\n\t/**\n\t * Whether {@link pendingRepoChanges} hold an injected or unfenced change, which may be told before it is on disk, so\n\t * the window can't say when its changes were observed\n\t */\n\tprivate pendingRepoUnstamped = false;\n\tprivate readonly repoClock: DebounceClock;\n\tprivate effectiveRepoMs: number;\n\tprivate effectiveRepoMaxWaitMs: number;\n\tprivate readonly defaultRepoMs: number;\n\tprivate readonly defaultRepoMaxWaitMs: number;\n\n\tprivate readonly workingTreeEmitter = new Emitter<WorkingTreeChangeEvent>();\n\tprivate readonly workingTreeSubscribers = new Map<number, DebounceTiming>();\n\tprivate workingTreeNextId = 0;\n\tprivate pendingWorkingTreePaths = new Set<string>();\n\tprivate pendingWorkingTreeIncomplete = false;\n\tprivate readonly workingTreeClock: DebounceClock;\n\tprivate effectiveWorkingTreeMs: number;\n\tprivate effectiveWorkingTreeMaxWaitMs: number;\n\tprivate readonly defaultWorkingTreeMs: number;\n\tprivate readonly defaultWorkingTreeMaxWaitMs: number;\n\n\tprivate _etagWorkingTree = 0;\n\tprivate _suspended: boolean;\n\tprivate _disposed = false;\n\n\tprivate readonly lifecycle?: WatchSessionLifecycle;\n\tprivate readonly onDidFireRepoChangeCallback?: (event: WatcherRepoChangeEvent) => void;\n\tprivate readonly onDidFireWorkingTreeChangeCallback?: (repoPath: string) => void;\n\n\tconstructor(options: WatchSessionOptions) {\n\t\tthis.repoPath = options.repoPath;\n\t\tthis.defaultRepoMs = options.defaultRepoDelayMs ?? defaultRepoDelay;\n\t\tthis.defaultWorkingTreeMs = options.defaultWorkingTreeDelayMs ?? defaultWorkingTreeDelay;\n\t\tthis.defaultRepoMaxWaitMs = options.defaultRepoMaxWaitMs ?? defaultRepoMaxWait;\n\t\tthis.defaultWorkingTreeMaxWaitMs = options.defaultWorkingTreeMaxWaitMs ?? defaultWorkingTreeMaxWait;\n\t\tthis.effectiveRepoMs = this.defaultRepoMs;\n\t\tthis.effectiveRepoMaxWaitMs = this.defaultRepoMaxWaitMs;\n\t\tthis.effectiveWorkingTreeMs = this.defaultWorkingTreeMs;\n\t\tthis.effectiveWorkingTreeMaxWaitMs = this.defaultWorkingTreeMaxWaitMs;\n\t\tthis.repoClock = new DebounceClock(\n\t\t\t() => this.effectiveRepoMs,\n\t\t\t() => this.effectiveRepoMaxWaitMs,\n\t\t\t() => this.flushRepo(),\n\t\t);\n\t\tthis.workingTreeClock = new DebounceClock(\n\t\t\t() => this.effectiveWorkingTreeMs,\n\t\t\t() => this.effectiveWorkingTreeMaxWaitMs,\n\t\t\t() => this.flushWorkingTree(),\n\t\t);\n\t\tthis.lifecycle = options.lifecycle;\n\t\tthis.onDidFireRepoChangeCallback = options.onDidFireRepoChange;\n\t\tthis.onDidFireWorkingTreeChangeCallback = options.onDidFireWorkingTreeChange;\n\t\tthis._suspended = options.suspended ?? false;\n\t\tif (this._suspended) {\n\t\t\tthis.repoClock.suspend();\n\t\t\tthis.workingTreeClock.suspend();\n\t\t}\n\t}\n\n\t[Symbol.dispose](): void {\n\t\tthis.dispose();\n\t}\n\n\tdispose(): void {\n\t\tif (this._disposed) return;\n\n\t\tthis._disposed = true;\n\n\t\tthis.repoClock.cancel();\n\t\tthis.workingTreeClock.cancel();\n\n\t\tthis.clearPendingRepoChanges();\n\t\tthis.pendingWorkingTreePaths.clear();\n\t\tthis.pendingWorkingTreeIncomplete = false;\n\t\tthis.repoSubscribers.clear();\n\t\tthis.relevantRefsSources.clear();\n\t\tthis.workingTreeSubscribers.clear();\n\n\t\tthis.repoEmitter.dispose();\n\t\tthis.workingTreeEmitter.dispose();\n\t}\n\n\tget suspended(): boolean {\n\t\treturn this._suspended;\n\t}\n\n\tget hasPendingChanges(): boolean {\n\t\treturn this.pendingRepoChanges.size > 0 || this.hasPendingWorkingTreeChanges;\n\t}\n\n\t/**\n\t * An incomplete batch with no surviving paths still has to fire: the caller dropped paths we never saw, so\n\t * gating the pipeline on the retained set alone would swallow the change entirely.\n\t */\n\tprivate get hasPendingWorkingTreeChanges(): boolean {\n\t\treturn this.pendingWorkingTreePaths.size > 0 || this.pendingWorkingTreeIncomplete;\n\t}\n\n\tget repoSubscriberCount(): number {\n\t\treturn this.repoSubscribers.size;\n\t}\n\n\tget workingTreeSubscriberCount(): number {\n\t\treturn this.workingTreeSubscribers.size;\n\t}\n\n\t/**\n\t * Monotonic counter incremented immediately when working tree changes\n\t * are pushed (before debounce). Used by `GitCommit.hasFullDetails()`\n\t * to detect staleness of uncommitted commit data.\n\t */\n\tget etagWorkingTree(): number {\n\t\treturn this._etagWorkingTree;\n\t}\n\n\t/**\n\t * Subscribe to .git directory changes with configurable debounce.\n\t * First subscribe fires `onFirstRepoSubscriber`, last dispose\n\t * fires `onLastRepoSubscriber`.\n\t *\n\t * When multiple subscribers exist, the shortest debounce wins —\n\t * all subscribers fire on the same (fastest) cadence. `maxWaitMs` bounds how long continuous\n\t * activity can defer a flush (the shortest wins too); `Infinity` means no cap.\n\t *\n\t * `relevantRefs` narrows THIS subscription's events to the refs it cares about, given as full ref names\n\t * (`refs/heads/main`, `refs/remotes/origin/main`, `refs/tags/v1`, `refs/stash`). It is read at delivery, so it can\n\t * return the subscriber's current list. A `heads`/`remotes`/`tags`/`stash` change is delivered only when a listed\n\t * ref of that kind may have moved, when the change isn't attributable to a name (e.g. a `packed-refs` rewrite),\n\t * or, for `heads`, when a pseudo-ref (`HEAD`, `ORIG_HEAD`) moved — so `stash` and `tags` changes are dropped unless\n\t * a ref of that kind is listed. A `config` change confined to some branches' `branch.<name>` sections\n\t * (`configBranches`) is delivered only when `HEAD` or one of those branches is listed. Other change kinds always\n\t * pass, and an event left with no changes isn't delivered.\n\t * The filter never affects other subscribers, the debounce, or the global `onDidFireRepoChange` forwarding.\n\t */\n\tsubscribe(opts?: {\n\t\tdelayMs?: number;\n\t\tmaxWaitMs?: number;\n\t\trelevantRefs?: () => Iterable<string>;\n\t}): RepositorySubscription {\n\t\tif (this._disposed) {\n\t\t\treturn Object.assign(\n\t\t\t\tcreateDisposable(() => {}),\n\t\t\t\t{\n\t\t\t\t\tonDidChange: this.repoEmitter.event,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tconst id = this.repoNextId++;\n\t\tconst wasEmpty = this.repoSubscribers.size === 0;\n\n\t\tthis.repoSubscribers.set(id, {\n\t\t\tdelayMs: opts?.delayMs ?? this.defaultRepoMs,\n\t\t\tmaxWaitMs: opts?.maxWaitMs ?? this.defaultRepoMaxWaitMs,\n\t\t});\n\t\tthis.recalcRepoTiming();\n\n\t\tconst relevantRefs = opts?.relevantRefs;\n\t\tif (relevantRefs != null) {\n\t\t\tthis.relevantRefsSources.set(id, relevantRefs);\n\t\t}\n\n\t\tif (wasEmpty) {\n\t\t\tthis.lifecycle?.onFirstRepoSubscriber?.();\n\t\t}\n\n\t\t// If the effective delay or max-wait got shorter while a flush is pending, move it sooner\n\t\tthis.repoClock.rearmIfEarlier();\n\n\t\tlet subDisposed = false;\n\t\treturn Object.assign(\n\t\t\tcreateDisposable(() => {\n\t\t\t\tif (subDisposed) return;\n\n\t\t\t\tsubDisposed = true;\n\n\t\t\t\tthis.repoSubscribers.delete(id);\n\t\t\t\tthis.relevantRefsSources.delete(id);\n\t\t\t\tthis.recalcRepoTiming();\n\n\t\t\t\tif (this.repoSubscribers.size === 0) {\n\t\t\t\t\tthis.repoClock.cancel();\n\t\t\t\t\tthis.clearPendingRepoChanges();\n\t\t\t\t\tthis.lifecycle?.onLastRepoSubscriber?.();\n\t\t\t\t}\n\t\t\t}),\n\t\t\t{\n\t\t\t\tonDidChange:\n\t\t\t\t\trelevantRefs != null\n\t\t\t\t\t\t? createRelevantRefsEvent(this.repoEmitter.event, relevantRefs)\n\t\t\t\t\t\t: this.repoEmitter.event,\n\t\t\t},\n\t\t);\n\t}\n\n\t/** Every repo subscriber's current `relevantRefs` (see {@link subscribe}), unioned */\n\tgetRelevantRefs(): Set<string> {\n\t\tconst refs = new Set<string>();\n\t\tfor (const relevantRefs of this.relevantRefsSources.values()) {\n\t\t\tfor (const ref of relevantRefs()) {\n\t\t\t\trefs.add(ref);\n\t\t\t}\n\t\t}\n\t\treturn refs;\n\t}\n\n\t/** Subscribe to working tree changes; `delayMs` and `maxWaitMs` behave as in {@link subscribe}. */\n\tsubscribeToWorkingTree(opts?: { delayMs?: number; maxWaitMs?: number }): WorkingTreeSubscription {\n\t\tif (this._disposed) {\n\t\t\treturn Object.assign(\n\t\t\t\tcreateDisposable(() => {}),\n\t\t\t\t{\n\t\t\t\t\tonDidChangeWorkingTree: this.workingTreeEmitter.event,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\n\t\tconst id = this.workingTreeNextId++;\n\t\tconst wasEmpty = this.workingTreeSubscribers.size === 0;\n\n\t\tthis.workingTreeSubscribers.set(id, {\n\t\t\tdelayMs: opts?.delayMs ?? this.defaultWorkingTreeMs,\n\t\t\tmaxWaitMs: opts?.maxWaitMs ?? this.defaultWorkingTreeMaxWaitMs,\n\t\t});\n\t\tthis.recalcWorkingTreeTiming();\n\n\t\tif (wasEmpty) {\n\t\t\tthis.lifecycle?.onFirstWorkingTreeSubscriber?.();\n\t\t}\n\n\t\t// If the effective delay or max-wait got shorter while a flush is pending, move it sooner\n\t\tthis.workingTreeClock.rearmIfEarlier();\n\n\t\tlet subDisposed = false;\n\t\treturn Object.assign(\n\t\t\tcreateDisposable(() => {\n\t\t\t\tif (subDisposed) return;\n\n\t\t\t\tsubDisposed = true;\n\n\t\t\t\tthis.workingTreeSubscribers.delete(id);\n\t\t\t\tthis.recalcWorkingTreeTiming();\n\n\t\t\t\tif (this.workingTreeSubscribers.size === 0) {\n\t\t\t\t\tthis.workingTreeClock.cancel();\n\t\t\t\t\tthis.pendingWorkingTreePaths.clear();\n\t\t\t\t\t// Dropped with the paths it describes — a stale flag would make the next subscriber's\n\t\t\t\t\t// first ordinary flush claim a partial set and force needless full refreshes.\n\t\t\t\t\tthis.pendingWorkingTreeIncomplete = false;\n\t\t\t\t\tthis.lifecycle?.onLastWorkingTreeSubscriber?.();\n\t\t\t\t}\n\t\t\t}),\n\t\t\t{ onDidChangeWorkingTree: this.workingTreeEmitter.event },\n\t\t);\n\t}\n\n\tsuspend(): void {\n\t\tthis._suspended = true;\n\t\t// Cancel active timers — events continue to coalesce but don't fire\n\t\tthis.repoClock.suspend();\n\t\tthis.workingTreeClock.suspend();\n\t}\n\n\tresume(delayMs?: number): void {\n\t\tif (!this._suspended) return;\n\n\t\tthis._suspended = false;\n\n\t\t// Flush accumulated changes (a clock with nothing pending stays idle); the max-wait window restarts from now\n\t\tthis.repoClock.resume(delayMs);\n\t\tthis.workingTreeClock.resume(delayMs);\n\t}\n\n\t/**\n\t * Inject changes (e.g., after a git operation the caller performed). Goes through debounce + suspend. Ref kinds\n\t * among them are unnamed — any ref of that kind may have moved — and the event they fire in has no `observedAt`.\n\t */\n\tfireChange(...changes: RepositoryChange[]): void {\n\t\tif (this._disposed || changes.length === 0) return;\n\n\t\tthis.pendingRepoUnstamped = true;\n\t\tthis.coalesceRepo(changes, undefined, 'unfenced');\n\t}\n\n\t/** Immediate fire, bypassing debounce + suspend (for Closed/Opened). Ref kinds among them are unnamed. */\n\tfireChangeImmediate(...changes: RepositoryChange[]): void {\n\t\tif (this._disposed || changes.length === 0) return;\n\n\t\tconst event = new WatcherRepoChangeEvent(this.repoPath, changes);\n\t\t// Same contract as `flushRepo`: notify the global forwarder (which advances the cache's status clock) BEFORE\n\t\t// subscribers. Skipping it here would route changes to subscribers that no one advanced the clock for —\n\t\t// subscribers see them as session-routed and (correctly) don't re-advance, so the cache would go stale.\n\t\tthis.onDidFireRepoChangeCallback?.(event);\n\t\tthis.repoEmitter.fire(event);\n\t}\n\n\t/**\n\t * Push interpreted repo changes into the pipeline. `ref` is the full ref name (or ref directory, or pseudo-ref) whose\n\t * file changed; a ref kind in `changes` is attributed to it when the kinds match, and is otherwise unnamed.\n\t * `false` preserves cache invalidations for a config edit without claiming any ref moved. `configBranches`, for a\n\t * `config` among `changes`, are the local branches (full ref names) whose `branch.<name>` sections are all that\n\t * changed in `.git/config`; without it, the config change may be anywhere. `movedWorktree`, for a `worktreeHead`\n\t * among `changes`, is the admin id of the linked worktree whose HEAD moved; without it, any linked worktree's may\n\t * have.\n\t */\n\tpushRepoChanges(\n\t\tchanges: RepositoryChange[],\n\t\tref?: string | false,\n\t\tconfigBranches?: ReadonlySet<string>,\n\t\tmovedWorktree?: string,\n\t): void {\n\t\tif (this._disposed) return;\n\n\t\tthis.coalesceRepo(\n\t\t\tchanges,\n\t\t\tref,\n\t\t\t'raw',\n\t\t\tconfigBranches,\n\t\t\tmovedWorktree != null ? new Set([movedWorktree]) : undefined,\n\t\t);\n\t}\n\n\t/**\n\t * Push watcher-observed repo changes that no write of core's can account for — an overflow's rescan, or an ignore\n\t * rule changed in the working tree — so {@link noteSelfWrite} never replaces them or takes them for its echo. Ref\n\t * kinds are unnamed, and the event they fire in has no `observedAt`: a host's watcher may say it dropped events\n\t * without their changes having all landed by then.\n\t */\n\tpushUnfencedRepoChanges(changes: RepositoryChange[]): void {\n\t\tif (this._disposed) return;\n\n\t\tthis.pendingRepoUnstamped = true;\n\t\tthis.coalesceRepo(changes, undefined, 'unfenced');\n\t}\n\n\t/**\n\t * Core announced one of its own writes for this repository: its caches were evicted and its host notified, both\n\t * after the write finished. The announcement becomes this session's one event for the write:\n\t *\n\t * - the announced kinds are pushed through the debounce and suspend like {@link fireChange}, and the event carries\n\t * them in `announced`. A ref kind is unnamed unless `refs` names refs of that kind (the full ref names the write\n\t * moved), in which case it carries those names and no other ref of the kind counts as changed by the write.\n\t * `config` is confined to the `branch.<name>` sections of the local branches `refs` names when\n\t * `options.configConfinedToRefs` says so, and the event carries them (`configBranches`). `worktreeHead` is\n\t * confined to the linked worktrees `options.movedWorktrees` names by admin id (none, for a write that moved only\n\t * the main checkout's HEAD), and is open without it;\n\t * - a raw change of an announced kind is the write's own report of it only when it is provably within what the\n\t * write announced: a ref the write named or a ref directory holding one, a config change confined to branches\n\t * the write's config was confined to, or a `worktreeHead` report of a worktree the write named, or of none (the\n\t * `worktrees` folder, a rescan). Pending when the announcement arrives, it is replaced, save the worktrees the\n\t * write didn't name, which stay as an outside move. Arriving later, it merges and the kind stays announced only\n\t * within the repo debounce delay of the announcement; a window can stay pending for minutes while the session is\n\t * suspended, and a later move of the same ref is as likely an outside one. Any other report of the kind is an\n\t * outside change: it stays, and the kind isn't `announced`, since the host has not handled the outside part. A\n\t * write never names `HEAD`, but a commit locks it to write its reflog, so under a write that announced `head`, a\n\t * report of the `HEAD` file within the same delay is the write's echo, its `heads` part included;\n\t * - a kind the write announced open (unnamed, or `config` unconfined) covers any change of the kind: raw changes\n\t * of it still pending are replaced, since the host evicts everything of the kind after the write. One arriving\n\t * within the repo debounce delay of the announcement, before its event fires, is taken for the write's own late\n\t * echo; any later report of the kind before the event fires clears the mark.\n\t *\n\t * Once the event fires, nothing is special: an echo the watcher delivers after it causes one extra, unannounced\n\t * event (a duplicate refresh, narrowed like any other), rather than risk losing an outside change of the same kind.\n\t *\n\t * Empty `changes`, or `'unknown'`, announces every kind a watcher can report (never `'unknown'` itself, which a\n\t * cache reads as a close), open whatever `refs` says; `'closed'` and `'opened'` are ignored. Only raw `.git` changes\n\t * are replaced or kept announced: {@link fireChange}, {@link fireChangeImmediate}, {@link pushUnfencedRepoChanges}\n\t * and working-tree changes always pass.\n\t */\n\tnoteSelfWrite(\n\t\tchanges: readonly RepositoryChange[],\n\t\trefs?: readonly string[],\n\t\toptions?: { readonly configConfinedToRefs?: boolean; readonly movedWorktrees?: readonly string[] },\n\t): void {\n\t\tif (this._disposed) return;\n\n\t\tconst all = changes.length === 0 || changes.includes('unknown');\n\t\tconst announced = all ? allWatchedRepositoryChanges : changes.filter(c => isAnnounceable(c));\n\t\tconst named = all ? undefined : groupNamedRefs(changes, refs);\n\t\tconst configBranches =\n\t\t\t!all && options?.configConfinedToRefs === true && changes.includes('config')\n\t\t\t\t? getBranchRefs(refs)\n\t\t\t\t: undefined;\n\t\tconst movedWorktrees =\n\t\t\t!all && options?.movedWorktrees != null && changes.includes('worktreeHead')\n\t\t\t\t? new Set(options.movedWorktrees)\n\t\t\t\t: undefined;\n\n\t\tfor (const change of this.pendingRepoChanges) {\n\t\t\tif (this.pendingRepoUnfencedChanges.has(change) || !isAnnounceable(change)) continue;\n\t\t\tif (!all && !changes.includes(change)) continue;\n\n\t\t\tif (change === 'config' && configBranches != null) {\n\t\t\t\t// An earlier announcement's config stays and merges with this one; a raw one is replaced only when it\n\t\t\t\t// is provably this write's own report\n\t\t\t\tif (this.pendingRepoAnnounced.has(change)) continue;\n\t\t\t\tif (!isSubsetOf(this.pendingRepoConfigBranches, configBranches)) continue;\n\t\t\t} else if (change === 'worktreeHead' && movedWorktrees != null) {\n\t\t\t\t// An earlier announcement's worktrees merge with this one's. What's left of the worktrees raw reports named\n\t\t\t\t// once this write's are taken out moved outside it, so it stays, unannounced\n\t\t\t\tif (this.pendingRepoAnnounced.has(change)) continue;\n\n\t\t\t\tconst outside = this.pendingRepoMovedWorktrees;\n\t\t\t\tif (outside != null) {\n\t\t\t\t\tfor (const id of movedWorktrees) {\n\t\t\t\t\t\toutside.delete(id);\n\t\t\t\t\t}\n\t\t\t\t\tif (outside.size) continue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst names = isRefChangeKind(change) ? named?.get(change) : undefined;\n\t\t\tif (names != null) {\n\t\t\t\tfor (const name of names) {\n\t\t\t\t\tthis.pendingRepoRefs.delete(name);\n\t\t\t\t}\n\t\t\t\t// Git reports the directory it creates or removes to hold the write's ref as well. Only a raw report can\n\t\t\t\t// be that echo: a name an earlier write announced is a ref it changed, and it can sit where this write's\n\t\t\t\t// directory is (delete `team`, then create `team/task`)\n\t\t\t\t// Walked from each name, as a write can name many refs (a fetch) while many outside ones are pending\n\t\t\t\tfor (const name of names) {\n\t\t\t\t\tfor (const dir of getRefDirectories(name)) {\n\t\t\t\t\t\tif (!this.pendingRepoAnnouncedRefs.has(dir)) {\n\t\t\t\t\t\t\tthis.pendingRepoRefs.delete(dir);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// What's left of the kind came from outside the write, so it stays, unannounced\n\t\t\t\tif (this.hasPendingRefOfKind(change)) continue;\n\t\t\t}\n\n\t\t\tthis.pendingRepoChanges.delete(change);\n\t\t\tthis.pendingRepoAnnounced.delete(change);\n\t\t\tif (change === 'config') {\n\t\t\t\tthis.pendingRepoConfigBranches = undefined;\n\t\t\t} else if (change === 'worktreeHead') {\n\t\t\t\tthis.pendingRepoMovedWorktrees = undefined;\n\t\t\t}\n\t\t\tif (!isRefChangeKind(change)) continue;\n\n\t\t\t// An unnamed announcement covers any ref of the kind, so the replaced kind takes its named refs with it\n\t\t\tthis.pendingRepoUnnamedRefKinds.delete(change);\n\t\t\tfor (const ref of this.pendingRepoRefs) {\n\t\t\t\tif (getRefChangeKind(ref) === change) {\n\t\t\t\t\tthis.pendingRepoRefs.delete(ref);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (announced.length !== 0) {\n\t\t\tthis.coalesceRepo(\n\t\t\t\tnamed != null ? announced.filter(c => !isRefChangeKind(c) || !named.has(c)) : announced,\n\t\t\t\tundefined,\n\t\t\t\t'announced',\n\t\t\t\tconfigBranches,\n\t\t\t\tmovedWorktrees,\n\t\t\t);\n\t\t\tif (named != null) {\n\t\t\t\tfor (const [kind, names] of named) {\n\t\t\t\t\tfor (const name of names) {\n\t\t\t\t\t\tthis.coalesceRepo([kind], name, 'announced');\n\t\t\t\t\t\t// Only a name kept among the pending refs can be taken for a directory's echo; past the cap\n\t\t\t\t\t\t// the kind went unnamed, which covers it, so the set stays as bounded as those refs\n\t\t\t\t\t\tif (this.pendingRepoRefs.has(name)) {\n\t\t\t\t\t\t\tthis.pendingRepoAnnouncedRefs.add(name);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (this.pendingRepoChanges.size === 0) {\n\t\t\t// Nothing left to flush: idle the clock rather than let it fire an empty window\n\t\t\tthis.repoClock.cancel();\n\t\t}\n\t}\n\n\t/** Push working tree file changes into the pipeline */\n\t/** `incomplete` marks the batch as partial when the caller already dropped paths of its own. */\n\tpushWorkingTreeChanges(paths: Iterable<string>, incomplete?: boolean): void {\n\t\tif (this._disposed) return;\n\n\t\tthis._etagWorkingTree++;\n\t\tif (incomplete) {\n\t\t\tthis.pendingWorkingTreeIncomplete = true;\n\t\t}\n\t\tthis.coalesceWorkingTrees(paths);\n\t}\n\n\tprivate static minDelay(subscribers: Map<number, DebounceTiming>, fallback: number): number {\n\t\tlet min = fallback;\n\t\tfor (const { delayMs } of subscribers.values()) {\n\t\t\tif (delayMs < min) {\n\t\t\t\tmin = delayMs;\n\t\t\t}\n\t\t}\n\t\treturn min;\n\t}\n\n\t/** Unlike the delay, the default isn't a ceiling — a subscriber can opt out of the cap with `Infinity` */\n\tprivate static minMaxWait(subscribers: Map<number, DebounceTiming>, fallback: number): number {\n\t\tif (subscribers.size === 0) return fallback;\n\n\t\tlet min = Infinity;\n\t\tfor (const { maxWaitMs } of subscribers.values()) {\n\t\t\tif (maxWaitMs < min) {\n\t\t\t\tmin = maxWaitMs;\n\t\t\t}\n\t\t}\n\t\treturn min;\n\t}\n\n\tprivate recalcRepoTiming(): void {\n\t\tthis.effectiveRepoMs = RepositoryWatchSession.minDelay(this.repoSubscribers, this.defaultRepoMs);\n\t\tthis.effectiveRepoMaxWaitMs = RepositoryWatchSession.minMaxWait(\n\t\t\tthis.repoSubscribers,\n\t\t\tthis.defaultRepoMaxWaitMs,\n\t\t);\n\t}\n\n\tprivate recalcWorkingTreeTiming(): void {\n\t\tthis.effectiveWorkingTreeMs = RepositoryWatchSession.minDelay(\n\t\t\tthis.workingTreeSubscribers,\n\t\t\tthis.defaultWorkingTreeMs,\n\t\t);\n\t\tthis.effectiveWorkingTreeMaxWaitMs = RepositoryWatchSession.minMaxWait(\n\t\t\tthis.workingTreeSubscribers,\n\t\t\tthis.defaultWorkingTreeMaxWaitMs,\n\t\t);\n\t}\n\n\tprivate flushRepo(): void {\n\t\tif (this.pendingRepoChanges.size === 0) return;\n\n\t\t// The event is built only here — raw events just add to the pending sets (which the event copies)\n\t\tconst event = new WatcherRepoChangeEvent(\n\t\t\tthis.repoPath,\n\t\t\t[...this.pendingRepoChanges],\n\t\t\t{\n\t\t\t\tnames: this.pendingRepoRefs,\n\t\t\t\tunnamed: this.pendingRepoUnnamedRefKinds,\n\t\t\t\tconfigBranches: this.pendingRepoConfigBranches,\n\t\t\t},\n\t\t\tthis.pendingRepoAnnounced.keys(),\n\t\t\tthis.pendingRepoMovedWorktrees,\n\t\t\tthis.pendingRepoUnstamped ? undefined : this.pendingRepoObservedAt,\n\t\t);\n\t\tthis.clearPendingRepoChanges();\n\t\t// Advance any cache clock BEFORE notifying subscribers (same rationale as `flushWorkingTree`): a subscriber\n\t\t// that synchronously reads status must see the post-change generation, not a joinable pre-change run.\n\t\tthis.onDidFireRepoChangeCallback?.(event);\n\t\tthis.repoEmitter.fire(event);\n\t}\n\n\t/**\n\t * `origin` is a raw `.git` event, a push no announcement replaces ({@link fireChange},\n\t * {@link pushUnfencedRepoChanges}), or core's announced write. A kind stays announced only while nothing else\n\t * reports it in the pending window, save the write's own report of it (see {@link noteSelfWrite}).\n\t * `configBranches` confines a `config` among `changes` to those branches' sections; without it, it may be anywhere.\n\t * `movedWorktrees` names the linked worktrees whose HEAD a `worktreeHead` among `changes` moved; without it, it may\n\t * be any linked worktree's.\n\t */\n\tprivate coalesceRepo(\n\t\tchanges: readonly RepositoryChange[],\n\t\tref: string | false | undefined,\n\t\torigin: 'raw' | 'unfenced' | 'announced',\n\t\tconfigBranches?: ReadonlySet<string>,\n\t\tmovedWorktrees?: ReadonlySet<string>,\n\t): void {\n\t\tif (changes.length === 0) return;\n\n\t\tthis.pendingRepoObservedAt = nextChangeOrdinal();\n\t\tconst now = performance.now();\n\t\tconst refKind = typeof ref === 'string' ? getRefChangeKind(ref) : undefined;\n\t\tfor (const change of changes) {\n\t\t\tconst pending = this.pendingRepoChanges.has(change);\n\t\t\t// What this report is confined to: the ref it names, or the branches whose config sections it changed\n\t\t\tlet names: ReadonlySet<string> | undefined;\n\t\t\tif (origin !== 'unfenced') {\n\t\t\t\tif (change === 'config') {\n\t\t\t\t\tnames = configBranches;\n\t\t\t\t} else if (change === 'worktreeHead') {\n\t\t\t\t\tnames = movedWorktrees;\n\t\t\t\t} else if (typeof ref === 'string' && refKind === change) {\n\t\t\t\t\tnames = new Set([ref]);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst announcement = this.pendingRepoAnnounced.get(change);\n\t\t\tlet own = false;\n\t\t\tif (origin === 'announced') {\n\t\t\t\tif (!pending) {\n\t\t\t\t\tthis.pendingRepoAnnounced.set(change, {\n\t\t\t\t\t\tat: now,\n\t\t\t\t\t\tnames: names != null ? new Set(names) : undefined,\n\t\t\t\t\t});\n\t\t\t\t} else if (announcement != null) {\n\t\t\t\t\t// Added in place: a write naming many refs arrives here once per name, and copying the set each\n\t\t\t\t\t// time would cost quadratic time in the number of refs it moved\n\t\t\t\t\tif (announcement.names != null && names != null) {\n\t\t\t\t\t\tfor (const name of names) {\n\t\t\t\t\t\t\tannouncement.names.add(name);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tannouncement.names = undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\town = origin === 'raw' && announcement != null && this.isOwnReport(change, announcement, names, now);\n\t\t\t\tif (announcement != null && !own) {\n\t\t\t\t\tthis.pendingRepoAnnounced.delete(change);\n\t\t\t\t} else if (!pending && origin === 'raw' && this.isHeadEcho(change, names, now)) {\n\t\t\t\t\t// A detached HEAD's move announces head without heads, and the HEAD file is all it wrote\n\t\t\t\t\tthis.pendingRepoAnnounced.set(change, { at: now, names: new Set(names) });\n\t\t\t\t}\n\t\t\t\tif (origin === 'unfenced') {\n\t\t\t\t\tthis.pendingRepoUnfencedChanges.add(change);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (change === 'config') {\n\t\t\t\tlet branches: Set<string> | undefined;\n\t\t\t\tif (!pending) {\n\t\t\t\t\tbranches = names != null ? new Set(names) : undefined;\n\t\t\t\t} else if (this.pendingRepoConfigBranches != null && names != null) {\n\t\t\t\t\tbranches = new Set([...this.pendingRepoConfigBranches, ...names]);\n\t\t\t\t}\n\t\t\t\tthis.pendingRepoConfigBranches =\n\t\t\t\t\tbranches != null && branches.size <= maxPendingRefNames ? branches : undefined;\n\t\t\t} else if (change === 'worktreeHead') {\n\t\t\t\tif (!pending) {\n\t\t\t\t\tthis.pendingRepoMovedWorktrees = new Set();\n\t\t\t\t}\n\t\t\t\t// The worktrees a write named, and its own reports of them, moved no HEAD outside it\n\t\t\t\tif (names == null && !own) {\n\t\t\t\t\tthis.pendingRepoMovedWorktrees = undefined;\n\t\t\t\t} else if (names != null && !own && origin !== 'announced') {\n\t\t\t\t\tfor (const id of names) {\n\t\t\t\t\t\tthis.pendingRepoMovedWorktrees?.add(id);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.pendingRepoChanges.add(change);\n\t\t\tif (ref === false || !isRefChangeKind(change)) continue;\n\n\t\t\tif (\n\t\t\t\tref != null &&\n\t\t\t\trefKind === change &&\n\t\t\t\t(this.pendingRepoRefs.size < maxPendingRefNames || this.pendingRepoRefs.has(ref))\n\t\t\t) {\n\t\t\t\tthis.pendingRepoRefs.add(ref);\n\t\t\t} else {\n\t\t\t\tthis.pendingRepoUnnamedRefKinds.add(change);\n\t\t\t}\n\t\t}\n\t\tthis.repoClock.note();\n\t}\n\n\t/**\n\t * Whether a raw report of `change`, confined to `names` (`undefined`: not confined), is the announced write's own.\n\t * It must arrive within the repo debounce delay of the announcement, as it always had to. An open announcement\n\t * asks nothing more; one confined to names also needs every name the report carries to be one the write announced,\n\t * save the `heads` part of a `HEAD` report under a write that announced `head` in time, which is a commit's echo. A\n\t * `worktreeHead` report naming no worktree (the `worktrees` folder, a rescan) can't be told apart from the write's.\n\t */\n\tprivate isOwnReport(\n\t\tchange: RepositoryChange,\n\t\tannouncement: PendingAnnouncement,\n\t\tnames: ReadonlySet<string> | undefined,\n\t\tnow: number,\n\t): boolean {\n\t\tif (now - announcement.at > this.effectiveRepoMs) return false;\n\t\tif (announcement.names == null) return true;\n\t\tif (names == null) return change === 'worktreeHead';\n\t\t// A ref and a directory of the same name can't coexist, which is what lets a directory report stand for its\n\t\t// refs; config sections `branch.team` and `branch.team/task` can\n\t\tif (isRefChangeKind(change) ? isCoveredBy(names, announcement.names) : isSubsetOf(names, announcement.names)) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn this.isHeadEcho(change, names, now);\n\t}\n\n\t/** Whether a raw `heads` report confined to `HEAD` is the echo of a write that announced `head` in time */\n\tprivate isHeadEcho(change: RepositoryChange, names: ReadonlySet<string> | undefined, now: number): boolean {\n\t\tif (change !== 'heads' || names?.size !== 1 || !names.has('HEAD')) return false;\n\n\t\tconst head = this.pendingRepoAnnounced.get('head');\n\t\treturn head != null && now - head.at <= this.effectiveRepoMs;\n\t}\n\n\t/** Whether a pending report of `kind` remains, unnamed or under a name */\n\tprivate hasPendingRefOfKind(kind: RepositoryChange): boolean {\n\t\tif (!isRefChangeKind(kind)) return false;\n\t\tif (this.pendingRepoUnnamedRefKinds.has(kind)) return true;\n\n\t\tfor (const ref of this.pendingRepoRefs) {\n\t\t\tif (getRefChangeKind(ref) === kind) return true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate clearPendingRepoChanges(): void {\n\t\tthis.pendingRepoChanges.clear();\n\t\tthis.pendingRepoRefs.clear();\n\t\tthis.pendingRepoUnnamedRefKinds.clear();\n\t\tthis.pendingRepoUnfencedChanges.clear();\n\t\tthis.pendingRepoAnnounced.clear();\n\t\tthis.pendingRepoAnnouncedRefs.clear();\n\t\tthis.pendingRepoConfigBranches = undefined;\n\t\tthis.pendingRepoMovedWorktrees = undefined;\n\t\tthis.pendingRepoObservedAt = undefined;\n\t\tthis.pendingRepoUnstamped = false;\n\t}\n\n\tprivate flushWorkingTree(): void {\n\t\tif (!this.hasPendingWorkingTreeChanges) return;\n\n\t\tconst paths = this.pendingWorkingTreePaths;\n\t\tconst incomplete = this.pendingWorkingTreeIncomplete;\n\t\tthis.pendingWorkingTreePaths = new Set();\n\t\tthis.pendingWorkingTreeIncomplete = false;\n\t\t// Advance the cache's status clock (via WatchService's global forwarding) BEFORE notifying subscribers,\n\t\t// so a subscriber that synchronously reads status sees the post-change generation, not a joinable pre-change run.\n\t\tthis.onDidFireWorkingTreeChangeCallback?.(this.repoPath);\n\t\tthis.workingTreeEmitter.fire({ repoPath: this.repoPath, paths: paths, incomplete: incomplete });\n\t}\n\n\tprivate coalesceWorkingTrees(paths: Iterable<string>): void {\n\t\tfor (const p of paths) {\n\t\t\t// Stop retaining paths past the cap, but keep draining the iterable — the flag is what makes the\n\t\t\t// partial set safe to consume, and dropping out early would leave later paths for the next window.\n\t\t\tif (this.pendingWorkingTreePaths.size >= maxWorkingTreePaths && !this.pendingWorkingTreePaths.has(p)) {\n\t\t\t\tthis.pendingWorkingTreeIncomplete = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tthis.pendingWorkingTreePaths.add(p);\n\t\t}\n\n\t\tif (this.hasPendingWorkingTreeChanges) {\n\t\t\tthis.workingTreeClock.note();\n\t\t}\n\t}\n}\n\n/** `'closed'` and `'opened'` are lifecycle, not a write's effect, so an announcement never replaces or names them */\nfunction isAnnounceable(change: RepositoryChange): boolean {\n\treturn change !== 'closed' && change !== 'opened';\n}\n\n/**\n * The names in `refs` grouped by their ref kind, for the ref kinds among `changes` only; `undefined` when none is named.\n * Pseudo-refs (`HEAD`) are left out: a write names the refs it moved, and those are full ref names.\n */\nfunction groupNamedRefs(\n\tchanges: readonly RepositoryChange[],\n\trefs: readonly string[] | undefined,\n): Map<RefChangeKind, Set<string>> | undefined {\n\tif (!refs?.length) return undefined;\n\n\tlet named: Map<RefChangeKind, Set<string>> | undefined;\n\tfor (const ref of refs) {\n\t\tif (!ref.startsWith('refs/')) continue;\n\n\t\tconst kind = getRefChangeKind(ref);\n\t\tif (kind == null || !changes.includes(kind)) continue;\n\n\t\tnamed ??= new Map();\n\t\tlet names = named.get(kind);\n\t\tif (names == null) {\n\t\t\tnames = new Set();\n\t\t\tnamed.set(kind, names);\n\t\t}\n\t\tnames.add(ref);\n\t}\n\treturn named;\n}\n\n/** The local branches among `refs` (full `refs/heads/` names), or `undefined` when there are none */\nfunction getBranchRefs(refs: readonly string[] | undefined): Set<string> | undefined {\n\tlet branches: Set<string> | undefined;\n\tfor (const ref of refs ?? []) {\n\t\tif (ref.startsWith('refs/heads/')) {\n\t\t\t(branches ??= new Set()).add(ref);\n\t\t}\n\t}\n\treturn branches;\n}\n\n/**\n * Whether `ref` is a ref directory holding one of `names` (compared on `/` boundaries). A namespace root\n * (`refs/heads`) or a pseudo-ref is no such directory, so a report of it is never a write's own by this rule.\n */\nfunction isRefDirectoryOfAny(ref: string, names: ReadonlySet<string>): boolean {\n\tif (!ref.startsWith('refs/') || getRefChangeKind(ref) == null) return false;\n\n\tconst prefix = `${ref}/`;\n\tfor (const name of names) {\n\t\tif (name.startsWith(prefix)) return true;\n\t}\n\treturn false;\n}\n\n/**\n * The ref directories holding `ref`, innermost first, each of `ref`'s own kind; never a namespace root (`refs/heads`),\n * as {@link isRefDirectoryOfAny} counts them\n */\nfunction* getRefDirectories(ref: string): Iterable<string> {\n\tfor (let index = ref.lastIndexOf('/'); index > 0; index = ref.lastIndexOf('/', index - 1)) {\n\t\tconst dir = ref.substring(0, index);\n\t\tif (!dir.startsWith('refs/') || getRefChangeKind(dir) == null) return;\n\n\t\tyield dir;\n\t}\n}\n\n/**\n * Whether every name in `names` is one in `of` or a ref directory holding one; never for `undefined`, which stands for\n * any name\n */\nfunction isCoveredBy(names: ReadonlySet<string> | undefined, of: ReadonlySet<string>): boolean {\n\tif (names == null) return false;\n\n\tfor (const name of names) {\n\t\tif (!of.has(name) && !isRefDirectoryOfAny(name, of)) return false;\n\t}\n\treturn true;\n}\n\n/** Whether every name in `names` is in `of`; never for `undefined`, which stands for any name */\nfunction isSubsetOf(names: ReadonlySet<string> | undefined, of: ReadonlySet<string>): boolean {\n\tif (names == null) return false;\n\n\tfor (const name of names) {\n\t\tif (!of.has(name)) return false;\n\t}\n\treturn true;\n}\n\n/** Wraps a session's repo event so each delivery is narrowed to the subscriber's relevant refs (see `subscribe`) */\nfunction createRelevantRefsEvent(\n\tevent: Event<WatcherRepoChangeEvent>,\n\trelevantRefs: () => Iterable<string>,\n): Event<WatcherRepoChangeEvent> {\n\treturn (listener, thisArgs, disposables) =>\n\t\tevent(\n\t\t\te => {\n\t\t\t\tconst narrowed = narrowToRelevantRefs(e, relevantRefs);\n\t\t\t\tif (narrowed != null) {\n\t\t\t\t\tlistener.call(thisArgs, narrowed);\n\t\t\t\t}\n\t\t\t},\n\t\t\tundefined,\n\t\t\tdisposables,\n\t\t);\n}\n\n/**\n * Narrows an event to the refs a subscriber cares about. Returns the event itself when no change kind is removed (the\n * kept names then stay a superset, which only makes `mayHaveChangedRef` more conservative), `undefined` when every kind\n * is removed, and otherwise a new event with the kept kinds, names and unnamed kinds. A `config` change confined to\n * some local branches' sections is removed unless a relevant ref is `HEAD` or one of those branches (see\n * `mayHaveChangedConfig`).\n */\nfunction narrowToRelevantRefs(\n\te: WatcherRepoChangeEvent,\n\trelevantRefs: () => Iterable<string>,\n): WatcherRepoChangeEvent | undefined {\n\t// Ref kinds that pass only if a relevant ref of that kind may have moved\n\tlet unresolved: Set<RefChangeKind> | undefined;\n\tfor (const change of e.changes) {\n\t\tif (!isRefChangeKind(change) || e.unnamedRefKinds.has(change)) continue;\n\n\t\t(unresolved ??= new Set()).add(change);\n\t}\n\t// A confined `config` passes only if a relevant ref is one of the branches it is confined to\n\tconst configBranches = e.configBranches;\n\tlet keepConfig = configBranches == null;\n\tif (unresolved == null && keepConfig) return e;\n\n\tunresolved ??= new Set();\n\n\tconst pseudoRefs: string[] = [];\n\tfor (const name of e.refs) {\n\t\tif (!name.startsWith('refs/')) {\n\t\t\tpseudoRefs.push(name);\n\t\t}\n\t}\n\tif (pseudoRefs.length !== 0) {\n\t\t// A pseudo-ref (`HEAD`, `ORIG_HEAD`) moving is a `heads` change for every subscriber\n\t\tunresolved.delete('heads');\n\t\tif (unresolved.size === 0 && keepConfig) return e;\n\t}\n\n\t// Names that equal or cover a relevant ref — collected as we go, since `relevantRefs` may be a one-shot iterable\n\tconst keptNames = new Set<string>(pseudoRefs);\n\tfor (const ref of relevantRefs()) {\n\t\t// `HEAD` is usually a symref to the checked-out branch, so any `heads` change may have moved it, and any branch's\n\t\t// config section may be its branch's\n\t\tif (ref === 'HEAD') {\n\t\t\tif (e.changes.has('heads')) {\n\t\t\t\tfor (const name of e.refs) {\n\t\t\t\t\tif (getRefChangeKind(name) === 'heads') {\n\t\t\t\t\t\tkeptNames.add(name);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tkeepConfig = true;\n\t\t\tunresolved.delete('heads');\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!keepConfig && configBranches?.has(ref)) {\n\t\t\tkeepConfig = true;\n\t\t}\n\n\t\tconst kind = getRefChangeKind(ref);\n\t\tif (kind == null || !e.changes.has(kind)) continue;\n\n\t\tconst covering = findCoveringRefName(e.refs, ref);\n\t\tif (covering == null) continue;\n\n\t\tkeptNames.add(covering);\n\t\tunresolved.delete(kind);\n\t}\n\tif (unresolved.size === 0 && keepConfig) return e;\n\n\tconst keptChanges: RepositoryChange[] = [];\n\tfor (const change of e.changes) {\n\t\tif (change === 'config' ? keepConfig : !isRefChangeKind(change) || !unresolved.has(change)) {\n\t\t\tkeptChanges.push(change);\n\t\t}\n\t}\n\tif (keptChanges.length === 0) return undefined;\n\n\treturn new WatcherRepoChangeEvent(\n\t\te.repoPath,\n\t\tkeptChanges,\n\t\t{ names: keptNames, unnamed: e.unnamedRefKinds, configBranches: configBranches },\n\t\te.announced,\n\t\te.movedWorktrees,\n\t\te.observedAt,\n\t);\n}\n"],"mappings":";;;;;;;AAiEA,MAAa,mBAAmB;AAChC,MAAM,0BAA0B;AAChC,MAAM,qBAAqB;AAC3B,MAAM,4BAA4B;;AAGlC,MAAM,gBAAgB;;;;;;;;;;;AAiBtB,IAAM,gBAAN,MAAoB;CAWD;CACA;CACA;CAZlB,SAAiB;CACjB,SAAiB;CACjB,UAAkB;CAClB,SAAiB;CACjB;CACA,aAAqB;;CAErB;CAEA,YACC,YACA,cACA,OACC;EAHgB,KAAA,aAAA;EACA,KAAA,eAAA;EACA,KAAA,QAAA;CACf;;CAGH,OAAa;EACZ,MAAM,MAAM,YAAY,IAAI;EAC5B,IAAI,CAAC,KAAK,QAAQ;GACjB,KAAK,SAAS;GACd,KAAK,UAAU;EAChB;EACA,KAAK,SAAS;EAEd,IAAI,KAAK,QAAQ;EAEjB,IAAI,KAAK,eAAe,MAAM;GAE7B,KAAK,cAAc,KAAA;GACnB,KAAK,eAAe;EACrB;EAEA,IAAI,KAAK,SAAS,MACjB,KAAK,IAAI,KAAK,SAAS,GAAG,GAAG;CAE/B;;CAGA,iBAAuB;EACtB,IAAI,CAAC,KAAK,UAAU,KAAK,UAAU,KAAK,SAAS,MAAM;EAEvD,MAAM,QAAQ,KAAK,SAAS;EAC5B,IAAI,SAAS,KAAK,YAAY;EAE9B,aAAa,KAAK,KAAK;EACvB,KAAK,IAAI,OAAO,YAAY,IAAI,CAAC;CAClC;;CAGA,UAAgB;EACf,KAAK,SAAS;EACd,KAAK,WAAW;CACjB;;;;;CAMA,OAAO,SAAwB;EAC9B,KAAK,SAAS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AI,EAAE,QAAQ,IAAI,OAAO,GACnB;SAAA,MAAM,QAAQ,EAAE,MACpB,IAAI,iBAAiB,IAAI,MAAM,SAC9B,UAAU,IAAI,IAAI;GAAA;GAIrB,aAAa;GACb,WAAW,OAAO,OAAO;GACzB;EACD;EAEA,IAAI,CAAC,cAAc,gBAAgB,IAAI,GAAG,GACzC,aAAa;EAGd,MAAM,OAAO,iBAAiB,GAAG;EACjC,IAAI,QAAQ,QAAQ,CAAC,EAAE,QAAQ,IAAI,IAAI,GAAG;EAE1C,MAAM,WAAW,oBAAoB,EAAE,MAAM,GAAG;EAChD,IAAI,YAAY,MAAM;EAEtB,UAAU,IAAI,QAAQ;EACtB,WAAW,OAAO,IAAI;CACvB;CACA,IAAI,WAAW,SAAS,KAAK,YAAY,OAAO;CAEhD,MAAM,cAAkC,CAAC;CACzC,KAAK,MAAM,UAAU,EAAE,SACtB,IAAI,WAAW,WAAW,aAAa,CAAC,gBAAgB,MAAM,KAAK,CAAC,WAAW,IAAI,MAAM,GACxF,YAAY,KAAK,MAAM;CAGzB,IAAI,YAAY,WAAW,GAAG,OAAO,KAAA;CAErC,OAAO,IAAI,uBACV,EAAE,UACF,aACA;EAAE,OAAO;EAAW,SAAS,EAAE;EAAiC;CAAe,GAC/E,EAAE,WACF,EAAE,gBACF,EAAE,UACH;AACD"}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { GitDirProbe } from "./gitDirPoller.js";
|
|
2
2
|
//#region ../git/src/watching/watcherPatterns.d.ts
|
|
3
|
-
/** For
|
|
3
|
+
/** For a checkout whose `.git` directory is the common one (a standard repo or a main checkout): every .git file */
|
|
4
4
|
export declare const dotGitGlobCombined = "{index,HEAD,*_HEAD,MERGE_*,rebase-apply,rebase-apply/**,rebase-merge,rebase-merge/**,sequencer,sequencer/**,config,gk/config,refs/**,packed-refs,shallow,info/exclude,FETCH_HEAD,worktrees,worktrees/*,worktrees/*/HEAD,worktrees/*/locked,worktrees/*/gitdir}";
|
|
5
5
|
/** For worktree repos: root watcher (worktree-specific files only) */
|
|
6
6
|
export declare const dotGitGlobRoot = "{index,HEAD,*_HEAD,MERGE_*,rebase-apply,rebase-apply/**,rebase-merge,rebase-merge/**,sequencer,sequencer/**}";
|
|
7
7
|
/** For worktree repos: common watcher (shared config, refs, info, etc.) */
|
|
8
8
|
export declare const dotGitGlobCommon = "{config,gk/config,refs/**,packed-refs,shallow,info/exclude,FETCH_HEAD,worktrees,worktrees/*,worktrees/*/HEAD,worktrees/*/locked,worktrees/*/gitdir}";
|
|
9
|
+
/**
|
|
10
|
+
* Whether a path relative to the common `.git` directory is one {@link dotGitGlobCommon} reads: a file every checkout of
|
|
11
|
+
* the repository shares. A trailing `/**` takes in the directory itself, as a watcher's globstar may
|
|
12
|
+
*/
|
|
13
|
+
export declare function isGitDirCommonPath(relativePath: string): boolean;
|
|
9
14
|
/**
|
|
10
15
|
* Directories to leave unwatched under the `.git` directory (relative to it), for a provider that prunes natively.
|
|
11
16
|
* Only directories nothing in the globs above reads: never anything under `refs`, `worktrees/*` itself, `gk`, `info`,
|
|
@@ -61,9 +66,18 @@ export declare const gitInitGlob = "**/.git";
|
|
|
61
66
|
*/
|
|
62
67
|
export declare function shouldIgnoreRepoPath(relativePath: string): boolean;
|
|
63
68
|
/**
|
|
64
|
-
* Returns true if the working tree path should be ignored
|
|
65
|
-
* (node_modules, .git internals, watchman cookies).
|
|
69
|
+
* Returns true if the working tree path, relative to the repository root, should be ignored
|
|
70
|
+
* (node_modules, .git internals, watchman cookies). Only whole segments match.
|
|
71
|
+
*/
|
|
72
|
+
export declare function shouldIgnoreWorkingTreePath(relativePath: string): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Creates the per-event noise check for a working-tree watcher. It judges only the part of an absolute event path
|
|
75
|
+
* inside `repoPath`, so folders above the root (`app.git/feature`, a `node_modules` ancestor) never count. The root is
|
|
76
|
+
* compiled once here, so an event costs one anchored match and a scan of its tail, with no path normalization. The
|
|
77
|
+
* match is tolerant of either separator and, off Linux, of case, as `isDescendant` is.
|
|
78
|
+
*
|
|
79
|
+
* A path not under the root is judged whole.
|
|
66
80
|
*/
|
|
67
|
-
export declare function
|
|
81
|
+
export declare function createWorkingTreeNoiseFilter(repoPath: string): (absoluteEventPath: string) => boolean;
|
|
68
82
|
//#endregion
|
|
69
83
|
//# sourceMappingURL=watcherPatterns.d.ts.map
|
|
@@ -1,13 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { escapeRegex } from "../../utils/string.js";
|
|
2
|
+
import { isLinux } from "../../utils/platform.js";
|
|
3
|
+
import { getBestPath, isAbsolute } from "../../utils/path.js";
|
|
2
4
|
//#region ../git/src/watching/watcherPatterns.ts
|
|
3
5
|
const dotGitFiles = "index,HEAD,*_HEAD,MERGE_*,rebase-apply,rebase-apply/**,rebase-merge,rebase-merge/**,sequencer,sequencer/**";
|
|
4
6
|
const dotGitCommonFiles = `config,gk/config,refs/**,packed-refs,shallow,info/exclude,FETCH_HEAD,worktrees,worktrees/*,worktrees/*/HEAD,worktrees/*/locked,worktrees/*/gitdir`;
|
|
5
|
-
/** For
|
|
7
|
+
/** For a checkout whose `.git` directory is the common one (a standard repo or a main checkout): every .git file */
|
|
6
8
|
const dotGitGlobCombined = `{${dotGitFiles},${dotGitCommonFiles}}`;
|
|
7
9
|
/** For worktree repos: root watcher (worktree-specific files only) */
|
|
8
10
|
const dotGitGlobRoot = `{${dotGitFiles}}`;
|
|
9
11
|
/** For worktree repos: common watcher (shared config, refs, info, etc.) */
|
|
10
12
|
const dotGitGlobCommon = `{${dotGitCommonFiles}}`;
|
|
13
|
+
const dotGitCommonPathRegex = new RegExp(`^(?:${dotGitCommonFiles.split(",").map((p) => p.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\/\*\*$|\*/g, (glob) => glob === "*" ? "[^/]*" : "(?:/.*)?")).join("|")})$`);
|
|
14
|
+
/**
|
|
15
|
+
* Whether a path relative to the common `.git` directory is one {@link dotGitGlobCommon} reads: a file every checkout of
|
|
16
|
+
* the repository shares. A trailing `/**` takes in the directory itself, as a watcher's globstar may
|
|
17
|
+
*/
|
|
18
|
+
function isGitDirCommonPath(relativePath) {
|
|
19
|
+
return dotGitCommonPathRegex.test(relativePath);
|
|
20
|
+
}
|
|
11
21
|
/**
|
|
12
22
|
* Directories to leave unwatched under the `.git` directory (relative to it), for a provider that prunes natively.
|
|
13
23
|
* Only directories nothing in the globs above reads: never anything under `refs`, `worktrees/*` itself, `gk`, `info`,
|
|
@@ -143,15 +153,36 @@ const ignoredRepoPathRegex = /(?:\/|\\)fsmonitor--daemon(?:\/|\\)|(?:^|\/)index\
|
|
|
143
153
|
function shouldIgnoreRepoPath(relativePath) {
|
|
144
154
|
return ignoredRepoPathRegex.test(relativePath);
|
|
145
155
|
}
|
|
146
|
-
const ignoredWorkingTreePathRegex = /(?:(
|
|
156
|
+
const ignoredWorkingTreePathRegex = /(?<![^\\/])(?:(?:node_modules|\.git)(?:[\\/]|$)|\.watchman-cookie-)/g;
|
|
157
|
+
function isIgnoredWorkingTreePathFrom(path, from) {
|
|
158
|
+
ignoredWorkingTreePathRegex.lastIndex = from;
|
|
159
|
+
return ignoredWorkingTreePathRegex.test(path);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Returns true if the working tree path, relative to the repository root, should be ignored
|
|
163
|
+
* (node_modules, .git internals, watchman cookies). Only whole segments match.
|
|
164
|
+
*/
|
|
165
|
+
function shouldIgnoreWorkingTreePath(relativePath) {
|
|
166
|
+
return isIgnoredWorkingTreePathFrom(relativePath, 0);
|
|
167
|
+
}
|
|
147
168
|
/**
|
|
148
|
-
*
|
|
149
|
-
* (
|
|
169
|
+
* Creates the per-event noise check for a working-tree watcher. It judges only the part of an absolute event path
|
|
170
|
+
* inside `repoPath`, so folders above the root (`app.git/feature`, a `node_modules` ancestor) never count. The root is
|
|
171
|
+
* compiled once here, so an event costs one anchored match and a scan of its tail, with no path normalization. The
|
|
172
|
+
* match is tolerant of either separator and, off Linux, of case, as `isDescendant` is.
|
|
173
|
+
*
|
|
174
|
+
* A path not under the root is judged whole.
|
|
150
175
|
*/
|
|
151
|
-
function
|
|
152
|
-
|
|
176
|
+
function createWorkingTreeNoiseFilter(repoPath) {
|
|
177
|
+
const root = getBestPath(repoPath);
|
|
178
|
+
const source = root.split("/").map(escapeRegex).join("[\\\\/]");
|
|
179
|
+
const rootRegex = new RegExp(`${root.startsWith("/") ? "" : "[\\\\/]?"}${source}(?:[\\\\/]|$)`, isLinux ? "y" : "iy");
|
|
180
|
+
return (absoluteEventPath) => {
|
|
181
|
+
rootRegex.lastIndex = 0;
|
|
182
|
+
return isIgnoredWorkingTreePathFrom(absoluteEventPath, rootRegex.test(absoluteEventPath) ? rootRegex.lastIndex : 0);
|
|
183
|
+
};
|
|
153
184
|
}
|
|
154
185
|
//#endregion
|
|
155
|
-
export { dotGitGlobCombined, dotGitGlobCommon, dotGitGlobRoot, getGitDirRefProbes, getIgnoredWorktreeFolderExcludes, gitDirCommonProbes, gitDirExcludes, gitDirProbesByEmittedPath, gitDirRootProbes, gitIgnoreGlob, gitInitGlob, sanitizeIgnoredWorktreeFolders, shouldIgnoreRepoPath, shouldIgnoreWorkingTreePath, workingTreeExcludes };
|
|
186
|
+
export { createWorkingTreeNoiseFilter, dotGitGlobCombined, dotGitGlobCommon, dotGitGlobRoot, getGitDirRefProbes, getIgnoredWorktreeFolderExcludes, gitDirCommonProbes, gitDirExcludes, gitDirProbesByEmittedPath, gitDirRootProbes, gitIgnoreGlob, gitInitGlob, isGitDirCommonPath, sanitizeIgnoredWorktreeFolders, shouldIgnoreRepoPath, shouldIgnoreWorkingTreePath, workingTreeExcludes };
|
|
156
187
|
|
|
157
188
|
//# sourceMappingURL=watcherPatterns.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watcherPatterns.js","names":[],"sources":["../../../../git/src/watching/watcherPatterns.ts"],"sourcesContent":["import { isAbsolute } from '@gitlens/utils/path.js';\nimport type { GitDirProbe } from './gitDirPoller.js';\n\n// Glob patterns for watching files inside the .git directory.\n// They represent pure Git knowledge — the library owns these patterns and\n// provides them to the pluggable FileWatcherFactory.\n\nconst dotGitFiles =\n\t'index,HEAD,*_HEAD,MERGE_*,rebase-apply,rebase-apply/**,rebase-merge,rebase-merge/**,sequencer,sequencer/**';\n\n// `worktrees` (the bare entry, no `/*` suffix) is its own pattern: `worktree remove` deletes the whole\n// `worktrees/<id>` subtree in one syscall, and some platforms/watcher backends coalesce a same-instant\n// subtree delete into a single event for the PARENT directory — `worktrees/*` alone never matches that.\n// `classifyGitDirChange` classifies a bare `worktrees` path, so this is watch-coverage only.\n//\n// Only what `git worktree list` reports per worktree is watched here (its HEAD, lock and location). A\n// linked worktree's own index, `*_HEAD`, `MERGE_*`, rebase and sequencer state is watched by that\n// worktree's root watcher (`dotGitGlobRoot`) instead, so it never wakes sibling worktrees.\nconst dotGitWorktreeFiles = 'worktrees,worktrees/*,worktrees/*/HEAD,worktrees/*/locked,worktrees/*/gitdir';\n\nconst dotGitCommonFiles = `config,gk/config,refs/**,packed-refs,shallow,info/exclude,FETCH_HEAD,${dotGitWorktreeFiles}`;\n\n/** For standard repos (no worktrees): single watcher covering all .git files */\nexport const dotGitGlobCombined = `{${dotGitFiles},${dotGitCommonFiles}}`;\n\n/** For worktree repos: root watcher (worktree-specific files only) */\nexport const dotGitGlobRoot = `{${dotGitFiles}}`;\n\n/** For worktree repos: common watcher (shared config, refs, info, etc.) */\nexport const dotGitGlobCommon = `{${dotGitCommonFiles}}`;\n\n/**\n * Directories to leave unwatched under the `.git` directory (relative to it), for a provider that prunes natively.\n * Only directories nothing in the globs above reads: never anything under `refs`, `worktrees/*` itself, `gk`, `info`,\n * or the rebase/sequencer directories.\n */\nexport const gitDirExcludes: readonly string[] = [\n\t'objects',\n\t'logs',\n\t'hooks',\n\t'lfs',\n\t'modules',\n\t'rr-cache',\n\t'fsmonitor--daemon',\n\t'worktrees/*/logs',\n];\n\n/**\n * What a poll stats in a worktree's own `.git` directory when its watcher can't be trusted — the files\n * {@link dotGitGlobRoot} reads.\n */\nexport const gitDirRootProbes: readonly GitDirProbe[] = [\n\t{ path: 'HEAD' },\n\t{ path: 'index' },\n\t{ path: 'ORIG_HEAD' },\n\t{ path: 'MERGE_HEAD' },\n\t{ path: 'CHERRY_PICK_HEAD' },\n\t{ path: 'REVERT_HEAD' },\n\t{ path: 'REBASE_HEAD' },\n\t{ path: 'rebase-merge' },\n\t{ path: 'rebase-apply' },\n\t{ path: 'sequencer' },\n\t// Moves with every commit, reset or checkout on the checked-out branch, without the poll knowing its name\n\t{ path: 'logs/HEAD', emitAs: ['HEAD'] },\n];\n\n/**\n * What a poll stats in the common `.git` directory — the files {@link dotGitGlobCommon} reads, with the `refs/**` it\n * can't list narrowed to its namespace directories (whose mtime moves as a top-level ref is created or deleted) and\n * to the named refs of {@link getGitDirRefProbes}.\n */\nexport const gitDirCommonProbes: readonly GitDirProbe[] = [\n\t{ path: 'packed-refs' },\n\t{ path: 'config' },\n\t{ path: 'gk/config' },\n\t{ path: 'info/exclude' },\n\t{ path: 'refs/heads' },\n\t// Moves as a remote's directory appears or goes: `git remote remove` and `git remote rename` delete or move each of\n\t// its loose refs (a packed one is locked through a loose path too), and git removes the emptied directory. Reported\n\t// as every remote-tracking ref possibly moved, since the poll can't tell which remote it was. A remote whose name\n\t// nests under a directory another remote still uses (`foo/bar` beside `foo/baz`) leaves it unmoved, so only a named\n\t// ref's probe sees that one go\n\t{ path: 'refs/remotes' },\n\t{ path: 'refs/tags' },\n\t{ path: 'refs/stash' },\n\t{ path: 'worktrees' },\n\t{ path: 'shallow' },\n\t// A fetch writes it with the remote-tracking refs it updated, which the poll can't list. Git rewrites it even on a\n\t// fetch that moves nothing, so each fetch is reported as a `remotes` change: the cost of seeing remote-tracking\n\t// refs no subscriber names\n\t{ path: 'FETCH_HEAD', emitAs: ['FETCH_HEAD', 'refs/remotes'] },\n];\n\n/** For each path a probe of {@link gitDirRootProbes} or {@link gitDirCommonProbes} is emitted as, the probes emitted as it */\nexport const gitDirProbesByEmittedPath: ReadonlyMap<string, readonly string[]> = getProbesByEmittedPath([\n\t...gitDirRootProbes,\n\t...gitDirCommonProbes,\n]);\n\nfunction getProbesByEmittedPath(probes: readonly GitDirProbe[]): Map<string, string[]> {\n\tconst map = new Map<string, string[]>();\n\tfor (const probe of probes) {\n\t\tfor (const path of probe.emitAs ?? []) {\n\t\t\tconst paths = map.get(path);\n\t\t\tif (paths == null) {\n\t\t\t\tmap.set(path, [probe.path]);\n\t\t\t} else {\n\t\t\t\tpaths.push(probe.path);\n\t\t\t}\n\t\t}\n\t}\n\treturn map;\n}\n\n/**\n * Probes for named branches and remote-tracking refs: each loose ref file, and each directory between it and its\n * namespace (`refs/heads/feature` for `refs/heads/feature/x`, `refs/remotes/origin`), whose mtime moves as a sibling\n * ref is created or deleted. A ref created in a directory no named ref sits in is left to `packed-refs`, `logs/HEAD`\n * and `FETCH_HEAD`.\n */\nexport function getGitDirRefProbes(refs: Iterable<string>): GitDirProbe[] {\n\tconst paths = new Set<string>();\n\tfor (const ref of refs) {\n\t\tconst namespaceEnd = ref.startsWith('refs/heads/') ? 10 : ref.startsWith('refs/remotes/') ? 12 : -1;\n\t\tif (namespaceEnd === -1) continue;\n\n\t\tfor (let path = ref; path.length > namespaceEnd; path = path.substring(0, path.lastIndexOf('/'))) {\n\t\t\tpaths.add(path);\n\t\t}\n\t}\n\treturn Array.from(paths, path => ({ path: path }));\n}\n\n/**\n * The top-level names under the `.git` directory that the globs above read or a poll stats, as one case-insensitive\n * pattern (a folder may sit on a case-insensitive file system)\n */\nconst watchedGitDirNames = new Set(\n\t[\n\t\t...`${dotGitFiles},${dotGitCommonFiles}`.split(','),\n\t\t...gitDirRootProbes.map(p => p.path),\n\t\t...gitDirCommonProbes.map(p => p.path),\n\t].map(p => p.split('/')[0]),\n);\nconst watchedGitDirNameRegex = new RegExp(\n\t`^(?:${Array.from(watchedGitDirNames, name => name.replace(/[.+?^${}()|[\\]\\\\]/g, '\\\\$&').replace(/\\*/g, '[^/]*')).join('|')})$`,\n\t'i',\n);\n\n/**\n * The registered folders whose worktrees core ignores, each as a `/`-separated literal path relative to a repository's\n * common git dir, without `.` or empty segments; any other is dropped. A folder must lie strictly inside the common git\n * dir (never absolute, never through `..`), name no glob syntax (a picomatch group or extglob's parentheses and `|`\n * included) or `:` (a watcher's exclude would read it as a pattern, so `(refs|x)` would leave `refs` unwatched, or a\n * drive), and not lie under `worktrees`, whose admin entries are what tells an ignored worktree apart.\n */\nexport function sanitizeIgnoredWorktreeFolders(folders: readonly string[] | undefined): string[] {\n\tif (!folders?.length) return [];\n\n\tconst sanitized = new Set<string>();\n\tfor (const folder of folders) {\n\t\tif (isAbsolute(folder) || /^[\\\\/]/.test(folder)) continue;\n\n\t\tconst segments = folder.split(/[\\\\/]/).filter(s => s && s !== '.');\n\t\tif (\n\t\t\t!segments.length ||\n\t\t\tsegments[0].toLowerCase() === 'worktrees' ||\n\t\t\tsegments.some(s => s === '..' || /[*?[\\]{}()|!:]/.test(s))\n\t\t) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tsanitized.add(segments.join('/'));\n\t}\n\treturn [...sanitized];\n}\n\n/**\n * The registered folders a `.git` watcher over the common git dir may leave unwatched: those of\n * {@link sanitizeIgnoredWorktreeFolders} that share no top-level directory with anything the `.git` globs read, which an\n * exclude would hide. Such a folder's worktrees are still ignored, only watched.\n */\nexport function getIgnoredWorktreeFolderExcludes(folders: readonly string[] | undefined): string[] {\n\treturn sanitizeIgnoredWorktreeFolders(folders).filter(f => !watchedGitDirNameRegex.test(f.split('/')[0]));\n}\n\n/**\n * Directories to leave unwatched in the working tree (relative to it), for a provider that prunes natively —\n * the same ones {@link shouldIgnoreWorkingTreePath} drops from events.\n */\nexport const workingTreeExcludes: readonly string[] = ['**/node_modules', '**/.git'];\n\n/** Glob for watching .gitignore files in the working tree */\nexport const gitIgnoreGlob = '.gitignore';\n\n/** Glob for detecting .git directory creation (repository init/clone) */\nexport const gitInitGlob = '**/.git';\n\n// Regex-based filters that complement the globs above. The globs tell\n// the watcher *what* to observe; these filters tell it what to *skip*\n// at runtime (transient lock files, daemon artifacts, etc.).\n\nconst ignoredRepoPathRegex = /(?:\\/|\\\\)fsmonitor--daemon(?:\\/|\\\\)|(?:^|\\/)index\\.lock$/;\n\n/**\n * Returns true if the `.git`-relative path should be ignored\n * (transient filesystem artifacts, not meaningful git state changes).\n */\nexport function shouldIgnoreRepoPath(relativePath: string): boolean {\n\treturn ignoredRepoPathRegex.test(relativePath);\n}\n\nconst ignoredWorkingTreePathRegex =\n\t/(?:(?:\\/|\\\\)node_modules(?:\\/|\\\\|$)|\\.git(?:\\/index\\.lock)?(?:\\/|\\\\|$)|\\.watchman-cookie-)/;\n\n/**\n * Returns true if the working tree path should be ignored\n * (node_modules, .git internals, watchman cookies).\n */\nexport function shouldIgnoreWorkingTreePath(absolutePath: string): boolean {\n\treturn ignoredWorkingTreePathRegex.test(absolutePath);\n}\n"],"mappings":";;AAOA,MAAM,cACL;AAYD,MAAM,oBAAoB;;AAG1B,MAAa,qBAAqB,IAAI,YAAY,GAAG,kBAAkB;;AAGvE,MAAa,iBAAiB,IAAI,YAAY;;AAG9C,MAAa,mBAAmB,IAAI,kBAAkB;;;;;;AAOtD,MAAa,iBAAoC;CAChD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;;;;;AAMA,MAAa,mBAA2C;CACvD,EAAE,MAAM,OAAO;CACf,EAAE,MAAM,QAAQ;CAChB,EAAE,MAAM,YAAY;CACpB,EAAE,MAAM,aAAa;CACrB,EAAE,MAAM,mBAAmB;CAC3B,EAAE,MAAM,cAAc;CACtB,EAAE,MAAM,cAAc;CACtB,EAAE,MAAM,eAAe;CACvB,EAAE,MAAM,eAAe;CACvB,EAAE,MAAM,YAAY;CAEpB;EAAE,MAAM;EAAa,QAAQ,CAAC,MAAM;CAAE;AACvC;;;;;;AAOA,MAAa,qBAA6C;CACzD,EAAE,MAAM,cA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Content":["import { getBestPath, isAbsolute } from '@gitlens/utils/path.js';\nimport { isLinux } from '@gitlens/utils/platform.js';\nimport { escapeRegex } from '@gitlens/utils/string.js';\nimport type { GitDirProbe } from './gitDirPoller.js';\n\n// Glob patterns for watching files inside the .git directory.\n// They represent pure Git knowledge — the library owns these patterns and\n// provides them to the pluggable FileWatcherFactory.\n\nconst dotGitFiles =\n\t'index,HEAD,*_HEAD,MERGE_*,rebase-apply,rebase-apply/**,rebase-merge,rebase-merge/**,sequencer,sequencer/**';\n\n// `worktrees` (the bare entry, no `/*` suffix) is its own pattern: `worktree remove` deletes the whole\n// `worktrees/<id>` subtree in one syscall, and some platforms/watcher backends coalesce a same-instant\n// subtree delete into a single event for the PARENT directory — `worktrees/*` alone never matches that.\n// `classifyGitDirChange` classifies a bare `worktrees` path, so this is watch-coverage only.\n//\n// Only what `git worktree list` reports per worktree is watched here (its HEAD, lock and location). A\n// linked worktree's own index, `*_HEAD`, `MERGE_*`, rebase and sequencer state is watched by that\n// worktree's root watcher (`dotGitGlobRoot`) instead, so it never wakes sibling worktrees.\nconst dotGitWorktreeFiles = 'worktrees,worktrees/*,worktrees/*/HEAD,worktrees/*/locked,worktrees/*/gitdir';\n\nconst dotGitCommonFiles = `config,gk/config,refs/**,packed-refs,shallow,info/exclude,FETCH_HEAD,${dotGitWorktreeFiles}`;\n\n/** For a checkout whose `.git` directory is the common one (a standard repo or a main checkout): every .git file */\nexport const dotGitGlobCombined = `{${dotGitFiles},${dotGitCommonFiles}}`;\n\n/** For worktree repos: root watcher (worktree-specific files only) */\nexport const dotGitGlobRoot = `{${dotGitFiles}}`;\n\n/** For worktree repos: common watcher (shared config, refs, info, etc.) */\nexport const dotGitGlobCommon = `{${dotGitCommonFiles}}`;\n\nconst dotGitCommonPathRegex = new RegExp(\n\t`^(?:${dotGitCommonFiles\n\t\t.split(',')\n\t\t.map(p =>\n\t\t\tp\n\t\t\t\t.replace(/[.+?^${}()|[\\]\\\\]/g, '\\\\$&')\n\t\t\t\t.replace(/\\/\\*\\*$|\\*/g, glob => (glob === '*' ? '[^/]*' : '(?:/.*)?')),\n\t\t)\n\t\t.join('|')})$`,\n);\n\n/**\n * Whether a path relative to the common `.git` directory is one {@link dotGitGlobCommon} reads: a file every checkout of\n * the repository shares. A trailing `/**` takes in the directory itself, as a watcher's globstar may\n */\nexport function isGitDirCommonPath(relativePath: string): boolean {\n\treturn dotGitCommonPathRegex.test(relativePath);\n}\n\n/**\n * Directories to leave unwatched under the `.git` directory (relative to it), for a provider that prunes natively.\n * Only directories nothing in the globs above reads: never anything under `refs`, `worktrees/*` itself, `gk`, `info`,\n * or the rebase/sequencer directories.\n */\nexport const gitDirExcludes: readonly string[] = [\n\t'objects',\n\t'logs',\n\t'hooks',\n\t'lfs',\n\t'modules',\n\t'rr-cache',\n\t'fsmonitor--daemon',\n\t'worktrees/*/logs',\n];\n\n/**\n * What a poll stats in a worktree's own `.git` directory when its watcher can't be trusted — the files\n * {@link dotGitGlobRoot} reads.\n */\nexport const gitDirRootProbes: readonly GitDirProbe[] = [\n\t{ path: 'HEAD' },\n\t{ path: 'index' },\n\t{ path: 'ORIG_HEAD' },\n\t{ path: 'MERGE_HEAD' },\n\t{ path: 'CHERRY_PICK_HEAD' },\n\t{ path: 'REVERT_HEAD' },\n\t{ path: 'REBASE_HEAD' },\n\t{ path: 'rebase-merge' },\n\t{ path: 'rebase-apply' },\n\t{ path: 'sequencer' },\n\t// Moves with every commit, reset or checkout on the checked-out branch, without the poll knowing its name\n\t{ path: 'logs/HEAD', emitAs: ['HEAD'] },\n];\n\n/**\n * What a poll stats in the common `.git` directory — the files {@link dotGitGlobCommon} reads, with the `refs/**` it\n * can't list narrowed to its namespace directories (whose mtime moves as a top-level ref is created or deleted) and\n * to the named refs of {@link getGitDirRefProbes}.\n */\nexport const gitDirCommonProbes: readonly GitDirProbe[] = [\n\t{ path: 'packed-refs' },\n\t{ path: 'config' },\n\t{ path: 'gk/config' },\n\t{ path: 'info/exclude' },\n\t{ path: 'refs/heads' },\n\t// Moves as a remote's directory appears or goes: `git remote remove` and `git remote rename` delete or move each of\n\t// its loose refs (a packed one is locked through a loose path too), and git removes the emptied directory. Reported\n\t// as every remote-tracking ref possibly moved, since the poll can't tell which remote it was. A remote whose name\n\t// nests under a directory another remote still uses (`foo/bar` beside `foo/baz`) leaves it unmoved, so only a named\n\t// ref's probe sees that one go\n\t{ path: 'refs/remotes' },\n\t{ path: 'refs/tags' },\n\t{ path: 'refs/stash' },\n\t{ path: 'worktrees' },\n\t{ path: 'shallow' },\n\t// A fetch writes it with the remote-tracking refs it updated, which the poll can't list. Git rewrites it even on a\n\t// fetch that moves nothing, so each fetch is reported as a `remotes` change: the cost of seeing remote-tracking\n\t// refs no subscriber names\n\t{ path: 'FETCH_HEAD', emitAs: ['FETCH_HEAD', 'refs/remotes'] },\n];\n\n/** For each path a probe of {@link gitDirRootProbes} or {@link gitDirCommonProbes} is emitted as, the probes emitted as it */\nexport const gitDirProbesByEmittedPath: ReadonlyMap<string, readonly string[]> = getProbesByEmittedPath([\n\t...gitDirRootProbes,\n\t...gitDirCommonProbes,\n]);\n\nfunction getProbesByEmittedPath(probes: readonly GitDirProbe[]): Map<string, string[]> {\n\tconst map = new Map<string, string[]>();\n\tfor (const probe of probes) {\n\t\tfor (const path of probe.emitAs ?? []) {\n\t\t\tconst paths = map.get(path);\n\t\t\tif (paths == null) {\n\t\t\t\tmap.set(path, [probe.path]);\n\t\t\t} else {\n\t\t\t\tpaths.push(probe.path);\n\t\t\t}\n\t\t}\n\t}\n\treturn map;\n}\n\n/**\n * Probes for named branches and remote-tracking refs: each loose ref file, and each directory between it and its\n * namespace (`refs/heads/feature` for `refs/heads/feature/x`, `refs/remotes/origin`), whose mtime moves as a sibling\n * ref is created or deleted. A ref created in a directory no named ref sits in is left to `packed-refs`, `logs/HEAD`\n * and `FETCH_HEAD`.\n */\nexport function getGitDirRefProbes(refs: Iterable<string>): GitDirProbe[] {\n\tconst paths = new Set<string>();\n\tfor (const ref of refs) {\n\t\tconst namespaceEnd = ref.startsWith('refs/heads/') ? 10 : ref.startsWith('refs/remotes/') ? 12 : -1;\n\t\tif (namespaceEnd === -1) continue;\n\n\t\tfor (let path = ref; path.length > namespaceEnd; path = path.substring(0, path.lastIndexOf('/'))) {\n\t\t\tpaths.add(path);\n\t\t}\n\t}\n\treturn Array.from(paths, path => ({ path: path }));\n}\n\n/**\n * The top-level names under the `.git` directory that the globs above read or a poll stats, as one case-insensitive\n * pattern (a folder may sit on a case-insensitive file system)\n */\nconst watchedGitDirNames = new Set(\n\t[\n\t\t...`${dotGitFiles},${dotGitCommonFiles}`.split(','),\n\t\t...gitDirRootProbes.map(p => p.path),\n\t\t...gitDirCommonProbes.map(p => p.path),\n\t].map(p => p.split('/')[0]),\n);\nconst watchedGitDirNameRegex = new RegExp(\n\t`^(?:${Array.from(watchedGitDirNames, name => name.replace(/[.+?^${}()|[\\]\\\\]/g, '\\\\$&').replace(/\\*/g, '[^/]*')).join('|')})$`,\n\t'i',\n);\n\n/**\n * The registered folders whose worktrees core ignores, each as a `/`-separated literal path relative to a repository's\n * common git dir, without `.` or empty segments; any other is dropped. A folder must lie strictly inside the common git\n * dir (never absolute, never through `..`), name no glob syntax (a picomatch group or extglob's parentheses and `|`\n * included) or `:` (a watcher's exclude would read it as a pattern, so `(refs|x)` would leave `refs` unwatched, or a\n * drive), and not lie under `worktrees`, whose admin entries are what tells an ignored worktree apart.\n */\nexport function sanitizeIgnoredWorktreeFolders(folders: readonly string[] | undefined): string[] {\n\tif (!folders?.length) return [];\n\n\tconst sanitized = new Set<string>();\n\tfor (const folder of folders) {\n\t\tif (isAbsolute(folder) || /^[\\\\/]/.test(folder)) continue;\n\n\t\tconst segments = folder.split(/[\\\\/]/).filter(s => s && s !== '.');\n\t\tif (\n\t\t\t!segments.length ||\n\t\t\tsegments[0].toLowerCase() === 'worktrees' ||\n\t\t\tsegments.some(s => s === '..' || /[*?[\\]{}()|!:]/.test(s))\n\t\t) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tsanitized.add(segments.join('/'));\n\t}\n\treturn [...sanitized];\n}\n\n/**\n * The registered folders a `.git` watcher over the common git dir may leave unwatched: those of\n * {@link sanitizeIgnoredWorktreeFolders} that share no top-level directory with anything the `.git` globs read, which an\n * exclude would hide. Such a folder's worktrees are still ignored, only watched.\n */\nexport function getIgnoredWorktreeFolderExcludes(folders: readonly string[] | undefined): string[] {\n\treturn sanitizeIgnoredWorktreeFolders(folders).filter(f => !watchedGitDirNameRegex.test(f.split('/')[0]));\n}\n\n/**\n * Directories to leave unwatched in the working tree (relative to it), for a provider that prunes natively —\n * the same ones {@link shouldIgnoreWorkingTreePath} drops from events.\n */\nexport const workingTreeExcludes: readonly string[] = ['**/node_modules', '**/.git'];\n\n/** Glob for watching .gitignore files in the working tree */\nexport const gitIgnoreGlob = '.gitignore';\n\n/** Glob for detecting .git directory creation (repository init/clone) */\nexport const gitInitGlob = '**/.git';\n\n// Regex-based filters that complement the globs above. The globs tell\n// the watcher *what* to observe; these filters tell it what to *skip*\n// at runtime (transient lock files, daemon artifacts, etc.).\n\nconst ignoredRepoPathRegex = /(?:\\/|\\\\)fsmonitor--daemon(?:\\/|\\\\)|(?:^|\\/)index\\.lock$/;\n\n/**\n * Returns true if the `.git`-relative path should be ignored\n * (transient filesystem artifacts, not meaningful git state changes).\n */\nexport function shouldIgnoreRepoPath(relativePath: string): boolean {\n\treturn ignoredRepoPathRegex.test(relativePath);\n}\n\n// Anchored to a whole path segment (the lookbehind accepts the start or a separator, which also lets a scan begin\n// mid-string at the first segment after a root), so `repo.git/` or `my_node_modules/` don't match. Global so\n// `lastIndex` can start the scan past the root.\nconst ignoredWorkingTreePathRegex = /(?<![^\\\\/])(?:(?:node_modules|\\.git)(?:[\\\\/]|$)|\\.watchman-cookie-)/g;\n\nfunction isIgnoredWorkingTreePathFrom(path: string, from: number): boolean {\n\tignoredWorkingTreePathRegex.lastIndex = from;\n\treturn ignoredWorkingTreePathRegex.test(path);\n}\n\n/**\n * Returns true if the working tree path, relative to the repository root, should be ignored\n * (node_modules, .git internals, watchman cookies). Only whole segments match.\n */\nexport function shouldIgnoreWorkingTreePath(relativePath: string): boolean {\n\treturn isIgnoredWorkingTreePathFrom(relativePath, 0);\n}\n\n/**\n * Creates the per-event noise check for a working-tree watcher. It judges only the part of an absolute event path\n * inside `repoPath`, so folders above the root (`app.git/feature`, a `node_modules` ancestor) never count. The root is\n * compiled once here, so an event costs one anchored match and a scan of its tail, with no path normalization. The\n * match is tolerant of either separator and, off Linux, of case, as `isDescendant` is.\n *\n * A path not under the root is judged whole.\n */\nexport function createWorkingTreeNoiseFilter(repoPath: string): (absoluteEventPath: string) => boolean {\n\tconst root = getBestPath(repoPath);\n\tconst source = root.split('/').map(escapeRegex).join('[\\\\\\\\/]');\n\t// Sticky: the match must start at `lastIndex` (0), so it is a prefix test with no scan\n\tconst rootRegex = new RegExp(\n\t\t`${root.startsWith('/') ? '' : '[\\\\\\\\/]?'}${source}(?:[\\\\\\\\/]|$)`,\n\t\tisLinux ? 'y' : 'iy',\n\t);\n\n\treturn (absoluteEventPath: string): boolean => {\n\t\trootRegex.lastIndex = 0;\n\t\treturn isIgnoredWorkingTreePathFrom(\n\t\t\tabsoluteEventPath,\n\t\t\trootRegex.test(absoluteEventPath) ? rootRegex.lastIndex : 0,\n\t\t);\n\t};\n}\n"],"mappings":";;;;AASA,MAAM,cACL;AAYD,MAAM,oBAAoB;;AAG1B,MAAa,qBAAqB,IAAI,YAAY,GAAG,kBAAkB;;AAGvE,MAAa,iBAAiB,IAAI,YAAY;;AAG9C,MAAa,mBAAmB,IAAI,kBAAkB;AAEtD,MAAM,wBAAwB,IAAI,OACjC,OAAO,kBACL,MAAM,GAAG,CAAC,CACV,KAAI,MACJ,EACE,QAAQ,sBAAsB,MAAM,CAAC,CACrC,QAAQ,gBAAe,SAAS,SAAS,MAAM,UAAU,UAAW,CACvE,CAAC,CACA,KAAK,GAAG,EAAE,GACb;;;;;AAMA,SAAg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SAAgB,iCAAiC,SAAkD;CAClG,OAAO,+BAA+B,OAAO,CAAC,CAAC,QAAO,MAAK,CAAC,uBAAuB,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC;AACzG;;;;;AAMA,MAAa,sBAAyC,CAAC,mBAAmB,SAAS;;AAGnF,MAAa,gBAAgB;;AAG7B,MAAa,cAAc;AAM3B,MAAM,uBAAuB;;;;;AAM7B,SAAgB,qBAAqB,cAA+B;CACnE,OAAO,qBAAqB,KAAK,YAAY;AAC9C;AAKA,MAAM,8BAA8B;AAEpC,SAAS,6BAA6B,MAAc,MAAuB;CAC1E,4BAA4B,YAAY;CACxC,OAAO,4BAA4B,KAAK,IAAI;AAC7C;;;;;AAMA,SAAgB,4BAA4B,cAA+B;CAC1E,OAAO,6BAA6B,cAAc,CAAC;AACpD;;;;;;;;;AAUA,SAAgB,6BAA6B,UAA0D;CACtG,MAAM,OAAO,YAAY,QAAQ;CACjC,MAAM,SAAS,KAAK,MAAM,GAAG,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,KAAK,SAAS;CAE9D,MAAM,YAAY,IAAI,OACrB,GAAG,KAAK,WAAW,GAAG,IAAI,KAAK,aAAa,OAAO,gBACnD,UAAU,MAAM,IACjB;CAEA,QAAQ,sBAAuC;EAC9C,UAAU,YAAY;EACtB,OAAO,6BACN,mBACA,UAAU,KAAK,iBAAiB,IAAI,UAAU,YAAY,CAC3D;CACD;AACD"}
|
|
@@ -62,8 +62,10 @@ export interface WorktreeSummary {
|
|
|
62
62
|
readonly baseDependsOn: readonly string[];
|
|
63
63
|
/**
|
|
64
64
|
* The latest recompute failed (worktree gone, lock contention, git past its time limit); the other fields hold the
|
|
65
|
-
* last values read. Also set
|
|
66
|
-
* `baseDependsOn` are their last values, or `undefined` and empty if the branch changed.
|
|
65
|
+
* last values read. Also set while only the base read failed, until a read of the base succeeds: the other fields
|
|
66
|
+
* are fresh, and `base` and `baseDependsOn` are their last values, or `undefined` and empty if the branch changed.
|
|
67
|
+
* Such a base is read again at once when something it depends on changes, and otherwise with the next change only
|
|
68
|
+
* once a wait since the failure is over, which doubles with each failure in a row.
|
|
67
69
|
*/
|
|
68
70
|
readonly stale: boolean;
|
|
69
71
|
}
|
|
@@ -124,16 +126,20 @@ export interface WorktreeSummaryServiceOptions {
|
|
|
124
126
|
readonly size: number;
|
|
125
127
|
} | undefined>;
|
|
126
128
|
/**
|
|
127
|
-
* For tests only; production never passes it. Called whenever the base re-measure
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
* Unset, it costs one check of the option.
|
|
129
|
+
* For tests only; production never passes it. Called whenever the base re-measure, or the base carried past a commit
|
|
130
|
+
* (`getAheadOfBaseAfterCommit`), answers in place of a full base read, with that answer and what a full
|
|
131
|
+
* `getAheadOfBase` of the same branch answers right after (`undefined` when that rejects or the provider has none),
|
|
132
|
+
* so a test can fail where the shortcut keeps an answer the full read would not. The summary keeps the shortcut's
|
|
133
|
+
* answer either way. The full read goes through the same provider and caches as the shortcut, so it checks the
|
|
134
|
+
* shortcut's reasoning, not whether those caches are current. The callback should record a mismatch for the test to
|
|
135
|
+
* fail on rather than throw: a throw is taken for a failed base read. Unset, it costs one check of the option.
|
|
134
136
|
*/
|
|
135
137
|
readonly verifyBaseRemeasure?: (remeasured: AheadOfBase, full: AheadOfBase | undefined) => void;
|
|
136
138
|
}
|
|
139
|
+
/** The clock a failed base read's wait, and the age of a base kept by a shortcut, are read from; exported for testing */
|
|
140
|
+
export declare const baseRetryClock: {
|
|
141
|
+
now: () => number;
|
|
142
|
+
};
|
|
137
143
|
/**
|
|
138
144
|
* A cached, change-notifying summary of each subscribed worktree — its branch, upstream and ahead/behind, whether it
|
|
139
145
|
* has working changes, and how far it is past its base — kept current by the repository watch layer.
|
|
@@ -173,8 +179,12 @@ export interface WorktreeSummaryServiceOptions {
|
|
|
173
179
|
* **Value-change-only notification.** {@link WorktreeSummarySubscription.onDidChange} and {@link onDidChangeSummary}
|
|
174
180
|
* fire only when some field's value differs from the previous summary — a recompute that reads the same answer is
|
|
175
181
|
* silent, so a consumer can re-render on every event without diffing. A failed recompute keeps the last values and
|
|
176
|
-
* sets `stale` (firing once); the next successful one clears it
|
|
177
|
-
*
|
|
182
|
+
* sets `stale` (firing once); the next successful one clears it, reading every group. A failed read of only the base
|
|
183
|
+
* keeps the rest and leaves the next events to read what they map to: the base again at once when what it depends on
|
|
184
|
+
* changed (a ref, HEAD, its stored values or config inputs), and else only once a wait since the failure is over,
|
|
185
|
+
* doubling with each failure in a row; until a base read succeeds, `stale` stays set. A summary still showing the
|
|
186
|
+
* dirty flag of a read without a subscription fires again, unchanged, once that flag is read again (its `dirtyReadAt`
|
|
187
|
+
* cleared).
|
|
178
188
|
*
|
|
179
189
|
* **Worktrees without a subscription.** {@link getSummary} and {@link getSummarySnapshot} answer one from its last read
|
|
180
190
|
* (kept for the {@link maxUnwatchedReads} most recently asked), re-reading only the groups whose inputs moved since:
|
|
@@ -232,7 +242,8 @@ export declare class WorktreeSummaryService implements UnifiedDisposable {
|
|
|
232
242
|
* {@link getSummary} does, with `dirtyReadAt` `undefined` once its summary follows its working tree, and until then
|
|
233
243
|
* the saved read's (see {@link WorktreeSummarySubscription.dirtyReadAt}), which `probeDirty` reads again. Any other
|
|
234
244
|
* answers from its last read, re-reading only the groups whose inputs moved since (no git when none did), and in
|
|
235
|
-
* full the first time, or after a failed
|
|
245
|
+
* full the first time, or after a failed read; a base that failed to read is read again as a subscribed worktree's
|
|
246
|
+
* is (see {@link WorktreeSummary.stale}). Its working tree is unwatched, so the dirty flag is re-read
|
|
236
247
|
* only when the index file moved, or with `probeDirty`; a rejection drops the last read, unless the read was cut
|
|
237
248
|
* short, which says nothing against it. Its inputs are core's cached answers, which only a `.git` watch of the
|
|
238
249
|
* worktree (or core's own writes) keeps current.
|