Fix Bear app not detecting note changes from CLI#6
Merged
Conversation
Extract BearCLICore library and add test infrastructure
CloudKit's records/lookup endpoint can return records without a "fields" key (e.g. not-found or deleted records), causing a keyNotFound decoding error. This adds a custom Decodable init that defaults fields to an empty dictionary, and filters out fieldless records from lookupRecords so the get command correctly falls through to uniqueIdentifier search. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…rd-lookup Fix crash when CloudKit returns records without fields
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Swift's padding(toLength:) truncates strings longer than the target length. CloudKit record names can exceed 36 characters, so the hardcoded 38-column width was silently chopping IDs. Compute the column width dynamically from the actual data instead.
Fix truncated record IDs in table output
The modified record-level metadata was passing through the old timestamp from the original record, causing CloudKit to not recognize the update. Now uses the current timestamp for the modified metadata in both updateNote() and trashNote(). Also bumps version to 0.3.3.
Fix modification date not updating after note edit
Two issues prevented Bear from recognizing edits made via the CLI: 1. Vector clock was being replaced instead of updated - incrementVectorClock created a new clock with only "Bear CLI", discarding all other device entries. Bear uses the vector clock to track changes across devices, so losing entries caused it to misinterpret the update. Now uses PropertyListSerialization to properly parse, preserve all device entries, and only increment the "Bear CLI" counter. 2. Text asset field not cleared on edit - when a note stored its content as an external asset (text field with downloadURL), the CLI wrote new content to textADP but left the old asset reference intact. Bear may read from the asset instead of textADP. Now explicitly sets text to null on update. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
asabirov
pushed a commit
that referenced
this pull request
Apr 8, 2026
Fix vector clock to preserve all device entries on update
asabirov
added a commit
that referenced
this pull request
Apr 8, 2026
Add null text field to edit record to trigger Bear desktop sync detection. Keep upstream's vector clock byte-scanning approach. (reimplements PR #6)
asabirov
added a commit
that referenced
this pull request
Apr 8, 2026
Add null text field to edit record to trigger Bear desktop sync detection. Keep upstream's vector clock byte-scanning approach. (reimplements PR #6)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
incrementVectorClocknow usesPropertyListSerializationto properly parse and update the bplist, preserving all existing device entries instead of replacing them with only "Bear CLI". This lets Bear correctly detect the note as modified.textADP, thetextasset field is now set to null so Bear doesn't read stale content from the old asset URL.Test plan
bcli editand verify Bear app shows the updated content after sync