Skip to content

refactor: remove hardware-related components and streamline service management#502

Merged
senamakel merged 5 commits intotinyhumansai:mainfrom
senamakel:fix/friday
Apr 11, 2026
Merged

refactor: remove hardware-related components and streamline service management#502
senamakel merged 5 commits intotinyhumansai:mainfrom
senamakel:fix/friday

Conversation

@senamakel
Copy link
Copy Markdown
Member

@senamakel senamakel commented Apr 11, 2026

Summary

  • Add pre-login user directory setup so core config and workspace paths exist before authentication completes.
  • Remove the hardware-specific config and tooling path from the Rust core.
  • Rename the Tauri command helper from hardware to service to match the streamlined service-management surface.
  • Update prompt/config references to align with the new service-oriented flow.
  • Include hook-generated formatting and Tauri lockfile sync so the branch pushes cleanly.

Problem

  • The branch was carrying a pre-login directory setup change alongside older hardware-oriented service management code that no longer fits the current product direction.
  • Reviewers need the branch packaged as a PR against upstream main with the current branch contents pushed and a clear summary of the mixed cleanup/config work.

Solution

  • Land the existing branch commits as-is on fix/friday and open a PR from senamakel:fix/friday to tinyhumansai:main.
  • Keep the config-path work and hardware-removal refactor together, since they already ship in the current branch history.
  • Include the formatting/lockfile normalization produced by the repo’s push hook so the branch is in a clean, publishable state.

Submission Checklist

  • Unit tests — Not run explicitly in this PR flow; the pre-push hook ran format, lint, TypeScript, and Tauri Rust checks.
  • E2E / integration — Not run explicitly in this PR flow.
  • N/A — Full test execution was not part of this push/PR task.
  • Doc comments — No additional doc comments added as part of this PR packaging step.
  • Inline comments — No additional inline comments added as part of this PR packaging step.

Impact

  • Runtime/platform impact is limited to the existing branch changes in the desktop app and Rust core.
  • Removes hardware-related core surface area and adjusts config/service plumbing accordingly.
  • No migration steps were added in this PR packaging step.

Related

  • Issue(s): None linked.
  • Follow-up PR(s)/TODOs: Address existing ESLint react-hooks/set-state-in-effect warnings that still appear during the push hook.

Summary by CodeRabbit

  • Refactor

    • Removed hardware-related tools, configuration options, and associated runtime support.
    • Eliminated optional hardware dependencies and related exports.
    • Simplified the system prompt by removing hardware-specific authorization instructions.
  • New Features

    • Added pre-login user directory support to scope default configuration before sign-in.
  • Tests

    • Updated test setup to seed config under the pre-login user path.

- Added support for a pre-login user directory to encapsulate configuration, memory, and state before any user logs in. This ensures that all initial data is scoped under a dedicated user directory (`users/local`), preventing direct writes to the root `.openhuman` path.
- Implemented the `pre_login_user_dir` function to return the appropriate path for the pre-login user.
- Updated configuration loading logic to defer disk state creation until the first successful login, enhancing user data management and isolation.
- Added tests to verify the correct behavior of the pre-login directory structure.
…anagement

- Deleted hardware configuration and related tools from the codebase, including `HardwareConfig`, `HardwareTransport`, and associated memory management tools.
- Introduced a new `service.ts` module for managing service and daemon commands, consolidating service-related functionalities.
- Updated import paths across the application to reflect the removal of hardware references and the addition of the new service management module.
- Refactored the `build_system_prompt` function to remove hardware access instructions, focusing on action instructions instead.
- Cleaned up the Cargo.toml and Cargo.lock files by removing unused dependencies related to hardware management.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 11, 2026

📝 Walkthrough

Walkthrough

Removes hardware-related crates and Cargo features, deletes hardware config schema and hardware tools, updates runtime config resolution to add a pre-login per-user directory, adjusts Tauri service export/imports, and removes hardware-specific system-prompt text.

Changes

Cohort / File(s) Summary
Dependency & Feature Removal
Cargo.toml
Deleted optional hardware dependencies (nusb, tokio-serial, probe-rs) and removed related hardware / probe feature wiring.
TypeScript Import Updates
app/src/lib/coreState/store.ts, app/src/services/coreStateApi.ts
Switched ServiceStatus imports from utils/tauriCommands/hardwareutils/tauriCommands/service.
Tauri Commands Barrel & Service API
app/src/utils/tauriCommands/index.ts, app/src/utils/tauriCommands/service.ts
Replaced export * from './hardware' with export * from './service'; removed hardware-related types and two hardware discovery/introspect commands from service.ts.
Config API & Schema Cleanup
src/openhuman/config/mod.rs, src/openhuman/config/schema/mod.rs, src/openhuman/config/schema/types.rs, src/openhuman/config/schema/hardware.rs
Removed HardwareConfig/HardwareTransport types and hardware schema file; removed hardware field from top-level Config; updated re-exports.
Pre-Login User Directory & Load Behavior
src/openhuman/config/schema/load.rs
Added PRE_LOGIN_USER_ID, pre_login_user_dir() helper; changed resolve/load fallback to use users/local for pre-login case and made Config::load_or_init avoid creating files for that default case.
Hardware Tools Removal
src/openhuman/tools/impl/hardware/..., src/openhuman/tools/impl/mod.rs
Deleted hardware tool implementations (board_info, memory_map, memory_read) and removed hardware module and re-exports from tools impl.
System Prompt Simplification
src/openhuman/channels/prompt.rs
Removed conditional "Hardware Access" prompt section that injected authorization text when hardware tools were present.
Tests: e2e config seeding
tests/json_rpc_e2e.rs
Refactored test helpers to write config.toml via helper and added logic to seed config under pre-login user path when using the root ~/.openhuman test dir.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • graycyrus

Poem

🐰 I hopped through code at break of day,

Removed the probes, sent wires away.
A cozy users/local nest tucked tight,
Cleaner paths now bask in light.
Hop, cheer, compile — all feels right. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately summarizes the main changes: removing hardware-related components and streamlining service management. It directly reflects the substantial refactoring across Rust core, Cargo dependencies, Tauri commands, and configuration schema.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Caution

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

⚠️ Outside diff range comments (1)
src/openhuman/channels/prompt.rs (1)

74-80: ⚠️ Potential issue | 🟠 Major

Guard tool-usage instruction behind tool availability

Line 77 currently mandates tool usage even when tools is empty, which can push the model to emit invalid <tool_call> tags. Make this instruction conditional so no-tool channels get a direct-response directive instead.

Proposed fix
-    // ── 1b. Action instruction (avoid meta-summary) ───────────────
-    prompt.push_str(
-        "## Your Task\n\n\
-         When the user sends a message, ACT on it. Use the tools to fulfill their request.\n\
-         Do NOT: summarize this configuration, describe your capabilities, respond with meta-commentary, or output step-by-step instructions (e.g. \"1. First... 2. Next...\").\n\
-         Instead: emit actual <tool_call> tags when you need to act. Just do what they ask.\n\n",
-    );
+    // ── 1b. Action instruction (avoid meta-summary) ───────────────
+    if tools.is_empty() {
+        prompt.push_str(
+            "## Your Task\n\n\
+             When the user sends a message, ACT on it directly.\n\
+             Do NOT: summarize this configuration, describe your capabilities, or respond with meta-commentary.\n\
+             There are no tools available in this channel, so respond normally without <tool_call> tags.\n\n",
+        );
+    } else {
+        prompt.push_str(
+            "## Your Task\n\n\
+             When the user sends a message, ACT on it. Use the tools to fulfill their request.\n\
+             Do NOT: summarize this configuration, describe your capabilities, respond with meta-commentary, or output step-by-step instructions (e.g. \"1. First... 2. Next...\").\n\
+             Instead: emit actual <tool_call> tags when you need to act. Just do what they ask.\n\n",
+        );
+    }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/openhuman/channels/prompt.rs` around lines 74 - 80, The "## Your Task"
block currently forces tool usage even when no tools are present; modify the
code around prompt.push_str so it checks the channel's tools list (e.g., tools
or whatever variable holds tool availability) and only injects the "emit
<tool_call> tags" instruction when tools is non-empty, otherwise push an
alternative directive telling the model to produce a direct response (no tool
tags, no meta-commentary). Ensure you update the logic that builds the prompt
(referencing prompt.push_str and the "## Your Task" string) so the two different
strings are chosen based on tools.is_empty() / tools.len() == 0.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/openhuman/channels/prompt.rs`:
- Around line 74-80: The "## Your Task" block currently forces tool usage even
when no tools are present; modify the code around prompt.push_str so it checks
the channel's tools list (e.g., tools or whatever variable holds tool
availability) and only injects the "emit <tool_call> tags" instruction when
tools is non-empty, otherwise push an alternative directive telling the model to
produce a direct response (no tool tags, no meta-commentary). Ensure you update
the logic that builds the prompt (referencing prompt.push_str and the "## Your
Task" string) so the two different strings are chosen based on tools.is_empty()
/ tools.len() == 0.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cf5f8233-e704-4932-8765-2601a185e420

📥 Commits

Reviewing files that changed from the base of the PR and between 57d307a and f4146e1.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • app/src-tauri/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (16)
  • Cargo.toml
  • app/src/lib/coreState/store.ts
  • app/src/services/coreStateApi.ts
  • app/src/utils/tauriCommands/index.ts
  • app/src/utils/tauriCommands/service.ts
  • src/openhuman/channels/prompt.rs
  • src/openhuman/config/mod.rs
  • src/openhuman/config/schema/hardware.rs
  • src/openhuman/config/schema/load.rs
  • src/openhuman/config/schema/mod.rs
  • src/openhuman/config/schema/types.rs
  • src/openhuman/tools/impl/hardware/board_info.rs
  • src/openhuman/tools/impl/hardware/memory_map.rs
  • src/openhuman/tools/impl/hardware/memory_read.rs
  • src/openhuman/tools/impl/hardware/mod.rs
  • src/openhuman/tools/impl/mod.rs
💤 Files with no reviewable changes (8)
  • src/openhuman/tools/impl/mod.rs
  • src/openhuman/config/schema/types.rs
  • src/openhuman/tools/impl/hardware/memory_read.rs
  • Cargo.toml
  • src/openhuman/config/schema/hardware.rs
  • src/openhuman/tools/impl/hardware/mod.rs
  • src/openhuman/tools/impl/hardware/memory_map.rs
  • src/openhuman/tools/impl/hardware/board_info.rs

…nction

- Introduced a `write_config_file` function to encapsulate the logic for creating directories and writing configuration files, improving code reuse and readability.
- Updated test cases to utilize the new function for writing configuration files, ensuring consistency and reducing duplication.
- Added handling for pre-login user directory structure to ensure configuration is correctly written to the appropriate paths.
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.

🧹 Nitpick comments (1)
tests/json_rpc_e2e.rs (1)

545-549: Consolidate duplicated config-writer helper to prevent drift

write_config_file is duplicated in both helpers (Line 545 and Line 581). Pulling it to a single file-level helper avoids future divergence when write semantics change.

[Line 545] and [Line 581] currently define the same logic independently.

♻️ Suggested refactor
+fn write_config_file(config_dir: &Path, cfg: &str) {
+    std::fs::create_dir_all(config_dir).expect("mkdir openhuman");
+    let path = config_dir.join("config.toml");
+    std::fs::write(&path, cfg).expect("write config");
+}
+
 fn write_min_config(openhuman_dir: &Path, api_origin: &str) {
@@
-    fn write_config_file(config_dir: &Path, cfg: &str) {
-        std::fs::create_dir_all(config_dir).expect("mkdir openhuman");
-        let path = config_dir.join("config.toml");
-        std::fs::write(&path, cfg).expect("write config");
-    }
-
     write_config_file(openhuman_dir, &cfg);
@@
 fn write_min_config_with_local_ai_disabled(openhuman_dir: &Path, api_origin: &str) {
@@
-    fn write_config_file(config_dir: &Path, cfg: &str) {
-        std::fs::create_dir_all(config_dir).expect("mkdir openhuman");
-        let path = config_dir.join("config.toml");
-        std::fs::write(&path, cfg).expect("write config");
-    }
-
     write_config_file(openhuman_dir, &cfg);

Also applies to: 581-585

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/json_rpc_e2e.rs` around lines 545 - 549, Two identical helpers named
write_config_file are duplicated; remove the duplicate and consolidate to a
single file-level helper. Create one top-level function
write_config_file(config_dir: &Path, cfg: &str) that contains the mkdir and
write logic, delete the second definition, and update any local test callers to
use that single helper; ensure the function signature/visibility matches the
callers so no additional changes are required.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/json_rpc_e2e.rs`:
- Around line 545-549: Two identical helpers named write_config_file are
duplicated; remove the duplicate and consolidate to a single file-level helper.
Create one top-level function write_config_file(config_dir: &Path, cfg: &str)
that contains the mkdir and write logic, delete the second definition, and
update any local test callers to use that single helper; ensure the function
signature/visibility matches the callers so no additional changes are required.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 79bfc93f-8202-4105-abda-ff5208fdc409

📥 Commits

Reviewing files that changed from the base of the PR and between f4146e1 and 5fbbab8.

📒 Files selected for processing (1)
  • tests/json_rpc_e2e.rs

@senamakel senamakel merged commit 73f8d12 into tinyhumansai:main Apr 11, 2026
8 of 9 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