CDP tab lifecycle policy

Module helpers: forge_lcdl.playwright.edge_cdp_attach (close_linkedin_cdp_tabs, list_linkedin_cdp_page_targets), forge_lcdl.playwright.connectors.lpc_linkedin_harvest (teardown_external_linkedin_cdp_tabs)

Updated

Problem

OWA LivePersonaCard See profile on LinkedIn opens a new linkedin.com/in/ tab in the operator's Edge profile. Harvest loops that only refocus the host tab (the People tab) leave every profile tab open — CDP attach slows, memory grows, and operators lose track of work tabs.

Rules

  1. Close external tabs after read — When harvest opens or polls a tab outside the host surface (LinkedIn profile, etc.), close it via CDP /json/close/{targetId} after the URL or snapshot is captured.
  2. Max one ephemeral LinkedIn profile tab per harvest step — Before clicking See profile on LinkedIn, close stale /in/ profile tabs (close_linkedin_cdp_tabs(..., profiles_only=True)). After capture, run teardown_external_linkedin_cdp_tabs (close + refocus host).
  3. Never open per-person without teardown — Batch harnesses (e.g. org-people reingest) must not accumulate one LinkedIn tab per contact.
  4. Host tabs are sacred — Do not close OWA mail, People, or Teams tabs. Cockpit default remains detach_generic_edge_cdp(..., close_owned=False) for operator sessions.
  5. Owned vs operator tabs — Close only tabs your integration opened or ephemeral third-party tabs required for a single read. Prune about:blank orphans with prune_about_blank_cdp_tabs before attach.

LinkedIn external resolve flow (LPC)

Used by Outlook People LPC LinkedIn harvest when COCKPIT_ORG_LINKEDIN_OPEN_EXTERNAL=1 or FORGE_LCDL_ORG_LINKEDIN_OPEN_EXTERNAL=1:

  1. _prepare_external_linkedin_click — close existing /in/ profile tabs.
  2. Click See profile on LinkedIn in the LPC flyout (OWA may open one new tab).
  3. _poll_linkedin_profile_url — read URL from CDP /json/list.
  4. teardown_external_linkedin_cdp_tabs — close profile tabs, refocus the People host tab.