Skip to content

feat: maintain field-lock information on the Visual Builder canvas#625

Merged
SahilCs15 merged 2 commits into
ce-auto-draft-lpfrom
feat/canvas-field-lock
Jul 24, 2026
Merged

feat: maintain field-lock information on the Visual Builder canvas#625
SahilCs15 merged 2 commits into
ce-auto-draft-lpfrom
feat/canvas-field-lock

Conversation

@SahilCs15

Copy link
Copy Markdown
Contributor

What

When two people edit the same entry, a field one of them is editing now shows as locked to the other on the canvas, and cannot be edited until they move off it. The lock clears when the peer deselects the field, navigates away, or disconnects.

How

The canvas keeps a read-only mirror of the parent's lock state per entry and paints the locked state on hover, reusing the existing field-disabled treatment (dashed outline, cursor, label, and the editor's avatar). Trying to edit a locked field is blocked before the inline editor opens.

The mirror stays fresh through an initial snapshot and live updates from the parent, with a retry when a fetch fails, a guard so a stale snapshot cannot overwrite a newer update, and a subscription so the locked state re-renders the moment it changes.

Testing

Unit tests cover lock resolution, the mirror, the snapshot exchange, the hover and click handling, and the field label. Run with npm test.

🤖 Generated with Claude Code

@SahilCs15
SahilCs15 requested a review from a team as a code owner July 21, 2026 19:55
@github-actions

Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 0 0 25 ✅ Passed
🟡 Medium Severity 0 0 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

✅ BUILD PASSED - All security checks passed

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 68.17% 2637 / 3868
🔵 Statements 67.04% 2679 / 3996
🔵 Functions 65.73% 472 / 718
🔵 Branches 63.01% 1629 / 2585
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/visualBuilder/index.ts 53.73% 26.76% 31.25% 53.73% 114-117, 122-131, 137-207, 215-248, 258-279, 336-338, 342, 396-399, 104-110
src/visualBuilder/visualBuilder.style.ts 100% 100% 100% 100%
src/visualBuilder/components/VisualBuilder.tsx 100% 100% 100% 100%
src/visualBuilder/components/fieldLabelWrapper.tsx 67.21% 68.46% 72% 68.64% 50-51, 60-61, 109-112, 146-156, 176-178, 237, 323-332, 377-380, 385-412, 455, 460-463, 628
src/visualBuilder/eventManager/useEntryLockInfoUpdateEvent.ts 100% 50% 100% 100%
src/visualBuilder/generators/generateLockAvatar.tsx 100% 83.33% 100% 100%
src/visualBuilder/listeners/mouseClick.ts 81.39% 79.04% 70.58% 83.2% 63, 76, 109-112, 121, 155, 167, 177-178, 192, 232-235, 251, 297, 324, 335, 395-400, 442-447, 466-474
src/visualBuilder/listeners/mouseHover.ts 63.8% 51.96% 56.52% 66.23% 58-63, 81, 91, 113, 143, 167-176, 192-200, 207, 215-223, 232, 244, 254-271, 279-280, 283-328, 350-353, 369-370, 375-378, 380-381, 464, 471, 502
src/visualBuilder/utils/fetchEntryPermissionsAndStageDetails.ts 0% 0% 0% 0% 22-80
src/visualBuilder/utils/fieldLockIndicator.ts 74.19% 80.95% 75% 75% 46, 93-103
src/visualBuilder/utils/fieldLockStore.ts 95.23% 87.5% 100% 95.23% 56
src/visualBuilder/utils/getEntryLockInfo.ts 100% 100% 100% 100%
Generated in workflow #869 for commit dda647e by the Vitest Coverage Report Action

@SahilCs15
SahilCs15 force-pushed the feat/canvas-field-lock branch from 1790871 to 1c42cac Compare July 22, 2026 05:36
@github-actions

Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 0 0 25 ✅ Passed
🟡 Medium Severity 0 0 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

✅ BUILD PASSED - All security checks passed

Mirror entry field-lock state in the canvas SDK so a field a collaborator is editing shows as locked to peers and cannot be edited until they move off it. Locks resolve per entry with container propagation, the affordance reuses the field-disabled treatment, and the mirror stays in sync with the parent through a snapshot request and live updates.

Co-Authored-By: Claude <noreply@anthropic.com>
@SahilCs15
SahilCs15 force-pushed the feat/canvas-field-lock branch from 1c42cac to 99f2c6e Compare July 22, 2026 06:14
@github-actions

Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 0 0 25 ✅ Passed
🟡 Medium Severity 0 0 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

✅ BUILD PASSED - All security checks passed

Comment thread src/visualBuilder/generators/generateLockAvatar.tsx Outdated
Comment thread src/visualBuilder/listeners/mouseClick.ts Outdated
Address review feedback on the field-lock canvas work:

- generateLockAvatar: add window.scrollX to the avatar's left offset. The
  badge is positioned absolutely from getBoundingClientRect (viewport
  coordinates); top already added scrollY but left omitted scrollX, so the
  badge drifted on a horizontally scrolled canvas.
- mouseClick: run the peer-lock edit gate before sendMouseClickPostMessage.
  A click on a field locked by another user now returns before posting
  MOUSE_CLICK, so it no longer cancels the current user's own pending lock
  release. The gate is guarded by eventDetails so a genuine empty-space
  click still posts (deselect / inline-edit metadata) unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 0 0 25 ✅ Passed
🟡 Medium Severity 0 0 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

✅ BUILD PASSED - All security checks passed

@faraazb-contentstack faraazb-contentstack left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@SahilCs15
SahilCs15 merged commit d6a7253 into ce-auto-draft-lp Jul 24, 2026
9 checks passed
@SahilCs15
SahilCs15 deleted the feat/canvas-field-lock branch July 24, 2026 14:32
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.

2 participants