Repository navigation
feat: implement cleanBlocks utility and integrate into doc and descri… - #132
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a cleanBlocks utility to normalize BlockNote JSON by stripping block-level id fields (recursively through children) and integrates that normalization into task description + document editor change detection, along with optimizing task updates to avoid sending unchanged fields.
Changes:
- Added
cleanBlocksto strip ephemeral blockids for stable comparisons. - Updated Doc editor + task description editor to compare against cleaned content and added readiness/dirty guards to reduce redundant saves.
- Updated task update mutation to filter out unchanged fields, with special handling for
tags,custom_fields, anddescription.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/web/src/lib/utils.ts | Adds cleanBlocks utility for block normalization (strip block ids recursively). |
| apps/web/src/lib/utils.test.ts | Adds unit tests validating cleanBlocks behavior. |
| apps/web/src/components/projects/interactions/task-detail/index.tsx | Filters update payload to only send meaningful changes; uses cleanBlocks for description diffing. |
| apps/web/src/components/projects/interactions/task-detail/description-section.tsx | Uses cleanBlocks in save/compare flow and adds editor readiness guard. |
| apps/web/src/components/projects/docs/doc-editor.tsx | Uses cleanBlocks in save/compare flow and adds dirty tracking to avoid unnecessary saves. |
Comments suppressed due to low confidence (1)
apps/web/src/components/projects/interactions/task-detail/index.tsx:180
- The comparison uses
cleanBlocks(...)but the actual update payload uses the un-sanitizednewValue. If the goal is to persist content without ephemeral blockids (as described in the PR), consider sendingcleanBlocks(newValue ?? null)asfiltered.descriptionso the backend stores the sanitized form too (not just the comparison string).
if (aClean !== bClean) {
filtered.description = newValue as unknown[] | null;
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
This pull request introduces a new utility function,
cleanBlocks, to standardize and sanitize block data by recursively removingidfields before saving or comparing content in project documentation and task descriptions. The change ensures that block data is compared and persisted based on meaningful content rather than ephemeral identifiers, reducing unnecessary updates and improving data consistency. The update also introduces tests for the new utility and refines the logic for detecting and saving changes in editors.Block data sanitization and consistency:
cleanBlocksutility inutils.tsto recursively removeidfields from block objects, and updated all relevant code paths to use this function when saving or comparing block content in both the document editor and task description editor. [1] [2] [3] [4] [5] [6] [7]Editor state management improvements:
dirtyRefandreadyRefflags to ensure that saves only occur when there are actual changes and the editor is ready, preventing unnecessary saves and race conditions. [1] [2] [3] [4] [5] [6]Task update optimization:
cleanBlocksfor block data), ensuring that only meaningful changes trigger updates to the backend. [1] [2]Testing:
cleanBlocksto verify correct behavior, including recursive removal ofidfields and preservation of other properties. [1] [2]