Skip to content

feat: expose plugin and CLI versions to catch eval version drift (#135)#136

Merged
mpiton merged 4 commits into
mainfrom
fix/135-version-introspection
Jun 10, 2026
Merged

feat: expose plugin and CLI versions to catch eval version drift (#135)#136
mpiton merged 4 commits into
mainfrom
fix/135-version-introspection

Conversation

@mpiton

@mpiton mpiton commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Root cause

Issue #135 reports native WebKit eval callback returned an error on macOS Tahoe with tauri-pilot 0.7.1. That string only ever came from the native macOS WKWebView eval path, which #127 removed in 0.7.1. So the plugin compiled into the reporter's app is <= 0.7.0 even though the CLI is 0.7.1.

The plugin and CLI are separate crates with independent versions, and nothing reported either one at runtime. That is why the same eval problem kept getting re-fixed per platform (#108, then #110/#112, then #126/#127): field reports were never tied to a plugin version.

Changes

  • plugin: ping returns plugin_version; state carries it too. The version is logged when the socket or named pipe starts listening.
  • cli: --version (was missing, asked for in Eval error native WebKit eval #135). tauri-pilot ping prints the plugin and CLI versions and warns when they drift. A ping response with no plugin_version is read as plugin <= 0.7.0, upgrade.
  • docs: plugin-setup gains a keep-in-sync section mapping the error string to an outdated plugin, with the cargo update or version-pin fix.

No change to the eval mechanism: the 0.7.1 IPC path is correct. This makes the version drift observable so it stops recurring.

Testing

  • cargo test --workspace (303 pass, 6 new)
  • cargo clippy --workspace --all-targets -- -D warnings

Addresses #135.


Summary by cubic

Expose plugin and CLI versions and add a version handshake in tauri-pilot ping to detect and warn about version drift behind the macOS eval error in #135. No eval/IPC behavior changed; run tauri-pilot ping to confirm versions match.

  • New Features

    • Plugin: ping and state include plugin_version.
    • CLI: --version added; tauri-pilot ping shows plugin and CLI versions and warns on drift (non-JSON). Test asserts exact --version output format.
    • Plugin logs its version when the socket/named pipe starts listening.
    • Docs: plugin-setup adds keep-in-sync guidance.
  • Refactors

    • Share version injection via a single inject_plugin_version helper used by ping and state.

Written for commit 49d779e. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features

    • CLI adds a --version flag.
    • Plugin exposes its version in ping and state responses.
  • Improvements

    • CLI prints a human-readable version handshake on ping (non-JSON).
    • Detects and warns when plugin and CLI versions drift.
    • Plugin logs its version on startup.
  • Documentation

    • Docs updated with verification output and guidance for keeping plugin/CLI in sync.

The macOS "native WebKit eval callback returned an error" came from a
plugin <= 0.7.0 compiled into the app while the CLI was already 0.7.1.
Nothing reported either version, so the drift was invisible and the same
eval problem kept resurfacing per platform.

- plugin: `ping` returns `plugin_version`; `state` includes it too
- plugin: log the version when the socket/named pipe starts listening
- cli: add `--version`; `ping` prints plugin+CLI versions and warns on drift
- docs: plugin-setup troubleshooting for the drift plus `cargo update`
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bf658cf4-223b-494b-8cc6-6ba412360294

📥 Commits

Reviewing files that changed from the base of the PR and between c250412 and 49d779e.

📒 Files selected for processing (1)
  • crates/tauri-pilot-cli/tests/version.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/tauri-pilot-cli/tests/version.rs

📝 Walkthrough

Walkthrough

This PR exposes the plugin's compile-time version in ping and state responses, logs the plugin version at server startup, adds a CLI --version flag, and implements CLI-side handshake reporting that compares CLI and plugin versions with tests and docs updates.

Changes

Version Reporting and Drift Detection

Layer / File(s) Summary
Plugin version exposure in RPC responses
crates/tauri-plugin-pilot/src/handler.rs
ping and state handlers inject plugin_version into JSON results; tests assert the field matches the crate version.
Server startup logging and response testing
crates/tauri-plugin-pilot/src/server/unix.rs, crates/tauri-plugin-pilot/src/server/windows.rs
Both servers log the compiled version at startup; ping tests now verify status and plugin_version.
CLI version flag support
crates/tauri-pilot-cli/src/cli.rs, crates/tauri-pilot-cli/tests/version.rs
Clap attribute formatted to expose version; integration test verifies tauri-pilot --version prints the compile-time package version.
CLI version reporting and drift detection
crates/tauri-pilot-cli/src/main.rs
Main intercepts ping output (non-JSON) and calls report_ping/diagnose_versions to compare CLI vs plugin versions and print match, drift, or absent warnings; unit tests added.
Changelog and setup guide updates
CHANGELOG.md, docs/src/content/docs/guides/plugin-setup.md
Unreleased changelog entries and setup guide updated with example outputs, drift remediation steps, and macOS troubleshooting notes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main objective: exposing plugin and CLI versions to detect version drift, with reference to issue #135.
Description check ✅ Passed The PR description comprehensively covers all required template sections: summary with clear bullet points, motivation tied to issue #135, detailed changes across plugin/CLI/docs, and testing results with cargo test and clippy validation.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

@sovri sovri Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sovri code review

✅ Approve

1 finding — 1 minor

Review assessment

Effort: ●●●●○ 4/5
Metrics: 1 finding · 1 file touched · 0 blocker plus major findings

Severity distribution:
Total: 1 finding
Bar: █

  • 🟡 minor: 1 finding

TL;DR

The pull request adds version introspection to detect and warn about version drift between the tauri-pilot plugin and CLI, addressing the root cause of recurring macOS eval errors. The changes include exposing plugin and CLI versions, logging the plugin version on startup, and documenting sync guidance. No functional changes were made to the eval mechanism itself.

Findings

Severity Location Title Details
🟡 crates/tauri-pilot-cli/src/main.rs:140 Missing JSON output for version handshake in ping The ping command omits JSON output when printing the version handshake, which breaks consistency with other commands. JSON consumers (e.g., scripts or CI) cannot parse the version drift warning programmatically.

File-by-file

crates/tauri-pilot-cli/src/main.rs

1 finding

  • crates/tauri-pilot-cli/src/main.rs:140 Missing JSON output for version handshake in ping
Compliance & provenance

Compliance & audit

Model: mistral / mistral-large-latest
Prompt sha256: ec9d577a30b739d74e1e3f12571df248b078764e0910c8f3067123873736744e
No signed audit trail is attached

Missing JSON output for version handshake in ping — crates/tauri-pilot-cli/src/main.rs:140

🔍 Audit Reference: SOVRI-MT-0C95-2A35


Tokens: 6068 in / 631 out · Estimated cost: $0.0040 (mistral mistral-large-latest)

Sovri

Comment thread crates/tauri-pilot-cli/src/main.rs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/tauri-plugin-pilot/src/server/windows.rs (1)

592-592: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Update the Windows ping test to verify plugin_version.

The Unix ping test (at unix.rs:284-289) was updated to verify both status and plugin_version fields, but the Windows test still checks only the entire result object. Since the handler's ping dispatch is platform-agnostic and returns plugin_version for all platforms, both server tests should verify the same response contract to catch regressions.

🔧 Align with the Unix test pattern
         assert_eq!(resp.id, serde_json::json!(1));
         assert!(resp.error.is_none());
-        assert_eq!(resp.result, Some(serde_json::json!({"status": "ok"})));
+        let result = resp.result.expect("ping returns a result");
+        assert_eq!(result["status"], serde_json::json!("ok"));
+        assert_eq!(
+            result["plugin_version"],
+            serde_json::json!(env!("CARGO_PKG_VERSION"))
+        );
🤖 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 `@crates/tauri-plugin-pilot/src/server/windows.rs` at line 592, The Windows
ping test currently asserts resp.result equals {"status":"ok"}; update it to
also verify the plugin_version like the Unix test does by asserting resp.result
is Some(serde_json::json!({"status":"ok","plugin_version":
crate::common::PLUGIN_VERSION})) or by asserting the "status" field equals "ok"
and the "plugin_version" field equals the PLUGIN_VERSION constant; locate the
assertion in the Windows test (where resp.result is compared) and replace it
with the combined check using serde_json::json! or two explicit assertions
referencing PLUGIN_VERSION.
🧹 Nitpick comments (1)
crates/tauri-plugin-pilot/src/handler.rs (1)

601-621: 💤 Low value

Consider consolidating the ping tests.

The test test_dispatch_ping_returns_ok (lines 601-608) verifies only the status field, while test_dispatch_ping_reports_plugin_version (lines 610-621) verifies both status and plugin_version. The first test is now redundant since the second provides full coverage.

♻️ Simplify by removing the redundant test
-    #[tokio::test]
-    async fn test_dispatch_ping_returns_ok() {
-        let engine = EvalEngine::new();
-        let result = dispatch("ping", None, &engine, None, None, None, &Recorder::new())
-            .await
-            .expect("dispatch succeeds");
-        assert_eq!(result["status"], json!("ok"));
-    }
-
     #[tokio::test]
     async fn test_dispatch_ping_reports_plugin_version() {
🤖 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 `@crates/tauri-plugin-pilot/src/handler.rs` around lines 601 - 621, Remove the
redundant test function test_dispatch_ping_returns_ok and consolidate its
assertion into test_dispatch_ping_reports_plugin_version: keep a single async
#[tokio::test] that calls dispatch("ping", ...) (as in the existing
test_dispatch_ping_reports_plugin_version), assert result["status"] ==
json!("ok") and assert result["plugin_version"] ==
json!(env!("CARGO_PKG_VERSION")); ensure the test uses EvalEngine::new(),
Recorder::new(), and .expect("dispatch succeeds") exactly like the current tests
and delete the now-duplicate test_dispatch_ping_returns_ok function.
🤖 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.

Outside diff comments:
In `@crates/tauri-plugin-pilot/src/server/windows.rs`:
- Line 592: The Windows ping test currently asserts resp.result equals
{"status":"ok"}; update it to also verify the plugin_version like the Unix test
does by asserting resp.result is
Some(serde_json::json!({"status":"ok","plugin_version":
crate::common::PLUGIN_VERSION})) or by asserting the "status" field equals "ok"
and the "plugin_version" field equals the PLUGIN_VERSION constant; locate the
assertion in the Windows test (where resp.result is compared) and replace it
with the combined check using serde_json::json! or two explicit assertions
referencing PLUGIN_VERSION.

---

Nitpick comments:
In `@crates/tauri-plugin-pilot/src/handler.rs`:
- Around line 601-621: Remove the redundant test function
test_dispatch_ping_returns_ok and consolidate its assertion into
test_dispatch_ping_reports_plugin_version: keep a single async #[tokio::test]
that calls dispatch("ping", ...) (as in the existing
test_dispatch_ping_reports_plugin_version), assert result["status"] ==
json!("ok") and assert result["plugin_version"] ==
json!(env!("CARGO_PKG_VERSION")); ensure the test uses EvalEngine::new(),
Recorder::new(), and .expect("dispatch succeeds") exactly like the current tests
and delete the now-duplicate test_dispatch_ping_returns_ok function.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 984990aa-9790-4c9d-a6cd-281383d14e91

📥 Commits

Reviewing files that changed from the base of the PR and between b5e529a and 4a98c82.

📒 Files selected for processing (8)
  • CHANGELOG.md
  • crates/tauri-pilot-cli/src/cli.rs
  • crates/tauri-pilot-cli/src/main.rs
  • crates/tauri-pilot-cli/tests/version.rs
  • crates/tauri-plugin-pilot/src/handler.rs
  • crates/tauri-plugin-pilot/src/server/unix.rs
  • crates/tauri-plugin-pilot/src/server/windows.rs
  • docs/src/content/docs/guides/plugin-setup.md

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 10, 2026
)

The unix server test was updated for the new ping field, but its
windows.rs twin still asserted the old {"status":"ok"} shape, so
cargo test failed on windows-latest only.
Comment thread crates/tauri-pilot-cli/src/main.rs
Comment thread crates/tauri-plugin-pilot/src/handler.rs Outdated
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 10, 2026
Addresses a PR review nit: extract inject_plugin_version so the
`plugin_version` field and its env! source live in one place instead of
being repeated in the ping and state arms.
Comment thread crates/tauri-pilot-cli/src/main.rs
Comment thread crates/tauri-pilot-cli/src/main.rs
Comment thread crates/tauri-pilot-cli/tests/version.rs
@mpiton

mpiton commented Jun 10, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai

Update the Windows ping test to verify plugin_version.

Already handled in db8f11f, ahead of this review. The Windows test at windows.rs:592 now asserts status and plugin_version separately, matching the Unix test. The diff you suggested is what shipped.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

@mpiton: Thanks for the heads-up! Confirmed — the Windows test in db8f11f matches the approach, asserting status and plugin_version independently just like the Unix counterpart. All good!

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 10, 2026
Per review: pin the assertion to `tauri-pilot <version>` so a change to
the binary name or clap's version layout is caught, not just the presence
of the version string.
Comment thread crates/tauri-pilot-cli/src/main.rs
@mpiton mpiton merged commit e43ad05 into main Jun 10, 2026
13 checks passed
@mpiton mpiton mentioned this pull request Jun 10, 2026
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