Skip to content

refactor(scanners): remove the CDP webview-account surface (1/3 for #5478) - #5482

Merged
senamakel merged 2 commits into
tinyhumansai:mainfrom
M3gA-Mind:remove/cdp-1-scanners
Aug 10, 2026
Merged

senamakel merged 2 commits into
tinyhumansai:mainfrom
M3gA-Mind:remove/cdp-1-scanners

Conversation

@M3gA-Mind

@M3gA-Mind M3gA-Mind commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • 1 of 3 for Remove the CDP layer and every surface that depends on it #5478. Removes the six CDP-driven provider scanners and the webview_accounts surface they ran inside — 17,430 lines.
  • This is dead-code removal, not a bug fix. The frontend entry points were deleted in refactor(cef): remove embedded webview accounts #5457 and never restored, so none of this was reachable by a user. See below.
  • Unregisters all 15 webview_account_* IPC commands, so the shell stops exposing commands whose implementation is gone.
  • imessage_scanner is byte-for-byte untouched and still registered — it reads chat.db natively and has zero CDP references.
  • Two deletions land here rather than in a later PR because they cannot compile without this one. Both are called out under Deviations with their evidence.

Problem

CDP (Chrome DevTools Protocol) only exists where the webview engine is Chromium. #5456 replaced CEF with upstream Tauri's Wry, so the engine is now WKWebView on macOS and WebKitGTK on Linux — neither speaks CDP. app/src-tauri/src/cdp/in_process.rs is a permanent error stub: install_for_label always returns Err, set_cef_app_handle is a no-op, and CdpRegistry's map is never written. Every scanner bottoms out there.

How it got here was a merge-ordering accident. #5457 deleted the embedded webview-account surface; #5456 branched before that commit and merged after it, and the conflict resolution b3d861d06 restored 6,659 lines — the Rust half only. The frontend half stayed deleted.

So nothing here is user-reachable. SidebarAppRail, WebviewHost and webviewAccountService are gone from app/src; Accounts.tsx is down to 95 lines with no webview references; and the scanners were reached only from webview_accounts/mod.rs. The four remaining webview_account_open call sites in lib.rs were all dev-only env-var conveniences (OPENHUMAN_DEV_AUTO_WHATSAPP, _SLACK, _TELEGRAM, _GOOGLE_MEET). This PR removes an orphaned implementation.

Solution

Deleted:

Path Lines
whatsapp / discord / slack / telegram / gmessages / wechat _scanner/ 10,191
app/src-tauri/src/webview_accounts/ 4,809
src/openhuman/channels/webview_accounts/ 511
app/src-tauri/src/cdp/{session,snapshot}.rs 1,316

Also removed: the CEF cold-start prewarm (CEF_PREWARM_LABEL, spawn_cef_prewarm, teardown_cef_prewarm, cef_prewarm_enabled + its 54 lines of tests) and the close_early_cef_webviews / pending_cef_webview_labels / wait_for_cef_webviews_to_close_async drain machinery. Its only two producers were the prewarm webview and webview_accounts::shutdown_all; with both gone it drained an always-empty list.

src/openhuman/channels/webview_accounts/ was WeChat ingest normalisation whose only producer was wechat_scanner. It already had zero other consumers — grep -rn webview_accounts src/ returned exactly one hit, its own pub mod line.

Deviations from the three-PR split, and why each is forced

1. meet_scanner is NOT in this PR (it moves to PR 2 with the rest of the Meet stack). It is inside the Meet dependency cycle, not the account-scanner group: meet_call/mod.rs:48 is use crate::meet_scanner; and calls meet_scanner::spawn(...) at :251, while meet_scanner itself references crate::meet_call. Deleting it here would break meet_call's compile. It has 0 references to webview_accounts, so it does not belong to this PR's surface either.

2. cdp/session.rs and cdp/snapshot.rs ARE in this PR, though cdp/ is otherwise PR 3's. cdp/session.rs:29 is use crate::webview_accounts::{emit_load_finished, redact_url_for_log, RevealTrigger}; — it cannot compile once webview_accounts is gone. Its own doc-comment describes it as "Per-account CDP session opener. One long-lived task per webview account", and snapshot.rs is the DOM parser only the deleted scanners called. Both have zero other consumers. They are the webview-account half of cdp/, not the transport.

What survives in cdp/, and why that matters for PR 3

Each cdp/mod.rs re-export was traced individually rather than trusting the module boundary. Consumers outside cdp/ after this PR:

  • spawn_session, SpawnedSession, placeholder_marker, placeholder_url, target_url_fragment, Snapshot, detach_session, find_page_target_where, install_for_account, conn_for_account, connect_and_attach_matching_in_process0 consumers, all removed.
  • CdpConn → 5 files, all Meet (meet_scanner, meet_video/inject, meet_audio/{caption_listener,speak_pump,inject}).
  • install_for_label, set_cef_app_handle, CdpRegistry → Meet plus lib.rs.

After this PR, cdp/'s only consumer is the Meet stack. PR 2 removes that; PR 3 can then delete cdp/ outright.

cdp/mod.rs carries a scoped #![allow(dead_code)] referencing PR 3: Meet uses a narrow slice of the transport, and pruning the rest would be churn that PR 3 deletes anyway. The module carried the same allow before #5456 removed it.

Deliberately not done here

  • i18n keys and user-facing provider copy are left in place. They split in PR 3: strings referenced only by deleted components are dead and go; strings a Show in-app web apps only to users who already have them connected #5423 removal notice could reuse stay, listed explicitly. Removing them now would pre-empt a product decision that has not been made.
  • AGENTS.md's "no new JS injection" rule is untouched — PR 3 rewrites it, since two of the three destinations it names ("CEF handlers, CDP from scanner modules, or Rust-side IPC hooks") stop existing only after PR 3.
  • app/src/lib/webviewNotifications/ is now orphaned — zero importers, and this PR deletes the Rust code that emitted its event — but removing it reaches into accountsSlice functions that still serve the live channel-accounts surface. Filed as Remove the orphaned webviewNotifications frontend module #5481 rather than bundled here.

Submission Checklist

  • Tests added or updated — deletion-only change; removed the 54 lines of cef_prewarm_enabled tests in lib_tests.rs whose subject is gone, and retargeted two common.test.ts IPC fixtures (below). No new behaviour to cover.
  • Diff coverage ≥ 80% — N/A for a diff that is 17,430 deletions and 53 insertions, none of them new logic. CI enforces the real number.
  • Coverage matrix updated — N/A: behaviour-only removal, no feature rows added/removed/renamed.
  • All affected feature IDs listed — N/A: no feature IDs.
  • No new external network dependencies introduced — deletion only.
  • Manual smoke checklist updated — N/A: nothing removed here was reachable from the shipped UI, so no smoke step changes. (PR 2 does touch a reachable surface and will say so.)
  • Linked issue closed via Closes #NNN — deliberately not closing Remove the CDP layer and every surface that depends on it #5478 here; Closes goes on PR 3, the last of the stack.

Impact

Desktop only. No runtime behaviour changes for any user: every surface removed was either unreachable from the UI or guaranteed to fail with "CDP is unavailable with the upstream Tauri WebView runtime".

The one externally-visible change is that 15 webview_account_* IPC commands are no longer registered. Any caller would previously have received a runtime error from the stub; it now gets an unknown-command error instead. There are no callers left in app/src.

No migration. No security or compatibility implications — this removes an automation path that drove logged-in web sessions, it does not add one.

Related


AI Authored PR Metadata (required for Codex/Linear PRs)

Linear Issue

  • Key: N/A
  • URL: N/A

Commit & Branch

  • Branch: remove/cdp-1-scanners
  • Commit SHA: a11bde26a68f2b1730acdeca2552cc778168b63b

Validation Run

  • pnpm --filter openhuman-app format:checknot run. node_modules is not installed in this clone and the only frontend change is a 5-string fixture swap in a test file; CI covers it.
  • pnpm typechecknot run, same reason.
  • Focused tests: no test run locally. The only frontend edit swaps the opaque command-name fixtures in app/src/utils/tauriCommands/common.test.ts from webview_account_hide / webview_account_reveal to mascot_window_hide / mascot_window_show (really registered at lib.rs:1176,1191). The invoke is mocked, so the assertions are unchanged and pass either way; the fixtures simply no longer name deleted commands.
  • Rust fmt/check (if changed): cargo fmt --all -- --check clean in both Cargo worlds. cargo check -p openhuman --tests → 0 errors. cargo check --no-default-features → 0 errors (channels-OFF, checked because the core-side deletion was #[cfg(feature = "channels")]).
  • Tauri fmt/check (if changed): cargo check --manifest-path app/src-tauri/Cargo.toml --all-targets → 0 errors. --all-targets deliberately, so lib_tests.rs compiles — a lib-only check would not have caught the removed prewarm tests.

Warnings: zero new ones. The core's warning set was diffed against a stashed baseline — empty delta. The Tauri shell emits one warning, unused import: std::fs at process_recovery.rs:14, verified pre-existing on main and left alone.

Validation Blocked

  • command: pnpm test / pnpm typecheck
  • error: not attempted — node_modules absent in this clone
  • impact: limited to the 5-string test-fixture swap described above; CI's frontend lane covers it.

Behavior Changes

  • Intended behavior change: remove an unreachable, non-functional automation surface and its IPC registrations.
  • User-visible effect: none. Every path removed was either unreachable from the shipped UI or returned "CDP is unavailable with the upstream Tauri WebView runtime".

Parity Contract

  • Legacy behavior preserved: imessage_scanner — zero-line diff, still registered (module declaration, managed state, shutdown_imessage_scanner, both teardown call sites, tick registration).
  • Guard/fallback/dispatch parity checks: grep -c "webview_account_" app/src-tauri/src/lib.rs → 0. Repo-wide code references to the deleted modules → 0.

Duplicate / Superseded PR Handling

  • Duplicate PR(s): N/A
  • Canonical PR: this PR
  • Resolution: N/A

Summary by CodeRabbit

  • Removed Features

    • Removed legacy web-based message scanning and synchronization for Discord, Google Messages, Slack, Telegram, WeChat, and WhatsApp.
    • Removed related account session handling, DOM snapshots, IndexedDB extraction, and provider-specific data ingestion.
    • Removed the legacy webview account bridge and associated WeChat ingestion support.
  • Maintenance

    • Simplified application startup and shutdown behavior.
    • Updated internal documentation and IPC-related test coverage to reflect the streamlined architecture.

1 of 3 for tinyhumansai#5478. Removes the six CDP-driven provider scanners and the
webview-account surface they ran inside. Pure dead-code removal: the
frontend entry points (SidebarAppRail, WebviewHost, webviewAccountService)
were deleted in tinyhumansai#5457 and never restored, so none of this was reachable
by a user.

Deleted:
- app/src-tauri/src/{whatsapp,discord,slack,telegram,gmessages,wechat}_scanner
- app/src-tauri/src/webview_accounts (4,809 lines)
- src/openhuman/channels/webview_accounts (WeChat ingest normalisation,
  whose only producer was wechat_scanner; already had zero other consumers)
- app/src-tauri/src/cdp/{session,snapshot}.rs — the per-account session
  opener and DOM-snapshot parser. session.rs imports webview_accounts
  directly, so it cannot compile without it; both had no other consumer.
- The CEF cold-start prewarm and the webview-close drain machinery, whose
  only producers were the prewarm webview and webview_accounts.

Unregisters all 15 webview_account_* IPC commands, so the shell no longer
exposes commands whose implementation is gone.

imessage_scanner is untouched and still registered: it reads chat.db
natively, has zero CDP references, and its only crate-internal dependency
is core_rpc.

cdp/ itself stays — after this its only consumers are the Meet stack
(meet_scanner, meet_audio, meet_video), removed in PR 2 of 3.

i18n keys and user-facing provider copy are deliberately left in place;
they are split and removed in PR 3 pending the tinyhumansai#5423 decision on whether
users with a connected web app get a removal notice.
@M3gA-Mind
M3gA-Mind requested a review from a team August 10, 2026 14:23
@M3gA-Mind

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ce338dd2-ae01-4c62-8b67-819b40ee572a

📥 Commits

Reviewing files that changed from the base of the PR and between a11bde2 and 3cad5cd.

📒 Files selected for processing (1)
  • AGENTS.md

📝 Walkthrough

Walkthrough

The change removes CDP-based provider scanners, account webview infrastructure, and related Tauri wiring. It simplifies teardown, retains label-based CDP compatibility APIs, preserves iMessage scanner shutdown, and updates documentation and IPC tests.

Changes

CDP and scanner removal

Layer / File(s) Summary
CDP API reduction
app/src-tauri/src/cdp/*
Account-based CDP sessions, snapshots, target attachment helpers, and session management are removed. Label-based transport and target APIs remain.
Provider and webview removal
app/src-tauri/src/{discord_scanner,gmessages_scanner,slack_scanner,telegram_scanner,wechat_scanner,whatsapp_scanner}/*, app/src-tauri/src/webview_accounts/*, src/openhuman/channels/webview_accounts/*
CDP scanners, scanner registries, webview runtime injection, WeChat ingest contracts, and related tests are deleted.
Application wiring and teardown
app/src-tauri/src/lib.rs, src/openhuman/channels/mod.rs
Scanner and webview registrations, CEF shutdown polling, and obsolete commands are removed. iMessage scanner shutdown is added.
Documentation and IPC tests
AGENTS.md, app/src-tauri/src/meet_audio/mod.rs, app/src/utils/tauriCommands/common.test.ts
Documentation reflects the remaining module layout. IPC tests use mascot window commands.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

Suggested labels: rust-core

Suggested reviewers: senamakel

Poem

A rabbit clears the old CDP trail,
While scanner branches fade and fail.
Webview hooks are tucked away,
iMessage keeps its watch each day.
Clean paths remain beneath the hay.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR removes the targeted scanner surfaces but leaves the Meet stack, remaining CDP transport, and other #5478 acceptance items for later PRs. Complete the remaining #5478 acceptance criteria, or link follow-up issues that explicitly own the deferred CDP, Meet, E2E, and copy cleanup.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the removal of the CDP webview-account surface and identifies its staged relationship to issue #5478.
Out of Scope Changes check ✅ Passed The changes support CDP surface removal, IPC cleanup, teardown simplification, documentation updates, and related test maintenance.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot added the rust-core Core Rust runtime in src/: CLI, core_server, shared infrastructure. label Aug 10, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/src-tauri/src/lib.rs`:
- Around line 1643-1646: Update shutdown_imessage_scanner to emit privacy-safe
[imessage] logs on entry, registry-present and registry-absent branches, the
shutdown call, and completion. Add unit tests covering both
ScannerRegistry-present and ScannerRegistry-absent paths, including the
observable shutdown behavior and log-relevant branch execution.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8f4ee4ff-6793-40ed-8625-39efdb2f00b0

📥 Commits

Reviewing files that changed from the base of the PR and between c7e15ba and a11bde2.

📒 Files selected for processing (42)
  • AGENTS.md
  • app/src-tauri/src/cdp/conn.rs
  • app/src-tauri/src/cdp/in_process.rs
  • app/src-tauri/src/cdp/mod.rs
  • app/src-tauri/src/cdp/session.rs
  • app/src-tauri/src/cdp/snapshot.rs
  • app/src-tauri/src/cdp/target.rs
  • app/src-tauri/src/discord_scanner/dom_snapshot.rs
  • app/src-tauri/src/discord_scanner/mod.rs
  • app/src-tauri/src/discord_scanner/mod_tests.rs
  • app/src-tauri/src/gmessages_scanner/cdp_walk.rs
  • app/src-tauri/src/gmessages_scanner/idb.rs
  • app/src-tauri/src/gmessages_scanner/mod.rs
  • app/src-tauri/src/lib.rs
  • app/src-tauri/src/lib_tests.rs
  • app/src-tauri/src/meet_audio/mod.rs
  • app/src-tauri/src/slack_scanner/dom_snapshot.rs
  • app/src-tauri/src/slack_scanner/extract.rs
  • app/src-tauri/src/slack_scanner/idb.rs
  • app/src-tauri/src/slack_scanner/mod.rs
  • app/src-tauri/src/telegram_scanner/dom_snapshot.rs
  • app/src-tauri/src/telegram_scanner/extract.rs
  • app/src-tauri/src/telegram_scanner/idb.rs
  • app/src-tauri/src/telegram_scanner/mod.rs
  • app/src-tauri/src/webview_accounts/mod.rs
  • app/src-tauri/src/webview_accounts/mod_tests.rs
  • app/src-tauri/src/webview_accounts/runtime.js
  • app/src-tauri/src/wechat_scanner/dom_snapshot.rs
  • app/src-tauri/src/wechat_scanner/mod.rs
  • app/src-tauri/src/whatsapp_scanner/dom_snapshot.rs
  • app/src-tauri/src/whatsapp_scanner/dom_snapshot_tests.rs
  • app/src-tauri/src/whatsapp_scanner/idb.rs
  • app/src-tauri/src/whatsapp_scanner/idb_tests.rs
  • app/src-tauri/src/whatsapp_scanner/mod.rs
  • app/src-tauri/src/whatsapp_scanner/mod_tests.rs
  • app/src-tauri/src/whatsapp_scanner/test_fixtures/dom_snapshot_2026_05.json
  • app/src/utils/tauriCommands/common.test.ts
  • src/openhuman/channels/mod.rs
  • src/openhuman/channels/webview_accounts/README.md
  • src/openhuman/channels/webview_accounts/mod.rs
  • src/openhuman/channels/webview_accounts/wechat_ingest.rs
  • src/openhuman/channels/webview_accounts/wechat_ingest_tests.rs
💤 Files with no reviewable changes (33)
  • app/src-tauri/src/slack_scanner/extract.rs
  • app/src-tauri/src/webview_accounts/mod_tests.rs
  • app/src-tauri/src/whatsapp_scanner/test_fixtures/dom_snapshot_2026_05.json
  • src/openhuman/channels/mod.rs
  • app/src-tauri/src/slack_scanner/dom_snapshot.rs
  • app/src-tauri/src/gmessages_scanner/idb.rs
  • app/src-tauri/src/telegram_scanner/mod.rs
  • app/src-tauri/src/discord_scanner/mod.rs
  • app/src-tauri/src/wechat_scanner/mod.rs
  • app/src-tauri/src/whatsapp_scanner/dom_snapshot_tests.rs
  • app/src-tauri/src/lib_tests.rs
  • src/openhuman/channels/webview_accounts/wechat_ingest_tests.rs
  • app/src-tauri/src/slack_scanner/mod.rs
  • app/src-tauri/src/discord_scanner/dom_snapshot.rs
  • app/src-tauri/src/telegram_scanner/idb.rs
  • src/openhuman/channels/webview_accounts/mod.rs
  • src/openhuman/channels/webview_accounts/wechat_ingest.rs
  • src/openhuman/channels/webview_accounts/README.md
  • app/src-tauri/src/telegram_scanner/extract.rs
  • app/src-tauri/src/wechat_scanner/dom_snapshot.rs
  • app/src-tauri/src/whatsapp_scanner/idb_tests.rs
  • app/src-tauri/src/webview_accounts/runtime.js
  • app/src-tauri/src/cdp/session.rs
  • app/src-tauri/src/whatsapp_scanner/mod.rs
  • app/src-tauri/src/slack_scanner/idb.rs
  • app/src-tauri/src/gmessages_scanner/cdp_walk.rs
  • app/src-tauri/src/whatsapp_scanner/dom_snapshot.rs
  • app/src-tauri/src/telegram_scanner/dom_snapshot.rs
  • app/src-tauri/src/whatsapp_scanner/mod_tests.rs
  • app/src-tauri/src/whatsapp_scanner/idb.rs
  • app/src-tauri/src/gmessages_scanner/mod.rs
  • app/src-tauri/src/cdp/snapshot.rs
  • app/src-tauri/src/discord_scanner/mod_tests.rs

Comment thread app/src-tauri/src/lib.rs
Comment on lines 1643 to 1646
fn shutdown_imessage_scanner<R: tauri::Runtime>(app: &AppHandle<R>) {
if let Some(registry) = app.try_state::<std::sync::Arc<imessage_scanner::ScannerRegistry>>() {
registry.inner().shutdown();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add logs and tests for iMessage scanner shutdown.

Add privacy-safe [imessage] logs for shutdown entry, the registry-present and registry-absent branches, and completion. The enclosing [app] logs cannot show whether this scanner shutdown ran.

Add unit coverage for both registry states. This teardown behavior must remain observable and tested.

As per coding guidelines, “New or changed flows must log entry/exit, branches, external calls, retries/timeouts, state transitions, and errors with stable grep-friendly prefixes” and “Untested code is incomplete; add unit tests for new or changed behavior.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/src-tauri/src/lib.rs` around lines 1643 - 1646, Update
shutdown_imessage_scanner to emit privacy-safe [imessage] logs on entry,
registry-present and registry-absent branches, the shutdown call, and
completion. Add unit tests covering both ScannerRegistry-present and
ScannerRegistry-absent paths, including the observable shutdown behavior and
log-relevant branch execution.

Source: Coding guidelines

@senamakel
senamakel merged commit 37ec62f into tinyhumansai:main Aug 10, 2026
7 of 8 checks passed
senamakel added a commit to nocstah/openhuman that referenced this pull request Sep 11, 2026
…ners\n\nrefactor(scanners): remove the CDP webview-account surface (1/3 for tinyhumansai#5478)\n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rust-core Core Rust runtime in src/: CLI, core_server, shared infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants