Skip to content

fix: include group in payload for playground - #1232

Merged
Calcium-Ion merged 1 commit into
QuantumNous:alphafrom
RedwindA:fix/playground-group
Jun 16, 2025
Merged

fix: include group in payload for playground#1232
Calcium-Ion merged 1 commit into
QuantumNous:alphafrom
RedwindA:fix/playground-group

Conversation

@RedwindA

@RedwindA RedwindA commented Jun 15, 2025

Copy link
Copy Markdown
Contributor

.

@coderabbitai

coderabbitai Bot commented Jun 15, 2025

Copy link
Copy Markdown
Contributor

Caution

Review failed

Failed to post review comments.

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between af9cc5c and a916080.

📒 Files selected for processing (36)
  • common/database.go (1 hunks)
  • controller/console_migrate.go (1 hunks)
  • controller/misc.go (2 hunks)
  • controller/option.go (2 hunks)
  • controller/redemption.go (5 hunks)
  • controller/setup.go (1 hunks)
  • controller/uptime_kuma.go (2 hunks)
  • dto/openai_request.go (1 hunks)
  • model/ability.go (8 hunks)
  • model/channel.go (2 hunks)
  • model/log.go (7 hunks)
  • model/main.go (10 hunks)
  • model/option.go (0 hunks)
  • model/redemption.go (4 hunks)
  • model/token.go (2 hunks)
  • model/user.go (3 hunks)
  • relay/relay-gemini.go (1 hunks)
  • router/api-router.go (2 hunks)
  • setting/console.go (0 hunks)
  • setting/console_setting/config.go (1 hunks)
  • setting/console_setting/validation.go (1 hunks)
  • web/src/components/layout/NoticeModal.js (1 hunks)
  • web/src/components/settings/DashboardSetting.js (3 hunks)
  • web/src/components/table/RedemptionsTable.js (8 hunks)
  • web/src/components/table/TokensTable.js (4 hunks)
  • web/src/helpers/api.js (1 hunks)
  • web/src/i18n/locales/en.json (3 hunks)
  • web/src/index.css (1 hunks)
  • web/src/pages/Channel/EditChannel.js (2 hunks)
  • web/src/pages/Channel/EditTagModal.js (2 hunks)
  • web/src/pages/Detail/index.js (12 hunks)
  • web/src/pages/Redemption/EditRedemption.js (4 hunks)
  • web/src/pages/Setting/Dashboard/SettingsAPIInfo.js (5 hunks)
  • web/src/pages/Setting/Dashboard/SettingsAnnouncements.js (5 hunks)
  • web/src/pages/Setting/Dashboard/SettingsFAQ.js (9 hunks)
  • web/src/pages/Setting/Dashboard/SettingsUptimeKuma.js (2 hunks)
💤 Files with no reviewable changes (2)
  • model/option.go
  • setting/console.go
🧰 Additional context used
🧬 Code Graph Analysis (14)
model/token.go (1)
model/main.go (1)
  • DB (54-54)
router/api-router.go (2)
controller/console_migrate.go (1)
  • MigrateConsoleSetting (14-103)
controller/redemption.go (1)
  • DeleteInvalidRedemption (229-244)
web/src/pages/Channel/EditTagModal.js (5)
web/src/pages/Redemption/EditRedemption.js (1)
  • handleInputChange (54-56)
web/src/pages/Channel/EditChannel.js (1)
  • handleInputChange (111-171)
web/src/pages/Token/EditToken.js (1)
  • handleInputChange (72-74)
web/src/pages/User/EditUser.js (1)
  • handleInputChange (59-61)
web/src/helpers/utils.js (2)
  • showSuccess (128-130)
  • showInfo (132-134)
web/src/components/table/TokensTable.js (9)
web/src/components/table/RedemptionsTable.js (1)
  • Typography (53-53)
web/src/components/table/LogsTable.js (1)
  • Typography (53-53)
web/src/components/table/TaskLogsTable.js (1)
  • Typography (51-51)
web/src/components/table/MjLogsTable.js (1)
  • Typography (65-65)
web/src/pages/Home/index.js (1)
  • Typography (12-12)
web/src/components/auth/PasswordResetConfirm.js (1)
  • Typography (8-8)
web/src/components/auth/PasswordResetForm.js (1)
  • Typography (9-9)
web/src/components/table/UsersTable.js (1)
  • Typography (52-52)
web/src/components/settings/SystemSetting.js (1)
  • Typography (14-14)
web/src/pages/Channel/EditChannel.js (2)
web/src/pages/Channel/EditTagModal.js (1)
  • handleInputChange (56-103)
web/src/helpers/utils.js (2)
  • showSuccess (128-130)
  • showInfo (132-134)
controller/option.go (1)
setting/console_setting/validation.go (1)
  • ValidateConsoleSettings (61-78)
model/ability.go (2)
model/main.go (1)
  • DB (54-54)
common/logger.go (1)
  • SysError (55-58)
model/channel.go (2)
model/main.go (1)
  • DB (54-54)
common/database.go (1)
  • UsingMySQL (12-12)
controller/redemption.go (2)
model/redemption.go (1)
  • DeleteInvalidRedemptions (191-195)
common/utils.go (1)
  • GetTimestamp (191-193)
model/log.go (2)
model/main.go (1)
  • DB (54-54)
model/token.go (1)
  • Token (13-30)
web/src/pages/Setting/Dashboard/SettingsAPIInfo.js (4)
web/src/pages/Setting/Dashboard/SettingsUptimeKuma.js (2)
  • updateOption (124-136)
  • handleToggleEnabled (268-285)
web/src/pages/Setting/Dashboard/SettingsAnnouncements.js (2)
  • updateOption (165-177)
  • handleToggleEnabled (306-323)
web/src/pages/Setting/Dashboard/SettingsFAQ.js (2)
  • updateOption (113-125)
  • handleToggleEnabled (243-260)
web/src/helpers/utils.js (2)
  • showSuccess (128-130)
  • showError (93-122)
setting/console_setting/validation.go (2)
relay/channel/baidu/dto.go (1)
  • Error (26-29)
setting/console_setting/config.go (1)
  • GetConsoleSetting (37-39)
web/src/pages/Setting/Dashboard/SettingsAnnouncements.js (2)
web/src/pages/Setting/Dashboard/SettingsFAQ.js (2)
  • updateOption (113-125)
  • handleToggleEnabled (243-260)
web/src/helpers/utils.js (2)
  • showSuccess (128-130)
  • showError (93-122)
web/src/pages/Setting/Dashboard/SettingsUptimeKuma.js (3)
web/src/pages/Setting/Dashboard/SettingsAPIInfo.js (6)
  • loading (40-40)
  • columns (222-298)
  • updateOption (74-86)
  • handleToggleEnabled (203-220)
  • handleBatchDelete (300-311)
  • renderHeader (313-367)
web/src/pages/Setting/Dashboard/SettingsFAQ.js (6)
  • loading (38-38)
  • columns (51-111)
  • updateOption (113-125)
  • handleToggleEnabled (243-260)
  • handleBatchDelete (262-273)
  • renderHeader (275-326)
web/src/helpers/utils.js (2)
  • showSuccess (128-130)
  • showError (93-122)
🔇 Additional comments (13)
model/token.go (1)

69-70: Verify commonKeyCol is defined and imported

The query now relies on commonKeyCol, but that symbol isn’t declared in this file. If it lives elsewhere, ensure it’s exported and imported to avoid a compile break.

web/src/components/table/TokensTable.js (1)

17-27: Import additions resolve previous runtime errors – LGTM

Tag, Divider, and Typography were previously referenced but never imported, causing the component to crash at run-time.
The added imports close that gap and do not introduce any side-effects.

model/user.go (1)

178-189: Confirm commonGroupCol is defined in the build scope

The query now concatenates commonGroupCol, replacing groupCol.
If commonGroupCol isn’t declared in the same package (or imported via model/main.go), this will cause a compilation error (undefined: commonGroupCol). Double-check that the constant is exported and in scope.

router/api-router.go (1)

84-85: Temporary migration endpoint left enabled – ensure it’s removed or guarded

/api/option/migrate_console_setting is annotated “下个版本会删除”. History shows such TODOs frequently linger.

Consider:

  1. Compiling the route only under a build tag (// +build debug) or
  2. Introducing an environment-flag guard so it cannot be hit in production accidentally.

Otherwise root tokens that leak can still trigger a one-way data transformation.

model/redemption.go (1)

135-137: Edge-case: redemption expiring exactly at current timestamp

< common.GetTimestamp() rejects only strictly older codes; a code with expired_time == now is accepted.

If the intention is “expiry is inclusive”, use <=.

web/src/pages/Redemption/EditRedemption.js (1)

229-247: Double-check DatePicker value type & timezone assumptions

@douyinfe/semi-ui DatePicker returns a Date instance when valueType="date" (default) but can return string when valueType is customised.
Since you call value.getTime(), make sure value is always Date; otherwise this explodes at runtime.

If unsure, explicitly set valueType="date" or guard the cast:

-                        const timestamp = Math.floor(value.getTime() / 1000);
+                        const timestamp = Math.floor(
+                          (value instanceof Date ? value : new Date(value)).getTime() / 1000
+                        );
model/ability.go (2)

75-83: Nice use of sub-query but remember GORM re-use

Good consolidation of max-priority selection into a sub-query and the retry path – concise and performant.


129-138: 👍 Deduplication map eliminates duplicate ability rows

The abilitySet map prevents UNIQUE conflicts and unnecessary inserts. Clean and effective.

model/log.go (2)

64-71: Verify logKeyCol resolves to “key” for Token model

Token’s column is literally key. If logKeyCol expands to something else, this lookup will fail and break /logs/by-key queries.

Please confirm the constant value or revert to the literal.


230-255: Map-based de-duplication removes n² scan – good optimisation

Switching from slice to map[int]struct{} for channelIds eliminates duplicate checks and scales linearly. 👍

controller/redemption.go (1)

246-251: Validation helper looks good

validateExpiredTime correctly blocks past timestamps and allows 0 to mean “never”.

web/src/pages/Detail/index.js (2)

586-590: loadUptimeData re-creates on every tab change

Because activeUptimeTab is in the dependency array, the callback identity flips after every setActiveUptimeTab, defeating memoisation and forcing downstream re-renders.
Unless the function genuinely depends on the previous tab value, remove it from the deps:

-}, [activeUptimeTab]);
+}, []);       // stable reference

947-953: Possible percentage overflow in Progress bar

(monitor.uptime || 0) * 100 assumes uptime is a 0-1 ratio. If backend already returns a percentage (e.g. 99.9) the result exceeds 100 and Semi UI silently caps it. Confirm the data contract or normalise here.

Walkthrough

This update introduces a comprehensive migration and refactor of console settings management, moving from legacy flat option keys to a structured console_setting configuration with JSON-encoded fields and enablement flags. The backend adds migration logic, validation, and new API endpoints for managing these settings, while the frontend updates all related UI components to support toggling panels, editing structured data, and handling legacy data migration. Additional improvements include enhanced redemption code expiration handling, refined database column consistency, and UI/UX enhancements for tokens and uptime monitoring.

Changes

File(s) Change Summary
common/database.go, model/main.go, model/ability.go, model/channel.go, model/log.go, model/token.go, model/user.go Standardized database column and type constants, improved query consistency, and enabled separate tracking for log/main DB.
controller/console_migrate.go, controller/option.go, controller/misc.go, controller/setup.go, controller/uptime_kuma.go, controller/redemption.go Added migration for legacy console settings, refactored option handling to new keys, added validation and endpoints for redemption code expiration and invalid code deletion, and modularized uptime status fetching.
dto/openai_request.go Added VlHighResolutionImages field for Ali Qwen params.
model/redemption.go Added ExpiredTime field, expiration validation, and invalid redemption cleanup logic.
model/option.go Removed legacy console setting keys from option map initialization.
relay/relay-gemini.go Cleaned up empty Gemini system instructions before sending requests.
router/api-router.go Added endpoints for migrating console settings and deleting invalid redemptions.
setting/console.go Deleted legacy console setting validation and retrieval logic.
setting/console_setting/config.go, setting/console_setting/validation.go Introduced new structured config and validation for console settings, including getter and validator functions for each panel.
web/src/components/layout/NoticeModal.js, web/src/index.css Switched scrollbar styling to CSS class for notice content and reorganized scrollbar hiding rules.
web/src/components/settings/DashboardSetting.js Added legacy data migration detection and modal for migrating old console settings.
web/src/components/table/RedemptionsTable.js, web/src/pages/Redemption/EditRedemption.js Added redemption code expiration column, UI, and logic for handling expired codes and batch deletion of invalid codes.
web/src/components/table/TokensTable.js Added informational section explaining token usage above tokens table.
web/src/helpers/api.js Added group field to API payload construction.
web/src/i18n/locales/en.json Expanded translations for uptime monitoring, token, and redemption management.
web/src/pages/Channel/EditChannel.js, web/src/pages/Channel/EditTagModal.js Improved custom model addition to skip duplicates and provide user feedback.
web/src/pages/Detail/index.js Modularized info panel rendering, added feature flags, tabbed uptime groups, and improved empty state illustration.
web/src/pages/Setting/Dashboard/SettingsAPIInfo.js, web/src/pages/Setting/Dashboard/SettingsAnnouncements.js, web/src/pages/Setting/Dashboard/SettingsFAQ.js, web/src/pages/Setting/Dashboard/SettingsUptimeKuma.js Refactored all dashboard panels to use new structured keys, added enable/disable toggles, and enhanced Uptime Kuma to support multiple groups with full CRUD UI.

Sequence Diagram(s)

Console Settings Migration Flow

sequenceDiagram
    participant User
    participant WebApp
    participant API
    participant Controller
    participant DB

    User->>WebApp: Detects legacy console keys
    WebApp->>User: Shows migration modal
    User->>WebApp: Confirms migration
    WebApp->>API: POST /api/option/migrate_console_setting
    API->>Controller: MigrateConsoleSetting
    Controller->>DB: Fetch all options
    Controller->>Controller: Parse and migrate legacy keys
    Controller->>DB: Save new structured keys, delete old keys
    Controller->>API: Respond success
    API->>WebApp: Migration result
    WebApp->>User: Notify migration success/failure
Loading

Redemption Code Expiration and Cleanup

sequenceDiagram
    participant Admin
    participant WebApp
    participant API
    participant Controller
    participant DB

    Admin->>WebApp: Clicks "Clear Invalid Redemption Codes"
    WebApp->>API: DELETE /api/redemption/invalid
    API->>Controller: DeleteInvalidRedemption
    Controller->>DB: Delete used, disabled, or expired codes
    Controller->>API: Return deleted count
    API->>WebApp: Show result
    WebApp->>Admin: Notify cleanup complete
Loading

Uptime Kuma Multi-Group Fetch

sequenceDiagram
    participant User
    participant WebApp
    participant API
    participant Controller
    participant UptimeKuma

    User->>WebApp: View status page
    WebApp->>API: GET /api/uptime_kuma_status
    API->>Controller: GetUptimeKumaStatus
    loop For each group
        Controller->>UptimeKuma: Fetch status & heartbeat (parallel)
        UptimeKuma->>Controller: Return group data
    end
    Controller->>API: Return all group statuses
    API->>WebApp: Render uptime panels/tabs
Loading

Poem

A hop, a skip, a leap through time,
Old keys are gone, new panels shine!
Settings migrate, codes expire,
Dashboards toggle at your desire.
Uptime groups now tab and play,
The rabbit cheers: "Hip-hip-hooray!" 🐇✨
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@RedwindA
RedwindA changed the base branch from main to alpha June 15, 2025 17:13
@RedwindA RedwindA changed the title Fix/playground-group fix: include group in payload for playground Jun 15, 2025
@Calcium-Ion
Calcium-Ion merged commit 4674390 into QuantumNous:alpha Jun 16, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Sep 29, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Dec 25, 2025
x22x22 pushed a commit to x22x22/new-api that referenced this pull request Apr 24, 2026
fix: include group in payload for playground
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