sshiv012 opened a new pull request, #9278:
URL: https://github.com/apache/texera/pull/9278
### What changes were proposed in this PR?
Comments on the canvas can now be anchored to an operator, the way a Google
Docs comment is tied to its text. An anchored comment moves with its operator,
whether you drag the operator or run auto-layout. Comments that aren't anchored
still float freely, as before.
```
floating: operator moves -> comment stays where it was
anchored: operator moves -> comment moves with it, same offset
```
| How | What happens |
|---|---|
| Right-click an operator, then **add comment** | A comment is created next
to the operator, already anchored to it |
| Drag a comment onto an operator | The operator is outlined while you drag,
and the comment anchors on drop if it is within 40px |
| Drag an anchored comment more than 160px away | It detaches and floats |
- An anchored comment has a dashed blue outline and a dashed line to its
operator.
- Auto-layout keeps each anchored comment beside its operator, evenly spaced.
- Copy/paste keeps the anchor when the operator is copied too. A comment
copied without its operator pastes as floating.
- Dragging several selected comments anchors or detaches each one by where
it lands, in one undo step.
- Anchors stay in sync between co-editors.
- Fixes an upstream bug where a comment's first move did not reach
co-editors: the first move enters the shared position map as an `add`, which
was ignored.
**Screenshots** (before = `main`, after = this PR)
| | Before | After |
|---|---|---|
| Drag an operator | _(screenshot)_ | _(screenshot)_ |
| Auto-layout | _(screenshot)_ | _(screenshot)_ |
| Right-click an operator | _(screenshot)_ | _(screenshot)_ |
**Compatibility.** The anchor is a single optional field,
`anchoredOperatorID`, on each comment box in the workflow content. Nothing
outside the frontend reads comment boxes, so no migration is needed.
| Case | Result |
|---|---|
| A workflow saved before this PR | Loads with every comment floating,
unchanged |
| This PR's workflow opened in an older build | Comments float. The older
build keeps the field when it saves, so the anchor comes back after upgrading |
| An anchor whose operator is gone (for example, deleted by an older client)
| Drawn and treated as floating |
Export/import round trip between this branch and `main`:
_(round-trip screenshot)_
### Any related issues, documentation, discussions?
Closes #9274
### How was this PR tested?
Unit tests, written before each change:
- `workflow-action.service.spec.ts`:
- anchoring, detaching and undo;
- auto-layout spacing;
- reload;
- the connector line;
- the snap and detach limits (40/41px and 160/161px);
- tie-breaks between equally near operators;
- anchors to a missing operator;
- a live second editor whose Y.js document is linked to the first,
checking that both converge.
- `workflow-editor.component.spec.ts`: drags driven by the paper's real
pointer events, covering a single comment, several selected comments, dragging
with an operator selected, and a click that doesn't move.
- `operator-menu.service.spec.ts`: paste with and without the anchored
operator.
- Context menu: the "add comment" item.
All frontend tests pass, and type-check, prettier and eslint are clean.
Manual check in Chrome, on a local dev stack:
1. Right-click an operator, choose **add comment**, and confirm the comment
appears with an outline and a line to the operator.
2. Drag the operator and confirm the comment follows. Run auto-layout and
confirm it stays beside the operator.
3. Drag the comment far away and confirm it detaches. Drag it back onto the
operator and confirm it re-anchors.
4. Shift-select two anchored comments and drag them away: both detach.
5. Export the workflow and upload it into a `main` build (it loads, with
comments floating). Edit it there, export it again, and upload it back into
this branch: the anchor returns.
### Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 5.5)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]