Skip to content

duplicate complex obstacle shapes - #1123

Open
Devin T. Currie (DTCurrie) wants to merge 2 commits into
mainfrom
duplicate-complex-obstacle-shapes
Open

Devin T. Currie (DTCurrie) wants to merge 2 commits into
mainfrom
duplicate-complex-obstacle-shapes

Conversation

@DTCurrie

Copy link
Copy Markdown
Member

Lets a user duplicate a shape while editing a Complex obstacle, from the shape's row in the obstacle editor, from the selected shape's details panel, or with Shift+D. The copy is appended with a numbered label so the user can rename it, and the row path focuses that label right away.

Library

  • duplicateObstacleGeometry appends a shallow copy of the entry at index, labeled <name>-N where the name is what rdk calls the entry (a → a-1, unlabeled geometry_2 → geometry_2-1) and N is the first free number. A capitalized Label key on the source is dropped so the copy carries its label under one spelling. An out-of-range index returns the list unchanged and no label.
  • addObstacleGeometry shares the free-number search with it through a private freeLabel.

Plugins

  • ComplexObstacleEditor adds a Duplicate icon button to each shape row, between Select and Remove. After the write it holds the copy's label as pending, and an effect focuses and selects that row's label input once the row renders. commit now returns whether it wrote.
  • DuplicateObstacleShapeButton is new: a "Duplicate shape" action for a selected Complex shape with a Shift+D chip. It registers editing.duplicateObstacleShape through useHotkey for as long as it is mounted, and moves the selection to the copy's entity when its frame appears. A copy rdk would reject shows the error under the button and writes nothing.
  • BuildDetails renders it above RemoveObstacleShapeButton.

Why?

Why does the hotkey select the copy but not focus its label, when the row button does?

Focusing an input from a hotkey would swallow the next Shift+D, since an unmodified press typed into a field belongs to the field. Repeated presses could not stack copies. The row button is a pointer action, so focusing the new label there costs nothing.

Why append the copy at the end rather than after its source?

Inserting mid-list renumbers every unlabeled geometry_N after it, which would need a new index move for the saved appearances to follow. Appending keeps every existing shape in place, the same as Add shape.

Why a shallow copy?

Edits never mutate a geometry in place. patchObstacleGeometry replaces the whole entry, so a shared translation object is never written through. A deep clone also fails on the Svelte state proxy the component prop arrives as.

Testing

Ran pnpm check, pnpm lint, and pnpm test scoped to src/lib/plugins/BuildFrames/ and src/lib/__tests__/obstacleGeometryList.spec.ts. Added specs for duplicateObstacleGeometry (labeling, free number, Label key, out-of-range), for the editor row (writes the copy, focuses the new label after rerender), and a new DuplicateObstacleShapeButton.svelte.spec.ts (click, hotkey match and run, chip, selection follows the copy, rejected copy). BuildDetails.svelte.spec.ts now supplies a keybindings context and checks both actions.

@changeset-bot

changeset-bot Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f858d68

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@viamrobotics/visualization Minor

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

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://viamrobotics.github.io/visualization/pr-preview/pr-1123/

Built to branch gh-pages at 2026-10-19 13:43 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@viam-overwatch

Copy link
Copy Markdown
Contributor

Hey Devin T. Currie (@DTCurrie) — CI is green and no reviewer is assigned yet. Could you request one when you have a chance?

Auto-comment from overwatch. Will not re-nudge for 7 days.

This branch has not been deployed

No deployments
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