The agent that turns websites into APIs!
feat(chrome-ext): improve side panel UX, reduce bundle size, fix message persistence
kalil0321ad8170917f62
diff --git a/README.md b/README.mdindex ad4ce7d..308b15a 100644--- a/README.md+++ b/README.md@@ -371,72 +371,44 @@ A Chrome extension that provides browser-native integration with reverse-api-eng- **Side Panel UI**: Interactive interface for managing captures and chatting with the AI agent- **Native Host Integration**: Communicates with the reverse-api-engineer CLI tool-### Local Development Setup--To run the Chrome extension locally for development:+### Setup**Prerequisites:**-- Node.js and npm installed+- Node.js and npm- Chrome browser-- reverse-api-engineer CLI installed and native host configured+- reverse-api-engineer CLI installed (`uv tool install reverse-api-engineer`)+- Claude Code CLI installed (`npm install -g @anthropic-ai/claude-code`)-**Setup Steps:**+**Steps:**-1. **Clone the repository:**- ```bash- git clone https://github.com/kalil0321/reverse-api-engineer.git- cd reverse-api-engineer- ```--2. **Navigate to the extension directory:**+1. **Build the extension:**```bashcd chrome-extension+ npm install+ npm run build```-3. **Install dependencies:**+2. **Load in Chrome:**+ - Go to `chrome://extensions/`+ - Enable **Developer mode** (top-right toggle)+ - Click **Load unpacked** and select the `chrome-extension/dist` directory+ - **Copy the extension ID** (32-character string shown under the extension name)++3. **Install the native host** (connects the extension to the CLI):```bash- npm install+ reverse-api-engineer install-host --extension-id YOUR_EXTENSION_ID```-4. **Build the extension:**+4. **macOS only** — run this once to approve Claude Code through Gatekeeper:```bash- npm run build+ claude --version```- This creates a `dist` directory with the compiled extension.--5. **Load the extension in Chrome:**- - Open Chrome and navigate to `chrome://extensions/`- - Enable "Developer mode" (toggle in the top-right corner)- - Click "Load unpacked"- - Select the `chrome-extension/dist` directory- - The extension should now appear in your extensions list--6. **Configure Native Host:**- - Ensure the native host is installed:- ```bash- reverse-api-engineer install-host- ```- - The extension communicates with the CLI via native messaging+ If macOS shows a security popup, go to **System Settings > Privacy & Security** and click **Allow Anyway**, then run the command again.**Development Workflow:**-- **Watch mode** (auto-rebuild on changes):- ```bash- npm run dev- ```- After rebuilding, reload the extension in Chrome (`chrome://extensions/` → click the reload icon).--- **Production build:**- ```bash- npm run build- ```--- **Type checking:**- ```bash- npm run typecheck- ```--**Status:** The extension is currently under active development. Some features may be incomplete or subject to change.+- `npm run dev` — watch mode (auto-rebuild on changes, then reload in `chrome://extensions/`)+- `npm run build` — production build## 💡 Examplesdiff --git a/chrome-extension/package-lock.json b/chrome-extension/package-lock.jsonindex f60710c..ab78b5f 100644--- a/chrome-extension/package-lock.json+++ b/chrome-extension/package-lock.json@@ -8,16 +8,12 @@"name": "reverse-api-extension","version": "0.1.0","dependencies": {- "@base-ui/react": "^1.0.0",- "ansi-to-react": "^6.1.6","clsx": "^2.1.1",- "lucide-react": "^0.563.0","react": "^18.3.1","react-dom": "^18.3.1","react-markdown": "^9.1.0","react-syntax-highlighter": "^15.6.6","remark-gfm": "^4.0.1",- "shiki": "^3.22.0","tailwind-merge": "^3.4.0"},"devDependencies": {@@ -337,60 +333,6 @@"node": ">=6.9.0"}},- "node_modules/@base-ui/react": {- "version": "1.0.0",- "resolved": "https://registry.npmjs.org/@base-ui/react/-/react-1.0.0.tgz",- "integrity": "sha512-4USBWz++DUSLTuIYpbYkSgy1F9ZmNG9S/lXvlUN6qMK0P0RlW+6eQmDUB4DgZ7HVvtXl4pvi4z5J2fv6Z3+9hg==",- "license": "MIT",- "dependencies": {- "@babel/runtime": "^7.28.4",- "@base-ui/utils": "0.2.3",- "@floating-ui/react-dom": "^2.1.6",- "@floating-ui/utils": "^0.2.10",- "reselect": "^5.1.1",- "tabbable": "^6.3.0",- "use-sync-external-store": "^1.6.0"- },- "engines": {- "node": ">=14.0.0"- },- "funding": {- "type": "opencollective",- "url": "https://opencollective.com/mui-org"- },- "peerDependencies": {- "@types/react": "^17 || ^18 || ^19",- "react": "^17 || ^18 || ^19",- "react-dom": "^17 || ^18 || ^19"- },- "peerDependenciesMeta": {- "@types/react": {- "optional": true- }- }- },- "node_modules/@base-ui/utils": {- "version": "0.2.3",- "resolved": "https://registry.npmjs.org/@base-ui/utils/-/utils-0.2.3.tgz",- "integrity": "sha512-/CguQ2PDaOzeVOkllQR8nocJ0FFIDqsWIcURsVmm53QGo8NhFNpePjNlyPIB41luxfOqnG7PU0xicMEw3ls7XQ==",- "license": "MIT",- "dependencies": {- "@babel/runtime": "^7.28.4",- "@floating-ui/utils": "^0.2.10",- "reselect": "^5.1.1",- "use-sync-external-store": "^1.6.0"- },- "peerDependencies": {- "@types/react": "^17 || ^18 || ^19",- "react": "^17 || ^18 || ^19",- "react-dom": "^17 || ^18 || ^19"- },- "peerDependenciesMeta": {- "@types/react": {- "optional": true- }- }- },"node_modules/@esbuild/aix-ppc64": {"version": "0.25.12","resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.12.tgz",@@ -833,44 +775,6 @@"node": ">=18"}},- "node_modules/@floating-ui/core": {- "version": "1.7.3",- "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.7.3.tgz",- "integrity": "sha512-sGnvb5dmrJaKEZ+LDIpguvdX3bDlEllmv4/ClQ9awcmCZrlx5jQyyMWFM5kBI+EyNOCDDiKk8il0zeuX3Zlg/w==",- "license": "MIT",- "dependencies": {- "@floating-ui/utils": "^0.2.10"- }- },- "node_modules/@floating-ui/dom": {- "version": "1.7.4",- "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.7.4.tgz",- "integrity": "sha512-OOchDgh4F2CchOX94cRVqhvy7b3AFb+/rQXyswmzmGakRfkMgoWVjfnLWkRirfLEfuD4ysVW16eXzwt3jHIzKA==",- "license": "MIT",- "dependencies": {- "@floating-ui/core": "^1.7.3",- "@floating-ui/utils": "^0.2.10"- }- },- "node_modules/@floating-ui/react-dom": {- "version": "2.1.6",- "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.1.6.tgz",- "integrity": "sha512-4JX6rEatQEvlmgU80wZyq9RT96HZJa88q8hp0pBd+LrczeDI4o6uA2M+uvxngVHo4Ihr8uibXxH6+70zhAFrVw==",- "license": "MIT",- "dependencies": {- "@floating-ui/dom": "^1.7.4"- },- "peerDependencies": {- "react": ">=16.8.0",- "react-dom": ">=16.8.0"- }- },- "node_modules/@floating-ui/utils": {- "version": "0.2.10",- "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.10.tgz",- "integrity": "sha512-aGTxbpbg8/b5JfU1HXSrbH3wXZuLPJcNEcZQFMxLs3oSzgtVu6nFPkbbGGUvBcUjKV2YyB9Wxxabo+HEH9tcRQ==",- "license": "MIT"- },"node_modules/@jridgewell/gen-mapping": {"version": "0.3.13","resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",@@ -1316,73 +1220,6 @@"win32"]},- "node_modules/@shikijs/core": {- "version": "3.22.0",- "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-3.22.0.tgz",- "integrity": "sha512-iAlTtSDDbJiRpvgL5ugKEATDtHdUVkqgHDm/gbD2ZS9c88mx7G1zSYjjOxp5Qa0eaW0MAQosFRmJSk354PRoQA==",- "license": "MIT",- "dependencies": {- "@shikijs/types": "3.22.0",- "@shikijs/vscode-textmate": "^10.0.2",- "@types/hast": "^3.0.4",- "hast-util-to-html": "^9.0.5"- }- },- "node_modules/@shikijs/engine-javascript": {- "version": "3.22.0",- "resolved": "https://registry.npmjs.org/@shikijs/engine-javascript/-/engine-javascript-3.22.0.tgz",- "integrity": "sha512-jdKhfgW9CRtj3Tor0L7+yPwdG3CgP7W+ZEqSsojrMzCjD1e0IxIbwUMDDpYlVBlC08TACg4puwFGkZfLS+56Tw==",- "license": "MIT",- "dependencies": {- "@shikijs/types": "3.22.0",- "@shikijs/vscode-textmate": "^10.0.2",- "oniguruma-to-es": "^4.3.4"- }- },- "node_modules/@shikijs/engine-oniguruma": {- "version": "3.22.0",- "resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-3.22.0.tgz",- "integrity": "sha512-DyXsOG0vGtNtl7ygvabHd7Mt5EY8gCNqR9Y7Lpbbd/PbJvgWrqaKzH1JW6H6qFkuUa8aCxoiYVv8/YfFljiQxA==",- "license": "MIT",- "dependencies": {- "@shikijs/types": "3.22.0",- "@shikijs/vscode-textmate": "^10.0.2"- }- },- "node_modules/@shikijs/langs": {- "version": "3.22.0",- "resolved": "https://registry.npmjs.org/@shikijs/langs/-/langs-3.22.0.tgz",- "integrity": "sha512-x/42TfhWmp6H00T6uwVrdTJGKgNdFbrEdhaDwSR5fd5zhQ1Q46bHq9EO61SCEWJR0HY7z2HNDMaBZp8JRmKiIA==",- "license": "MIT",- "dependencies": {- "@shikijs/types": "3.22.0"- }- },- "node_modules/@shikijs/themes": {- "version": "3.22.0",- "resolved": "https://registry.npmjs.org/@shikijs/themes/-/themes-3.22.0.tgz",- "integrity": "sha512-o+tlOKqsr6FE4+mYJG08tfCFDS+3CG20HbldXeVoyP+cYSUxDhrFf3GPjE60U55iOkkjbpY2uC3It/eeja35/g==",- "license": "MIT",- "dependencies": {- "@shikijs/types": "3.22.0"- }- },- "node_modules/@shikijs/types": {- "version": "3.22.0",- "resolved": "https://registry.npmjs.org/@shikijs/types/-/types-3.22.0.tgz",- "integrity": "sha512-491iAekgKDBFE67z70Ok5a8KBMsQ2IJwOWw3us/7ffQkIBCyOQfm/aNwVMBUriP02QshIfgHCBSIYAl3u2eWjg==",- "license": "MIT",- "dependencies": {- "@shikijs/vscode-textmate": "^10.0.2",- "@types/hast": "^3.0.4"- }- },- "node_modules/@shikijs/vscode-textmate": {- "version": "10.0.2",- "resolved": "https://registry.npmjs.org/@shikijs/vscode-textmate/-/vscode-textmate-10.0.2.tgz",- "integrity": "sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg==",- "license": "MIT"- },"node_modules/@types/babel__core": {"version": "7.20.5","resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz",@@ -1582,26 +1419,6 @@"vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0"}},- "node_modules/anser": {- "version": "1.4.10",- "resolved": "https://registry.npmjs.org/anser/-/anser-1.4.10.tgz",- "integrity": "sha512-hCv9AqTQ8ycjpSd3upOJd7vFwW1JaoYQ7tpham03GJ1ca8/65rqn0RpaWpItOAd6ylW9wAw6luXYPJIyPFVOww==",- "license": "MIT"- },- "node_modules/ansi-to-react": {- "version": "6.1.6",- "resolved": "https://registry.npmjs.org/ansi-to-react/-/ansi-to-react-6.1.6.tgz",- "integrity": "sha512-+HWn72GKydtupxX9TORBedqOMsJRiKTqaLUKW8txSBZw9iBpzPKLI8KOu4WzwD4R7hSv1zEspobY6LwlWvwZ6Q==",- "license": "BSD-3-Clause",- "dependencies": {- "anser": "^1.4.1",- "escape-carriage": "^1.3.0"- },- "peerDependencies": {- "react": "^16.3.2 || ^17.0.0",- "react-dom": "^16.3.2 || ^17.0.0"- }- },"node_modules/any-promise": {"version": "1.3.0","resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz",@@ -2047,12 +1864,6 @@"node": ">=6"}},- "node_modules/escape-carriage": {- "version": "1.3.1",- "resolved": "https://registry.npmjs.org/escape-carriage/-/escape-carriage-1.3.1.tgz",- "integrity": "sha512-GwBr6yViW3ttx1kb7/Oh+gKQ1/TrhYwxKqVmg5gS+BK+Qe2KrOa/Vh7w3HPBvgGf0LfcDGoY9I6NHKoA5Hozhw==",- "license": "MIT"- },"node_modules/escape-string-regexp": {"version": "5.0.0","resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz",@@ -2240,29 +2051,6 @@"url": "https://opencollective.com/unified"}},- "node_modules/hast-util-to-html": {- "version": "9.0.5",- "resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-9.0.5.tgz",- "integrity": "sha512-OguPdidb+fbHQSU4Q4ZiLKnzWo8Wwsf5bZfbvu7//a9oTYoqD/fWpe96NuHkoS9h0ccGOTe0C4NGXdtS0iObOw==",- "license": "MIT",- "dependencies": {- "@types/hast": "^3.0.0",- "@types/unist": "^3.0.0",- "ccount": "^2.0.0",- "comma-separated-tokens": "^2.0.0",- "hast-util-whitespace": "^3.0.0",- "html-void-elements": "^3.0.0",- "mdast-util-to-hast": "^13.0.0",- "property-information": "^7.0.0",- "space-separated-tokens": "^2.0.0",- "stringify-entities": "^4.0.0",- "zwitch": "^2.0.4"- },- "funding": {- "type": "opencollective",- "url": "https://opencollective.com/unified"- }- },"node_modules/hast-util-to-jsx-runtime": {"version": "2.3.6","resolved": "https://registry.npmjs.org/hast-util-to-jsx-runtime/-/hast-util-to-jsx-runtime-2.3.6.tgz",@@ -2393,16 +2181,6 @@"url": "https://opencollective.com/unified"}},- "node_modules/html-void-elements": {- "version": "3.0.0",- "resolved": "https://registry.npmjs.org/html-void-elements/-/html-void-elements-3.0.0.tgz",- "integrity": "sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg==",- "license": "MIT",- "funding": {- "type": "github",- "url": "https://github.com/sponsors/wooorm"- }- },"node_modules/inline-style-parser": {"version": "0.2.7","resolved": "https://registry.npmjs.org/inline-style-parser/-/inline-style-parser-0.2.7.tgz",@@ -2635,15 +2413,6 @@"yallist": "^3.0.2"}},- "node_modules/lucide-react": {- "version": "0.563.0",- "resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-0.563.0.tgz",- "integrity": "sha512-8dXPB2GI4dI8jV4MgUDGBeLdGk8ekfqVZ0BdLcrRzocGgG75ltNEmWS+gE7uokKF/0oSUuczNDT+g9hFJ23FkA==",- "license": "ISC",- "peerDependencies": {- "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0"- }- },"node_modules/markdown-table": {"version": "3.0.4","resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-3.0.4.tgz",@@ -3585,23 +3354,6 @@"node": ">= 6"}},- "node_modules/oniguruma-parser": {- "version": "0.12.1",- "resolved": "https://registry.npmjs.org/oniguruma-parser/-/oniguruma-parser-0.12.1.tgz",- "integrity": "sha512-8Unqkvk1RYc6yq2WBYRj4hdnsAxVze8i7iPfQr8e4uSP3tRv0rpZcbGUDvxfQQcdwHt/e9PrMvGCsa8OqG9X3w==",- "license": "MIT"- },- "node_modules/oniguruma-to-es": {- "version": "4.3.4",- "resolved": "https://registry.npmjs.org/oniguruma-to-es/-/oniguruma-to-es-4.3.4.tgz",- "integrity": "sha512-3VhUGN3w2eYxnTzHn+ikMI+fp/96KoRSVK9/kMTcFqj1NRDh2IhQCKvYxDnWePKRXY/AqH+Fuiyb7VHSzBjHfA==",- "license": "MIT",- "dependencies": {- "oniguruma-parser": "^0.12.1",- "regex": "^6.0.1",- "regex-recursion": "^6.0.2"- }- },"node_modules/parse-entities": {"version": "4.0.2","resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-4.0.2.tgz",@@ -4095,30 +3847,6 @@"node": ">=6"}},- "node_modules/regex": {- "version": "6.1.0",- "resolved": "https://registry.npmjs.org/regex/-/regex-6.1.0.tgz",- "integrity": "sha512-6VwtthbV4o/7+OaAF9I5L5V3llLEsoPyq9P1JVXkedTP33c7MfCG0/5NOPcSJn0TzXcG9YUrR0gQSWioew3LDg==",- "license": "MIT",- "dependencies": {- "regex-utilities": "^2.3.0"- }- },- "node_modules/regex-recursion": {- "version": "6.0.2",- "resolved": "https://registry.npmjs.org/regex-recursion/-/regex-recursion-6.0.2.tgz",- "integrity": "sha512-0YCaSCq2VRIebiaUviZNs0cBz1kg5kVS2UKUfNIx8YVs1cN3AV7NTctO5FOKBA+UT2BPJIWZauYHPqJODG50cg==",- "license": "MIT",- "dependencies": {- "regex-utilities": "^2.3.0"- }- },- "node_modules/regex-utilities": {- "version": "2.3.0",- "resolved": "https://registry.npmjs.org/regex-utilities/-/regex-utilities-2.3.0.tgz",- "integrity": "sha512-8VhliFJAWRaUiVvREIiW2NXXTmHs4vMNnSzuJVhscgmGav3g9VDxLrQndI3dZZVVdp0ZO/5v0xmX516/7M9cng==",- "license": "MIT"- },"node_modules/remark-gfm": {"version": "4.0.1","resolved": "https://registry.npmjs.org/remark-gfm/-/remark-gfm-4.0.1.tgz",@@ -4185,12 +3913,6 @@"url": "https://opencollective.com/unified"}},- "node_modules/reselect": {- "version": "5.1.1",- "resolved": "https://registry.npmjs.org/reselect/-/reselect-5.1.1.tgz",- "integrity": "sha512-K/BG6eIky/SBpzfHZv/dd+9JBFiS4SWV7FIujVyJRux6e45+73RaUHXLmIR1f7WOMaQ0U1km6qwklRQxpJJY0w==",- "license": "MIT"- },"node_modules/resolve": {"version": "1.22.11","resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.11.tgz",@@ -4311,22 +4033,6 @@"semver": "bin/semver.js"}},- "node_modules/shiki": {- "version": "3.22.0",- "resolved": "https://registry.npmjs.org/shiki/-/shiki-3.22.0.tgz",- "integrity": "sha512-LBnhsoYEe0Eou4e1VgJACes+O6S6QC0w71fCSp5Oya79inkwkm15gQ1UF6VtQ8j/taMDh79hAB49WUk8ALQW3g==",- "license": "MIT",- "dependencies": {- "@shikijs/core": "3.22.0",- "@shikijs/engine-javascript": "3.22.0",- "@shikijs/engine-oniguruma": "3.22.0",- "@shikijs/langs": "3.22.0",- "@shikijs/themes": "3.22.0",- "@shikijs/types": "3.22.0",- "@shikijs/vscode-textmate": "^10.0.2",- "@types/hast": "^3.0.4"- }- },"node_modules/source-map-js": {"version": "1.2.1","resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",@@ -4415,12 +4121,6 @@"url": "https://github.com/sponsors/ljharb"}},- "node_modules/tabbable": {- "version": "6.4.0",- "resolved": "https://registry.npmjs.org/tabbable/-/tabbable-6.4.0.tgz",- "integrity": "sha512-05PUHKSNE8ou2dwIxTngl4EzcnsCDZGJ/iCLtDflR/SHB/ny14rXc+qU5P4mG9JkusiV7EivzY9Mhm55AzAvCg==",- "license": "MIT"- },"node_modules/tailwind-merge": {"version": "3.4.0","resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-3.4.0.tgz",@@ -4712,15 +4412,6 @@"browserslist": ">= 4.21.0"}},- "node_modules/use-sync-external-store": {- "version": "1.6.0",- "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.6.0.tgz",- "integrity": "sha512-Pp6GSwGP/NrPIrxVFAIkOQeyw8lFenOHijQWkUTrDvrF4ALqylP2C/KCkeS9dpUM3KvYRQhna5vt7IL95+ZQ9w==",- "license": "MIT",- "peerDependencies": {- "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"- }- },"node_modules/util-deprecate": {"version": "1.0.2","resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",diff --git a/chrome-extension/package.json b/chrome-extension/package.jsonindex 67440b3..652a412 100644--- a/chrome-extension/package.json+++ b/chrome-extension/package.json@@ -10,16 +10,12 @@"preview": "vite preview"},"dependencies": {- "@base-ui/react": "^1.0.0",- "ansi-to-react": "^6.1.6","clsx": "^2.1.1",- "lucide-react": "^0.563.0","react": "^18.3.1","react-dom": "^18.3.1","react-markdown": "^9.1.0","react-syntax-highlighter": "^15.6.6","remark-gfm": "^4.0.1",- "shiki": "^3.22.0","tailwind-merge": "^3.4.0"},"devDependencies": {diff --git a/chrome-extension/src/background/service-worker.ts b/chrome-extension/src/background/service-worker.tsindex 806bd21..fa1e3df 100644--- a/chrome-extension/src/background/service-worker.ts+++ b/chrome-extension/src/background/service-worker.ts@@ -9,6 +9,7 @@ import {saveSettings,getCurrentSession,clearCapturedRequests,+ getCapturedRequests,addCapturedRequest,getAllSessions,getSession,@@ -19,7 +20,8 @@ import {getAppMode,setAppMode,getSaveLocation,- updateSessionDualSavePaths+ updateSessionDualSavePaths,+ updateSessionMessages} from '../shared/storage'import type { Session, AppMode } from '../shared/types'@@ -127,6 +129,21 @@ async function handleMessage(message: { type: string;[key: string]: unknown }):return startCodegen()case 'stopCodegen':return stopCodegen()+ case 'saveMessages':+ if (activeSessionId) {+ await updateSessionMessages(activeSessionId, message.messages as import('../shared/types').ChatMessage[])+ }+ return { success: true }+ case 'clearTraffic':+ return clearTraffic()+ case 'getCapturedRequests': {+ // Prefer in-memory entries from capture manager, fall back to storage+ const entries = captureManager.getEntries()+ if (entries.length > 0) return entries+ return getCapturedRequests(activeSessionId || undefined)+ }+ case 'getTabInfo':+ return getTabInfo()// Codegen state for content scriptcase 'getCodegenState':return { codegenActive, codegenTabId }@@ -139,7 +156,19 @@ async function getState(): Promise<Record<string, unknown>> {const session = await getCurrentSession()const sessions = await getAllSessions()const settings = await getSettings()- const stats = captureManager.getStats()+ const liveStats = captureManager.getStats()++ // Use live stats when capturing, otherwise use session's stored request count+ const stats = captureManager.isCapturing()+ ? liveStats+ : { total: session?.requestCount || 0, xhr: 0, fetch: 0, websocket: 0, other: 0 }++ // Get current tab info for restricted URL detection+ let currentTabUrl = ''+ try {+ const [tab] = await chrome.tabs.query({ active: true, currentWindow: true })+ currentTabUrl = tab?.url || ''+ } catch { /* ignore */ }return {capturing: captureManager.isCapturing(),@@ -152,7 +181,8 @@ async function getState(): Promise<Record<string, unknown>> {activeSessionId,mode: currentMode,codegenActive,- codegenScript+ codegenScript,+ currentTabUrl}}@@ -448,6 +478,41 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {return false})+async function clearTraffic(): Promise<{ success: boolean }> {+ if (captureManager.isCapturing()) {+ throw new Error('Cannot clear traffic while capturing. Stop capture first.')+ }+ // Clear in-memory entries+ captureManager.clear()+ // Clear stored requests for active session+ if (activeSessionId) {+ await clearCapturedRequests(activeSessionId)+ const session = await getSession(activeSessionId)+ if (session) {+ session.requestCount = 0+ await saveSession(session)+ }+ }+ broadcastMessage({ type: 'trafficCleared' })+ return { success: true }+}++async function getTabInfo(): Promise<{ url: string; isRestricted: boolean }> {+ const [tab] = await chrome.tabs.query({ active: true, currentWindow: true })+ const url = tab?.url || ''+ const restrictedProtocols = ['chrome:', 'chrome-extension:', 'edge:', 'about:', 'data:', 'file:', 'view-source:']+ let isRestricted = !url+ if (url) {+ try {+ const urlObj = new URL(url)+ isRestricted = restrictedProtocols.includes(urlObj.protocol)+ } catch {+ isRestricted = true+ }+ }+ return { url, isRestricted }+}+async function startCapture(tabId?: number): Promise<{ success: boolean; runId: string; tabId: number }> {if (captureManager.isCapturing()) {throw new Error('Already capturing')@@ -463,11 +528,16 @@ async function startCapture(tabId?: number): Promise<{ success: boolean; runId:if (!activeSessionId) {const { session } = await createSession()activeSessionId = session.id+ currentRunId = session.runId+ }++ // Only generate a new run ID if the session doesn't have one yet+ if (!currentRunId) {+ currentRunId = generateRunId()}- currentRunId = generateRunId()const settings = await getSettings()- await clearCapturedRequests(activeSessionId || undefined)+ // Don't clear captured requests — append to existing data on resumeawait captureManager.start(tabId, { captureTypes: settings.captureTypes })@@ -476,8 +546,7 @@ async function startCapture(tabId?: number): Promise<{ success: boolean; runId:if (session) {session.runId = currentRunIdsession.tabId = tabId- session.startTime = new Date().toISOString()- session.requestCount = 0+ if (!session.startTime) session.startTime = new Date().toISOString()session.isActive = trueawait saveSession(session)}diff --git a/chrome-extension/src/components/agent-action.tsx b/chrome-extension/src/components/agent-action.tsxindex 9a2a186..6e2043d 100644--- a/chrome-extension/src/components/agent-action.tsx+++ b/chrome-extension/src/components/agent-action.tsx@@ -34,7 +34,16 @@ export function AgentAction({ event, previousEvent }: AgentActionProps) {/>)}- // Don't show tool result output for other tools+ // Show output for other tools if present+ if (event.output) {+ return (+ <ToolResultAction+ toolName={event.tool_name || 'Tool'}+ output={event.output}+ isError={event.is_error}+ />+ )+ }return nullcase 'text':return <MarkdownRenderer content={event.content || ''} className="text-white/95" />@@ -68,7 +77,7 @@ function ToolUseAction({ toolName, toolInput }: { toolName: string; toolInput?:}return (- <div className="text-[11px] text-text-secondary/70">+ <div className="text-[11px] text-text-secondary/70 break-all"><span className="text-primary/80">→</span> <span className="font-medium">{toolName}</span><span className="text-text-secondary/50 ml-2">{getToolDisplay()}</span></div>@@ -102,6 +111,18 @@ function ErrorAction({ message }: { message: string }) {)}+function ToolResultAction({ output, isError }: { toolName: string; output: string; isError?: boolean }) {+ return (+ <div className="my-1">+ <pre className={`text-[11px] leading-relaxed font-mono whitespace-pre-wrap break-all max-h-40 overflow-y-auto custom-scrollbar px-2 py-1.5 rounded-md ${+ isError ? 'text-red-400/80 bg-red-500/5' : 'text-text-secondary/60 bg-white/[0.02]'+ }`}>+ {output}+ </pre>+ </div>+ )+}+function TodoWriteAction({ toolInput }: { toolInput?: Record<string, unknown> }) {const todos = (toolInput?.todos as Array<{ content: string; status: string; activeForm?: string }> | undefined) || []diff --git a/chrome-extension/src/components/icons.tsx b/chrome-extension/src/components/icons.tsxindex 1bde8c6..68d7ce2 100644--- a/chrome-extension/src/components/icons.tsx+++ b/chrome-extension/src/components/icons.tsx@@ -1,8 +1,58 @@-import { Copy, Download, Check, FileCode, Play, Square } from 'lucide-react'--export const Copy01Icon = Copy-export const Download01Icon = Download-export const Tick02Icon = Check-export const HugeiconsIcon = FileCode-export const PlayIcon = Play-export const StopIcon = Square+interface IconProps {+ className?: string+ size?: number+}++export function Copy01Icon({ className, size = 24 }: IconProps) {+ return (+ <svg className={className} width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">+ <rect width="14" height="14" x="8" y="8" rx="2" ry="2" />+ <path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />+ </svg>+ )+}++export function Download01Icon({ className, size = 24 }: IconProps) {+ return (+ <svg className={className} width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">+ <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />+ <polyline points="7 10 12 15 17 10" />+ <line x1="12" y1="15" x2="12" y2="3" />+ </svg>+ )+}++export function Tick02Icon({ className, size = 24 }: IconProps) {+ return (+ <svg className={className} width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">+ <polyline points="20 6 9 17 4 12" />+ </svg>+ )+}++export function HugeiconsIcon({ className, size = 24 }: IconProps) {+ return (+ <svg className={className} width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">+ <path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z" />+ <polyline points="14 2 14 8 20 8" />+ <path d="m10 13-2 2 2 2" />+ <path d="m14 17 2-2-2-2" />+ </svg>+ )+}++export function PlayIcon({ className }: IconProps) {+ return (+ <svg className={className} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">+ <polygon points="5 3 19 12 5 21 5 3" />+ </svg>+ )+}++export function StopIcon({ className }: IconProps) {+ return (+ <svg className={className} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round">+ <rect width="14" height="14" x="5" y="5" rx="1" />+ </svg>+ )+}diff --git a/chrome-extension/src/components/markdown-renderer.tsx b/chrome-extension/src/components/markdown-renderer.tsxindex 41b794d..ecaf39a 100644--- a/chrome-extension/src/components/markdown-renderer.tsx+++ b/chrome-extension/src/components/markdown-renderer.tsx@@ -1,8 +1,19 @@import React from 'react'import ReactMarkdown from 'react-markdown'import remarkGfm from 'remark-gfm'-import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'+import { PrismLight as SyntaxHighlighter } from 'react-syntax-highlighter'import { vscDarkPlus } from 'react-syntax-highlighter/dist/esm/styles/prism'+import python from 'react-syntax-highlighter/dist/esm/languages/prism/python'+import bash from 'react-syntax-highlighter/dist/esm/languages/prism/bash'+import json from 'react-syntax-highlighter/dist/esm/languages/prism/json'+import javascript from 'react-syntax-highlighter/dist/esm/languages/prism/javascript'+import typescript from 'react-syntax-highlighter/dist/esm/languages/prism/typescript'++SyntaxHighlighter.registerLanguage('python', python)+SyntaxHighlighter.registerLanguage('bash', bash)+SyntaxHighlighter.registerLanguage('json', json)+SyntaxHighlighter.registerLanguage('javascript', javascript)+SyntaxHighlighter.registerLanguage('typescript', typescript)interface MarkdownRendererProps {content: string@@ -11,7 +22,7 @@ interface MarkdownRendererProps {export function MarkdownRenderer({ content, className = '' }: MarkdownRendererProps) {return (- <div className={`text-[14px] text-white/90 leading-relaxed space-y-4 prose prose-invert prose-sm max-w-none ${className}`}>+ <div className={`text-[14px] text-white/90 leading-relaxed space-y-4 prose prose-invert prose-sm max-w-none overflow-hidden break-words ${className}`}><ReactMarkdownremarkPlugins={[remarkGfm]}components={{@@ -29,11 +40,14 @@ export function MarkdownRenderer({ content, className = '' }: MarkdownRendererPrstyle={vscDarkPlus}language={language}PreTag="div"+ wrapLongLinesclassName="!bg-transparent !p-4 !m-0"customStyle={{margin: 0,padding: 0,background: 'transparent',+ overflowX: 'hidden',+ wordBreak: 'break-all',}}{...props}>diff --git a/chrome-extension/src/components/session-selector.tsx b/chrome-extension/src/components/session-selector.tsxindex 1f5962b..72bb3f0 100644--- a/chrome-extension/src/components/session-selector.tsx+++ b/chrome-extension/src/components/session-selector.tsx@@ -1,5 +1,4 @@import { useState, useRef, useEffect } from 'react'-import { Button } from '@base-ui/react/button'import type { Session } from '../shared/types'interface SessionSelectorProps {@@ -99,7 +98,7 @@ export function SessionSelector({return (<div className="relative" ref={dropdownRef}>- <Button+ <buttononClick={() => setIsOpen(!isOpen)}className="flex items-center gap-2 px-3 py-1.5 text-[16px] leading-relaxed font-normal text-text-primary hover:text-white bg-muted hover:bg-muted/80 rounded-lg transition-all">@@ -108,7 +107,7 @@ export function SessionSelector({{activeSession?.name || 'No Session'}</span><ChevronIcon isOpen={isOpen} />- </Button>+ </button>{isOpen && (<div className="absolute top-full left-0 mt-1 w-72 bg-background-secondary rounded-xl shadow-2xl border border-border z-[100] overflow-hidden">@@ -116,12 +115,12 @@ export function SessionSelector({<div className="px-3 py-2 bg-muted"><div className="flex items-center justify-between"><span className="text-[14px] leading-relaxed font-normal text-white/50 uppercase tracking-wider">Sessions</span>- <Button+ <buttononClick={handleCreateSession}className="text-[14px] leading-relaxed text-primary hover:text-primary/80 font-normal transition-colors">+ New- </Button>+ </button></div></div>@@ -186,7 +185,7 @@ export function SessionSelector({{/* Actions */}<div className="flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity">- <Button+ <buttononClick={(e) => {e.stopPropagation()startEditing(session)@@ -195,9 +194,9 @@ export function SessionSelector({title="Rename"><EditIcon />- </Button>+ </button>{session.id !== activeSessionId && !isCapturing && (- <Button+ <buttononClick={(e) => {e.stopPropagation()onDeleteSession(session.id)@@ -206,7 +205,7 @@ export function SessionSelector({title="Delete"><TrashIcon />- </Button>+ </button>)}</div></>diff --git a/chrome-extension/src/components/terminal.tsx b/chrome-extension/src/components/terminal.tsxindex 11ec032..cf8b136 100644--- a/chrome-extension/src/components/terminal.tsx+++ b/chrome-extension/src/components/terminal.tsx@@ -1,5 +1,3 @@-import AnsiToReact from 'ansi-to-react'-interface TerminalProps {command: stringstdout?: string@@ -30,27 +28,23 @@ export function Terminal({<span className="text-white/90">{command}</span></div></div>-+{(stdout || stderr) && (<div className="p-4 font-mono text-[12px] leading-relaxed">{stdout && (- <div className="text-white/90 whitespace-pre-wrap break-words">- <AnsiToReact>{stdout}</AnsiToReact>- </div>+ <pre className="text-white/90 whitespace-pre-wrap break-words">{stdout}</pre>)}{stderr && (- <div className="text-primary/90 mt-2 whitespace-pre-wrap break-words">- <AnsiToReact>{stderr}</AnsiToReact>- </div>+ <pre className="text-primary/90 mt-2 whitespace-pre-wrap break-words">{stderr}</pre>)}</div>)}-+<div className={`px-4 py-2 border-t border-border/30 flex items-center gap-3 text-[10px] ${isSuccess ? 'text-green-500/80' : 'text-primary/80'}`}><span className="font-semibold">- {isSuccess ? '✓' : '✗'} Exit {exitCode}+ {isSuccess ? '\u2713' : '\u2717'} Exit {exitCode}</span>{durationMs !== undefined && (<span className="text-text-secondary/60">diff --git a/chrome-extension/src/components/ui/code-block.tsx b/chrome-extension/src/components/ui/code-block.tsxindex 1551b24..b6f24cd 100644--- a/chrome-extension/src/components/ui/code-block.tsx+++ b/chrome-extension/src/components/ui/code-block.tsx@@ -1,8 +1,19 @@import { type FC, useState } from "react";-import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';+import { PrismLight as SyntaxHighlighter } from 'react-syntax-highlighter';import { vscDarkPlus } from 'react-syntax-highlighter/dist/esm/styles/prism';+import python from 'react-syntax-highlighter/dist/esm/languages/prism/python';+import bash from 'react-syntax-highlighter/dist/esm/languages/prism/bash';+import json from 'react-syntax-highlighter/dist/esm/languages/prism/json';+import javascript from 'react-syntax-highlighter/dist/esm/languages/prism/javascript';+import typescript from 'react-syntax-highlighter/dist/esm/languages/prism/typescript';++SyntaxHighlighter.registerLanguage('python', python);+SyntaxHighlighter.registerLanguage('bash', bash);+SyntaxHighlighter.registerLanguage('json', json);+SyntaxHighlighter.registerLanguage('javascript', javascript);+SyntaxHighlighter.registerLanguage('typescript', typescript);import {Copy01Icon,Download01Icon,@@ -240,12 +251,15 @@ export const CodeBlock: FC<CodeBlockProps> = ({language={mappedLang}style={vscDarkPlus}showLineNumbers={showLineNumbers}+ wrapLongLinescustomStyle={{margin: 0,padding: '1rem',background: 'transparent',fontSize: '14px',lineHeight: '1.5',+ overflowX: 'hidden',+ wordBreak: 'break-all',}}codeTagProps={{style: {diff --git a/chrome-extension/src/shared/capture.ts b/chrome-extension/src/shared/capture.tsindex cd49b4d..7bf65cc 100644--- a/chrome-extension/src/shared/capture.ts+++ b/chrome-extension/src/shared/capture.ts@@ -117,8 +117,8 @@ class HarCaptureManager {this.tabId = tabIdthis.settings = { ...this.settings, ...settings }this.requests.clear()- this.entries = []- this.startTime = new Date()+ // Keep existing entries so resumed captures append to previous data+ if (!this.startTime) this.startTime = new Date()await chrome.debugger.attach({ tabId }, '1.3')await chrome.debugger.sendCommand({ tabId }, 'Network.enable', {@@ -394,6 +394,10 @@ class HarCaptureManager {}}+ getEntries(): RequestSummary[] {+ return [...this.entries, ...this.requests.values()].map(e => this.summarizeRequest(e))+ }+addListener(callback: CaptureEventCallback): void {this.listeners.add(callback)}@@ -423,6 +427,12 @@ class HarCaptureManager {}}+ clear(): void {+ this.requests.clear()+ this.entries = []+ this.startTime = null+ }+isCapturing(): boolean {return this.capturing}diff --git a/chrome-extension/src/shared/types.ts b/chrome-extension/src/shared/types.tsindex 64056b4..cae034b 100644--- a/chrome-extension/src/shared/types.ts+++ b/chrome-extension/src/shared/types.ts@@ -85,6 +85,10 @@ export type MessageType =| { type: 'setMode'; mode: AppMode }| { type: 'startCodegen' }| { type: 'stopCodegen' }+ | { type: 'clearTraffic' }+ | { type: 'getCapturedRequests' }+ | { type: 'getTabInfo' }+ | { type: 'saveMessages'; messages: ChatMessage[] }export interface CaptureEvent {type: 'complete' | 'failed' | 'started'diff --git a/chrome-extension/src/sidepanel/side-panel.tsx b/chrome-extension/src/sidepanel/side-panel.tsxindex bdf8af4..c303866 100644--- a/chrome-extension/src/sidepanel/side-panel.tsx+++ b/chrome-extension/src/sidepanel/side-panel.tsx@@ -1,6 +1,4 @@import { useState, useEffect, useRef, useCallback } from 'react'-import { Button } from '@base-ui/react/button'-import { Tooltip } from '@base-ui/react/tooltip'import { AgentAction } from '../components/agent-action'import { ChatInput } from '../components/chat-input'import { SessionSelector } from '../components/session-selector'@@ -14,12 +12,25 @@ interface ChatMessage {role: 'user' | 'assistant'content?: stringevents?: AgentEvent[]+ timestamp?: string}interface ExtendedAppState extends AppState {sessions?: Session[]codegenActive?: booleancodegenScript?: string+ currentTabUrl?: string+}++interface CapturedRequest {+ id: string+ method: string+ url: string+ status?: number+ statusText?: string+ type: string+ time: number+ size: number}const DEFAULT_STATE: ExtendedAppState = {@@ -51,16 +62,31 @@ export function SidePanel() {const [codegenSavedPath, setCodegenSavedPath] = useState<string | null>(null)const [codegenVisiblePath, setCodegenVisiblePath] = useState<string | null>(null)const [codegenVisibleDirectory, setCodegenVisibleDirectory] = useState<string | null>(null)- const [showSettings, setShowSettings] = useState(false)+ const [showTrafficList, setShowTrafficList] = useState(false)+ const [capturedRequests, setCapturedRequests] = useState<CapturedRequest[]>([])+ const [isRestrictedPage, setIsRestrictedPage] = useState(false)const messagesEndRef = useRef<HTMLDivElement>(null)const currentResponseIdRef = useRef<string | null>(null)const warningTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null)+ const showTrafficListRef = useRef(false)+ showTrafficListRef.current = showTrafficListconst scrollToBottom = useCallback(() => {messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' })}, [])+ const checkRestrictedUrl = useCallback((url: string) => {+ if (!url) { setIsRestrictedPage(true); return }+ const restrictedProtocols = ['chrome:', 'chrome-extension:', 'edge:', 'about:', 'data:', 'file:', 'view-source:']+ try {+ const urlObj = new URL(url)+ setIsRestrictedPage(restrictedProtocols.includes(urlObj.protocol))+ } catch {+ setIsRestrictedPage(true)+ }+ }, [])+// Initialize: load state and settingsuseEffect(() => {const init = async () => {@@ -71,6 +97,7 @@ export function SidePanel() {])if (stateRes) {setState(prev => ({ ...prev, ...stateRes }))+ if (stateRes.currentTabUrl) checkRestrictedUrl(stateRes.currentTabUrl)// Load active session's data including messages and codegen infoconst sessions = stateRes.sessions as Session[] | undefined@@ -88,7 +115,28 @@ export function SidePanel() {}}init()- }, [])+ }, [checkRestrictedUrl])++ // Listen for tab changes to detect restricted pages+ useEffect(() => {+ const handleTabActivated = () => {+ chrome.runtime.sendMessage({ type: 'getTabInfo' }).then(res => {+ if (res) checkRestrictedUrl(res.url)+ }).catch(() => {})+ }+ const handleTabUpdated = (_tabId: number, changeInfo: chrome.tabs.TabChangeInfo) => {+ if (changeInfo.url || changeInfo.status === 'complete') {+ handleTabActivated()+ }+ }++ chrome.tabs.onActivated.addListener(handleTabActivated)+ chrome.tabs.onUpdated.addListener(handleTabUpdated)+ return () => {+ chrome.tabs.onActivated.removeListener(handleTabActivated)+ chrome.tabs.onUpdated.removeListener(handleTabUpdated)+ }+ }, [checkRestrictedUrl])// Cleanup warning timeout on unmountuseEffect(() => {@@ -106,6 +154,12 @@ export function SidePanel() {chrome.runtime.sendMessage({ type: 'getState' }).then(res => {if (res) setState(prev => ({ ...prev, ...res }))})+ // Refresh request list if it's open+ if (showTrafficListRef.current) {+ chrome.runtime.sendMessage({ type: 'getCapturedRequests' }).then(res => {+ if (Array.isArray(res)) setCapturedRequests(res as CapturedRequest[])+ }).catch(() => {})+ }breakcase 'agentEvent':handleAgentEvent(message.event as AgentEvent)@@ -137,6 +191,13 @@ export function SidePanel() {}})break+ case 'trafficCleared':+ chrome.runtime.sendMessage({ type: 'getState' }).then(res => {+ if (res) setState(prev => ({ ...prev, ...res }))+ })+ setCapturedRequests([])+ setShowTrafficList(false)+ breakcase 'modeChanged':if (message.mode) {setState(prev => ({ ...prev, mode: message.mode! }))@@ -211,10 +272,15 @@ export function SidePanel() {})})- // Handle done/error events+ // Handle done/error events — persist messages when response completesif (event.event_type === 'done' || event.event_type === 'error') {currentResponseIdRef.current = nullsetState(prev => ({ ...prev, isStreaming: false, current_task: null }))+ // Read latest messages and persist+ setMessages(prev => {+ chrome.runtime.sendMessage({ type: 'saveMessages', messages: prev }).catch(() => {})+ return prev+ })}}, [])@@ -223,15 +289,46 @@ export function SidePanel() {if (state.capturing) {await chrome.runtime.sendMessage({ type: 'stopCapture' })} else {+ if (isRestrictedPage) {+ showWarning('Navigate to a website first (http:// or https://)')+ return+ }await chrome.runtime.sendMessage({ type: 'startCapture' })}const res = await chrome.runtime.sendMessage({ type: 'getState' })if (res) setState(prev => ({ ...prev, ...res }))} catch (err) {console.error('Capture error:', err)+ showWarning((err as Error).message || 'Failed to start capture')}}+ const handleClearTraffic = async () => {+ try {+ await chrome.runtime.sendMessage({ type: 'clearTraffic' })+ const res = await chrome.runtime.sendMessage({ type: 'getState' })+ if (res) setState(prev => ({ ...prev, ...res }))+ setCapturedRequests([])+ setShowTrafficList(false)+ } catch (err) {+ showWarning((err as Error).message || 'Failed to clear traffic')+ }+ }++ const loadCapturedRequests = async () => {+ try {+ const res = await chrome.runtime.sendMessage({ type: 'getCapturedRequests' })+ if (Array.isArray(res)) setCapturedRequests(res as CapturedRequest[])+ } catch (err) {+ console.error('Failed to load requests:', err)+ }+ }++ const toggleTrafficList = () => {+ if (!showTrafficList) loadCapturedRequests()+ setShowTrafficList(prev => !prev)+ }+const checkNativeHost = async () => {try {const res = await chrome.runtime.sendMessage({ type: 'checkNativeHost' })@@ -249,6 +346,10 @@ export function SidePanel() {}, 3000)}+ const persistMessages = useCallback((msgs: ChatMessage[]) => {+ chrome.runtime.sendMessage({ type: 'saveMessages', messages: msgs }).catch(() => {})+ }, [])+const sendMessage = async (message: string) => {if (!message.trim()) return@@ -267,7 +368,8 @@ export function SidePanel() {return}- // Clear current task when starting new query+ // Reset response tracking for the new query+ currentResponseIdRef.current = nullsetState(prev => ({ ...prev, current_task: null }))// Add user message@@ -275,8 +377,13 @@ export function SidePanel() {id: `user-${Date.now()}`,role: 'user',content: message,+ timestamp: new Date().toISOString(),}- setMessages(prev => [...prev, userMsg])+ setMessages(prev => {+ const updated = [...prev, userMsg]+ persistMessages(updated)+ return updated+ })setInputValue('')setWarningMessage(null)setState(prev => ({ ...prev, isStreaming: true }))@@ -425,71 +532,35 @@ export function SidePanel() {</div><div className="flex items-center gap-2 flex-shrink-0">- {/* Icon-based Trigger Button */}- <Tooltip.Root>- <Tooltip.Trigger- render={- <Button- onClick={state.mode === 'capture' ? toggleCapture : toggleCodegen}- className={`p-1.5 rounded-lg cursor-pointer transition-all duration-200 ${isActive- ? state.mode === 'capture'- ? 'text-capture bg-capture/10 hover:bg-capture/20'- : 'text-codegen bg-codegen/10 hover:bg-codegen/20'- : 'text-white/60 hover:text-white hover:bg-white/10'- }`}- aria-label={- state.mode === 'capture'- ? state.capturing ? 'Stop capture' : 'Start capture'- : state.codegenActive ? 'Stop recording' : 'Start recording'- }- >- {isActive ? (- <StopIcon className="w-4 h-4" />- ) : (- <PlayIcon className="w-4 h-4" />- )}- </Button>- }- />- <Tooltip.Portal>- <Tooltip.Positioner sideOffset={4}>- <Tooltip.Popup className="bg-background-elevated text-white text-caption px-2 py-1 rounded-lg z-[100] font-mono">- {state.mode === 'capture'- ? state.capturing- ? `Stop recording (${state.stats.total} requests)`- : 'Start recording traffic'- : state.codegenActive- ? 'Stop code generation'- : 'Start generating code'}- </Tooltip.Popup>- </Tooltip.Positioner>- </Tooltip.Portal>- </Tooltip.Root>-- {/* Settings Button */}- <Tooltip.Root>- <Tooltip.Trigger- render={- <Button- onClick={() => setShowSettings(true)}- className="p-1.5 rounded-lg cursor-pointer transition-all duration-200 text-white/60 hover:text-white hover:bg-white/10"- aria-label="Open settings"- >- <svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" strokeWidth={2}>- <path strokeLinecap="round" strokeLinejoin="round" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" />- <path strokeLinecap="round" strokeLinejoin="round" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />- </svg>- </Button>- }- />- <Tooltip.Portal>- <Tooltip.Positioner sideOffset={4}>- <Tooltip.Popup className="bg-background-elevated text-white text-caption px-2 py-1 rounded-lg z-[100] font-mono">- Settings- </Tooltip.Popup>- </Tooltip.Positioner>- </Tooltip.Portal>- </Tooltip.Root>+ <button+ onClick={state.mode === 'capture' ? toggleCapture : toggleCodegen}+ className={`p-1.5 rounded-lg cursor-pointer transition-all duration-200 ${isActive+ ? state.mode === 'capture'+ ? 'text-capture bg-capture/10 hover:bg-capture/20'+ : 'text-codegen bg-codegen/10 hover:bg-codegen/20'+ : 'text-white/60 hover:text-white hover:bg-white/10'+ }`}+ title={+ state.mode === 'capture'+ ? state.capturing+ ? `Stop recording (${state.stats.total} requests)`+ : 'Start recording traffic'+ : state.codegenActive+ ? 'Stop code generation'+ : 'Start generating code'+ }+ aria-label={+ state.mode === 'capture'+ ? state.capturing ? 'Stop capture' : 'Start capture'+ : state.codegenActive ? 'Stop recording' : 'Start recording'+ }+ >+ {isActive ? (+ <StopIcon className="w-4 h-4" />+ ) : (+ <PlayIcon className="w-4 h-4" />+ )}+ </button></div></header>@@ -506,23 +577,93 @@ export function SidePanel() {reverse-api-engineer install-host</code></p>- <Button+ <buttononClick={checkNativeHost}className="mt-2 text-caption text-white hover:text-capture transition-colors font-bold underline cursor-pointer"aria-label="Retry connection to native host">{'>'} Retry connection- </Button>+ </button>+ </div>+ </div>+ </div>+ )}++ {/* Restricted page warning */}+ {isRestrictedPage && !state.capturing && state.mode === 'capture' && (+ <div className="mx-4 mt-4 p-3 bg-capture/5 rounded-xl border border-capture/10">+ <div className="flex items-start gap-3">+ <WarningIcon />+ <div className="flex-1 min-w-0">+ <p className="text-small font-bold text-capture uppercase tracking-tight">Cannot record here</p>+ <p className="text-caption text-text-secondary mt-1 leading-relaxed">+ Navigate to a website (http:// or https://) to start recording.+ </p></div></div></div>)}- {/* Traffic Count indicator (when capturing) */}+ {/* Traffic panel */}{state.mode === 'capture' && state.stats.total > 0 && (- <div className="px-4 pt-4 pb-0 flex justify-end">- <div className="text-tiny text-text-secondary px-2 py-0.5 rounded-full bg-muted border border-border">- Traffic captured: <span className="text-white font-bold">{state.stats.total}</span>+ <div className="mx-4 mt-4">+ <div className="rounded-xl border border-border bg-muted/50 overflow-hidden">+ {/* Traffic header row */}+ <div className="flex items-center justify-between px-3 py-2">+ <button+ onClick={toggleTrafficList}+ className="flex items-center gap-2 text-tiny text-text-secondary hover:text-white transition-colors cursor-pointer"+ >+ <svg+ className={`w-3 h-3 transition-transform duration-200 ${showTrafficList ? 'rotate-90' : ''}`}+ fill="none" stroke="currentColor" viewBox="0 0 24 24" strokeWidth={2}+ >+ <path strokeLinecap="round" strokeLinejoin="round" d="M9 5l7 7-7 7" />+ </svg>+ Traffic captured: <span className="text-white font-bold">{state.stats.total}</span>+ </button>+ <button+ onClick={handleClearTraffic}+ disabled={state.capturing}+ className="text-tiny text-text-secondary hover:text-capture transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed px-1.5 py-0.5 rounded hover:bg-capture/10"+ title={state.capturing ? 'Stop capture before clearing' : 'Clear captured traffic'}+ >+ <svg className="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24" strokeWidth={2}>+ <path strokeLinecap="round" strokeLinejoin="round" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />+ </svg>+ </button>+ </div>++ {/* Expandable request list */}+ {showTrafficList && (+ <div className="border-t border-border max-h-60 overflow-y-auto custom-scrollbar">+ {capturedRequests.length === 0 ? (+ <div className="px-3 py-4 text-center text-tiny text-text-secondary">+ No requests recorded yet+ </div>+ ) : (+ capturedRequests.map((req, idx) => {+ let urlPath = req.url+ try { urlPath = new URL(req.url).pathname + new URL(req.url).search } catch { /* use full url */ }+ const statusColor = !req.status ? 'text-text-secondary'+ : req.status < 300 ? 'text-green-400'+ : req.status < 400 ? 'text-amber-400'+ : 'text-red-400'+ return (+ <div+ key={req.id || idx}+ className="flex items-center gap-2 px-3 py-1.5 text-tiny border-t border-border/50 first:border-t-0 hover:bg-white/5"+ >+ <span className="font-bold text-primary w-10 flex-shrink-0 text-right">{req.method}</span>+ <span className={`w-8 flex-shrink-0 text-right ${statusColor}`}>{req.status || '-'}</span>+ <span className="text-text-secondary truncate flex-1 font-mono" title={req.url}>{urlPath}</span>+ <span className="text-text-secondary/50 flex-shrink-0 w-10 text-right">{req.type?.toLowerCase()}</span>+ </div>+ )+ })+ )}+ </div>+ )}</div></div>)}@@ -597,7 +738,7 @@ export function SidePanel() {) : (/* Capture Mode - Show chat area */<>- <div className="flex-1 overflow-y-auto px-6 pb-4 pt-6 custom-scrollbar">+ <div className="flex-1 overflow-y-auto overflow-x-hidden px-6 pb-4 pt-6 custom-scrollbar">{messages.length === 0 ? (<div className="flex flex-col items-center justify-center h-full"><div className="w-24 h-24 text-white/10">@@ -680,89 +821,6 @@ export function SidePanel() {</>)}- {/* Settings Modal */}- {showSettings && (- <div className="absolute inset-0 bg-black/50 backdrop-blur-sm z-50 flex items-center justify-center">- <div className="bg-background border border-border rounded-xl p-6 w-80 max-w-[90vw] shadow-2xl">- <div className="flex items-center justify-between mb-4">- <h2 className="text-lg font-semibold text-white">Settings</h2>- <button- onClick={() => setShowSettings(false)}- className="text-white/60 hover:text-white p-1"- >- <svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />- </svg>- </button>- </div>-- {/* Save Location Setting */}- <div className="space-y-3">- <label className="text-sm text-white/80 block">Save Location</label>-- <div className="space-y-2">- <label className="flex items-center gap-2 cursor-pointer">- <input- type="radio"- name="saveLocation"- checked={settings.saveLocation === 'downloads'}- onChange={() => {- const newSettings = { ...settings, saveLocation: 'downloads' as const }- setSettings(newSettings)- chrome.runtime.sendMessage({ type: 'saveSettings', settings: newSettings })- }}- className="w-4 h-4 accent-primary"- />- <span className="text-sm text-white/70">Downloads folder (default)</span>- </label>-- <label className="flex items-center gap-2 cursor-pointer">- <input- type="radio"- name="saveLocation"- checked={settings.saveLocation !== 'downloads'}- onChange={() => {- if (settings.saveLocation === 'downloads') {- const newSettings = { ...settings, saveLocation: '/Users/' }- setSettings(newSettings)- chrome.runtime.sendMessage({ type: 'saveSettings', settings: newSettings })- }- }}- className="w-4 h-4 accent-primary"- />- <span className="text-sm text-white/70">Custom folder</span>- </label>- </div>-- {settings.saveLocation !== 'downloads' && (- <div className="mt-2 p-2 bg-background-elevated rounded-lg">- <div className="text-xs text-white/50 mb-1">Custom path:</div>- <input- type="text"- value={settings.saveLocation}- onChange={(e) => {- const newSettings = { ...settings, saveLocation: e.target.value }- setSettings(newSettings)- chrome.runtime.sendMessage({ type: 'saveSettings', settings: newSettings })- }}- className="w-full text-xs text-white/80 font-mono bg-background border border-white/10 rounded px-2 py-1 focus:outline-none focus:border-primary"- placeholder="/Users/..."- />- </div>- )}- </div>-- <div className="mt-6 pt-4 border-t border-border">- <button- onClick={() => setShowSettings(false)}- className="w-full py-2 bg-primary/20 hover:bg-primary/30 text-primary rounded-lg text-sm font-medium transition-colors"- >- Done- </button>- </div>- </div>- </div>- )}</div>)}diff --git a/src/reverse_api/native_host.py b/src/reverse_api/native_host.pyindex 1a2554b..d9c4c27 100644--- a/src/reverse_api/native_host.py+++ b/src/reverse_api/native_host.py@@ -147,6 +147,63 @@ def _check_python_version(python_path: str, min_version: tuple[int, int]) -> booreturn False+def _preflight_claude_cli() -> str | None:+ """+ Run a preflight check on the Claude CLI to trigger any macOS Gatekeeper+ prompts in the terminal (where the user can approve them).++ When Claude Code is later launched as a subprocess by Chrome's native+ messaging host, Gatekeeper blocks unsigned .node addons silently.+ Running it once from the terminal lets the user approve it interactively.++ Returns:+ Warning message if Claude CLI had issues, None if OK.+ """+ import subprocess++ try:+ claude_path = shutil.which("claude")+ if not claude_path:+ return (+ "Warning: 'claude' CLI not found in PATH.\n"+ "Install it with: npm install -g @anthropic-ai/claude-code\n"+ "Then run: claude --version\n"+ "This is needed to approve any macOS security prompts."+ )++ result = subprocess.run(+ [claude_path, "--version"],+ capture_output=True,+ text=True,+ timeout=30,+ )+ if result.returncode != 0:+ return (+ "Warning: 'claude --version' failed. Please run it manually:\n"+ f" {claude_path} --version\n"+ "This ensures macOS security prompts are handled before the extension uses it."+ )++ # On macOS, also clear quarantine on the claude installation+ if platform.system() == "Darwin":+ claude_dir = str(Path(claude_path).resolve().parent.parent)+ subprocess.run(+ ["xattr", "-rd", "com.apple.quarantine", claude_dir],+ capture_output=True,+ timeout=30,+ )++ return None+ except subprocess.TimeoutExpired:+ return (+ "Warning: 'claude --version' timed out. If you see a macOS security popup,\n"+ "approve it in System Settings > Privacy & Security, then run:\n"+ " claude --version"+ )+ except Exception as e:+ return f"Warning: Could not verify Claude CLI: {e}"++def install_native_host(extension_id: str | None = None) -> tuple[bool, str]:"""Install the native messaging host.@@ -219,7 +276,14 @@ run_host()if platform.system() == "Windows":_install_windows_registry(manifest_path)- return True, f"Native host installed successfully.\nManifest: {manifest_path}\nHost script: {host_script}\nPython interpreter: {python_path}"+ # Preflight Claude CLI to trigger Gatekeeper prompts in the terminal+ cli_warning = _preflight_claude_cli()++ result_msg = f"Native host installed successfully.\nManifest: {manifest_path}\nHost script: {host_script}\nPython interpreter: {python_path}"+ if cli_warning:+ result_msg += f"\n\n{cli_warning}"++ return True, result_msgexcept Exception as e:return False, f"Failed to install native host: {e}"@@ -742,7 +806,7 @@ The HAR content is available at the path above. Use the Read tool to analyze it.{"type": "agent_event","event_type": "thinking",- "content": block.thinking[:500] + "..." if len(block.thinking) > 500 else block.thinking,+ "content": block.thinking[:2000] + "..." if len(block.thinking) > 2000 else block.thinking,})elif isinstance(block, ToolUseBlock):@@ -761,7 +825,7 @@ The HAR content is available at the path above. Use the Read tool to analyze it.is_error = block.is_error if block.is_error else Falseoutput = ""if hasattr(block, "content"):- output = str(block.content)[:500] if block.content else ""+ output = str(block.content)[:2000] if block.content else ""send_message({@@ -769,7 +833,7 @@ The HAR content is available at the path above. Use the Read tool to analyze it."event_type": "tool_result","tool_name": last_tool_name or "Tool","is_error": is_error,- "output": output + "..." if len(output) >= 500 else output,+ "output": output + "..." if len(output) >= 2000 else output,})