fix: Adjust metadata ID resolution order in Deepnote data handling#338
fix: Adjust metadata ID resolution order in Deepnote data handling#338
Conversation
Updated the order of ID resolution in the DeepnoteDataConverter, DeepnoteFileChangeWatcher, and Pocket modules to prioritize '__deepnoteBlockId' over 'id'. Added a test to ensure updates are not applied when cells lack block IDs and no fallback is available.
📝 WalkthroughWalkthroughReorders block ID resolution to prefer Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #338 +/- ##
===========================
===========================
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/notebooks/deepnote/deepnoteFileChangeWatcher.unit.test.ts`:
- Around line 1071-1074: Replace the fixed sleep after snapshotOnDidChange.fire
by waiting deterministically for the condition that readSnapshotCallCount
increments: instead of await new Promise(resolve => setTimeout(...)), create a
Promise that resolves when readSnapshotCallCount >= 1 (either by subscribing to
the same observable/event that triggers the read, attaching a one-time listener,
or polling readSnapshotCallCount with a short interval and overall timeout) and
await that; target the test logic around snapshotOnDidChange.fire,
debounceWaitMs and the readSnapshotCallCount assertion so the test no longer
relies on a fixed delay.
ℹ️ Review info
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (4)
src/notebooks/deepnote/deepnoteDataConverter.tssrc/notebooks/deepnote/deepnoteFileChangeWatcher.tssrc/notebooks/deepnote/deepnoteFileChangeWatcher.unit.test.tssrc/platform/deepnote/pocket.ts
… tests Replaced the setTimeout with a waitFor function to ensure that readSnapshot is called at least once after the snapshot change event is fired. This improves the reliability of the test by directly waiting for the expected condition.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/notebooks/deepnote/deepnoteFileChangeWatcher.unit.test.ts`:
- Around line 1055-1081: The test needs a short grace period after the waitFor
to mirror existing patterns and avoid flakiness: after the existing waitFor(()
=> readSnapshotCallCount >= 1) call, add a delay using the shared
autoSaveGraceMs value (or await a helper that waits that duration) before
asserting snapshotApplyEditCount is 0; this should be applied in the test using
the same symbols used in the file (waitFor, autoSaveGraceMs,
snapshotOnDidChange, readSnapshotCallCount, snapshotApplyEditCount) so the
assertion that applyEdit was not called runs only after the grace period.
ℹ️ Review info
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
src/notebooks/deepnote/deepnoteFileChangeWatcher.unit.test.ts
Updated the order of ID resolution in the DeepnoteDataConverter, DeepnoteFileChangeWatcher, and Pocket modules to prioritize '__deepnoteBlockId' over 'id'. Added a test to ensure updates are not applied when cells lack block IDs and no fallback is available.
So the problem is that VS Code's live cells have lost their original metadata.id. Let me trace exactly how getBlockIdFromMetadata resolves block IDs from live cells. The IDs come from cell.metadata, which VS Code manages internally. VS Code is known to overwrite metadata.id with its own internal cell ID.
Summary by CodeRabbit
Bug Fixes
Tests