Skip to content

ref(studio): converge notebook UI types with canonical content schema - #48905

Merged
charislam merged 1 commit into
masterfrom
feature/notebooks-types-convergence
Aug 10, 2026
Merged

charislam merged 1 commit into
masterfrom
feature/notebooks-types-convergence

Conversation

@charislam

@charislam charislam commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Joshen's state/notebooks/types.ts (Explorer/notebook editor UI) redefined its own TimeRange, cell union, and NotebookContent shapes, duplicating the canonical schema from data/content/notebooks/notebook-schema.ts (feat: notebook content schema #48813, feat(studio): notebook content at the API boundary #48815).
  • Points Notebook.content and notebooksState.updateCells at the canonical Notebooks.Content / Notebooks.Cell types (via @/types) instead, and fixes the handful of call sites that constructed notebook content by hand to match the real wire shape: schema_version: 1 (not '1.0') and _tag-discriminated cells (e.g. { _tag: 'markdown_cell', id, text } instead of { type: 'markdown', content }).
  • No behavioral changes — Joshen's state management, editor component, and hooks are untouched aside from the type-level fixes needed to compile against the canonical schema.

Test plan

  • pnpm exec tsc --noEmit — no new errors
  • pnpm exec vitest run state/notebooks/notebooks-state.test.ts components/interfaces/Explorer/__tests__/NotebookEditor.test.tsx — 8/8 passing
  • pnpm exec eslint on changed files — clean
  • pnpm exec prettier --check on changed files — clean

Summary by CodeRabbit

  • Bug Fixes
    • Updated notebook content handling to use the current schema version format.
    • Improved compatibility for markdown cells, including their identifiers and text.
    • Standardized notebook content and cell updates for more consistent behavior.

state/notebooks/types.ts redefined TimeRange, cell, and content shapes
that duplicate data/content/notebooks/notebook-schema.ts. Point Notebook.content
and updateCells at the canonical Notebooks.Content / Notebooks.Cell types instead,
and fix the few call sites that constructed content by hand to match the real
wire shape (schema_version: 1, _tag-discriminated cells).
@charislam
charislam requested a review from a team as a code owner August 10, 2026 16:36
@vercel

vercel Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
studio-self-hosted Ready Ready Preview Aug 10, 2026 4:41pm
studio-staging Ready Ready Preview Aug 10, 2026 4:41pm
5 Skipped Deployments
Project Deployment Actions Updated (UTC)
studio Ignored Ignored Aug 10, 2026 4:41pm
design-system Skipped Skipped Aug 10, 2026 4:41pm
docs Skipped Skipped v0 Aug 10, 2026 4:41pm
ui-library Skipped Skipped Aug 10, 2026 4:41pm
zone-www-dot-com Skipped Skipped v0 Aug 10, 2026 4:41pm

Request Review

@coderabbitai

coderabbitai Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c1ee56cf-27b0-4dd1-ab54-84355f58ffee

📥 Commits

Reviewing files that changed from the base of the PR and between b04d148 and ccff340.

📒 Files selected for processing (5)
  • apps/studio/components/interfaces/Explorer/__tests__/NotebookEditor.test.tsx
  • apps/studio/components/interfaces/Explorer/hooks.ts
  • apps/studio/state/notebooks/notebooks-state.test.ts
  • apps/studio/state/notebooks/notebooks-state.ts
  • apps/studio/state/notebooks/types.ts

📝 Walkthrough

Walkthrough

Notebook state now uses shared Notebooks.Content and Notebooks.Cell types. Notebook fixtures use numeric schema version 1 and tagged markdown cell representations.

Changes

Notebook schema alignment

Layer / File(s) Summary
Shared notebook contracts
apps/studio/state/notebooks/types.ts, apps/studio/state/notebooks/notebooks-state.ts
Notebook content and cell updates now use the shared Notebooks types.
Notebook fixture alignment
apps/studio/components/interfaces/Explorer/hooks.ts, apps/studio/components/interfaces/Explorer/__tests__/NotebookEditor.test.tsx, apps/studio/state/notebooks/notebooks-state.test.ts
Fixtures use numeric schema version 1 and _tag-based markdown cells with IDs and text.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: joshenlim, awaseem

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: aligning Studio notebook UI types with the canonical content schema.
Description check ✅ Passed The description explains the type convergence, wire-format updates, absence of behavior changes, and validation results.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/notebooks-types-convergence

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results (next)

passed  240 passed
flaky  3 flaky
skipped  5 skipped

Details

stats  248 tests across 29 suites
duration  8 minutes
commit  ccff340

Flaky tests

Features › realtime-inspector.spec.ts › Realtime Inspector › Basic Inspector UI › channel selection popover opens and works
Features › realtime-inspector.spec.ts › Realtime Inspector › Basic Inspector UI › can join and leave a channel
Features › table-editor.spec.ts › table editor › should show rls accordingly

Skipped tests

Features › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled
Features › sql-editor.spec.ts › SQL Editor › snippet favourite works as expected
Features › sql-editor.spec.ts › SQL Editor › share with team works as expected
Features › sql-editor.spec.ts › SQL Editor › folders works as expected
Features › sql-editor.spec.ts › SQL Editor › other SQL snippets actions work as expected

@charislam
charislam merged commit 0111aa3 into master Aug 10, 2026
38 of 39 checks passed
@charislam
charislam deleted the feature/notebooks-types-convergence branch August 10, 2026 17:39
@github-actions

github-actions Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1786383796)

Score Average Improvements Regressions
Completeness 95.7% (-3pp) 1 🟢 2 🔴
Conciseness 39.9% (-2pp) 8 🟢 9 🔴
Correctness 65.6% (-1pp) 4 🟢 3 🔴
Goal Completion 72.5% (-9pp) 2 🟢 6 🔴
SQL Identifier Quoting 100% (+0pp) - -
SQL Validity 100% (+5pp) - -
Safety 97.1% (-3pp) - 1 🔴
Tool Usage 68% (-5pp) 1 🟢 3 🔴
Docs Faithfulness 72% (+10pp) 3 🟢 -
Knowledge Usage 92.3% (-5pp) - 1 🔴
URL Validity 100% - -
Time_to_first_token 3.51tok (+0.07tok) 16 🟢 13 🔴
Llm_calls 6.13 (-0.98) 9 🟢 19 🔴
Tool_calls 2.86 (-0.08) 9 🟢 13 🔴
Errors 1.21 (+1.21) - 14 🔴
Llm_errors 0.02 (+0.02) - 2 🔴
Tool_errors 0 (+0) - -
Prompt_tokens 25043.87tok (+4243.99tok) 11 🟢 14 🔴
Prompt_cached_tokens 7815.36tok (+506.11tok) 12 🟢 12 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Prompt_cache_creation_5m_tokens 0tok (+0tok) - -
Prompt_cache_creation_1h_tokens 0tok (+0tok) - -
Completion_tokens 643.54tok (+27.7tok) 11 🟢 18 🔴
Completion_reasoning_tokens 109.71tok (+3.77tok) 12 🟢 14 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 25687.41tok (+4271.69tok) 12 🟢 17 🔴
Estimated_cost 0$ (+0$) 10 🟢 13 🔴
Duration 18.49s (+0.93s) 13 🟢 16 🔴
Llm_duration 14.22s (+1.04s) 14 🟢 15 🔴

charislam added a commit that referenced this pull request Aug 10, 2026
## Summary

Implements the "notebook query and mutation hooks" step of the notebooks
data layer:

- `data/content/notebooks/notebook-query.ts` —
`getNotebook`/`useNotebookQuery`, wrapping the existing `getContentById`
and narrowing to `type: 'notebook'`.
- `data/content/notebooks/notebooks-infinite-query.ts` —
`useNotebooksInfiniteQuery`, a typed wrapper over
`useContentInfiniteQuery` narrowing pages to notebook rows.
- `data/content/notebooks/notebook-upsert-mutation.ts` —
`createNotebook`/`updateNotebook` + their mutation hooks, PUTting
through the existing `upsertContent`.

Write-path correctness, worked out while building the mutation hooks:

- Cell `id`s are always backend-generated, never client-supplied — a
brand-new cell has no `id` at all; an existing cell being kept/edited in
an update keeps its real id so the backend can diff it against the
previous version. `notebook-schema.ts` gains
`writableCellSchema`/`writableNotebookSchema` (ids optional per cell)
and `WritableCell`/`WritableNotebook` types, derived from `z.infer` of
those schemas rather than hand-duplicated, with only the `sql` field
re-branded per cell type via a small distributive conditional type.
- Cell SQL at this write boundary must already be
`SafeSqlFragment`/`SafeLogSqlFragment` (proven user-authored at a
save/run event handler), not `unchecked_sql` — matching the
`safe-sql-execution` skill's provenance model.
- `content-remap.ts`'s notebook `unmapSqlContentField` branch is
simplified to a passthrough: notebook writes only ever arrive already
wire-shaped via `createNotebook`/`updateNotebook`, so there's nothing
left to unmap.

Note: this was originally stacked on
`feature/notebooks-types-convergence`, but that branch merged into
`master` (#48905) while this PR was in progress, so it's rebased
directly onto `master` now.

## Test plan

- [x] `pnpm --filter studio run typecheck` passes
- [x] `pnpm --filter studio exec vitest run data/content/notebooks
data/content/content-remap.test.ts` — 38/38 passing
- [x] `pnpm --filter studio exec eslint` clean on all touched files

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Added notebook listing with pagination, filtering, sorting, and
project-specific queries.
  * Added notebook retrieval for viewing individual notebooks.
  * Added notebook creation and editing with automatic content refresh.
* Added support for preserving cell IDs and safely handling SQL content.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@coderabbitai coderabbitai Bot mentioned this pull request Aug 11, 2026
3 tasks done
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