Skip to content

fix: add warning for pass through body - #2512

Merged
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
seefs001:fix/warning-pass-through-body
Dec 26, 2025
Merged

fix: add warning for pass through body#2512
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
seefs001:fix/warning-pass-through-body

Conversation

@seefs001

@seefs001 seefs001 commented Dec 24, 2025

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Added visual warning indicators for channels with request pass-through enabled, displaying an alert icon with explanatory tooltip.
    • Added a global warning banner alerting users when request pass-through is enabled system-wide.
  • Documentation

    • Added multi-language support (English, French, Japanese, Russian, Vietnamese, Chinese) for pass-through related warnings, informing users that enabling pass-through disables certain built-in features.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Dec 24, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The pull request introduces request pass-through feature detection and user-facing warnings. It adds channel-level pass-through status checks in the channels table, conditionally displays alert icons next to channel names, adds a global pass-through warning banner, and expands localization strings across multiple languages to communicate that pass-through disables built-in NewAPI features.

Changes

Cohort / File(s) Summary
Channel UI Components
web/src/components/table/channels/ChannelsColumnDefs.jsx, web/src/components/table/channels/index.jsx
Added channel-level pass-through detection with alert icon and tooltip in NAME column; added global pass-through warning banner with localized description and icon import (IconAlertTriangle).
State Management
web/src/hooks/channels/useChannelsData.jsx
Introduced globalPassThroughEnabled state; added fetchGlobalPassThroughEnabled function to fetch global.pass_through_request_enabled option via API with toBoolean conversion; exposed new state in hook return.
Localization
web/src/i18n/locales/{en,fr,ja,ru,vi,zh}.json
Added three new translation keys (channel-level, global-level, and short-form pass-through warnings) across seven locale files describing that pass-through disables built-in NewAPI features and recommending against issue submission.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A rabbit hops through channels with care,
Warning of pass-through everywhere!
Icons and banners in shades of caution,
Translations aligned—quite the commotion.
NewAPI features yield to the light,
Pass-through awareness, done just right! 🚨

Pre-merge checks and finishing touches

✅ 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 accurately describes the main change: adding warning UI elements (alert indicators and banners) for pass-through features across channels and global settings.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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.

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

🧹 Nitpick comments (4)
web/src/i18n/locales/en.json (1)

843-845: Pass‑through warnings read clearly; consider minor wording polish and naming consistency

The three strings are technically accurate and clearly communicate that enabling pass‑through disables New API’s built‑in features and is not recommended. Two small, optional tweaks you might consider:

  • Consistency: elsewhere this file uses “New API” (with a space, e.g., “New API project repository address”), while these new strings use “NewAPI”. Aligning on a single product name spelling would look more polished.
  • Tone (optional only): “If this causes issues, please do not submit an issue.” is fairly direct. If you want a softer UX without changing meaning, something like “we can’t provide support for issues caused by this configuration” might feel less confrontational while still discouraging bug reports for self‑inflicted breakage.

If you’re happy with the existing tone and naming, the current strings are already serviceable.

web/src/i18n/locales/vi.json (1)

799-801: Vietnamese translations correctly mirror the new warnings; optional naming alignment

The three Vietnamese lines accurately reflect the intent and detail of the source strings (channel vs global pass‑through, disabled built‑in features, non‑recommended usage, and no‑support note). No functional issues here.

If you decide to standardize the product name spelling in other locales (e.g., “New API” vs “NewAPI” in English), you may want to mirror that convention here as well for cross‑language consistency, but that’s purely cosmetic.

web/src/components/table/channels/ChannelsColumnDefs.jsx (1)

42-46: Pass-through detection helper and NAME column warning behavior are correct, with one small enhancement to consider

  • isRequestPassThroughEnabled(record) defensively handles missing records, tag rows (children), object vs JSON-string setting, and JSON parse failures; this is a good, low-risk helper.
  • NAME column now reuses the existing remark tooltip as nameNode and, when pass-through is enabled, decorates it with an alert icon and a separate explanatory tooltip, which is a clean UX.
  • Tag rows correctly skip pass-through evaluation via the children !== undefined guard.

One small potential hardening: if record.setting may contain pass_through_body_enabled as a non-boolean (e.g., "true" or 1), the strict === true check will ignore it. If that’s possible from your API, consider normalizing via the same toBoolean helper used elsewhere in the app for options before comparing.

Also applies to: 194-214, 248-305

web/src/hooks/channels/useChannelsData.jsx (1)

29-30: Global pass-through flag fetching and exposure look correct

  • Importing toBoolean and using it in fetchGlobalPassThroughEnabled against /api/option/ with key global.pass_through_request_enabled is a reasonable way to normalize the stored value into a boolean.
  • Errors or malformed responses safely fall back to false without impacting the rest of the hook.
  • The initial useEffect wires this fetch once on mount, and globalPassThroughEnabled is cleanly exposed in the returned object for ChannelsPage to consume.

If you ever need the banner to react live to changes made in other admin screens without a full page reload, you could optionally call fetchGlobalPassThroughEnabled inside refresh or after relevant mutations—but the current one-shot load is fine for most admin flows.

Also applies to: 89-91, 92-108, 164-165, 1051-1052

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 12555a3 and 09f3957.

📒 Files selected for processing (9)
  • web/src/components/table/channels/ChannelsColumnDefs.jsx
  • web/src/components/table/channels/index.jsx
  • web/src/hooks/channels/useChannelsData.jsx
  • web/src/i18n/locales/en.json
  • web/src/i18n/locales/fr.json
  • web/src/i18n/locales/ja.json
  • web/src/i18n/locales/ru.json
  • web/src/i18n/locales/vi.json
  • web/src/i18n/locales/zh.json
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-08-27T02:15:25.448Z
Learnt from: AAEE86
Repo: QuantumNous/new-api PR: 1658
File: web/src/components/table/channels/modals/EditChannelModal.jsx:555-569
Timestamp: 2025-08-27T02:15:25.448Z
Learning: In EditChannelModal.jsx, the applyModelMapping function transforms the models list by replacing original model names (mapping values) with display names (mapping keys). The database stores this transformed list containing mapped keys. On channel load, data.models contains these mapped display names, making the initialization filter if (data.models.includes(key)) correct.

Applied to files:

  • web/src/hooks/channels/useChannelsData.jsx
📚 Learning: 2025-08-27T02:15:25.448Z
Learnt from: AAEE86
Repo: QuantumNous/new-api PR: 1658
File: web/src/components/table/channels/modals/EditChannelModal.jsx:555-569
Timestamp: 2025-08-27T02:15:25.448Z
Learning: In EditChannelModal.jsx, the database stores mapped keys (display names) in the models field after applying model mapping transformations. When loading a channel, data.models contains the mapped keys, not the original model names. The filtering logic if (data.models.includes(key)) in the initialization is correct.

Applied to files:

  • web/src/hooks/channels/useChannelsData.jsx
🧬 Code graph analysis (2)
web/src/components/table/channels/index.jsx (1)
web/src/components/table/channels/ChannelsTable.jsx (1)
  • channelsData (30-63)
web/src/hooks/channels/useChannelsData.jsx (1)
web/src/helpers/api.js (6)
  • res (224-224)
  • res (225-225)
  • res (301-301)
  • res (302-302)
  • API (29-37)
  • API (29-37)
🔇 Additional comments (5)
web/src/i18n/locales/zh.json (1)

833-835: LGTM! Pass-through warning translations added.

Three new Chinese translation keys have been added for pass-through functionality warnings. The keys serve different UI contexts (channel-specific vs. global, with/without issue submission guidance), which justifies having separate entries despite content similarity.

The translations clearly communicate that enabling pass-through will disable NewAPI's built-in features and advise users not to file issues related to this choice.

web/src/i18n/locales/fr.json (1)

851-853: LGTM! French translations align with source locale.

The three French translation keys mirror the Chinese locale additions and maintain consistent messaging about pass-through functionality warnings. The translations appropriately convey:

  • Channel-level and global pass-through scope
  • Impact on NewAPI built-in features
  • Guidance about issue reporting

The localization is properly integrated and ready for use.

web/src/i18n/locales/ru.json (1)

860-862: Pass-through warning translations look accurate and consistent

The Russian strings correctly capture the intent of the Chinese originals and match the keys referenced from the UI (banner and per-channel tooltip). No issues from an i18n or interpolation standpoint.

web/src/components/table/channels/index.jsx (1)

21-23: Global pass-through banner integration looks solid

Using channelsData.globalPassThroughEnabled to gate the Banner and pulling the description via channelsData.t with the dedicated i18n key is straightforward and keeps the concern localized to this page. Icon usage and simple spacing via style={{ marginBottom: 12 }} are also fine.

Also applies to: 68-83

web/src/i18n/locales/ja.json (1)

799-801: Japanese pass-through warnings are well-localized

The three new Japanese messages accurately reflect the Chinese source strings, including the “not best practice” guidance and the note about not filing issues if problems arise. Keys align with those used in the channels table and global banner.

@Calcium-Ion
Calcium-Ion merged commit c722ddd into QuantumNous:main Dec 26, 2025
1 check passed
ennnnny pushed a commit to ennnnny/new-api that referenced this pull request Mar 17, 2026
…rough-body

fix: add warning for pass through body
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