Skip to content

feat: replace tabId with targetId as cross-layer page identity#899

Open
jackwener wants to merge 4 commits intomainfrom
feat/page-identity-targetid
Open

feat: replace tabId with targetId as cross-layer page identity#899
jackwener wants to merge 4 commits intomainfrom
feat/page-identity-targetid

Conversation

@jackwener
Copy link
Copy Markdown
Owner

Summary

  • Use Chrome CDP targetId (UUID) as the canonical page identity across all layers (extension → daemon → CLI), demoting tabId to an extension-internal routing detail
  • Add identity.ts module for bidirectional targetId ↔ tabId mapping with lazy refresh via chrome.debugger.getTargets()
  • Add sendCommandFull() to daemon-client for returning page identity alongside response data

Changes

Layer File What changed
Extension identity.ts New module — resolveTargetId(), resolveTabId(), evictTab(), refreshMappings()
Extension protocol.ts Command.page and Result.page fields (targetId)
Extension background.ts resolveCommandTabId() + pageScopedResult() helpers; all page-scoped handlers emit targetId
CLI daemon-client.ts DaemonCommand.page, DaemonResult.page, new sendCommandFull()
CLI page.ts _page stores targetId; goto()/selectTab() extract from sendCommandFull()
CLI record.ts injectedPages tracks by targetId instead of tabId
CLI types.ts IPage.getActivePage() returns targetId
Infra vitest.config.ts Extension tests added to test projects
Infra package.json npm test includes --project extension

Design constraints

  1. workspace ≠ page — workspace is task context, page is the CDP target
  2. page only in page-scoped responses — navigate, exec, screenshot, tabs:select, etc.
  3. Missing page → hard error — never guess or fall back silently

Test plan

  • All 551 tests pass (0 failures, 2 pre-existing skips)
  • TypeScript compiles clean (no new errors)
  • Extension tests included in npm test and CI
  • Manual: opencli run navigates and returns targetId in page field
  • Manual: tab switch via selectTab() updates _page correctly

… icons

- Remove unused `scripting` permission (Chrome Web Store rejection fix)
- Bump version 1.6.7 → 1.6.8
- Redesign icons with neon gradient style (pure SVG paths, glow effect)
Use Chrome CDP targetId (UUID) as the canonical page identity across
all layers (extension → daemon → CLI), demoting tabId to an
extension-internal routing detail.

- Add extension/src/identity.ts: bidirectional targetId ↔ tabId mapping
  with lazy refresh via chrome.debugger.getTargets()
- Update protocol: Command.page and Result.page carry targetId
- Update background.ts: resolveCommandTabId() and pageScopedResult()
  helpers; all page-scoped handlers return targetId
- Add sendCommandFull() to daemon-client for responses with page identity
- Update Page class: _page stores targetId, goto/selectTab extract it
- Update record.ts: injectedPages tracks by targetId
- Add extension tests to vitest config and CI test scripts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant