Circuit-Editor Classical-Control Support - #3596
Merged
Merged
Conversation
…-extend scenario.
Scott Carda (ScottCarda-MS)
marked this pull request as ready for review
August 21, 2026 20:27
Scott Carda (ScottCarda-MS)
requested review from
Andrew Casey (amcasey) and
Bill Ticehurst (billti)
as code owners
August 21, 2026 20:27
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds robust classical-dependency handling to the circuit editor’s structural edits (add/remove/move/clone) by temporarily replacing positional (qubit, result) addresses with stable identities during an edit, then reassigning final contiguous result indices once the circuit reaches its new shape.
Changes:
- Centralizes structural edits into a shared
_editOperationtransaction that performs validation, structural reconciliation, classical ref encoding/decoding, and qubit cleanup. - Generalizes consumer detection/cascade behavior from measurement-only to subtree-wide producer/consumer relationships, with prompt support for stranded dependents on move/delete.
- Adds extensive regression coverage across prompts and edit operations, including multi-producer groups, same-wire clones, and preview-vs-commit agreement.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| source/npm/qsharp/ux/circuit-vis/editor/prompts.ts | Updates move/delete confirmation flows to use subtree-wide consumer detection and dependency-aware commit paths. |
| source/npm/qsharp/ux/circuit-vis/actions/circuitActions.ts | Introduces _editOperation, dependency-aware move/delete helpers, and a stranded-consumer preview counter. |
| source/npm/qsharp/ux/circuit-vis/actions/circuit-actions/move.ts | Ensures measurement .results[*].qubit stays consistent with .qubits during vertical moves. |
| source/npm/qsharp/ux/circuit-vis/actions/circuit-actions/gridPrimitives.ts | Extracts column-injection decision logic into willInsertNewColumn and removes direct measurement-line renumbering. |
| source/npm/qsharp/ux/circuit-vis/actions/circuit-actions/classicalRefs.ts | Implements classical ref token encode/decode, subtree consumer collection, and post-move invalidation detection. |
| source/npm/qsharp/test/circuit-editor/prompts.test.mjs | Updates and expands prompt behavior tests for the new stranded-consumer logic and unified messaging. |
| source/npm/qsharp/test/circuit-editor/circuit-actions/measurementCascade.test.mjs | Reworks cascade tests around the new identity/token approach; adds preview-vs-commit agreement coverage. |
| source/npm/qsharp/test/circuit-editor/circuit-actions/groupMove.test.mjs | Adds broader invariants for multi-producer group moves and consumer/producers relinking across wire shifts. |
| source/npm/qsharp/test/circuit-editor/circuit-actions/groupClone.test.mjs | Adds cloning tests ensuring cloned consumers bind to cloned producers, including same-wire cloning. |
| source/npm/qsharp/test/circuit-editor/circuit-actions/addRemove.test.mjs | Adds add/remove renumbering + repointing tests and a toolbox-measurement initialization test. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Dima Fedoriaka (fedimser)
approved these changes
Aug 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Circuit Editor: support classical dependencies across structural edits
Summary
Adds classical-dependency support to circuit-editor add, remove, move, and clone operations.
Because classical result addresses are positional, structural edits can change a producer's
(qubit, result)address. This PR adds an edit algorithm that replaces those addresses with stableidentities while an edit is in progress, then assigns final addresses after the circuit reaches its
new shape.
What changed
them into contiguous per-wire result indices afterward.
follow the intended producer in both cases.
cleanup in the shared
_editOperationtransaction.invalid consumers on confirmation. Canceling leaves the model unchanged, while safe moves proceed
without a prompt.
This also supports same-wire producer-consumer cloning and group moves involving multiple internal
or external producers.
The temporary tokens do not change the circuit data model or serialized format.
Testing
Adds 48 focused regression tests for add/remove resequencing, move and clone identity handling,
dependent-operation cascades, prompt behavior, and result-count updates.
Result: 128 tests passed, 0 failed across all changed test suites.