Skip to content

fix: explain reset-data Windows file locks#2395

Merged
graycyrus merged 1 commit into
tinyhumansai:mainfrom
Bortlesboat:codex/1615-reset-lock-guidance
May 22, 2026
Merged

fix: explain reset-data Windows file locks#2395
graycyrus merged 1 commit into
tinyhumansai:mainfrom
Bortlesboat:codex/1615-reset-lock-guidance

Conversation

@Bortlesboat
Copy link
Copy Markdown
Contributor

@Bortlesboat Bortlesboat commented May 21, 2026

Summary

  • route Tauri reset-local-data delete failures through a shared formatter
  • detect Windows sharing/lock violation OS errors and show guidance to close other OpenHuman windows
  • keep the existing generic delete error copy for non-lock failures

Tests

  • cargo fmt --manifest-path app/src-tauri/Cargo.toml
  • cargo test --manifest-path app/src-tauri/Cargo.toml reset_local_data --lib

Addresses #1615

Summary by CodeRabbit

  • Bug Fixes

    • Improved error messages when resetting local data fails on Windows due to file locks, now directing users to close other application windows or processes blocking the operation.
  • Tests

    • Added unit tests to verify Windows file-lock error detection and handling.

Review Change Stack

@Bortlesboat Bortlesboat requested a review from a team May 21, 2026 01:19
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 21, 2026

📝 Walkthrough

Walkthrough

This PR improves error handling during the reset_local_data teardown operation on Windows. When file deletion fails due to Windows file-lock errors (raw OS codes 32/33), the system now detects these specific errors and returns a focused message advising users to close other OpenHuman windows or processes, rather than a generic deletion failure message.

Changes

Windows file-lock error handling

Layer / File(s) Summary
Windows file-lock error detection helpers
app/src-tauri/src/lib.rs
Three new internal helpers detect Windows file-lock raw OS errors (32/33) and generate specialized deletion failure messages for lock errors vs. generic errors.
Integration into delete operations
app/src-tauri/src/lib.rs
remove_path_if_exists and remove_dir_if_exists now map non-NotFound deletion errors to the specialized reset_local_data_delete_error message instead of generic format strings.
Windows file-lock error detection tests
app/src-tauri/src/lib.rs
Unit tests verify Windows file-lock code detection and confirm specialized messaging for lock errors while preserving generic messages for non-lock errors.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

  • tinyhumansai/openhuman#1615: The PR directly addresses Windows file-lock failures during reset_local_data by detecting error codes 32/33 and returning specialized guidance to close other OpenHuman processes.

Possibly related PRs

  • tinyhumansai/openhuman#1769: Both PRs modify the same remove_path_if_exists and remove_dir_if_exists helpers introduced in that PR to improve deletion error handling.
  • tinyhumansai/openhuman#1811: Both PRs update Windows reset_local_data file-lock error detection with specialized "close other OpenHuman windows/processes" messaging.

Poem

A rabbit hops to Windows' door,
Where file locks block the way,
"Close your other apps," it chirps with glee,
"Then try reset again, hooray!" 🐰✨

🚥 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 describes the main change: improving error handling for Windows file locks during reset-data operations by providing user-friendly guidance.
Docstring Coverage ✅ Passed Docstring coverage is 90.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.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

coderabbitai[bot]
coderabbitai Bot previously requested changes May 21, 2026
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

🤖 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 `@app/src-tauri/src/lib.rs`:
- Around line 3407-3414: The test currently asserts a platform-specific
hardcoded path string "/tmp/openhuman"; change the assertion to use the same
Path display value used when building the message so it is platform-agnostic:
construct the test Path (the same one passed into reset_local_data_delete_error)
and use its display() (or its to_string/display representation) in the assert!
that checks msg.starts_with(...) and any other assertions that compare the path
text, referencing reset_local_data_delete_error and the Path you create in the
test so the test works on Windows and Unix.
🪄 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: 7361a977-f8c1-4ae0-859a-431132673e67

📥 Commits

Reviewing files that changed from the base of the PR and between 369a392 and 254243f.

📒 Files selected for processing (1)
  • app/src-tauri/src/lib.rs

Comment thread app/src-tauri/src/lib.rs
Comment on lines +3407 to +3414
let msg = reset_local_data_delete_error(
"current openhuman dir",
std::path::Path::new("/tmp/openhuman"),
&err,
);

assert!(msg.starts_with("Failed to remove current openhuman dir at /tmp/openhuman:"));
assert!(!msg.contains("Close all OpenHuman windows and try again"));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Make the generic-message test path assertion platform-agnostic.

The assertion hardcodes /tmp/openhuman, which is brittle on Windows path rendering. Assert against the same Path display value used to build the message.

Suggested patch
     fn reset_local_data_delete_error_keeps_generic_message_for_other_errors() {
         let err = std::io::Error::from(std::io::ErrorKind::PermissionDenied);
+        let path = std::path::Path::new("/tmp/openhuman");
         let msg = reset_local_data_delete_error(
             "current openhuman dir",
-            std::path::Path::new("/tmp/openhuman"),
+            path,
             &err,
         );
 
-        assert!(msg.starts_with("Failed to remove current openhuman dir at /tmp/openhuman:"));
+        let expected_prefix = format!(
+            "Failed to remove current openhuman dir at {}:",
+            path.display()
+        );
+        assert!(msg.starts_with(&expected_prefix));
         assert!(!msg.contains("Close all OpenHuman windows and try again"));
     }
🤖 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 `@app/src-tauri/src/lib.rs` around lines 3407 - 3414, The test currently
asserts a platform-specific hardcoded path string "/tmp/openhuman"; change the
assertion to use the same Path display value used when building the message so
it is platform-agnostic: construct the test Path (the same one passed into
reset_local_data_delete_error) and use its display() (or its to_string/display
representation) in the assert! that checks msg.starts_with(...) and any other
assertions that compare the path text, referencing reset_local_data_delete_error
and the Path you create in the test so the test works on Windows and Unix.

Copy link
Copy Markdown
Contributor

@graycyrus graycyrus left a comment

Choose a reason for hiding this comment

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

Looks good, nice work!

@graycyrus graycyrus merged commit f9d9481 into tinyhumansai:main May 22, 2026
27 checks passed
senamakel pushed a commit to aqilaziz/openhuman that referenced this pull request May 23, 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.

2 participants