Skip to content

Bloch Sphere Widget - Command and Dev Playground#3306

Open
ScottCarda-MS wants to merge 34 commits into
mainfrom
sccarda/bloch
Open

Bloch Sphere Widget - Command and Dev Playground#3306
ScottCarda-MS wants to merge 34 commits into
mainfrom
sccarda/bloch

Conversation

@ScottCarda-MS

@ScottCarda-MS ScottCarda-MS commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Bloch Sphere View for Q# UX (Playground + VS Code)

Summary

This PR introduces an interactive Bloch sphere view in the shared Q# UX package and wires it into both:

  • the dev playground (as a first-class Tools view)
  • the VS Code extension webview (via a dedicated command)

It also adds the synthesis data/tooling used by the Bloch Rz helper.

What’s Included

New Bloch UX surface

  • Adds a new Bloch widget implementation in the shared UX layer.
  • Includes gate application controls, sequence playback/history, and Rz synthesis integration.
  • Includes theme-aware rendering/styling for host environments.

Shared math and compute cleanup

  • Introduces shared quantum math primitives used across Bloch/state visualization paths.
  • Refactors relevant state-viz worker computation to align with shared math utilities.

Rz synthesis artifacts and generator source

  • Adds checked-in lookup artifacts:
    • source/npm/qsharp/rz-array.json
    • source/npm/qsharp/rz-details.json
  • Adds generator source/tooling for reproducibility:
    • source/npm/qsharp/tools/rz-synthesis.ts
    • source/npm/qsharp/tools/tsconfig.json

Playground integration

  • Adds Bloch view routing/rendering in the dev playground.
  • Adds navigation entry placement under Tools.

VS Code integration

  • Adds/updates webview command plumbing for Bloch panel display.
  • Ensures webview/learning webview type-check configs support shared UX JSON import path.

Packaging and dependency updates

  • Updates npm dependency metadata and lockfiles.
  • Updates component governance manifest for shipped dependency compliance.

Key Files (high signal)

  • source/npm/qsharp/ux/bloch.tsx
  • source/npm/qsharp/ux/blochGates.ts
  • source/npm/qsharp/ux/quantum-math.ts
  • source/npm/qsharp/ux/cplx.ts
  • source/npm/qsharp/ux/circuit-vis/state-viz/worker/stateCompute.ts
  • source/npm/qsharp/rz-array.json
  • source/npm/qsharp/rz-details.json
  • source/npm/qsharp/tools/rz-synthesis.ts
  • source/playground/src/nav.tsx
  • source/playground/src/main.tsx
  • source/vscode/src/webviewPanel.ts
  • source/vscode/src/webview/webview.tsx

Screenshots

image

@ScottCarda-MS ScottCarda-MS changed the title Sccarda/bloch Bloch Sphere Widget - Command and Dev Playground Jun 11, 2026
Comment thread source/npm/qsharp/ux/bloch.tsx Fixed
@ScottCarda-MS ScottCarda-MS marked this pull request as ready for review June 12, 2026 23:52
@amcasey

amcasey commented Jun 13, 2026

Copy link
Copy Markdown
Member

Are the colors we want in dark mode? I find the arrows and the axis labels pretty close together.

Edit: from the code, they seem to have been chosen pretty deliberately. I find the white on beige a little strange, but it's not substantially hurting readability.

image

Also, this might just be my ignorance, but is n/a the appropriate value for phi here?

@amcasey

amcasey commented Jun 13, 2026

Copy link
Copy Markdown
Member

Were we expecting it to expand with the pane?

image

@amcasey

amcasey commented Jun 13, 2026

Copy link
Copy Markdown
Member

It seems like the slider at the bottom manipulates Rz in radians but the angles at the top are in degrees? Maybe that's a feature?

@amcasey

amcasey commented Jun 13, 2026

Copy link
Copy Markdown
Member

Personally, I'd find it very helpful to see the ending state in the top-level summary (maybe top-right) and not just in the sidebar.

@amcasey

amcasey commented Jun 13, 2026

Copy link
Copy Markdown
Member

Is the Reset button supposed to clear the Rz slider too?

@amcasey amcasey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Random drive-by comments. That's a lot of 3D geometry code to review...

Comment thread source/npm/qsharp/ux/quantum-math.ts Outdated
Comment thread source/npm/qsharp/ux/blochGates.ts Outdated
Comment thread source/npm/qsharp/ux/bloch.tsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants