Skip to content

alpha -> main - #1865

Merged
12 commits merged into
mainfrom
alpha
Sep 29, 2025
Merged

alpha -> main#1865
12 commits merged into
mainfrom
alpha

Conversation

@seefs001

@seefs001 seefs001 commented Sep 22, 2025

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Bug Fixes

    • Corrected WeChat and Telegram binding displays and action labels when account data is missing.
  • UX Improvements

    • Unified account binding presentation for consistent display.
  • New Features

    • Optional site analytics snippet can be injected via environment configuration.
    • Enabled a configurable "Allow promotion codes" option for Stripe checkout with corresponding UI toggle and translations.
  • Refactor

    • Simplified account state checks to reduce edge-case issues.

@coderabbitai

coderabbitai Bot commented Sep 22, 2025

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@seefs001 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 40 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between a498da7 and ffc0774.

📒 Files selected for processing (4)
  • dto/gemini.go (1 hunks)
  • relay/channel/gemini/relay-gemini.go (3 hunks)
  • web/src/components/table/channels/modals/EditChannelModal.jsx (7 hunks)
  • web/src/components/table/task-logs/modals/ContentModal.jsx (1 hunks)

Walkthrough

Adds optional chaining and unified account rendering in AccountManagement.jsx; injects an Umami analytics script into served HTML at runtime via an <analytics></analytics> placeholder using UMAMI env vars; introduces a Stripe promotion-codes toggle propagated through settings, model, and checkout session AllowPromotionCodes.

Changes

Cohort / File(s) Summary of Changes
Settings — account bindings
web/src/components/settings/personal/cards/AccountManagement.jsx
Replaced direct property access with optional chaining for wechat_id and telegram_id; uses renderAccountInfo(userState.user?.wechat_id, t('微信 ID')) and consistent rendering; bind-button labels use optional chaining; no public signature changes.
Server — analytics injection
main.go
Added runtime construction/injection of an Umami analytics <script> using UMAMI_WEBSITE_ID and optional UMAMI_SCRIPT_URL env vars; builds script tag and replaces <analytics></analytics>\n placeholder in served index page; added bytes and strings imports.
Web — analytics placeholder
web/index.html
Inserted an <analytics></analytics> tag in the <head> to be replaced by server injection at runtime.
Stripe — promotion code toggle (backend)
controller/topup_stripe.go, model/option.go, setting/payment_stripe.go
Added exported StripePromotionCodesEnabled setting; new option key handled in InitOptionMap/updateOptionMap; controller/topup_stripe.go sets AllowPromotionCodes on Stripe Checkout session from setting.StripePromotionCodesEnabled.
Stripe — promotion code toggle (frontend & i18n)
web/src/pages/Setting/Payment/SettingsPaymentGatewayStripe.jsx, web/src/components/settings/PaymentSetting.jsx, web/src/i18n/locales/en.json, web/src/i18n/locales/zh.json
Added StripePromotionCodesEnabled to inputs state and initialization; submit logic includes option change serialization ('true'/'false'); UI switch control added to Stripe settings page; English and Chinese translation keys added.

Sequence Diagram(s)

sequenceDiagram
    participant Server
    participant Env as Environment
    participant Template as index.html (template)
    participant Client

    Note over Server,Env: Server startup / request-time preparation
    Server->>Env: read UMAMI_WEBSITE_ID, UMAMI_SCRIPT_URL
    alt UMAMI_WEBSITE_ID present
        Server->>Server: build <script data-website-id="..."> tag (using UMAMI_SCRIPT_URL or default)
    else no UMAMI_WEBSITE_ID
        Server->>Server: skip analytics injection
    end
    Server->>Template: load HTML template (contains <analytics></analytics>)
    alt script built
        Server->>Template: replace "<analytics></analytics>\n" with script tag
    end
    Server->>Client: serve final HTML
Loading
sequenceDiagram
    participant AdminUI as Admin UI (Settings)
    participant API as Backend API
    participant Options as Option Store / model
    participant StripeCtrl as topup_stripe controller
    participant Stripe as Stripe API

    AdminUI->>API: submit Stripe settings (StripePromotionCodesEnabled = true/false)
    API->>Options: update option "StripePromotionCodesEnabled" -> "true"/"false"
    Note over StripeCtrl,Options: When creating checkout session
    StripeCtrl->>Options: read setting StripePromotionCodesEnabled
    StripeCtrl->>Stripe: create Checkout Session with AllowPromotionCodes = <setting>
    Stripe->>StripeCtrl: return session
    StripeCtrl->>AdminUI: respond with session info / redirect
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • creamlike1024
  • Calcium-Ion

Poem

A rabbit hopped through code at night,
Optional chains made checks polite.
Analytics tucked in head so sly,
Promotion toggles waved goodbye.
Thump-thump — the deploy hops by. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title Check ⚠️ Warning The title “alpha -> main” merely indicates a branch merge and does not summarize any of the actual feature changes in the pull request, such as the analytics injection, optional chaining updates, or Stripe promotion code support, making it misleading and uninformative. Please update the title to a concise description of the primary changes, for example “Add Umami analytics injection and Stripe promotion code support,” or split the pull request into separate, focused PRs each with its own descriptive title.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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 (1)
web/src/components/settings/personal/cards/AccountManagement.jsx (1)

183-183: Fix redundant user existence check.

The condition userState.user && userState.user?.wechat_id is redundant since optional chaining already handles the null/undefined case. The userState.user check is unnecessary.

Apply this diff to simplify the condition:

-                      {userState.user && userState.user?.wechat_id
+                      {userState.user?.wechat_id
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7c27558 and b692452.

📒 Files selected for processing (1)
  • web/src/components/settings/personal/cards/AccountManagement.jsx (3 hunks)
🔇 Additional comments (2)
web/src/components/settings/personal/cards/AccountManagement.jsx (2)

168-171: LGTM! Consistent use of optional chaining and renderAccountInfo utility.

The WeChat display implementation now consistently uses optional chaining and leverages the renderAccountInfo utility function, which provides a standardized way to display account information with proper fallback handling and popover functionality.


302-302: LGTM! Proper use of optional chaining.

The Telegram binding check correctly uses optional chaining, which is consistent with the other changes in this file and provides safe property access.

feat: support UMAMI analytics

@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 (1)
main.go (1)

164-164: Make the analytics placeholder replacement resilient to line-ending differences.

bytes.ReplaceAll is searching for <analytics></analytics>\n. If the embedded web/dist/index.html happens to be written with Windows-style \r\n (which Vite or manual edits can produce), the placeholder never matches and Umami is silently skipped. Please switch to a newline-agnostic replacement so the feature keeps working regardless of how the file was generated.

Apply this diff to make the replacement resilient:

-	indexPage = bytes.ReplaceAll(indexPage, []byte("<analytics></analytics>\n"), []byte(analyticsInject))
+	indexPage = bytes.ReplaceAll(indexPage, []byte("<analytics></analytics>\r\n"), []byte(analyticsInject+"\r\n"))
+	indexPage = bytes.ReplaceAll(indexPage, []byte("<analytics></analytics>\n"), []byte(analyticsInject+"\n"))
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b692452 and 79859a3.

📒 Files selected for processing (2)
  • main.go (3 hunks)
  • web/index.html (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Push Docker image to multiple registries

@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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 79859a3 and a498da7.

📒 Files selected for processing (7)
  • controller/topup_stripe.go (1 hunks)
  • model/option.go (2 hunks)
  • setting/payment_stripe.go (1 hunks)
  • web/src/components/settings/PaymentSetting.jsx (1 hunks)
  • web/src/i18n/locales/en.json (1 hunks)
  • web/src/i18n/locales/zh.json (1 hunks)
  • web/src/pages/Setting/Payment/SettingsPaymentGatewayStripe.jsx (4 hunks)
✅ Files skipped from review due to trivial changes (1)
  • web/src/i18n/locales/zh.json
🧰 Additional context used
🧬 Code graph analysis (3)
controller/topup_stripe.go (1)
setting/payment_stripe.go (1)
  • StripePromotionCodesEnabled (8-8)
model/option.go (2)
common/constants.go (1)
  • OptionMap (36-36)
setting/payment_stripe.go (1)
  • StripePromotionCodesEnabled (8-8)
web/src/pages/Setting/Payment/SettingsPaymentGatewayStripe.jsx (1)
web/src/components/settings/PaymentSetting.jsx (1)
  • inputs (30-49)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Push Docker image to multiple registries
🔇 Additional comments (6)
controller/topup_stripe.go (1)

228-230: LGTM! Clean integration of promotion codes feature.

The implementation correctly integrates the new StripePromotionCodesEnabled setting into the Stripe Checkout session configuration. The code follows established patterns in the codebase and properly sources the configuration from the setting module.

setting/payment_stripe.go (1)

8-8: LGTM! Proper initialization of new configuration variable.

The new StripePromotionCodesEnabled variable is correctly declared with a sensible default value of false, following the established pattern for other Stripe-related configuration variables in this file.

web/src/components/settings/PaymentSetting.jsx (1)

48-48: LGTM! Consistent addition to input state.

The new StripePromotionCodesEnabled field is properly added to the inputs state with the correct default value (false) and follows the established naming convention for other Stripe-related settings.

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

840-840: LGTM! Clear and descriptive translation key.

The English translation for the Stripe promotion codes feature is clear, descriptive, and follows the established pattern for other UI strings in the localization file.

model/option.go (2)

85-85: LGTM! Proper initialization in option map.

The new StripePromotionCodesEnabled option is correctly added to the initialization map using the appropriate boolean-to-string conversion function, consistent with other boolean settings in the codebase.


334-335: LGTM! Correct option handling logic.

The option update logic properly handles the new StripePromotionCodesEnabled setting by converting the string value to boolean and assigning it to the appropriate setting variable, following the established pattern for other boolean configuration options.

Comment on lines +67 to 71
StripePromotionCodesEnabled:
props.options.StripePromotionCodesEnabled !== undefined
? props.options.StripePromotionCodesEnabled
: false,
};

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 | 🔴 Critical

Fix: Normalize StripePromotionCodesEnabled to a boolean before binding

submitStripeSetting stores the option as the strings 'true'/'false', but here we feed that raw value back into Form.Switch. Semi UI treats any non-empty string as truthy, so an option saved as 'false' renders the switch ON and makes it impossible to reflect the real state. Coerce the value to an actual boolean when hydrating currentInputs.

-        StripePromotionCodesEnabled:
-          props.options.StripePromotionCodesEnabled !== undefined
-            ? props.options.StripePromotionCodesEnabled
-            : false,
+        StripePromotionCodesEnabled:
+          props.options.StripePromotionCodesEnabled !== undefined
+            ? typeof props.options.StripePromotionCodesEnabled === 'string'
+              ? props.options.StripePromotionCodesEnabled.toLowerCase() === 'true'
+              : !!props.options.StripePromotionCodesEnabled
+            : false,
📝 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
StripePromotionCodesEnabled:
props.options.StripePromotionCodesEnabled !== undefined
? props.options.StripePromotionCodesEnabled
: false,
};
StripePromotionCodesEnabled:
props.options.StripePromotionCodesEnabled !== undefined
? typeof props.options.StripePromotionCodesEnabled === 'string'
? props.options.StripePromotionCodesEnabled.toLowerCase() === 'true'
: !!props.options.StripePromotionCodesEnabled
: false,
🤖 Prompt for AI Agents
In web/src/pages/Setting/Payment/SettingsPaymentGatewayStripe.jsx around lines
67 to 71, the StripePromotionCodesEnabled value is passed raw (sometimes the
string 'true'/'false') into Form.Switch; coerce it to a real boolean when
hydrating currentInputs by checking for the boolean true or the string 'true'
(e.g. set StripePromotionCodesEnabled =
props.options.StripePromotionCodesEnabled === true ||
props.options.StripePromotionCodesEnabled === 'true', otherwise false) so the
switch reflects the actual saved state.

seefs001 and others added 4 commits September 27, 2025 16:16
feat: if video cannot play open in a new tab
feat: add duplicate key removal function when edit or add new channel
@seefs001 seefs001 closed this pull request by merging all changes into main in a91f3e7 Sep 29, 2025
jiutubaba pushed a commit to jiutubaba/fx-api that referenced this pull request May 17, 2026
The hardcoded codex CLI version (0.104.0) causes upstream rejection
when using gpt-5.5 with compact, as the server treats the request
as an outdated client and returns 400/502.

Update codexCLIVersion, codexCLIUserAgent, and openAICodexProbeVersion
to 0.125.0 to match the current Codex CLI release.

Fixes QuantumNous#1933, QuantumNous#1887, QuantumNous#1865
Related: QuantumNous#1609, QuantumNous#1298, QuantumNous#849
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.

5 participants