Skip to content

fix(PDiskSpaceDistribution): slot height calculation#3897

Open
Raubzeug wants to merge 1 commit into
mainfrom
semi-rigid
Open

fix(PDiskSpaceDistribution): slot height calculation#3897
Raubzeug wants to merge 1 commit into
mainfrom
semi-rigid

Conversation

@Raubzeug
Copy link
Copy Markdown
Contributor

@Raubzeug Raubzeug commented May 13, 2026

#3821

CI Results

Test Status: ⚠️ FLAKY

📊 Full Report

Total Passed Failed Flaky Skipped
646 642 0 1 3
Test Changes Summary 🗑️13

🗑️ Deleted Tests (13)

  1. renders the new storage layout in light theme (tenant/diagnostics/tabs/tenantOverviewStorage.test.ts)
  2. renders grouped summary sections for multiple storage types in light theme (tenant/diagnostics/tabs/tenantOverviewStorage.test.ts)
  3. renders the new storage layout in dark theme (tenant/diagnostics/tabs/tenantOverviewStorage.test.ts)
  4. renders grouped summary sections for multiple storage types in dark theme (tenant/diagnostics/tabs/tenantOverviewStorage.test.ts)
  5. shows quota missing helpmark for a single-media user data summary without quota (tenant/diagnostics/tabs/tenantOverviewStorage.test.ts)
  6. shows quota missing helpmark only for multi-media rows without quota (tenant/diagnostics/tabs/tenantOverviewStorage.test.ts)
  7. keeps legacy dedicated storage layout when experiment is disabled (tenant/diagnostics/tabs/tenantOverviewStorage.test.ts)
  8. highlights hovered storage segment and shows rich tooltip in light theme (tenant/diagnostics/tabs/tenantOverviewStorage.test.ts)
  9. shows tooltip on legend hover and clears state after click in light theme (tenant/diagnostics/tabs/tenantOverviewStorage.test.ts)
  10. highlights hovered storage segment and shows rich tooltip in dark theme (tenant/diagnostics/tabs/tenantOverviewStorage.test.ts)
  11. shows tooltip on legend hover and clears state after click in dark theme (tenant/diagnostics/tabs/tenantOverviewStorage.test.ts)
  12. keeps legacy dedicated storage layout when storage_stats capability is unavailable (tenant/diagnostics/tabs/tenantOverviewStorage.test.ts)
  13. keeps legacy serverless storage layout when experiment is enabled (tenant/diagnostics/tabs/tenantOverviewStorage.test.ts)

Bundle Size: ✅

Current: 63.76 MB | Main: 63.76 MB
Diff: +1.27 KB (0.00%)

✅ Bundle size unchanged.

ℹ️ CI Information
  • Test recordings for failed tests are available in the full report.
  • Bundle size is measured for the entire 'dist' directory.
  • 📊 indicates links to detailed reports.
  • 🔺 indicates increase, 🔽 decrease, and ✅ no change in bundle size.

Greptile Summary

This PR replaces the previous fixed-container-height + flexGrow approach for rendering PDisk slot bars with explicit per-slot pixel heights calculated proportionally relative to the smallest non-log slot capacity. Log slots are assigned a fixed half-height (20 px) while data and empty slots scale by (Total / minNonLogTotal) × 40 px.

  • Height calculation: minNonLogTotal is memoised across slot items; the outer container's hard-coded height/minHeight inline styles are removed in favour of height: auto on the bar class, letting the container grow naturally.
  • CSS adjustments: flex-grow: 1 is removed from __pdisk-bar, height: 100% is added to __slot so each DiskStateProgressBar fills its explicitly-sized wrapper, and the redundant .storage-disk-progress-bar { height: 100% } override is dropped.

Confidence Score: 4/5

Safe to merge for normal YDB deployments; one edge case with incomplete slot data could produce extreme heights but is unlikely in production.

The change is straightforward and well-scoped. For the typical case where all non-log slots have valid Total values the new proportional heights work correctly. The only concern is that a slot with a missing or zero Total forces minNonLogTotal down to 1, which would make other slots compute astronomically large pixel heights — a cap on slotHeight would close that gap without changing normal behaviour.

The height formula in PDiskSpaceDistribution.tsx around lines 200–204 is worth a second look for the missing-Total edge case.

Important Files Changed

Filename Overview
src/containers/PDiskPage/PDiskSpaceDistribution/PDiskSpaceDistribution.tsx Replaces fixed-container flexGrow approach with explicit proportional pixel heights per slot; adds minNonLogTotal memoization; log slots get a fixed half-height while others scale relative to the smallest non-log slot
src/containers/PDiskPage/PDiskSpaceDistribution/PDiskSpaceDistribution.scss Removes flex-grow from pdisk-bar, adds height: auto and height: 100% to slot, removes the .storage-disk-progress-bar height override — all consistent with the new explicit-height approach

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[SlotItems] --> B{Any non-log slots?}
    B -- No --> C[minNonLogTotal = 1]
    B -- Yes --> D[Find min Total among non-log slots]
    D --> E{All Totals undefined/zero?}
    E -- Yes --> C
    E -- No --> F[minNonLogTotal = smallest real Total]

    F --> G[For each Slot]
    C --> G

    G --> H{SlotType === 'log'?}
    H -- Yes --> I[height = BASE_SLOT_HEIGHT / 2 = 20px]
    H -- No --> J["height = (item.Total / minNonLogTotal) × 40px"]

    J --> K{item.Total undefined/zero?}
    K -- Yes --> L["effective Total = 1 → height = 1/minNonLogTotal × 40"]
    K -- No --> M[height proportional to capacity ratio]

    I --> N[Render slot-wrapper with explicit height]
    L --> N
    M --> N
Loading

Fix All in Codex Fix All in Claude Code

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
src/containers/PDiskPage/PDiskSpaceDistribution/PDiskSpaceDistribution.tsx:200-204
When `item.Total` is `undefined`, `null`, or `0` for any non-log slot, `Number(item.Total) || 1` normalises it to `1`. That `1` then wins the `minNonLogTotal` search, so every other slot with a real capacity — say 100 GB = `107_374_182_400` — computes a height of `(107_374_182_400 / 1) × 40 ≈ 4.3 × 10¹²px`, effectively freezing the page. Adding a `Math.min` cap (e.g. `10 × BASE_SLOT_HEIGHT`) keeps the layout sensible even when data is incomplete.

```suggestion
    // Log slots get half the base height; others scale proportionally to the smallest non-log slot
    const slotHeight =
        item.SlotType === 'log'
            ? BASE_SLOT_HEIGHT / 2
            : Math.min(
                  ((Number(item.Total) || 1) / minNonLogTotal) * BASE_SLOT_HEIGHT,
                  10 * BASE_SLOT_HEIGHT,
              );
```

Reviews (1): Last reviewed commit: "fix(PDiskSpaceDistribution): slot height..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

@Raubzeug Raubzeug marked this pull request as ready for review May 14, 2026 04:58
Copilot AI review requested due to automatic review settings May 14, 2026 04:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts PDisk space distribution rendering so slot rows use explicit heights based on slot size, with log slots rendered smaller than regular slots.

Changes:

  • Replaces the fixed container-height/flex-grow layout with per-slot height calculation.
  • Computes the smallest non-log slot total as the scaling baseline.
  • Updates PDisk space distribution styles to support auto-height layout and full-height slot bars.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/containers/PDiskPage/PDiskSpaceDistribution/PDiskSpaceDistribution.tsx Adds slot height scaling logic and passes the computed baseline into each slot.
src/containers/PDiskPage/PDiskSpaceDistribution/PDiskSpaceDistribution.scss Adjusts layout styles for the new explicit slot-height rendering.

Comment on lines +200 to +204
// Log slots get half the base height; others scale proportionally to the smallest non-log slot
const slotHeight =
item.SlotType === 'log'
? BASE_SLOT_HEIGHT / 2
: ((Number(item.Total) || 1) / minNonLogTotal) * BASE_SLOT_HEIGHT;
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.

P2 When item.Total is undefined, null, or 0 for any non-log slot, Number(item.Total) || 1 normalises it to 1. That 1 then wins the minNonLogTotal search, so every other slot with a real capacity — say 100 GB = 107_374_182_400 — computes a height of (107_374_182_400 / 1) × 40 ≈ 4.3 × 10¹²px, effectively freezing the page. Adding a Math.min cap (e.g. 10 × BASE_SLOT_HEIGHT) keeps the layout sensible even when data is incomplete.

Suggested change
// Log slots get half the base height; others scale proportionally to the smallest non-log slot
const slotHeight =
item.SlotType === 'log'
? BASE_SLOT_HEIGHT / 2
: ((Number(item.Total) || 1) / minNonLogTotal) * BASE_SLOT_HEIGHT;
// Log slots get half the base height; others scale proportionally to the smallest non-log slot
const slotHeight =
item.SlotType === 'log'
? BASE_SLOT_HEIGHT / 2
: Math.min(
((Number(item.Total) || 1) / minNonLogTotal) * BASE_SLOT_HEIGHT,
10 * BASE_SLOT_HEIGHT,
);
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/containers/PDiskPage/PDiskSpaceDistribution/PDiskSpaceDistribution.tsx
Line: 200-204

Comment:
When `item.Total` is `undefined`, `null`, or `0` for any non-log slot, `Number(item.Total) || 1` normalises it to `1`. That `1` then wins the `minNonLogTotal` search, so every other slot with a real capacity — say 100 GB = `107_374_182_400` — computes a height of `(107_374_182_400 / 1) × 40 ≈ 4.3 × 10¹²px`, effectively freezing the page. Adding a `Math.min` cap (e.g. `10 × BASE_SLOT_HEIGHT`) keeps the layout sensible even when data is incomplete.

```suggestion
    // Log slots get half the base height; others scale proportionally to the smallest non-log slot
    const slotHeight =
        item.SlotType === 'log'
            ? BASE_SLOT_HEIGHT / 2
            : Math.min(
                  ((Number(item.Total) || 1) / minNonLogTotal) * BASE_SLOT_HEIGHT,
                  10 * BASE_SLOT_HEIGHT,
              );
```

How can I resolve this? If you propose a fix, please make it concise.

Fix in Codex Fix in Claude Code

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6c578b476f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

if (item.SlotType === 'log') {
continue;
}
const value = Number(item.Total) || 1;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Prevent invalid totals from becoming a 1-byte baseline

When any non-log slot has a missing, zero, or NaN Total, this fallback makes minNonLogTotal equal to 1. The new height calculation then divides real byte-sized slots by that value, so a normal 20 GB empty slot renders as about 800,000,000,000 px tall. This can happen with partial/older VDisk data where SizeLimit is unavailable while ExpectedSlotCount still creates empty slots; the previous flex layout kept the total bar height bounded, but these fixed pixel heights can make the PDisk page unusable.

Useful? React with 👍 / 👎.

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