Skip to content

feat: implement cleanBlocks utility and integrate into doc and descri… - #132

Merged
pikann merged 5 commits into
masterfrom
feature/enhance-updating-workflow
May 22, 2026
Merged

pikann merged 5 commits into
masterfrom
feature/enhance-updating-workflow

Conversation

@pikann

@pikann pikann commented May 22, 2026

Copy link
Copy Markdown
Contributor

This pull request introduces a new utility function, cleanBlocks, to standardize and sanitize block data by recursively removing id fields 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:

  • Added the cleanBlocks utility in utils.ts to recursively remove id fields 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:

  • Improved editor state tracking by adding dirtyRef and readyRef flags 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:

  • Enhanced the task update mutation to filter out unchanged fields (including using cleanBlocks for block data), ensuring that only meaningful changes trigger updates to the backend. [1] [2]

Testing:

  • Added comprehensive unit tests for cleanBlocks to verify correct behavior, including recursive removal of id fields and preservation of other properties. [1] [2]

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 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 cleanBlocks to strip ephemeral block ids 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, and description.

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-sanitized newValue. If the goal is to persist content without ephemeral block ids (as described in the PR), consider sending cleanBlocks(newValue ?? null) as filtered.description so 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.

Comment thread apps/web/src/lib/utils.ts Resolved
Copilot finished work on behalf of pikann May 22, 2026 04:36
Copilot finished work on behalf of pikann May 22, 2026 04:38
Copilot finished work on behalf of pikann May 22, 2026 04:38
Copilot finished work on behalf of pikann May 22, 2026 04:39
@pikann
pikann merged commit d94f3d0 into master May 22, 2026
1 check passed
@pikann
pikann deleted the feature/enhance-updating-workflow branch May 22, 2026 06:18
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.

3 participants