Skip to content

feat: Langfuse trace notice & fix theme redirect loop#6

Merged
Starry-Sky-World merged 5 commits into
mainfrom
feat/langfuse-trace-notice
May 22, 2026
Merged

feat: Langfuse trace notice & fix theme redirect loop#6
Starry-Sky-World merged 5 commits into
mainfrom
feat/langfuse-trace-notice

Conversation

@Starry-Sky-World
Copy link
Copy Markdown

@Starry-Sky-World Starry-Sky-World commented May 22, 2026

Changes

1. Langfuse 完整统计提示 (feat)

当 Langfuse 启用且完整统计(trace_content)同时开启时,在日志和 Keys 页面显示警告横幅:

本站使用Langfuse记录用户提示词等数据,请注意安全。

只开启统计不开启完整统计则不显示提示。

  • 后端 /api/status 新增 langfuse_trace_content 字段(enabled && trace_content)
  • 新建 LangfuseTraceNotice 可复用组件
  • 日志页面和 Keys 页面添加提示
  • 6 语言 i18n 翻译(en/zh/fr/ja/ru/vi)

2. 主题重定向循环修复 (fix)

  • 扩展 MapFrontendPath 完整的 classic/default 路径映射
  • 将路径映射逻辑从 router 移至 common/frontend_theme.go
  • 修复 classic 主题 UserProvider 无限重定向循环
  • 修复 default 主题 auth redirect 仅在 classic 时重定向
  • 修复 _authenticated route 对 classic 主题重定向到 /console
  • 后端 controller 中硬编码的 /console/xxx 路径改为 GetThemeAwarePath()
  • 前端组件中硬编码的 /console/xxx 链接修正为正确的 default 主题路径

Summary by CodeRabbit

  • New Features

    • Langfuse LLM observability UI, tracing controls, and subscription auto-bind options
    • Theme-aware frontend routing so redirects respect the active interface theme
  • Bug Fixes / Improvements

    • Payment and OAuth redirects now follow theme-aware paths
    • Improved theme-switch navigation and single-redirect behavior
    • Deployment link and navigation targets updated
    • Safer external link handling (noopener,noreferrer)
  • Documentation

    • Added i18n strings for Langfuse across multiple locales
  • Chores

    • Removed deprecated theme-cookie helpers; updated ignore patterns

Review Change Stack

When Langfuse is enabled AND trace_content (full statistics) is enabled,
display a warning banner on the Logs and Keys pages:
'本站使用Langfuse记录用户提示词等数据,请注意安全。'

- Add langfuse_trace_content field to /api/status public endpoint
- Create LangfuseTraceNotice reusable component
- Add notice to Usage Logs page
- Add notice to API Keys page
- Add i18n translations for en/zh/fr/ja/ru/vi
- Expand MapFrontendPath with complete classic<->default path mappings
- Move path mapping logic from router to common/frontend_theme.go
- Fix infinite redirect loop in classic theme UserProvider
- Fix default theme auth redirect to only redirect for classic
- Fix _authenticated route to redirect to /console for classic theme
- Replace hardcoded /console/xxx paths with GetThemeAwarePath() in:
  - epay/stripe/waffo payment controllers
  - telegram bind controller
  - topup controllers
- Fix hardcoded /console/xxx links in default frontend components:
  - channels-columns.tsx, channel-test-dialog.tsx, message-error.tsx
- Remove duplicate setFrontendTheme from classic PageLayout
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0f128a48-b547-4a62-a292-cd6daa093d25

📥 Commits

Reviewing files that changed from the base of the PR and between d1203ef and cfc6f76.

📒 Files selected for processing (22)
  • web/classic/src/components/common/markdown/MarkdownRenderer.jsx
  • web/classic/src/components/playground/MessageContent.jsx
  • web/classic/src/components/table/channels/modals/ModelTestModal.jsx
  • web/classic/src/components/table/model-deployments/modals/ViewLogsModal.jsx
  • web/classic/src/components/table/task-logs/modals/AudioPreviewModal.jsx
  • web/classic/src/components/table/task-logs/modals/ContentModal.jsx
  • web/classic/src/components/table/tokens/modals/CCSwitchModal.jsx
  • web/classic/src/components/topup/SubscriptionPlansCard.jsx
  • web/classic/src/components/topup/index.jsx
  • web/classic/src/helpers/api.js
  • web/classic/src/hooks/tokens/useTokensData.jsx
  • web/classic/src/pages/Home/index.jsx
  • web/classic/src/pages/Setting/Model/SettingModelDeployment.jsx
  • web/default/src/features/keys/components/dialogs/cc-switch-dialog.tsx
  • web/default/src/features/models/components/dialogs/view-details-dialog.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
✅ Files skipped from review due to trivial changes (4)
  • web/default/src/features/models/components/dialogs/view-details-dialog.tsx
  • web/classic/src/components/topup/SubscriptionPlansCard.jsx
  • web/classic/src/helpers/api.js
  • web/classic/src/components/table/model-deployments/modals/ViewLogsModal.jsx

📝 Walkthrough

Walkthrough

This PR centralizes theme-aware frontend path routing in the backend, applies it across payment/topup handlers, refactors frontend theme navigation with safer redirect logic, adds Langfuse observability UI with security notices, and updates i18n across six languages.

Changes

Theme routing and observability

Layer / File(s) Summary
Backend theme-aware path mapping foundation
common/frontend_theme.go, router/web-router.go
Introduces MapFrontendPath and GetThemeAwarePath to centrally map routes between classic and default themes; router/web-router.go migrates from local mapFrontendPath to use the shared infrastructure.
Payment and checkout handler updates
controller/subscription_payment_epay.go, controller/subscription_payment_stripe.go, controller/telegram.go, controller/topup.go, controller/topup_stripe.go, controller/topup_waffo.go, controller/topup_waffo_pancake.go
All payment handlers now use GetThemeAwarePath to generate theme-aware redirect URLs instead of hardcoded console paths; handlers for Stripe, epay, Waffo, and Telegram updated consistently.
Frontend theme state management and navigation
web/classic/src/context/User/index.jsx, web/classic/src/components/settings/personal/cards/PreferencesSettings.jsx, web/classic/src/components/layout/PageLayout.jsx, web/default/src/routes/_authenticated/route.tsx, web/default/src/features/auth/hooks/use-auth-redirect.ts
User context now uses useRef to track and prevent repeated theme redirects; theme navigation triggers hard redirect to /console when switching to classic theme; old theme-cookie logic removed from PageLayout; auth hook updated to redirect classic theme users.
Frontend route navigation URL updates
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
Updates hardcoded /console/setting and /console/deployment links to point to /system-settings and /models/deployments respectively; adds noopener feature for security.
Langfuse observability feature
controller/misc.go, web/default/src/components/langfuse-trace-notice.tsx, web/default/src/features/keys/index.tsx, web/default/src/features/usage-logs/index.tsx
Status endpoint exposes langfuse_trace_content flag; new LangfuseTraceNotice component displays security warning when Langfuse tracing is enabled; component rendered on API Keys and Usage Logs pages.
Internationalization updates
web/default/src/i18n/locales/en.json, fr.json, ja.json, ru.json, vi.json, zh.json
Adds translations across six languages for Langfuse observability UI (enable toggle, host/server URL, public/secret key labels, trace content options), subscription-plan binding, interface redirect messages, and Langfuse security notices.
Add noopener/noreferrer to window.open calls
multiple frontend files across web/classic and web/default
Replaces two-argument window.open calls with three-argument calls including noopener,noreferrer for security in many places (payments, OAuth, external links, previews).
Repository housekeeping
.gitignore
Extends ignore patterns to include fixdoc.md and hero-rep.html.

🎯 3 (Moderate) | ⏱️ ~25 minutes

🐰 A theme-aware hop through the routing thicket,
Where payments and Langfuse now reach the right wicket,
Frontend themes dance with redirect precision,
Users see warnings with security vision,
Six languages unified in i18n's decision! 🌍✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.23% 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 accurately captures the two main feature/fix objectives: Langfuse trace notice component addition and theme redirect loop fixes.
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 feat/langfuse-trace-notice

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces theme-aware path mapping and redirection logic to maintain navigation consistency between the 'classic' and 'default' frontend themes. It also adds Langfuse LLM observability features, including a frontend notice component and backend status flags. Feedback focuses on correcting path mapping errors where missing trailing slashes would lead to broken sub-path URLs and resolving an inconsistency in the deployment route mapping. Additionally, several i18n entries in the English and other non-Chinese locale files need to be corrected as they currently contain untranslated Chinese text.

Comment thread common/frontend_theme.go Outdated
}

var classicToDefaultPrefixes = []struct{ prefix, replacement string }{
{"/console/chat/", "/playground"},
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The replacement path for /console/chat/ is missing a trailing slash. This will result in incorrect URL concatenation for sub-paths (e.g., /console/chat/abc mapping to /playgroundabc instead of /playground/abc).

Suggested change
{"/console/chat/", "/playground"},
{"/console/chat/", "/playground/"},

Comment thread common/frontend_theme.go Outdated
}

var defaultToClassicPrefixes = []struct{ prefix, replacement string }{
{"/dashboard/", "/console"},
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The replacement path for /dashboard/ is missing a trailing slash. This will cause sub-paths to be incorrectly mapped (e.g., /dashboard/abc mapping to /consoleabc instead of /console/abc).

Suggested change
{"/dashboard/", "/console"},
{"/dashboard/", "/console/"},

Comment thread common/frontend_theme.go Outdated
"/console/midjourney": "/usage-logs",
"/console/task": "/usage-logs",
"/console/models": "/models",
"/console/deployment": "/models",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Inconsistency detected: /console/deployment is mapped to /models here, but the frontend code in channels-columns.tsx (line 664) uses /models/deployments. Please update this mapping to match the actual frontend route.

Suggested change
"/console/deployment": "/models",
"/console/deployment": "/models/deployments",

Comment thread web/default/src/i18n/locales/en.json Outdated
"Configuration for Stripe payment integration": "Configuration for Stripe payment integration",
"Configuration required": "Configuration required",
"Configure": "Configure",
"Configure Langfuse LLM observability": "配置 Langfuse LLM 可观测性",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This entry in the English locale file contains a Chinese translation. It should be in English.

Suggested change
"Configure Langfuse LLM observability": "配置 Langfuse LLM 可观测性",
"Configure Langfuse LLM observability": "Configure Langfuse LLM observability",

Comment thread web/default/src/i18n/locales/en.json Outdated
Comment on lines +1254 to +1259
"Enable Langfuse Tracing": "启用 Langfuse 追踪",
"Include full prompt and completion content in traces. Disabling sends only token counts and metadata.": "在追踪中包含完整的提示词和补全内容。禁用时仅发送 Token 数量和元数据。",
"Langfuse Host": "Langfuse 地址",
"Langfuse server URL (cloud or self-hosted)": "Langfuse 服务器地址(云端或自托管)",
"Langfuse Tracing": "Langfuse 追踪",
"Public Key": "公钥",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

These entries in the English locale file contain Chinese translations. They should be translated to English. This issue also appears in other non-Chinese locale files (fr, ja, ru, vi).

Suggested change
"Enable Langfuse Tracing": "启用 Langfuse 追踪",
"Include full prompt and completion content in traces. Disabling sends only token counts and metadata.": "在追踪中包含完整的提示词和补全内容。禁用时仅发送 Token 数量和元数据。",
"Langfuse Host": "Langfuse 地址",
"Langfuse server URL (cloud or self-hosted)": "Langfuse 服务器地址(云端或自托管)",
"Langfuse Tracing": "Langfuse 追踪",
"Public Key": "公钥",
"Enable Langfuse Tracing": "Enable Langfuse Tracing",
"Include full prompt and completion content in traces. Disabling sends only token counts and metadata.": "Include full prompt and completion content in traces. Disabling sends only token counts and metadata.",
"Langfuse Host": "Langfuse Host",
"Langfuse server URL (cloud or self-hosted)": "Langfuse server URL (cloud or self-hosted)",
"Langfuse Tracing": "Langfuse Tracing",
"Public Key": "Public Key",

Comment thread web/default/src/i18n/locales/en.json Outdated
"Interface Language": "Interface Language",
"Interface Style": "Interface Style",
"Interface style updated. Reloading...": "Interface style updated. Reloading...",
"Interface style updated. Redirecting...": "界面风格已更新,正在跳转...",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This entry in the English locale file contains a Chinese translation.

Suggested change
"Interface style updated. Redirecting...": "界面风格已更新,正在跳转...",
"Interface style updated. Redirecting...": "Interface style updated. Redirecting...",

Comment thread web/default/src/i18n/locales/en.json Outdated
"Statistical quota": "Statistical quota",
"Statistical tokens": "Statistical tokens",
"Statistics reset": "Statistics reset",
"Statistics": "统计",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This entry in the English locale file contains a Chinese translation.

Suggested change
"Statistics": "统计",
"Statistics": "Statistics",

Copy link
Copy Markdown

@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: 15

🧹 Nitpick comments (3)
common/frontend_theme.go (1)

99-125: ⚡ Quick win

Add table-driven tests for mapping edge cases.

This mapper is now a redirect critical path; add tests for exact mapping, prefix mapping, trailing slash normalization, and escaped paths to prevent regressions.

🤖 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 `@common/frontend_theme.go` around lines 99 - 125, Add table-driven unit tests
for MapFrontendPath to cover exact key mapping, prefix replacement,
trailing-slash normalization and URL-escaped inputs so we catch regressions in
the redirect hot path; create a test table that feeds various inputs to
MapFrontendPath (including values that exercise normalizeMapPath, entries in
defaultToClassicMap/classicToDefaultMap and prefixes in
defaultToClassicPrefixes/classicToDefaultPrefixes) and assert expected outputs
for theme="classic" and theme="default", including cases that should return ""
for no-match; include cases for trailing slashes and percent-encoded paths to
validate normalization and prefix handling.
web/default/src/components/langfuse-trace-notice.tsx (1)

16-18: 💤 Low value

Translation key uses full sentence instead of semantic identifier.

The translation key is a complete English sentence rather than a semantic key (e.g., 'langfuse.trace.security_warning'). This pattern makes translations harder to maintain and update across locales.

♻️ Consider using a semantic key
-        {t(
-          'This site uses Langfuse to record user prompts and other data. Please be aware of security risks.'
-        )}
+        {t('langfuse.trace.security_warning')}

Then update locale files with the appropriate key-value pairs.

🤖 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/langfuse-trace-notice.tsx` around lines 16 - 18,
The translation call in langfuse-trace-notice.tsx uses a full English sentence
as the key; change the t(...) invocation to use a semantic key like
'langfuse.trace.security_warning' (update the call site in the component where
t(...) is used), then add the corresponding key/value entry to your locale JSON
files for each language (e.g., "langfuse.trace.security_warning": "This site
uses Langfuse to record user prompts and other data. Please be aware of security
risks."). Ensure the new semantic key is used consistently wherever this message
appears.
controller/misc.go (1)

123-123: 💤 Low value

Consider caching the Langfuse setting call for readability.

The expression calls GetLangfuseSetting() twice. While likely inexpensive, extracting to a local variable would improve readability.

♻️ Optional refactor
+	langfuseSetting := langfuse_setting.GetLangfuseSetting()
 	data := gin.H{
 		"version":                     common.Version,
 		// ... other fields ...
-		"langfuse_trace_content":      langfuse_setting.GetLangfuseSetting().Enabled && langfuse_setting.GetLangfuseSetting().TraceContent,
+		"langfuse_trace_content":      langfuseSetting.Enabled && langfuseSetting.TraceContent,
 	}
🤖 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 `@controller/misc.go` at line 123, Assign the result of
langfuse_setting.GetLangfuseSetting() to a local variable (e.g., lf :=
langfuse_setting.GetLangfuseSetting()) and then use lf.Enabled &&
lf.TraceContent for the "langfuse_trace_content" assignment to avoid calling
GetLangfuseSetting() twice and improve readability; update the expression in the
controller/misc.go block that currently uses
langfuse_setting.GetLangfuseSetting() &&
langfuse_setting.GetLangfuseSetting().TraceContent accordingly.
🤖 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 `@common/frontend_theme.go`:
- Around line 65-77: The prefix-rewrite arrays classicToDefaultPrefixes and
defaultToClassicPrefixes contain two replacement strings missing the trailing
slash, causing nested routes to merge (e.g., "/console/chat/abc" →
"/playgroundabc"). Update the replacement values so they preserve the separator:
in classicToDefaultPrefixes change the replacement for prefix "/console/chat/"
from "/playground" to "/playground/" and in defaultToClassicPrefixes change the
replacement for prefix "/dashboard/" from "/console" to "/console/"; keep other
entries unchanged so nested paths remain valid.

In `@web/classic/src/context/User/index.jsx`:
- Around line 32-33: The module-scoped mutable object themeRedirectAttempted
persists across component lifetimes and should be replaced with a per-instance
React ref: inside the UserProvider component create a ref via useRef (e.g.,
const themeRedirectAttemptedRef = useRef(false)) and replace all reads/writes of
themeRedirectAttempted.current with themeRedirectAttemptedRef.current so the
flag resets when UserProvider unmounts/remounts; update any imports/usages in
this file to reference the ref variable rather than the module-scoped
themeRedirectAttempted.
- Around line 63-66: UserContext's automatic redirect to '/dashboard' (in
web/classic/src/context/User/index.jsx using themeRedirectAttempted.current)
conflicts with the delayed navigation from PreferencesSettings
(PreferencesSettings.jsx calling getFrontendThemeSettingsPath('default') after
300ms); fix by introducing a shared "theme navigation pending" flag that
PreferencesSettings sets before scheduling its navigation and clears after
navigation completes, and have UserContext check that flag (skip its
'/dashboard' redirect when set) or use a small public API on UserContext (e.g.,
startThemeNavigation()/endThemeNavigation) so only one redirect runs per theme
change.

In `@web/default/src/features/auth/hooks/use-auth-redirect.ts`:
- Around line 92-93: In use-auth-redirect.ts, the savedTheme === 'classic'
branch currently calls window.location.assign('/console'); change this to
window.location.replace('/console') so the redirect does not preserve the
current page in browser history; update the savedTheme check in the redirect
logic (the function handling post-auth redirect in useAuthRedirect hook) to use
replace for consistency with _authenticated/route.tsx.

In `@web/default/src/features/channels/components/channels-columns.tsx`:
- Around line 664-666: The deep-link currently always builds targetUrl as
`/models/deployments?deployment_id=${deploymentId}` which the default theme
ignores and the classic theme expects a different path; update the onClick in
ChannelsColumns (where targetUrl and window.open are used) to branch on theme:
if classic theme, open `/console/deployment?deployment_id=${deploymentId}`,
otherwise open a route the default theme will honor (use a path segment with the
id, e.g. `/models/deployments/${deploymentId}` or the app's canonical deployment
route that accepts an id); detect theme via the existing theme flag/prop (e.g.
isClassicTheme or theme.name) and set targetUrl accordingly before calling
window.open.

In
`@web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx`:
- Around line 355-356: The window.open call inside the ChannelTestDialog
component currently uses window.open('/system-settings?tab=ratio', '_blank')
which leaves window.opener available; update that call to include the third
parameter to prevent access from the opened page (e.g. use
window.open('/system-settings?tab=ratio', '_blank', 'noopener') or
'noopener,noreferrer') so the new window cannot access window.opener.

In `@web/default/src/features/playground/components/message-error.tsx`:
- Around line 42-43: The window.open call in message-error.tsx (inside the
component handling the ratio settings link) should include the 'noopener'
feature to prevent the newly opened page from accessing window.opener; update
the window.open('/system-settings?tab=ratio', '_blank') invocation to pass a
features string that includes 'noopener' (e.g. third argument 'noopener' or
'noopener,noreferrer' as appropriate) so the opened page cannot manipulate the
parent window.

In `@web/default/src/i18n/locales/en.json`:
- Line 744: Several entries in en.json were accidentally replaced with Chinese;
restore the English strings so the English locale shows correct UI text. Find
the key "Configure Langfuse LLM observability" (and the other entries that were
changed to Chinese in this file) and replace their values with the original
English phrases, keeping the keys unchanged; after updating, run the
i18n/localization check or build to verify no missing/invalid English strings
remain.

In `@web/default/src/i18n/locales/fr.json`:
- Line 403: The French locale file contains untranslated English strings;
replace the English value for the key "Automatically bind this subscription plan
to new users upon registration" in fr.json (and the duplicate at the other
occurrence) with the correct French translation, ensuring the JSON string
remains valid and preserves surrounding punctuation and spacing; search for the
exact English phrase to find both occurrences and update them to the proper
French text.
- Line 744: The fr.json contains Chinese values instead of French for keys like
"Configure Langfuse LLM observability" (and other occurrences flagged in the
review); update each Chinese string to an accurate French translation for the
corresponding JSON keys (search fr.json for any values containing Chinese
characters or keys shown in the review) so the French locale is fully French,
keep the JSON key names intact, preserve surrounding punctuation/escaping, and
run the i18n/lint check to ensure encoding and formatting remain valid before
committing.

In `@web/default/src/i18n/locales/ja.json`:
- Line 403: Replace the untranslated English values in the Japanese locale JSON:
update the value "Automatically bind this subscription plan to new users upon
registration" to its Japanese translation and update "Initial Subscription Plan"
to its Japanese translation in the ja.json file (they currently appear as
English values); locate the JSON entries by those exact English strings and
replace their values with the correct Japanese text, preserving the JSON key
structure and quoting/commas.
- Line 744: Several values in the Japanese locale file are written in Chinese
(e.g., the value for "Configure Langfuse LLM observability", the Langfuse
settings block around lines 1254–1259, "追踪请求/响应内容", the Langfuse trace
descriptions, and "统计"); update each of those translation values in
web/default/src/i18n/locales/ja.json to proper Japanese equivalents (replace "配置
Langfuse LLM 可观测性" and the other Chinese strings with correct Japanese
translations), keep existing correct entries like "シークレットキー" untouched, and run
your i18n/lint validation to ensure no other non-Japanese strings remain.

In `@web/default/src/i18n/locales/ru.json`:
- Line 403: Two locale entries remain in English and must be translated into
Russian: update the string value for the key "Automatically bind this
subscription plan to new users upon registration" (and the other identical
English key found later in the file) to a proper Russian translation; locate
these keys in ru.json and replace the English text with the Russian equivalent
while keeping the JSON key intact and preserving punctuation and formatting.
- Line 744: Several values in the Russian locale file are still Chinese; replace
any Chinese value strings with proper Russian translations — for example change
the value for the key "Configure Langfuse LLM observability" to a Russian string
like "Настроить наблюдение за LLM Langfuse" and similarly update the other
Chinese-valued entries referenced (the entries around the block at lines
1254–1261, the key at line 1893, the two keys at 3245–3246, and the key at 3371)
so all values in ru.json are Russian.

In `@web/default/src/i18n/locales/vi.json`:
- Line 403: The Vietnamese locale file contains untranslated/mixed-language
entries (e.g., the key whose value is "Automatically bind this subscription plan
to new users upon registration" and other entries flagged at lines referenced in
the review); update those values to proper Vietnamese translations by replacing
the English/Chinese strings in vi.json with their Vietnamese equivalents,
ensuring you modify the exact locale keys shown (use the exact string values as
identifiers to locate entries) and keep the JSON formatting and quotes intact so
the locale file remains valid.

---

Nitpick comments:
In `@common/frontend_theme.go`:
- Around line 99-125: Add table-driven unit tests for MapFrontendPath to cover
exact key mapping, prefix replacement, trailing-slash normalization and
URL-escaped inputs so we catch regressions in the redirect hot path; create a
test table that feeds various inputs to MapFrontendPath (including values that
exercise normalizeMapPath, entries in defaultToClassicMap/classicToDefaultMap
and prefixes in defaultToClassicPrefixes/classicToDefaultPrefixes) and assert
expected outputs for theme="classic" and theme="default", including cases that
should return "" for no-match; include cases for trailing slashes and
percent-encoded paths to validate normalization and prefix handling.

In `@controller/misc.go`:
- Line 123: Assign the result of langfuse_setting.GetLangfuseSetting() to a
local variable (e.g., lf := langfuse_setting.GetLangfuseSetting()) and then use
lf.Enabled && lf.TraceContent for the "langfuse_trace_content" assignment to
avoid calling GetLangfuseSetting() twice and improve readability; update the
expression in the controller/misc.go block that currently uses
langfuse_setting.GetLangfuseSetting() &&
langfuse_setting.GetLangfuseSetting().TraceContent accordingly.

In `@web/default/src/components/langfuse-trace-notice.tsx`:
- Around line 16-18: The translation call in langfuse-trace-notice.tsx uses a
full English sentence as the key; change the t(...) invocation to use a semantic
key like 'langfuse.trace.security_warning' (update the call site in the
component where t(...) is used), then add the corresponding key/value entry to
your locale JSON files for each language (e.g.,
"langfuse.trace.security_warning": "This site uses Langfuse to record user
prompts and other data. Please be aware of security risks."). Ensure the new
semantic key is used consistently wherever this message appears.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f1c76e1a-2de5-4a43-b95b-bd2d5a65b44c

📥 Commits

Reviewing files that changed from the base of the PR and between 9f47e4b and 2fb64e8.

📒 Files selected for processing (31)
  • common/frontend_theme.go
  • controller/misc.go
  • controller/subscription_payment_epay.go
  • controller/subscription_payment_stripe.go
  • controller/telegram.go
  • controller/topup.go
  • controller/topup_stripe.go
  • controller/topup_waffo.go
  • controller/topup_waffo_pancake.go
  • router/web-router.go
  • web/classic/src/components/layout/PageLayout.jsx
  • web/classic/src/context/User/index.jsx
  • web/default/src/components/langfuse-trace-notice.tsx
  • web/default/src/features/auth/hooks/use-auth-redirect.ts
  • web/default/src/features/channels/components/channels-columns.tsx
  • web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx
  • web/default/src/features/keys/index.tsx
  • web/default/src/features/playground/components/message-error.tsx
  • web/default/src/features/usage-logs/index.tsx
  • web/default/src/i18n/locales/_reports/_sync-report.json
  • web/default/src/i18n/locales/_reports/fr.untranslated.json
  • web/default/src/i18n/locales/_reports/ja.untranslated.json
  • web/default/src/i18n/locales/_reports/ru.untranslated.json
  • web/default/src/i18n/locales/_reports/vi.untranslated.json
  • web/default/src/i18n/locales/en.json
  • web/default/src/i18n/locales/fr.json
  • web/default/src/i18n/locales/ja.json
  • web/default/src/i18n/locales/ru.json
  • web/default/src/i18n/locales/vi.json
  • web/default/src/i18n/locales/zh.json
  • web/default/src/routes/_authenticated/route.tsx
💤 Files with no reviewable changes (1)
  • web/classic/src/components/layout/PageLayout.jsx

Comment thread common/frontend_theme.go
Comment thread web/classic/src/context/User/index.jsx Outdated
Comment thread web/classic/src/context/User/index.jsx Outdated
Comment thread web/default/src/features/auth/hooks/use-auth-redirect.ts Outdated
Comment on lines +664 to 666
const targetUrl = `/models/deployments?deployment_id=${deploymentId}`
window.open(targetUrl, '_blank', 'noopener')
}}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Search for the deployments route definition

# Search for route definitions containing "deployments"
rg -n "deployments" --type=ts --type=tsx -g "**/*route*" -g "**/*router*" -C3

Repository: CuzTeam/new-api

Length of output: 87


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Search for explicit path '/models/deployments' =="
rg -n "/models/deployments" -S -g "*.ts" -g "*.tsx" -C2 || true

echo
echo "== Search for path substring 'models/deployments' =="
rg -n "models/deployments" -S -g "*.ts" -g "*.tsx" -C2 || true

echo
echo "== Search for deployment_id usage around deployments route =="
rg -n "deployment_id" -S -g "*.ts" -g "*.tsx" -C2 || true

echo
echo "== Search for route/router definitions referencing 'deployments' =="
rg -n "deployments" -S -g "*.ts" -g "*.tsx" -g "*route*" -g "*router*" -C3 || true

Repository: CuzTeam/new-api

Length of output: 50371


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== deployment_id usage in models UI =="
rg -n "deployment_id" web/default/src/features/models -S -g "*.ts" -g "*.tsx" || true

echo
echo "== '/models/deployments' usage in classic theme =="
rg -n "/models/deployments" -S -g "*.ts" -g "*.tsx" web/classic || true

echo
echo "== deployments route definition files in default theme =="
rg -n "'deployments'|models/deployments|_authenticated/models" -S -g "*.ts" -g "*.tsx" web/default/src/features/models web/default/src -C1 || true

Repository: CuzTeam/new-api

Length of output: 8453


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Inspect default route handler for /_authenticated/models/$section =="
ls -la web/default/src/routes/_authenticated/models || true
wc -l web/default/src/routes/_authenticated/models/\$section.tsx web/default/src/routes/_authenticated/models/index.tsx 2>/dev/null || true
sed -n '1,200p' web/default/src/routes/_authenticated/models/\$section.tsx
echo "----"
sed -n '1,200p' web/default/src/routes/_authenticated/models/index.tsx

echo
echo "== Search for deployment_id usage in the default route chain =="
rg -n "deployment[_-]?id" web/default/src/routes/_authenticated/models -S --glob "*.ts" --glob "*.tsx" || true
rg -n "deployment[_-]?id" web/default/src/features/models -S --glob "*.ts" --glob "*.tsx" || true
rg -n "searchParams|query|location|useSearchParams|useLocation" web/default/src/routes/_authenticated/models/\$section.tsx -S --glob "*.ts" --glob "*.tsx" || true

echo
echo "== Check classic theme for equivalent /models/$section route =="
rg -n "/models/\\$section|/_authenticated/models|models/\\$section" web/classic -S --glob "*.ts" --glob "*.tsx" || true

echo
echo "== Classic theme: direct usage of '/models/deployments' =="
rg -n "/models/deployments" web/classic -S --glob "*.ts" --glob "*.tsx" || true

Repository: CuzTeam/new-api

Length of output: 104


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Inspect default route handler files =="
ls -la web/default/src/routes/_authenticated/models || true

echo
echo "== File: web/default/src/routes/_authenticated/models/\$section.tsx =="
wc -l 'web/default/src/routes/_authenticated/models/$section.tsx' || true
sed -n '1,220p' 'web/default/src/routes/_authenticated/models/$section.tsx'

echo
echo "== File: web/default/src/routes/_authenticated/models/index.tsx =="
wc -l web/default/src/routes/_authenticated/models/index.tsx || true
sed -n '1,220p' web/default/src/routes/_authenticated/models/index.tsx

echo
echo "== Search default route code for deployment_id / query params =="
rg -n "deployment[_-]?id|searchParams|useSearchParams|query\\.|location\\.search" \
  web/default/src/routes/_authenticated/models -S --glob "*.ts" --glob "*.tsx" || true

echo
echo "== Check classic theme for models section route equivalents =="
rg -n "(_authenticated/models|/models/\\$section|/models/deployments)" \
  web/classic -S --glob "*.ts" --glob "*.tsx" || true

echo
echo "== Check if classic theme references deployment_id query param =="
rg -n "deployment[_-]?id" web/classic -S --glob "*.ts" --glob "*.tsx" || true

Repository: CuzTeam/new-api

Length of output: 2781


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Search for 'deployment_id' handling in web/default =="
rg -n "deployment_id" web/default/src -S --glob "*.ts" --glob "*.tsx" || true

echo
echo "== Search for deployment query param usage in web/default (deploymentId / deployment-id) =="
rg -n "deployment[-_]id|deploymentId" web/default/src -S --glob "*.ts" --glob "*.tsx" || true

echo
echo "== Classic theme: search for /models/deployments or models/$section route files =="
rg -n "/models/deployments|_authenticated/models|models/\\$section" web/classic -S --glob "*.ts" --glob "*.tsx" || true

echo
echo "== Classic theme: find any models route definitions (file name patterns) =="
fd -t f -e ts -e tsx -e js -e jsx -a "models" web/classic/src 2>/dev/null | head -n 50 || true

echo
echo "== Default theme: confirm /models/deployments section is registered =="
rg -n "'deployments'|MODELS_SECTION_IDS|models/\\$section|/_authenticated/models" web/default/src/features/models -S --glob "*.ts" --glob "*.tsx" || true

Repository: CuzTeam/new-api

Length of output: 9042


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Classic theme: list route-related files under web/classic/src (shallow) =="
ls -la web/classic/src 2>/dev/null | head || true
fd -t f -a "route" web/classic/src 2>/dev/null | head -n 50 || true

echo
echo "== Classic theme: search for '/models/deployments' usage =="
rg -n "/models/deployments" web/classic/src -S --glob "*.ts" --glob "*.tsx" --glob "*.js" --glob "*.jsx" || true

echo
echo "== Classic theme: search for 'deployments' section under models routes =="
rg -n "models.*deployments|deployments.*models|/models/.*deployments|models/\\$section" \
  web/classic/src -S --glob "*.ts" --glob "*.tsx" --glob "*.js" --glob "*.jsx" || true

echo
echo "== Classic theme: search for deployment_id query handling =="
rg -n "deployment[_-]?id|deploymentId" web/classic/src -S --glob "*.ts" --glob "*.tsx" --glob "*.js" --glob "*.jsx" || true

Repository: CuzTeam/new-api

Length of output: 870


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Default theme: does models UI read deployment_id from URL/search params? =="
rg -n "useSearchParams|useLocation\\(|searchParams|get\\(.*deployment|deployment[_-]?id" \
  web/default/src/features/models -S --glob "*.ts" --glob "*.tsx" || true

echo
echo "== Default theme: does routes/_authenticated/models validate/allow deployment_id? =="
rg -n "validateSearch|modelsSearchSchema|deployment[_-]?id" \
  web/default/src/routes/_authenticated/models -S --glob "*.ts" --glob "*.tsx" || true

echo
echo "== Classic theme: any route/path definition containing '/models' or '/models/' =="
rg -n "\"/models|'/models|/models/:" web/classic/src -S --glob "*.js" --glob "*.jsx" --glob "*.ts" --glob "*.tsx" || true

echo
echo "== Classic theme: any '/models/deployments' literal usage anywhere =="
rg -n "/models/deployments" web/classic/src -S --glob "*.js" --glob "*.jsx" --glob "*.ts" --glob "*.tsx" || true

echo
echo "== Classic theme: any 'deployments' route/section routing =="
rg -n "models.*deployments|deployments.*models|/models.*deployments" \
  web/classic/src -S --glob "*.js" --glob "*.jsx" --glob "*.ts" --glob "*.tsx" || true

Repository: CuzTeam/new-api

Length of output: 2182


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Default theme: inspect Models component to see if it reads search params / deployment_id =="
sed -n '1,240p' web/default/src/features/models/index.tsx
echo "----"
sed -n '1,260p' web/default/src/features/models/components/deployments-table.tsx
echo "----"
rg -n "deployment[_-]?id|useSearchParams|searchParams|location\\.search|query\\." \
  web/default/src/features/models/index.tsx web/default/src/features/models/components/deployments-table.tsx \
  -S --glob "*.ts" --glob "*.tsx" || true

echo
echo "== Classic theme: search for deep-link target and query param usage =="
rg -n "models/deployments" web/classic/src -S --glob "*.js" --glob "*.jsx" --glob "*.ts" --glob "*.tsx" || true
rg -n "deployment[_-]?id" web/classic/src -S --glob "*.js" --glob "*.jsx" --glob "*.ts" --glob "*.tsx" || true

echo
echo "== Classic theme: search for any '/models' strings in routing or navigation =="
rg -n "'/models|\"/models|/models/" web/classic/src -S --glob "*.js" --glob "*.jsx" --glob "*.ts" --glob "*.tsx" || true

echo
echo "== Classic theme: search for models section terms that might indicate routing =="
rg -n "models|deployments" web/classic/src -S --glob "*.js" --glob "*.jsx" --glob "*.ts" --glob "*.tsx" --max-count 200 || true

Repository: CuzTeam/new-api

Length of output: 50372


Fix deep-link behavior for /models/deployments?deployment_id=...

  • In the default theme, /models/deployments resolves to the deployments section, but deployment_id is not handled: the / _authenticated/models/$section search schema and the deployments-table URL state only accept paging/filter fields (so the query param is ignored).
  • In the classic theme, there’s no /models/deployments route usage; deployment deep-links go to /console/deployment?deployment_id=... instead—adjust the target URL per theme if deployment-specific navigation is required.
🤖 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/channels-columns.tsx` around
lines 664 - 666, The deep-link currently always builds targetUrl as
`/models/deployments?deployment_id=${deploymentId}` which the default theme
ignores and the classic theme expects a different path; update the onClick in
ChannelsColumns (where targetUrl and window.open are used) to branch on theme:
if classic theme, open `/console/deployment?deployment_id=${deploymentId}`,
otherwise open a route the default theme will honor (use a path segment with the
id, e.g. `/models/deployments/${deploymentId}` or the app's canonical deployment
route that accepts an id); detect theme via the existing theme flag/prop (e.g.
isClassicTheme or theme.name) and set targetUrl accordingly before calling
window.open.

Comment thread web/default/src/i18n/locales/ja.json Outdated
Comment thread web/default/src/i18n/locales/ja.json Outdated
Comment thread web/default/src/i18n/locales/ru.json Outdated
Comment thread web/default/src/i18n/locales/ru.json Outdated
Comment thread web/default/src/i18n/locales/vi.json Outdated
- Fix /console/deployment mapping to /models/deployments (not /models)
- Fix missing trailing slash in prefix replacements:
  - /dashboard/ -> /console/ (was /console, causing /consolesomething)
  - /console/chat/ -> /playground/ (was /playground, causing /playgroundxxx)
- Fix en.json: replace Chinese translations with English
- Fix fr/ja/ru/vi.json: replace Chinese translations with proper translations
Copy link
Copy Markdown

@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

♻️ Duplicate comments (2)
web/default/src/i18n/locales/ja.json (2)

1877-1877: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Critical: Untranslated English string in Japanese locale.

Line 1877 contains English text that must be translated to Japanese:
"Initial Subscription Plan"

All translation values in ja.json must be in Japanese for users to see the correct language.

Suggested Japanese translation
-    "Initial Subscription Plan": "Initial Subscription Plan",
+    "Initial Subscription Plan": "初期サブスクリプションプラン",
🤖 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/i18n/locales/ja.json` at line 1877, Replace the English value
for the JSON key "Initial Subscription Plan" in ja.json with a Japanese
translation so the Japanese locale contains only Japanese text; locate the entry
with the key "Initial Subscription Plan" (currently: "Initial Subscription
Plan") and change its value to a proper Japanese string such as
"初期サブスクリプションプラン".

403-403: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Critical: Untranslated English string in Japanese locale.

Line 403 contains English text that must be translated to Japanese:
"Automatically bind this subscription plan to new users upon registration"

All translation values in ja.json must be in Japanese for users to see the correct language.

Suggested Japanese translation
-    "Automatically bind this subscription plan to new users upon registration": "Automatically bind this subscription plan to new users upon registration",
+    "Automatically bind this subscription plan to new users upon registration": "登録時に新規ユーザーにこのサブスクリプションプランを自動的に紐付ける",
🤖 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/i18n/locales/ja.json` at line 403, Replace the untranslated
English value for the key "Automatically bind this subscription plan to new
users upon registration" in the ja.json locale with a Japanese translation;
locate the exact string in the file and set its value to a natural Japanese
phrase (e.g., "登録時に新しいユーザーにこのサブスクリプションプランを自動的に紐付ける") so all entries in ja.json
are in Japanese.
🤖 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 `@common/frontend_theme.go`:
- Line 43: The route map is missing an exact reverse mapping for the deployment
path so "/models/deployments" falls through to the generic "/models/" rule; add
an exact entry mapping "/models/deployments" -> "/console/deployment" in the
same routing map (the map that contains the existing "/console/deployment":
"/models/deployments" entry) so requests to "/models/deployments" are rewritten
back to the exact console deployment route rather than the generic models
prefix.

---

Duplicate comments:
In `@web/default/src/i18n/locales/ja.json`:
- Line 1877: Replace the English value for the JSON key "Initial Subscription
Plan" in ja.json with a Japanese translation so the Japanese locale contains
only Japanese text; locate the entry with the key "Initial Subscription Plan"
(currently: "Initial Subscription Plan") and change its value to a proper
Japanese string such as "初期サブスクリプションプラン".
- Line 403: Replace the untranslated English value for the key "Automatically
bind this subscription plan to new users upon registration" in the ja.json
locale with a Japanese translation; locate the exact string in the file and set
its value to a natural Japanese phrase (e.g.,
"登録時に新しいユーザーにこのサブスクリプションプランを自動的に紐付ける") so all entries in ja.json are in
Japanese.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f713274a-ff30-4509-8cb1-ca8233f52fdf

📥 Commits

Reviewing files that changed from the base of the PR and between 2fb64e8 and 1952ed0.

📒 Files selected for processing (7)
  • common/frontend_theme.go
  • web/default/src/i18n/locales/_reports/_sync-report.json
  • web/default/src/i18n/locales/en.json
  • web/default/src/i18n/locales/fr.json
  • web/default/src/i18n/locales/ja.json
  • web/default/src/i18n/locales/ru.json
  • web/default/src/i18n/locales/vi.json

Comment thread common/frontend_theme.go
"/console/midjourney": "/usage-logs",
"/console/task": "/usage-logs",
"/console/models": "/models",
"/console/deployment": "/models/deployments",
Copy link
Copy Markdown

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

Add the missing reverse mapping for deployment routes.

Line 43 adds /console/deployment -> /models/deployments, but there is no exact reverse entry. In classic theme, /models/deployments currently falls through to the generic /models/ prefix and rewrites to /console/models/deployments, which is inconsistent and can send users to the wrong route.

Suggested fix
 var defaultToClassicMap = map[string]string{
 	"/dashboard":        "/console",
 	"/profile":          "/console/personal",
 	"/channels":         "/console/channel",
 	"/keys":             "/console/token",
+	"/models/deployments": "/console/deployment",
 	"/models":           "/console/models",
 	"/usage-logs":       "/console/log",
 	"/system-settings":  "/console/setting",
 	"/playground":       "/console/playground",
 	"/wallet":           "/console/topup",
🤖 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 `@common/frontend_theme.go` at line 43, The route map is missing an exact
reverse mapping for the deployment path so "/models/deployments" falls through
to the generic "/models/" rule; add an exact entry mapping "/models/deployments"
-> "/console/deployment" in the same routing map (the map that contains the
existing "/console/deployment": "/models/deployments" entry) so requests to
"/models/deployments" are rewritten back to the exact console deployment route
rather than the generic models prefix.

- Fix classic UserProvider: use useRef instead of module-scoped mutable
- Fix theme redirect conflict: add startThemeNavigation() API to
  UserContext so PreferencesSettings can signal pending navigation
- Fix use-auth-redirect.ts: use replace() instead of assign() for
  classic theme redirect
- Fix window.open security: add 'noopener' to channel-test-dialog and
  message-error
- Fix controller/misc.go: use local variable for GetLangfuseSetting()
- Fix fr/ja/ru/vi.json: translate 'Automatically bind this subscription
  plan' and 'Initial Subscription Plan' entries
Copy link
Copy Markdown

@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

🤖 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/classic/src/context/User/index.jsx`:
- Around line 37-41: UserContext’s default value is an object but UserProvider
supplies a tuple/array [state, dispatch, startThemeNavigation] and consumers
destructure it as an array; change the UserContext default to the same tuple
shape (e.g., [initialState, () => null, () => {}]) so components using
useContext(UserContext) and array-destructuring (e.g., const [userState]) won’t
throw when rendered outside UserProvider; update the export const UserContext =
React.createContext(...) to provide that array-shaped default matching
UserProvider and referencing initialState and startThemeNavigation names.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4268973f-60c9-49d9-b8c2-dc4851dacedd

📥 Commits

Reviewing files that changed from the base of the PR and between 1952ed0 and d1203ef.

📒 Files selected for processing (11)
  • .gitignore
  • controller/misc.go
  • web/classic/src/components/settings/personal/cards/PreferencesSettings.jsx
  • web/classic/src/context/User/index.jsx
  • web/default/src/features/auth/hooks/use-auth-redirect.ts
  • web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx
  • web/default/src/features/playground/components/message-error.tsx
  • web/default/src/i18n/locales/fr.json
  • web/default/src/i18n/locales/ja.json
  • web/default/src/i18n/locales/ru.json
  • web/default/src/i18n/locales/vi.json
✅ Files skipped from review due to trivial changes (1)
  • .gitignore

Comment on lines 37 to 41
export const UserContext = React.createContext({
state: initialState,
dispatch: () => null,
startThemeNavigation: () => {},
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
FILE="web/classic/src/context/User/index.jsx"
if [ ! -f "$FILE" ]; then
  echo "Missing file: $FILE" >&2
  exit 1
fi
nl -ba "$FILE" | sed -n '1,140p'

Repository: CuzTeam/new-api

Length of output: 102


🏁 Script executed:

#!/bin/bash
set -euo pipefail
FILE="web/classic/src/context/User/index.jsx"

ls -la "$FILE" >/dev/null
echo "=== $FILE (lines 1-120) ==="
sed -n '1,120p' "$FILE"

echo "=== $FILE (lines 60-110) ==="
sed -n '60,110p' "$FILE"

echo "=== $FILE (lines 30-50) ==="
sed -n '30,50p' "$FILE"

Repository: CuzTeam/new-api

Length of output: 4681


🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n "UserContext" web/classic/src | head -n 200

Repository: CuzTeam/new-api

Length of output: 3130


🏁 Script executed:

#!/bin/bash
set -euo pipefail

sed -n '70,110p' web/classic/src/pages/Playground/index.jsx
echo "----"
sed -n '20,70p' web/classic/src/hooks/model-pricing/useModelPricingData.jsx
echo "----"
sed -n '35,80p' web/classic/src/components/layout/PageLayout.jsx

Repository: CuzTeam/new-api

Length of output: 5133


Align UserContext default value with the provider tuple shape.

UserProvider supplies value={[state, dispatch, startThemeNavigation]}, but UserContext’s default is an object. Components destructure it as an array (e.g., const [userState] = useContext(UserContext)), which can throw when rendered outside UserProvider (object is not iterable).

💡 Minimal fix
-export const UserContext = React.createContext({
-  state: initialState,
-  dispatch: () => null,
-  startThemeNavigation: () => {},
-});
+export const UserContext = React.createContext([
+  initialState,
+  () => null,
+  () => {},
+]);
🤖 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/classic/src/context/User/index.jsx` around lines 37 - 41, UserContext’s
default value is an object but UserProvider supplies a tuple/array [state,
dispatch, startThemeNavigation] and consumers destructure it as an array; change
the UserContext default to the same tuple shape (e.g., [initialState, () =>
null, () => {}]) so components using useContext(UserContext) and
array-destructuring (e.g., const [userState]) won’t throw when rendered outside
UserProvider; update the export const UserContext = React.createContext(...) to
provide that array-shaped default matching UserProvider and referencing
initialState and startThemeNavigation names.

…napping

- Fix OAuth window.open calls in default theme (oauth.ts): GitHub,
  Discord, OIDC, LinuxDO
- Fix OAuth window.open in classic theme (api.js): redirectToOAuthUrl
- Fix payment window.open calls: use-waffo-payment, use-payment,
  use-creem-payment, subscription-purchase-dialog
- Fix utility window.open calls: audio-preview-dialog, cc-switch-dialog,
  view-details-dialog, ionet-deployment-settings-section
- Fix classic theme window.open calls: topup, SubscriptionPlansCard,
  CCSwitchModal, AudioPreviewModal, ContentModal, ViewLogsModal,
  ModelTestModal, MessageContent, MarkdownRenderer, useTokensData,
  SettingModelDeployment, Home
@Starry-Sky-World Starry-Sky-World merged commit 3e101f8 into main May 22, 2026
2 of 3 checks passed
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