Skip to content

Commit 019e18c

Browse files
rekmarksclaude
andauthored
build: Decouple browser opening from watch mode in extension dev (#726)
- Add `--start-maximized` Chrome arg to extensionDev plugin - Replace `--watch` trigger with `OPEN_BROWSER` env var for browser opening - Add `build:browser` script that sets `OPEN_BROWSER=true` - Update `start.sh` scripts to use `yarn build:browser` Browser now opens maximized so dev mode toggle is visible. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Decouples automatic browser launch from watch mode and adds a dedicated opt‑in. > > - Adds `build:browser` in `packages/extension` and `packages/omnium-gatherum`; updates `scripts/start.sh` to use it > - Vite configs now gate `extensionDev` on `OPEN_BROWSER` (`shouldOpenBrowser`) instead of `--watch` > - `extension-dev` plugin launches Chrome with `--start-maximized` and removes explicit viewport sizing > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 2fef526. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: Claude Opus 4.5 <[email protected]>
1 parent 88e3964 commit 019e18c

File tree

7 files changed

+11
-7
lines changed

7 files changed

+11
-7
lines changed

packages/extension/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"build": "yarn build:vite && yarn test:build",
1919
"build:dev": "yarn build:vite --mode development",
2020
"build:watch": "yarn build:dev --watch",
21+
"build:browser": "OPEN_BROWSER=true yarn build:dev --watch",
2122
"build:vite": "vite build --configLoader runner --config vite.config.ts",
2223
"changelog:validate": "../../scripts/validate-changelog.sh @ocap/extension",
2324
"clean": "rimraf --glob './*.tsbuildinfo' ./.eslintcache ./coverage ./dist ./.turbo",

packages/extension/scripts/start.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ function cleanup() {
2323
# Ensure we always close the ocap cli
2424
trap cleanup EXIT
2525

26-
yarn build:watch
26+
yarn build:browser

packages/extension/vite.config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const staticCopyTargets: readonly (string | Target)[] = [
4444
export default defineConfig(({ mode }) => {
4545
const isDev = mode === 'development';
4646
const isWatching = process.argv.includes('--watch');
47+
const shouldOpenBrowser = process.env.OPEN_BROWSER === 'true';
4748
if (isWatching && !isDev) {
4849
throw new Error('Cannot watch in non-development mode');
4950
}
@@ -111,8 +112,8 @@ export default defineConfig(({ mode }) => {
111112
}),
112113
moveHtmlFilesToRoot(),
113114
watchInternalPackages({ rootDir, packages: ['kernel-ui'] }),
114-
// Open the extension in the browser when watching
115-
isWatching && extensionDev({ extensionPath: outDir }),
115+
// Open the extension in the browser when --browser flag is passed
116+
shouldOpenBrowser && extensionDev({ extensionPath: outDir }),
116117
],
117118
};
118119
});

packages/omnium-gatherum/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"build": "yarn build:vite && yarn test:build",
2020
"build:dev": "yarn build:vite --mode development",
2121
"build:watch": "yarn build:dev --watch",
22+
"build:browser": "OPEN_BROWSER=true yarn build:dev --watch",
2223
"build:vite": "vite build --configLoader runner --config vite.config.ts",
2324
"changelog:validate": "../../scripts/validate-changelog.sh @ocap/omnium-gatherum",
2425
"clean": "rimraf --glob './*.tsbuildinfo' ./.eslintcache ./coverage ./dist ./.turbo",

packages/omnium-gatherum/scripts/start.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ function cleanup() {
2323
# Ensure we always close the ocap cli
2424
trap cleanup EXIT
2525

26-
yarn build:watch
26+
yarn build:browser

packages/omnium-gatherum/vite.config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const trustedPreludes: PreludeRecord = {
5252
export default defineConfig(({ mode }) => {
5353
const isDev = mode === 'development';
5454
const isWatching = process.argv.includes('--watch');
55+
const shouldOpenBrowser = process.env.OPEN_BROWSER === 'true';
5556
if (isWatching && !isDev) {
5657
throw new Error('Cannot watch in non-development mode');
5758
}
@@ -121,8 +122,8 @@ export default defineConfig(({ mode }) => {
121122
}),
122123
moveHtmlFilesToRoot(),
123124
watchInternalPackages({ rootDir, packages: ['kernel-ui'] }),
124-
// Open the extension in the browser when watching
125-
isWatching && extensionDev({ extensionPath: outDir }),
125+
// Open the extension in the browser when --browser flag is passed
126+
shouldOpenBrowser && extensionDev({ extensionPath: outDir }),
126127
],
127128
};
128129
});

packages/repo-tools/src/vite-plugins/extension-dev.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export function extensionDev({
6262
args: [
6363
`--disable-extensions-except=${extensionPath}`,
6464
`--load-extension=${extensionPath}`,
65+
'--start-maximized',
6566
],
6667
});
6768

@@ -89,7 +90,6 @@ export function extensionDev({
8990

9091
// Open the extensions page for our extension
9192
const extensionsPage = await browserContext.newPage();
92-
await extensionsPage.setViewportSize({ width: 1300, height: 700 });
9393
await extensionsPage.goto(`chrome://extensions/?id=${extensionId}`);
9494

9595
// Update state after all checks

0 commit comments

Comments
 (0)