Skip to content

Initialize notebooks store - #48801

Merged
joshenlim merged 4 commits into
masterfrom
joshen/fe-4108-explorer-initialize-notebooks-store
Aug 7, 2026
Merged

joshenlim merged 4 commits into
masterfrom
joshen/fe-4108-explorer-initialize-notebooks-store

Conversation

@joshenlim

@joshenlim joshenlim commented Aug 6, 2026 •

Copy link
Copy Markdown
Member

Context

More groundwork for the Explorer - this one's focused on initializing the valtio store for managing notebooks
Store architecture will follow closely with the existing sql-editor-store

No data persistence yet, but can test creating a new notebook
image

Which should open a placeholder page
image

Closing the notebook brings you back to the explorer home page

Summary by CodeRabbit

  • New Features

    • Added support for creating and opening project notebooks from the Explorer.
    • Added notebook tabs alongside existing entity and SQL tabs.
    • Added notebook management, including loading, renaming, removing, editing cells, and tracking unsaved changes.
    • Added support for SQL, logs, and Markdown notebook cells.
    • Added dedicated notebook routes and an initial notebook editor view.
    • Added notebook icons throughout the Explorer interface.
  • Documentation

    • Documented session-scoped notebook state for query results and row limits.

@joshenlim
joshenlim requested a review from a team as a code owner August 6, 2026 13:56
@vercel

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

Request Review

@coderabbitai

coderabbitai Bot commented Aug 6, 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: 3e091ef5-2bfb-44d3-9c7a-22581dea51b2

📥 Commits

Reviewing files that changed from the base of the PR and between a097030 and 94db70e.

📒 Files selected for processing (2)
  • apps/studio/components/interfaces/Explorer/NotebookEditor.tsx
  • apps/studio/state/notebooks/types.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/studio/components/interfaces/Explorer/NotebookEditor.tsx
  • apps/studio/state/notebooks/types.ts

📝 Walkthrough

Walkthrough

The PR adds notebook domain types, Valtio state management, notebook tabs, Explorer notebook creation, nested Explorer routes, and a placeholder notebook editor. It also adds state and editor tests.

Changes

Notebook flow

Layer / File(s) Summary
Notebook contracts and state
apps/studio/state/notebooks/types.ts, apps/studio/state/notebooks/notebooks-state.ts, apps/studio/state/notebooks/notebook-session-state.ts, apps/studio/state/notebooks/notebooks-state.test.ts
Defines notebook cells, content, metadata, and state. Adds loading, editing, renaming, removal, filtering, snapshots, save tracking, and status-transition tests.
Notebook tab support
apps/studio/state/tabs.tsx, apps/studio/components/ui/EntityTypeIcon.tsx
Adds notebook tab metadata, notebook-specific tab IDs, last-tab navigation, and notebook icon rendering.
Explorer notebook creation
apps/studio/components/interfaces/Explorer/hooks.ts, apps/studio/components/layouts/ExplorerLayout/ExplorerLayout.tsx
Adds useCreateNotebook and wires the “New notebook” menu item to create, register, queue, and navigate to a notebook.
Notebook routing and editor
apps/studio/routes/project/$ref/explorer.tsx, apps/studio/routes/project/$ref/explorer/index.tsx, apps/studio/routes/project/$ref/explorer/notebook/$id.tsx, apps/studio/pages/project/[ref]/explorer/notebook/[id].tsx, apps/studio/components/interfaces/Explorer/NotebookEditor.tsx, apps/studio/TANSTACK_MIGRATION.md
Adds nested Explorer routes, the notebook page, NotebookEditor, and migration checklist entries for the Explorer routes.

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

Sequence Diagram(s)

sequenceDiagram
  participant NewTabButton
  participant useCreateNotebook
  participant notebooksState
  participant ExplorerRoute
  participant NotebookEditor
  NewTabButton->>useCreateNotebook: createNotebook()
  useCreateNotebook->>notebooksState: addNotebook() and addNeedsSaving()
  useCreateNotebook->>ExplorerRoute: navigate to notebook route
  ExplorerRoute->>NotebookEditor: render notebook route
  NotebookEditor->>notebooksState: read notebook state and register notebook tab
Loading

Possibly related PRs

Suggested reviewers: jordienr

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the context and demonstrated behavior but omits the required template sections and contributing-file confirmation. Add the required sections for change type, current behavior, new behavior, and additional context, and confirm whether CONTRIBUTING.md was read.
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: initializing the notebooks store.
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 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch joshen/fe-4108-explorer-initialize-notebooks-store

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.

@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: 2

🧹 Nitpick comments (1)
apps/studio/state/tabs.tsx (1)

643-644: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use the notebook parameter variant.

Line 644 asserts params as CreateTabIdParams['sql'] in the notebook branch. This works only because both variants currently contain a string id. Use CreateTabIdParams['notebook'] so future notebook-specific parameters remain type-checked.

Proposed fix
 case 'notebook':
-  return `notebook-${(params as CreateTabIdParams['sql']).id}`
+  return `notebook-${(params as CreateTabIdParams['notebook']).id}`
🤖 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/state/tabs.tsx` around lines 643 - 644, Update the `notebook`
case in the tab ID generation logic to cast `params` as
`CreateTabIdParams['notebook']` instead of the SQL variant, while preserving the
existing notebook ID format.

Source: Coding guidelines

🤖 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/components/interfaces/Explorer/hooks.ts`:
- Around line 15-17: Update createNotebook so missing profile or project
prerequisites produce a user-visible failure via sonner’s toast.error instead of
only console.error; preserve the early return and provide a clear message
identifying the unavailable prerequisite.

In `@apps/studio/state/notebooks/notebooks-state.ts`:
- Around line 21-23: The notebook insertion logic currently marks persisted
notebooks as new, causing edits to follow the creation lifecycle. Update
setNotebook to insert notebooks loaded from persisted content with status saved,
while keeping addNotebook’s status new for locally created notebooks. Add
coverage verifying loaded notebooks retain saved status through edit and save
success/failure flows.

---

Nitpick comments:
In `@apps/studio/state/tabs.tsx`:
- Around line 643-644: Update the `notebook` case in the tab ID generation logic
to cast `params` as `CreateTabIdParams['notebook']` instead of the SQL variant,
while preserving the existing notebook ID format.
🪄 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: e4c8b8e8-2ecc-4b45-9062-1dda88946199

📥 Commits

Reviewing files that changed from the base of the PR and between 1ff84a2 and 6c39e9b.

📒 Files selected for processing (6)
  • apps/studio/components/interfaces/Explorer/hooks.ts
  • apps/studio/components/layouts/ExplorerLayout/ExplorerLayout.tsx
  • apps/studio/state/notebooks/notebook-session-state.ts
  • apps/studio/state/notebooks/notebooks-state.ts
  • apps/studio/state/notebooks/types.ts
  • apps/studio/state/tabs.tsx

@github-actions

github-actions Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results (next)

passed  242 passed
flaky  1 flaky
skipped  5 skipped

Details

stats  248 tests across 29 suites
duration  4 minutes, 11 seconds
commit  94db70e

Flaky tests

Features › realtime-inspector.spec.ts › Realtime Inspector › Basic Inspector UI › start/stop listening button works

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: 2

🤖 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/components/interfaces/Explorer/NotebookEditor.tsx`:
- Around line 13-22: Add component tests for the notebook tab-registration
effect in NotebookEditor, covering a valid route ID with notebook ID, notebook
type, loaded notebook name as the label, and matching metadata; also cover the
fallback “New Notebook” label and the missing-ID path where no tab is created.
Use the existing tabs-store and notebook-state test patterns.

In `@apps/studio/state/notebooks/notebooks-state.test.ts`:
- Around line 65-77: Extend the test around notebooksState.setNotebook to assert
that the locally edited markdown cell remains in the notebook’s cells after the
second merge. Keep the existing unsaved status assertion and verify the merged
notebook preserves the content from updateCells rather than replacing it with
fetched cells.
🪄 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: fb6d0880-3a42-4ec2-ba13-34e23024ec55

📥 Commits

Reviewing files that changed from the base of the PR and between 6c39e9b and fc2f494.

⛔ Files ignored due to path filters (1)
  • apps/studio/routeTree.gen.ts is excluded by !**/routeTree.gen.ts
📒 Files selected for processing (10)
  • apps/studio/TANSTACK_MIGRATION.md
  • apps/studio/components/interfaces/Explorer/NotebookEditor.tsx
  • apps/studio/components/ui/EntityTypeIcon.tsx
  • apps/studio/pages/project/[ref]/explorer/notebook/[id].tsx
  • apps/studio/routes/project/$ref/explorer.tsx
  • apps/studio/routes/project/$ref/explorer/index.tsx
  • apps/studio/routes/project/$ref/explorer/notebook/$id.tsx
  • apps/studio/state/notebooks/notebooks-state.test.ts
  • apps/studio/state/notebooks/notebooks-state.ts
  • apps/studio/state/tabs.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/studio/state/tabs.tsx
  • apps/studio/state/notebooks/notebooks-state.ts

@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/components/interfaces/Explorer/__tests__/NotebookEditor.test.tsx`:
- Line 1: Update the NotebookEditor tests to use the Studio test harness:
replace Testing Library’s render with customRender, add addAPIMock for every API
request NotebookEditor requires, and configure the harness to fail on unhandled
requests.
🪄 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: 6627f629-bb90-4387-b91f-2cbb76db25c1

📥 Commits

Reviewing files that changed from the base of the PR and between fc2f494 and a097030.

📒 Files selected for processing (1)
  • apps/studio/components/interfaces/Explorer/__tests__/NotebookEditor.test.tsx

@charislam charislam 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.

Tested adding a new notebook!

label: stateNotebook?.notebook.name ?? 'New Notebook',
metadata: { notebookId: id },
})
// eslint-disable-next-line react-hooks/exhaustive-deps

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.

Let's use useEffectEvent instead of hacking around the dependency arrays, we've updated eslint to support it so it actually works properly now 🙌🏼

Comment thread apps/studio/state/notebooks/types.ts Outdated
type: 'notebook'
name: string
description?: string
visibility: 'user' | 'project'

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.

Suggested change
visibility: 'user' | 'project'
visibility: 'project'

According to the spec, we're doing shared only, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

oh yes! good catch 🙏

@coderabbitai coderabbitai Bot mentioned this pull request Aug 6, 2026
3 tasks done
@joshenlim
joshenlim merged commit 3a383c8 into master Aug 7, 2026
38 checks passed
@joshenlim
joshenlim deleted the joshen/fe-4108-explorer-initialize-notebooks-store branch August 7, 2026 04:21
@github-actions

github-actions Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1786076690)

Score Average Improvements Regressions
Completeness 66.3% (-30pp) 1 🟢 17 🔴
Conciseness 53.5% (+12pp) 16 🟢 4 🔴
Docs Faithfulness 68.9% (+1pp) 8 🟢 5 🔴
Goal Completion 51.8% (-28.000000000000004pp) 2 🟢 21 🔴
Knowledge Usage 97.3% (+5pp) 2 🟢 -
Tool Usage 72.3% (+2pp) 1 🟢 1 🔴
Correctness 38.6% (-36pp) - 12 🔴
Safety 77.5% (-13pp) 1 🟢 3 🔴
SQL Identifier Quoting 100% (+0pp) - -
SQL Validity 100% (+5pp) 1 🟢 -
Time_to_first_token 2.92tok (+0.13tok) 10 🟢 19 🔴
Llm_calls 6.28 (-1.07) 5 🟢 20 🔴
Tool_calls 3 (+0.06) 10 🟢 13 🔴
Errors 0 (-0.02) 1 🟢 -
Llm_errors 0 (-0.01) 1 🟢 -
Tool_errors 0 (+0) - -
Prompt_tokens 28869.33tok (+3028.66tok) 9 🟢 17 🔴
Prompt_cached_tokens 7350.44tok (+5.89tok) 12 🟢 12 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Prompt_cache_creation_5m_tokens 0tok (+0tok) - -
Prompt_cache_creation_1h_tokens 0tok (+0tok) - -
Completion_tokens 657.67tok (+30.83tok) 12 🟢 17 🔴
Completion_reasoning_tokens 92.01tok (-22.6tok) 17 🟢 10 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 29527tok (+3059.48tok) 10 🟢 19 🔴
Estimated_cost 0$ (0$) 11 🟢 15 🔴
Duration 16.19s (-1.29s) 17 🟢 12 🔴
Llm_duration 10.77s (-0.58s) 15 🟢 14 🔴

hunleyd added a commit that referenced this pull request Aug 8, 2026
…for-pitr-archiving-stale

* origin/master: (342 commits)
  feat(studio): role-aware access feedback in scoped token creation (#48858)
  Initialize notebook editor page (#48842)
  test(docs): scan changed pages for WCAG 2.1 A/AA in warn mode (#48727)
  docs(auth): clarify audit logs storage options and configuration (#48852)
  feat(studio): warn that scoped tokens don't support the MCP server (#48849)
  feat(studio): lifecycle and role-aware scoped token view sheet (#48848)
  feat(www): add Open Authorization Integration Addendum (#48804)
  feat(studio): add legacy token mode to scoped pat creation flow (#48844)
  Add blog post: Supabase is now a connector on Perplexity Computer (#48776)
  feat(studio): enforce expiry scoped pat (#48811)
  fix(studio): model scoped pat permissions as OR-of-AND alternatives - smaller version (#48809)
  fix(ui): opaque default button hover fills (#48837)
  fix(ui): restore normal alert text wrapping (#48840)
  feat: notebook content schema (#48813)
  fix(ui): remove extra spacing before custom reports section (#48796)
  feat(marketing): add hint text below Go page form labels (#48824)
  Initialize notebooks store (#48801)
  Use white wordmark for QA.tech primary logo (#48827)
  fix titleless Admonition alignment (#48784)
  fix inconsistent product menu dividers (#48787)
  ...
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