diff --git a/scripts/desktop-tauri-build.test.mjs b/scripts/desktop-tauri-build.test.mjs index 40037fa28d..2399ecc306 100644 --- a/scripts/desktop-tauri-build.test.mjs +++ b/scripts/desktop-tauri-build.test.mjs @@ -68,6 +68,31 @@ test('Desktop DMG uses the branded installer layout', () => { appPosition: { x: 180, y: 170 }, applicationFolderPosition: { x: 480, y: 170 }, }); + + // Finder uses the PNG's physical size, not just its pixel dimensions. + // A 660x400 image tagged at 96 DPI renders at 495x300 points and leaves gaps. + const dmg = config.bundle.macOS.dmg; + const background = readFileSync(join(ROOT, 'src', 'apps', 'desktop', dmg.background)); + assert.deepEqual(background.subarray(0, 8), Buffer.from('89504e470d0a1a0a', 'hex')); + let pixels; + let density; + for (let offset = 8; offset < background.length; ) { + const length = background.readUInt32BE(offset); + const type = background.toString('ascii', offset + 4, offset + 8); + if (type === 'IHDR') { + pixels = [background.readUInt32BE(offset + 8), background.readUInt32BE(offset + 12)]; + } else if (type === 'pHYs') { + assert.equal(background[offset + 16], 1, 'background density must be in pixels per metre'); + density = [background.readUInt32BE(offset + 8), background.readUInt32BE(offset + 12)]; + } + offset += length + 12; + } + assert.ok(pixels && density, 'DMG background must declare pixel dimensions and physical density'); + for (const [axis, points] of [dmg.windowSize.width, dmg.windowSize.height].entries()) { + const imagePoints = pixels[axis] * 72 / (density[axis] * 0.0254); + // PNG stores integer pixels/metre, so 72 DPI rounds to 2835 pixels/metre. + assert.ok(Math.abs(imagePoints - points) < 0.1, `background axis ${axis} must match Finder points`); + } }); test('Desktop builds prepare and bundle the OpenCode extension Host', () => { diff --git a/src/apps/desktop/dmg/background.png b/src/apps/desktop/dmg/background.png index 6e5f604d9b..a48af7a145 100644 Binary files a/src/apps/desktop/dmg/background.png and b/src/apps/desktop/dmg/background.png differ