Skip to content

Fix/auto fetch upstream model tips - #3096

Merged
Calcium-Ion merged 3 commits into
QuantumNous:mainfrom
seefs001:fix/auto-fetch-upstream-model-tips
Mar 3, 2026
Merged

Fix/auto fetch upstream model tips#3096
Calcium-Ion merged 3 commits into
QuantumNous:mainfrom
seefs001:fix/auto-fetch-upstream-model-tips

Conversation

@seefs001

@seefs001 seefs001 commented Mar 3, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Bug Fixes

    • Upstream model update detection now runs when the action is invoked, regardless of a channel’s previous update-enable setting.
  • Improvements

    • Renamed/moved the ignored-models field label to "已忽略模型" in channel settings.
    • Update success messages now show the total count of ignored models alongside added/removed/ignored stats.

@coderabbitai

coderabbitai Bot commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 429b742 and 40c36b1.

📒 Files selected for processing (1)
  • web/src/hooks/channels/useChannelUpstreamUpdates.jsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/src/hooks/channels/useChannelUpstreamUpdates.jsx

Walkthrough

Removed runtime guards that prevented upstream model update detection; UI now invokes detection unconditionally and success messages include total ignored-model counts. Minor struct tag formatting fixes applied to ChannelOtherSettings.

Changes

Cohort / File(s) Summary
Backend Update Logic
controller/channel_upstream_update.go
Removed early-return guard that skipped detection when UpstreamModelUpdateCheckEnabled is false; DetectChannelUpstreamModelUpdates now calls checkAndPersistChannelUpstreamModelUpdates with force=true and allowAutoApply=false unconditionally.
Data Structure Formatting
dto/channel_settings.go
Fixed JSON struct tag formatting (e.g., AllowIncludeObfuscation tag) and reflowed nearby tags — cosmetic only, no API/behavior change.
Frontend Update Detection
web/src/components/table/channels/ChannelsColumnDefs.jsx
Removed runtime early-return when upstreamUpdateMeta.enabled was false; menu action now calls detectChannelUpstreamUpdates(record) whenever the action is invoked (if supported).
Frontend Form Updates
web/src/components/table/channels/modals/EditChannelModal.jsx
Replaced label/location of upstream_model_update_ignored_models input: new label 已忽略模型 and moved placement in form; field name and handler unchanged.
Success Message Enhancement
web/src/hooks/channels/useChannelUpstreamUpdates.jsx
Added helper getManualIgnoredModelCountFromSettings to derive total ignored-model count; success toast now reports total ignored alongside added/removed/ignored deltas.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Frontend
  participant API
  participant Controller
  participant Persistence
  User->>Frontend: Click "Detect upstream model updates"
  Frontend->>API: POST /channels/:id/detect-upstream
  API->>Controller: DetectChannelUpstreamModelUpdates(channelID)
  Controller->>Controller: checkAndPersistChannelUpstreamModelUpdates(force=true, allowAutoApply=false)
  Controller->>Persistence: Read/Write channel update state
  Persistence-->>Controller: Persisted result
  Controller-->>API: Result (added/removed/ignored counts)
  API-->>Frontend: Success payload
  Frontend-->>User: Show toast with added/removed/ignored/totalIgnored
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • QuantumNous/new-api#2971: Edits dto/channel_settings.go (fields like AllowIncludeObfuscation), overlapping the struct-tag formatting changes in this PR.

Poem

🐰 Hopping through code with a curious cheer,
The checks now run whether far or near.
Ignored models counted, their names in view,
Forms rearranged, tags tidy and true.
Channels awaken — updates pass through! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Fix/auto fetch upstream model tips' is vague and does not clearly convey the main changes. The changeset involves removing upstream model update checks and modifying related UI/logic, but the title uses non-descriptive terms like 'tips' that don't accurately reflect the substantial behavioral changes across multiple files. Consider a more specific title that describes the main change, such as 'Remove upstream model update check guards' or 'Always perform upstream model update detection regardless of enabled status'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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 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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@web/src/hooks/channels/useChannelUpstreamUpdates.jsx`:
- Around line 24-39: The function getManualIgnoredModelCountFromSettings can
pass a string into normalizeModelList causing "map is not a function"; update it
to coerce parsed.upstream_model_update_ignored_models into an array before
calling normalizeModelList: extract const raw =
parsed?.upstream_model_update_ignored_models, if raw is a string try
JSON.parse(raw) in a try/catch, if parsedRaw is not an array but is truthy wrap
it as [parsedRaw], and if falsy use [] — then call normalizeModelList on that
array; reference getManualIgnoredModelCountFromSettings and normalizeModelList
when making the change.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e71f5a4 and 429b742.

📒 Files selected for processing (5)
  • controller/channel_upstream_update.go
  • dto/channel_settings.go
  • web/src/components/table/channels/ChannelsColumnDefs.jsx
  • web/src/components/table/channels/modals/EditChannelModal.jsx
  • web/src/hooks/channels/useChannelUpstreamUpdates.jsx
💤 Files with no reviewable changes (2)
  • web/src/components/table/channels/ChannelsColumnDefs.jsx
  • controller/channel_upstream_update.go

Comment on lines +24 to +39
const getManualIgnoredModelCountFromSettings = (settings) => {
let parsed = null;
if (settings && typeof settings === 'object') {
parsed = settings;
} else if (typeof settings === 'string') {
try {
parsed = JSON.parse(settings);
} catch (error) {
parsed = null;
}
}
if (!parsed || typeof parsed !== 'object') {
return 0;
}
return normalizeModelList(parsed.upstream_model_update_ignored_models).length;
};

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

Guard string-form ignored models before normalization.

At Line 38, passing a string directly to normalizeModelList can throw (map is not a function). Coerce to an array first for legacy/malformed payload safety.

Proposed fix
 const getManualIgnoredModelCountFromSettings = (settings) => {
   let parsed = null;
   if (settings && typeof settings === 'object') {
     parsed = settings;
   } else if (typeof settings === 'string') {
@@
   if (!parsed || typeof parsed !== 'object') {
     return 0;
   }
-  return normalizeModelList(parsed.upstream_model_update_ignored_models).length;
+  const rawIgnored = parsed.upstream_model_update_ignored_models;
+  const ignoredModels = Array.isArray(rawIgnored)
+    ? rawIgnored
+    : typeof rawIgnored === 'string'
+      ? rawIgnored.split(',')
+      : [];
+  return normalizeModelList(ignoredModels).length;
 };
📝 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
const getManualIgnoredModelCountFromSettings = (settings) => {
let parsed = null;
if (settings && typeof settings === 'object') {
parsed = settings;
} else if (typeof settings === 'string') {
try {
parsed = JSON.parse(settings);
} catch (error) {
parsed = null;
}
}
if (!parsed || typeof parsed !== 'object') {
return 0;
}
return normalizeModelList(parsed.upstream_model_update_ignored_models).length;
};
const getManualIgnoredModelCountFromSettings = (settings) => {
let parsed = null;
if (settings && typeof settings === 'object') {
parsed = settings;
} else if (typeof settings === 'string') {
try {
parsed = JSON.parse(settings);
} catch (error) {
parsed = null;
}
}
if (!parsed || typeof parsed !== 'object') {
return 0;
}
const rawIgnored = parsed.upstream_model_update_ignored_models;
const ignoredModels = Array.isArray(rawIgnored)
? rawIgnored
: typeof rawIgnored === 'string'
? rawIgnored.split(',')
: [];
return normalizeModelList(ignoredModels).length;
};
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/hooks/channels/useChannelUpstreamUpdates.jsx` around lines 24 - 39,
The function getManualIgnoredModelCountFromSettings can pass a string into
normalizeModelList causing "map is not a function"; update it to coerce
parsed.upstream_model_update_ignored_models into an array before calling
normalizeModelList: extract const raw =
parsed?.upstream_model_update_ignored_models, if raw is a string try
JSON.parse(raw) in a try/catch, if parsedRaw is not an array but is truthy wrap
it as [parsedRaw], and if falsy use [] — then call normalizeModelList on that
array; reference getManualIgnoredModelCountFromSettings and normalizeModelList
when making the change.

@Calcium-Ion
Calcium-Ion merged commit 196f534 into QuantumNous:main Mar 3, 2026
1 check passed
ennnnny pushed a commit to ennnnny/new-api that referenced this pull request Mar 17, 2026
…ream-model-tips

Fix/auto fetch upstream model tips
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