Repository navigation
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 - #8839
Conversation
Backport auto-label reportThis
|
Automated Reviewer SuggestionsBased on the
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8839 +/- ##
============================================
+ Coverage 92.33% 92.39% +0.06%
Complexity 5045 5045
============================================
Files 1260 1289 +29
Lines 54067 55513 +1446
Branches 6755 7110 +355
============================================
+ Hits 49921 51290 +1369
- Misses 2486 2510 +24
- Partials 1660 1713 +53
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
0fa86cf to
342d021
Compare
bb770ac to
5b7424e
Compare
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Stale card state can overwrite newer edits, while deferred dropdown rebuilds and model-loading races can leave the UI inconsistent.
Review effort: Balanced
Findings: 1
Open (3)
What changed in this PR
This PR aligns Form View widgets with the canvas property panel, allowing HuggingFace task changes and related property resets to persist.
Changes:
- Adds atomic multi-property write-back and sibling controls.
- Synchronizes HuggingFace task/model state across views.
- Refines dropdown typing detection and expands regression tests.
| File | Description |
|---|---|
form-binding.service.ts |
Adds merged multi-property writes. |
form-binding.service.spec.ts |
Tests multi-property writes. |
workflow-form.spec-harness.ts |
Mocks the new write API. |
workflow-form.component.ts |
Adds sibling controls, patching, and dropdown handling. |
workflow-form.component.spec.ts |
Tests persistence and typing behavior. |
hugging-face.component.ts |
Follows externally changed tasks. |
hugging-face.component.spec.ts |
Tests Form View and external synchronization. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
5b7424e to
29cec39
Compare
29cec39 to
695e659
Compare
695e659 to
c02ba6e
Compare
c02ba6e to
af2b405
Compare
af2b405 to
0c0e9fc
Compare
… the panel does, so the HuggingFace task change persists on the form An exposed HuggingFace model picker on the Form View offered a 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. Changing the task on the form switched the model list but saved nothing, so a reader could pick a model for a task the operator does not run. The Form View is another way to show the canvas, so a card now behaves like the operator property panel for the property it exposes. The field keeps the property's own key; the operator's other properties ride along as plain controls on the card's form and in its model, so a widget that reads or writes a sibling by key (the HuggingFace picker writes task and resets the task-scoped fields) finds the same controls as on the panel; and the card writes back everything that differs from the operator in one edit (FormBindingService.writeProperties), the bound property and the siblings a widget changed. An empty string and an absent property count as the same value, so formly's blank for a property the operator never had is not written on every build. Two more things the two views needed to agree, found with both open on one workflow: the form held every rebuild while a closed dropdown kept the focus (its search box counted as typing), so a change made on the canvas never showed until the reader clicked elsewhere -- a dropdown is typing only while its list is open; and the HuggingFace selector on the canvas kept showing the task it was built with when the form (or a co-editor) changed it -- it now follows its field's model on every check, as a local pick is followed (the panel hides the schema's task field, so there is no control to listen to). Closes apache#8762 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
0c0e9fc to
0e2517a
Compare
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
3 open issues
This hunk removes the previousfield.key = binding.idassignment, but does not setfield.keyto… · New WhenrebuildDeferredis true, everykeyupwill schedule alater()callback. During sustained… · New Spreadingoperator.operatorPropertiesandpatchinto a plain object literal can be vulnerable… · New
1 resolved since last review
Review effort: Lite
…ild is held, not one per key (review) Copilot on apache#8839: with a rebuild held, every keyup scheduled its own later() callback. A flushQueued flag makes the re-check single-flight, cleared when the callback runs so the next hold gets its own; a spec asserts five interactions queue one and run the held rebuild once, and that a later hold is re-checked again. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FVvP3ttj22f9LB4p9u2anY
There was a problem hiding this comment.
🔵 Needs a closer look
Human assessment is needed for a subtle interaction between task switching and compilation that can discard saved model and prompt state when only modelId is exposed.
No open issues 🎉
3 resolved since last review
Review effort: Balanced
kunwp1
left a comment
There was a problem hiding this comment.
One issue inline, and one nit.
Nit. The two guards in workflow-form.component.spec.ts at lines 1225 and 1939 still assert that writeValue is not called. Since the card now writes only through writeProperties, neither of them can fail. Thus, both could assert on writeProperties instead.
| this.formBindingService.writeProperties(binding.operatorID, patch); | ||
| // The card has caught up with what it just sent; anything else on the operator stays | ||
| // someone else's, and only a rebuild re-seeds this card with it. | ||
| baseline = { ...baseline, ...cloneDeep(patch) }; |
There was a problem hiding this comment.
A main issue. After a card writes a sibling, its contextKey still describes the operator as it was when the card was built. Notice that contextKeyFor leaves out only the bound properties, so the task this card just wrote counts as a change to the widget context, and the compilation that the write triggers rebuilds the card. As a consequence, the HuggingFace picker is recreated and loses taskStateByTag. Switching the task back on the card is then treated as a first visit, and resetTaskStateForFirstVisit blanks modelId and the prompt fields, which the card writes back. On the panel, whose picker survives the compilation, the same switch restores them. This seems to be the interaction that Copilot's latest review asks a human to look at.
One way to fix it is to advance the context key together with the baseline, so that only someone else's change rebuilds the card:
baseline = { ...baseline, ...cloneDeep(patch) };
card.contextKey = this.contextKeyOf(binding.operatorID, baseline);Here contextKeyOf(operatorID, properties) is the serializing half of contextKeyFor. A spec next to "rebuilds the inputs when another property of a card's operator changed" that sets task through the card's control, flushes, and runs a compilation fails without this change and passes with it.
There was a problem hiding this comment.
Thank you -- that is the interaction, and the fix is as you describe: contextKeyOf(operatorID, properties) is the serializing half, contextKeyFor reads the operator and calls it, and after a write the card's key is contextKeyOf(binding.operatorID, baseline) (set once this.parameters is refreshed, so both sides use the same bound set). One addition: the key sorts keys at every level, not only the top one, because the shared model updates a nested object key by key and keeps its stored order (updateYTypeFromObject), so a sibling written in another order would read back reordered and count as someone else's change. The spec sets task through the card's control, lets the debounced write land on the operator, runs a compilation and expects no rebuild, then changes task from outside and expects one; it fails on the first expectation without the key advancing (99c7f3b).
Review fix on apache#8839 (kunwp1). After a card wrote a sibling, its context key still described the operator as it was when the card was built, so the compilation the write triggered rebuilt the card: the HuggingFace picker was recreated and lost the state it keeps per task, and switching the task back blanked the model as a first visit does, where the panel's picker (which survives) restored it. The key now advances with the baseline, so only someone else's change rebuilds the card. It sorts keys at every level, since the shared model updates a nested object key by key and keeps its stored order, which would otherwise read back as a change. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FVvP3ttj22f9LB4p9u2anY


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:
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.taskthrough 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.FormBindingService.writeProperties): the bound property and whatever siblings the widget changed with it, the way the panel writes its whole model. The comparison is against the card's own baseline, a clone of what it was built from, and the baseline is advanced by each write -- not against the operator as it is now, which would have sent back a sibling this card never touched but the canvas, a co-editor or another card on the same operator had changed in the meantime, putting the older value on top of the newer one (Copilot). The card's context key -- the operator's other properties, which decide when a compilation rebuilds the card -- advances with the baseline, so the sibling the card itself just wrote is not a change to its context: left at what the card was built from, the compilation the write triggers rebuilt the card, recreating the HuggingFace picker and losing the state it keeps per task, so switching the task back blanked the model as a first visit does, where the panel's picker (which survives) restored it (kunwp1). Only someone else's change rebuilds the card. The guard against formly's blank build-time default stays, for the bound property only.taskfield, so there is no control to listen to).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; only what the card changed is sent, so a sibling someone else changed in the meantime is left alone, and the baseline is advanced so a second edit sends only the second change; a card survives the compilation its own write of a sibling triggers, while a sibling someone else changes afterwards still rebuilds it; a sibling control's change lands in the model; an unchanged sibling emission writes nothing; a held rebuild is flushed by a click as well as by the focus leaving, and not while the list is still open (the host bindings exercised through real events in the rendered spec, including a click on an option inside a
.cdk-overlay-containerbuilt outside the page, which the test first asserts the page does not contain); 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:writePropertieswrites 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 fieldmodelId, 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; a task change arriving on the model shows the new task and loads its models, while the task already shown or a blank does nothing; a response or a failure that comes back for a task the widget has left does not replace the list it now shows; a task change cancels a search that is still out rather than leaving its spinner on or judging its answer later, drops a query still in the debounce (which then never goes out) and still allows a fresh search under the task now shown; and a poll started for an earlier task is stopped by the next load. The form's spec also pins that a selection made while a rebuild is held is written rather than lost to the rebuild, and that a card's value is compared under the property it is bound to rather than under the binding's id (Copilot). The form's spec also pins the typing guard (a closed dropdown's focused search box is not typing, an open one's is) and that formly's blank for a property the operator never had writes nothing. 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.
Video
Before
Screen.Recording.2026-10-03.at.11.14.45.PM.mov
After
Screen.Recording.2026-10-03.at.11.15.09.PM.mov
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