Skip to content

feat(frontend): suggest next operators on the canvas - #6437

Open
gupta-sahil01 wants to merge 22 commits into
apache:mainfrom
gupta-sahil01:feat/operator-recommender-frontend
Open

gupta-sahil01 wants to merge 22 commits into
apache:mainfrom
gupta-sahil01:feat/operator-recommender-frontend

Conversation

@gupta-sahil01

@gupta-sahil01 gupta-sahil01 commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Frontend half (PR 2 of 2) of the ambient operator recommender, Version 1 — see #6293
(design discussion #5240). Depends on the backend /api/recommend endpoint in #6436.

After the user drops an operator onto the canvas, 1–3 faded suggestion chips appear
on its output port; clicking one materializes that operator and wires the link as a
single undoable action, then offers a fresh round of suggestions on the operator it just
created. Behaves like code completion, but for dataflow graphs. Opt-in and default-off.

  • OperatorRecommendationService calls POST /api/recommend and materializes a chosen
    suggestion. Fails soft: a disabled feature, an output-less operator, a backend error, or an operator type the catalog doesn't know all leave the canvas unchanged.
  • Trigger is the drag-drop drop event, not the graph's operator-add stream — so
    workflow load, undo/redo, paste, and remote co-editor edits do not fire requests.
    Chaining after a click is explicit for the same reason.
  • Suggestion overlay in the workflow editor, sharing one paper-to-screen anchor helper
    with the chat popover; re-anchored on operator move and zoom, dismissed on blank click
    or when the anchor operator is deleted.
  • Opt-in flag operatorRecommendationEnabled (default false), threaded through
    gui.conf → GuiConfig → ConfigResource → the frontend GuiConfig type + mock, and
    listed as false in values.yaml, values-development.yaml, and .env so deployments
    can turn it on without a chart edit.
  • Routing for the endpoint added to the dev proxy, the single-node nginx config, and
    the prod gateway. On the gateway it gets its own HTTPRoute rather than joining
    /api/agents: that route is the target of a BackendTrafficPolicy pinning requests to a
    replica by consistent-hashing X-Agent-Workflow-Id, and the recommender is stateless and
    sends no such header. Auth posture is unchanged either way — the gateway's extAuth
    SecurityPolicy scopes to -dynamic-routes only, which covered neither route.
  • Requests are cancellable. The drop trigger and the post-click chaining call feed
    one subject through switchMap, and dismissing pushes a cancel through it — so a slow
    response can neither overwrite newer suggestions nor re-open a dismissed overlay.
  • No suggestions on an already-wired port. A drop can arrive linked (onto an existing
    edge, or proximity auto-linking), and the port can acquire a link while the chips are
    up, so the check runs both when asking and when a chip is clicked.
  • The frozen canvas is respected. The chips dismiss when workflow modification is
    disabled — during execution, version preview, or a read-only view — and a click
    re-checks the lock. Materializing writes to the shared model, and undoAction() refuses
    while the lock is on, so the write could not be taken back.

V1 payload is intentionally minimal. The request carries the operator type and the
types already on the canvas; the backend's V1 ranker is a hardcoded table that needs no
schema or data sample, and documents existingOperatorTypes as reserved for V2. Output
schema and graph topology arrive with the V2 LLM ranker.

image

Any related issues, documentation, discussions?

How was this PR tested?

  • yarn ng test — operator-recommendation.service.spec.ts, 8 passed.
  • yarn ng test — workflow-editor.component.spec.ts, 116 passed, 11 covering the
    recommender: a drop requests suggestions; operators arriving without a drop do not;
    a drop that already wired the anchor port does not; a chip click after the port
    acquires a link does not materialize; disabling workflow modification dismisses the
    chips; a click while modification is disabled does not materialize; a response
    arriving after dismissal is ignored; the newest request wins when an older response
    lands last; deleting the anchor dismisses; clicking a chip chains a fresh round;
    repositioning to an unchanged position skips change detection.
  • yarn ng build --configuration=production — succeeds under strict templates.
  • End-to-end (manual): ran the local-dev stack with
    GUI_WORKFLOW_WORKSPACE_OPERATOR_RECOMMENDATION_ENABLED=true; verified chips render on
    the output port, clicking materializes + links + re-suggests, and POST /api/recommend
    is reached through the proxy.

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Anthropic Claude (Claude Code)

@github-actions github-actions Bot added feature frontend Changes related to the frontend GUI infra common platform Non-amber Scala service paths labels Jul 15, 2026
@github-actions

github-actions Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @zyratlo, @sshiv012, @aglinxinyuan
    You can notify them by mentioning @zyratlo, @sshiv012, @aglinxinyuan in a comment.

@Yicong-Huang

Copy link
Copy Markdown
Contributor

great feature, could you please include screenshots/gifs in the PR description?

@github-actions

github-actions Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Benchmark changes need a look

🟢 6 better · 🔴 4 worse · ⚪ 5 noise (<±5%) · 0 without baseline

Compared against main 2d0a0a3 benchmarked on this same runner, so the delta is largely free of cross-runner hardware noise. The "7d avg" column still reflects the gh-pages dashboard. Treat <±5% as noise unless repeated.

Dashboard · Run

config throughput MB/s latency max Δ latest / 7d
🔴 bs=10 sw=10 sl=64 714 0.435 14,369/17,840/17,840 us 🟢 -60.0% / 🔴 +36.3%
🟢 bs=100 sw=10 sl=64 1,703 1.039 57,152/78,725/78,725 us 🟢 -7.6% / 🟢 +29.7%
🔴 bs=1000 sw=10 sl=64 1,984 1.211 498,566/554,615/554,615 us 🔴 -5.1% / 🟢 +47.3%
Baseline details

Latest main 2d0a0a3 from same runner

config metric PR latest main 7d avg Δ latest Δ 7d
bs=10 sw=10 sl=64 throughput 714 tuples/sec 641 tuples/sec 943.62 tuples/sec +11.4% -24.3%
bs=10 sw=10 sl=64 MB/s 0.435 MB/s 0.391 MB/s 0.576 MB/s +11.3% -24.5%
bs=10 sw=10 sl=64 p50 14,369 us 13,681 us 10,541 us +5.0% +36.3%
bs=10 sw=10 sl=64 p95 17,840 us 44,578 us 13,727 us -60.0% +30.0%
bs=10 sw=10 sl=64 p99 17,840 us 44,578 us 16,861 us -60.0% +5.8%
bs=100 sw=10 sl=64 throughput 1,703 tuples/sec 1,704 tuples/sec 1,313 tuples/sec -0.1% +29.7%
bs=100 sw=10 sl=64 MB/s 1.039 MB/s 1.04 MB/s 0.801 MB/s -0.1% +29.7%
bs=100 sw=10 sl=64 p50 57,152 us 55,719 us 79,983 us +2.6% -28.5%
bs=100 sw=10 sl=64 p95 78,725 us 85,220 us 86,516 us -7.6% -9.0%
bs=100 sw=10 sl=64 p99 78,725 us 85,220 us 93,488 us -7.6% -15.8%
bs=1000 sw=10 sl=64 throughput 1,984 tuples/sec 2,090 tuples/sec 1,347 tuples/sec -5.1% +47.3%
bs=1000 sw=10 sl=64 MB/s 1.211 MB/s 1.276 MB/s 0.822 MB/s -5.1% +47.3%
bs=1000 sw=10 sl=64 p50 498,566 us 474,475 us 780,074 us +5.1% -36.1%
bs=1000 sw=10 sl=64 p95 554,615 us 537,708 us 826,232 us +3.1% -32.9%
bs=1000 sw=10 sl=64 p99 554,615 us 537,708 us 869,114 us +3.1% -36.2%
Raw CSV
config_idx,batch_size,schema_width,string_len,num_batches,total_ms,total_tuples,total_bytes,tuples_per_sec,mb_per_sec,lat_p50_us,lat_p95_us,lat_p99_us
0,10,10,64,20,280.30,200,128000,714,0.435,14369.39,17840.24,17840.24
1,100,10,64,20,1174.53,2000,1280000,1703,1.039,57151.81,78724.52,78724.52
2,1000,10,64,20,10079.25,20000,12800000,1984,1.211,498566.23,554615.24,554615.24

@gupta-sahil01

Copy link
Copy Markdown
Contributor Author

great feature, could you please include screenshots/gifs in the PR description?

added screenshots

@chenlica

Copy link
Copy Markdown
Contributor

@xuang7 @zuozhiw : Per the discussion #5240, can you review it?

@xuang7

xuang7 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

@xuang7 @zuozhiw : Per the discussion #5240, can you review it?

I'm not very familiar with this part of the codebase, so I'll leave general comments where I can. It would probably be helpful to assign someone more familiar with this area for a thorough review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.

@Yicong-Huang

Copy link
Copy Markdown
Contributor

Hi @gupta-sahil01 a high level comment: let's not name it ghost suggestions. Let's find a better name for it?

@gupta-sahil01

Copy link
Copy Markdown
Contributor Author

Hi @gupta-sahil01 a high level comment: let's not name it ghost suggestions. Let's find a better name for it?

I thought since they were blurred like a "ghost". If you have a better name for it, I'm open to changing it.

@Yicong-Huang

Copy link
Copy Markdown
Contributor

How about just call them "suggested operators"? On the UI, the suggested operators are rendered with faded, blurred effect, but they are real suggestion instances. "ghost" the word has a negative semantic and I'd like to avoid it, and it is bundled with its UI effect: if we were to change such operators UI effect to be not blurred, the naming will be obsolete.

@gupta-sahil01

Copy link
Copy Markdown
Contributor Author

How about just call them "suggested operators"? On the UI, the suggested operators are rendered with faded, blurred effect, but they are real suggestion instances. "ghost" the word has a negative semantic and I'd like to avoid it, and it is bundled with its UI effect: if we were to change such operators UI effect to be not blurred, the naming will be obsolete.

Well, the word "ghost" doesn't appear directly in the UI. When we drag an operator from the panel, the 3 suggestions will show up with it.

@Yicong-Huang

Yicong-Huang commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Not only about UI, or what user sees, but also for code comments, variable names as well as GitHub discussion, pr titles and description, etc. can we avoid this naming in general? Thanks

@chenlica
chenlica requested review from xuang7 and zuozhiw July 18, 2026 04:06
@chenlica

Copy link
Copy Markdown
Contributor

@xuang7 and @zuozhiw : can you review it?

Frontend half of the ambient operator recommender (apache#5240).
After an operator is added to the canvas, 1-3 faded suggestion chips appear
on its output port showing likely next operators; clicking one materializes
the operator and wires the link as a single undoable action.

- OperatorRecommendationService: calls the stateless agent-service
  POST /api/recommend endpoint and turns a chosen suggestion into a real
  operator. Fails soft - a disabled feature, an output-less operator, or a
  backend error simply yields no suggestions, leaving the canvas unchanged.
- Suggestion overlay in the workflow editor, reusing the chat-popover
  anchoring pattern (screen-coord conversion, re-anchored on move / zoom /
  pan); dismissed on blank click or when the anchor operator is deleted.
- Opt-in GUI config flag `operatorRecommendationEnabled`, default off,
  threaded through gui.conf, GuiConfig, ConfigResource, and the frontend
  GuiConfig type + mock.
@gupta-sahil01
gupta-sahil01 force-pushed the feat/operator-recommender-frontend branch from 1a02c7d to a0794b6 Compare July 18, 2026 04:29
@gupta-sahil01 gupta-sahil01 changed the title feat(frontend): ambient operator recommender ghost suggestions feat(frontend): ambient operator recommender suggestions on the canvas Jul 18, 2026
@gupta-sahil01

Copy link
Copy Markdown
Contributor Author

Am I allowed to update the branches because I made some changes with respect to eliminating the word "ghost" from everywhere?

@Yicong-Huang Yicong-Huang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 1 resolved · 0 open · 1 new (1 new = 0 newly introduced · 1 late catch)

The doc block is fixed exactly as suggested, and every claim in it re-checks out against the pinned library sources. The one new item is a word in a comment I read and cleared last round.

Polish: 1 quick touch-up (see inline comment).

Verification trace

The corrected doc block is right on all three counts. Backbone 1.4.1 fires reset and sort as (collection, options) (backbone.js:965, :1045), and joint.dia.Graph re-triggers its cells collection's events verbatim (cells.on('all', this.trigger, this), jointjs 3.5.4 dist/joint.js:16579), so a handler really does receive the collection. change is proxied per cell by _onModelEvent (backbone.js:1210-1222), and because Graph = Backbone.Model.extend (joint.js:16560) a graph-attribute set fires it with the Graph — which is what the new wording now says.

The union is still sound. add, remove and change:position all put the Cell first, so the admitted set stays a strict subset of the cell-reporting events, and the signature and body are byte-identical to the last round.

The description's numbers are now exact. grep -c gives 8 in the service spec and 116 in the editor spec; the recommender describe at :2460 holds 11 it( blocks, and the eleven behaviours the description lists match those eleven titles one-for-one.

@Yicong-Huang Yicong-Huang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 2 resolved · 0 open · 1 new (1 new = 0 newly introduced · 1 late catch)

Both round-3 findings are verified fixed and all 34 threads are resolved. Nothing left blocks merge. One note for whoever merges: the backend half (#6436) is still open and this PR carries Closes #6293, so it should land second.

Polish: 1 quick touch-up (see inline comment).

Verification trace

The corrected doc block is right. joint.dia.Graph re-triggers its cells collection's events verbatim (cells.on('all', this.trigger, this), jointjs 3.5.4 dist/joint.js:16579), and Backbone 1.4.1 fires reset and sort as (collection, options) — so both hand a handler the collection. change is genuinely both cases: the Graph is itself a Model, so graph.set(...) fires it with the Graph, while a cell's own change arrives through _onModelEvent with the Cell first (backbone.js:1210-1222). The new text states both halves, which is exactly what the previous wording got wrong.

Nothing else moved. git diff 79e35771a 3339c8f6d is one file, 4 insertions and 4 deletions, all of it comment prose. fromJointGraphCellEvent still has a single call site (workflow-editor.component.ts:1844, passing change:position); the feature still performs exactly one graph mutation (operator-recommendation.service.ts:157); and the recommender describe still holds 11 it( blocks at workflow-editor.component.spec.ts:2460 out of 116 in the file — both numbers matching the description's refreshed test line. The lock bullet the last round asked for is in the description now too.

The comment said 'Both conditions' while the condition has three conjuncts. Name the lock and port checks as guarding state no dismissal covers, and mark hasOperator as backing up the delete stream rather than load-bearing.
@gupta-sahil01

Copy link
Copy Markdown
Contributor Author

/request-review @Yicong-Huang

@github-actions
github-actions Bot requested a review from Yicong-Huang August 31, 2026 17:49

@Yicong-Huang Yicong-Huang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 1 resolved · 0 open · 1 new (1 new = 0 newly introduced · 1 late catch)

The round-4/5 finding is verified fixed: the guard comment now names its three checks, and the belt-and-braces claim it adds is true. All 36 threads are resolved and every executable line is unchanged since round 3. One late catch on my own earlier wording is left.

Polish: 1 touch-up in two places (see inline comments).

For whoever merges: the backend half (#6436) is still open and this PR carries Closes #6293, so it should land second.

Verification trace

The new belt-and-braces claim holds. The rewritten comment says hasOperator only backs up the delete stream. Traced it rather than accepting it: getOperatorDeleteStream() is subscribed at workflow-editor.component.ts:1835, and its source operatorDeleteSubject.next(...) sits at shared-model-change-handler.ts:112, inside the Y-observer's delete arm but outside the if (event.transaction.local) guard that opens at :101. So a co-editor's remote delete emits the same stream as a local one, closeNextOperatorSuggestions() nulls the state, and materializeNextOperatorSuggestion returns at its own if (!this.nextOperatorSuggestion) (:1921) before the conjunct is reached. hasOperator is genuinely redundant.

Nothing else moved. git diff 3339c8f6d 7aa41664b is one file, 7 insertions and 6 deletions, all comment prose. The description's test numbers still hold in the tree: 8 it( in operator-recommendation.service.spec.ts and 116 in workflow-editor.component.spec.ts, 11 of them inside describe("Ambient Operator Recommender") at :2460.

OperatorInfo.forVisualization gives every visualization a SINGLE_SNAPSHOT output port, so a chart is not output-less and does produce suggestions. The catalog has no zero-output operator outside test stubs, so the parenthetical is dropped rather than replaced. Fixed in both the service and the component, which duplicate the guard.
@gupta-sahil01

Copy link
Copy Markdown
Contributor Author

/request-review @Yicong-Huang

@Yicong-Huang Yicong-Huang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 1 resolved · 0 open · 0 new (0 new = 0 newly introduced · 0 late catches)

The round-6 finding is verified fixed. You said the wording was in a third place as well — the PR description — and that checks out: nothing in the tree or the description names a zero-output operator any more. All 38 threads are resolved and no executable line has changed since round 3, so there is nothing outstanding from this review series.

For whoever merges: the backend half (#6436) is still open and this PR carries Closes #6293, so it should land second.

Verification trace

The third site is genuinely fixed, not relocated. grep -rn "chart sink" over the worktree returns no hits, and the description bullet now reads "a disabled feature, an output-less operator, a backend error, or an operator type the catalog doesn't know all leave the canvas unchanged". That phrasing states the guard's input condition rather than claiming such an operator exists in the catalog, which was the actual defect. Both code sites match their suggestion blocks character for character: operator-recommendation.service.ts:91-92 and workflow-editor.component.ts:1866-1867.

Nothing else moved. git diff 3339c8f6d e8b30c44, filtered to lines whose content is not a // comment, returns nothing at all — every executable line in this PR is unchanged since round 3. The description's three test counts were re-counted in the tree rather than carried forward: 8 it( in operator-recommendation.service.spec.ts, 116 in workflow-editor.component.spec.ts, and 11 at or after describe("Ambient Operator Recommender") on :2460.

@Yicong-Huang

Copy link
Copy Markdown
Contributor

@gupta-sahil01 shall we wait for #6436?

@gupta-sahil01

Copy link
Copy Markdown
Contributor Author

@Yicong-Huang I feel like since #6436 has been marked as stale, we shouldn't wait any longer.

@gupta-sahil01

Copy link
Copy Markdown
Contributor Author

Any updates here? @Yicong-Huang

@gupta-sahil01

Copy link
Copy Markdown
Contributor Author

@Yicong-Huang

@Yicong-Huang

Copy link
Copy Markdown
Contributor

please resolve the conflicts and we can merge this

…mender-frontend

# Conflicts:
#	bin/k8s/templates/base/gateway/gateway-routes.yaml
#	frontend/src/app/workspace/component/workflow-editor/workflow-editor.component.ts
@gupta-sahil01

Copy link
Copy Markdown
Contributor Author

please resolve the conflicts and we can merge this

Done

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has
not had any activity for 30 days. It will be closed in 7 days if no
further activity occurs.

If this PR is still relevant, please:

  • Push new commits or rebase onto the latest main, or
  • Comment with a status update, or
  • Address any open review feedback.

To exempt this PR from auto-close, a maintainer can add the pinned label.
Thank you for your contribution to Apache Texera (incubating)!

@github-actions github-actions Bot added the stale label Nov 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed due to 37 days of inactivity.
If you would like to continue this work, please re-open the PR or open a new
one referencing this. Thank you for your contribution.

@github-actions github-actions Bot closed this Nov 30, 2026
@gupta-sahil01

Copy link
Copy Markdown
Contributor Author

@Xiao-zhen-Liu, please review this PR because it has been automatically marked as closed. Should we reopen it?

@Xiao-zhen-Liu Xiao-zhen-Liu reopened this Nov 30, 2026
@Ma77Ball

Ma77Ball commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Hello @gupta-sahil01, can you resolve the branch and CI/CD conflicts in this PR? In the meantime, I plan to review and work with you consistently to merge the backend half of this two-part PR first. I think this PR has been open for a long time, and I would like to help resolve it.

@Ma77Ball
Ma77Ball self-requested a review December 2, 2026 20:00
gupta-sahil01 and others added 2 commits December 4, 2026 08:46
Resolve conflicts where both sides added code at the same place: keep the
operator-recommendation-enabled setting alongside main's new AI fix model
setting (gui.conf, GuiConfig, its spec, ConfigResource, the frontend
GuiConfig type and mock), and merge the workflow editor's imports, dropping
OperatorResultSummary, which main replaced with OperatorExecutionSummary.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…#6436

- Call POST /api/operator-recommendations with the operator type and the
  anchor output port (sourcePortID), dropping existingOperatorTypes.
- Wire a clicked suggestion to the input port the backend names
  (targetPortID), falling back to the first input port if this frontend's
  operator has no port by that ID.
- Drop the /api/recommend routes from the dev proxy and single-node nginx;
  apache#6436 adds /api/operator-recommendations to both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gupta-sahil01

Copy link
Copy Markdown
Contributor Author

Hello @Ma77Ball, thank you for checking the status of this PR. I've resolved the CI/CD conflicts and also updated the code to the new endpoint that is used in the backend PR. Please have a look after the required checks have finished.

@github-actions github-actions Bot removed the feature label Dec 4, 2026

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

common frontend Changes related to the frontend GUI infra platform Non-amber Scala service paths stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ambient "operator recommender"

8 participants