Skip to content

Commit 0812df2

Browse files
authored
chore(extension): do not complain about old extension version (#937)
1 parent 3d1a60b commit 0812df2

File tree

3 files changed

+8
-74
lines changed

3 files changed

+8
-74
lines changed

extension/src/ui/connect.tsx

Lines changed: 2 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ import type { TabInfo } from './tabItem.js';
2222
type Status =
2323
| { type: 'connecting'; message: string }
2424
| { type: 'connected'; message: string }
25-
| { type: 'error'; message: string }
26-
| { type: 'error'; versionMismatch: { pwMcpVersion: string; extensionVersion: string; downloadUrl: string } };
25+
| { type: 'error'; message: string };
2726

2827
const ConnectApp: React.FC = () => {
2928
const [tabs, setTabs] = useState<TabInfo[]>([]);
@@ -59,23 +58,6 @@ const ConnectApp: React.FC = () => {
5958
return;
6059
}
6160

62-
const pwMcpVersion = params.get('pwMcpVersion');
63-
const extensionVersion = chrome.runtime.getManifest().version;
64-
if (pwMcpVersion !== extensionVersion) {
65-
const downloadUrl = params.get('downloadUrl') || `https://github.com/microsoft/playwright-mcp/releases/download/v${extensionVersion}/playwright-mcp-extension-v${extensionVersion}.zip`;
66-
setShowButtons(false);
67-
setShowTabList(false);
68-
setStatus({
69-
type: 'error',
70-
versionMismatch: {
71-
pwMcpVersion: pwMcpVersion || 'unknown',
72-
extensionVersion,
73-
downloadUrl
74-
}
75-
});
76-
return;
77-
}
78-
7961
void connectToMCPRelay(relayUrl);
8062

8163
// If this is a browser_navigate command, hide the tab list and show simple allow/reject
@@ -199,50 +181,11 @@ const ConnectApp: React.FC = () => {
199181
);
200182
};
201183

202-
const VersionMismatchError: React.FC<{ pwMcpVersion: string; extensionVersion: string; downloadUrl: string }> = ({ pwMcpVersion, extensionVersion, downloadUrl }) => {
203-
const readmeUrl = 'https://github.com/microsoft/playwright-mcp/blob/main/extension/README.md';
204-
205-
const handleDownloadAndOpenExtensions = () => {
206-
// Start download
207-
const link = document.createElement('a');
208-
link.href = downloadUrl;
209-
link.download = `playwright-mcp-extension-v${extensionVersion}.zip`;
210-
document.body.appendChild(link);
211-
link.click();
212-
document.body.removeChild(link);
213-
214-
setTimeout(() => {
215-
chrome.tabs.query({ active: true, currentWindow: true }, tabs => {
216-
if (tabs[0]?.id)
217-
chrome.tabs.update(tabs[0].id, { url: 'chrome://extensions/' });
218-
});
219-
}, 1000); // Wait 1 second for download to initiate
220-
};
221-
222-
return (
223-
<div>
224-
Incompatible Playwright MCP version: {pwMcpVersion} (extension version: {extensionVersion}).{' '}
225-
<button
226-
onClick={handleDownloadAndOpenExtensions}
227-
className='link-button'
228-
>Click here</button> to download the matching extension, then drag and drop it into the Chrome Extensions page.{' '}
229-
See <a href={readmeUrl} target='_blank' rel='noopener noreferrer'>installation instructions</a> for more details.
230-
</div>
231-
);
232-
};
233184

234185
const StatusBanner: React.FC<{ status: Status }> = ({ status }) => {
235186
return (
236187
<div className={`status-banner ${status.type}`}>
237-
{'versionMismatch' in status ? (
238-
<VersionMismatchError
239-
pwMcpVersion={status.versionMismatch.pwMcpVersion}
240-
extensionVersion={status.versionMismatch.extensionVersion}
241-
downloadUrl={status.versionMismatch.downloadUrl}
242-
/>
243-
) : (
244-
status.message
245-
)}
188+
{status.message}
246189
</div>
247190
);
248191
};

extension/tests/extension.spec.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import fs from 'fs';
1818
import path from 'path';
1919
import { fileURLToPath } from 'url';
2020
import { chromium } from 'playwright';
21-
import packageJSON from '../../package.json' assert { type: 'json' };
2221
import { test as base, expect } from '../../tests/fixtures.js';
2322

2423
import type { Client } from '@modelcontextprotocol/sdk/client/index.js';
@@ -117,7 +116,7 @@ async function startWithExtensionFlag(browserWithExtension: BrowserWithExtension
117116
return client;
118117
}
119118

120-
const testWithOldVersion = test.extend({
119+
const testWithOldExtensionVersion = test.extend({
121120
pathToExtension: async ({}, use, testInfo) => {
122121
const extensionDir = testInfo.outputPath('extension');
123122
const oldPath = fileURLToPath(new URL('../dist', import.meta.url));
@@ -216,7 +215,7 @@ for (const [mode, startClientMethod] of [
216215
await confirmationPagePromise;
217216
});
218217

219-
testWithOldVersion(`extension version mismatch (${mode})`, async ({ browserWithExtension, startClient, server, useShortConnectionTimeout }) => {
218+
testWithOldExtensionVersion(`works with old extension version (${mode})`, async ({ browserWithExtension, startClient, server, useShortConnectionTimeout }) => {
220219
useShortConnectionTimeout(500);
221220

222221
// Prelaunch the browser, so that it is properly closed after the test.
@@ -233,19 +232,13 @@ for (const [mode, startClientMethod] of [
233232
arguments: { url: server.HELLO_WORLD },
234233
});
235234

236-
const confirmationPage = await confirmationPagePromise;
237-
await expect(confirmationPage.locator('.status-banner')).toHaveText(`Incompatible Playwright MCP version: ${packageJSON.version} (extension version: 0.0.1). Click here to download the matching extension, then drag and drop it into the Chrome Extensions page. See installation instructions for more details.`);
235+
const selectorPage = await confirmationPagePromise;
236+
// For browser_navigate command, the UI shows Allow/Reject buttons instead of tab selector
237+
await selectorPage.getByRole('button', { name: 'Allow' }).click();
238238

239239
expect(await navigateResponse).toHaveResponse({
240-
result: expect.stringContaining('Extension connection timeout.'),
241-
isError: true,
240+
pageState: expect.stringContaining(`- generic [active] [ref=e1]: Hello, world!`),
242241
});
243-
244-
const downloadPromise = confirmationPage.waitForEvent('download');
245-
await confirmationPage.locator('.status-banner').getByRole('button', { name: 'Click here' }).click();
246-
const download = await downloadPromise;
247-
expect(download.url()).toBe(`https://github.com/microsoft/playwright-mcp/releases/download/v0.0.1/playwright-mcp-extension-v0.0.1.zip`);
248-
await download.cancel();
249242
});
250243

251244
}

src/extension/cdpRelay.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import { WebSocket, WebSocketServer } from 'ws';
2929
import { httpAddressToString } from '../mcp/http.js';
3030
import { logUnhandledError } from '../utils/log.js';
3131
import { ManualPromise } from '../mcp/manualPromise.js';
32-
import { packageJSON } from '../utils/package.js';
3332

3433
import type websocket from 'ws';
3534
import type { ClientInfo } from '../browserContextFactory.js';
@@ -120,7 +119,6 @@ export class CDPRelayServer {
120119
version: clientInfo.version,
121120
};
122121
url.searchParams.set('client', JSON.stringify(client));
123-
url.searchParams.set('pwMcpVersion', packageJSON.version);
124122
if (toolName)
125123
url.searchParams.set('newTab', String(toolName === 'browser_navigate'));
126124
const href = url.toString();

0 commit comments

Comments
 (0)