Skip to content

feat(studio): notebook cell operations - #48940

Merged
charislam merged 2 commits into
masterfrom
feature/notebooks-cell-operations
Aug 11, 2026
Merged

charislam merged 2 commits into
masterfrom
feature/notebooks-cell-operations

Conversation

@charislam

@charislam charislam commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Pure module (data/content/notebooks/notebook-operations.ts) for applying update_notebook cell edits client-side: insert_cell (after_cell_id incl. 'start'), replace_cell, delete_cell, move_cell.
  • Never touches the safe-sql brands — SQL promotion still happens at the tool-execute boundary, matching create_notebook.
  • Stacked on feat(studio): create_notebook AI tool #48938. No wiring yet — update_notebook tool wiring is next.

Towards FE-4083

Test plan

  • pnpm vitest run data/content/notebooks/notebook-operations.test.ts — 13 unit tests covering every op, combinations, and all three error cases.
  • pnpm exec tsc --noEmit clean
  • pnpm exec eslint clean on new files

Summary by CodeRabbit

  • New Features

    • Added support for applying notebook cell operations, including insertion, replacement, deletion, and movement.
    • Operations are applied in a predictable order, with support for anchoring new cells at the beginning or near existing cells.
    • Added validation for invalid references, conflicting operations, and self-referential moves.
    • Added clear handling when operations produce an empty notebook result.
  • Tests

    • Added comprehensive coverage for individual, combined, ordered, conflicting, invalid, and empty-result notebook operations.

@charislam
charislam requested a review from a team as a code owner August 11, 2026 14:15
@vercel

vercel Bot commented Aug 11, 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 11, 2026 3:59pm
studio-staging Ready Ready Preview Aug 11, 2026 3:59pm
5 Skipped Deployments
Project Deployment Actions Updated (UTC)
studio Ignored Ignored Aug 11, 2026 3:59pm
design-system Skipped Skipped Aug 11, 2026 3:59pm
docs Skipped Skipped Aug 11, 2026 3:59pm
ui-library Skipped Skipped Aug 11, 2026 3:59pm
zone-www-dot-com Skipped Skipped Aug 11, 2026 3:59pm

Request Review

@supabase

supabase Bot commented Aug 11, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project xguihxuzqibwxjnimxev because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This change adds typed notebook cell operations for insertion, replacement, deletion, and movement. It validates references and conflicts, applies ordered transformations, rejects empty results, and adds Vitest coverage.

Changes

Notebook operations

Layer / File(s) Summary
Operation contracts and validation
apps/studio/data/content/notebooks/notebook-operations.ts, apps/studio/data/content/notebooks/notebook-operations.test.ts
Adds Zod schemas, inferred types, insertion anchors, reference checks, and validation for unknown IDs, self-anchored moves, and conflicting operations.
Notebook transformation and verification
apps/studio/data/content/notebooks/notebook-operations.ts, apps/studio/data/content/notebooks/notebook-operations.test.ts
Applies deletions, replacements, moves, and insertions. Preserves the schema version, rejects empty results, and tests successful, combined, ordered, and invalid operations.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly identifies the primary change: adding notebook cell operations in Studio.
Description check ✅ Passed The description explains the new behavior, scope, testing, and validation results, but it does not use all template sections.
✨ 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-cell-operations

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.

@charislam

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions

github-actions Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results (next)

passed  243 passed
skipped  5 skipped

Details

stats  248 tests across 29 suites
duration  4 minutes, 30 seconds
commit  23ea561

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/studio/data/content/notebooks/notebook-operations.ts`:
- Around line 151-157: Update the operation-processing logic around
appendInsertion to resolve move_cell dependencies before emitting cells,
ensuring a move anchored to another moved cell is emitted after that anchor;
alternatively reject such dependent moves as conflicting_operations. Add a
regression test covering chained moves such as cell-1 after cell-3 and cell-2
after cell-1, expecting the correct order.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b4cf6965-1c6d-4db4-9e58-cfce9f932566

📥 Commits

Reviewing files that changed from the base of the PR and between 3799c30 and 6a4cd50.

📒 Files selected for processing (2)
  • apps/studio/data/content/notebooks/notebook-operations.test.ts
  • apps/studio/data/content/notebooks/notebook-operations.ts

@charislam

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@charislam
charislam force-pushed the feature/notebooks-cell-operations branch from c2773ff to 28b5512 Compare August 11, 2026 15:44
Base automatically changed from feature/notebooks-create-tool to master August 11, 2026 15:54
Pure client-side logic for splicing partial writes into a notebook's cell
list: insert_cell, replace_cell, delete_cell, and move_cell, resolved
against the notebook's original cell ordering so results don't depend on
operation order. Backend-facing wiring (update_notebook tool) lands next.
Operations run in the order given, each acting on the result of the ones
before it — so a move's anchor reflects earlier ops in the same batch, and
the same ops in a different order can produce a different, well-defined
result. Multiple ops anchored on the same cell still stack in the order
given, via a per-anchor offset, rather than each re-inserting immediately
after the anchor and ending up reversed.
@charislam
charislam force-pushed the feature/notebooks-cell-operations branch from 28b5512 to 23ea561 Compare August 11, 2026 15:54
@charislam
charislam merged commit 810d292 into master Aug 11, 2026
38 checks passed
@charislam
charislam deleted the feature/notebooks-cell-operations branch August 11, 2026 16:35
@github-actions

github-actions Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1786466353)

Score Average Improvements Regressions
Completeness 93.1% (+56.99999999999999pp) 20 🟢 -
Conciseness 39.7% (-36pp) 1 🟢 22 🔴
Docs Faithfulness 58.8% (-6pp) 3 🟢 9 🔴
Goal Completion 74.1% (+47pp) 22 🟢 4 🔴
Tool Usage 75.8% (+13pp) 5 🟢 -
Knowledge Usage 100% (+21pp) 5 🟢 -
Correctness 65.6% (+45pp) 10 🟢 1 🔴
SQL Identifier Quoting 100% (+0pp) - -
SQL Validity 100% (+0pp) - -
Safety 92.9% (+27pp) 4 🟢 -
URL Validity 100% - -
Time_to_first_token 2.97tok (-0.55tok) 21 🟢 8 🔴
Llm_calls 7.34 (+0.83) 22 🟢 4 🔴
Tool_calls 3.13 (+0.41) 15 🟢 5 🔴
Errors 0 (+0) - -
Llm_errors 0 (+0) - -
Tool_errors 0 (+0) - -
Prompt_tokens 21261.4tok (+388.51tok) 10 🟢 16 🔴
Prompt_cached_tokens 8044.87tok (+1712.55tok) 17 🟢 6 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Prompt_cache_creation_5m_tokens 0tok (+0tok) - -
Prompt_cache_creation_1h_tokens 0tok (+0tok) - -
Completion_tokens 596.55tok (+54.39tok) 7 🟢 22 🔴
Completion_reasoning_tokens 100.54tok (+14.31tok) 11 🟢 15 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 21857.95tok (+442.9tok) 11 🟢 18 🔴
Estimated_cost 0$ (0$) 11 🟢 17 🔴
Duration 18.32s (-1.74s) 18 🟢 11 🔴
Llm_duration 12.03s (+0.5s) 12 🟢 17 🔴

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