You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@texera.apache.org by "xuang7 (via GitHub)" <gi...@apache.org> on 2026/08/13 23:18:17 UTC

[PR] feat(operator-demo-video): add the operator drag-and-connect controller [texera]

xuang7 opened a new pull request, #7641:
URL: https://github.com/apache/texera/pull/7641

   ### What changes were proposed in this PR?
   
   This PR adds the controller that puts an operator on the canvas, the step every demo builds around.
   
   Changes:
   
   - `OperatorControllerBuilder.insertViaDrag`: locates the operator in the left panel by its metadata group hierarchy (falling back to the search box), drags it onto the canvas, and wires it up. Wiring follows the operator's port topology: source operators connect nothing, single-input operators connect to the anchor, and two-input operators pull a second edge from a given upstream port into a given input port.
   - `OperatorGroups`: flattens the operator group tree into name -> path, shared metadata used to walk the nested group panels.
   - Adds the module's dependency on the operator-metadata modules, with the jackson overrides that keep Playwright's transitive jackson on the repo-wide version.
   - Extends `Utils` (canvas-geometry helpers and a shared name normalizer) and the timing constants the controller waits on.
   - Four `data-testid` hooks (left-panel Operators button, operator search input, per-operator list items `operator-item-<type>`, and the property-panel title the controller waits on after a drop), each covered by a guard test in the component's existing spec.
   
   ### Any related issues, documentation, discussions?
   
   Closes #7521
   Depends on #7600.
   
   ### How was this PR tested?
   
   No behavior change to any existing module. `sbt DemoVideoGenerator/compile`, `scalafmtCheck`, and `scalafix --check` all pass; the three touched component specs (65 tests, including the new guard tests) pass. The drag-and-connect flow was exercised against a local deployment across all three port topologies (source, single-input, two-input join).
   
   ### Was this PR authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Claude Fable 5)
   
   


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(operator-demo-video): add the operator drag-and-connect controller [texera]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #7641:
URL: https://github.com/apache/texera/pull/7641#issuecomment-6406257544

   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.


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(operator-demo-video): add the operator drag-and-connect controller [texera]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #7641:
URL: https://github.com/apache/texera/pull/7641#issuecomment-6257759506

   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)!


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(operator-demo-video): add the operator drag-and-connect controller [texera]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #7641:
URL: https://github.com/apache/texera/pull/7641#issuecomment-5287495969

   ## [Codecov](https://app.codecov.io/gh/apache/texera/pull/7641?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 89.67%. Comparing base ([`12169c2`](https://app.codecov.io/gh/apache/texera/commit/12169c2cfe5f92d0c492ae12d8eb2b53a6fec098?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`658512c`](https://app.codecov.io/gh/apache/texera/commit/658512cbe248ae8a190ed33296322f2b497b829c?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff              @@
   ##               main    #7641      +/-   ##
   ============================================
   + Coverage     89.65%   89.67%   +0.01%     
   + Complexity     4397     4396       -1     
   ============================================
     Files          1177     1177              
     Lines         46996    46947      -49     
     Branches       5268     5260       -8     
   ============================================
   - Hits          42136    42099      -37     
   + Misses         3094     3092       -2     
   + Partials       1766     1756      -10     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/texera/pull/7641/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | | *Carryforward flag |
   |---|---|---|---|
   | [access-control-service](https://app.codecov.io/gh/apache/texera/pull/7641/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `70.00% <ø> (ø)` | | Carriedforward from [4afe8d4](https://app.codecov.io/gh/apache/texera/commit/4afe8d4ecdf6b4eff007ce55b859b09553163c43?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [agent-service](https://app.codecov.io/gh/apache/texera/pull/7641/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `98.62% <ø> (ø)` | | |
   | [amber](https://app.codecov.io/gh/apache/texera/pull/7641/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `86.38% <ø> (+0.03%)` | :arrow_up: | Carriedforward from [4afe8d4](https://app.codecov.io/gh/apache/texera/commit/4afe8d4ecdf6b4eff007ce55b859b09553163c43?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [computing-unit-managing-service](https://app.codecov.io/gh/apache/texera/pull/7641/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `72.46% <ø> (ø)` | | Carriedforward from [4afe8d4](https://app.codecov.io/gh/apache/texera/commit/4afe8d4ecdf6b4eff007ce55b859b09553163c43?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [config-service](https://app.codecov.io/gh/apache/texera/pull/7641/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `77.31% <ø> (ø)` | | Carriedforward from [4afe8d4](https://app.codecov.io/gh/apache/texera/commit/4afe8d4ecdf6b4eff007ce55b859b09553163c43?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [file-service](https://app.codecov.io/gh/apache/texera/pull/7641/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `68.90% <ø> (ø)` | | Carriedforward from [4afe8d4](https://app.codecov.io/gh/apache/texera/commit/4afe8d4ecdf6b4eff007ce55b859b09553163c43?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [frontend](https://app.codecov.io/gh/apache/texera/pull/7641/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `90.67% <ø> (ø)` | | Carriedforward from [4afe8d4](https://app.codecov.io/gh/apache/texera/commit/4afe8d4ecdf6b4eff007ce55b859b09553163c43?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [notebook-migration-service](https://app.codecov.io/gh/apache/texera/pull/7641/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `78.89% <ø> (ø)` | | Carriedforward from [4afe8d4](https://app.codecov.io/gh/apache/texera/commit/4afe8d4ecdf6b4eff007ce55b859b09553163c43?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [pyamber](https://app.codecov.io/gh/apache/texera/pull/7641/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `97.57% <ø> (ø)` | | Carriedforward from [4afe8d4](https://app.codecov.io/gh/apache/texera/commit/4afe8d4ecdf6b4eff007ce55b859b09553163c43?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [workflow-compiling-service](https://app.codecov.io/gh/apache/texera/pull/7641/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `57.89% <ø> (ø)` | | Carriedforward from [4afe8d4](https://app.codecov.io/gh/apache/texera/commit/4afe8d4ecdf6b4eff007ce55b859b09553163c43?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   *This pull request uses carry forward flags. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/texera/pull/7641?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(operator-demo-video): add the operator drag-and-connect controller [texera]

Posted by "xuang7 (via GitHub)" <gi...@apache.org>.
xuang7 commented on PR #7641:
URL: https://github.com/apache/texera/pull/7641#issuecomment-5287661174

   Could you take a look when you're available? Thanks! @carloea2


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(operator-demo-video): add the operator drag-and-connect controller [texera]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #7641:
URL: https://github.com/apache/texera/pull/7641#issuecomment-5287537354

   <!-- texera-benchmarks-comment -->
   ## ⚠️ Benchmark changes need a look
   
   🟢 0 better · 🔴 7 worse · ⚪ 8 noise (<±5%) · 0 without baseline
   
   > Compared against main `12169c2` 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](https://apache.github.io/texera/dev/bench/) · [Run](https://github.com/apache/texera/actions/runs/31753406954)
   
   | | config | throughput | MB/s | latency | max Δ latest / 7d |
   |---|---|---:|---:|---:|---:|
   | 🔴 | bs=10 sw=10 sl=64 | 356 | 0.217 | 27,605/35,107/35,107 us | 🔴 +17.0% / 🔴 +116.7% |
   | 🔴 | bs=100 sw=10 sl=64 | 769 | 0.47 | 127,381/160,450/160,450 us | 🔴 +16.8% / 🔴 +49.1% |
   | ⚪ | bs=1000 sw=10 sl=64 | 905 | 0.552 | 1,108,489/1,144,482/1,144,482 us | ⚪ within ±5% / 🔴 -12.2% |
   
   <details><summary>Baseline details</summary>
   
   Latest main `12169c2` from same runner
   
   | config | metric | PR | latest main | 7d avg | Δ latest | Δ 7d |
   |---|---|---:|---:|---:|---:|---:|
   | bs=10 sw=10 sl=64 | throughput | 356 tuples/sec | 401 tuples/sec | 774.89 tuples/sec | -11.2% | -54.1% |
   | bs=10 sw=10 sl=64 | MB/s | 0.217 MB/s | 0.245 MB/s | 0.473 MB/s | -11.4% | -54.1% |
   | bs=10 sw=10 sl=64 | p50 | 27,605 us | 23,596 us | 12,738 us | +17.0% | +116.7% |
   | bs=10 sw=10 sl=64 | p95 | 35,107 us | 36,603 us | 16,348 us | -4.1% | +114.7% |
   | bs=10 sw=10 sl=64 | p99 | 35,107 us | 36,603 us | 18,848 us | -4.1% | +86.3% |
   | bs=100 sw=10 sl=64 | throughput | 769 tuples/sec | 812 tuples/sec | 1,005 tuples/sec | -5.3% | -23.5% |
   | bs=100 sw=10 sl=64 | MB/s | 0.47 MB/s | 0.495 MB/s | 0.613 MB/s | -5.1% | -23.4% |
   | bs=100 sw=10 sl=64 | p50 | 127,381 us | 123,434 us | 100,970 us | +3.2% | +26.2% |
   | bs=100 sw=10 sl=64 | p95 | 160,450 us | 137,386 us | 107,605 us | +16.8% | +49.1% |
   | bs=100 sw=10 sl=64 | p99 | 160,450 us | 137,386 us | 116,429 us | +16.8% | +37.8% |
   | bs=1000 sw=10 sl=64 | throughput | 905 tuples/sec | 907 tuples/sec | 1,030 tuples/sec | -0.2% | -12.2% |
   | bs=1000 sw=10 sl=64 | MB/s | 0.552 MB/s | 0.554 MB/s | 0.629 MB/s | -0.4% | -12.2% |
   | bs=1000 sw=10 sl=64 | p50 | 1,108,489 us | 1,106,932 us | 991,433 us | +0.1% | +11.8% |
   | bs=1000 sw=10 sl=64 | p95 | 1,144,482 us | 1,157,207 us | 1,036,668 us | -1.1% | +10.4% |
   | bs=1000 sw=10 sl=64 | p99 | 1,144,482 us | 1,157,207 us | 1,070,470 us | -1.1% | +6.9% |
   
   </details>
   
   <details><summary>Raw CSV</summary>
   
   ```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,561.80,200,128000,356,0.217,27604.88,35106.63,35106.63
   1,100,10,64,20,2599.28,2000,1280000,769,0.470,127381.30,160450.49,160450.49
   2,1000,10,64,20,22097.42,20000,12800000,905,0.552,1108489.17,1144482.34,1144482.34
   ```
   
   </details>
   


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(operator-demo-video): add the operator drag-and-connect controller [texera]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #7641:
URL: https://github.com/apache/texera/pull/7641#issuecomment-5287475892

   <!-- texera-reviewer-suggestion -->
   ### Automated Reviewer Suggestions
   
   Based on the `git blame` history of the changed files, we recommend the following reviewers:
   
   - **Contributors with relevant context:** `@aglinxinyuan`, `@Neilk1021`, `@mengw15`
     You can notify them by mentioning `@aglinxinyuan`, `@Neilk1021`, `@mengw15` in a comment.
   


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(operator-demo-video): add the operator drag-and-connect controller [texera]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #7641:
URL: https://github.com/apache/texera/pull/7641#discussion_r3792787767


##########
docs/operator-demo-videos/src/main/scala/org/apache/texera/demovideos/controllers/OperatorControllerBuilder.scala:
##########
@@ -0,0 +1,725 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.demovideos.controllers
+
+import com.microsoft.playwright._
+import com.microsoft.playwright.options.WaitForSelectorState
+import org.apache.texera.amber.operator.metadata.OperatorMetadataGenerator
+
+// ═══════════════════════════════════════════════════════════════════
+// 3. OperatorControllerBuilder
+//    new OperatorControllerBuilder(ctx)
+//      .insertViaDrag("Bar Chart", dragNextTo = Some("CSVFileScan-operator-"))
+//      .execute()
+// ═══════════════════════════════════════════════════════════════════
+
+class OperatorControllerBuilder(ctx: ControllerContext) extends ControllerBuilder(ctx) {
+
+  private lazy val operatorMetadata = OperatorMetadataGenerator.allOperatorMetadata.operators
+  private def groupPathByName: Map[String, Seq[String]] = OperatorGroups.pathByName
+
+  // Some list items drag from an inner handle element rather than the outer container.
+  private def dragHandle(item: Locator): Locator = {
+    val draggable = Utils.firstVisible(item.locator("[draggable='true']")).orNull
+    if (draggable != null && draggable.count() > 0) draggable else item
+  }
+
+  def insertViaDrag(
+      operatorName: String,
+      operatorType: Option[String] = None,
+      canvasPosition: (Double, Double) = (0.06, 0.2),
+      dragNextTo: Option[String] = None,
+      autoConnectToAnchor: Boolean = false,
+      connectAdditionalFrom: Option[String] = None,
+      connectAdditionalFromPortIndex: Int = 0,
+      connectAdditionalToInputIndex: Option[Int] = None,
+      // Gap (px) between the anchor's right edge and the drop; ML scripts pass a
+      // tighter value because their template has more intermediate nodes.
+      dragSpacing: Double = 180.0
+  ): this.type =
+    addStep(new ControllerStep {
+      override def name =
+        s"Insert '$operatorName' via Drag${dragNextTo.map(n => s" (next to $n)").getOrElse("")}"
+      override def run(ctx: ControllerContext): Unit = {
+        val page = ctx.page
+        ctx.ensureFakeCursor()
+        val sidebarSearchText: String = operatorName
+
+        // ── Open operator panel & resolve source ──
+        val operatorsMenu = page
+          .getByTestId("operator-left-panel-operators-button")
+          .or(page.getByText("Operators", new Page.GetByTextOptions().setExact(true)))
+          .first()
+        Utils.waitVisible(operatorsMenu)
+        Utils.clickWithCursor(page, operatorsMenu)
+
+        val panelSearch = page
+          .getByTestId("operator-search-input")
+          .or(page.getByPlaceholder("search operator"))
+          .first()
+        try {
+          panelSearch.waitFor(
+            new Locator.WaitForOptions()
+              .setState(WaitForSelectorState.VISIBLE)
+              .setTimeout(Timeouts.Quick)
+          )
+        } catch {
+          case _: Exception =>
+            // Some states require one more click to switch to the Operators tab.
+            Utils.clickWithCursor(page, operatorsMenu)
+            panelSearch.waitFor(
+              new Locator.WaitForOptions()
+                .setState(WaitForSelectorState.VISIBLE)
+                .setTimeout(Timeouts.Quick)
+            )
+        }
+
+        // Locate operator from group
+        val metadata = metadataFor(operatorName, operatorType)
+        val groupPath = metadata
+          .flatMap(m => groupPathByName.get(m.additionalMetadata.operatorGroupName))
+          .getOrElse(Seq.empty)
+        val hierarchyOperator = resolveByGroupPath(page, operatorName, operatorType)
+
+        val operator = hierarchyOperator
+          .map(dragHandle)
+          .getOrElse {
+            println(s"[Operator] Hierarchy fallback to search for '$operatorName'")
+            val searchInput = page
+              .getByTestId("operator-search-input")
+              .or(page.getByPlaceholder("search operator"))
+              .first()
+            Utils.waitVisible(searchInput)
+            Utils.clickWithCursor(page, searchInput)
+            searchInput.fill(sidebarSearchText)
+            page.waitForTimeout(Delays.Settle)
+            dragHandle(resolveOperatorSource(page, sidebarSearchText, operatorType))

Review Comment:
   The hierarchy fallback does not actually resolve the visible autocomplete result. `resolveOperatorSource` first returns any matching `data-testid` by `count()`, even when that group item is hidden; if collapsed panels are not rendered it searches only `#left-container`, while the autocomplete option is in the overlay. The subsequent drag therefore gets a null bounding box or throws before the Enter fallback can run. Resolve a visible autocomplete option explicitly (or make it carry the per-operator hook) before attempting the drag.



##########
docs/operator-demo-videos/src/main/scala/org/apache/texera/demovideos/controllers/NavigationControllerBuilder.scala:
##########
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.demovideos.controllers
+
+import com.microsoft.playwright._
+import com.microsoft.playwright.options.{AriaRole, LoadState, WaitForSelectorState, WaitUntilState}
+import org.apache.texera.demovideos.config.TestDataConfig
+
+// ═══════════════════════════════════════════════════════════════════
+// 2. NavigationControllerBuilder
+//    new NavigationControllerBuilder(ctx).createNewWorkflow().execute()
+//    new NavigationControllerBuilder(ctx).importWorkflow("path/to/sample.json").execute()
+// ═══════════════════════════════════════════════════════════════════
+
+class NavigationControllerBuilder(ctx: ControllerContext) extends ControllerBuilder(ctx) {
+
+  private def gotoWorkflowList(page: Page): Unit = {
+    page.navigate(
+      s"${TestDataConfig.baseUrl}/user/workflow",
+      new Page.NavigateOptions()
+        .setWaitUntil(WaitUntilState.DOMCONTENTLOADED)
+        .setTimeout(Timeouts.Long)
+    )
+    try {
+      page.waitForLoadState(
+        LoadState.NETWORKIDLE,
+        new Page.WaitForLoadStateOptions().setTimeout(Timeouts.Medium)
+      )
+    } catch {
+      case _: Exception =>
+    }
+  }
+
+  private def waitForCanvas(page: Page): Unit = {
+    page
+      .getByTestId("navigation-workflow-canvas")
+      .first()
+      .waitFor(
+        new Locator.WaitForOptions()
+          .setState(WaitForSelectorState.VISIBLE)
+          .setTimeout(Timeouts.Long)
+      )
+  }
+
+  def createNewWorkflow(): this.type =
+    addStep(new ControllerStep {
+      override def name = "Create New Workflow"
+      override def run(ctx: ControllerContext): Unit = {
+        val page = ctx.page
+        ctx.ensureFakeCursor()
+        gotoWorkflowList(page)
+
+        val createBtn = page
+          .getByTestId("navigation-create-workflow-button")
+          .or(
+            page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Create Workflow"))
+          )
+          .first()
+        Utils.clickWithCursor(page, createBtn)
+
+        try waitForCanvas(page)
+        catch {
+          case _: Exception =>
+            if (!page.url().contains("/workflow/")) {
+              throw new RuntimeException("Create workflow did not open workflow editor.")
+            }
+        }
+      }
+    })
+
+  def importWorkflow(jsonFilePath: String): this.type =
+    addStep(new ControllerStep {
+      override def name = s"Import Workflow from ${jsonFilePath.split("/").last}"
+      override def run(ctx: ControllerContext): Unit = {
+        val page = ctx.page
+        ctx.ensureFakeCursor()
+
+        val filePath = java.nio.file.Paths.get(jsonFilePath)
+        if (!java.nio.file.Files.exists(filePath)) {
+          throw new RuntimeException(s"Workflow JSON not found: $jsonFilePath")
+        }
+        // The dashboard names the uploaded workflow after the file, minus the extension.
+        val fileName = filePath.getFileName.toString
+        val workflowName = {
+          val dot = fileName.lastIndexOf('.')
+          if (dot == -1) fileName else fileName.substring(0, dot)
+        }
+
+        // Uploading from the workflow listing creates a NEW workflow named after the
+        // file and appends it to the list; it is not opened automatically.
+        gotoWorkflowList(page)
+
+        val uploadBtn = page
+          .getByTestId("navigation-upload-workflow-button")
+          .or(page.getByTitle("Upload ZIP/JSON file as workflow"))
+          .first()
+        Utils.waitVisible(uploadBtn)
+        val chooser = page.waitForFileChooser(
+          new Page.WaitForFileChooserOptions().setTimeout(Timeouts.Medium),
+          () => {
+            Utils.clickWithCursor(page, uploadBtn)
+          }
+        )
+        chooser.setFiles(filePath)
+
+        try {
+          page
+            .getByText("Upload Successful")
+            .first()
+            .waitFor(
+              new Locator.WaitForOptions()
+                .setState(WaitForSelectorState.VISIBLE)
+                .setTimeout(Timeouts.Long)
+            )
+        } catch {
+          case _: Exception =>
+            println("[Import] Upload confirmation not seen; falling back to the list entry")
+        }
+
+        // The upload handler refreshes the search afterwards, which re-sorts the
+        // list newest-first — so the FIRST same-named entry is this upload's workflow.
+        // .workflow-name is the list view, .resource-name the card view; which one
+        // renders depends on the user's saved view preference.
+        val entry = page
+          .locator(".workflow-name, .resource-name")
+          .filter(new Locator.FilterOptions().setHasText(workflowName))
+          .first()

Review Comment:
   `setHasText(workflowName)` performs a substring match, so importing `foo.json` can click a newer `foobar` entry instead of the uploaded `foo` workflow. Use an exact text locator or an anchored, escaped regex before selecting the first same-named result.



##########
docs/operator-demo-videos/src/main/scala/org/apache/texera/demovideos/controllers/OperatorControllerBuilder.scala:
##########
@@ -0,0 +1,725 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.demovideos.controllers
+
+import com.microsoft.playwright._
+import com.microsoft.playwright.options.WaitForSelectorState
+import org.apache.texera.amber.operator.metadata.OperatorMetadataGenerator
+
+// ═══════════════════════════════════════════════════════════════════
+// 3. OperatorControllerBuilder
+//    new OperatorControllerBuilder(ctx)
+//      .insertViaDrag("Bar Chart", dragNextTo = Some("CSVFileScan-operator-"))
+//      .execute()
+// ═══════════════════════════════════════════════════════════════════
+
+class OperatorControllerBuilder(ctx: ControllerContext) extends ControllerBuilder(ctx) {
+
+  private lazy val operatorMetadata = OperatorMetadataGenerator.allOperatorMetadata.operators
+  private def groupPathByName: Map[String, Seq[String]] = OperatorGroups.pathByName
+
+  // Some list items drag from an inner handle element rather than the outer container.
+  private def dragHandle(item: Locator): Locator = {
+    val draggable = Utils.firstVisible(item.locator("[draggable='true']")).orNull
+    if (draggable != null && draggable.count() > 0) draggable else item
+  }
+
+  def insertViaDrag(
+      operatorName: String,
+      operatorType: Option[String] = None,
+      canvasPosition: (Double, Double) = (0.06, 0.2),
+      dragNextTo: Option[String] = None,
+      autoConnectToAnchor: Boolean = false,
+      connectAdditionalFrom: Option[String] = None,
+      connectAdditionalFromPortIndex: Int = 0,
+      connectAdditionalToInputIndex: Option[Int] = None,
+      // Gap (px) between the anchor's right edge and the drop; ML scripts pass a
+      // tighter value because their template has more intermediate nodes.
+      dragSpacing: Double = 180.0
+  ): this.type =
+    addStep(new ControllerStep {
+      override def name =
+        s"Insert '$operatorName' via Drag${dragNextTo.map(n => s" (next to $n)").getOrElse("")}"
+      override def run(ctx: ControllerContext): Unit = {
+        val page = ctx.page
+        ctx.ensureFakeCursor()
+        val sidebarSearchText: String = operatorName
+
+        // ── Open operator panel & resolve source ──
+        val operatorsMenu = page
+          .getByTestId("operator-left-panel-operators-button")
+          .or(page.getByText("Operators", new Page.GetByTextOptions().setExact(true)))
+          .first()
+        Utils.waitVisible(operatorsMenu)
+        Utils.clickWithCursor(page, operatorsMenu)
+
+        val panelSearch = page
+          .getByTestId("operator-search-input")
+          .or(page.getByPlaceholder("search operator"))
+          .first()
+        try {
+          panelSearch.waitFor(
+            new Locator.WaitForOptions()
+              .setState(WaitForSelectorState.VISIBLE)
+              .setTimeout(Timeouts.Quick)
+          )
+        } catch {
+          case _: Exception =>
+            // Some states require one more click to switch to the Operators tab.
+            Utils.clickWithCursor(page, operatorsMenu)
+            panelSearch.waitFor(
+              new Locator.WaitForOptions()
+                .setState(WaitForSelectorState.VISIBLE)
+                .setTimeout(Timeouts.Quick)
+            )
+        }
+
+        // Locate operator from group
+        val metadata = metadataFor(operatorName, operatorType)
+        val groupPath = metadata
+          .flatMap(m => groupPathByName.get(m.additionalMetadata.operatorGroupName))
+          .getOrElse(Seq.empty)
+        val hierarchyOperator = resolveByGroupPath(page, operatorName, operatorType)
+
+        val operator = hierarchyOperator
+          .map(dragHandle)
+          .getOrElse {
+            println(s"[Operator] Hierarchy fallback to search for '$operatorName'")
+            val searchInput = page
+              .getByTestId("operator-search-input")
+              .or(page.getByPlaceholder("search operator"))
+              .first()
+            Utils.waitVisible(searchInput)
+            Utils.clickWithCursor(page, searchInput)
+            searchInput.fill(sidebarSearchText)
+            page.waitForTimeout(Delays.Settle)
+            dragHandle(resolveOperatorSource(page, sidebarSearchText, operatorType))
+          }
+        operator.scrollIntoViewIfNeeded()
+        page.waitForTimeout(Delays.Tick)
+
+        // ── Prepare canvas ──
+        val canvas = page
+          .getByTestId("navigation-workflow-canvas")
+          .or(page.locator("svg[joint-selector='svg'], svg#v-2"))
+          .first()
+        Utils.waitVisible(canvas)
+        canvas.scrollIntoViewIfNeeded()
+        page.waitForTimeout(Delays.Tick)
+
+        val beforeCount = page.locator("g.joint-cell.joint-element").count()
+        val beforeLinkCount = page.locator("g.joint-cell.joint-link").count()
+        val canvasBox = canvas.boundingBox()
+        if (canvasBox == null)
+          throw new RuntimeException("Drag failed: missing canvas bounding box")
+
+        // ── Calculate drop position ──
+        val anchorNode: Option[Locator] = dragNextTo.flatMap(findNodeByType(page, _))
+
+        if (dragNextTo.isDefined && anchorNode.isEmpty) {
+          println(
+            s"[Operator] Warning: dragNextTo='${dragNextTo.get}' not found on canvas, using default position"
+          )
+        }
+
+        val (tgtX, tgtY) = anchorNode
+          .flatMap { anchor =>
+            val box = Utils.cellBox(anchor)
+            if (box != null) {
+              Some(
+                (
+                  math.min(canvasBox.x + canvasBox.width - 30, box.x + box.width + dragSpacing),
+                  box.y + box.height / 2.0 - 40.0 // slight lift so the label row stays readable
+                )
+              )
+            } else None
+          }
+          .getOrElse {
+            // No anchor: place at the canvasPosition fraction, stepping a 4-column grid
+            // (~node footprint) past any existing nodes. The min() clamps keep the drop
+            // inside the canvas — outside it the drop is silently lost.
+            val index = Math.max(0, beforeCount)
+            val baseX = canvasBox.x + canvasBox.width * canvasPosition._1
+            val baseY = canvasBox.y + canvasBox.height * canvasPosition._2
+            (
+              math.min(canvasBox.x + canvasBox.width - 40, baseX + (index % 4) * 180),
+              math.min(canvasBox.y + canvasBox.height - 40, baseY + (index / 4) * 120)
+            )
+          }
+
+        // ── Perform drag with fallbacks ──
+        performDrag(page, operator, tgtX, tgtY)
+
+        val targetCount = beforeCount + 1
+        if (!waitForNodeCountAtLeast(page, targetCount, maxRetries = 20)) {
+          val searchInput = page
+            .getByTestId("operator-search-input")
+            .or(page.getByPlaceholder("search operator"))
+            .first()
+          Utils.waitVisible(searchInput)
+          Utils.clickWithCursor(page, searchInput)
+          searchInput.fill("")
+          page.waitForTimeout(Delays.Tick)
+          val retryOperator =
+            dragHandle(resolveOperatorSource(page, sidebarSearchText, operatorType))
+          performDrag(page, retryOperator, tgtX, tgtY)
+        }
+        if (!waitForNodeCountAtLeast(page, targetCount, maxRetries = 20)) {
+          // Last fallback: insert through search + Enter when drag source is flaky.
+          val searchInput = page
+            .getByTestId("operator-search-input")
+            .or(page.getByPlaceholder("search operator"))
+            .first()
+          Utils.waitVisible(searchInput)
+          Utils.clickWithCursor(page, searchInput)
+          searchInput.fill("")
+          page.waitForTimeout(Delays.Tick)
+          searchInput.fill(sidebarSearchText)
+          page.waitForTimeout(Delays.Tick)
+          searchInput.press("Enter")
+        }
+        if (!waitForNodeCountAtLeast(page, targetCount, maxRetries = 20)) {
+          throw new RuntimeException(
+            s"Insert failed for '$operatorName' (${operatorType.getOrElse("unknown")}). " +
+              s"Canvas count did not increase from $beforeCount."
+          )
+        }
+
+        val centerBtn = page.getByTitle("minimap-center-button")
+        if (centerBtn.count() > 0) {
+          Utils.clickWithCursor(page, centerBtn)
+          page.waitForTimeout(Delays.Tick)
+        }
+
+        // ── Click the new node to select it ──
+        val newNode = operatorType
+          .flatMap(findNodeByType(page, _))
+          .getOrElse(Utils.waitVisible(page.locator("g.joint-cell.joint-element").nth(beforeCount)))

Review Comment:
   This can select an existing operator of the same type rather than the node just inserted because `findNodeByType` returns the first match. Connections and repositioning would then modify the old node and leave the new node unwired. Select the newly appended element, as the fallback already does.



##########
docs/operator-demo-videos/src/main/scala/org/apache/texera/demovideos/controllers/OperatorControllerBuilder.scala:
##########
@@ -0,0 +1,725 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.demovideos.controllers
+
+import com.microsoft.playwright._
+import com.microsoft.playwright.options.WaitForSelectorState
+import org.apache.texera.amber.operator.metadata.OperatorMetadataGenerator
+
+// ═══════════════════════════════════════════════════════════════════
+// 3. OperatorControllerBuilder
+//    new OperatorControllerBuilder(ctx)
+//      .insertViaDrag("Bar Chart", dragNextTo = Some("CSVFileScan-operator-"))
+//      .execute()
+// ═══════════════════════════════════════════════════════════════════
+
+class OperatorControllerBuilder(ctx: ControllerContext) extends ControllerBuilder(ctx) {
+
+  private lazy val operatorMetadata = OperatorMetadataGenerator.allOperatorMetadata.operators
+  private def groupPathByName: Map[String, Seq[String]] = OperatorGroups.pathByName
+
+  // Some list items drag from an inner handle element rather than the outer container.
+  private def dragHandle(item: Locator): Locator = {
+    val draggable = Utils.firstVisible(item.locator("[draggable='true']")).orNull
+    if (draggable != null && draggable.count() > 0) draggable else item
+  }
+
+  def insertViaDrag(
+      operatorName: String,
+      operatorType: Option[String] = None,
+      canvasPosition: (Double, Double) = (0.06, 0.2),
+      dragNextTo: Option[String] = None,
+      autoConnectToAnchor: Boolean = false,
+      connectAdditionalFrom: Option[String] = None,
+      connectAdditionalFromPortIndex: Int = 0,
+      connectAdditionalToInputIndex: Option[Int] = None,
+      // Gap (px) between the anchor's right edge and the drop; ML scripts pass a
+      // tighter value because their template has more intermediate nodes.
+      dragSpacing: Double = 180.0
+  ): this.type =
+    addStep(new ControllerStep {
+      override def name =
+        s"Insert '$operatorName' via Drag${dragNextTo.map(n => s" (next to $n)").getOrElse("")}"
+      override def run(ctx: ControllerContext): Unit = {
+        val page = ctx.page
+        ctx.ensureFakeCursor()
+        val sidebarSearchText: String = operatorName
+
+        // ── Open operator panel & resolve source ──
+        val operatorsMenu = page
+          .getByTestId("operator-left-panel-operators-button")
+          .or(page.getByText("Operators", new Page.GetByTextOptions().setExact(true)))
+          .first()
+        Utils.waitVisible(operatorsMenu)
+        Utils.clickWithCursor(page, operatorsMenu)
+
+        val panelSearch = page
+          .getByTestId("operator-search-input")
+          .or(page.getByPlaceholder("search operator"))
+          .first()
+        try {
+          panelSearch.waitFor(
+            new Locator.WaitForOptions()
+              .setState(WaitForSelectorState.VISIBLE)
+              .setTimeout(Timeouts.Quick)
+          )
+        } catch {
+          case _: Exception =>
+            // Some states require one more click to switch to the Operators tab.
+            Utils.clickWithCursor(page, operatorsMenu)
+            panelSearch.waitFor(
+              new Locator.WaitForOptions()
+                .setState(WaitForSelectorState.VISIBLE)
+                .setTimeout(Timeouts.Quick)
+            )
+        }
+
+        // Locate operator from group
+        val metadata = metadataFor(operatorName, operatorType)
+        val groupPath = metadata
+          .flatMap(m => groupPathByName.get(m.additionalMetadata.operatorGroupName))
+          .getOrElse(Seq.empty)
+        val hierarchyOperator = resolveByGroupPath(page, operatorName, operatorType)
+
+        val operator = hierarchyOperator
+          .map(dragHandle)
+          .getOrElse {
+            println(s"[Operator] Hierarchy fallback to search for '$operatorName'")
+            val searchInput = page
+              .getByTestId("operator-search-input")
+              .or(page.getByPlaceholder("search operator"))
+              .first()
+            Utils.waitVisible(searchInput)
+            Utils.clickWithCursor(page, searchInput)
+            searchInput.fill(sidebarSearchText)
+            page.waitForTimeout(Delays.Settle)
+            dragHandle(resolveOperatorSource(page, sidebarSearchText, operatorType))
+          }
+        operator.scrollIntoViewIfNeeded()
+        page.waitForTimeout(Delays.Tick)
+
+        // ── Prepare canvas ──
+        val canvas = page
+          .getByTestId("navigation-workflow-canvas")
+          .or(page.locator("svg[joint-selector='svg'], svg#v-2"))
+          .first()
+        Utils.waitVisible(canvas)
+        canvas.scrollIntoViewIfNeeded()
+        page.waitForTimeout(Delays.Tick)
+
+        val beforeCount = page.locator("g.joint-cell.joint-element").count()
+        val beforeLinkCount = page.locator("g.joint-cell.joint-link").count()
+        val canvasBox = canvas.boundingBox()
+        if (canvasBox == null)
+          throw new RuntimeException("Drag failed: missing canvas bounding box")
+
+        // ── Calculate drop position ──
+        val anchorNode: Option[Locator] = dragNextTo.flatMap(findNodeByType(page, _))
+
+        if (dragNextTo.isDefined && anchorNode.isEmpty) {
+          println(
+            s"[Operator] Warning: dragNextTo='${dragNextTo.get}' not found on canvas, using default position"
+          )
+        }
+
+        val (tgtX, tgtY) = anchorNode
+          .flatMap { anchor =>
+            val box = Utils.cellBox(anchor)
+            if (box != null) {
+              Some(
+                (
+                  math.min(canvasBox.x + canvasBox.width - 30, box.x + box.width + dragSpacing),
+                  box.y + box.height / 2.0 - 40.0 // slight lift so the label row stays readable
+                )
+              )
+            } else None
+          }
+          .getOrElse {
+            // No anchor: place at the canvasPosition fraction, stepping a 4-column grid
+            // (~node footprint) past any existing nodes. The min() clamps keep the drop
+            // inside the canvas — outside it the drop is silently lost.
+            val index = Math.max(0, beforeCount)
+            val baseX = canvasBox.x + canvasBox.width * canvasPosition._1
+            val baseY = canvasBox.y + canvasBox.height * canvasPosition._2
+            (
+              math.min(canvasBox.x + canvasBox.width - 40, baseX + (index % 4) * 180),
+              math.min(canvasBox.y + canvasBox.height - 40, baseY + (index / 4) * 120)
+            )
+          }
+
+        // ── Perform drag with fallbacks ──
+        performDrag(page, operator, tgtX, tgtY)
+
+        val targetCount = beforeCount + 1
+        if (!waitForNodeCountAtLeast(page, targetCount, maxRetries = 20)) {
+          val searchInput = page
+            .getByTestId("operator-search-input")
+            .or(page.getByPlaceholder("search operator"))
+            .first()
+          Utils.waitVisible(searchInput)
+          Utils.clickWithCursor(page, searchInput)
+          searchInput.fill("")
+          page.waitForTimeout(Delays.Tick)
+          val retryOperator =
+            dragHandle(resolveOperatorSource(page, sidebarSearchText, operatorType))
+          performDrag(page, retryOperator, tgtX, tgtY)
+        }
+        if (!waitForNodeCountAtLeast(page, targetCount, maxRetries = 20)) {
+          // Last fallback: insert through search + Enter when drag source is flaky.
+          val searchInput = page
+            .getByTestId("operator-search-input")
+            .or(page.getByPlaceholder("search operator"))
+            .first()
+          Utils.waitVisible(searchInput)
+          Utils.clickWithCursor(page, searchInput)
+          searchInput.fill("")
+          page.waitForTimeout(Delays.Tick)
+          searchInput.fill(sidebarSearchText)
+          page.waitForTimeout(Delays.Tick)
+          searchInput.press("Enter")
+        }
+        if (!waitForNodeCountAtLeast(page, targetCount, maxRetries = 20)) {
+          throw new RuntimeException(
+            s"Insert failed for '$operatorName' (${operatorType.getOrElse("unknown")}). " +
+              s"Canvas count did not increase from $beforeCount."
+          )
+        }
+
+        val centerBtn = page.getByTitle("minimap-center-button")
+        if (centerBtn.count() > 0) {
+          Utils.clickWithCursor(page, centerBtn)
+          page.waitForTimeout(Delays.Tick)
+        }
+
+        // ── Click the new node to select it ──
+        val newNode = operatorType
+          .flatMap(findNodeByType(page, _))
+          .getOrElse(Utils.waitVisible(page.locator("g.joint-cell.joint-element").nth(beforeCount)))
+        if (newNode.count() > 0) {
+          val body = newNode.locator("rect.body").first()
+          if (body.count() > 0) Utils.clickWithCursor(page, body)
+          else Utils.clickWithCursor(page, newNode)
+        }
+
+        if (
+          autoConnectToAnchor && dragNextTo.isDefined && anchorNode.exists(_.count() > 0) && newNode
+            .count() > 0
+        ) {
+          // Check if the drag itself already created a link (canvas port-snapping)
+          val currentLinkCount = page.locator("g.joint-cell.joint-link").count()
+          if (currentLinkCount > beforeLinkCount) {
+            println(
+              s"[Operator] Drag already created a link for '$operatorName', skipping autoConnect"
+            )
+          } else {
+            val connected = tryAutoConnect(
+              page,
+              anchorNode.get,
+              newNode,
+              fromPortIndex = 0,
+              toPortIndex = 0
+            )
+            if (connected) {
+              var retries = 0
+              while (
+                page
+                  .locator("g.joint-cell.joint-link")
+                  .count() <= beforeLinkCount && retries < Retries.Short
+              ) {
+                page.waitForTimeout(Delays.Tick)
+                retries += 1
+              }
+              if (page.locator("g.joint-cell.joint-link").count() <= beforeLinkCount) {
+                println(
+                  s"[Operator] Warning: explicit connect attempted but no new link was detected for '$operatorName'"
+                )
+              }
+            } else {
+              println(s"[Operator] Warning: could not locate connectable ports for '$operatorName'")
+            }
+          }
+        }
+
+        if (connectAdditionalFrom.isDefined && newNode.count() > 0) {
+          // Clear state from the first connection before attempting the second
+          try page.keyboard().press("Escape")
+          catch { case _: Exception => }
+          page.waitForTimeout(Delays.Settle)
+
+          val additionalFromNode = findNodeByType(page, connectAdditionalFrom.get)
+          if (additionalFromNode.isEmpty) {
+            println(
+              s"[Operator] Warning: connectAdditionalFrom='${connectAdditionalFrom.get}' not found on canvas"
+            )
+          } else {
+            val expectedLinkCount = page.locator("g.joint-cell.joint-link").count() + 1
+            val targetInputPort = connectAdditionalToInputIndex.getOrElse(0)
+
+            val inputPorts = collectInputPortCount(page, newNode)
+            val alreadyConnected =
+              inputPorts > 0 && page.locator("g.joint-cell.joint-link").count() >= expectedLinkCount

Review Comment:
   The default two-input path targets input 0 twice: the anchor connection uses port 0, and `connectAdditionalToInputIndex = None` also resolves to 0. Moreover, `alreadyConnected` compares the current count with that same count plus one, so it can never detect the occupied port. A call that omits the optional target cannot wire the second input; infer an unconnected input (normally port 1 after auto-connect) and determine occupancy from link endpoints.



##########
docs/operator-demo-videos/src/main/scala/org/apache/texera/demovideos/controllers/OperatorControllerBuilder.scala:
##########
@@ -0,0 +1,725 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.texera.demovideos.controllers
+
+import com.microsoft.playwright._
+import com.microsoft.playwright.options.WaitForSelectorState
+import org.apache.texera.amber.operator.metadata.OperatorMetadataGenerator
+
+// ═══════════════════════════════════════════════════════════════════
+// 3. OperatorControllerBuilder
+//    new OperatorControllerBuilder(ctx)
+//      .insertViaDrag("Bar Chart", dragNextTo = Some("CSVFileScan-operator-"))
+//      .execute()
+// ═══════════════════════════════════════════════════════════════════
+
+class OperatorControllerBuilder(ctx: ControllerContext) extends ControllerBuilder(ctx) {
+
+  private lazy val operatorMetadata = OperatorMetadataGenerator.allOperatorMetadata.operators
+  private def groupPathByName: Map[String, Seq[String]] = OperatorGroups.pathByName
+
+  // Some list items drag from an inner handle element rather than the outer container.
+  private def dragHandle(item: Locator): Locator = {
+    val draggable = Utils.firstVisible(item.locator("[draggable='true']")).orNull
+    if (draggable != null && draggable.count() > 0) draggable else item
+  }
+
+  def insertViaDrag(
+      operatorName: String,
+      operatorType: Option[String] = None,
+      canvasPosition: (Double, Double) = (0.06, 0.2),
+      dragNextTo: Option[String] = None,
+      autoConnectToAnchor: Boolean = false,
+      connectAdditionalFrom: Option[String] = None,
+      connectAdditionalFromPortIndex: Int = 0,
+      connectAdditionalToInputIndex: Option[Int] = None,
+      // Gap (px) between the anchor's right edge and the drop; ML scripts pass a
+      // tighter value because their template has more intermediate nodes.
+      dragSpacing: Double = 180.0
+  ): this.type =
+    addStep(new ControllerStep {
+      override def name =
+        s"Insert '$operatorName' via Drag${dragNextTo.map(n => s" (next to $n)").getOrElse("")}"
+      override def run(ctx: ControllerContext): Unit = {
+        val page = ctx.page
+        ctx.ensureFakeCursor()
+        val sidebarSearchText: String = operatorName
+
+        // ── Open operator panel & resolve source ──
+        val operatorsMenu = page
+          .getByTestId("operator-left-panel-operators-button")
+          .or(page.getByText("Operators", new Page.GetByTextOptions().setExact(true)))
+          .first()
+        Utils.waitVisible(operatorsMenu)
+        Utils.clickWithCursor(page, operatorsMenu)
+
+        val panelSearch = page
+          .getByTestId("operator-search-input")
+          .or(page.getByPlaceholder("search operator"))
+          .first()
+        try {
+          panelSearch.waitFor(
+            new Locator.WaitForOptions()
+              .setState(WaitForSelectorState.VISIBLE)
+              .setTimeout(Timeouts.Quick)
+          )
+        } catch {
+          case _: Exception =>
+            // Some states require one more click to switch to the Operators tab.
+            Utils.clickWithCursor(page, operatorsMenu)
+            panelSearch.waitFor(
+              new Locator.WaitForOptions()
+                .setState(WaitForSelectorState.VISIBLE)
+                .setTimeout(Timeouts.Quick)
+            )
+        }
+
+        // Locate operator from group
+        val metadata = metadataFor(operatorName, operatorType)
+        val groupPath = metadata
+          .flatMap(m => groupPathByName.get(m.additionalMetadata.operatorGroupName))
+          .getOrElse(Seq.empty)
+        val hierarchyOperator = resolveByGroupPath(page, operatorName, operatorType)
+
+        val operator = hierarchyOperator
+          .map(dragHandle)
+          .getOrElse {
+            println(s"[Operator] Hierarchy fallback to search for '$operatorName'")
+            val searchInput = page
+              .getByTestId("operator-search-input")
+              .or(page.getByPlaceholder("search operator"))
+              .first()
+            Utils.waitVisible(searchInput)
+            Utils.clickWithCursor(page, searchInput)
+            searchInput.fill(sidebarSearchText)
+            page.waitForTimeout(Delays.Settle)
+            dragHandle(resolveOperatorSource(page, sidebarSearchText, operatorType))
+          }
+        operator.scrollIntoViewIfNeeded()
+        page.waitForTimeout(Delays.Tick)
+
+        // ── Prepare canvas ──
+        val canvas = page
+          .getByTestId("navigation-workflow-canvas")
+          .or(page.locator("svg[joint-selector='svg'], svg#v-2"))
+          .first()
+        Utils.waitVisible(canvas)
+        canvas.scrollIntoViewIfNeeded()
+        page.waitForTimeout(Delays.Tick)
+
+        val beforeCount = page.locator("g.joint-cell.joint-element").count()
+        val beforeLinkCount = page.locator("g.joint-cell.joint-link").count()
+        val canvasBox = canvas.boundingBox()
+        if (canvasBox == null)
+          throw new RuntimeException("Drag failed: missing canvas bounding box")
+
+        // ── Calculate drop position ──
+        val anchorNode: Option[Locator] = dragNextTo.flatMap(findNodeByType(page, _))
+
+        if (dragNextTo.isDefined && anchorNode.isEmpty) {
+          println(
+            s"[Operator] Warning: dragNextTo='${dragNextTo.get}' not found on canvas, using default position"
+          )
+        }

Review Comment:
   When `autoConnectToAnchor` is requested, a missing anchor only emits a warning and the step succeeds with an unwired operator. This violates the requested operation and can silently produce an invalid demo; fail the step when connection was requested while retaining the fallback for positioning-only calls.
   
   This issue also appears in the following locations of the same file:
   - line 254
   - line 267
   - line 325



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(operator-demo-video): add the operator drag-and-connect controller [texera]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #7641: feat(operator-demo-video): add the operator drag-and-connect controller
URL: https://github.com/apache/texera/pull/7641


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org