# Add a Side Panel to a Chrome Extension

Yes. An agent adds a Manifest V3 side panel to your extension, wires it into the webpack build and manifest, tests the logic with Jest, and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/add-side-panel/chrome-extension/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent reads how the extension is built and what surfaces it already has before it adds one. In an extension shaped like chibat/chrome-extension-typescript-starter, `public/manifest.json` is Manifest V3 with an `action` whose `default_popup` is `popup.html`, an `options_ui` page, a content script on `<all_urls>`, a background `service_worker` at `js/background.js`, the `storage` permission and `<all_urls>` host permissions. `webpack/webpack.common.js` has four entries, `popup`, `options`, `background` and `content_script`, emits them to `dist/js/`, splits shared code into `vendor.js` for every chunk except the background, and copies `public/` to `dist/` with `copy-webpack-plugin`. `src/popup.tsx` is a React 18 component that reads the active tab's URL with `chrome.tabs.query`, sets a badge count and sends a message to the content script. `package.json` pins `@types/chrome` at 0.0.158, which predates the `chrome.sidePanel` namespace, and `jest.config.js` transforms only `.ts` files through `ts-jest` with `tsconfig.test.json`, with one test in `src/__tests__/sum.ts`.

It adds the panel in the same shape as the popup. `public/sidepanel.html` loads `js/vendor.js` and `js/sidepanel.js` into a `#root` div, `src/sidepanel.tsx` renders a React component, and `webpack.common.js` gets a `sidepanel` entry so the copy plugin and the chunk splitting cover it with no other change. `manifest.json` gets a `side_panel` object with `default_path` set to `sidepanel.html`, the `sidePanel` permission, and a `minimum_chrome_version` because the API is not available in older builds. Because the action already opens a popup and Chrome gives the popup precedence, the agent keeps the popup and adds an "Open side panel" button to `src/popup.tsx` that calls `chrome.sidePanel.open` with the current window's id, which is allowed from a click. `src/background.ts` calls `chrome.sidePanel.setPanelBehavior` once at startup so the panel stays available per window.

The panel's job in the starter is to show the active tab and keep showing it as the user moves: the component reads `chrome.tabs.query` on mount, then subscribes to `chrome.tabs.onActivated` and `chrome.tabs.onUpdated` and unsubscribes in the effect's cleanup, so the title and URL follow the tab without a reload. The tab logic lives in `src/sidepanel/tabs.ts`, a `.ts` module with no React in it that exports `describeTab` and `subscribeToActiveTab(callback)`, so the component is thin and the logic matches what `jest.config.js` can transform. `@types/chrome` moves to a version that declares `chrome.sidePanel`, and `tsc` with `noEmitOnError` in `tsconfig.json` is what catches a wrong call signature.

Tests go in `src/__tests__/sidepanel-tabs.ts` beside `sum.ts`: a `chrome` global built from `jest.fn` stubs, a test that `subscribeToActiveTab` registers both listeners and the returned function removes them, a test that an `onUpdated` event for a different tab is ignored, and a test that `describeTab` handles a tab with no `url`, which happens on `chrome://` pages without the `tabs` permission. Before pushing the agent runs `npm ci`, `npm run build` to confirm `dist/` contains `sidepanel.html` and `js/sidepanel.js`, `npm test`, and `npx prettier --check` over `src/`, the steps the `build` workflow runs on Node 20 and 22.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add a side panel to this Chrome extension and open a pull request. Read package.json, public/manifest.json, public/popup.html, webpack/webpack.common.js, src/popup.tsx, src/background.ts, src/options.tsx, jest.config.js, tsconfig.json, tsconfig.test.json, src/__tests__/sum.ts and .github/workflows/build.yml first. Add public/sidepanel.html and src/sidepanel.tsx in the same shape as the popup, a sidepanel webpack entry, and in manifest.json a side_panel default_path, the sidePanel permission and a minimum_chrome_version. Keep the popup and add a button to it that opens the panel with chrome.sidePanel.open; set the panel behaviour in background.ts. The panel shows the active tab's title and URL and follows tab changes through chrome.tabs.onActivated and onUpdated, with the logic in src/sidepanel/tabs.ts as a plain TypeScript module. Update @types/chrome to a version that declares chrome.sidePanel. Write Jest tests for the tabs module with a stubbed chrome global. Run npm ci, npm run build, npm test and prettier --check and paste the results in the pull request. Do not change the content script or the options page.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is a pull request that adds `public/sidepanel.html`, `src/sidepanel.tsx`, `src/sidepanel/tabs.ts` and `src/__tests__/sidepanel-tabs.ts`, edits `public/manifest.json`, `webpack/webpack.common.js`, `src/popup.tsx`, `src/background.ts` and the `@types/chrome` line in `package.json` and `package-lock.json`. The content script and options page are untouched. The description shows the manifest diff, says why the popup stays and how the panel opens, lists the files `npm run build` emitted into `dist/`, and pastes the build, test and Prettier output.

On a repository with the starter's `build` workflow, the pull request runs `npm ci`, `npm run build` and `npm test` on Node 20 and 22, so a manifest key the build cannot copy or a type the updated `@types/chrome` does not declare fails before review.

A reviewer loads `dist/` as an unpacked extension, clicks the action, opens the panel from the popup, switches tabs and watches the panel follow. Then they decide whether the panel should replace the popup as the action's click target, which is a one-line change to `setPanelBehavior` and the removal of `default_popup`.

## Run it on every extension that needs a persistent surface

A team that maintains several extensions sends one `POST /o/{org}/sessions` per repository with this prompt and that repository in `resources`. Each run reads its own manifest and bundler, so an extension built with Vite and CRXJS gets a panel entry in that plugin's shape and a plain-JavaScript extension gets a panel without React, and each run opens its own pull request.

Give the API key a `webhook_url` and Rush POSTs `run.completed` when each turn ends, with the `session_url` to read the pull request and the build output from.

## Why run it on Rush?

An extension change is checked by building the bundle and inspecting what lands in `dist/`, because a manifest key with a typo or an entry the copy plugin misses only shows when Chrome refuses to load the folder. In a Rush sandbox the agent runs the real webpack build, lists the emitted files, runs the Jest suite with a stubbed `chrome` global, and keeps every command and its output in the run's record, so the reviewer sees the panel's HTML and script in the build before loading it.

The panel follows the popup's pattern exactly, one HTML file, one entry, one React component, and keeps the logic in a plain module the existing Jest configuration can run. The only dependency change is the `@types/chrome` version, which the new API requires. The same request works on any Manifest V3 extension with a bundler.

## Frequently asked questions

### Why keep the popup?

The manifest's `action` has a `default_popup`, and when one is set Chrome opens the popup on click, not the panel. The agent keeps the popup and gives it a button that calls `chrome.sidePanel.open`, which is allowed from a user click. Removing `default_popup` and letting the action open the panel is a one-line follow-up the pull request describes.

### Why update @types/chrome?

The pinned 0.0.158 release predates the `chrome.sidePanel` namespace, so `tsc` would reject every call to it and `noEmitOnError` would stop the build. The agent moves to a version that declares it and leaves the rest of the toolchain alone.

### How is the panel tested without a browser?

The tab-following logic is a plain TypeScript module, `src/sidepanel/tabs.ts`, with no React in it, which is what `jest.config.js` transforms. The tests build a `chrome` global from `jest.fn` stubs and check that listeners are added and removed and that updates for other tabs are ignored. The React component stays thin.

### Does the panel need new permissions?

The `sidePanel` permission. The active tab's URL and title are already readable because the manifest has `<all_urls>` in `host_permissions`; on pages where that does not apply, the module handles a tab with no `url` and the test covers it.

## More Chrome Extension jobs

- [Publish a Chrome Extension to the Chrome Web Store from GitHub Actions](https://getrush.ai/run/add-web-store-publishing/chrome-extension/)
- [Convert a Chrome Extension From JavaScript to TypeScript](https://getrush.ai/run/convert-javascript-to-typescript/chrome-extension/)
- [Migrate a Chrome Extension from Jest to Vitest](https://getrush.ai/run/migrate-jest-to-vitest/chrome-extension/)

## More jobs like this: Hand off a long task

- [Add Signals and Queries to a Temporal Workflow](https://getrush.ai/run/add-signals-and-queries/temporal/)
- [Add a Single-Instance Lock to an Electron App](https://getrush.ai/run/add-single-instance-lock/electron/)
- [Add a Sitemap to an Astro Blog](https://getrush.ai/run/add-sitemap/astro/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
