Files
deepseek-harness/apps/cli/tests/profile-hmr.spec.ts
T
Tianyi Cui fd814589fb refactor(profiles): make module HMR opt-in
Move the shared module-reload policy into dsh-base by inserting its HMR row disabled, then remove the redundant disabled overrides from Web, headless, SDK, and ACP. No shipped profile enables server module reload; live profile patch watching continues through the launcher-owned config-only fallback, and browser client HMR remains a separate mechanism.

A later profile layer can opt into source-module reload explicitly with disabled: false while retaining the base root configuration. Composition tests cover every shipped mode and the explicit enable path, and the bundle references plus launcher Agent Notes document the resulting ownership and safety rationale.
2026-08-23 10:59:01 +08:00

43 lines
1.6 KiB
TypeScript

/** Module-HMR ownership across the real shipped profile bundle layers. */
import { join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { describe, expect, it } from 'vitest'
import { composeEntries, loadOverlayPatches } from '@deepseek-ai/dsh-app-boot'
import type { PatchOptions } from '@deepseek-ai/cordis-plugin-include'
const REPOSITORY_ROOT = fileURLToPath(new URL('../../../', import.meta.url))
/** Load one shipped bundle patch through the same parser as profile boot. */
function bundle(name: 'acp-app' | 'base' | 'headless' | 'sdk-app' | 'web-app'): PatchOptions[] {
return loadOverlayPatches('profile-hmr test', join(REPOSITORY_ROOT, 'packages', 'bundle', name, 'cordis.patch.yml'))
}
/** Resolve the effective HMR row after the supplied layers. */
function hmr(layers: PatchOptions[][]) {
const row = composeEntries(layers).find(entry => entry.id === 'hmr')
if (row === undefined) throw new Error('the base bundle must insert the hmr row')
return row
}
describe('profile module-HMR policy', () => {
it.each(['web-app', 'headless', 'sdk-app', 'acp-app'] as const)(
'%s inherits the disabled base row without a mode override',
(mode) => {
const modePatches = bundle(mode)
expect(modePatches.some(patch => patch.id === 'hmr')).toBe(false)
expect(hmr([bundle('base'), modePatches])).toMatchObject({
disabled: true,
config: { root: ['.'] },
})
},
)
it('requires an explicit later layer to enable source-module reload', () => {
expect(hmr([bundle('base'), [{ id: 'hmr', disabled: false }]])).toMatchObject({
disabled: false,
config: { root: ['.'] },
})
})
})