Skip to content

chore: refine codex usage modal layout - #4386

Merged
Calcium-Ion merged 2 commits into
QuantumNous:mainfrom
seefs001:refactor/codex-usage-modal
Apr 22, 2026
Merged

chore: refine codex usage modal layout#4386
Calcium-Ion merged 2 commits into
QuantumNous:mainfrom
seefs001:refactor/codex-usage-modal

Conversation

@seefs001

@seefs001 seefs001 commented Apr 22, 2026

Copy link
Copy Markdown
Collaborator

⚠️ 提交说明 / PR Notice

Important

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

📝 变更描述 / Description

优化额度窗口展示,新增 GPT-5.3-Codex-Spark 单独计费的模型展示

🚀 变更类型 / Type of change

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

🔗 关联任务 / Related Issue

  • Closes # (如有)

✅ 提交前检查项 / Checklist

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

📸 运行证明 / Proof of Work

(请在此粘贴截图、关键日志或测试报告,以证明变更生效)

Summary by CodeRabbit

  • New Features
    • Added support for displaying additional rate limits in the usage modal
    • Improved modal responsiveness across mobile and desktop devices
    • Enhanced rate limit information display layout for better organization

@coderabbitai

coderabbitai Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

This PR enhances the CodexUsageModal component by introducing responsive mobile-aware modal sizing, refactoring rate-limit window rendering into a reusable component structure, and extending support for displaying additional rate limits with their respective usage windows and status indicators.

Changes

Cohort / File(s) Summary
Modal Responsiveness & Rate-Limit Refactoring
web/src/components/table/channels/modals/CodexUsageModal.jsx
Added isMobileViewport() and getCodexUsageModalLayout() helpers for adaptive modal sizing across viewports. Introduced RateLimitWindowGrid and RateLimitGroupSection components to consolidate rate-limit window rendering logic. Extended CodexUsageView to extract and render additional rate limits from data.additional_rate_limits with conditional sections. Updated window card header layout to support text wrapping and adjusted explanatory text for add-on billing context.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A modal grows wise, from desktop to phone,
Windows reusable, no longer alone,
Rate limits flow, additional and bright,
Responsive layouts—mobile-first delight! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the primary change: refining the layout of the Codex usage modal with mobile-aware sizing, rate-limit window rendering refactoring, and additional rate limits support.
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.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 (4)
web/src/components/table/channels/modals/CodexUsageModal.jsx (4)

344-358: Raw metered_feature label is not translated.

Line 350 renders the literal string metered_feature as a UI label, while every other user-facing string in this file goes through tt('中文'). If this is intended as a fixed technical/API field name it's fine to leave; if it's meant to be a user-facing caption, it should follow the project i18n convention.

As per coding guidelines, "Use useTranslation() hook and call t('中文key') in components" with Chinese source strings as translation keys.

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

In `@web/src/components/table/channels/modals/CodexUsageModal.jsx` around lines
344 - 358, The literal label "metered_feature" in the CodexUsageModal JSX should
be translated; update the component to use the i18n hook (useTranslation) and
replace the raw string with a t(...) call (e.g., t('计量特性') or your chosen
Chinese key) where the span currently renders "metered_feature", ensuring you
import/use useTranslation at the top of CodexUsageModal.jsx and call t inside
the component so the featureText caption follows the project's i18n convention.

483-531: Status tag is now rendered twice for the base group.

The outer account card already renders statusTag at Line 422, and the base RateLimitGroupSection renders it again at Line 342 via the statusTag prop. For the additional-rate-limit items this makes sense (each has its own status), but for the "基础额度" section it duplicates information that the user just saw directly above. Consider either omitting the statusTag prop for the base section, or dropping the status tag from the outer account card so the per-section tags become the single source of truth.

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

In `@web/src/components/table/channels/modals/CodexUsageModal.jsx` around lines
483 - 531, The base "基础额度" section is rendering the same status twice: once in
the outer account card via statusTag and again by passing statusTag into the
base RateLimitGroupSection; remove the duplication by deleting the statusTag
prop from the base RateLimitGroupSection (the one with title={tt('基础额度')} and
rateLimitSource={data}) so the outer account card remains the single source of
truth; do not change the additionalRateLimits mapping (which should still pass
resolveUsageStatusTag(tt, item?.rate_limit) into RateLimitGroupSection).

144-173: Responsive layout is computed once at modal open.

getCodexUsageModalLayout() is invoked only at openCodexUsageModal time (Line 649) and its result is frozen into the Modal.info props. If the user rotates their device or resizes the viewport across the 768px threshold while the modal is open, the modal will not re-switch between the mobile and desktop layouts. For a responsive polish PR this is worth addressing — e.g., render the modal content through a small wrapper that subscribes to the existing useIsMobile hook and updates the modal instance, or switch to Modal.destroyAll() + re-open on breakpoint change.

Not a blocker given modals are typically short-lived, but flagging since the whole intent here is responsiveness.

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

In `@web/src/components/table/channels/modals/CodexUsageModal.jsx` around lines
144 - 173, The modal layout returned by getCodexUsageModalLayout is computed
once in openCodexUsageModal and frozen into Modal.info, so it doesn't respond to
viewport changes; fix by making the open flow subscribe to the existing
useIsMobile (or a resize/breakpoint listener) and update the open modal when the
breakpoint crosses 768px — either call Modal.destroyAll() and re-open with the
new getCodexUsageModalLayout output or call the Modal instance update method
when available; locate references to getCodexUsageModalLayout,
openCodexUsageModal, Modal.info, and the useIsMobile hook to implement the
subscription and the re-open/update logic.

321-369: RateLimitGroupSection prop contract is implicit — worth a brief comment.

rateLimitSource is passed two shapes from the caller: the top-level data (for the base group, where data.rate_limit and data.plan_type are read by resolveRateLimitWindows) and each additional_rate_limits[] item (where plan_type is absent, so the free-plan branch at Line 87 is silently skipped). The behavior is correct, but the coupling between the two call sites and resolveRateLimitWindows' internal field access is non-obvious. A one-line JSDoc on this component describing the expected shape of rateLimitSource would reduce the chance of a future caller passing e.g. rateLimitSource={data.rate_limit} and breaking the lookup.

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

In `@web/src/components/table/channels/modals/CodexUsageModal.jsx` around lines
321 - 369, Add a one-line JSDoc above the RateLimitGroupSection component
clarifying the expected shape of the rateLimitSource prop: it can be the full
top-level data object (with optional rate_limit and plan_type fields used by
resolveRateLimitWindows) or an individual additional_rate_limits[] item (which
may omit plan_type), and note that resolveRateLimitWindows reads data.rate_limit
and data.plan_type; this will make the implicit contract between the callers and
resolveRateLimitWindows explicit and prevent future incorrect calls like
rateLimitSource={data.rate_limit}.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@web/src/components/table/channels/modals/CodexUsageModal.jsx`:
- Around line 344-358: The literal label "metered_feature" in the
CodexUsageModal JSX should be translated; update the component to use the i18n
hook (useTranslation) and replace the raw string with a t(...) call (e.g.,
t('计量特性') or your chosen Chinese key) where the span currently renders
"metered_feature", ensuring you import/use useTranslation at the top of
CodexUsageModal.jsx and call t inside the component so the featureText caption
follows the project's i18n convention.
- Around line 483-531: The base "基础额度" section is rendering the same status
twice: once in the outer account card via statusTag and again by passing
statusTag into the base RateLimitGroupSection; remove the duplication by
deleting the statusTag prop from the base RateLimitGroupSection (the one with
title={tt('基础额度')} and rateLimitSource={data}) so the outer account card remains
the single source of truth; do not change the additionalRateLimits mapping
(which should still pass resolveUsageStatusTag(tt, item?.rate_limit) into
RateLimitGroupSection).
- Around line 144-173: The modal layout returned by getCodexUsageModalLayout is
computed once in openCodexUsageModal and frozen into Modal.info, so it doesn't
respond to viewport changes; fix by making the open flow subscribe to the
existing useIsMobile (or a resize/breakpoint listener) and update the open modal
when the breakpoint crosses 768px — either call Modal.destroyAll() and re-open
with the new getCodexUsageModalLayout output or call the Modal instance update
method when available; locate references to getCodexUsageModalLayout,
openCodexUsageModal, Modal.info, and the useIsMobile hook to implement the
subscription and the re-open/update logic.
- Around line 321-369: Add a one-line JSDoc above the RateLimitGroupSection
component clarifying the expected shape of the rateLimitSource prop: it can be
the full top-level data object (with optional rate_limit and plan_type fields
used by resolveRateLimitWindows) or an individual additional_rate_limits[] item
(which may omit plan_type), and note that resolveRateLimitWindows reads
data.rate_limit and data.plan_type; this will make the implicit contract between
the callers and resolveRateLimitWindows explicit and prevent future incorrect
calls like rateLimitSource={data.rate_limit}.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2c33e295-137d-490f-9763-361b7aef738d

📥 Commits

Reviewing files that changed from the base of the PR and between f995a86 and 48e3b5e.

📒 Files selected for processing (1)
  • web/src/components/table/channels/modals/CodexUsageModal.jsx

@Calcium-Ion
Calcium-Ion merged commit d586a56 into QuantumNous:main Apr 22, 2026
2 checks passed
isboyjc pushed a commit to isboyjc/amux-api that referenced this pull request Apr 29, 2026
* chore: refine codex usage modal layout

* fix: polish codex usage modal responsiveness
Jinxuans referenced this pull request in TokFlux-Org/TokFlux May 9, 2026
* chore: refine codex usage modal layout

* fix: polish codex usage modal responsiveness
xyfacai pushed a commit to xyfacai/new-api that referenced this pull request May 30, 2026
* chore: refine codex usage modal layout

* fix: polish codex usage modal responsiveness
@coderabbitai coderabbitai Bot mentioned this pull request Jun 18, 2026
11 tasks
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