fix(titlebar): reserve Windows window controls for logo

This commit is contained in:
2026-09-02 10:42:16 +08:00
parent d83757a115
commit e800d42595
5 changed files with 98 additions and 6 deletions

View File

@@ -711,9 +711,15 @@ test('PI feature UI isolates Conversations and exposes queue, interaction, model
]);
expect(titlebarBounds.every((bounds) => bounds?.y === 0 && bounds.height === 40)).toBe(true);
const logoBounds = await page.getByTestId('titlebar-logo').boundingBox();
const windowWidth = await page.evaluate(() => window.innerWidth);
expect(logoBounds).not.toBeNull();
expect(Math.abs((logoBounds!.x + logoBounds!.width) - windowWidth)).toBeLessThanOrEqual(1);
if (await page.evaluate(() => window.electron.platform === 'win32')) {
const minimizeBounds = await page.getByTitle('Minimize').boundingBox();
expect(minimizeBounds).not.toBeNull();
expect(logoBounds!.x + logoBounds!.width).toBeLessThanOrEqual(minimizeBounds!.x);
} else {
const windowWidth = await page.evaluate(() => window.innerWidth);
expect(Math.abs((logoBounds!.x + logoBounds!.width) - windowWidth)).toBeLessThanOrEqual(1);
}
const conversationHeader = page.getByTestId('coding-conversation-header');
await expect(conversationHeader).toContainText('新对话');
await expect(conversationHeader).not.toContainText('Pi ·');

View File

@@ -0,0 +1,20 @@
import { closeElectronApp, expect, getStableWindow, test } from './fixtures/electron';
test('keeps the Canvas logo clear of Windows window controls', async ({ launchElectronApp }) => {
test.skip(process.platform !== 'win32', 'Windows custom titlebar only');
const app = await launchElectronApp({ skipSetup: true });
try {
const page = await getStableWindow(app);
await expect(page.getByTestId('ai-module-selection-page')).toBeVisible();
await page.getByTestId('ai-module-option-painting').click();
const logoBounds = await page.getByTestId('titlebar-logo').boundingBox();
const minimizeBounds = await page.getByTitle('Minimize').boundingBox();
expect(logoBounds).not.toBeNull();
expect(minimizeBounds).not.toBeNull();
expect(logoBounds!.x + logoBounds!.width).toBeLessThanOrEqual(minimizeBounds!.x);
} finally {
await closeElectronApp(app);
}
});