Summary
In direct CDP mode, ref-based get commands are unreliable across normal CLI invocations.
Reproduction
Using the normal standalone CLI flow:
node dist/cli.js tab 3 --json
node dist/cli.js snapshot --json
node dist/cli.js get text 0 --json
node dist/cli.js get url --json
node dist/cli.js get title --json
Observed before fix:
- the second process often fell back to the wrong tab (
about:blank) because the selected target was only stored in-process
get text <ref> could fail with Unknown ref or return an empty string
get url / get title failed with Missing ref or attribute parameter
Root Cause
packages/cli/src/cdp-client.ts only tracked currentTargetId in memory, so a fresh CLI process lost the selected tab. On top of that:
get text tried to resolve text through a non-existent [data-bb-node-id=...] selector
get url / get title incorrectly required ref
Expected
Normal multi-invocation CLI usage should keep operating on the selected target, and get text|url|title should return the expected values without requiring a fresh snapshot or a bogus ref.
Summary
In direct CDP mode, ref-based
getcommands are unreliable across normal CLI invocations.Reproduction
Using the normal standalone CLI flow:
Observed before fix:
about:blank) because the selected target was only stored in-processget text <ref>could fail withUnknown refor return an empty stringget url/get titlefailed withMissing ref or attribute parameterRoot Cause
packages/cli/src/cdp-client.tsonly trackedcurrentTargetIdin memory, so a fresh CLI process lost the selected tab. On top of that:get texttried to resolve text through a non-existent[data-bb-node-id=...]selectorget url/get titleincorrectly requiredrefExpected
Normal multi-invocation CLI usage should keep operating on the selected target, and
get text|url|titleshould return the expected values without requiring a freshsnapshotor a bogusref.