Repository navigation
Chore/add sessions database connections - #48094
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
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds PostgreSQL activity querying and a Database Connections observability page with live refresh, URL-synced filters, session metadata, duration and blocking details, query inspection, and confirmed session termination. ChangesDatabase Connections Activity
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant DatabaseConnections
participant Activity
participant useDatabaseActivityQuery
participant PostgreSQL
DatabaseConnections->>Activity: pass live state
Activity->>useDatabaseActivityQuery: request activity and filters
useDatabaseActivityQuery->>PostgreSQL: query pg_stat_activity
PostgreSQL-->>Activity: return activity rows
Activity-->>DatabaseConnections: render sessions and controls
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 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.
Actionable comments posted: 4
🧹 Nitpick comments (1)
apps/studio/components/interfaces/Observability/DatabaseConnections/Activity.tsx (1)
147-151: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
getBadgeVarianthas no distinct styling for'idle in transaction (aborted)'.This state is arguably more severe than plain
'idle in transaction'(an aborted transaction still holding a lock), yet it falls through to the'default'variant.const getBadgeVariant = (state: DatabaseActivity['state']) => { if (state === 'active') return 'success' - if (state === 'idle in transaction') return 'warning' + if (state === 'idle in transaction' || state === 'idle in transaction (aborted)') return 'warning' return 'default' }🤖 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/interfaces/Observability/DatabaseConnections/Activity.tsx` around lines 147 - 151, Update getBadgeVariant to explicitly handle the 'idle in transaction (aborted)' state with a distinct, more severe badge variant than the warning used for 'idle in transaction', while preserving the existing mappings for active and other 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.
Inline comments:
In
`@apps/studio/components/interfaces/Observability/DatabaseConnections/Activity.tsx`:
- Around line 63-66: Rename the useQueryState key in the Activity component’s
stateFilter initialization from “functions” to “state” so the URL parameter
accurately represents the Sessions state filter. Preserve the existing
selectFilterSchema parsing and stateFilter behavior.
- Around line 141-172: Update onConfirmTerminate to remove the empty catch so
abortQuery’s rejection propagates and AlertDialogAction remains open on failure.
Use the query client to invalidate databaseKeys.databaseActivity(projectRef)
after successful termination, alongside the existing mutation behavior, so the
Sessions table refreshes when live updates are paused.
- Around line 41-53: Update getDuration to verify activity.state_change before
calculating idle duration and activity.transaction_start before calculating
idle-in-transaction duration. Return null when either timestamp is absent,
preserving the existing duration calculations for valid timestamps so the UI
displays the placeholder instead of NaNs.
In `@apps/studio/pages/project/`[ref]/observability/connections.tsx:
- Around line 49-53: Update the DatabaseConnections layout in
apps/studio/pages/project/[ref]/observability/connections.tsx:49-53 to use the
title “Database Connections”; update observabilityLayoutTitle in
apps/studio/routes/project/$ref/observability/connections.tsx:5-10 to the same
title; and remove the duplicated NAV_OBSERVABILITY_API_GATEWAY shortcutId from
the connections menu entry in
apps/studio/components/layouts/ObservabilityLayout/ObservabilityMenu.utils.tsx:94-102,
unless a dedicated connection shortcut already exists.
---
Nitpick comments:
In
`@apps/studio/components/interfaces/Observability/DatabaseConnections/Activity.tsx`:
- Around line 147-151: Update getBadgeVariant to explicitly handle the 'idle in
transaction (aborted)' state with a distinct, more severe badge variant than the
warning used for 'idle in transaction', while preserving the existing mappings
for active and other states.
🪄 Autofix (Beta)
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
Run ID: a3f41312-a744-4c96-b594-10518abce498
⛔ Files ignored due to path filters (1)
apps/studio/routeTree.gen.tsis excluded by!**/routeTree.gen.ts
📒 Files selected for processing (10)
apps/studio/components/interfaces/Observability/DatabaseConnections/Activity.tsxapps/studio/components/interfaces/QueryPerformance/QueryPerformance.utils.tsapps/studio/components/interfaces/Reports/v2/ReportsSelectFilter.tsxapps/studio/components/layouts/ObservabilityLayout/ObservabilityMenu.utils.tsxapps/studio/data/database/activity-query.tsapps/studio/data/database/keys.tsapps/studio/pages/project/[ref]/observability/connections.tsxapps/studio/routes/project/$ref/observability/connections.tsxpackages/pg-meta/src/sql/studio/database/activity.tspackages/pg-meta/src/sql/studio/database/index.ts
🎭 Playwright Test Results (next)Details
Flaky testsFeatures › database.spec.ts › Database › Schema Visualizer › table actions work as expected Skipped testsFeatures › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled |
kemaldotearth
left a comment
There was a problem hiding this comment.
Few nits I mentioned on Slack:
- Shall we match up the pause/play button to what we have on unified logs? Basically one pattern instead of two.
- Loading skeleton for the list. Maybe 3 dummy items at most.
- Should we use our syntax highlighting like in Query Performance for the query?
- Did we consciously remove the big metrics?
Otherwise looking fantastic and better terminology with "terminate" rather than "kill"!
…fomap-entry-for-pitr-archiving-stale' into hunleyd/indata-979-studio-lintinfomap-entry-for-pitr-archiving-stale * origin/hunleyd/indata-979-studio-lintinfomap-entry-for-pitr-archiving-stale: (35 commits) chore: simplify CPU messaging for compute sizes (#48109) chore(studio): add valtio and react-hook-form ESLint ratchet rules (#48037) feat: Add ai/python federated content and data (#48043) feat: Add ai-skills federated content and data (#48045) feat: Add deployment/ci federated content and data (#48041) fix(studio): wire up siwc-enabled query param opt-in on sign-in/sign-up (#48126) fix(studio): stop stacking overlaid area series in report charts (#48034) Update Dev toolbar to support filtering feature flags (#48137) Update dev toolbar to support mocking org restrictions (#48136) feat: Add terraform federated content and data (#48010) Chore/add sessions database connections (#48094) fix(studio): guard panel collapse/resize on narrow viewports (#48098) Landing page agent focus (#47989) fix(studio): chip away explicit-tabindex ratchet debt (#48040) fix(studio): untangle nested buttons in editor tabs (#48101) fix(docs): broken link (#48117) docs: add VS Code to the AI coding agent plugin install picker (#48108) docs: add Kimi Code to MCP and AI coding agent plugin setup (#48099) fix: preserve function responses (#47920) fix(assistant): SQL approval buttons do nothing (#48102) ...
Context
Initial work for Top for Postgres - adds a "Sessions" section under a new Observability segment "Database Connections"
NOTE: All the copywriting and naming might change - not sure what's an ideal title for this
We'll also be iteratively building on top of this UI, adding more actionable signals instead of just information
Changes are featured flagged, off for public
pg_stat_activityas per the ongoing queries UISummary by CodeRabbit
Release Notes
New Features
Enhancements