-
Notifications
You must be signed in to change notification settings - Fork 297
feat(extension): improve recording fidelity and iframe gating #104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Diveyam-Mishra
wants to merge
4
commits into
browser-use:main
Choose a base branch
from
Diveyam-Mishra:split-extension
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
09a6007
feat(extension): improve recording fidelity and iframe gating
Diveyam-Mishra 55c8768
chore(extension): address review feedback
Diveyam-Mishra 70673c3
Removing instructions.md
Diveyam-Mishra 809f752
feat(extension): restore semantic metadata support
Diveyam-Mishra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # Copilot Instructions for workflow-use | ||
|
|
||
| These project-specific instructions help AI coding agents work productively in this repo. Keep responses concise, implement with tools when possible, and follow the repo’s patterns. | ||
|
|
||
| ## Architecture (big picture) | ||
| - Monorepo with three main parts: | ||
| - `extension/` (WXT MV3 Chrome extension): records user actions via rrweb + custom DOM events and streams to a local server. | ||
| - `workflows/` (Python package + CLI + FastAPI backend): converts recorded events into deterministic workflow steps, runs/replays steps (fallback to Browser Use/Playwright). | ||
| - `ui/` (Vite/React frontend): GUI to view and run workflows. | ||
| - Data flow: | ||
| 1) Content scripts capture events → background aggregates → posts `WORKFLOW_UPDATE` to `http://127.0.0.1:7331/event`. | ||
| 2) Backend stores/processes to `workflows/examples/*.json` and executes with Playwright. | ||
| 3) UI/CLI visualize/run. | ||
| - Key types: `extension/src/lib/types.ts` (Stored* events), `extension/src/lib/workflow-types.ts` (Step union), `workflows` Python `Workflow` model. | ||
|
|
||
| ## Dev workflows | ||
| - Build extension: `cd extension && npm install && npm run build`. | ||
| - Python backend setup: `cd workflows && uv sync && playwright install chromium && cp .env.example .env`. | ||
| - Record: `cd workflows && python cli.py create-workflow` (starts local server; open Chrome with built extension). | ||
| - Run workflow as tool: `python cli.py run-as-tool examples/example.workflow.json --prompt "..."`. | ||
| - Run workflow: `python cli.py run-workflow examples/example.workflow.json`. | ||
| - Launch GUI: `python cli.py launch-gui` (starts FastAPI + UI dev server). | ||
|
|
||
| ## Extension patterns | ||
| - Use `defineBackground` and `defineContentScript` (WXT). Content script always attaches listeners; background aggregates and emits `WORKFLOW_UPDATE` with a hash to avoid spam. | ||
| - Recording: | ||
| - rrweb for scroll/meta; custom `CUSTOM_CLICK_EVENT`, `CUSTOM_INPUT_EVENT`, `CUSTOM_KEY_EVENT`, etc. | ||
| - New-tab intent: content sends `PREPARE_NEW_TAB`; background correlates `tabs.onCreated` and marks `userInitiated`. | ||
| - Activated tab gating: ignore tabs never activated (reduces ad/tracker noise). | ||
| - Dedupe: merge consecutive identical steps, collapse rapid empty input bursts, consolidate navigations per tab. | ||
| - Iframes: content runs with `allFrames: true` and `matchAboutBlank: true`; events carry `frameUrl` and `frameIdPath`. Background only allows rrweb meta navigations from frames the user interacted with and filters ad/analytics hosts. | ||
|
|
||
| ## Backend patterns | ||
| - Python FastAPI endpoint `http://127.0.0.1:7331/event` receives: | ||
| - `RECORDING_STARTED/STOPPED`, `WORKFLOW_UPDATE` with `steps` only (hash-based dedupe). | ||
| - CLI: `workflows/cli.py` provides record/run/launch commands; Playwright is used for replay. | ||
| - Keep workflow JSON in `workflows/examples/`. Naming is free-form; version stays at `1.0.0` today. | ||
|
|
||
| ## Conventions | ||
| - Step schema (extension `workflow-types.ts`): navigation, click, input, key_press, scroll. Prefer merging updates over emitting new steps. | ||
| - Use XPath + enhanced CSS selectors; keep values masked for password inputs. | ||
| - Avoid sending events from tabs not in `activatedTabs` unless `userInitiated`. | ||
| - When adding new event types, extend Stored* in `types.ts`, enrich in content, and map to `Step` in background. | ||
|
|
||
| ## Gotchas / Tips | ||
| - Avoid noisy iframe navs (recaptcha/ads): rely on `interactedFrameUrls` filtering in background. If adjusting, prefer allow/deny logic over hard-coding hosts in multiple places. | ||
| - When changing extension logic, rebuild with `npm run build`; dev opens side panel on install/update. | ||
| - Screenshot capture only works for visible tabs; background uses `captureVisibleTab` best-effort. | ||
| - If tests are added, ensure they run per package (`extension`, `workflows`, `ui`) rather than at repo root. | ||
|
|
||
| ## Example tasks for agents | ||
| - Add a new step type (e.g., select): | ||
| 1) Extend `StoredCustomSelectEvent` in `types.ts` and emit in `content.ts`. | ||
| 2) Map to a `SelectStep` in `background.ts` (convertStoredEventsToSteps). | ||
| 3) Update backend replay to handle the new step. | ||
| - Reduce noise further: | ||
| - Tune debounce windows in content. | ||
| - Post-process duplicates in `broadcastWorkflowDataUpdate`. | ||
| - Add frame interaction checks before accepting rrweb meta navigations. | ||
|
|
||
| ## Security & secrets | ||
| - Do not commit real API keys. `.env.example` exists; load secrets locally. If you see a real key in `workflows/.env`, instruct maintainers to rotate and remove it. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove this file