Repository navigation
feat(blocks,convert,runtime-core,mcp): add the pivot-table block type - #524
Conversation
Deepnote's product ships a pivot table block, but `deepnoteBlockSchema` had no arm for it. The union is closed, so any `.deepnote` file or snapshot containing one was rejected by `deserializeDeepnoteFile`. `pivot-table` now parses, re-serializes with its configuration intact, converts to and from Jupyter, Percent, Quarto and Marimo, executes through runtime-core, and is creatable through the MCP server — the support level `visualization` has. The `deepnote_pivot_*` metadata fields are deliberately left undeclared: the block is in beta and `executableBlockMetadataSchema` is `.passthrough()`, so the product's keys survive a roundtrip whatever their current shape. `skills/deepnote/references/blocks-display.md` is therefore the only reference for their names and types, since the generated `schema.ts` renders them as the arm's `[k: string]: any`. Codegen disables `sanitizePythonVariableName`'s `input_1` fallback, unlike the SQL block: a pivot block reads its variable rather than defining it, so a fallback name would point at a variable the kernel does not have. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011qCZn7rQzh55Ty5aXrp8Hn
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #524 +/- ##
==========================================
+ Coverage 89.86% 89.89% +0.02%
==========================================
Files 207 208 +1
Lines 12200 12226 +26
Branches 3514 3529 +15
==========================================
+ Hits 10963 10990 +27
+ Misses 1234 1233 -1
Partials 3 3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The pivot-table YAML example reused the id and blockGroup of the big-number example further down the same file. An agent copying both examples into one .deepnote would produce colliding ids, which the MCP block lookups reject as an ambiguous prefix. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0189TDaQLJ8fGjXm4EXDXSSv
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Essentials Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Essentials Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughThe change adds beta Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Feature Suggested reviewers: Merge Risk: ⚪ Minimal · up to The reviewed changes show no established actionable regression that should prevent merging. 🚥 Pre-merge checks | ✅ 5 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (5 passed)
Comment |
…in createPythonCode function
The switch added in 6bf3e47 had no test, so every line of it was uncovered and the patch sat below codecov's 80% target. One case per non-executable block type pins the message it throws, and an unknown type covers the fall-through that `block satisfies never` rules out at compile time but not at runtime. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0189TDaQLJ8fGjXm4EXDXSSv
The list in 6325a53 was the switch's case labels retyped, so it could only ever agree with the implementation. Reading the types off deepnoteBlockSchema and subtracting the executable ones makes the test fail when a block type is added to the schema and createPythonCode is not taught about it. An empty it.each generates no tests and reports green, so a separate assertion guards the derivation against silently yielding nothing. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0189TDaQLJ8fGjXm4EXDXSSv
What
Adds the
pivot-tableblock type to@deepnote/blocks. Deepnote's product ships a pivot table block (docs), butdeepnoteBlockSchemahad no arm for it. The union is a closedz.discriminatedUnion, so any.deepnotefile or snapshot containing one was rejected bydeserializeDeepnoteFile, and the product's own export path dropped or rejected it before the file was written.After this change
pivot-tableparses, re-serializes with its configuration intact, converts to and from Jupyter/Percent/Quarto/Marimo, executes throughruntime-core, and is creatable through the MCP server — the same support levelvisualizationhas.The product consumes this package at
^4.5.1, so the product-side effect follows a release and a dependency bump, not this merge.Changes
pivot-tablearm aftervisualizationBlockSchema,PivotTableBlockexported fromdeepnote-file-schema.ts(not the package index, matchingVisualizationBlock), and membership inExecutableBlock.packages/blocks/src/blocks/pivot-table-blocks.tsreproducing the source the product emits for a pivot cell, dispatched fromcreatePythonCode.executableBlockTypesin@deepnote/blocksand@deepnote/runtime-core, andCODE_BLOCK_TYPESin@deepnote/convert.deepnote_createcase.blocks-display.md,SKILL.md,packages/blocks/README.md, and a regeneratedskills/deepnote/references/schema.ts.Two deliberate design decisions
deepnote_pivot_*fields are left undeclared.executableBlockMetadataSchemais.passthrough(), so the product's keys survive parse and serialize whatever their current shape — which is what a beta block needs. The consequence: the generatedschema.tsrenders them as the arm's[k: string]: any, so the hand-written table inblocks-display.mdis the only place an agent can learn their names and types.Codegen disables
sanitizePythonVariableName'sinput_1fallback, unlikesql-blocks.ts. A SQL block's variable is one the generated code defines; a pivot block reads its variable, so a fallback name would point at a variable the kernel does not have.createPythonCodereturns''instead.Out of scope
application/vnd.deepnote.pivot-table.v1+json.output-renderer.tsfalls through to[Output with MIME types: …]andextractOutputsTextyields'', so the MCPrunsummary omits the block and an agent block running after it in the same run sees an empty### Output:section. Not an exact parallel tovisualization, whose chart output carries atext/plainrepr that both surfaces print.AST_ANALYZER_SUPPORTED_CELL_TYPES_LISTomitsvisualization, andagentwas deliberately removed from it in770f2114.packages/mcp/src/instructions.tsandprompts.ts— confirmed these already omitagent,visualization,notebook-function,input-textareaandinput-file, so they are partial lists by design rather than a sync obligation.Verification
pnpm vitest run --bail=0pnpm typecheckpnpm biome:checkpnpm prettier:checkThree pre-existing failures are unchanged from the baseline, all in
packages/cli/src/commands/run.test.ts: they assertpythonEnv: 'python'but the dev box has onlypython3onPATH. Unrelated to this change; present onmain.Every new test was watched failing under a realistic mutation before being accepted — removing the
createPythonCodebranch, removing the union arm, removingpivot-tablefromCODE_BLOCK_TYPES, removing it from runtime-core'sexecutableBlockTypes, droppingdisableEmptyFallback, dropping sanitization, and making the arm's metadata.strip()instead of passthrough. The generated Python was also diffed byte-for-byte against the intended output andast.parsed as valid Python.Reviewer note
The codegen template could not be verified against the product's
createJupyterSourceindeepnote-internalfrom this environment. Please check the emitted source againstlibs/shared/src/cells/pivot-table-cell-utils.ts:Risk
Additive only — one new union arm, one new module, four list entries. No existing behavior changes; rollback is a revert with no migration. The one-way door is format-level: once a
.deepnotefile in the wild contains apivot-tableblock, an older@deepnote/blocksrejects the whole file. That is inherent to the feature.🤖 Generated with Claude Code
https://claude.ai/code/session_011qCZn7rQzh55Ty5aXrp8Hn
Summary by CodeRabbit