app-16292: refactor Details panel into focused subcomponents#736
Conversation
🦋 Changeset detectedLatest commit: 99d1188 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Foundation for the upcoming Gizmos plugin. No callers yet; these symbols are consumed by follow-up PRs in the stack. * writeMatrix(entity, patch): patch a Pose onto an entity's Matrix trait via createPose/matrixToPose/poseToMatrix, then dirty the trait. Used by the refactored Details panel and the Gizmos plugin. * CustomDetails trait: marker so the Details panel suppresses its default frame/pose UI for entities that render their own. * useMouseRaycaster firstHitOnly option (forwarded to three-mesh-bvh). * 'gizmo' value added to Settings.interactionMode. * Re-exports of DEFAULT_LINE_WIDTH and ARROW_LENGTH for downstream consumers.
681bd0b to
9e637c6
Compare
The Details overlay component had grown to handle four entirely different entity shapes (color, geometry, line, matrix) inline. Split each into its own component under details/ so callers and reviewers can reason about one entity type at a time. * ColorDetails.svelte, GeometryDetails.svelte, MatrixDetails.svelte and LineDetails/LineDetails.svelte are now individual focused components. * linePositions.ts extracts the line-position derivation with its own spec. * MatrixDetails uses writeMatrix() added in the prior PR. * vitest-setup-client.ts stubs @threlte/extras Portal / PortalTarget / HTML so the refactored panel can render in unit tests. Behavior should be unchanged; existing Details.svelte.spec.ts continues to pass with the new mocks.
a9faa2f to
bf49747
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
- Move writeMatrix below updateGeometryTrait for consistent file layout - Add JSDoc to writeMatrix documenting round-trip semantics and no-op behavior - Filter undefined values from patch before Object.assign to prevent NaN in matrix - Add comment clarifying firstHitOnly affects both hover and click handlers - Strengthen orientation test with oX/oY/oZ assertions Co-authored-by: Devin T. Currie <DTCurrie@users.noreply.github.com>
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
- linePositions.ts: add bounds check to writeLinePosition; return copy unchanged on out-of-bounds index - Details.svelte: await navigator.clipboard.writeText() and wrap in try/catch to handle permission denial - MatrixDetails.svelte: add comments explaining useQuery vs configFrames and unconditional rendering - linePositions.spec.ts: add edge cases for out-of-bounds write and single-point removal guard - Add component tests for ColorDetails, GeometryDetails, MatrixDetails, and LineDetails Co-authored-by: Devin T. Currie <DTCurrie@users.noreply.github.com>
…stHitOnly effect split - Add early-exit guard in writeMatrix when filtered patch is empty to avoid spurious entity.changed(Matrix) notifications - Add tests for undefined field filtering and empty/all-undefined patch paths - Split firstHitOnly assignment into its own $effect so toggling it doesn't tear down and re-attach event listeners Co-authored-by: Devin T. Currie <DTCurrie@users.noreply.github.com>
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
- vitest-setup-client.ts: `invalidate` was nested inside `scene` in the
useThrelte mock instead of at the top level; `const { invalidate } =
useThrelte()` returned undefined in all tests.
- linePositions.ts: `removeLinePosition` had a duplicate
`if (source.length <= 6) return source` guard (dead code after the
bounds-check fix in a prior commit).
Co-authored-by: Devin T. Currie <DTCurrie@users.noreply.github.com>
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
|
@claude final review |
|
Claude finished @DTCurrie's task in 2m 40s —— View job Final Review
This PR is in good shape. All substantive issues from previous rounds have been resolved:
One fix committed: duplicate Pre-existing CI noise (unrelated to this PR): Architecture is sound. The |
Co-authored-by: Devin T. Currie <DTCurrie@users.noreply.github.com>
micheal-parks
left a comment
There was a problem hiding this comment.
should we postfix all of these new files with "Details" if they're in the details folder? seems potentially noisy like the situation with "BaseView", "CameraView" etc in test-cards, but I could also understand not wanting to pollute ctrl+p search
@micheal-parks that is the exact reason. I don't feel strongly about it though so I am open to removing them |
| @@ -0,0 +1,189 @@ | |||
| <script | |||
There was a problem hiding this comment.
Can we call this PoseDetails? I feel like this should reflect what the user sees, matrices are an internal design detail that the user never sees
There was a problem hiding this comment.
Ha, I actually originally named it that then swapped to MatrixDetails. I'll swap it back
Splits the monolithic
Details.svelteoverlay into focused subcomponents undersrc/lib/components/overlay/details/. Behavior is unchanged for the refactor itself.This is preparation for the per-entity panels that the Gizmos plugin mounts in #738.
Note
Use this PR preview to view all of the changes from this stack: https://viamrobotics.github.io/visualization/pr-preview/pr-739/snapshot
Stack
Frontend
src/lib/components/overlay/details/ColorDetails.svelte,GeometryDetails.svelte,MatrixDetails.svelte,LineDetails/LineDetails.svelte,OpacityDetails.svelte, andAxesHelperDetails.svelte.src/lib/components/overlay/details/LineDetails/linePositions.ts: extracts the line-position derivation with its own spec so it can be tested without rendering Svelte.src/lib/components/overlay/Details.svelte: mounts aPortalTargetnameddetails-extensionsso plugin-supplied editors (e.g. the gizmo Details in app-16292: add Gizmos plugin #738) can render inline, and replaces the inline opacity slider and show-axes-helper switch with<OpacityDetails>and<AxesHelperDetails>. Plugin-supplied panels mount these conditionally per entity kind.MatrixDetails.svelte: takes requiredonPoseChange(patch)andonParentChange(next)props so the caller decides whether mutations commit immediately (writeMatrix/hierarchy.setParent) or buffer through an edit session (e.g. a future frame edit plugin writing toEditedMatrix). Required rather than defaulted to avoid silently committing edits that should have been buffered.OpacityDetails.svelte: owns the opacity slider. Always writestraits.Opacity(value)instead of removing the trait at1, and falls back to0.7for display to match the renderer's historical default. Previously, the slider would remove the trait at1, after whichLine/Meshwould fall back to their own0.7default and render translucent instead of opaque.AxesHelperDetails.svelte: owns the show-axes-helper switch, adding/removingtraits.ShowAxesHelperdirectly.vitest-setup-client.ts: stubs@threlte/extrasPortal,PortalTarget, andHTMLso the refactored panel can render in unit tests without a<Canvas>parent.Testing
The existing
src/lib/components/overlay/__tests__/Details.svelte.spec.tscontinues to pass against the refactored component with the new mocks. NewMatrixDetails.svelte.spec.ts,OpacityDetails.svelte.spec.ts, andAxesHelperDetails.svelte.spec.tscover the structural rendering branches of each extracted component, andlinePositions.spec.tscovers the extracted line-position derivation. Ranpnpm checkandpnpm test. Manually verified the opacity slider now produces a fully opaque mesh at1and stays at0.7for a trait-less entity.