fix(agent-browser): enable preview page domain

This commit is contained in:
2026-08-27 02:35:36 +08:00
parent afb5c10fae
commit 23c49aa3d2
3 changed files with 98 additions and 0 deletions

View File

@@ -0,0 +1,73 @@
# Task: Remediate X-01 preview CDP enable
## Identity
- Task ID: 20260827-x01-cdp-enable-4e8a2c71
- Mode: Feature
- Branch: codex/20260827-x01-cdp-enable-4e8a2c71-x01-cdp-enable-4e8a2c71
- Worktree: D:\Datas\OthersProjects\makelore-x01-cdp-enable-4e8a2c71
- Base commit: afb5c10fae090567869fcd7a10410a8be2c963ad
- Owner: codex
- Status: Ready for Integration
## Scope
- Update `electron/agent-browser/module.ts` so preview-data CDP setup enables the
same root or child session immediately before `Page.addScriptToEvaluateOnNewDocument`.
- Add focused root/child ordering and `sessionRef` regression coverage in
`tests/unit/agent-browser-core.test.ts`.
- Maintain this task record only; no coordinator worktree, PR, live run, or
broader CDP refactor.
## Intent And Constraints
- Exact remediation for X-01 packaged evidence: `Page.enable` must precede
every preview-data script installation while preserving the optional
`sessionRef`.
- Preserve the existing target URL origin fix and exact-origin getter from the
base commit; ownership is limited to the two source/test files and this record.
- The prior injection-origin task was released before this task started; the
coordinator remains at the recorded exact base and is not modified.
## Planning Gate
- Result: Passed.
- Evidence: prior task released; isolated task/worktree started from
`afb5c10fae090567869fcd7a10410a8be2c963ad`; repository project-docs startup
instructions and architecture/coordinator scope records were read; no
conflicting ownership was found.
## Plan
1. Add `Page.enable` with the same optional session reference immediately before
each preview script command.
2. Assert root ordering and child ordering/session propagation in focused tests.
3. Run focused tests, typecheck, scoped lint, documentation drift, then commit
once and leave the worktree clean.
## Outcome
- Added `Page.enable` immediately before every preview-data
`Page.addScriptToEvaluateOnNewDocument` call, passing the same optional
`sessionRef` for root and document-child sessions. Added root and child
ordering/session propagation assertions while preserving the existing
target URL and exact-origin injection behavior.
## Verification
- PASS: `corepack pnpm vitest run tests/unit/agent-browser-core.test.ts` (77/77).
- PASS: `corepack pnpm run typecheck`.
- PASS: `corepack pnpm exec eslint electron/agent-browser/module.ts tests/unit/agent-browser-core.test.ts`.
- PASS: `git diff --check`.
- PASS: project-docs drift/completion gates (recorded before commit).
- The isolated worktree required `corepack pnpm install --frozen-lockfile --offline`
before the focused command; no tracked dependency files changed.
## Follow-ups
- None. No live/E2E run was requested for this bounded remediation.
## Promotion Candidates
- Commit the single source/test/documentation change after the documentation
gate passes.