Skip to content

fix(doctor): surface cached extension version when disconnected to detect version mismatch#1914

Open
hyyu189 wants to merge 1 commit into
jackwener:mainfrom
hyyu189:fix/doctor-cached-extension-version
Open

fix(doctor): surface cached extension version when disconnected to detect version mismatch#1914
hyyu189 wants to merge 1 commit into
jackwener:mainfrom
hyyu189:fix/doctor-cached-extension-version

Conversation

@hyyu189

@hyyu189 hyyu189 commented Jun 11, 2026

Copy link
Copy Markdown

Problem

When the Chrome Web Store auto-upgrades the extension but the npm CLI stays pinned at an older version, the bridge silently breaks. opencli doctor shows only "extension not connected" with no indication of a version mismatch — the user (and automated agents) have no way to diagnose the root cause.

Repro

  1. Chrome Web Store auto-updates extension to v1.0.19
  2. npm CLI stays at v1.8.0
  3. opencli doctorExtension: not connected (silent)
  4. All COOKIE / INTERCEPT / UI adapters fail with extension not connected

The existing compat-range check (lines 168-185 in doctor.ts) correctly detects protocol mismatches when the extension IS connected, but it never runs when the extension is disconnected.

Fix

Two minimal changes:

  1. update-check.ts: Export getCachedExtensionVersion() to read currentExtensionVersion from the daemon's shared cache. The daemon already writes this on every successful WebSocket handshake via recordExtensionVersion() — we just weren't reading it in the doctor path.

  2. doctor.ts: When the extension is disconnected (daemonRunning && !extensionConnected), check the cached extension version. If found, append a version-mismatch hint to the issues list, suggesting npm install -g + restart Chrome.

Example output (before → after)

Before:

[OK] Daemon: running on port 19825
[MISSING] Extension: not connected
Issues:
  • Daemon is running but the Chrome/Chromium extension is not connected.

After:

[OK] Daemon: running on port 19825
[MISSING] Extension: not connected
Issues:
  • Daemon is running but the Chrome/Chromium extension is not connected.
  • Extension was previously connected at v1.0.19 but is now unreachable.
    CLI is v1.8.0. This may indicate a version mismatch from Chrome Web Store auto-upgrade.
    Try: npm install -g @jackwener/opencli && opencli daemon restart
    Then restart Chrome to reload the extension service worker.

Testing

All existing tests pass:

  • src/doctor.test.ts — 17/17
  • Full npm test --project unit — 1175 passed, 1 skipped

When the Chrome Web Store auto-upgrades the extension but npm CLI
stays pinned at an older version, the bridge silently breaks.
`opencli doctor` shows only "extension not connected" with no
indication of version mismatch.

Changes:
- update-check.ts: export getCachedExtensionVersion() to read
  the last-seen extension version from the daemon hello cache
- doctor.ts: when the extension is disconnected, check the cached
  version and report a version-mismatch hint with a suggested fix
  (npm install -g + restart Chrome)

The daemon already records currentExtensionVersion on every
successful WebSocket handshake; this change just exposes that
information in the doctor report when the extension goes missing.
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