Skip to content

feat: align reviews drill-down UI and use corrected sizes#152

Merged
coji merged 2 commits intomainfrom
feat/align-reviews-drill-down-ui
Mar 11, 2026
Merged

feat: align reviews drill-down UI and use corrected sizes#152
coji merged 2 commits intomainfrom
feat/align-reviews-drill-down-ui

Conversation

@coji
Copy link
Owner

@coji coji commented Mar 11, 2026

Summary

  • Reviews ページのドリルダウンシートの表示を dashboard/ongoing と統一(SizeBadge、リスクエリアバッジ)
  • PR サイズ集計で人が補正したサイズ(correctedComplexity)を優先使用するよう変更
  • PR 件数の 3 桁カンマ区切り、セレクト高さの統一

Changes

  • pr-drill-down-sheet.tsx: グレーの pill → SizeBadge コンポーネント、riskAreas をバッジ表示
  • pr-size-chart.tsx: ドリルダウンのサブタイトルに SizeBadge 追加、件数に toLocaleString()
  • classify.ts: getPRComplexitycorrectedComplexity を優先するよう変更
  • queries.server.ts: getWipCycleRawData / getPRSizeDistributionpullRequestFeedbacks LEFT JOIN 追加
  • team-filter.tsx: SelectTrigger の高さをデフォルト(h-9)に統一

Test plan

  • pnpm validate passes
  • Reviews ページでドリルダウンシートを開き、サイズバッジとリスクエリアバッジが表示されることを確認
  • サイズ補正済みの PR が補正後のサイズで集計されていることを確認

🤖 Generated with Claude Code

coji and others added 2 commits March 11, 2026 15:22
- Use SizeBadge component for colored size labels (was grey bg-muted pill)
- Display risk areas as outline badges (was plain text)
- Show SizeBadge in sheet description subtitle
- Format PR count with locale comma separators
- Unify SelectTrigger height to default across period and team filters

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- LEFT JOIN pull_request_feedbacks in reviews queries (WIP cycle, PR size)
- Update getPRComplexity to prefer correctedComplexity over LLM complexity
- Add correctedComplexity to WipRawRow and PRSizeRawRow types
- Format PR count with locale comma separator in drill-down description

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Mar 11, 2026

📝 Walkthrough

Walkthrough

This change introduces support for corrected PR size classification, enabling users to provide feedback that overrides automated complexity categorization. The feature adds a correctedComplexity field throughout the data pipeline, from database queries through classification logic to UI display with new badge components and improved formatting.

Changes

Cohort / File(s) Summary
UI Component Styling
app/components/team-filter.tsx
Removed fixed height utility class from SelectTrigger element, preserving width styling.
PR Drill-Down & Risk Area Display
app/routes/$orgSlug/reviews/+components/pr-drill-down-sheet.tsx
Added Badge and SizeBadge component imports; introduced parseRiskAreas() helper to normalize risk area data from multiple formats; updated description prop type from string to React.ReactNode; replaced inline size rendering with SizeBadge component; added flexible risk areas badge display when data exists.
PR Size Chart Display
app/routes/$orgSlug/reviews/+components/pr-size-chart.tsx
Added SizeBadge import; enhanced PRDrillDownSheet description to display formatted count with toLocaleString() and paired SizeBadge component instead of plain string.
Data Model Definitions
app/routes/$orgSlug/reviews/+functions/aggregate.ts
Added correctedComplexity: string | null field to WipRawRow and PRSizeRawRow interfaces, enabling optional complexity overrides at the data layer.
Test Data Builders
app/routes/$orgSlug/reviews/+functions/aggregate.test.ts
Updated wipRow and sizeRow test builders to accept and return correctedComplexity: string | null in their overrides and returned objects, maintaining test data consistency.
Classification & Sorting Logic
app/routes/$orgSlug/reviews/+functions/classify.ts
Updated getPRComplexity() to accept optional correctedComplexity parameter and prioritize it over complexity; added new complexitySortingFn() export for sorting items by corrected or standard complexity using PR_SIZE_RANK.
Database Query Layer
app/routes/$orgSlug/reviews/+functions/queries.server.ts
Added left joins to pullRequestFeedbacks table in getWipCycleRawData() and getPRSizeDistribution(), selecting correctedComplexity field alongside existing PR metrics.
Feature Documentation
docs/pr-size-classification-guide.md
New comprehensive guide explaining PR size classification purpose, human feedback loop mechanics, tier definitions (XS–XL) with examples, decision flow, common LLM error scenarios, dashboard feedback instructions, and future automation improvements.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 A hop through the feedback, so clever and keen,
Where users correct what the LLM's seen,
From database deep to the badges so bright,
Complexity ranked with corrected insight! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the main changes: aligning the reviews drill-down UI and incorporating corrected PR sizes, which are the primary objectives throughout the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/align-reviews-drill-down-ui

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 and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

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

⚠️ Outside diff range comments (1)
app/routes/$orgSlug/reviews/+functions/classify.ts (1)

49-67: ⚠️ Potential issue | 🟡 Minor

Validate the corrected label before overriding the original one.

Right now any non-null correctedComplexity wins, even if it is not one of the supported size labels. Because this value is stored as free text, a bad/stale correction would downgrade an otherwise valid complexity to Unclassified here and in complexitySortingFn.

🐛 Suggested fix
+function toValidSizeLabel(
+  value: string | null | undefined,
+): PRSizeLabel | null {
+  return value != null && (PR_SIZE_LABELS as readonly string[]).includes(value)
+    ? (value as PRSizeLabel)
+    : null
+}
+
 /** 補正済みサイズ → LLM分類 → Unclassified の優先順で返す */
 export function getPRComplexity(pr: {
   complexity: string | null
   correctedComplexity?: string | null
 }): PRSizeLabel {
-  const value = pr.correctedComplexity ?? pr.complexity
-  if (value != null && (PR_SIZE_LABELS as readonly string[]).includes(value)) {
-    return value as PRSizeLabel
-  }
-  return 'Unclassified'
+  return (
+    toValidSizeLabel(pr.correctedComplexity) ??
+    toValidSizeLabel(pr.complexity) ??
+    'Unclassified'
+  )
 }
 
 /** correctedComplexity ?? complexity でソートする関数 */
 export function complexitySortingFn<
   T extends { correctedComplexity: string | null; complexity: string | null },
 >(a: { original: T }, b: { original: T }): number {
-  const aVal = a.original.correctedComplexity ?? a.original.complexity ?? ''
-  const bVal = b.original.correctedComplexity ?? b.original.complexity ?? ''
+  const aVal =
+    toValidSizeLabel(a.original.correctedComplexity) ??
+    toValidSizeLabel(a.original.complexity) ??
+    'Unclassified'
+  const bVal =
+    toValidSizeLabel(b.original.correctedComplexity) ??
+    toValidSizeLabel(b.original.complexity) ??
+    'Unclassified'
   return (PR_SIZE_RANK[aVal] ?? 5) - (PR_SIZE_RANK[bVal] ?? 5)
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/routes/`$orgSlug/reviews/+functions/classify.ts around lines 49 - 67,
getPRComplexity and complexitySortingFn currently unconditionally prefer
correctedComplexity even if it contains free-text that isn't in PR_SIZE_LABELS;
update both to validate correctedComplexity against PR_SIZE_LABELS (and coerce
to PRSizeLabel) before using it, falling back to complexity if
correctedComplexity is invalid or null, and ensure complexitySortingFn computes
aVal/bVal from the validated label values so PR_SIZE_RANK lookups only receive
known keys (use PR_SIZE_LABELS and PR_SIZE_RANK in the validation).
🧹 Nitpick comments (3)
app/routes/$orgSlug/reviews/+components/pr-size-chart.tsx (1)

30-30: Use the app alias for this new cross-folder import.

Please switch this to the ~/ form instead of ../../... so the new import follows the repo rule and stays stable if this folder moves.

♻️ Suggested change
-import { SizeBadge } from '../../+components/size-badge'
+import { SizeBadge } from '~/app/routes/$orgSlug/+components/size-badge'

As per coding guidelines, "Use path aliases with ~/ prefix for imports from the app/ directory".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/routes/`$orgSlug/reviews/+components/pr-size-chart.tsx at line 30, The
import for SizeBadge in pr-size-chart.tsx uses a relative path; change the
import to use the app alias (~/) so it reads from the app root instead of
'../../+components/size-badge' — update the import that references SizeBadge to
use '~/routes/$orgSlug/reviews/+components/size-badge' (or the appropriate path
under the app alias) so the module resolution stays stable if the file is moved.
app/routes/$orgSlug/reviews/+components/pr-drill-down-sheet.tsx (1)

11-11: Use the app alias for this new import as well.

This new cross-folder import should use the ~/ form instead of ../../... to stay aligned with the repo convention.

♻️ Suggested change
-import { SizeBadge } from '../../+components/size-badge'
+import { SizeBadge } from '~/app/routes/$orgSlug/+components/size-badge'

As per coding guidelines, "Use path aliases with ~/ prefix for imports from the app/ directory".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/routes/`$orgSlug/reviews/+components/pr-drill-down-sheet.tsx at line 11,
The import in pr-drill-down-sheet.tsx uses a relative path for SizeBadge; update
the import to use the app alias (~/) instead of '../../+components/size-badge'
so it follows the repo convention; locate the import statement for SizeBadge in
the file and change it to the `~/` prefixed path referencing the same
+components/size-badge module.
app/routes/$orgSlug/reviews/+functions/aggregate.test.ts (1)

63-78: Add a regression test for corrected-size precedence.

Now that sizeRow carries correctedComplexity, please add one aggregatePRSize case where complexity and correctedComplexity disagree and assert that the corrected bucket wins. That is the main behavior change in this PR.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/routes/`$orgSlug/reviews/+functions/aggregate.test.ts around lines 63 -
78, Add a regression test in
app/routes/$orgSlug/reviews/+functions/aggregate.test.ts that ensures
correctedComplexity takes precedence: create an aggregatePRSize test case where
the input sizeRow (constructed by the existing helper used in the file) has
complexity set to one bucket and correctedComplexity set to a different bucket,
call aggregatePRSize with that row, and assert the returned size bucket equals
the correctedComplexity value (not complexity); reference the aggregatePRSize
function and the correctedComplexity and complexity properties on the sizeRow
when adding the case.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/pr-size-classification-guide.md`:
- Around line 27-37: The fenced code blocks containing the ASCII diagram (the
block starting with "┌─────────────┐    ┌──────────────┐    ┌─────────────────┐"
and the other similar block later in the file) are missing a language tag and
trigger MD040; add a language specifier of text to each fenced block (change ```
to ```text) for both the diagram shown and the other fenced block around lines
64-78 so the markdown linter stops warning.

---

Outside diff comments:
In `@app/routes/`$orgSlug/reviews/+functions/classify.ts:
- Around line 49-67: getPRComplexity and complexitySortingFn currently
unconditionally prefer correctedComplexity even if it contains free-text that
isn't in PR_SIZE_LABELS; update both to validate correctedComplexity against
PR_SIZE_LABELS (and coerce to PRSizeLabel) before using it, falling back to
complexity if correctedComplexity is invalid or null, and ensure
complexitySortingFn computes aVal/bVal from the validated label values so
PR_SIZE_RANK lookups only receive known keys (use PR_SIZE_LABELS and
PR_SIZE_RANK in the validation).

---

Nitpick comments:
In `@app/routes/`$orgSlug/reviews/+components/pr-drill-down-sheet.tsx:
- Line 11: The import in pr-drill-down-sheet.tsx uses a relative path for
SizeBadge; update the import to use the app alias (~/) instead of
'../../+components/size-badge' so it follows the repo convention; locate the
import statement for SizeBadge in the file and change it to the `~/` prefixed
path referencing the same +components/size-badge module.

In `@app/routes/`$orgSlug/reviews/+components/pr-size-chart.tsx:
- Line 30: The import for SizeBadge in pr-size-chart.tsx uses a relative path;
change the import to use the app alias (~/) so it reads from the app root
instead of '../../+components/size-badge' — update the import that references
SizeBadge to use '~/routes/$orgSlug/reviews/+components/size-badge' (or the
appropriate path under the app alias) so the module resolution stays stable if
the file is moved.

In `@app/routes/`$orgSlug/reviews/+functions/aggregate.test.ts:
- Around line 63-78: Add a regression test in
app/routes/$orgSlug/reviews/+functions/aggregate.test.ts that ensures
correctedComplexity takes precedence: create an aggregatePRSize test case where
the input sizeRow (constructed by the existing helper used in the file) has
complexity set to one bucket and correctedComplexity set to a different bucket,
call aggregatePRSize with that row, and assert the returned size bucket equals
the correctedComplexity value (not complexity); reference the aggregatePRSize
function and the correctedComplexity and complexity properties on the sizeRow
when adding the case.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0159322f-6119-4fef-9bc6-b36a9329c0b6

📥 Commits

Reviewing files that changed from the base of the PR and between 967d86d and 9657fa8.

📒 Files selected for processing (8)
  • app/components/team-filter.tsx
  • app/routes/$orgSlug/reviews/+components/pr-drill-down-sheet.tsx
  • app/routes/$orgSlug/reviews/+components/pr-size-chart.tsx
  • app/routes/$orgSlug/reviews/+functions/aggregate.test.ts
  • app/routes/$orgSlug/reviews/+functions/aggregate.ts
  • app/routes/$orgSlug/reviews/+functions/classify.ts
  • app/routes/$orgSlug/reviews/+functions/queries.server.ts
  • docs/pr-size-classification-guide.md

Comment on lines +27 to +37
```
┌─────────────┐ ┌──────────────┐ ┌─────────────────┐
│ LLM が分類 │ → │ 人間が補正 │ → │ 補正データ蓄積 │
│ (自動) │ │ (ダッシュボード) │ │ (フィードバック) │
└─────────────┘ └──────────────┘ └────────┬────────┘
┌──────────────┐ │
│ 分類精度向上 │ ←────────────┘
│ (プロンプト改善) │
└──────────────┘
```
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Add a language to both fenced blocks.

These examples currently trigger MD040. Using text for both blocks is enough to clear the warning and keep the docs lint-clean.

Also applies to: 64-78

🧰 Tools
🪛 markdownlint-cli2 (0.21.0)

[warning] 27-27: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/pr-size-classification-guide.md` around lines 27 - 37, The fenced code
blocks containing the ASCII diagram (the block starting with "┌─────────────┐   
┌──────────────┐    ┌─────────────────┐" and the other similar block later in
the file) are missing a language tag and trigger MD040; add a language specifier
of text to each fenced block (change ``` to ```text) for both the diagram shown
and the other fenced block around lines 64-78 so the markdown linter stops
warning.

@coji coji merged commit 98cf8a0 into main Mar 11, 2026
6 checks passed
@coji coji deleted the feat/align-reviews-drill-down-ui branch March 11, 2026 06:57
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.

1 participant