gupta-sahil01 commented on code in PR #6437:
URL: https://github.com/apache/texera/pull/6437#discussion_r3768889941
##########
frontend/src/app/workspace/component/workflow-editor/workflow-editor.component.ts:
##########
@@ -1717,6 +1762,158 @@ export class WorkflowEditorComponent implements OnInit,
AfterViewInit, OnDestroy
return
this.operatorSummaries.get(operatorId)?.sampleRecords?.[0]?.["__is_visualization__"]
=== true;
}
+ /**
+ * Ambient operator recommender (apache/texera#5240). When the user drops an
+ * operator onto the canvas, ask the recommender for likely next operators
and
+ * float them as suggestion chips on the operator's output port; clicking one
+ * materializes it. The whole feature is opt-in and self-effacing: if it is
+ * disabled or the backend returns nothing, the canvas is untouched.
+ */
+ private handleOperatorRecommendation(): void {
+ this.repositionSuggestion$
+ .pipe(auditTime(100), untilDestroyed(this))
+ .subscribe(() => this.repositionRecommendations());
+
+ if (!this.operatorRecommendationService.isEnabled()) {
+ return;
+ }
+
+ // Trigger: the user interactively dropped an operator onto the canvas.
+ // Deliberately not the graph's operator-add stream, which also fires on
+ // workflow load, undo/redo, paste, and remote co-editor edits — none of
+ // which are a user authoring a next step.
+ this.dragDropService.operatorDropStream
Review Comment:
No — suggesting after an auto-link isn't intended, and you're right that the
fixed +100 offset makes it worse than noise. Added a `getAllLinks()` check in
the trigger: if the dropped operator's anchor port already has an outgoing
link, no request is made. Covers both `dragDropped` branches, since it tests
the resulting graph rather than which branch ran.
Two notes: it checks the anchor port specifically rather than the operator,
so a multi-output operator with one port wired still gets suggestions on a free
one; and it sits at the trigger next to the output-port guard rather than in
the service, keeping the "should we ask" conditions together. Chaining is
unaffected — the new operator's output is free.
##########
frontend/src/app/workspace/component/workflow-editor/workflow-editor.component.ts:
##########
@@ -109,6 +113,22 @@ export class WorkflowEditorComponent implements OnInit,
AfterViewInit, OnDestroy
position: { x: number; y: number };
} | null = null;
+ // Ambient operator recommender state (apache/texera#5240). Holds the faded
+ // next-operator suggestions anchored on the output port of the
+ // operator that was just added; null when nothing is being suggested.
+ public operatorSuggestion: {
Review Comment:
Renamed the component-side symbols to `nextOperatorSuggestion*` as suggested
— fields, methods, and the CSS classes, which carried the same ambiguous
prefix. `OperatorRecommendationService`, the `OperatorRecommendation` wire type
and its methods stay as-is, aligned with the backend. `DragDropService` is
untouched, so it's now the sole owner of `operatorSuggestion*` /
`SUGGESTION_DISTANCE_THRESHOLD` / `handleOperatorRecommendationOnDrag`.
One thing I left: the `operatorRecommendationEnabled` config flag and its
`GUI_WORKFLOW_WORKSPACE_OPERATOR_RECOMMENDATION_ENABLED` env var. That's
deployment-facing config matching the backend feature name rather than a
component symbol, and renaming it would touch `gui.conf`, `GuiConfig.scala`,
`ConfigResource.scala`, the frontend type and mock, and all three values/env
files. Happy to include it if you'd rather it move too.
--
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]