Skip to content

perf: index Pen snapping with reference parity#127

Merged
dompm merged 5 commits into
codex/interaction-viewportfrom
codex/interaction-snap-index
Jul 16, 2026
Merged

perf: index Pen snapping with reference parity#127
dompm merged 5 commits into
codex/interaction-viewportfrom
codex/interaction-snap-index

Conversation

@dompm

@dompm dompm commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • build cached Pen vertex and segment indexes from immutable piece geometry
  • use sorted X/Y ranges for vertex and alignment snapping
  • use cached vertices and exact-coordinate adjacency for Shift and equal-length queries
  • add randomized parity coverage across 6, 24, and 96 vertices

Why

Steady Pen movement should not repeatedly flatten every piece or scan unrelated geometry.

Stack

Depends on #126 (codex/interaction-viewport).

Verification

  • 25 interaction tests pass
  • randomized snap checks pass at 6, 24, and 96 vertices
  • production build succeeds
  • no new TypeScript errors beyond the documented baseline

This is a draft pending performance review and browser regression testing.

@dompm dompm left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

The index removes steady-state curve flattening and the randomized vertex/alignment checks pass, but equal-length parity still has an uncovered ordering regression.

  • [P1] Preserve project piece order in equal-length queries. The reference implementation appends qualifying piece segments in pieces order, but queryLengthSnap populates its Set in active-draft-point order. If an earlier draft point touches later project piece B and a later point touches earlier piece A, B is queried first. With A offering length 10, B length 20, and a current length of 15, the reference chooses 10 while the index chooses 20. Collect membership first, then iterate qualifying piece indexes in project order.
  • The randomized parity suite does not call queryLengthSnap; it covers vertex, ordinary alignment, and Shift alignment only. Add fixed and randomized equal-length parity cases, including equal-distance ties and reversed active-point/project-piece ordering.

Cached linear Shift alignment is permitted by the plan, so its full vertex scan is not itself a blocker unless tracing shows it is material.

@dompm
dompm force-pushed the codex/interaction-snap-index branch from fe8b6bf to fc18b9c Compare July 13, 2026 19:22
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 13, 2026

Copy link
Copy Markdown

Deploying vitrai with  Cloudflare Pages  Cloudflare Pages

Latest commit: df25762
Status: ✅  Deploy successful!
Preview URL: https://b934e987.vitrai.pages.dev
Branch Preview URL: https://codex-interaction-snap-index.vitrai.pages.dev

View logs

@dompm
dompm force-pushed the codex/interaction-viewport branch from 83635dd to a5d83ce Compare July 13, 2026 19:22
@dompm
dompm force-pushed the codex/interaction-snap-index branch from fc18b9c to 2fc10c5 Compare July 13, 2026 19:44

@dompm dompm left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

The project-order fix is correct and the reversed active-point regression now passes.

  • [P2] Complete the requested randomized equal-length parity coverage. The randomized loop still exercises only vertex, ordinary alignment, and Shift alignment. queryLengthSnap is compared with the reference in one fixed case only. Add randomized active drafts that touch multiple pieces in varying order, including ties, and compare queryLengthSnap with findLengthSnap across the 6/24/96-vertex fixtures before calling the full snap parity run complete.

@dompm
dompm force-pushed the codex/interaction-viewport branch from 54ca1ee to aae8e12 Compare July 13, 2026 20:00
@dompm
dompm force-pushed the codex/interaction-snap-index branch 2 times, most recently from 300790c to 75c469a Compare July 16, 2026 15:08
@dompm
dompm force-pushed the codex/interaction-snap-index branch from 75c469a to df25762 Compare July 16, 2026 16:19
@dompm
dompm force-pushed the codex/interaction-viewport branch from d4f3d28 to 289779c Compare July 16, 2026 16:19
@dompm
dompm marked this pull request as ready for review July 16, 2026 16:47
@dompm
dompm merged commit 138e0a3 into codex/interaction-viewport Jul 16, 2026
3 checks passed
@dompm
dompm deleted the codex/interaction-snap-index branch July 16, 2026 16:47
dompm added a commit that referenced this pull request Jul 16, 2026
* perf: frame-limit viewport gesture publication

* perf: move viewport gestures into focused store subscribers

* perf: narrow viewport subscriptions around stable canvas children

* perf: keep glass pieces idle during pan

* perf: index Pen snapping with reference parity (#127)

* perf: index pen snapping with reference parity

* perf: cache shift-alignment snap queries

* fix: preserve project order in length snapping

* test: randomize equal-length snap parity

* fix: preserve current snapping behavior on indexed path
dompm added a commit that referenced this pull request Jul 16, 2026
* perf: frame-limit pen and pencil interaction controllers

* fix: refresh and cancel scheduled pen previews

* perf: isolate pen preview from result panel

* perf: isolate pen status from app state

* perf: frame-limit viewport gesture publication (#126)

* perf: frame-limit viewport gesture publication

* perf: move viewport gestures into focused store subscribers

* perf: narrow viewport subscriptions around stable canvas children

* perf: keep glass pieces idle during pan

* perf: index Pen snapping with reference parity (#127)

* perf: index pen snapping with reference parity

* perf: cache shift-alignment snap queries

* fix: preserve project order in length snapping

* test: randomize equal-length snap parity

* fix: preserve current snapping behavior on indexed path
dompm added a commit that referenced this pull request Jul 16, 2026
* perf: add interaction fixtures and behavior baselines

* perf: cache piece geometry and memoize canvas pieces

* perf: isolate stable and interaction canvas layers

* perf: preview piece transforms outside project state

* fix: address interaction foundation review feedback

* fix: preserve debug mask composition backdrop

* perf: frame-limit Pen and Pencil interactions (#125)

* perf: frame-limit pen and pencil interaction controllers

* fix: refresh and cancel scheduled pen previews

* perf: isolate pen preview from result panel

* perf: isolate pen status from app state

* perf: frame-limit viewport gesture publication (#126)

* perf: frame-limit viewport gesture publication

* perf: move viewport gestures into focused store subscribers

* perf: narrow viewport subscriptions around stable canvas children

* perf: keep glass pieces idle during pan

* perf: index Pen snapping with reference parity (#127)

* perf: index pen snapping with reference parity

* perf: cache shift-alignment snap queries

* fix: preserve project order in length snapping

* test: randomize equal-length snap parity

* fix: preserve current snapping behavior on indexed path
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.

1 participant