Skip to content

itemsync: Fix GUI freeze when removing all items and on startup - #3629

Merged
hluk merged 1 commit into
masterfrom
fix-sync-stuck
Jun 9, 2026
Merged

hluk merged 1 commit into
masterfrom
fix-sync-stuck

Conversation

@hluk

@hluk hluk commented Jun 5, 2026

Copy link
Copy Markdown
Owner

Batch the duplicate-baseName check when removing items so the model is scanned once instead of once per removed row, reducing O(NÂē) to O(N+M).

Skip file-open retries (with sleep) for read-only operations; transient failures are handled by the file watcher on the next cycle. This prevents accumulated sleep time from freezing the UI on startup after a crash.

Always log a warning when a sync file cannot be opened for reading.

Assisted-by: Claude (Anthropic)

@hluk
hluk force-pushed the fix-sync-stuck branch from 8b0a6b4 to 4ea2e2d Compare June 5, 2026 07:23
@codecov

codecov Bot commented Jun 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 64.40678% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.36%. Comparing base (00435bb) to head (cc9f15f).
⚠ïļ Report is 47 commits behind head on master.

Files with missing lines Patch % Lines
plugins/itemsync/filewatcher.cpp 63.79% 21 Missing ⚠ïļ

❌ Your patch status has failed because the patch coverage (64.40%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3629      +/-   ##
==========================================
- Coverage   74.44%   74.36%   -0.09%     
==========================================
  Files         253      253              
  Lines       37916    37912       -4     
  Branches     5120     5114       -6     
==========================================
- Hits        28228    28192      -36     
- Misses       9688     9720      +32     

☔ View full report in Codecov by Harness.
ðŸ“Ē Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄ïļ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • ðŸ“Ķ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hluk
hluk force-pushed the fix-sync-stuck branch 4 times, most recently from dc24a6c to d378869 Compare June 9, 2026 17:30
@hluk
hluk requested a review from Copilot June 9, 2026 18:00

Copilot AI left a comment

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.

Pull request overview

This PR aims to prevent UI freezes in the ItemSync plugin by reducing expensive per-row work during item removal and by avoiding retry/sleep loops for read-only file opens (letting the file watcher handle transient failures on the next cycle).

Changes:

  • Added a regression test covering reading a large (lazy-loaded) item after its backing file is deleted.
  • Reworked file-operation retry handling to allow zero-retry read-only opens and improved logging for read-open failures.
  • Introduced a batched API to remove files for multiple removed indexes in one call.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/tests/itemsynctests.h Declares a new ItemSync test slot.
src/tests/itemsynctests.cpp Adds a regression test for reading a large item after its backing file is deleted.
plugins/itemsync/itemsync.cpp Switches item-removal cleanup to a batched file-removal helper.
plugins/itemsync/filewatcher.h Replaces single-index removal API with a multi-index variant (optional own-only filtering).
plugins/itemsync/filewatcher.cpp Adjusts retry semantics for read-only operations, centralizes read-open failure logging, and batches file removal for removed indexes.

ðŸ’Ą Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plugins/itemsync/filewatcher.cpp Outdated
Comment thread plugins/itemsync/filewatcher.cpp
@hluk
hluk force-pushed the fix-sync-stuck branch from d378869 to 7b5539d Compare June 9, 2026 18:13
Batch the duplicate-baseName check when removing items so the model is
scanned once instead of once per removed row, reducing O(NÂē) to O(N+M).

Skip file-open retries (with sleep) for read-only operations; transient
failures are handled by the file watcher on the next cycle. This prevents
accumulated sleep time from freezing the UI on startup after a crash.

Log a warning when a sync file exists but cannot be opened for reading;
use debug level when the file was simply deleted (normal sync operation).

Assisted-by: Claude (Anthropic)
@hluk
hluk force-pushed the fix-sync-stuck branch from 7b5539d to cc9f15f Compare June 9, 2026 18:41
@hluk
hluk merged commit 3d3ca2c into master Jun 9, 2026
11 of 13 checks passed
@hluk
hluk deleted the fix-sync-stuck branch June 9, 2026 19:04
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