Skip to content

optimize: channel affinity tips - #2898

Merged
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
seefs001:feature/channel-affinity-tips
Feb 8, 2026
Merged

optimize: channel affinity tips#2898
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
seefs001:feature/channel-affinity-tips

Conversation

@seefs001

@seefs001 seefs001 commented Feb 8, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Channel affinity indicators now appear in the usage logs table; click to view detailed usage information.
  • Improvements

    • Enhanced channel information display and streamlined column rendering for better clarity.

@coderabbitai

coderabbitai Bot commented Feb 8, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

The change refactors channel column rendering in usage logs to display channel affinity via a Sparkles badge indicator, moves affinity handling from the retry column, and improves use_channel array validation.

Changes

Cohort / File(s) Summary
Channel Affinity UI Updates
web/src/components/table/usage-logs/UsageLogsColumnDefs.jsx
Import adjustments (Button repositioned, Sparkles added); channel column refactored to detect channel affinity and render interactive Sparkles badge triggering modal; retry column simplified to remove affinity UI; improved use_channel array validation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 A sparkle badge now adorns the logs,
Where channels find their perfect home,
Through affinity's delightful fog,
No user's path need ever roam alone. ✨

🚥 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 'optimize: channel affinity tips' directly relates to the main change, which reorganizes channel affinity handling by moving it from the Retry column to a Sparkles badge in the Channel column.
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
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@seefs001
seefs001 force-pushed the feature/channel-affinity-tips branch from 152cf50 to 8f831fc Compare February 8, 2026 15:47

@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

🤖 Fix all issues with AI agents
In `@web/src/components/table/usage-logs/UsageLogsColumnDefs.jsx`:
- Around line 620-628: The retry-column logic uses other.admin_info.use_channel
without ensuring it's an array, so calling .join('->') on non-arrays will throw;
update the block that constructs useChannelStr (in UsageLogsColumnDefs.jsx where
other.admin_info/use_channel is referenced) to first check
Array.isArray(other.admin_info.use_channel) &&
other.admin_info.use_channel.length > 0 before calling .join, and fall back to
treating a string value as-is (or skip/empty) when use_channel is a non-array
truthy value; ensure the variable names referenced (useChannel, useChannelStr,
content) are adapted accordingly.
🧹 Nitpick comments (1)
web/src/components/table/usage-logs/UsageLogsColumnDefs.jsx (1)

614-618: Unsafe JSON.parse without try-catch — consider using getLogOther for consistency.

The channel column uses getLogOther(record.other) (which handles parse errors gracefully), but this retry column calls JSON.parse(record.other) directly. Malformed JSON will crash the render.

Proposed fix
-        let content = t('渠道') + `:${record.channel}`;
-        if (record.other !== '') {
-          let other = JSON.parse(record.other);
-          if (other === null) {
-            return <></>;
-          }
+        let content = t('渠道') + `:${record.channel}`;
+        let other = getLogOther(record.other);
+        if (other) {

Comment on lines 620 to 628
if (other.admin_info !== undefined) {
if (
other.admin_info.use_channel !== null &&
other.admin_info.use_channel !== undefined &&
other.admin_info.use_channel !== ''
other.admin_info.use_channel !== null &&
other.admin_info.use_channel !== undefined &&
other.admin_info.use_channel !== ''
) {
let useChannel = other.admin_info.use_channel;
let useChannelStr = useChannel.join('->');
content = t('渠道') + `:${useChannelStr}`;

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.

⚠️ Potential issue | 🟡 Minor

Inconsistent use_channel validation — .join() will throw on non-array values.

The channel column (line 321) now properly guards with Array.isArray(adminInfo.use_channel) && adminInfo.use_channel.length > 0, but this retry column still uses loose truthy checks. If use_channel is a non-array truthy value (e.g., a string), calling .join('->') on line 627 will throw a TypeError at runtime.

Proposed fix: align with channel column's validation
          if (
-                other.admin_info.use_channel !== null &&
-                other.admin_info.use_channel !== undefined &&
-                other.admin_info.use_channel !== ''
+                Array.isArray(other.admin_info.use_channel) &&
+                other.admin_info.use_channel.length > 0
           ) {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (other.admin_info !== undefined) {
if (
other.admin_info.use_channel !== null &&
other.admin_info.use_channel !== undefined &&
other.admin_info.use_channel !== ''
other.admin_info.use_channel !== null &&
other.admin_info.use_channel !== undefined &&
other.admin_info.use_channel !== ''
) {
let useChannel = other.admin_info.use_channel;
let useChannelStr = useChannel.join('->');
content = t('渠道') + `:${useChannelStr}`;
if (other.admin_info !== undefined) {
if (
Array.isArray(other.admin_info.use_channel) &&
other.admin_info.use_channel.length > 0
) {
let useChannel = other.admin_info.use_channel;
let useChannelStr = useChannel.join('->');
content = t('渠道') + `:${useChannelStr}`;
🤖 Prompt for AI Agents
In `@web/src/components/table/usage-logs/UsageLogsColumnDefs.jsx` around lines 620
- 628, The retry-column logic uses other.admin_info.use_channel without ensuring
it's an array, so calling .join('->') on non-arrays will throw; update the block
that constructs useChannelStr (in UsageLogsColumnDefs.jsx where
other.admin_info/use_channel is referenced) to first check
Array.isArray(other.admin_info.use_channel) &&
other.admin_info.use_channel.length > 0 before calling .join, and fall back to
treating a string value as-is (or skip/empty) when use_channel is a non-array
truthy value; ensure the variable names referenced (useChannel, useChannelStr,
content) are adapted accordingly.

@Calcium-Ion
Calcium-Ion merged commit ba032b7 into QuantumNous:main Feb 8, 2026
1 check passed
ennnnny pushed a commit to ennnnny/new-api that referenced this pull request Mar 17, 2026
…inity-tips

optimize: channel affinity tips
@coderabbitai coderabbitai Bot mentioned this pull request May 21, 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