Skip to content

Record paste and surface creation as append patches - #362

Draft
nabeya11 wants to merge 5 commits into
perf/patch-labelfrom
perf/patch-append
Draft

Record paste and surface creation as append patches#362
nabeya11 wants to merge 5 commits into
perf/patch-labelfrom
perf/patch-append

Conversation

@nabeya11

Copy link
Copy Markdown
Member

Changes

Paste and surface creation (merge) now append to the cloud in place and record a patch holding only the previous point count, width and height. Undo just truncates back to the previous count.

  • oldWidth / oldHeight are recorded because merge flattens the cloud to W=points, H=1; undo restores the organized shape as well.
  • Introduces newCloudView: pcgol caches an unsafe float32 alias of Data validated only by its base pointer, so an operation that changes the length of Data must return a fresh PointCloud sharing the same backing array (otherwise a stale view remains and causes out-of-range access).

merge now appends to the existing cloud in place and records only the
previous point count, instead of cloning the whole cloud and keeping a
snapshot. The result is delivered via a fresh PointCloud (newCloudView)
because pcgol caches an unsafe float32 alias of Data keyed by its base
pointer, which goes stale when the slice length changes in place.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.49%. Comparing base (b964e52) to head (44b4edf).

Files with missing lines Patch % Lines
patch.go 86.20% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@                 Coverage Diff                  @@
##           perf/patch-label     #362      +/-   ##
====================================================
+ Coverage             45.86%   46.49%   +0.62%     
====================================================
  Files                     9        9              
  Lines                  1598     1624      +26     
====================================================
+ Hits                    733      755      +22     
- Misses                  813      815       +2     
- Partials                 52       54       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI 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.

Pull request overview

This PR changes how paste and surface creation (“merge”) operations are recorded for undo: instead of storing a full replacement snapshot of the previous cloud, it appends points in-place and records a minimal “append patch” containing only the prior point count and organized dimensions, with undo implemented as a truncation back to the prior count (restoring width/height as well). It also introduces a helper to return a fresh *pc.PointCloud view when the underlying Data slice length changes, to avoid stale cached unsafe views in pcgol.

Changes:

  • Add appendPatch to record pre-append (Points, Width, Height) and revert by truncating Data.
  • Add newCloudView to produce a fresh *pc.PointCloud when Data length changes.
  • Update editor.merge to push appendPatch and use newCloudView; extend tests to cover append patch revert and encode/decode round-trip.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
patch.go Adds newCloudView, introduces appendPatch, and extends patch decoding to support append patches.
patch_test.go Adds unit test coverage for appendPatch revert and encode/decode round-trip.
editor.go Updates merge to record append-only undo state and refresh the point cloud view after appending.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread patch.go
The decoded oldPoints could turn negative on an int width smaller than
64 bits and slip through the bounds checks into a negative slice bound.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Copilot AI 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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread patch.go
Rewrite the data bound in a division form matching the other guards
and reject negative width/height, so the checks hold on any int width
without relying on evaluation order.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Copilot AI 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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread patch.go
nabeya11 and others added 2 commits August 22, 2026 22:10
Adapt appendPatch to the encodeHead/payload interface.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A corrupted replacePatch can restore a cloud whose decoded header
yields a zero stride; the division in the bounds check then panicked
instead of returning errBrokenPatch on the following undo.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Copilot AI 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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

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