Skip to content

fix(si_server): skip embedded server autostart on non-macOS (OPENHUMAN-TAURI-50)#1542

Open
oxoxDev wants to merge 2 commits into
tinyhumansai:mainfrom
oxoxDev:fix-si-server-non-macos-crash-13903582644506769746
Open

fix(si_server): skip embedded server autostart on non-macOS (OPENHUMAN-TAURI-50)#1542
oxoxDev wants to merge 2 commits into
tinyhumansai:mainfrom
oxoxDev:fix-si-server-non-macos-crash-13903582644506769746

Conversation

@oxoxDev
Copy link
Copy Markdown
Contributor

@oxoxDev oxoxDev commented May 12, 2026

Summary

  • Skip embedded si_server autostart on non-macOS at the spawn site so cores no longer crash with accessibility automation is macOS-only in V1. Sentry issue OPENHUMAN-TAURI-50 (~15 events).
  • Demote residual macOS-only failure logs from error! to info! for defense-in-depth.
  • macOS path unchanged.

Problem

screen_intelligence::server::start_if_enabled spawns the embedded screen-intelligence server on every platform during core boot. The underlying accessibility engine is macOS-only in V1 (per the existing check at engine.rs:95-96), so on Windows/Linux the spawned task immediately errors and surfaces as Sentry OPENHUMAN-TAURI-50 (~15 events). The error log is the noise — the actual feature gap is expected and documented.

Solution

  • src/openhuman/screen_intelligence/server.rs::start_if_enabled: runtime if !cfg!(target_os = "macos") guard returns early with an info! log explaining the V1 platform constraint. Avoids #[cfg]-gating the function symbol so non-mac callers still compile.
  • Same file: when the inner start_session or spawned run() does fail with a macOS-only message (defense-in-depth — covers any future caller that bypasses start_if_enabled), demote error!info! so any residual non-mac entrypoint doesn't pollute Sentry.
  • Existing engine-side check at engine.rs:95-96 left intact.

Submission Checklist

  • Tests added or updated (happy path + at least one failure / edge case) — non-macOS cfg-gated test asserts start_if_enabled returns without panic and server is Stopped; macOS cfg-gated test asserts global server initializes
  • Diff coverage ≥ 80% — both platform arms covered plus both demoted error sites; total diff is +47/-2 in a single file
  • Coverage matrix updated — N/A: platform-gating fix, no new feature row
  • All affected feature IDs from the matrix are listed in the PR description under ## RelatedN/A: behaviour-only change
  • No new external network dependencies introduced (mock backend used per Testing Strategy)
  • Manual smoke checklist updated if this touches release-cut surfaces — N/A: no release-cut surface touched
  • Linked issue closed via Closes in the ## Related section

Impact

  • Runtime/platform: skips autostart on Windows / Linux; macOS unchanged. Pure log-level demotion on the residual failure paths.
  • Observability: Sentry event volume drops on OPENHUMAN-TAURI-50 (~15 events). Replaces error noise with a single info! line per non-mac core boot.
  • Compatibility: config semantics unchanged — screen_intelligence.enabled = true on non-mac now no-ops cleanly instead of erroring. Feature availability identical to V1 reality (mac-only).
  • Security: no new surface.
  • Performance: runtime cfg!() check is a compile-time constant; negligible.

Related

  • Closes OPENHUMAN-TAURI-50
  • Follow-up PR(s)/TODOs: when accessibility engine support lands for Win/Linux (post-V1), remove the runtime guard

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

Linear Issue

  • Key: N/A — Sentry-driven, not Linear
  • URL: N/A

Commit & Branch

  • Branch: fix-si-server-non-macos-crash-13903582644506769746
  • Commit SHA: see git log on PR

Validation Run

  • pnpm --filter openhuman-app format:check — N/A: no app/ changes
  • pnpm typecheck — N/A: no TS changes
  • Focused tests:
    • cargo test --lib openhuman::screen_intelligence::server::tests::start_if_enabled_skips_on_non_macos (non-mac targets)
    • cargo test --lib openhuman::screen_intelligence::server::tests::start_if_enabled_continues_on_macos (mac targets)
  • Rust fmt/check (if changed): clean per agent run
  • Tauri fmt/check (if changed): N/A — no app/src-tauri/ changes

Validation Blocked

  • command: N/A
  • error: N/A
  • impact: N/A

Behavior Changes

  • Intended behavior change: non-macOS cores no longer spawn an embedded server that immediately fails; log level demoted on residual mac-only failure paths.
  • User-visible effect: none direct — observability cleanup. Screen-intelligence feature remains mac-only in V1 (unchanged).

Parity Contract

  • Legacy behavior preserved: macOS path identical to before; non-mac path now no-ops cleanly instead of erroring.
  • Guard/fallback/dispatch parity checks: engine-side check at engine.rs:95-96 left intact as last line of defense.

Duplicate / Superseded PR Handling

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

Authoring note: This PR was prepared by Google Jules (cloud async coding agent) as part of the Wave 1 Sentry triage batch (clusters K / J / H). Branch published to oxoxDev/openhuman and opened cross-repo against tinyhumansai/openhuman.

Summary by CodeRabbit

  • Bug Fixes

    • Improved platform-aware handling: macOS-only startup failures are now logged as informational on non-macOS, autostart is skipped with an info log, and background task logging distinguishes expected vs unexpected failures.
  • Tests

    • Added tests verifying startup/autostart behavior and the classifier across macOS and non-macOS environments.

Review Change Stack

Add a runtime check `if !cfg!(target_os = "macos")` in `start_if_enabled`
to skip `si_server` autostart on non-macOS platforms.
Adjust logging to use `info!` for "macOS-only" errors on those platforms
to prevent Sentry noise.

Sentry: OPENHUMAN-TAURI-50

Co-authored-by: oxoxDev <164490987+oxoxDev@users.noreply.github.com>
@oxoxDev oxoxDev requested a review from a team May 12, 2026 11:36
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

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: 92ed4025-a0bc-4af7-9954-3a7006bfe329

📥 Commits

Reviewing files that changed from the base of the PR and between a80d17d and 7ab9413.

📒 Files selected for processing (1)
  • src/openhuman/screen_intelligence/server.rs

📝 Walkthrough

Walkthrough

The server classifies known "macOS-only" session-start failures and logs them at info on non-macOS, skips embedded autostart on non-macOS, and includes tests that validate the classifier and platform-specific autostart behavior.

Changes

Cross-Platform macOS-Only Error Handling

Layer / File(s) Summary
Error handling for macOS-only failures
src/openhuman/screen_intelligence/server.rs
Session startup errors in SiServer::run and errors from the spawned embedded-server task are checked by is_expected_macos_only_failure; on non-macOS such failures are logged at info level while still setting last_error, transitioning state to Stopped, and returning Err(e).
Autostart platform guard and tests
src/openhuman/screen_intelligence/server.rs
start_if_enabled now early-returns on non-macOS with an info log and does not construct/start the embedded server. New tests validate non-macOS skip, the classifier true/false cases, and that macOS proceeds to initialize the global server.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • tinyhumansai/openhuman#382: Modifies the same screen_intelligence server and earlier introduces standalone server and start_if_enabled behavior.

Suggested reviewers

  • senamakel

Poem

🐰 In logs I hop, I sniff the clue,
Mac-only errors I now view,
On Linux I whisper, "skip this start",
On macOS I let the server start.
Hooray — less noise, more rabbit heart!

🚥 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 'fix(si_server): skip embedded server autostart on non-macOS' directly matches the main change—preventing embedded server autostart on non-macOS by adding an early return guard.
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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/openhuman/screen_intelligence/server.rs (1)

159-163: ⚡ Quick win

Deduplicate the macOS-only error classification check.

The same !cfg!(target_os = "macos") && e.contains("macOS-only") logic is repeated in two paths. Extract a small helper to keep behavior consistent over time.

Proposed refactor
+fn is_macos_only_error(err: &str) -> bool {
+    err.contains("macOS-only")
+}
...
-                if !cfg!(target_os = "macos") && e.contains("macOS-only") {
+                if !cfg!(target_os = "macos") && is_macos_only_error(&e) {
                     info!("{LOG_PREFIX} failed to start session: {e}");
                 } else {
                     error!("{LOG_PREFIX} failed to start session: {e}");
                 }
...
-            if !cfg!(target_os = "macos") && e.contains("macOS-only") {
+            if !cfg!(target_os = "macos") && is_macos_only_error(&e) {
                 info!("{LOG_PREFIX} embedded server autostart skipped: {e}");
             } else {
                 error!("{LOG_PREFIX} embedded server exited with error: {e}");
             }

Also applies to: 366-370

🤖 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 `@src/openhuman/screen_intelligence/server.rs` around lines 159 - 163, The
duplicated condition `!cfg!(target_os = "macos") && e.contains("macOS-only")`
should be extracted into a small helper (e.g., fn is_macos_only_error(e: &str)
-> bool) in server.rs and used wherever that check appears (replace the inline
condition in the session-start error branch around the LOG_PREFIX handling and
the similar branch at the 366-370 area); update the two branches to call
is_macos_only_error(e) and keep the existing info/error logging behavior
unchanged.
🤖 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 `@src/openhuman/screen_intelligence/server.rs`:
- Around line 462-475: The test should assert the no-op contract more strictly
by verifying no global server was created after calling start_if_enabled:
instead of only checking an existing server's state, assert that
try_global_server() returns None (i.e., no server instance exists) after
start_if_enabled(&config). Update the test function (which currently calls
start_if_enabled and then inspects try_global_server and ServerState::Stopped)
to assert try_global_server().is_none() so regressions that create-then-stop are
caught.

---

Nitpick comments:
In `@src/openhuman/screen_intelligence/server.rs`:
- Around line 159-163: The duplicated condition `!cfg!(target_os = "macos") &&
e.contains("macOS-only")` should be extracted into a small helper (e.g., fn
is_macos_only_error(e: &str) -> bool) in server.rs and used wherever that check
appears (replace the inline condition in the session-start error branch around
the LOG_PREFIX handling and the similar branch at the 366-370 area); update the
two branches to call is_macos_only_error(e) and keep the existing info/error
logging behavior unchanged.
🪄 Autofix (Beta)

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

Run ID: aa4b1506-c141-4bc0-a5b5-fb4c4bd66354

📥 Commits

Reviewing files that changed from the base of the PR and between 78d1f3d and a80d17d.

📒 Files selected for processing (1)
  • src/openhuman/screen_intelligence/server.rs

Comment thread src/openhuman/screen_intelligence/server.rs
…st (OPENHUMAN-TAURI-50)

Two adjustments per CodeRabbit review on PR tinyhumansai#1542:

1. Deduplicate `!cfg!(target_os = "macos") && e.contains("macOS-only")` —
   the same predicate appeared in both `SiServer::run`'s start_session
   error arm and `start_if_enabled`'s spawned `server.run` future.
   Extracted to a single private `is_expected_macos_only_failure(&str)`
   helper so the log-level decision (info! vs error!) stays in sync if
   the engine ever revises its marker text. Plus one unit test
   covering the platform-gated branches.

2. Strengthen the non-macOS `start_if_enabled_skips_on_non_macos` test
   to assert the strict no-op contract. The previous shape only
   checked `if let Some(server)... state == Stopped`, which would
   silently pass if the implementation regressed to a
   "create-then-stop" pattern. The test now records pre-state and
   asserts `try_global_server()` stays `None` post-call when the
   singleton was untouched at entry.

`cargo test --lib openhuman::screen_intelligence::server` — 7/7 pass
(local on macOS; the non-macOS-only test is cfg-gated out — CI matrix
covers the Windows / Linux leg).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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