Skip to content

fix(jupyter): emit Quarto-canonical cells so captures splice into previews (bd-gthycd33)#360

Merged
cscheid merged 1 commit into
mainfrom
bugfix/bd-gthycd33-jupyter-engine-output-not
Jul 2, 2026
Merged

fix(jupyter): emit Quarto-canonical cells so captures splice into previews (bd-gthycd33)#360
cscheid merged 1 commit into
mainfrom
bugfix/bd-gthycd33-jupyter-engine-output-not

Conversation

@cscheid

@cscheid cscheid commented Jul 2, 2026

Copy link
Copy Markdown
Member

Summary

Fixes bd-gthycd33: executed jupyter output never spliced into the hub-client / q2 preview preview (the {python} cell kept rendering as raw source), while the identical knitr flow worked.

Root cause. The jupyter engine emitted executed cells as bare fences (```python echo + ```{.cell-output}), with no ::: {.cell} wrapper. derive_cell_outputs (capture splice) requires each engine cell to map to a Div.cell in the post-engine markdown, so the cell-output map came out empty and the splice fail-softed to raw source. The Bootstrap CSS (.cell .cell-output-* pre code) never matched jupyter output either.

Fix (emission-side). text_execute.rs now emits the knitr/Q1-parity shape: ::: {.cell} wrapper, {.python .cell-code} echo fence, ::: {.cell-output .cell-output-{stdout,stderr,display,error}} divs (Q1's outputTypeCssClass scheme), and Q1-rule fence sizing (max(3, longest leading backtick run + 1) — fixes latent markdown corruption for backtick-bearing content). Also: array-form mime text (nbformat multiline) is no longer silently dropped, and a cell without a preceding blank line can't glue its div fence onto the paragraph.

Structural anti-regression. The test-only parallel AST emitter (JupyterTransform / outputs_to_blocks) is retired — no production consumer; one emission path remains. Two new fences pin the contract:

  • capture_splice_engines.rs — regression pair driving the real engines through record_capture and the exact splice path (jupyter failed with an empty map before this fix; knitr is the control).
  • engine_output_parity.rs — 5 cross-engine shape-parity cases (stream, expression value, error under #| error: true, source-only, dependent cells); block-kind + semantic-class tree equality; runtime-gated on both engines being installed.

Verification. Workspace suite 10181 passed; full cargo xtask verify passed; clippy/lint/fmt clean. E2E: q2 render HTML inspected (div.cell, 5 in .cell-output-display); q2 preview in a real browser after the full WASM chain rebuild shows the spliced capture (5 + stream output in the iframe DOM) — the originally-failing surface.

Follow-ups filed (discovered-from bd-gthycd33): bd-ohvl879u (error-policy divergence: jupyter embeds cell errors and continues where knitr fails the render), bd-2me3cslx (pre-existing broken #[ignore]d full-pipeline tests — nested tokio runtime, reproduced at baseline), bd-u996g8g2 (inline {python} expr), bd-5t6wvu7m (real image outputs), bd-vs7sa0qx (execution_count attrs).

Plan with full evidence: claude-notes/plans/2026-07-01-bd-gthycd33-jupyter-cell-wrapper.md.

🤖 Generated with Claude Code

…ice into previews (bd-gthycd33)

Jupyter's post-engine markdown lacked the Div.cell wrapper that
CaptureSpliceStage and the Bootstrap cell CSS key on, so executed
output never spliced into hub-client/q2-preview (knitr worked). Emit
the knitr/Q1-parity shape, retire the divergent test-only AST path
(JupyterTransform/outputs_to_blocks), and pin the contract with a
splice regression pair + a 5-case cross-engine output-parity suite.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@posit-snyk-bot

posit-snyk-bot commented Jul 2, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@cscheid cscheid merged commit 370e0e5 into main Jul 2, 2026
8 checks passed
@cscheid cscheid deleted the bugfix/bd-gthycd33-jupyter-engine-output-not branch July 2, 2026 18:20
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.

2 participants