Skip to content

fix(data-table): prevent component cell clipping - #5536

Merged
t0ng7u merged 1 commit into
mainfrom
fix/data-table-component-cells
Jun 17, 2026
Merged

t0ng7u merged 1 commit into
mainfrom
fix/data-table-component-cells

Conversation

@QuentinHsu

@QuentinHsu QuentinHsu commented Jun 16, 2026 •

Copy link
Copy Markdown
Collaborator

⚠️ 提交说明 / PR Notice

Important

  • 请提供人工撰写的简洁摘要,避免直接粘贴未经整理的 AI 输出。

📝 变更描述 / Description

(简述:做了什么?为什么这样改能生效?请基于你对代码逻辑的理解来写,避免粘贴未经整理的内容)
修复表格中非纯文本组件内容被外层裁剪或溢出到相邻列的问题。表格层现在只对纯文本单元格应用省略和 tooltip 逻辑;组件型单元格由组件自身决定显示策略。同时调整表格宽度计算,使内容可撑开表格并通过横向滚动承载,避免长模型名称与后续列重叠。模型徽章现在完整单行显示模型名称。

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix) - 请关联对应 Issue,避免将设计取舍、理解偏差或预期不一致直接归类为 bug
  • ✨ 新功能 (New feature) - 重大特性建议先通过 Issue 沟通
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

  • Closes # (如有)

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 Issues 与 PRs,确认不是重复提交。
  • Bug fix 说明: 若此 PR 标记为 Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • 本地验证: 已在本地运行并通过测试或手动验证,维护者可以据此复核结果。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

(请在此粘贴截图、关键日志或测试报告,以证明变更生效)
CleanShot 2026-06-16 at 17 25 07

Summary by CodeRabbit

  • Style
    • Improved data table cell rendering with better overflow handling for text content
    • Enhanced table layout sizing for improved responsiveness and content visibility
    • Refined model badge display to prevent unwanted text truncation

- apply table-level truncation only to primitive text cells.
- let tables expand to content width with horizontal scrolling to avoid column overlap.
- update model badges to show full model names on one line.
@coderabbitai

coderabbitai Bot commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The data table is updated to use auto table layout with max-content width and a CSS max() minWidth expression. Cell rendering is refactored to return an isPrimitive flag alongside content, conditionally applying overflow-hidden only on text-like cells. ModelBadge switches from truncating to whitespace-nowrap display for model names.

Changes

Data Table Cell Overflow and Sizing

Layer / File(s) Summary
Table sizing: auto layout with max-content width
web/default/src/components/data-table/core/table-sizing.ts
getTableSizeStyle changes tableLayout to 'auto', sets width to 'max-content', and updates minWidth to max(100%, ${width}px).
Cell rendering: isPrimitive flag and conditional overflow-hidden
web/default/src/components/data-table/core/data-table-row.tsx
renderCellContent returns { content, isPrimitive } instead of a raw node; DataTableRowInner uses isPrimitive to conditionally apply overflow-hidden only to primitive/text cells.
ModelBadge: remove truncation, use whitespace-nowrap
web/default/src/features/usage-logs/components/model-badge.tsx
ModelBadgeContent switches StatusBadge className from max-w-full/min-w-0 to max-w-none and changes model name display from truncate to whitespace-nowrap.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • QuantumNous/new-api#5510: Modifies the same data-table-row.tsx file with overlapping changes to renderCellContent primitive detection and TruncatedCell wrapping logic.

Poem

🐇 A table once clipped every cell with a shear,
Now only plain text gets the overflow snipped here.
The width goes max-content, no fixed layout in sight,
And badges no longer truncate — what a delight!
The rabbit hops proudly through columns so neat. 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(data-table): prevent component cell clipping' accurately summarizes the main issue being addressed—preventing cell content clipping in data tables by applying truncation selectively to primitive text cells and adjusting table layout.
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.

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

✨ 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 fix/data-table-component-cells

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.

@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.

🧹 Nitpick comments (2)
web/default/src/components/data-table/core/data-table-row.tsx (2)

104-118: 💤 Low value

Consider adding an explicit return type for better type safety and documentation.

The inferred return type of renderCellContent is correct, but explicitly declaring it would improve code clarity and catch potential type mismatches earlier.

📝 Proposed type declaration
+interface CellContentResult {
+  content: React.ReactNode
+  isPrimitive: boolean
+}
+
-function renderCellContent<TData>(cell: Cell<TData, unknown>) {
+function renderCellContent<TData>(cell: Cell<TData, unknown>): CellContentResult {
  const content = flexRender(cell.column.columnDef.cell, cell.getContext())
  const textContent = getPrimitiveTextContent(content)
🤖 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 `@web/default/src/components/data-table/core/data-table-row.tsx` around lines
104 - 118, Add an explicit return type annotation to the renderCellContent
function to improve type safety and documentation. The function currently relies
on TypeScript's type inference for its return type. Declare the return type as
an object with content property (which accepts React.ReactNode or similar) and
isPrimitive property (boolean) to make the contract explicit and catch potential
type mismatches earlier in development.

104-126: Add explicit return type annotation to renderCellContent for clarity.

The refactored function lacks an explicit return type annotation and relies on TypeScript type inference. While the code is type-safe and usage correctly destructures both properties (isPrimitive and content), explicitly annotating the return type aligns with TypeScript best practices and the project's coding guidelines on explicit type annotations.

Define the return type:

Suggested type definition
type RenderCellResult = {
  content: React.ReactNode
  isPrimitive: boolean
}

function renderCellContent<TData>(cell: Cell<TData, unknown>): RenderCellResult {
  // existing implementation
}
🤖 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 `@web/default/src/components/data-table/core/data-table-row.tsx` around lines
104 - 126, Add an explicit return type annotation to the `renderCellContent`
function to align with TypeScript best practices. First, define a new type
called RenderCellResult that represents the return object structure with two
properties: content of type React.ReactNode and isPrimitive of type boolean.
Then, annotate the `renderCellContent` function signature with the
RenderCellResult return type. This clarifies the contract of the function and
improves code readability without changing the implementation logic.
🤖 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.

Nitpick comments:
In `@web/default/src/components/data-table/core/data-table-row.tsx`:
- Around line 104-118: Add an explicit return type annotation to the
renderCellContent function to improve type safety and documentation. The
function currently relies on TypeScript's type inference for its return type.
Declare the return type as an object with content property (which accepts
React.ReactNode or similar) and isPrimitive property (boolean) to make the
contract explicit and catch potential type mismatches earlier in development.
- Around line 104-126: Add an explicit return type annotation to the
`renderCellContent` function to align with TypeScript best practices. First,
define a new type called RenderCellResult that represents the return object
structure with two properties: content of type React.ReactNode and isPrimitive
of type boolean. Then, annotate the `renderCellContent` function signature with
the RenderCellResult return type. This clarifies the contract of the function
and improves code readability without changing the implementation logic.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: caff4bd2-5f61-418d-9b47-40104997b0ec

📥 Commits

Reviewing files that changed from the base of the PR and between eb86311 and 34287af.

📒 Files selected for processing (3)
  • web/default/src/components/data-table/core/data-table-row.tsx
  • web/default/src/components/data-table/core/table-sizing.ts
  • web/default/src/features/usage-logs/components/model-badge.tsx

@t0ng7u
t0ng7u merged commit e5250d6 into main Jun 17, 2026
2 checks passed
@Calcium-Ion
Calcium-Ion deleted the fix/data-table-component-cells branch June 24, 2026 10:42
zhaodechao2008 pushed a commit to zhaodechao2008/new-api that referenced this pull request Jul 27, 2026
Merge pull request QuantumNous#5536 from QuantumNous/fix/data-table-component-cells
330079598 pushed a commit to 330079598/new-api that referenced this pull request Aug 19, 2026
Merge pull request QuantumNous#5536 from QuantumNous/fix/data-table-component-cells
salem-2007 added a commit to salem-2007/new-api that referenced this pull request Sep 10, 2026
Merge pull request QuantumNous#5536 from QuantumNous/fix/data-table-component-cells
junjundesk pushed a commit to junjundesk/new-api that referenced this pull request Oct 3, 2026
Merge pull request QuantumNous#5536 from QuantumNous/fix/data-table-component-cells
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