A Manifest V3 Chrome Extension that does two things at once:
- Records user interaction flows for AI-powered test-automation generation.
- Acts as a live AI co-pilot β predicting your next UI action in real time using a deterministic scoring engine with an optional Gemini / ChatGPT fallback.
- Captures clicks, input changes, form submissions, route changes (SPA-aware), and API calls (fetch/XHR).
- Every event includes:
- Session ID, timestamp, URL, and route (pathname)
- Full element metadata: tag, ID, className, innerText, name, type, role, aria-label, data-testid
- Stable CSS selector and XPath fallback
- API details: method, endpoint, status code, duration
- Floating panel injected via Shadow DOM β zero CSS pollution.
- Shows the top-3 predicted next actions with confidence score and per-factor score breakdown (proximity, intent, form, role, direction).
- Highlights the predicted element on hover.
- "Run" button to execute the predicted action directly.
- "Fill Form" assist β detects active forms and autofills fields with smart placeholder data.
-
Deterministic-first: weighted scoring across five factors before any AI call.
Factor Weight Proximity 0.30 Intent 0.25 Form 0.25 Role 0.10 Direction 0.10 -
Hard form dominance: submit-type actions inside the active form are boosted Γ1.25; out-of-form candidates penalised Γ0.75.
-
AI fallback (Gemini or ChatGPT) kicks in only when
confidence < 0.2and the AI cooldown window has passed. -
AI results are validated by semantic similarity before overriding deterministic results.
- Flow tab: browse recorded events, view selectors and API calls, export as JSON.
- AI tab: auto-generated summary, structured LLM prompt for test generation, metrics, and suggested test points.
- Export as JSON or Markdown.
| Layer | Technology |
|---|---|
| Language | TypeScript 5 |
| UI (popup) | React 18, CSS modules |
| Build | Vite 5 (two configs: popup/background + content) |
| Extension | Manifest V3, service worker, content script |
| AI | Gemini / ChatGPT via pluggable AIProvider interface |
chrome-extension-flow-recorder/
βββ public/
β βββ manifest.json # Extension manifest (MV3)
βββ src/
β βββ background/
β β βββ background.ts # Service worker: messaging, storage, tab broadcast
β βββ config/
β β βββ aiConfig.ts # API key config from VITE_* env vars
β β βββ prompts.ts # AI prompt templates
β βββ content/
β β βββ content.ts # Main content script: recording + agent orchestration
β β βββ agentPanel.ts # Floating AI panel (Shadow DOM)
β β βββ agentManager.ts # Agent lifecycle and prediction scheduling
β β βββ autofill.ts # Form autofill assist
β β βββ chatgptBridge.ts # Bridge script for ChatGPT tab provider
β β βββ execution.ts # Execute predicted actions
β β βββ flyout.ts / flyout.css # Flyout overlay UI
β β βββ formDetect.ts # Active form detection
β β βββ prediction.ts # Prediction wiring in content context
β β βββ providers.ts # AI provider instantiation for content
β β βββ rateLimit.ts # AI call rate limiting
β β βββ state.ts # Content-script shared state
β βββ popup/
β β βββ popup.html
β β βββ main.tsx # React entry point
β β βββ App.tsx # Tabs: Control | Flow | AI
β β βββ App.css
β β βββ components/
β β β βββ RecorderControl.tsx # Start/Stop/Clear, Agent toggle
β β β βββ FlowViewer.tsx # Recorded event list and export
β β β βββ AIPanel.tsx # AI analysis, prompts, export
β β β βββ Dashboard.tsx # Summary dashboard
β β β βββ MissionBar.tsx / .css
β β βββ styles/ # Component CSS
β βββ types/
β β βββ index.ts # RecordedEvent, FlowNode/Edge, ACTION_TYPES, ElementMetadata
β β βββ ai.ts # AIProvider, CompactContext, AIPrediction
β βββ ui/
β β βββ agentPanel.ts # Panel render helpers
β βββ utils/
β βββ storage.ts # chrome.storage.local wrapper
β βββ selectorGenerator.ts # CSS selector & XPath generation
β βββ elementAnalyzer.ts # ElementMetadata, form helpers
β βββ navigationDetector.ts # SPA route-change detection
β βββ apiInterceptor.ts # Fetch/XHR interception
β βββ flowAnalyzer.ts # analyzeEventFlow, detectForms, identifyTestPoints
β βββ aiFormatter.ts # prepareFlowData, JSON/Markdown export
β βββ contextBuilder.ts # Full PageContext builder
β βββ predictionEngine.ts # generatePredictions, maybeUseAI, fillFormFields
β βββ aiProviderFactory.ts # createAIProvider(name, apiKey)
β βββ geminiProvider.ts # GeminiProvider
β βββ chatgptProvider.ts # ChatGPTProvider (OpenAI)
β βββ chatgptTabProvider.ts # ChatGPT via tab bridge
β βββ novaProvider.ts # Nova provider
β βββ batchingProvider.ts # Batching wrapper
β βββ aiQueue.ts # AI request queue
β βββ agentExecutor.ts # Agent action executor
βββ vite.config.ts # Popup + background build
βββ vite.config.content.ts # Content script build (does not clear dist)
βββ tsconfig.json
βββ package.json
βββ .env # API keys (never commit β see below)
βββ dist/ # Build output loaded by Chrome
- Node.js 18+
- npm
- Chrome, Edge, or Brave (Chromium-based)
cd chrome-extension-flow-recorder
npm installCreate a .env file in the project root. These are build-time keys injected by Vite β never commit this file.
VITE_GEMINI_API_KEY=your_gemini_api_key
VITE_OPENAI_API_KEY=your_openai_api_keyThe Gemini key is used first; ChatGPT is the fallback. If neither key is set, the extension uses deterministic predictions only.
npm run buildThis runs two Vite builds:
vite buildβ popup (popup.html,popup.js) and background service worker (background.js).vite build --config vite.config.content.tsβ content script (content.js) and ChatGPT bridge (chatgptBridge.js).
Output lands in dist/.
- Open
chrome://extensions/ - Enable Developer mode (top-right toggle)
- Click Load unpacked
- Select the
dist/folder
# Watch mode: rebuilds popup/background + content script on change
npm run dev
# Type-check
npm run check- Click the extension icon to open the popup.
- Control tab β click Start.
- Interact with any web page.
- Click Stop when done.
- Flow tab β browse events, view selectors, or Export JSON.
- AI tab β view auto-generated summary, LLM prompt, metrics, and test point suggestions.
- Copy the structured prompt to clipboard or export as Markdown for use with any LLM.
The floating panel appears automatically on every page once the extension is loaded. It:
- Displays top-3 predicted next actions with confidence and score breakdown.
- Lets you Run a prediction or Fill Form when a form is active.
- Can be toggled from the Control tab in the popup.
The background service worker brokers all communication:
| Action | Sender | Effect |
|---|---|---|
START_RECORDING |
Popup | Persists state; broadcasts to all tabs |
STOP_RECORDING |
Popup | Persists state; broadcasts to all tabs |
GET_EVENTS |
Popup | Returns stored events |
CLEAR_EVENTS |
Popup | Clears events from storage |
SAVE_SESSION |
Popup | Appends current events as a saved session |
TOGGLE_AGENT |
Popup | Enables/disables the agent panel on all tabs |
EVENT_RECORDED |
Content | Keeps service worker alive |
All stored in chrome.storage.local:
| Key | Value |
|---|---|
flowRecorder_events |
Array of RecordedEvent |
flowRecorder_sessionId |
Current session ID |
flowRecorder_isRecording |
Boolean |
flowRecorder_sessions |
Saved sessions |
flowRecorder_lastUserAction |
Last event (for agent context) |
flowRecorder_agentEnabled |
Whether the agent panel is on |
mousemove / interaction event
β
buildPageContext()
β
generatePredictions(context) β deterministic weighted scoring
β
confidence < 0.2 AND cooldown passed?
β yes
maybeUseAI(context) β Gemini / ChatGPT
β
renderAgentPanel(topThree, confidence)
- Local-only storage β no data leaves the browser unless you paste an exported prompt into an external LLM.
- API keys are embedded at build time via Vite's
import.meta.env; they exist only in the extension bundle. - The agent panel is isolated in Shadow DOM; it cannot be styled or read by the host page.
- Elements marked
[data-flow-recorder]are excluded from recording and prediction.
- Recordings are scoped to the active tab (no cross-tab recording).
- API keys are bundled into the extension β for personal/dev use only. Avoid publishing to the Chrome Web Store with live API keys.
- AI fallback requires a network connection and a valid API key.
- Move AI calls to the background service worker for better key isolation.
- Adaptive weight tuning via reinforcement learning.
- Intent drift detection.
- Runtime provider switching in the popup UI.
- Direct test file export (Cypress / Playwright).
- Multi-tab recording.
- Prediction heatmap overlay.
Built with TypeScript, React 18, Vite 5, and Chrome Manifest V3