Skip to content

Add top blocker overview card - #48290

Merged
joshenlim merged 2 commits into
masterfrom
joshen/fe-3998-add-top-blocker-overview-card
Jul 27, 2026
Merged

Add top blocker overview card#48290
joshenlim merged 2 commits into
masterfrom
joshen/fe-3998-add-top-blocker-overview-card

Conversation

@joshenlim

@joshenlim joshenlim commented Jul 24, 2026

Copy link
Copy Markdown
Member

Context

Adds a "Top blocker" overview card for Database Connections
This should provide a better signal if there's any process that's behaving as a bottleneck for multiple blocked queries
image

^ We only highlight the card in red if the query is blocking more than 3 other queries to account - otherwise the signal might be too noisy

image

Other changes involved

  • Am swapping the card positions around a little
  • Longest running query card shows the PID as the primary information, followed by the duration of the run

Summary by CodeRabbit

  • New Features
    • Added a Top blocker metric to the Database Connections Overview to highlight the PID/account blocking the most other queries.
    • Warning styling now appears when a query blocks more than 3 other queries.
    • Reorganized the metrics layout and ordering for improved visibility (active, idle-in-transaction, blocked, top blocker, and longest running).
  • Bug Fixes
    • Updated tooltip and guidance text for clearer explanations of blocked and idle-in-transaction states.

@joshenlim
joshenlim requested a review from a team as a code owner July 24, 2026 09:52
@vercel

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

Request Review

@supabase

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

@coderabbitai

coderabbitai Bot commented Jul 24, 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: 6d7abd54-098d-4caa-a1bc-1eae1ba00501

📥 Commits

Reviewing files that changed from the base of the PR and between 4fc8a39 and 7fae3e3.

📒 Files selected for processing (1)
  • apps/studio/components/interfaces/Observability/DatabaseConnections/Overview.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/studio/components/interfaces/Observability/DatabaseConnections/Overview.tsx

📝 Walkthrough

Walkthrough

The Database Connections Overview now identifies the query blocking the most other queries, applies a warning threshold, and displays it in a reorganized metric-card layout with updated query metrics.

Changes

Database connection metrics

Layer / File(s) Summary
Top-blocker threshold and detection
apps/studio/components/interfaces/Observability/DatabaseConnections/DatabaseConnections.constants.ts, apps/studio/components/interfaces/Observability/DatabaseConnections/Overview.tsx
Adds WARN_TOP_BLOCKER and computes per-PID blocked-query counts to identify the top blocker.
Metric card layout and rendering
apps/studio/components/interfaces/Observability/DatabaseConnections/Overview.tsx
Adds the Top blocker card, updates metric ordering and responsive layout, and revises active, idle, blocked, and longest-running card presentation.

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

Possibly related PRs

Suggested reviewers: alaister

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description lacks the required template sections for CONTRIBUTING, change type, current behavior, new behavior, and additional context/issues. Restructure the PR description to match the template and fill in the missing sections, including YES/NO, change type, current behavior, and new behavior.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: adding a top blocker overview card.
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 joshen/fe-3998-add-top-blocker-overview-card

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

🧹 Nitpick comments (1)
apps/studio/components/interfaces/Observability/DatabaseConnections/Overview.tsx (1)

215-323: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate clickable-PID structure between "Top blocker" and "Longest running" cards.

Both cards repeat the same role="button"/tabIndex/onClick/onKeyDown pattern for making a PID clickable (lines 240-253 and 297-310), differing only in the trailing label text. Consider extracting a small shared sub-component (e.g., ClickablePid) co-located with Overview.tsx to avoid this duplication and centralize the keyboard-activation logic.

♻️ Example extraction
const ClickablePid = ({ pid, onSelect }: { pid: number; onSelect: (pid: number) => void }) => (
  <span
    role="button"
    tabIndex={0}
    className="normal-nums cursor-pointer hover:underline"
    onClick={() => onSelect(pid)}
    onKeyDown={(e) => {
      if (e.key === 'Enter' || e.key === ' ') {
        e.preventDefault()
        onSelect(pid)
      }
    }}
  >
    PID: {pid}
  </span>
)
🤖 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/Overview.tsx`
around lines 215 - 323, Extract the duplicated clickable PID markup from the
“Top blocker” and “Longest running” cards into a shared ClickablePid component
near Overview. Move the role, tabIndex, styling, click handler, and Enter/Space
keyboard activation into that component, accepting pid and selection callback
props, then replace both inline spans while preserving their existing
surrounding labels.
🤖 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/Overview.tsx`:
- Around line 68-83: Update the warnTopBlocker threshold in the query-blocker
calculation to use a strict comparison, so the warning and downstream Top
blocker styling activate only when the blocker count exceeds WARN_TOP_BLOCKER;
preserve the existing count fallback and threshold symbol.

---

Nitpick comments:
In
`@apps/studio/components/interfaces/Observability/DatabaseConnections/Overview.tsx`:
- Around line 215-323: Extract the duplicated clickable PID markup from the “Top
blocker” and “Longest running” cards into a shared ClickablePid component near
Overview. Move the role, tabIndex, styling, click handler, and Enter/Space
keyboard activation into that component, accepting pid and selection callback
props, then replace both inline spans while preserving their existing
surrounding labels.
🪄 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 Plus

Run ID: dff9d3c4-c929-4bcf-913a-b72cc9ee7db2

📥 Commits

Reviewing files that changed from the base of the PR and between cea246d and 4fc8a39.

📒 Files selected for processing (2)
  • apps/studio/components/interfaces/Observability/DatabaseConnections/DatabaseConnections.constants.ts
  • apps/studio/components/interfaces/Observability/DatabaseConnections/Overview.tsx

@github-actions

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results (next)

passed  243 passed
skipped  5 skipped

Details

stats  248 tests across 29 suites
duration  4 minutes, 12 seconds
commit  7fae3e3

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

Comment on lines +159 to +169
tooltip={
<>
<p>
Transactions left open without running a query, which can hold locks and block
table cleanup for as long as it stays open
</p>
<p className="mt-2">
Typically indicates an app issue, such as a forgotten COMMIT or ROLLBACK.
</p>
</>
}

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.

Not specific to your PR but I noticed the tooltip trigger isn't accessible: you can't tab to it.

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 good catch! this needs fixing at the UI component level in ui-patterns - will look into this separately 🙏

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.

got a fix here 🙂
#48294

<span
role="button"
tabIndex={0}
className="normal-nums cursor-pointer hover:underline"

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.

Not specific to your PR either but we should also add classes for the focus state

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.

gotcha! i'll fix this one separately 🙂 🙏

@joshenlim
joshenlim merged commit fb7debe into master Jul 27, 2026
37 checks passed
@joshenlim
joshenlim deleted the joshen/fe-3998-add-top-blocker-overview-card branch July 27, 2026 03:09
@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1785121946)

Score Average Improvements Regressions
Completeness 98.9% (-1pp) - 1 🔴
Conciseness 38.5% (-6pp) 4 🟢 10 🔴
Correctness 66.7% (-2pp) 2 🟢 3 🔴
Docs Faithfulness 66.7% (+3pp) 4 🟢 4 🔴
Goal Completion 82.8% (-1pp) 3 🟢 4 🔴
Knowledge Usage 97.4% (-3pp) - 1 🔴
SQL Identifier Quoting 100% (+0pp) - -
SQL Validity 95.5% (-5pp) - 1 🔴
Safety 81% (-19pp) - 3 🔴
Tool Usage 71.9% (-5pp) - 3 🔴
URL Validity 100% (+0pp) - -
Time_to_first_token 3.19tok (-0.11tok) 16 🟢 13 🔴
Llm_calls 7.55 (-0.02) 13 🟢 11 🔴
Tool_calls 3.07 (-0.08) 9 🟢 12 🔴
Errors 0.05 (+0.05) - 2 🔴
Llm_errors 0.02 (+0.02) - 2 🔴
Tool_errors 0 (+0) - -
Prompt_tokens 24290.64tok (+70.6tok) 14 🟢 12 🔴
Prompt_cached_tokens 7638.8tok (+470.8tok) 16 🟢 10 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Prompt_cache_creation_5m_tokens 0tok (+0tok) - -
Prompt_cache_creation_1h_tokens 0tok (+0tok) - -
Completion_tokens 605.11tok (-68.46tok) 16 🟢 13 🔴
Completion_reasoning_tokens 91.95tok (-16.29tok) 14 🟢 13 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 24895.76tok (+2.14tok) 15 🟢 14 🔴
Estimated_cost 0$ (0$) 16 🟢 13 🔴
Duration 19.61s (+0.17s) 12 🟢 17 🔴
Llm_duration 12s (-0.9s) 17 🟢 12 🔴

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