Skip to content

fix: update default frontend hardcoded route links - #5016

Merged
seefs001 merged 1 commit into
QuantumNous:mainfrom
yyhhyyyyyy:fix/default-frontend-hardcoded-routes
May 22, 2026
Merged

fix: update default frontend hardcoded route links#5016
seefs001 merged 1 commit into
QuantumNous:mainfrom
yyhhyyyyyy:fix/default-frontend-hardcoded-routes

Conversation

@yyhhyyyyyy

@yyhhyyyyyy yyhhyyyyyy commented May 21, 2026

Copy link
Copy Markdown
Contributor

⚠️ 提交说明 / PR Notice

Important

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

📝 变更描述 / Description

(简述:做了什么?为什么这样改能生效?请基于你对代码逻辑的理解来写,避免粘贴未经整理的内容)
修复 default 前端中残留的 classic 硬编码路由。

🚀 变更类型 / Type of change

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

🔗 关联任务 / Related Issue

✅ 提交前检查项 / Checklist

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

📸 运行证明 / Proof of Work

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

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Updated navigation links across channel management and error dialogs to direct users to the correct deployment management and billing settings pages when accessing related features.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

This PR updates three UI component files to redirect navigation links away from legacy console routes to new system-settings and models deployment destinations. Channel test dialogs, message error handlers, and deployment columns now point to consolidated billing and deployment pages.

Changes

Navigation route consolidation

Layer / File(s) Summary
Update navigation destinations across UI components
web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx, web/default/src/features/playground/components/message-error.tsx, web/default/src/features/channels/components/channels-columns.tsx
Model pricing "Go to Settings" actions in channel test failures and playground errors redirect to /system-settings/billing/model-pricing. Deployment links in the channels column redirect to /models/deployments?dFilter=... instead of console routes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • QuantumNous/new-api#4988: Also updates channel-test-dialog.tsx to handle model_price_error failure flow's "Go to Settings" action.

Suggested reviewers

  • seefs001

Poem

🐰 Routes redirect with care,
from /console to settings fair,
Models and billing paths unite,
navigation shines so bright!
Hop along to /system-settings, right! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% 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
Title check ✅ Passed The title accurately describes the main change: updating hardcoded frontend route links from old 'classic' routes to new system-settings routes across multiple components.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ 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.

Actionable comments posted: 2

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

Inline comments:
In
`@web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx`:
- Around line 762-764: Multiple call sites open external pages with
window.open(..., '_blank') (e.g., the window.open in channel-test-dialog.tsx) or
anchor elements without rel protection; update each to prevent
tabnabbing/referrer leakage by adding the third window.open argument
"noopener,noreferrer" (e.g., window.open(url, '_blank', 'noopener,noreferrer'))
and, where an <a> element is used (e.g., in ChatPresetsItem, ChannelsColumns,
ViewDetailsDialog, MessageError, SubscriptionPurchaseDialog,
IonetDeploymentSettingsSection, AudioPreviewDialog and similar), add
rel="noopener noreferrer" alongside target="_blank"; also update the hook files
(use-creem-payment, use-payment, use-waffo-payment) and oauth.ts to use the same
window.open signature so all listed symbols are hardened.

In `@web/default/src/features/playground/components/message-error.tsx`:
- Around line 59-61: The onClick handler that opens
'/system-settings/billing/model-pricing' in a new tab should pass secure
window.open features to prevent opener/referrer leakage; update the onClick in
the MessageError component (the onClick that calls
window.open('/system-settings/billing/model-pricing', '_blank')) to include the
third argument "noopener,noreferrer" (or convert to an anchor element with
target="_blank" and rel="noopener noreferrer") so the new-tab navigation uses
noopener and noreferrer.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ac8a6425-2bac-411b-8a02-34af88a13d4e

📥 Commits

Reviewing files that changed from the base of the PR and between 006e801 and 7f343f7.

📒 Files selected for processing (3)
  • web/default/src/features/channels/components/channels-columns.tsx
  • web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx
  • web/default/src/features/playground/components/message-error.tsx

Comment on lines +762 to +764
onClick={() =>
window.open('/system-settings/billing/model-pricing', '_blank')
}

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 | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx"

# Show the exact snippet + a little context around the referenced lines
sed -n '740,790p' "$FILE" | nl -ba | sed -n '1,120p'

# Search for other window.open usages in the frontend and summarize patterns
rg -n "window\.open\(" web/default/src --glob='*.ts*' || true

# Specifically find calls that open _blank without noopener/noreferrer (3-arg form or missing third arg)
rg -n --glob='*.ts*' "window\.open\([^)]*['_\"]_blank['\"][^,)]*(?:\)[;}]|\n)" web/default/src || true

Repository: QuantumNous/new-api

Length of output: 106


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx"

echo "== Snippet with line numbers =="
awk 'NR>=740 && NR<=785 {printf "%d\t%s\n", NR, $0}' "$FILE"

echo
echo "== All window.open occurrences (ts/tsx) =="
rg -n "window\.open\(" web/default/src --glob='*.ts*' | head -n 200 || true

echo
echo "== window.open(_blank) missing noopener/noreferrer (best-effort scan) =="
python3 - <<'PY'
import os, re

root = "web/default/src"
target_ext = (".ts", ".tsx")
files=[]
for dirpath, _, filenames in os.walk(root):
    for fn in filenames:
        if fn.endswith(target_ext):
            files.append(os.path.join(dirpath, fn))

# Find window.open occurrences and inspect nearby text for _blank and noopener/noreferrer.
# Best-effort: examines up to N chars after the call site.
N=600

occ_re = re.compile(r'window\s*\.?\s*open\s*\(')

def linecol(text, idx):
    # compute 1-based line and column
    line = text.count('\n', 0, idx) + 1
    last_nl = text.rfind('\n', 0, idx)
    col = idx - last_nl if last_nl != -1 else idx + 1
    return line, col

bad=[]
for path in files:
    try:
        with open(path, "r", encoding="utf-8") as f:
            s=f.read()
    except Exception:
        continue
    for m in occ_re.finditer(s):
        i=m.start()
        chunk = s[i:i+N]
        if ("'_blank'" in chunk) or ('"_blank"' in chunk) or ("_blank" in chunk):
            # consider it "has protections" if both substrings appear somewhere nearby
            # (covers typical "'noopener,noreferrer'" or separate 'noopener'/'noreferrer')
            has_noop = "noopener" in chunk
            has_noref = "noreferrer" in chunk
            if not (has_noop and has_noref):
                # find line number
                line, col = linecol(s, i)
                snippet = chunk.splitlines()[0][:180]
                bad.append((path, line, col, snippet))
                break  # report at most once per file to keep output bounded

print("Matches:")
if not bad:
    print("None found (best-effort).")
else:
    for path,line,col,snippet in bad[:200]:
        print(f"- {path}:{line}:{col} :: {snippet}")
PY

Repository: QuantumNous/new-api

Length of output: 6792


Harden window.open(..., '_blank') against tabnabbing/referrer leakage

  • web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx uses window.open(..., '_blank') without noopener,noreferrer (lines 762-764); add the third argument to prevent opener/referrer leakage.
  • Other _blank callsites also lack full protection and should be updated similarly:
    web/default/src/components/layout/components/chat-presets-item.tsx, web/default/src/features/channels/components/channels-columns.tsx, web/default/src/features/keys/components/dialogs/cc-switch-dialog.tsx, web/default/src/features/keys/components/data-table-row-actions.tsx, web/default/src/features/models/components/dialogs/view-details-dialog.tsx, web/default/src/features/playground/components/message-error.tsx, web/default/src/features/subscriptions/components/dialogs/subscription-purchase-dialog.tsx, web/default/src/features/system-settings/integrations/ionet-deployment-settings-section.tsx, web/default/src/features/usage-logs/components/dialogs/audio-preview-dialog.tsx, web/default/src/features/wallet/hooks/use-creem-payment.ts, web/default/src/features/wallet/hooks/use-payment.ts, web/default/src/features/wallet/hooks/use-waffo-payment.ts, web/default/src/lib/oauth.ts.
Suggested fix
-            onClick={() =>
-              window.open('/system-settings/billing/model-pricing', '_blank')
-            }
+            onClick={() =>
+              window.open(
+                '/system-settings/billing/model-pricing',
+                '_blank',
+                'noopener,noreferrer'
+              )
+            }
📝 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
onClick={() =>
window.open('/system-settings/billing/model-pricing', '_blank')
}
onClick={() =>
window.open(
'/system-settings/billing/model-pricing',
'_blank',
'noopener,noreferrer'
)
}
🤖 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/features/channels/components/dialogs/channel-test-dialog.tsx`
around lines 762 - 764, Multiple call sites open external pages with
window.open(..., '_blank') (e.g., the window.open in channel-test-dialog.tsx) or
anchor elements without rel protection; update each to prevent
tabnabbing/referrer leakage by adding the third window.open argument
"noopener,noreferrer" (e.g., window.open(url, '_blank', 'noopener,noreferrer'))
and, where an <a> element is used (e.g., in ChatPresetsItem, ChannelsColumns,
ViewDetailsDialog, MessageError, SubscriptionPurchaseDialog,
IonetDeploymentSettingsSection, AudioPreviewDialog and similar), add
rel="noopener noreferrer" alongside target="_blank"; also update the hook files
(use-creem-payment, use-payment, use-waffo-payment) and oauth.ts to use the same
window.open signature so all listed symbols are hardened.

Comment on lines 59 to 61
onClick={() =>
window.open('/console/setting?tab=ratio', '_blank')
window.open('/system-settings/billing/model-pricing', '_blank')
}

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 | 🟠 Major | ⚡ Quick win

Use secure window.open features for the new-tab link.

Please include noopener,noreferrer for this _blank navigation to avoid opener/referrer exposure.

Suggested fix
-              onClick={() =>
-                window.open('/system-settings/billing/model-pricing', '_blank')
-              }
+              onClick={() =>
+                window.open(
+                  '/system-settings/billing/model-pricing',
+                  '_blank',
+                  'noopener,noreferrer'
+                )
+              }
📝 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
onClick={() =>
window.open('/console/setting?tab=ratio', '_blank')
window.open('/system-settings/billing/model-pricing', '_blank')
}
onClick={() =>
window.open(
'/system-settings/billing/model-pricing',
'_blank',
'noopener,noreferrer'
)
}
🤖 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/features/playground/components/message-error.tsx` around
lines 59 - 61, The onClick handler that opens
'/system-settings/billing/model-pricing' in a new tab should pass secure
window.open features to prevent opener/referrer leakage; update the onClick in
the MessageError component (the onClick that calls
window.open('/system-settings/billing/model-pricing', '_blank')) to include the
third argument "noopener,noreferrer" (or convert to an anchor element with
target="_blank" and rel="noopener noreferrer") so the new-tab navigation uses
noopener and noreferrer.

@seefs001
seefs001 merged commit e13d673 into QuantumNous:main May 22, 2026
2 checks passed
xyfacai pushed a commit to xyfacai/new-api that referenced this pull request May 30, 2026
SamuelSxy pushed a commit to SamuelSxy/new-api-rh that referenced this pull request Jun 7, 2026
fx247562340 pushed a commit to fx247562340/vancine-platform that referenced this pull request Jun 11, 2026
330079598 pushed a commit to 330079598/new-api that referenced this pull request Aug 19, 2026
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.

添加新渠道后测试模型未定价,点击前往设置,报错404

2 participants