You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@texera.apache.org by "yangzhang75 (via GitHub)" <gi...@apache.org> on 2026/10/04 04:15:04 UTC

[PR] fix(workflow-form): let a card change its operator's siblings the way the panel does, so the HuggingFace task change persists on the form [texera]

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

   ### What changes were proposed in this PR?
   
   Closes #8762. Part of the Form View feature (#8011); from the #8439 refinements (item 3).
   
   An exposed HuggingFace model picker (`modelId`) on the Form View offered a live task selector that could not persist. The card wrote back only the property it was bound to, under the binding's id, and the operator's other properties were a read-only copy with no controls behind them. Changing the task on the form switched the model list, but the operator kept its task; a reload showed the old one, and a model picked meanwhile was saved for a task the operator does not run.
   
   The Form View is another way to show the canvas, so the fix makes the card behave like the operator property panel for the property it exposes, rather than freezing the selector:
   
   - The field keeps the property's own key (`modelId`, not the binding id), so a widget that reaches itself or a sibling by key finds the same keys as on the panel. The card's model is the operator's properties, as the panel's is.
   - The operator's other properties ride along as plain controls on the card's form (formly builds only the exposed field), so a widget finds its siblings on the card's form exactly as on the panel's -- the HuggingFace picker writes `task` through its control, which is also what announces the change, and resets the task-scoped fields through theirs; a control-level write lands in the model.
   - The card writes back everything that differs from the operator, in one edit (`FormBindingService.writeProperties`): the bound property and whatever siblings the widget changed, the way the panel writes its whole model. The guard against formly's blank build-time default stays, for the bound property only.
   - The HuggingFace widget itself is unchanged: on the form a task change now does on the operator what it does on the canvas (new task, model and task-scoped fields reset), and the reader then picks a model for that task.
   
   ### Any related issues, documentation, discussions?
   
   Closes #8762. Raised by Copilot on #8437; filed from #8439. A first version froze the task on the form; dropped on the principle that the form stays consistent with the canvas, filling gaps rather than hiding controls. Known limitation, not this PR's: a card's context is read once per build, so between a co-editor's edit of the same operator on the canvas and the form's next rebuild the card can show a stale sibling (every seeded card today; tracked as a follow-up).
   
   ### How was this PR tested?
   
   Unit tests (vitest). The form's spec: the field is keyed by its property; the card's model carries the operator's other properties and its form carries them as controls; a sibling a widget changed is written back along with the bound value, in one call; a sibling control's change lands in the model; an unchanged sibling emission writes nothing; the existing write-back guards (unchanged value, blank before an edit, dirtied value, snapshot refresh) hold with the property key. The binding service's spec: `writeProperties` writes several properties over the current ones and is a no-op for a missing operator. The HuggingFace spec: on a card shaped as the form shapes it (bound field `modelId`, siblings as plain controls), a task change writes the task to the card's form, resets the model and the task-scoped controls, and the form hears it, which is what the card's write-back listens to. Each guard was deletion-checked and turned a named test red. eslint, prettier and the production (AOT
 ) build pass; the full frontend suite passes; every line this PR adds is covered.
   
   Checked by hand on a flag-on instance (main-demo, wid 14): on the form, switching the task to Text Generation reloads the model list; after the save the canvas panel shows the new task with the model cleared; picking a model on the form lands on the canvas; before the fix the same switch reverted on reload and the model was saved under the old task.
   
   ### Was this PR authored or co-authored using generative AI tooling?
   
   Yes. Generated-by: Claude Code (Claude Fable 5.1, Anthropic). Co-authored with Claude, reviewed line by line by the author before submission.
   
   πŸ€– 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: notifications-unsubscribe@texera.apache.org

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


Re: [PR] fix(workflow-form): let a card change its operator's siblings the way the panel does, so the HuggingFace task change persists on the form [texera]

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


##########
frontend/src/app/workspace/component/hugging-face/hugging-face.component.ts:
##########
@@ -200,6 +203,25 @@ export class HuggingFaceComponent extends FieldType<FieldTypeConfig> implements
     );
   }
 
+  /**
+   * The task can change under this widget: a co-editor's edit, or the Form View's, lands on the
+   * operator and from there on this field's model (the panel hands formly a fresh model object; the
+   * form card is rebuilt). The selector shows this widget's own state, and on the panel the schema's
+   * `task` field is hidden, so there is no control to listen to: the model is checked on every
+   * change detection instead, and the selector follows it as a local pick is followed -- show the
+   * task, load its models -- rather than keeping what it showed when it was built.
+   */
+  ngDoCheck(): void {
+    const tag = this.model?.task;
+    if (!this.initialized || typeof tag !== "string" || !tag || tag === this.selectedTaskTag) {
+      return;
+    }
+    this.selectedTaskTag = tag;
+    this.searchText = "";
+    this.filteredModels = null;
+    this.loadAllModels();

Review Comment:
   Confirmed and fixed in 29cec391. Anything that comes back for a task the widget has since left is cached for the next asker and not shown -- the response, the failure, and a poll waiting on another instance's request, which is now stopped at the top of the next load whichever path that load takes. Three tests cover it, each deletion-checked. The race predates this PR (picking a second task while the first loads does it on main); this PR adds the no-click trigger, so the guard belongs with it.



-- 
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] fix(workflow-form): let a card change its operator's siblings the way the panel does, so the HuggingFace task change persists on the form [texera]

Posted by "yangzhang75 (via GitHub) via notifications" <no...@texera.apache.org>.
yangzhang75 commented on code in PR #8839:
URL: https://github.com/apache/texera/pull/8839#discussion_r4445529406


##########
frontend/src/app/workspace/component/workflow-form/workflow-form.component.ts:
##########
@@ -1006,22 +1042,44 @@ export class WorkflowFormComponent implements OnInit, OnDestroy {
     // The schema's own title ("Attributes", "Limit", "File") -- the reader's title when unnamed.
     // Falls back to this, not the lower-camel key ("fileName"), which would read inconsistently.
     const schemaLabel = (source.props?.label as string) || binding.propertyKey;
-    field.key = binding.id;
+    // The field keeps the property's own key, as on the operator property panel: a widget that
+    // reaches a sibling or itself by key (the HuggingFace picker resets `modelId` and its
+    // task-scoped siblings on a task change) must find the same controls and model keys here.
     field.props = {
       ...(field.props ?? {}),
       label: binding.displayName || schemaLabel,
     };

Review Comment:
   `field` is `cloneDeep(source)`, and `source` is the formly child found by `child.key === binding.propertyKey` a few lines up, so the key is already the property's; assigning it again would be a no-op. The spec pins it: "renders a healthy input as a real formly field keyed by its property, as the panel does" asserts `fields[0].key` is `"n_hvg"`. No change.



##########
frontend/src/app/workspace/component/workflow-form/workflow-form.component.ts:
##########
@@ -563,6 +563,32 @@ export class WorkflowFormComponent implements OnInit, OnDestroy {
    */
   @HostListener("focusout")
   public onFocusOut(): void {
+    this.flushHeldRebuild();
+  }
+
+  /**
+   * A click or a key also ends a hold, because a focus change is not the only thing that does:
+   * closing an nz-select leaves the focus in its search box (ng-zorro re-focuses it), so no focusout
+   * fires, and a rebuild held while the list was open would have waited for an unrelated event
+   * (Copilot on #8839). The same later() re-check as below decides it after the current tick, by
+   * when the dropdown has lost its open class.
+   *
+   * The click is listened for on the document, not on this host. A dropdown's options are drawn in
+   * the CDK's overlay container, a sibling of the whole app rather than a descendant of this page,
+   * so the click that picks one -- or that picks the option already chosen, which changes no value
+   * and moves no focus -- never bubbles through here (Copilot). A click anywhere else ends the hold
+   * for the same reason a focusout does: the reader is no longer typing into the card. The handler
+   * returns at once unless a rebuild is actually held. Keys stay on the host: what is typed goes
+   * into controls this page owns (nz-select keeps its search box in the trigger, not the overlay),
+   * and a document-wide key listener would run on every keystroke in the workspace.
+   */
+  @HostListener("document:click")
+  @HostListener("keyup")
+  public onInteraction(): void {
+    this.flushHeldRebuild();
+  }
+
+  private flushHeldRebuild(): void {
     if (this.rebuildDeferred) {
       this.later(() => {
         if (this.rebuildDeferred) {

Review Comment:
   Done: `flushHeldRebuild` is single-flight now, with a `flushQueued` flag the callback clears. A burst of keys queues one re-check; a spec asserts five interactions queue one `later` and run the held rebuild once, and that the next hold is re-checked again. (f4ea02e80)



##########
frontend/src/app/workspace/service/form-binding/form-binding.service.ts:
##########
@@ -209,13 +209,23 @@ export class FormBindingService {
    * why a run started from either one behaves identically.
    */
   public writeValue(binding: FormFieldBinding, value: unknown): void {
-    const operator = this.getOperator(binding.operatorID);
+    this.writeProperties(binding.operatorID, { [binding.propertyKey]: value });
+  }
+
+  /**
+   * Write several properties of one operator at once, over its current ones: what a card's widget
+   * changed, which is the bound property and whatever siblings it touches the way it does on the
+   * operator property panel (the HuggingFace picker resets the task-scoped fields on a task
+   * change). One edit, as the panel makes one.
+   */
+  public writeProperties(operatorID: string, patch: Record<string, unknown>): void {
+    const operator = this.getOperator(operatorID);
     if (!operator) {
       return;
     }
-    this.workflowActionService.setOperatorProperty(binding.operatorID, {
+    this.workflowActionService.setOperatorProperty(operatorID, {
       ...operator.operatorProperties,
-      [binding.propertyKey]: value,
+      ...patch,
     });

Review Comment:
   Object spread does not reach the `__proto__` setter: `{...a, ...b}` defines an own property named `__proto__` and leaves `Object.prototype` untouched; only the literal form `{__proto__: x}` sets a prototype. The keys merged here come from the operator's schema and the card's own widget, not from imported content. No change.



-- 
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] fix(workflow-form): let a card change its operator's siblings the way the panel does, so the HuggingFace task change persists on the form [texera]

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


##########
frontend/src/app/workspace/component/hugging-face/hugging-face.component.ts:
##########
@@ -200,6 +203,25 @@ export class HuggingFaceComponent extends FieldType<FieldTypeConfig> implements
     );
   }
 
+  /**
+   * The task can change under this widget: a co-editor's edit, or the Form View's, lands on the
+   * operator and from there on this field's model (the panel hands formly a fresh model object; the
+   * form card is rebuilt). The selector shows this widget's own state, and on the panel the schema's
+   * `task` field is hidden, so there is no control to listen to: the model is checked on every
+   * change detection instead, and the selector follows it as a local pick is followed -- show the
+   * task, load its models -- rather than keeping what it showed when it was built.
+   */
+  ngDoCheck(): void {
+    const tag = this.model?.task;
+    if (!this.initialized || typeof tag !== "string" || !tag || tag === this.selectedTaskTag) {
+      return;
+    }
+    this.selectedTaskTag = tag;
+    this.searchText = "";
+    this.filteredModels = null;
+    this.loadAllModels();

Review Comment:
   Right, fixed in c02ba6e5. A task change now forgets the search altogether -- the text, the results and the spinner -- through one resetSearch() that clearSearch() also uses, instead of clearing two of the three. The dropped answer was the only thing that would have turned the spinner off, so leaving it set made the widget read as searching for an empty string. A test asserts isSearching is false after the task change and stays false when the old answer lands; deletion-checked.



-- 
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] fix(workflow-form): let a card change its operator's siblings the way the panel does, so the HuggingFace task change persists on the form [texera]

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


##########
frontend/src/app/workspace/component/hugging-face/hugging-face.component.ts:
##########
@@ -200,6 +203,25 @@ export class HuggingFaceComponent extends FieldType<FieldTypeConfig> implements
     );
   }
 
+  /**
+   * The task can change under this widget: a co-editor's edit, or the Form View's, lands on the
+   * operator and from there on this field's model (the panel hands formly a fresh model object; the
+   * form card is rebuilt). The selector shows this widget's own state, and on the panel the schema's
+   * `task` field is hidden, so there is no control to listen to: the model is checked on every
+   * change detection instead, and the selector follows it as a local pick is followed -- show the
+   * task, load its models -- rather than keeping what it showed when it was built.
+   */
+  ngDoCheck(): void {
+    const tag = this.model?.task;
+    if (!this.initialized || typeof tag !== "string" || !tag || tag === this.selectedTaskTag) {
+      return;
+    }
+    this.selectedTaskTag = tag;
+    this.searchText = "";
+    this.filteredModels = null;
+    this.loadAllModels();

Review Comment:
   When an external task change arrives while a server-side search is in flight, this clears the search text/results but leaves `searchLoading` true. The new stale-result guard returns before clearing that flag, so `isSearching` can remain true indefinitely and an empty current task is rendered as `No models found for ""` even though no search is active. Reset `searchLoading` together with the other search state here.



-- 
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] fix(workflow-form): let a card change its operator's siblings the way the panel does, so the HuggingFace task change persists on the form [texera]

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


##########
frontend/src/app/workspace/component/workflow-form/workflow-form.component.ts:
##########
@@ -563,6 +563,23 @@ export class WorkflowFormComponent implements OnInit, OnDestroy {
    */
   @HostListener("focusout")
   public onFocusOut(): void {
+    this.flushHeldRebuild();
+  }
+
+  /**
+   * A click or a key inside the page also ends a hold, because a focus change is not the only thing
+   * that does: closing an nz-select leaves the focus in its search box (ng-zorro re-focuses it), so
+   * no focusout fires, and a rebuild held while the list was open would have waited for an unrelated
+   * event (Copilot on #8839). The same later() re-check as below decides it after the current tick,
+   * by when the dropdown has lost its open class.
+   */
+  @HostListener("click")

Review Comment:
   Confirmed: the options are drawn in the CDK overlay container, a sibling of the app, so the click that picks one never bubbles through this host -- and picking the option already chosen changes no value and moves no focus either, so nothing was left to end the hold.
   
   The click now comes off the document; a click anywhere ends a hold for the same reason a focusout does, and the handler returns at once unless one is actually held. Keys stay on the host: what is typed goes into controls this page owns (nz-select keeps its search box in the trigger, not the overlay), and a document-wide key listener would run on every keystroke in the workspace.
   
   Regression test as asked, in the rendered spec: a real `.cdk-overlay-container` built outside the fixture, an option clicked in it, with the test first asserting the host does not contain that option. Deletion-checked both ways -- putting the listener back on the host turns the new test red, removing it turns that and the in-page one red. Pushed as 0e2517ad6.



-- 
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] fix(workflow-form): let a card change its operator's siblings the way the panel does, so the HuggingFace task change persists on the form [texera]

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

   <!-- 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:** `@PG1204`, `@eugenegujing`
     You can notify them by mentioning `@PG1204`, `@eugenegujing` 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] fix(workflow-form): let a card change its operator's siblings the way the panel does, so the HuggingFace task change persists on the form [texera]

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


##########
frontend/src/app/workspace/component/workflow-form/workflow-form.component.ts:
##########
@@ -563,6 +563,23 @@ export class WorkflowFormComponent implements OnInit, OnDestroy {
    */
   @HostListener("focusout")
   public onFocusOut(): void {
+    this.flushHeldRebuild();
+  }
+
+  /**
+   * A click or a key inside the page also ends a hold, because a focus change is not the only thing
+   * that does: closing an nz-select leaves the focus in its search box (ng-zorro re-focuses it), so
+   * no focusout fires, and a rebuild held while the list was open would have waited for an unrelated
+   * event (Copilot on #8839). The same later() re-check as below decides it after the current tick,
+   * by when the dropdown has lost its open class.
+   */
+  @HostListener("click")

Review Comment:
   nz-select options render in CDK's body-level overlay, outside this component's host, so clicking an option does not reach this listener. If a rebuild is held and the reader clicks the already-selected option to close the list, there is no value change, focusout, or keyup to release it, leaving the card stale. Listen for document clicks while keeping the deferred typing re-check, and add a regression test using an overlay option rather than dispatching a click directly on the host.



-- 
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] fix(workflow-form): let a card change its operator's siblings the way the panel does, so the HuggingFace task change persists on the form [texera]

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


##########
frontend/src/app/workspace/component/workflow-form/workflow-form.component.ts:
##########
@@ -563,6 +563,32 @@ export class WorkflowFormComponent implements OnInit, OnDestroy {
    */
   @HostListener("focusout")
   public onFocusOut(): void {
+    this.flushHeldRebuild();
+  }
+
+  /**
+   * A click or a key also ends a hold, because a focus change is not the only thing that does:
+   * closing an nz-select leaves the focus in its search box (ng-zorro re-focuses it), so no focusout
+   * fires, and a rebuild held while the list was open would have waited for an unrelated event
+   * (Copilot on #8839). The same later() re-check as below decides it after the current tick, by
+   * when the dropdown has lost its open class.
+   *
+   * The click is listened for on the document, not on this host. A dropdown's options are drawn in
+   * the CDK's overlay container, a sibling of the whole app rather than a descendant of this page,
+   * so the click that picks one -- or that picks the option already chosen, which changes no value
+   * and moves no focus -- never bubbles through here (Copilot). A click anywhere else ends the hold
+   * for the same reason a focusout does: the reader is no longer typing into the card. The handler
+   * returns at once unless a rebuild is actually held. Keys stay on the host: what is typed goes
+   * into controls this page owns (nz-select keeps its search box in the trigger, not the overlay),
+   * and a document-wide key listener would run on every keystroke in the workspace.
+   */
+  @HostListener("document:click")
+  @HostListener("keyup")
+  public onInteraction(): void {
+    this.flushHeldRebuild();
+  }
+
+  private flushHeldRebuild(): void {
     if (this.rebuildDeferred) {
       this.later(() => {
         if (this.rebuildDeferred) {

Review Comment:
   When `rebuildDeferred` is true, every `keyup` will schedule a `later()` callback. During sustained typing this can enqueue many redundant deferred checks (each still runs and calls into the typing guard later). Recommendation (optional but strongly suggested): coalesce/single-flight these checks (e.g., keep a `flushScheduled` boolean or store/clear a pending timer) so only one deferred re-check is queued at a time while a rebuild is held.



##########
frontend/src/app/workspace/component/workflow-form/workflow-form.component.ts:
##########
@@ -1006,22 +1042,44 @@ export class WorkflowFormComponent implements OnInit, OnDestroy {
     // The schema's own title ("Attributes", "Limit", "File") -- the reader's title when unnamed.
     // Falls back to this, not the lower-camel key ("fileName"), which would read inconsistently.
     const schemaLabel = (source.props?.label as string) || binding.propertyKey;
-    field.key = binding.id;
+    // The field keeps the property's own key, as on the operator property panel: a widget that
+    // reaches a sibling or itself by key (the HuggingFace picker resets `modelId` and its
+    // task-scoped siblings on a task change) must find the same controls and model keys here.
     field.props = {
       ...(field.props ?? {}),
       label: binding.displayName || schemaLabel,
     };

Review Comment:
   This hunk removes the previous `field.key = binding.id` assignment, but does not set `field.key` to `binding.propertyKey` (despite the comment/PR intent). If `field.key` is left undefined or relies on jsonschema defaults, widgets that look up controls by key and tests expecting a deterministic key can break for schemas that don’t provide a key. Recommendation (mandatory): explicitly assign `field.key = binding.propertyKey` here to guarantee consistent behavior with the panel.



##########
frontend/src/app/workspace/service/form-binding/form-binding.service.ts:
##########
@@ -209,13 +209,23 @@ export class FormBindingService {
    * why a run started from either one behaves identically.
    */
   public writeValue(binding: FormFieldBinding, value: unknown): void {
-    const operator = this.getOperator(binding.operatorID);
+    this.writeProperties(binding.operatorID, { [binding.propertyKey]: value });
+  }
+
+  /**
+   * Write several properties of one operator at once, over its current ones: what a card's widget
+   * changed, which is the bound property and whatever siblings it touches the way it does on the
+   * operator property panel (the HuggingFace picker resets the task-scoped fields on a task
+   * change). One edit, as the panel makes one.
+   */
+  public writeProperties(operatorID: string, patch: Record<string, unknown>): void {
+    const operator = this.getOperator(operatorID);
     if (!operator) {
       return;
     }
-    this.workflowActionService.setOperatorProperty(binding.operatorID, {
+    this.workflowActionService.setOperatorProperty(operatorID, {
       ...operator.operatorProperties,
-      [binding.propertyKey]: value,
+      ...patch,
     });

Review Comment:
   Spreading `operator.operatorProperties` and `patch` into a plain object literal can be vulnerable to prototype-pollution style keys (e.g., `__proto__`, `constructor`, `prototype`) if operator properties / schema-derived keys can be influenced by imported workflow content or other untrusted inputs. Recommendation (mandatory if any untrusted input can reach these keys): sanitize/disallow those special keys before merging, or merge into an object created with a null prototype to avoid triggering the `__proto__` setter.



-- 
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] fix(workflow-form): let a card change its operator's siblings the way the panel does, so the HuggingFace task change persists on the form [texera]

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


##########
frontend/src/app/workspace/component/workflow-form/workflow-form.component.ts:
##########
@@ -887,40 +894,67 @@ export class WorkflowFormComponent implements OnInit, OnDestroy {
     // The schema's own title ("Attributes", "Limit", "File") -- the reader's title when unnamed.
     // Falls back to this, not the lower-camel key ("fileName"), which would read inconsistently.
     const schemaLabel = (source.props?.label as string) || binding.propertyKey;
-    field.key = binding.id;
+    // The field keeps the property's own key, as on the operator property panel: a widget that
+    // reaches a sibling or itself by key (the HuggingFace picker resets `modelId` and its
+    // task-scoped siblings on a task change) must find the same controls and model keys here.
     field.props = {
       ...(field.props ?? {}),
       label: binding.displayName || schemaLabel,
     };
 
     const form = new FormGroup({});
-    // Seed the model with the operator's other properties as read-only context, not just this
-    // input's own value: some custom widgets read a sibling to decide what to show -- the
-    // HuggingFace model picker reads `task` to load the right models and label the field. Only
-    // this binding's value is ever written back (see below); the context is never persisted, and
-    // it is cloned so a widget that mutates it cannot reach through to the real operator.
+    // The card's model is the operator's properties, as the panel's is: the exposed value, and
+    // every other property as context a widget may read or change -- the HuggingFace model picker
+    // reads `task` to load the right models and, when the task is changed, resets the task-scoped
+    // siblings as it does on the panel. The copy is cloned so nothing reaches through to the real
+    // operator; what changes is written back below, as one edit, the way the panel writes.
     const model: Record<string, unknown> = {
       ...cloneDeep(operator?.operatorProperties ?? {}),
-      [binding.id]: cloneDeep(resolved.value),
+      [binding.propertyKey]: cloneDeep(resolved.value),
     };
+    // The other properties ride along as plain controls (formly builds only the exposed field), so
+    // a widget finds its siblings on the card's form exactly as on the panel's -- the HuggingFace
+    // picker writes `task` through its control, which is also what announces the change -- and a
+    // control-level write lands in the model, which is what is written back.
+    const schemaKeys = Object.keys((schema as { properties?: Record<string, unknown> }).properties ?? {});
+    const siblingKeys = [...new Set([...schemaKeys, ...Object.keys(model)])].filter(key => key !== binding.propertyKey);
+    for (const key of siblingKeys) {
+      const control = new FormControl(model[key] ?? null);
+      control.valueChanges.pipe(takeUntil(this.formsRebuilt), untilDestroyed(this)).subscribe(value => {
+        model[key] = value;
+      });
+      form.addControl(key, control);
+    }
     if (this.canEdit) {
       form.valueChanges
         .pipe(debounceTime(FORM_DEBOUNCE_TIME_MS), takeUntil(this.formsRebuilt), untilDestroyed(this))
         .subscribe(() => {
-          // Formly emits the schema's empty default while building the control, before any edit;
-          // writing that back silently wiped the operator's real value (both views edit one
-          // workflow). So only accept a dirtied form, or a value that differs from the operator's
-          // without being emptier (some controls set values without marking dirty).
-          const next = model[binding.id];
-          const current = this.formBindingService.readValue(binding.operatorID, binding.propertyKey);
+          // Whatever differs from the operator is written back: the bound property, and the
+          // siblings a widget changed with it. Formly emits the schema's empty default for the bound
+          // control while building it, before any edit; writing that back silently wiped the
+          // operator's real value (both views edit one workflow). So the bound property is taken
+          // only from a dirtied form, or when it differs without being emptier (some controls set
+          // values without marking dirty).
+          const current = (this.workflowActionService.getTexeraGraph().getOperator(binding.operatorID)
+            ?.operatorProperties ?? {}) as Record<string, unknown>;
           const isEmpty = (v: unknown) => v === undefined || v === null || v === "";
-          const unchanged = JSON.stringify(next ?? null) === JSON.stringify(current ?? null);
-          if (unchanged || (!form.dirty && isEmpty(next) && !isEmpty(current))) {
+          // An empty string and an absent property mean the same to an operator, and formly fills a
+          // blank for a string the operator never had: neither is a change of the other.
+          const asJson = (value: unknown) => JSON.stringify(value === "" ? null : value ?? null);
+          const differs = (key: string) => asJson(model[key]) !== asJson(current[key]);
+          const bound = binding.propertyKey;
+          const blankBeforeEdit = !form.dirty && isEmpty(model[bound]) && !isEmpty(current[bound]);
+          const patch = Object.fromEntries(
+            Object.keys(model)
+              .filter(key => differs(key) && !(key === bound && blankBeforeEdit))
+              .map(key => [key, model[key]])

Review Comment:
   Confirmed and fixed in 29cec391. The card now diffs against its own baseline -- a clone of what it was built from, advanced by each write -- instead of against the operator as it is now, so the patch is only what this card changed. A sibling the canvas, a co-editor or another card on the same operator changed in the meantime is no longer in it, and the blank-build-default guard moved to the same baseline. Two tests cover it (only the changed key is sent; a second edit sends only the second change), both deletion-checked.



##########
frontend/src/app/workspace/component/workflow-form/workflow-form.component.ts:
##########
@@ -724,6 +724,13 @@ export class WorkflowFormComponent implements OnInit, OnDestroy {
     if (!active || !this.host.nativeElement.contains(active)) {
       return false;
     }
+    // A dropdown (nz-select) keeps the focus on its search box after a pick. That is typing only
+    // while the list is open and a filter can be typed; a closed dropdown that merely holds the
+    // focus held every rebuild, so a change made elsewhere (the canvas, a co-editor) never showed.
+    const dropdown = active.closest(".ant-select");
+    if (dropdown) {
+      return dropdown.classList.contains("ant-select-open");

Review Comment:
   Right, fixed in 29cec391. The held rebuild is now flushed by a click or a key anywhere on the page as well as by focusout, through the same deferred re-check, so closing the dropdown releases it even though the focus stays in its search box. A filter still being typed is unaffected, since the re-check runs after the tick and the predicate still sees an open list. Covered by a host-binding test in the rendered spec plus the negative case.



-- 
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] fix(workflow-form): let a card change its operator's siblings the way the panel does, so the HuggingFace task change persists on the form [texera]

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


##########
frontend/src/app/workspace/component/hugging-face/hugging-face.component.ts:
##########
@@ -517,10 +563,15 @@ export class HuggingFaceComponent extends FieldType<FieldTypeConfig> implements
   }
 
   clearSearch(): void {
+    this.resetSearch();
+    this.goToPage(0);
+  }
+
+  /** Forget the search: the text, the results it filtered to, and the spinner it was waiting on. */
+  private resetSearch(): void {
     this.searchText = "";
     this.filteredModels = null;
     this.searchLoading = false;

Review Comment:
   Confirmed and fixed. `resetSearch()` now drops the search subscription and remakes it, which discards both a query still sitting in the debounce and a request already out; nothing queued can go back out under the task the widget has moved to.
   
   That makes the tag the answer travelled with unreachable, so it is gone: whatever reaches the subscriber was asked for under the task still shown (switchMap drops a search the next search replaces, a task change drops the whole subscription). The comment there says so, in place of the guard.
   
   Tests: a query typed and overtaken by a task change never goes out and leaves the box empty and unfiltered; a search after a task change still goes out, under the new task. The two late-response tests now expect cancellation rather than a judged answer, as you suggested. Both halves deletion-checked.



##########
frontend/src/app/workspace/component/workflow-form/workflow-form.component.ts:
##########
@@ -543,6 +543,23 @@ export class WorkflowFormComponent implements OnInit, OnDestroy {
    */
   @HostListener("focusout")
   public onFocusOut(): void {
+    this.flushHeldRebuild();
+  }
+
+  /**
+   * A click or a key inside the page also ends a hold, because a focus change is not the only thing
+   * that does: closing an nz-select leaves the focus in its search box (ng-zorro re-focuses it), so
+   * no focusout fires, and a rebuild held while the list was open would have waited for an unrelated
+   * event (Copilot on #8839). The same later() re-check as below decides it after the current tick,
+   * by when the dropdown has lost its open class.
+   */
+  @HostListener("click")
+  @HostListener("keyup")
+  public onInteraction(): void {
+    this.flushHeldRebuild();

Review Comment:
   Checked against the rebased branch and this one is already closed, by #8845 which landed on main in the meantime: `buildForm()` writes every card's pending edit before it emits `formsRebuilt` (`this.rendered.forEach(card => card.pendingWrite && card.flushWrite?.())`), so the held rebuild flushes the selection instead of cancelling it.
   
   Added the regression test you asked for anyway, since nothing pinned this path from the keyup side: a rebuild held while the list is open, an option accepted, then the click that closed the list runs the rebuild -- the selection reaches the operator. Deletion-checked by removing the flush, which turns it red.



-- 
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] fix(workflow-form): let a card change its operator's siblings the way the panel does, so the HuggingFace task change persists on the form [texera]

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


##########
frontend/src/app/workspace/component/hugging-face/hugging-face.component.ts:
##########
@@ -200,6 +203,25 @@ export class HuggingFaceComponent extends FieldType<FieldTypeConfig> implements
     );
   }
 
+  /**
+   * The task can change under this widget: a co-editor's edit, or the Form View's, lands on the
+   * operator and from there on this field's model (the panel hands formly a fresh model object; the
+   * form card is rebuilt). The selector shows this widget's own state, and on the panel the schema's
+   * `task` field is hidden, so there is no control to listen to: the model is checked on every
+   * change detection instead, and the selector follows it as a local pick is followed -- show the
+   * task, load its models -- rather than keeping what it showed when it was built.
+   */
+  ngDoCheck(): void {
+    const tag = this.model?.task;
+    if (!this.initialized || typeof tag !== "string" || !tag || tag === this.selectedTaskTag) {
+      return;
+    }
+    this.selectedTaskTag = tag;
+    this.searchText = "";
+    this.filteredModels = null;
+    this.loadAllModels();

Review Comment:
   Confirmed and fixed in 695e659c. The task the search was made for now travels with it, and an answer whose task is no longer the one on show is dropped: switchMap only drops a search the next search replaces, and a task change is not a search, so its answer could still arrive and refill the list the task change had just cleared. A test flushes a search after the task has moved on and asserts the shown list is untouched; deletion-checked.



-- 
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] fix(workflow-form): let a card change its operator's siblings the way the panel does, so the HuggingFace task change persists on the form [texera]

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


##########
frontend/src/app/workspace/component/workflow-form/workflow-form.component.ts:
##########
@@ -543,6 +543,23 @@ export class WorkflowFormComponent implements OnInit, OnDestroy {
    */
   @HostListener("focusout")
   public onFocusOut(): void {
+    this.flushHeldRebuild();
+  }
+
+  /**
+   * A click or a key inside the page also ends a hold, because a focus change is not the only thing
+   * that does: closing an nz-select leaves the focus in its search box (ng-zorro re-focuses it), so
+   * no focusout fires, and a rebuild held while the list was open would have waited for an unrelated
+   * event (Copilot on #8839). The same later() re-check as below decides it after the current tick,
+   * by when the dropdown has lost its open class.
+   */
+  @HostListener("click")
+  @HostListener("keyup")
+  public onInteraction(): void {
+    this.flushHeldRebuild();

Review Comment:
   When a rebuild is held while an nz-select is open, accepting an option with Enter emits a form change and closes the dropdown. This keyup handler schedules the rebuild at 0 ms, before the 150 ms write-back debounce completes. `readConfig()` calls `buildForm()`, whose `formsRebuilt` emission cancels the pending write through `takeUntil`, so the selection is discarded and the old operator value returns. Flush pending card patches before reading the graph and rebuilding, or wait for those writes to complete. Add a regression test that commits a selection while a rebuild is held.



##########
frontend/src/app/workspace/component/hugging-face/hugging-face.component.ts:
##########
@@ -517,10 +563,15 @@ export class HuggingFaceComponent extends FieldType<FieldTypeConfig> implements
   }
 
   clearSearch(): void {
+    this.resetSearch();
+    this.goToPage(0);
+  }
+
+  /** Forget the search: the text, the results it filtered to, and the spinner it was waiting on. */
+  private resetSearch(): void {
     this.searchText = "";
     this.filteredModels = null;
     this.searchLoading = false;

Review Comment:
   This reset leaves queries queued in `debounceTime(300)` alive. If a model-driven task change arrives before the debounce expires, `setupServerSearch()` later captures the new task for the old query. The response passes the task guard and filters the new task's models even though the search box is empty. Cancel and recreate the search subscription on reset to discard both queued queries and active requests. Add a test that changes the task before the debounce expires, and update existing late-response tests to expect cancellation.



-- 
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] fix(workflow-form): let a card change its operator's siblings the way the panel does, so the HuggingFace task change persists on the form [texera]

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

   ## [Codecov](https://app.codecov.io/gh/apache/texera/pull/8839?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `89.47368%` with `2 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 92.57%. Comparing base ([`2082021`](https://app.codecov.io/gh/apache/texera/commit/2082021a8073c26bc38aeac7d654bdc661d4ff87?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`0fa86cf`](https://app.codecov.io/gh/apache/texera/commit/0fa86cf805184d3ab6a371a53ed174d77bb617d2?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/texera/pull/8839?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [...component/workflow-form/workflow-form.component.ts](https://app.codecov.io/gh/apache/texera/pull/8839?src=pr&el=tree&filepath=frontend%2Fsrc%2Fapp%2Fworkspace%2Fcomponent%2Fworkflow-form%2Fworkflow-form.component.ts&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZnJvbnRlbmQvc3JjL2FwcC93b3Jrc3BhY2UvY29tcG9uZW50L3dvcmtmbG93LWZvcm0vd29ya2Zsb3ctZm9ybS5jb21wb25lbnQudHM=) | 87.50% | [0 Missing and 2 partials :warning: ](https://app.codecov.io/gh/apache/texera/pull/8839?src=pr&el=tree&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    #8839      +/-   ##
   ============================================
   - Coverage     92.57%   92.57%   -0.01%     
     Complexity     5046     5046              
   ============================================
     Files          1251     1251              
     Lines         53368    53379      +11     
     Branches       6618     6621       +3     
   ============================================
   + Hits          49405    49414       +9     
     Misses         2319     2319              
   - Partials       1644     1646       +2     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/texera/pull/8839/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/8839/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `77.38% <ΓΈ> (ΓΈ)` | | Carriedforward from [2082021](https://app.codecov.io/gh/apache/texera/commit/2082021a8073c26bc38aeac7d654bdc661d4ff87?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/8839/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `99.16% <ΓΈ> (ΓΈ)` | | Carriedforward from [2082021](https://app.codecov.io/gh/apache/texera/commit/2082021a8073c26bc38aeac7d654bdc661d4ff87?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [amber](https://app.codecov.io/gh/apache/texera/pull/8839/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `88.08% <ΓΈ> (ΓΈ)` | | Carriedforward from [2082021](https://app.codecov.io/gh/apache/texera/commit/2082021a8073c26bc38aeac7d654bdc661d4ff87?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/8839/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `60.41% <ΓΈ> (ΓΈ)` | | Carriedforward from [2082021](https://app.codecov.io/gh/apache/texera/commit/2082021a8073c26bc38aeac7d654bdc661d4ff87?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/8839/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `87.37% <ΓΈ> (ΓΈ)` | | Carriedforward from [2082021](https://app.codecov.io/gh/apache/texera/commit/2082021a8073c26bc38aeac7d654bdc661d4ff87?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/8839/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `81.53% <ΓΈ> (ΓΈ)` | | Carriedforward from [2082021](https://app.codecov.io/gh/apache/texera/commit/2082021a8073c26bc38aeac7d654bdc661d4ff87?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/8839/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `96.55% <89.47%> (-0.01%)` | :arrow_down: | |
   | [notebook-migration-service](https://app.codecov.io/gh/apache/texera/pull/8839/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `83.73% <ΓΈ> (ΓΈ)` | | Carriedforward from [2082021](https://app.codecov.io/gh/apache/texera/commit/2082021a8073c26bc38aeac7d654bdc661d4ff87?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/8839/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `98.56% <ΓΈ> (ΓΈ)` | | Carriedforward from [2082021](https://app.codecov.io/gh/apache/texera/commit/2082021a8073c26bc38aeac7d654bdc661d4ff87?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/8839/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `74.09% <ΓΈ> (ΓΈ)` | | Carriedforward from [2082021](https://app.codecov.io/gh/apache/texera/commit/2082021a8073c26bc38aeac7d654bdc661d4ff87?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/8839?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] fix(workflow-form): let a card change its operator's siblings the way the panel does, so the HuggingFace task change persists on the form [texera]

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

   <!-- backport-auto-label-report -->
   ### Backport auto-label report
   
   This `fix:` PR was checked against each actively-supported release branch. A `release/*` label nominates a backport target; the branch's release manager approving this PR is what sends the fix there. The required **Backport Approvals** check stays red until every label below is approved, so each manager either approves or removes their own label β€” which is why the labels left on a merged PR are exactly the branches it reached.
   
   | Release branch | Analysis |
   | --- | --- |
   | βœ… `release/v1.3` | Change detected on this branch β€” label added; this fix is queued to backport here. @mengw15 decides: approving sends the fix here, removing this label declines it. The merge waits on one or the other. Review requested. |
   | ⚠️ `release/v1.2` | Not labeled automatically β€” none of the files this PR modifies exist on this branch (`frontend/src/app/workspace/component/hugging-face/hugging-face.component.spec.ts`, `frontend/src/app/workspace/component/workflow-form/workflow-form.component.spec.ts`, `frontend/src/app/workspace/component/workflow-form/workflow-form.component.ts`, `frontend/src/app/workspace/component/workflow-form/workflow-form.spec-harness.ts`, `frontend/src/app/workspace/service/form-binding/form-binding.service.spec.ts`, `frontend/src/app/workspace/service/form-binding/form-binding.service.ts`). The fix may target code that isn't on this release, or the files were moved/renamed after the branch was cut. **Please check and add `release/v1.2` by hand if this fix should be backported here** β€” its release manager then has to approve before this PR can merge. |
   
   _[Auto-label run](https://github.com/apache/texera/actions/runs/37176452710)._


-- 
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] fix(workflow-form): let a card change its operator's siblings the way the panel does, so the HuggingFace task change persists on the form [texera]

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


##########
frontend/src/app/workspace/component/hugging-face/hugging-face.component.ts:
##########
@@ -200,6 +203,25 @@ export class HuggingFaceComponent extends FieldType<FieldTypeConfig> implements
     );
   }
 
+  /**
+   * The task can change under this widget: a co-editor's edit, or the Form View's, lands on the
+   * operator and from there on this field's model (the panel hands formly a fresh model object; the
+   * form card is rebuilt). The selector shows this widget's own state, and on the panel the schema's
+   * `task` field is hidden, so there is no control to listen to: the model is checked on every
+   * change detection instead, and the selector follows it as a local pick is followed -- show the
+   * task, load its models -- rather than keeping what it showed when it was built.
+   */
+  ngDoCheck(): void {
+    const tag = this.model?.task;
+    if (!this.initialized || typeof tag !== "string" || !tag || tag === this.selectedTaskTag) {
+      return;
+    }
+    this.selectedTaskTag = tag;
+    this.searchText = "";
+    this.filteredModels = null;
+    this.loadAllModels();

Review Comment:
   On an external task change, `loadAllModels()` can take a cached/error/in-flight fast path before it cancels this component's previous request or polling interval. For example, if task A is still loading and task B is cached, B is shown immediately, then A's late response overwrites the list while the selector still says B. Cancel the prior loader before any fast path, or ignore completions whose task is no longer `selectedTaskTag`.



##########
frontend/src/app/workspace/component/workflow-form/workflow-form.component.ts:
##########
@@ -887,40 +894,67 @@ export class WorkflowFormComponent implements OnInit, OnDestroy {
     // The schema's own title ("Attributes", "Limit", "File") -- the reader's title when unnamed.
     // Falls back to this, not the lower-camel key ("fileName"), which would read inconsistently.
     const schemaLabel = (source.props?.label as string) || binding.propertyKey;
-    field.key = binding.id;
+    // The field keeps the property's own key, as on the operator property panel: a widget that
+    // reaches a sibling or itself by key (the HuggingFace picker resets `modelId` and its
+    // task-scoped siblings on a task change) must find the same controls and model keys here.
     field.props = {
       ...(field.props ?? {}),
       label: binding.displayName || schemaLabel,
     };
 
     const form = new FormGroup({});
-    // Seed the model with the operator's other properties as read-only context, not just this
-    // input's own value: some custom widgets read a sibling to decide what to show -- the
-    // HuggingFace model picker reads `task` to load the right models and label the field. Only
-    // this binding's value is ever written back (see below); the context is never persisted, and
-    // it is cloned so a widget that mutates it cannot reach through to the real operator.
+    // The card's model is the operator's properties, as the panel's is: the exposed value, and
+    // every other property as context a widget may read or change -- the HuggingFace model picker
+    // reads `task` to load the right models and, when the task is changed, resets the task-scoped
+    // siblings as it does on the panel. The copy is cloned so nothing reaches through to the real
+    // operator; what changes is written back below, as one edit, the way the panel writes.
     const model: Record<string, unknown> = {
       ...cloneDeep(operator?.operatorProperties ?? {}),
-      [binding.id]: cloneDeep(resolved.value),
+      [binding.propertyKey]: cloneDeep(resolved.value),
     };
+    // The other properties ride along as plain controls (formly builds only the exposed field), so
+    // a widget finds its siblings on the card's form exactly as on the panel's -- the HuggingFace
+    // picker writes `task` through its control, which is also what announces the change -- and a
+    // control-level write lands in the model, which is what is written back.
+    const schemaKeys = Object.keys((schema as { properties?: Record<string, unknown> }).properties ?? {});
+    const siblingKeys = [...new Set([...schemaKeys, ...Object.keys(model)])].filter(key => key !== binding.propertyKey);
+    for (const key of siblingKeys) {
+      const control = new FormControl(model[key] ?? null);
+      control.valueChanges.pipe(takeUntil(this.formsRebuilt), untilDestroyed(this)).subscribe(value => {
+        model[key] = value;
+      });
+      form.addControl(key, control);
+    }
     if (this.canEdit) {
       form.valueChanges
         .pipe(debounceTime(FORM_DEBOUNCE_TIME_MS), takeUntil(this.formsRebuilt), untilDestroyed(this))
         .subscribe(() => {
-          // Formly emits the schema's empty default while building the control, before any edit;
-          // writing that back silently wiped the operator's real value (both views edit one
-          // workflow). So only accept a dirtied form, or a value that differs from the operator's
-          // without being emptier (some controls set values without marking dirty).
-          const next = model[binding.id];
-          const current = this.formBindingService.readValue(binding.operatorID, binding.propertyKey);
+          // Whatever differs from the operator is written back: the bound property, and the
+          // siblings a widget changed with it. Formly emits the schema's empty default for the bound
+          // control while building it, before any edit; writing that back silently wiped the
+          // operator's real value (both views edit one workflow). So the bound property is taken
+          // only from a dirtied form, or when it differs without being emptier (some controls set
+          // values without marking dirty).
+          const current = (this.workflowActionService.getTexeraGraph().getOperator(binding.operatorID)
+            ?.operatorProperties ?? {}) as Record<string, unknown>;
           const isEmpty = (v: unknown) => v === undefined || v === null || v === "";
-          const unchanged = JSON.stringify(next ?? null) === JSON.stringify(current ?? null);
-          if (unchanged || (!form.dirty && isEmpty(next) && !isEmpty(current))) {
+          // An empty string and an absent property mean the same to an operator, and formly fills a
+          // blank for a string the operator never had: neither is a change of the other.
+          const asJson = (value: unknown) => JSON.stringify(value === "" ? null : value ?? null);
+          const differs = (key: string) => asJson(model[key]) !== asJson(current[key]);
+          const bound = binding.propertyKey;
+          const blankBeforeEdit = !form.dirty && isEmpty(model[bound]) && !isEmpty(current[bound]);
+          const patch = Object.fromEntries(
+            Object.keys(model)
+              .filter(key => differs(key) && !(key === bound && blankBeforeEdit))
+              .map(key => [key, model[key]])

Review Comment:
   This computes the patch from every difference between the card's build-time model and the live operator, not from properties changed by this card. If another card, the canvas, or a co-editor updates any sibling before this card rebuilds, the next local form emission includes the stale sibling and silently reverts that newer edit. Track a per-card baseline/local dirty keys (including the HuggingFace model-only resets) and patch only locally changed keys, then advance that baseline after a successful write.



##########
frontend/src/app/workspace/component/workflow-form/workflow-form.component.ts:
##########
@@ -724,6 +724,13 @@ export class WorkflowFormComponent implements OnInit, OnDestroy {
     if (!active || !this.host.nativeElement.contains(active)) {
       return false;
     }
+    // A dropdown (nz-select) keeps the focus on its search box after a pick. That is typing only
+    // while the list is open and a filter can be typed; a closed dropdown that merely holds the
+    // focus held every rebuild, so a change made elsewhere (the canvas, a co-editor) never showed.
+    const dropdown = active.closest(".ant-select");
+    if (dropdown) {
+      return dropdown.classList.contains("ant-select-open");

Review Comment:
   A rebuild that arrives while this dropdown is open is still stored in `rebuildDeferred`, but closing `nz-select` keeps focus on the search input, so `onFocusOut` never runs. Changing this predicate only lets later rebuild requests through; it does not flush the already-deferred one, leaving the card stale until an unrelated event or blur. Flush deferred work when the dropdown closes (and add a test that defers while open, then closes without focusout).



-- 
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] fix(workflow-form): let a card change its operator's siblings the way the panel does, so the HuggingFace task change persists on the form [texera]

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


##########
frontend/src/app/workspace/component/hugging-face/hugging-face.component.ts:
##########
@@ -200,6 +203,25 @@ export class HuggingFaceComponent extends FieldType<FieldTypeConfig> implements
     );
   }
 
+  /**
+   * The task can change under this widget: a co-editor's edit, or the Form View's, lands on the
+   * operator and from there on this field's model (the panel hands formly a fresh model object; the
+   * form card is rebuilt). The selector shows this widget's own state, and on the panel the schema's
+   * `task` field is hidden, so there is no control to listen to: the model is checked on every
+   * change detection instead, and the selector follows it as a local pick is followed -- show the
+   * task, load its models -- rather than keeping what it showed when it was built.
+   */
+  ngDoCheck(): void {
+    const tag = this.model?.task;
+    if (!this.initialized || typeof tag !== "string" || !tag || tag === this.selectedTaskTag) {
+      return;
+    }
+    this.selectedTaskTag = tag;
+    this.searchText = "";
+    this.filteredModels = null;
+    this.loadAllModels();

Review Comment:
   A task change clears the displayed search state but does not cancel an in-flight server-side search. `setupServerSearch()` captures the old task in its request and applies every eventual response unconditionally, so a search for task A can return after this switches to task B and replace B's models with A's results. Cancel/retag pending searches when the task changes and ignore responses whose captured task no longer matches `selectedTaskTag`.



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