Repository navigation
test(studio): mock notebook tools - #48952
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
5 Skipped Deployments
|
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe change adds shared notebook operation error descriptions and mock notebook tools. The mocks use deterministic fixtures and isolated in-memory stores for listing, retrieval, creation, and cell updates. Tests cover approval behavior, state changes, validation errors, and isolation. ChangesNotebook tool support
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant getMockTools
participant NotebookTool
participant MockNotebookStore
Caller->>getMockTools: create tool set
getMockTools->>MockNotebookStore: initialize isolated store
Caller->>NotebookTool: invoke notebook operation
NotebookTool->>MockNotebookStore: read or update notebook state
MockNotebookStore-->>NotebookTool: return notebook data or operation error
NotebookTool-->>Caller: return tool result
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/studio/lib/ai/tools/mock-tools.ts (1)
379-380: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider deep-copying the seeded notebooks per store.
createMockNotebookStoreputs the exportedMOCK_NOTEBOOKS_DATAobjects into the Map by reference. Every store therefore shares the same seeded notebook objects. The current code stays safe becausereplaceCellswrites a new object instead of mutatingexisting. If a later change mutates a notebook or itscontent.cellsin place, state will leak acrossgetMockToolscalls and across tests. A per-store clone removes that risk.♻️ Proposed clone of the seeded fixtures
function createMockNotebookStore() { - const notebooks = new Map(MOCK_NOTEBOOKS_DATA.map((notebook) => [notebook.id, notebook])) + const notebooks = new Map( + MOCK_NOTEBOOKS_DATA.map((notebook) => [notebook.id, structuredClone(notebook)]) + )🤖 Prompt for 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. In `@apps/studio/lib/ai/tools/mock-tools.ts` around lines 379 - 380, Update createMockNotebookStore so each Map entry is a deep clone of its corresponding MOCK_NOTEBOOKS_DATA fixture rather than the shared object reference. Preserve notebook IDs and the existing store behavior while ensuring nested content.cells state is isolated across getMockTools calls and tests.
🤖 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.
Nitpick comments:
In `@apps/studio/lib/ai/tools/mock-tools.ts`:
- Around line 379-380: Update createMockNotebookStore so each Map entry is a
deep clone of its corresponding MOCK_NOTEBOOKS_DATA fixture rather than the
shared object reference. Preserve notebook IDs and the existing store behavior
while ensuring nested content.cells state is isolated across getMockTools calls
and tests.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 6f46ebd4-da35-4f71-a3e4-2f7844c903ae
📒 Files selected for processing (4)
apps/studio/data/content/notebooks/notebook-operations.tsapps/studio/lib/ai/tools/mock-tools.test.tsapps/studio/lib/ai/tools/mock-tools.tsapps/studio/lib/ai/tools/notebook-tools.ts
🎭 Playwright Test Results (tanstack)Details
Flaky testsFeatures › rls-policies.spec.ts › RLS Policies › Create RLS Policy › should create an INSERT policy with authenticated role Skipped testsFeatures › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled |
Add deterministic list_notebooks/get_notebook fixtures and stateful in-memory create_notebook/update_notebook mocks for the AI assistant eval harness. Dedupe describeOperationError (duplicated between this mock and notebook-tools.ts) into a single exported describeNotebookOperationError in notebook-operations.ts.
cd4eb45 to
08d643a
Compare
Summary
list_notebooks/get_notebookfixtures (two seeded notebooks, each with markdown/database/log cells) and stateful in-memorycreate_notebook/update_notebookmocks toapps/studio/lib/ai/tools/mock-tools.ts, so Braintrust evals can exercise notebook tool calls without a real project.needsApproval: false, matching the existingexecute_sql/deploy_edge_functionmock pattern — the eval harness filters out tool-parts in'approval-requested'state and can never answer an approval gate.getNotebookTools()definitions (onlyexecute/needsApprovaloverridden), so evals validate the model's arguments against the exact production schemas.describeOperationError(previously duplicated between this new mock andnotebook-tools.ts) into a single exporteddescribeNotebookOperationErrorinnotebook-operations.ts.Stacked on #48949 (
feature/notebooks-update-tool) — this PR's base branch is that PR, notmaster, because it reusesupdate_notebookand the shared error helper that only exist there. Merge #48949 first, then retarget/merge this one.Test plan
Summary by CodeRabbit
New Features
Bug Fixes
Tests