diff --git a/src/session-cache.ts b/src/session-cache.ts index b713d2a3..42e09404 100644 --- a/src/session-cache.ts +++ b/src/session-cache.ts @@ -650,7 +650,7 @@ export function isCacheDirty(cache: SessionCache): boolean { * held back by the resident process's coalescing. */ export function hasDirtyDurableProvider(cache: SessionCache): boolean { for (const provider of stateOf(cache).dirtyBuckets.keys()) { - if (DURABLE_PROVIDER_NAMES.has(provider)) return true + if (DURABLE_PROVIDER_NAMES.has(provider) || cache.providers[provider]?.durable) return true } return false } diff --git a/tests/durable-publish-guard.test.ts b/tests/durable-publish-guard.test.ts new file mode 100644 index 00000000..fb410cbf --- /dev/null +++ b/tests/durable-publish-guard.test.ts @@ -0,0 +1,23 @@ +import { describe, expect, it } from 'vitest' + +import { emptyCache, hasDirtyDurableProvider, markCacheDirty } from '../src/session-cache.js' + +describe('hasDirtyDurableProvider', () => { + it('covers a provider marked durable on its section, not only the named ones', () => { + const cache = emptyCache() + cache.providers['quickdesk'] = { envFingerprint: '', files: {}, durable: true } + cache.providers['claude'] = { envFingerprint: '', files: {} } + + markCacheDirty(cache, 'claude') + expect(hasDirtyDurableProvider(cache)).toBe(false) + + markCacheDirty(cache, 'quickdesk') + expect(hasDirtyDurableProvider(cache)).toBe(true) + }) + + it('still covers copilot before its section carries the flag', () => { + const cache = emptyCache() + markCacheDirty(cache, 'copilot') + expect(hasDirtyDurableProvider(cache)).toBe(true) + }) +})