Skip to content

Chore/refactor observability layout menu - #48089

Merged
joshenlim merged 2 commits into
masterfrom
chore/refactor-observability-layout-menu
Jul 20, 2026
Merged

joshenlim merged 2 commits into
masterfrom
chore/refactor-observability-layout-menu

Conversation

@joshenlim

@joshenlim joshenlim commented Jul 20, 2026 •

Copy link
Copy Markdown
Member

Context

Just refactors ObservabilityMenu to retrieve the menu items via a hook + scaffold the Top for Postgres menu item

No functional changes here

Summary by CodeRabbit

  • New Features
    • Added a keyboard shortcut (U, then C) for quickly opening Observability Connections.
    • Improved observability navigation with feature-aware sections and consistent URL parameter preservation.
    • Custom reports are now sorted alphabetically and include available actions directly in the menu.
  • Bug Fixes
    • Improved handling of missing report details and duplicate or unsupported query parameters.

@joshenlim
joshenlim requested a review from a team as a code owner July 20, 2026 06:46
@supabase

supabase Bot commented Jul 20, 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 ↗︎.

@vercel

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

Request Review

@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Observability menu generation now uses hooks for navigation and custom reports, with preserved query parameters and feature-gated sections. Custom report rendering consumes hook results. A new keyboard shortcut registers Observability Connections navigation.

Changes

Observability menu generation

Layer / File(s) Summary
Navigation menu hooks
apps/studio/components/layouts/ObservabilityLayout/ObservabilityMenu.utils.tsx, apps/studio/components/layouts/ObservabilityLayout/ObservabilityMenu.utils.test.tsx
Navigation items now derive from URL parameters, feature flags, platform state, and preserved query parameters, with hook-level coverage.
Custom report menu integration
apps/studio/components/layouts/ObservabilityLayout/ObservabilityMenu.utils.tsx, apps/studio/components/layouts/ObservabilityLayout/ObservabilityMenu.tsx, apps/studio/components/layouts/ObservabilityLayout/ObservabilityMenu.utils.test.tsx
Custom reports are queried, filtered, sorted, mapped to menu items, and rendered with loading and empty states.

Observability Connections shortcut

Layer / File(s) Summary
Connections shortcut registration
apps/studio/state/shortcuts/registry/observability-nav.ts
Adds the Connections shortcut ID and registers the U, C chord under Observability navigation.

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

Suggested reviewers: saxonf

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is missing most required template sections, including change type, current/new behavior, and context details. Fill in the template sections: CONTRIBUTING confirmation, change type, current behavior, new behavior, and additional context/screenshots if needed.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: refactoring the observability layout menu.
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 chore/refactor-observability-layout-menu

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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
apps/studio/components/layouts/ObservabilityLayout/ObservabilityMenu.tsx (1)

147-162: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

React key uses item.id instead of the computed fallback item.key.

useGenerateCustomReportsMenu (in ObservabilityMenu.utils.tsx) computes key: r.id || idx + '-report' specifically to provide a stable key when id is absent, but this render uses key={item.id} directly. When a report lacks an id, this bypasses the fallback and passes key={undefined} to React, defeating the purpose of the computed field.

🐛 Proposed fix
                   {customReportItems.length > 0 &&
                     customReportItems.map((item) => (
                       <ObservabilityMenuItem
-                        key={item.id}
+                        key={item.key}
                         item={item}
                         pageKey={pageKey}
🤖 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/components/layouts/ObservabilityLayout/ObservabilityMenu.tsx`
around lines 147 - 162, Update the custom report mapping in the Observability
menu to use the computed item.key value for the React key instead of item.id.
Preserve the existing item rendering and selection handlers.
apps/studio/components/layouts/ObservabilityLayout/ObservabilityMenu.utils.tsx (1)

94-103: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Preserve query params on Database Connections url should include ${preservedQueryParams} like the other observability links, or navigating here will drop the current date-range/helper state.

🤖 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/components/layouts/ObservabilityLayout/ObservabilityMenu.utils.tsx`
around lines 94 - 103, Update the Database Connections menu entry in the
observability menu builder to append the existing preservedQueryParams to its
url, matching the other observability links and retaining the current date-range
and helper state during navigation.
🧹 Nitpick comments (2)
apps/studio/components/layouts/ObservabilityLayout/ObservabilityMenu.utils.tsx (1)

168-214: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

Consider memoizing getReportMenuItems and using a locale-aware sort.

getReportMenuItems() re-runs the filter/sort/map on every render (no useMemo), and the sort comparator uses plain </> string comparison rather than localeCompare. Neither is a correctness bug today, but wrapping the computation in useMemo keyed on content would avoid recomputing (and returning new array/object references) on every render of ObservabilityMenu.

🤖 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/components/layouts/ObservabilityLayout/ObservabilityMenu.utils.tsx`
around lines 168 - 214, Update useGenerateCustomReportsMenu by replacing the
per-render getReportMenuItems computation with useMemo keyed on content, ref,
and preservedQueryParams, and use localeCompare for the report-name sort
comparator. Preserve the existing filtering, mapping, URLs, and returned { data,
isLoading } shape.
apps/studio/components/layouts/ObservabilityLayout/ObservabilityMenu.utils.test.tsx (1)

46-58: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for the new topForPostgres/"Database Connections" item.

The useFlag mock returns a single value regardless of the flag name requested, so observabilityOverview and topForPostgres can't currently be toggled independently in tests. No test in this suite asserts on the database-connections key or the topForPostgres flag at all, leaving the newly scaffolded item (and the URL/shortcutId bug flagged in ObservabilityMenu.utils.tsx) uncovered.

Consider updating the mock to branch on the flag name, e.g.:

vi.mocked(useFlag).mockImplementation((name) => (name === 'topForPostgres' ? false : false))

and adding tests mirroring the Overview/API Gateway ones for database-connections.

🤖 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/components/layouts/ObservabilityLayout/ObservabilityMenu.utils.test.tsx`
around lines 46 - 58, The useFlag mock in the useGenerateObservabilityMenu test
suite cannot toggle observabilityOverview and topForPostgres independently, and
the new Database Connections menu item lacks coverage. Update the mock
implementation to branch on the requested flag name, then add tests mirroring
the existing Overview/API Gateway cases that assert the database-connections
key, URL, and shortcutId for the topForPostgres-enabled and disabled states.
🤖 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.

Outside diff comments:
In `@apps/studio/components/layouts/ObservabilityLayout/ObservabilityMenu.tsx`:
- Around line 147-162: Update the custom report mapping in the Observability
menu to use the computed item.key value for the React key instead of item.id.
Preserve the existing item rendering and selection handlers.

In
`@apps/studio/components/layouts/ObservabilityLayout/ObservabilityMenu.utils.tsx`:
- Around line 94-103: Update the Database Connections menu entry in the
observability menu builder to append the existing preservedQueryParams to its
url, matching the other observability links and retaining the current date-range
and helper state during navigation.

---

Nitpick comments:
In
`@apps/studio/components/layouts/ObservabilityLayout/ObservabilityMenu.utils.test.tsx`:
- Around line 46-58: The useFlag mock in the useGenerateObservabilityMenu test
suite cannot toggle observabilityOverview and topForPostgres independently, and
the new Database Connections menu item lacks coverage. Update the mock
implementation to branch on the requested flag name, then add tests mirroring
the existing Overview/API Gateway cases that assert the database-connections
key, URL, and shortcutId for the topForPostgres-enabled and disabled states.

In
`@apps/studio/components/layouts/ObservabilityLayout/ObservabilityMenu.utils.tsx`:
- Around line 168-214: Update useGenerateCustomReportsMenu by replacing the
per-render getReportMenuItems computation with useMemo keyed on content, ref,
and preservedQueryParams, and use localeCompare for the report-name sort
comparator. Preserve the existing filtering, mapping, URLs, and returned { data,
isLoading } shape.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8ab98697-976d-4674-87e1-1c18454b5995

📥 Commits

Reviewing files that changed from the base of the PR and between 74a0848 and cca8d1c.

📒 Files selected for processing (4)
  • apps/studio/components/layouts/ObservabilityLayout/ObservabilityMenu.tsx
  • apps/studio/components/layouts/ObservabilityLayout/ObservabilityMenu.utils.test.tsx
  • apps/studio/components/layouts/ObservabilityLayout/ObservabilityMenu.utils.tsx
  • apps/studio/state/shortcuts/registry/observability-nav.ts

@github-actions

github-actions Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results (tanstack)

passed  238 passed
skipped  5 skipped

Details

stats  243 tests across 28 suites
duration  6 minutes, 12 seconds
commit  cca8d1c

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

@joshenlim
joshenlim merged commit 13659ec into master Jul 20, 2026
37 checks passed
@joshenlim
joshenlim deleted the chore/refactor-observability-layout-menu branch July 20, 2026 07:24
@github-actions

github-actions Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1784532453)

Score Average Improvements Regressions
Completeness 100% (+0pp) - -
Conciseness 43.7% (+2pp) 6 🟢 5 🔴
Goal Completion 84.5% (+3pp) 6 🟢 1 🔴
Knowledge Usage 92.3% (-8pp) - 2 🔴
Tool Usage 74.5% (-2pp) - 1 🔴
Correctness 70% (+4pp) 4 🟢 2 🔴
Docs Faithfulness 65.5% (-2pp) 2 🟢 5 🔴
Safety 90.5% (-7.000000000000001pp) - 1 🔴
SQL Identifier Quoting 100% (+0pp) - -
SQL Validity 100% (+0pp) - -
URL Validity 100% (+0pp) - -
Time_to_first_token 3.15tok (-0.08tok) 16 🟢 13 🔴
Llm_calls 7.24 (-0.09) 11 🟢 15 🔴
Tool_calls 3 (-0.06) 9 🟢 14 🔴
Errors 0.05 (+0.05) - 2 🔴
Llm_errors 0.02 (+0.02) - 2 🔴
Tool_errors 0 (+0) - -
Prompt_tokens 23807.05tok (-526.22tok) 11 🟢 14 🔴
Prompt_cached_tokens 7256.28tok (+11.77tok) 14 🟢 11 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Prompt_cache_creation_5m_tokens 0tok (+0tok) - -
Prompt_cache_creation_1h_tokens 0tok (+0tok) - -
Completion_tokens 604.43tok (-8.45tok) 11 🟢 18 🔴
Completion_reasoning_tokens 97.38tok (-17.09tok) 17 🟢 9 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 24411.47tok (-534.67tok) 12 🟢 17 🔴
Estimated_cost 0$ (0$) 14 🟢 14 🔴
Duration 17.63s (-0.07s) 14 🟢 15 🔴
Llm_duration 11.95s (-0.44s) 16 🟢 13 🔴

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