📚 Focus workspace transform guidance

Document preview cleanup on gesture end and unmount alongside commit
and cancellation boundaries in a directly named memory.

AI-assisted-by: gpt-6.1-terra
This commit is contained in:
Andrey Antukh 2026-11-24 09:24:07 +00:00
parent c8083b35cf
commit 381b784a0e
4 changed files with 10 additions and 23 deletions

View File

@ -14,7 +14,7 @@ Start at `app.main.ui` for Rumext components, `app.main.data` for Potok events,
- Store, refs, and interaction streams: `mem:frontend/workspace-store`.
- Local and remote commits, rebase, and undo: `mem:frontend/workspace-commits`.
- Save queue, rejected edits, retries, and recovery: `mem:frontend/workspace-state-persistence-subtleties`.
- Modifier previews, transform commits, and WASM bridge: `mem:frontend/workspace-transform-subtleties`.
- Modifier previews, transform commits, and WASM bridge: `mem:frontend/workspace-transforms`.
- Token application and propagation: `mem:frontend/workspace-token-subtleties`; token model: `mem:common/tokens-schema-subtleties`.
## App shell

View File

@ -1,7 +1,7 @@
# Workspace store and refs
- `app.main.store` owns the Potok store; `app.main.refs` provides derived refs. `emit!` dispatches and returns nil, not the result of a watch. To inspect a live stream, use `mem:frontend/cljs-repl`.
- `app.main.streams` keeps high-frequency WASM modifier and selection-rectangle previews out of the normal store to avoid ref churn; do not treat those previews as committed shape data. See `mem:frontend/workspace-transform-subtleties`.
- `app.main.streams` keeps high-frequency WASM modifier and selection-rectangle previews out of the normal store to avoid ref churn; do not treat those previews as committed shape data. See `mem:frontend/workspace-transforms`.
- Preserve page-object map identity when possible: `refs/workspace-page-objects` compares with `identical?`. Keep the selection input equality check before processing selected shapes. Prefer selecting libraries from `refs/files` with component memoization over the broad deprecated `refs/libraries`.
- Keyboard modifier state must clear on window blur. Focus mode tracks added and removed objects as the page changes; exit when none remain and restore the surviving pre-focus selection. Otherwise a later draw can re-arm a mode the user already left.
- Reloading a workspace initializes again without finalizing the existing one; finalizing would drop transient state. Consumers started by initialization must stop on a newer initialization, not just on exit, or reload doubles undo and other side effects.

View File

@ -1,21 +0,0 @@
# Frontend Workspace Transform Subtleties
## Preview vs committed transforms
- High-frequency previews use `app.main.streams/wasm-modifiers` and `workspace-selrect` behavior subjects instead of normal store commits; components consume them through refs that wrap plain atoms.
- `apply-modifiers*` is the lower-level commit path once object/text modifiers are ready. It updates frame guides, frame comment threads, and then emits `update-shapes` with `:reg-objects? true`.
- Transform commits restrict diff attrs to `transform-attrs` to avoid scanning unrelated shape attrs.
- Text transforms may carry derived `:position-data`; `assoc-position-data` attaches it while preserving the original text shape context.
- A drag commits when its `mse/drag-stopper` fires, `:interrupt` (Escape) included. The save-failure lock emits `::plk/cancel-gestures` first: drags built on `plk/gesture-stopper` (start-move, start-resize, start-rotate, start-move-line-point, box/curve/line drawing) see a `cancelled?` flag set before the stop and emit `dwt/cancel-transform` (`clear-local-transform` + `finish-transform`) or `cancel-drawing` instead. A new drag gesture must use it (or, in a component, drop the drag when read-only turns on): `commit-changes` refuses the commit anyway, but the preview (WASM modifiers/props) would stay.
## Component-copy touched suppression
- `calculate-ignore-tree` walks modified shapes and descendants to decide per copy-shape `ignore-geometry?`.
- `check-delta` compares a copy's relative position/rotation to its component root before and after transform. If relative movement is under about 1px and size/rotation are effectively unchanged, geometry touching is suppressed.
- This logic is why pure translations of component copies can avoid marking every descendant as geometry-touched, while resizes/rotations still propagate touched state.
## WASM bridge details
- WASM modifier updates set plugin/local props with parsed geometry/structure modifiers rather than directly mutating file data.
- The position-data recomputation watcher ignores commits tagged `:position-data`; keep that tag when adding derived position-data commits.
- Rotation has separate WASM and non-WASM event paths. Check both when changing rotation modifier semantics.

View File

@ -0,0 +1,8 @@
# Workspace transforms
- Start at `app.main.data.workspace.transforms`, `app.main.data.workspace.modifiers` and `app.main.streams`. High-frequency WASM modifier and selection-rectangle previews use behavior subjects and refs outside normal store commits; they are not persisted shape data.
- Clear `wasm-modifiers` and `workspace-selrect` on gesture end **and** when a control unmounts mid-gesture. Otherwise stale preview state can displace the next selection overlay. `app.main.streams/clear-transform-preview!` resets both.
- A normal `mse/drag-stopper` can end a drag on `:interrupt` as well as mouse release. On save failure, `::plk/cancel-gestures` arrives first; `plk/gesture-stopper` marks the gesture cancelled so it clears the transform or drawing preview instead of committing. New drag gestures need that cancellation or equivalent unmount/read-only cleanup: the commit gate alone does not clear WASM preview state. See `mem:frontend/workspace-state-persistence-subtleties`.
- `apply-modifiers*` updates frame guides and comment threads before `update-shapes`, with `:reg-objects? true` and `transform-attrs` limiting the diff. `assoc-position-data` preserves the original text shape context when applying derived text positions. Keep the `:position-data` tag on derived commits so its watcher does not react to itself.
- `calculate-ignore-tree` and its WASM counterpart compare each copy and its root before and after transforms. Small relative movement with effectively unchanged size and rotation can suppress geometry touched for descendants; resizes and rotations must still propagate it. For touched semantics and geometric precision see `mem:common/components` and `mem:common/geometry`.
- WASM modifier updates write local/plugin props rather than directly mutating file data. Rotation has distinct WASM and non-WASM event paths; check both when changing semantics. Rendering flush and tile invalidation are in `mem:render-wasm/rendering`.