Skip to content

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

Merged
jackwener merged 1 commit intomainfrom
feat/page-identity-targetid
Apr 9, 2026
Merged

feat: replace tabId with targetId as cross-layer page identity#899
jackwener merged 1 commit 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

@jackwener jackwener force-pushed the feat/page-identity-targetid branch from 52a2b8b to 6292b6c Compare April 9, 2026 04:20
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
@jackwener jackwener force-pushed the feat/page-identity-targetid branch from 6292b6c to e035f68 Compare April 9, 2026 04:24
@jackwener jackwener merged commit 555626f into main Apr 9, 2026
14 checks passed
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