Skip to content

fix: [BUG] Some notes never exit "modified" status#77

Merged
phernandez merged 4 commits into
mainfrom
fix-issue-72-20250405023851
Apr 6, 2025
Merged

fix: [BUG] Some notes never exit "modified" status#77
phernandez merged 4 commits into
mainfrom
fix-issue-72-20250405023851

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented Apr 5, 2025

This PR fixes issue #72

Changes Summary

I fixed Issue #72 where notes with wikilinks stayed in "modified" status after syncing. The problem was that after processing relations in files with wikilinks, the final checksum wasn't being accurately computed and saved, causing false "modified" status on subsequent syncs.

Changes made:

  1. Created a new test file (tests/sync/test_sync_wikilink_issue.py) that reproduces the issue with notes containing wikilinks staying in modified status.

  2. Fixed the sync_markdown_file method in src/basic_memory/sync/sync_service.py:

    • Added computation of a final checksum after relation processing is complete
    • Updated the entity record with this final checksum
    • Enhanced logging to include the checksum in the completion message
    • Ensured the final checksum is returned from the method

The fix ensures that after relations between files are established and updated, the final file state is properly captured in the checksum, preventing false "modified" status in subsequent syncs. This issue was particularly noticeable when importing existing notes with wikilinks from other vaults, as mentioned in the bug report.

Original Issue

Bug Description

Some notes never seem to exit "Modified" status, even if sync occurs when file has not been modified.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Install version 0.11.0 (Occurred in 0.10.1 as well)
  2. Run command basic-memory sync or sync --verbose or status
  3. Note is in "modified" status
  4. Edit note and re-sync
  5. Note again in "modified" status
  6. Sync again without changing note, note still in "modified" status

Expected Behavior

If note hasn't changed, should no longer be listed as modified.

Actual Behavior

Described above. Note that hash value in verbose sync does not change.

Environment

  • OS: Windows 11 Insider Preview 10.0.26120.3585
  • Python version: 3.13.2
  • Basic Memory version: [e.g. 0.11.0]
  • Installation method: uv (version 0.6.8 (c1ef48276 2025-03-18))
  • Claude Desktop version (if applicable): 0.9.0

Additional Context

Initially I thought it was to do with the file encoding (line endings being either LF or CR LF) but that didn't seem to matter. I've chased it down to having something to do with a wikilink. If the note is synced with a pre-existing link (ie, the note is pasted or moved into the vault from another vault, regardless of whether the wikilinks point to an existing note or not), it can stay at Modified. If that link is removed, the note is synced, and then sync is run again, it gets removed from the status/sync Modified list. If the wikilink is then returned to the file, it shows up as modified at first sync, then when sync is run again, it disappears.

I tried the remove/re-add links to a template, and the remove/re-add doesn't fix the inclusion in the sync Modified list.

Possible Solution

No clue, sadly. Feels random.


🤖 Generated with Claude Code GitHub Action

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 5, 2025

CLA assistant check
All committers have signed the CLA.

Claude Code Bot and others added 2 commits April 5, 2025 19:35
Automated fix generated by Claude Code based on issue analysis.

---
🤖 Generated with Claude Code GitHub Action

Signed-off-by: phernandez <paul@basicmachines.co>
Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez phernandez force-pushed the fix-issue-72-20250405023851 branch from 0ac6698 to eab4331 Compare April 6, 2025 00:35
@phernandez phernandez changed the title Fix: [BUG] Some notes never exit "modified" status fix: [BUG] Some notes never exit "modified" status Apr 6, 2025
@phernandez phernandez merged commit 7930ddb into main Apr 6, 2025
8 checks passed
@phernandez phernandez deleted the fix-issue-72-20250405023851 branch April 6, 2025 03:03
phernandez pushed a commit that referenced this pull request Apr 6, 2025
Signed-off-by: phernandez <paul@basicmachines.co>
@claude claude Bot mentioned this pull request Jul 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants