Skip to content

Improve reset local data guidance for locked Windows files#1811

Merged
senamakel merged 3 commits into
tinyhumansai:mainfrom
Yong-yuan-X:fix/windows-reset-local-data-guidance
May 16, 2026
Merged

Improve reset local data guidance for locked Windows files#1811
senamakel merged 3 commits into
tinyhumansai:mainfrom
Yong-yuan-X:fix/windows-reset-local-data-guidance

Conversation

@Yong-yuan-X
Copy link
Copy Markdown
Contributor

@Yong-yuan-X Yong-yuan-X commented May 15, 2026

Summary

  • Detect Windows file-lock failures during local data reset.
  • Return clearer guidance when .openhuman or active_workspace.toml cannot be deleted because another process is using it.
  • Surface the core reset error in Settings and Welcome recovery flows instead of replacing it with generic UI errors.
  • Add a Windows-only test for the locked local data guidance message.

Problem

On Windows, config_reset_local_data can fail when the .openhuman directory is locked by another OpenHuman window or process.

The current error path can result in generic UI messages, making it unclear what the user should do next. This PR addresses the user-guidance part of #1615 by giving users a clearer recovery action.

Solution

The Rust core now detects Windows file-lock errors using OS error codes:

  • 32: sharing violation
  • 33: lock violation

When those errors occur while removing local data files/directories, the core returns a clearer message asking the user to close all OpenHuman windows and try again.

The Settings and Welcome recovery flows were updated to display the reset error returned by the core instead of replacing it with a generic fallback message.

Submission Checklist

  • Tests added or updated (happy path + at least one failure / edge case) per Testing Strategy
  • Diff coverage ≥ 80% — verified locally during maintainer merge: cargo check + Vitest on SettingsHome.test.tsx / Welcome.test.tsx cover all changed lines (PR is +63/-10).
  • Coverage matrix updated — N/A: no feature rows were added, removed, or renamed.
  • All affected feature IDs from the matrix are listed in the PR description under ## Related — N/A: no coverage-matrix feature IDs were changed.
  • No new external network dependencies introduced (mock backend used per Testing Strategy)
  • Manual smoke checklist updated if this touches release-cut surfaces (docs/RELEASE-MANUAL-SMOKE.md) — N/A: this is a targeted error-message path change and does not add a new release smoke surface.
  • Linked issue closed via Closes #NNN in the ## Related section — N/A: this PR addresses only the user-guidance part of Windows: 'Reset local data' fails when .openhuman directory is locked by another process #1615, not the full issue.

Impact

This affects Windows desktop local-data reset behavior.

There is no lifecycle, database shutdown, migration, network, or dependency change. Non-file-lock removal failures continue to use the existing generic removal error path.

Related


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

Linear Issue

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

Commit & Branch

  • Branch: fix/windows-reset-local-data-guidance
  • Commit SHA: 70b24b53

Validation Run

  • pnpm --filter openhuman-app format:check — passed on the resolved files during maintainer merge.
  • pnpm typecheck — passed (tsc --noEmit).
  • Focused tests: SettingsHome.test.tsx (26/26) and Welcome.test.tsx passed.
  • Rust fmt/check (if changed): cargo fmt --check and cargo check --lib clean.
  • Tauri fmt/check (if changed): N/A — no app/src-tauri changes in this PR.

Validation Blocked

  • command: git push -u origin fix/windows-reset-local-data-guidance
  • error: local pre-push checks ran full formatting and modified unrelated files; rust:check also failed locally due to missing/invalid local Rust/Tauri build dependencies, including libclang/CEF build issues.
  • impact: validation could not be completed locally, but the pushed commit remains focused and does not include unrelated formatting changes.

Behavior Changes

  • Intended behavior change: Windows file-lock reset failures now return clearer user guidance.
  • User-visible effect: users are told to close all OpenHuman windows and try again when local data deletion is blocked by a file lock.

Parity Contract

  • Legacy behavior preserved: non-Windows and non-file-lock deletion errors continue to use the existing generic removal error format.
  • Guard/fallback/dispatch parity checks: UI still falls back to generic messages when no core error message is available.

Duplicate / Superseded PR Handling

  • Duplicate PR(s): N/A
  • Canonical PR: N/A
  • Resolution (closed/superseded/updated): N/A

Summary by CodeRabbit

  • Bug Fixes

    • Show the actual error message when clearing app data or logging out, instead of a generic fallback.
    • Detect Windows file-lock conditions and provide clearer guidance to close other app instances and retry.
  • Tests

    • Added/updated tests (including Windows-only and UI coverage) to verify the new error messaging and fallback behaviors.

Review Change Stack

@Yong-yuan-X Yong-yuan-X requested a review from a team May 15, 2026 12:03
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 15, 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: 360f7056-bb39-43db-ae79-c88e536733d9

📥 Commits

Reviewing files that changed from the base of the PR and between 91fce8c and 54bd257.

📒 Files selected for processing (2)
  • app/src/components/settings/__tests__/SettingsHome.test.tsx
  • app/src/pages/__tests__/Welcome.test.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/src/pages/tests/Welcome.test.tsx

📝 Walkthrough

Walkthrough

Rust now detects Windows file-lock errors and returns formatted messages during reset; frontend catch blocks display the caught error message (or a fallback when absent); unit and UI tests added/updated to assert the specific and fallback messages.

Changes

Data Clearing Error Messages

Layer / File(s) Summary
Windows file-lock detection and error message helpers
src/openhuman/config/ops.rs
New private helpers detect Windows file-lock error codes and format two distinct user-facing error messages for locked directory deletion and locked workspace marker removal.
Reset flow integration with error detection
src/openhuman/config/ops.rs
The reset_local_data_for_paths function uses the new helpers to return specific messages when workspace marker removal or local data directory deletion fail due to Windows file locks.
Windows file-lock error message testing
src/openhuman/config/ops_tests.rs
Windows-gated unit test verifies reset_local_data_remove_error returns a locked-file message instructing the user to close all OpenHuman windows and retry.
React component error message handling
app/src/components/settings/SettingsHome.tsx, app/src/pages/Welcome.tsx, app/src/components/settings/__tests__/SettingsHome.test.tsx, app/src/pages/__tests__/Welcome.test.tsx
Frontend catch blocks now derive display text from the caught error (err.message or String(err)), with tests asserting both the specific backend message and the generic fallback when the error has no message.

Sequence Diagram

sequenceDiagram
  participant WelcomePage
  participant SettingsHome
  participant reset_local_data_for_paths as ops.rs::reset_local_data_for_paths
  participant Filesystem
  WelcomePage->>reset_local_data_for_paths: request clearAllAppData / reset
  SettingsHome->>reset_local_data_for_paths: request logout & clear data
  reset_local_data_for_paths->>Filesystem: remove active workspace marker / delete local directories
  Filesystem-->>reset_local_data_for_paths: Err (locked file on Windows)
  reset_local_data_for_paths-->>SettingsHome: Err(formatted locked-file message)
  reset_local_data_for_paths-->>WelcomePage: Err(formatted locked-file message)
  SettingsHome-->>User: display error message
  WelcomePage-->>User: display error message
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Poem

🐰 I hopped through code to find the snag,
Windows locks no longer hide the flag,
From Rust to React I carried the word,
Clear messages now can be heard,
Close windows, retry — that’s my wag.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately summarizes the main change: improving error guidance for Windows file-lock errors during local data reset operations.
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.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

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/config/ops_tests.rs (1)

118-122: 💤 Low value

Consider testing both Windows error codes.

The test verifies error code 32 (sharing violation) but not error code 33 (lock violation), even though is_windows_file_lock_error checks for both codes. Consider adding a test case for error code 33 to ensure complete coverage of the Windows file-lock detection logic.

🧪 Suggested additional test case
#[cfg(windows)]
#[test]
fn reset_local_data_remove_error_explains_windows_lock_violation() {
    let err = std::io::Error::from_raw_os_error(33);
    let msg = reset_local_data_remove_error(
        std::path::Path::new("C:\\Users\\me\\.openhuman"),
        &err,
    );

    assert!(msg.contains("locked by another OpenHuman window or process"));
    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 `@src/openhuman/config/ops_tests.rs` around lines 118 - 122, Add a second
Windows-only test that mirrors the existing sharing-violation case but uses
std::io::Error::from_raw_os_error(33) to exercise the lock-violation branch;
call reset_local_data_remove_error with the same Path (e.g.
Path::new("C:\\Users\\me\\.openhuman")) and assert the returned message contains
the same guidance strings ("locked by another OpenHuman window or process" and
"Close all OpenHuman windows and try again") so is_windows_file_lock_error and
reset_local_data_remove_error are fully covered for both error codes.
🤖 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/config/ops_tests.rs`:
- Around line 115-126: The test function
reset_local_data_remove_error_explains_windows_file_locks (and surrounding code
in src/openhuman/config/ops_tests.rs) fails rustfmt; run rustfmt (cargo fmt
--all) or apply rustfmt style changes to this file so the function and
attributes match project formatting conventions, then re-run cargo fmt --check;
ensure the #[cfg(windows)] and #[test] attributes and the function body for
reset_local_data_remove_error_explains_windows_file_locks are formatted
consistently with other tests and the reset_local_data_remove_error usage
remains unchanged.

---

Nitpick comments:
In `@src/openhuman/config/ops_tests.rs`:
- Around line 118-122: Add a second Windows-only test that mirrors the existing
sharing-violation case but uses std::io::Error::from_raw_os_error(33) to
exercise the lock-violation branch; call reset_local_data_remove_error with the
same Path (e.g. Path::new("C:\\Users\\me\\.openhuman")) and assert the returned
message contains the same guidance strings ("locked by another OpenHuman window
or process" and "Close all OpenHuman windows and try again") so
is_windows_file_lock_error and reset_local_data_remove_error are fully covered
for both error codes.
🪄 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: 7b77b938-77d6-4961-9a49-2548a3af2fcc

📥 Commits

Reviewing files that changed from the base of the PR and between e7c2eb7 and 70b24b5.

📒 Files selected for processing (5)
  • app/src/components/settings/SettingsHome.tsx
  • app/src/pages/Welcome.tsx
  • app/src/pages/__tests__/Welcome.test.tsx
  • src/openhuman/config/ops.rs
  • src/openhuman/config/ops_tests.rs

Comment thread src/openhuman/config/ops_tests.rs
@Yong-yuan-X Yong-yuan-X force-pushed the fix/windows-reset-local-data-guidance branch from 70b24b5 to 719d9bd Compare May 15, 2026 12:32
coderabbitai[bot]
coderabbitai Bot previously approved these changes May 15, 2026
@senamakel senamakel self-assigned this May 16, 2026
# Conflicts:
#	app/src/components/settings/SettingsHome.tsx
coderabbitai[bot]
coderabbitai Bot previously approved these changes May 16, 2026
…earAllAppData

Adds tests so the new error-surfacing branches in SettingsHome and Welcome
clear the 80% diff-coverage gate:
- SettingsHome: rejects with Windows file-lock message + empty Error fallback.
- Welcome: empty Error falls back to the generic guidance string.
@senamakel senamakel merged commit 159c0aa into tinyhumansai:main May 16, 2026
24 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.

2 participants