Skip to content

fix: daemon-health identity race + Orchestration sub-tab follow-ups - #5085

Merged
senamakel merged 3 commits into
tinyhumansai:mainfrom
senamakel:fix/daemon-health-and-orch-followups
Jul 21, 2026
Merged

fix: daemon-health identity race + Orchestration sub-tab follow-ups#5085
senamakel merged 3 commits into
tinyhumansai:mainfrom
senamakel:fix/daemon-health-and-orch-followups

Conversation

@senamakel

Copy link
Copy Markdown
Member

Summary

Follow-up review fixes on top of #5075 (the Orchestration-under-Brain fold +
daemon-health/local-AI cleanup, already merged to main). These were surfaced
by CodeRabbit/Codex review of the superseded #5080 and are not on main:

  • daemon-health identity-flip race: resolve the health-store user from the
    refresh's own sessionToken (passed by CoreStateProvider) instead of the
    deferred non-React snapshot store — commitState writes that store inside a
    React setState updater, so reading it at ingest time filed health under the
    prior / __pending__ user during a login/identity flip. Add privacy-safe
    watchdog + ingest diagnostics.
  • LocalAI download snackbar: treat an empty-but-successful RPC response as
    transient, not "download complete", so a soft failure no longer freezes the
    fast poll for the rest of the download.
  • Brain sub-tab hygiene: skip the memoryTreeGraphExport fetch and gate
    useSubconscious polling (new enabled param) off the Orchestration sub-tab,
    so opening /brain?tab=orchestration (and the redirected /orchestration)
    no longer starts unrelated graph / heartbeat RPCs the standalone page never
    issued.
  • Redirect diagnostics: privacy-safe entry/exit logging in
    OrchestrationRedirect + a new OrchestrationRedirect.test.tsx covering every
    mapping branch.
  • RPC contract test: assert health.updated_at in json_rpc_e2e (the
    frontend rejects the payload without it).

Problem

#5075 shipped the fold + poll consolidation, but review flagged a real
identity-flip data-integrity race, a poll-freeze soft-failure, two unrelated
RPC loops newly triggered on the Orchestration sub-tab, and a couple of missing
diagnostics / assertions. None landed on main.

Solution

Small, targeted fixes with regression tests for each; no behaviour change to the
orchestration surfaces themselves.

Submission Checklist

If a section does not apply to this change, mark the item as N/A with a one-line reason. Do not delete items.

  • Tests added or updated (happy path + at least one failure / edge case) per Testing Strategy
  • Diff coverage ≥ 80% — new lines are covered by OrchestrationRedirect.test.tsx, the Brain orchestration-tab tests, the useSubconscious disabled-path test, and the daemon-health ingest tests; the full gate is enforced by CI.
  • N/A: Coverage matrix — behaviour-preserving follow-up fixes; no docs/TEST-COVERAGE-MATRIX.md feature rows change.
  • N/A: No matrix feature IDs affected.
  • No new external network dependencies introduced (mock backend used per Testing Strategy)
  • N/A: No release-cut smoke surfaces changed.
  • N/A: No linked issue to close.

Impact

  • Desktop UI/runtime: health is filed under the correct user across identity
    flips; download progress no longer freezes on a soft RPC failure; the
    Orchestration sub-tab stops two unrelated background RPC loops. No migration,
    security, or API-surface changes.

Related


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

Keep this section for AI-authored PRs. For human-only PRs, mark each field N/A.

Linear Issue

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

Commit & Branch

  • Branch: fix/daemon-health-and-orch-followups
  • Commit SHA: a7a2520ab

Validation Run

  • pnpm --filter openhuman-app format:check
  • pnpm typecheck
  • Focused tests: Vitest OrchestrationRedirect, Brain, useSubconscious, daemonHealthService, CoreStateProvider, LocalAIDownloadSnackbar (68 passing)
  • Rust fmt/check (if changed): cargo fmt --all --check (json_rpc_e2e assertion only)
  • N/A: Tauri shell unchanged

Validation Blocked

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

Behavior Changes

  • Intended behavior change: correct health-store identity on flips; no fast-poll freeze; no unrelated RPCs on the Orchestration sub-tab.
  • User-visible effect: reliable download progress + daemon-health status; slightly less background work on Orchestration.

Parity Contract

  • Legacy behavior preserved: orchestration surfaces unchanged; useSubconscious defaults to enabled for all existing callers.
  • Guard/fallback/dispatch parity checks: getUserId(tokenOverride) falls back to the store when no token is passed; useSubconscious(enabled=true) default keeps Activity + other callers unchanged.

Duplicate / Superseded PR Handling

- AppRoutes: add privacy-safe entry/exit diagnostics to OrchestrationRedirect
  (allowlisted branch ids + session-presence only) and cover it with a new
  OrchestrationRedirect.test.tsx exercising every mapping branch.
- LocalAIDownloadSnackbar: treat an empty-but-successful RPC response as
  transient, not "download complete", so a soft failure no longer freezes the
  fast poll for the rest of the download.
- daemonHealthService: resolve the health-store user from the refresh's own
  sessionToken passed by CoreStateProvider, not the deferred non-React store
  (commitState writes it inside a React setState updater) — fixes health being
  filed under the prior/__pending__ user during an identity flip. Add
  privacy-safe watchdog/ingest diagnostics.
- json_rpc_e2e: assert health.updated_at in the RPC contract test (the frontend
  rejects the payload without it).
Folding Orchestration under Brain mounted the full Brain component for
/brain?tab=orchestration (and the redirected /orchestration), whose effect
unconditionally called memoryTreeGraphExport on mount + memory-tree events —
an unrelated graph RPC the standalone Orchestration page never issued. Gate the
effect off when the orchestration tab is active (re-running when returning to a
graph-bearing tab). Addresses Codex review on PR tinyhumansai#5080.
Brain calls useSubconscious() unconditionally, which fires subconsciousStatus /
openhumanHeartbeatSettingsGet and installs a 5s poll. Folding Orchestration
under Brain meant opening Brain > Orchestration (and the redirected
/orchestration) now kept those unrelated heartbeat/subconscious RPCs running —
which the standalone OrchestrationPage never did. Add an `enabled` param to
useSubconscious (default true, back-compat) that skips the initial fetch + poll
when false, and pass `activeTab === 'subconscious'` from Brain. The status is
consumed only on that tab. Addresses Codex review on PR tinyhumansai#5080.
@senamakel
senamakel requested a review from a team July 21, 2026 12:06
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 19 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5f264784-6892-4842-a92b-426f71d680ce

📥 Commits

Reviewing files that changed from the base of the PR and between f181115 and a7a2520.

📒 Files selected for processing (10)
  • app/src/AppRoutes.tsx
  • app/src/components/LocalAIDownloadSnackbar.tsx
  • app/src/hooks/__tests__/useSubconscious.test.ts
  • app/src/hooks/useSubconscious.ts
  • app/src/pages/Brain.tsx
  • app/src/pages/__tests__/Brain.test.tsx
  • app/src/pages/__tests__/OrchestrationRedirect.test.tsx
  • app/src/providers/CoreStateProvider.tsx
  • app/src/services/daemonHealthService.ts
  • tests/json_rpc_e2e.rs

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

@senamakel
senamakel merged commit 49a0d3b into tinyhumansai:main Jul 21, 2026
15 of 16 checks passed
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