Skip to content

perf: refactor canvas interaction foundations#123

Merged
dompm merged 7 commits into
mainfrom
codex/interaction-performance
Jul 16, 2026
Merged

perf: refactor canvas interaction foundations#123
dompm merged 7 commits into
mainfrom
codex/interaction-performance

Conversation

@dompm

@dompm dompm commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary

Implements phases 0–3 of the interaction-performance plan:

  • adds deterministic interaction fixtures and behavior baselines
  • caches derived piece geometry and memoizes canvas piece rendering
  • separates stable canvas content from transient interaction layers
  • previews piece drag/rotation transforms outside durable project state
  • commits a complete transform once per gesture for coherent undo and autosave behavior

Why

High-frequency pointer interactions currently rebuild project state, rerender broad React/Konva trees, and recompute polygon geometry. These foundations isolate transient work while preserving the existing project schema and editor behavior.

Validation

  • pnpm test:interaction: 14 tests pass
  • production build succeeds
  • the real app type-check has the same eight pre-existing errors recorded in the performance baseline; this branch adds no new errors

Status

Draft: phases 0–3 are implemented. Review findings will be added inline before phase 4 begins.

@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: 4d7eda5
Status: ✅  Deploy successful!
Preview URL: https://eee990e1.vitrai.pages.dev
Branch Preview URL: https://codex-interaction-performanc.vitrai.pages.dev

View logs

Comment thread frontend/src/editor/performance/fixtures.ts
Comment thread frontend/src/editor/interaction/pieceTransformPreviewStore.ts
Comment thread frontend/src/components/ResultPanel.tsx
@dompm

dompm commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

Quick review of phases 0–3:

  • 14/14 interaction tests pass
  • production build succeeds
  • the real app type-check has the same eight pre-existing errors and no new ones
  • architecture is directionally solid

I would fix the two P1 behavior issues and close the Phase 0 fixture/coverage gap noted inline before starting phase 4.

@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.

Follow-up review: the earlier compositing issue is not fully resolved.

  • [P1] Preserve the debug-mask backdrop. globalCompositeOperation="difference" only composites against pixels in the same Konva Layer. The mask now shares the piece layer, but the paper and pattern image remain in the background layer. Before the split, background, pattern, pieces, and mask were in one canvas, so the visible Box/debug preview is still behaviorally different. Please use a combined/offscreen composition while the mask is active, or another implementation that preserves the original assembled backdrop.

The fixture and no-op transform fixes from the earlier review look good.

@dompm
dompm force-pushed the codex/interaction-performance branch from 1d00b43 to 30bc4d5 Compare July 16, 2026 16:19
* 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
dompm marked this pull request as ready for review July 16, 2026 16:50
@dompm
dompm merged commit 6097408 into main Jul 16, 2026
2 checks passed
@dompm
dompm deleted the codex/interaction-performance branch July 16, 2026 16:51
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