Repository navigation
Chore/refactor observability layout menu - #48089
Conversation
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
5 Skipped Deployments
|
📝 WalkthroughWalkthroughObservability 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. ChangesObservability menu generation
Observability Connections shortcut
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
There was a problem hiding this comment.
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 winReact
keyusesitem.idinstead of the computed fallbackitem.key.
useGenerateCustomReportsMenu(inObservabilityMenu.utils.tsx) computeskey: r.id || idx + '-report'specifically to provide a stable key whenidis absent, but this render useskey={item.id}directly. When a report lacks anid, this bypasses the fallback and passeskey={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 winPreserve query params on Database Connections
urlshould 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 valueConsider memoizing
getReportMenuItemsand using a locale-aware sort.
getReportMenuItems()re-runs the filter/sort/map on every render (nouseMemo), and the sort comparator uses plain</>string comparison rather thanlocaleCompare. Neither is a correctness bug today, but wrapping the computation inuseMemokeyed oncontentwould avoid recomputing (and returning new array/object references) on every render ofObservabilityMenu.🤖 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 winAdd coverage for the new
topForPostgres/"Database Connections" item.The
useFlagmock returns a single value regardless of the flag name requested, soobservabilityOverviewandtopForPostgrescan't currently be toggled independently in tests. No test in this suite asserts on thedatabase-connectionskey or thetopForPostgresflag at all, leaving the newly scaffolded item (and the URL/shortcutId bug flagged inObservabilityMenu.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
📒 Files selected for processing (4)
apps/studio/components/layouts/ObservabilityLayout/ObservabilityMenu.tsxapps/studio/components/layouts/ObservabilityLayout/ObservabilityMenu.utils.test.tsxapps/studio/components/layouts/ObservabilityLayout/ObservabilityMenu.utils.tsxapps/studio/state/shortcuts/registry/observability-nav.ts
🎭 Playwright Test Results (tanstack)Details
Skipped testsFeatures › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled |
Braintrust eval report
|
Context
Just refactors
ObservabilityMenuto retrieve the menu items via a hook + scaffold the Top for Postgres menu itemNo functional changes here
Summary by CodeRabbit
U, thenC) for quickly opening Observability Connections.