Originally created by: kristofferR
Part of the assessment epic [#59] (Ref [#45], Ref [#46]).
Carrier's page features (badge, notifications, blur, shortcuts) rest on Facebook's unstable DOM, and failures went into empty catch {} blocks — a Messenger markup change would silently kill a feature. This PR gives breakage a paper trail:
Injected script (messenger.js)
diag(key, msg): rate-limited (1/key/min) reporter that emits carrier:diag to the Rust side; mirrors to the console when localStorage.__carrier_debug = "1". Reports carry only Carrier's own strings — never page content.[role="main"]) are checked 45 s after load and every 5 min, only on a logged-in /messages page. Two consecutive dry checks → a diag report + a one-time toast ("A Messenger update may have broken part of Carrier — check for updates").carrier:notify emit, badge set/emit) now report through diag().Rust (lib.rs)
tauri-plugin-log gets explicit targets (stdout + log dir) with dependencies capped at Warn; Carrier's own Info lines pass.carrier:diag listener: payload is remote-origin input, so it's sanitized (control chars stripped, 160-char cap — unit-tested) and capped at 200 reports/session.eprintln! sites converted to log::warn!/log::error! so release builds capture them.Settings → Advanced: "Open log folder" button (open_log_folder command — callable because the settings window is a local origin).
Full migration of all ~71 selector call sites to a central registry is deliberately deferred to the messenger.js toolchain/refactor work (#48) to keep this diff small next to the open PRs.
Verified: cargo fmt / clippy -D warnings / 47 lib tests pass (3 new for sanitize_diag), node --check clean.
https://claude.ai/code/session_01Pqw8xaJrGLhgSo2YR68ov5
Added Settings → Advanced → Open log folder to quickly access Carrier logs.
Bug Fixes
Improved handling for notification, badge, and URL-opening failures so they no longer get swallowed.
Tests
Originally posted by: kristofferR
@coderabbitai review
Originally posted by: coderabbitai[bot]
✅ Action performed
Review finished. > 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.Originally posted by: coderabbitai[bot]
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
**Configuration used**: Path: .coderabbit.yaml **Review profile**: ASSERTIVE **Plan**: Pro **Run ID**: `5c6455fa-f482-42a9-b2ae-b7354c6cd522`📥 Commits
Reviewing files that changed from the base of the PR and between [071b66] and bbcd9875a8c1b0f2a63788bad441b0e881c3f4cd.📒 Files selected for processing (1)
* `src-tauri/src/lib.rs`📝 Walkthrough
## Walkthrough Adds structured logging, a page diagnostics channel with sanitization and rate limits, a log-folder command, settings UI wiring for opening logs, and README documentation for the diagnostics log feature. ### Changes **Diagnostics logging feature** |Layer / File(s)|Summary| |---|---| |**Backend log setup and failure reporting**`src-tauri/Cargo.toml`, `src-tauri/src/lib.rs`|Adds `log = "0.4"`, configures Tauri log output, and replaces stderr printing with structured logging in cache clearing, DNS preflight, settings persistence, and cache-clear scheduling paths.| |**Diagnostics channel and log folder command**
`src-tauri/src/lib.rs`|Defines diagnostics payload parsing and sanitization, adds the `carrier:diag` listener with per-session rate limiting, registers `open_log_folder`, and adds unit tests for payload validation and sanitization.| |**Injected diagnostics helper and call sites**
`src-tauri/inject/messenger.js`|Adds `diag()`, selector-health checks, and replaces silent catches in URL opening, notification, and unread-badge paths with diagnostic reporting.| |**Settings action and feature docs**
`dist/settings.html`, `README.md`|Adds the Advanced-tab log-folder row and documents the diagnostics log feature.| **Estimated code review effort:** 3 (Moderate) | ~25 minutes ### Sequence Diagram(s) :::mermaid sequenceDiagram participant MessengerJS as messenger.js participant EventBus as carrier:diag participant Backend as carrier:diag listener participant Sanitizer as sanitize_diag participant Log as log::warn! MessengerJS->>EventBus: emit diagnostics payload EventBus->>Backend: deliver carrier:diag event Backend->>Backend: enforce per-session cap Backend->>Sanitizer: sanitize key and msg Sanitizer-->>Backend: sanitized diagnostic Backend->>Log: write warning :::mermaid sequenceDiagram participant User participant SettingsUI as settings.html participant TauriCmd as open_log_folder participant OS as log directory User->>SettingsUI: click Open log folder SettingsUI->>TauriCmd: invoke open_log_folder TauriCmd->>OS: open log directory OS-->>SettingsUI: success or error SettingsUI-->>User: show status message **Possibly related PRs** - [[kristofferR/Carrier#2](https://github.com/kristofferR/Carrier/issues/2)](https://github.com/kristofferR/Carrier/pull/2): Introduces the unread badge/tray sync via `carrier:unread`, which this PR wraps with new `diag()` error logging. - [[kristofferR/Carrier#11](https://github.com/kristofferR/Carrier/issues/11)](https://github.com/kristofferR/Carrier/pull/11): Touches the same `set_badge_count`/`carrier:unread` badge flow in `messenger.js` that this PR wraps with `diag()` calls. - [[kristofferR/Carrier#13](https://github.com/kristofferR/Carrier/issues/13)](https://github.com/kristofferR/Carrier/pull/13): Established the `carrier:notify` notification bridge that this PR updates to use `diag()` logging instead of silent catches.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation | | :------------------------: | :------- | :------------------------------------------------------------------------------------------------------------------------------- | | Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. | | Title check | ✅ Passed | The title clearly matches the PR’s main goal: making Messenger page-feature breakage observable through diagnostics and logging. | | Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. | | Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |✨ Finishing Touches
📝 Generate docstrings
- [ ] Create stacked PR - [ ] Commit on current branch🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests - [ ] Commit unit tests in branch `feature/diagnostics-observability`⚔️ Resolve merge conflicts
- [ ] Resolve merge conflict in branch `feature/diagnostics-observability`Comment
@coderabbitai helpto get the list of available commands.Originally posted by: kristofferR
@coderabbitai review
Originally posted by: coderabbitai[bot]
✅ Action performed
Review finished. > 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.Ticket changed by: kristofferR