Skip to content

sync(upstream): 10 commits from upstream - #91

Open
clyang82 wants to merge 10 commits into
mainfrom
sync/upstream-32c261923a97-9a8674425c5a
Open

clyang82 wants to merge 10 commits into
mainfrom
sync/upstream-32c261923a97-9a8674425c5a

Conversation

@clyang82

Copy link
Copy Markdown

Upstream Sync: 10 Commits

Upstream Commits

SHA Intent Type Risk
32c261923a97 Improve 503 'no available channel' error to name the claiming task plugin and suggest disabling/overriding it when a plugin-owned model has no enabled channel, keeping the generic message otherwise. bugfix medium
3a9f41ee85cc Temporarily disables the Claude token-counting endpoint by commenting out the POST /messages/count_tokens route registration (and deleting its router test), taking the endpoint offline until controller.CountClaudeTokens is fixed. breaking high
7c044d7c5c2d Rebuilds model-name post-processing around an explicit trailing @key:value modifier syntax (thinking/effort/temperature/topp) with family-whitelisted legacy alias parsing and a canonical billing-identity resolution ladder in ModelPriceHelper; drops the OpenRouter host-invented '-thinking' alias (explicitly breaking). breaking high
6b659fd61c50 Stop implicitly rewriting/parsing thinking-suffix model names when a model is configured to preserve its suffix, so the user's reasoning effort passes through unchanged across DeepSeek, OpenAI, Volcengine, xAI, Claude, and Gemini adaptors. bugfix medium
d5803532bdcc Add contributor/agent guidance requiring new built-in model prices to be defined as self-contained billing expressions in setting/billing_setting/builtin_billing.go (real USD per million tokens) instead of legacy ratio tables, preserving admin overrides and mandating coverage of context-length thresholds and cache categories. internal low
eb99ab1b4034 Introduce built-in expression-based billing defaults (including pricing for the new gpt-6-astra model) and expose the effective billing mode/expression maps through the admin options endpoint, even when not explicitly persisted. feature medium
2cf177ac487e Performance optimization: add a jinzhu/copier TypeConverter to common.DeepCopy so json.RawMessage fields are bulk-copied via bytes.Clone instead of byte-by-byte reflection, with comprehensive regression tests for request cloning. refactor medium
49ec46966825 Fix OpenAI chat capability detection so gpt-5+ generation models (e.g., gpt-6-astra) get max_completion_tokens conversion and unsupported-parameter (temperature/top_p/logprobs) stripping instead of matching only the literal 'gpt-5' prefix bugfix medium
d8cb177440ce Add a dedicated security center with access-token status/rotation/revocation plus persisted audit logging, audit.read authorization, and an audit log viewer, while upgrading the ClickHouse driver. feature medium
9a8674425c5a Prevent redundant schema migrations on application restart by upgrading the SQLite GORM driver and normalizing dialect-specific type/default metadata during migration comparison. bugfix medium

Affected Surfaces

  • ApplyReasoningModelSuffix (signature changed: now takes gin.Context)
  • ClickHouse driver v2.46.0
  • ConvertOpenAIRequest
  • EffortTailModelIDs (config escape hatch for in-family IDs)
  • GET /api/access_token/status
  • GET /api/audit
  • GET /api/audit/self
  • GetSystemRoleName
  • IsOpenAIGPT5Model
  • Legacy -thinking/-nothinking/-thinking-<budget>/effort aliases now restricted to gpt-*/o-series/claude-*/gemini-* families
  • Model name @key:value modifier syntax (new wire-level contract on request model field: thinking/effort/temperature/topp)
  • ModelPriceHelper billing-identity ladder (pricing/billing behavior change)
  • OpenRouter '-thinking' model alias (removed — BREAKING, needs model-mapping migration)
  • POST /api/access_token/revoke
  • POST /v1/messages/count_tokens (HTTP route removed; controller.CountClaudeTokens no longer wired into the router)
  • Thinking-suffix blacklist supporting re:-prefixed Go regex entries (config semantics)
  • audit_log database schema/events with role snapshot and JSON metadata
  • authz resource audit.read
  • billing_setting.GetBillingExprCopy
  • billing_setting.GetBillingModeCopy
  • billing_setting.billing_expr (option key)
  • billing_setting.billing_mode (option key)
  • buildTestRequest
  • common.DeepCopy
  • controller.GetAccessTokenStatus
  • controller.GetAuditLogs
  • controller.RevokeAccessToken
  • convdiag conversion diagnostics collector (new relayconvert package)
  • database schema migration behavior
  • distributor 503 error response text for plugin-claimed models
  • frontend route /security
  • frontend route /usage-logs/audit
  • github.com/glebarez/sqlite (v1.9.0 -> v1.11.0)
  • i18n distributor message constants (new plugin-specific no-available-channel key)
  • model.AuditLogFilter
  • model.GetUserAccessTokenStatus
  • model.RevokeUserAccessToken
  • model.ValidAuditCategory
  • model.ValidTokenFingerprint
  • model_setting.ShouldPreserveThinkingSuffix
  • openai.ModelList entry 'gpt-6-astra'
  • ratio_setting.RoutingMatchModelName (renamed from FormatMatchingModelName)
  • reasoning suffix parsing/remapping behavior (relaykit/relayconvert/reasoning)
  • sidebar module keys for security and audit logs
  • thinking-suffix model naming convention (preserve-suffix config key)
  • tokenModelLimitAllows (new middleware helper for token model limits)

Transformations Applied

Downstream File Confidence Notes
i18n/keys.go high upstream diff applied directly via git apply
i18n/locales/en.yaml high upstream diff applied directly via git apply
i18n/locales/zh-CN.yaml high upstream diff applied directly via git apply
i18n/locales/zh-TW.yaml high upstream diff applied directly via git apply
middleware/distributor.go high upstream diff applied directly via git apply
middleware/distributor_test.go high upstream diff applied directly via git apply
router/relay-router.go high upstream diff applied directly via git apply
router/relay_router_test.go high upstream diff applied directly via git apply
controller/channel-test.go high upstream diff applied directly via git apply
controller/model.go high upstream diff applied directly via git apply
middleware/distributor.go high upstream diff applied directly via git apply
middleware/distributor_test.go high upstream diff applied directly via git apply
model/channel_cache.go high upstream diff applied directly via git apply
model/channel_satisfy.go high upstream diff applied directly via git apply
relay/channel/claude/adaptor_test.go high upstream diff applied directly via git apply
relay/channel/claude/relay_claude_test.go high upstream diff applied directly via git apply
relay/channel/openai/adaptor.go high upstream diff applied directly via git apply
relay/claude_handler.go high upstream diff applied directly via git apply
relay/common/relay_info.go high upstream diff applied directly via git apply
relay/common/relay_info_test.go high upstream diff applied directly via git apply
relay/compatible_handler.go high upstream diff applied directly via git apply
relay/convert_request_error_test.go high upstream diff applied directly via git apply
relay/gemini_handler.go high upstream diff applied directly via git apply
relay/helper/model_mapped.go high upstream diff applied directly via git apply
relay/helper/model_modifier.go high upstream diff applied directly via git apply
relay/helper/price.go high upstream diff applied directly via git apply
relay/helper/reasoning_suffix.go high upstream diff applied directly via git apply
relay/responses_handler.go high upstream diff applied directly via git apply
relaykit/relayconvert/internal/convdiag/collector.go high upstream diff applied directly via git apply
relaykit/relayconvert/internal/oai_chat/to_claude_messages_req.go high upstream diff applied directly via git apply
relaykit/relayconvert/internal/oai_responses/to_claude_messages_req.go high upstream diff applied directly via git apply
relaykit/relayconvert/internal/shared/claude/reasoning.go high upstream diff applied directly via git apply
relaykit/relayconvert/internal/shared/gemini/request.go high upstream diff applied directly via git apply
relaykit/relayconvert/reasoning/claude.go high upstream diff applied directly via git apply
relaykit/relayconvert/reasoning/suffix.go high upstream diff applied directly via git apply
relaykit/relayconvert/reasoning/suffix_test.go high upstream diff applied directly via git apply
relaykit/relayconvert/request_compat.go high upstream diff applied directly via git apply
relaykit/relayconvert/request_registry.go high upstream diff applied directly via git apply
setting/model_setting/global_test.go high upstream diff applied directly via git apply
setting/ratio_setting/matching_test.go high upstream diff applied directly via git apply
setting/ratio_setting/model_ratio.go high upstream diff applied directly via git apply
setting/reasoning/suffix.go high upstream diff applied directly via git apply
setting/reasoning/suffix_test.go high upstream diff applied directly via git apply
web/src/features/system-settings/models/global-settings-card.tsx high upstream diff applied directly via git apply
setting/model_setting/global.go high The downstream file already contains the upstream pre-change ShouldPreserveThinkingSuffix verbatim, so the regex-blacklist replacement applies directly. The direct apply failed only because downstream's import block carries two extra fork imports (relayconvert/reasoning, ratio_setting) and downstream's struct fields were already gofmt-aligned (upstream's realignment hunk didn't match). I added fmt/regexp/sync and the common package to the import block, inserted the EffortTailModelIDs doc comment while keeping downstream's existing field alignment (no reformatting of unrelated lines), and replaced ShouldPreserveThinkingSuffix with the cached compiled exact+regex version. The downstream-specific ShouldPreserveEffortTail (reasoning.TrimEffortSuffixWithSuffixes / ratio_setting.IsRegisteredModel) is untouched since the visible upstream diff does not modify it. common.SysError exists at the unchanged module path. (applied 3 targeted edits)
web/src/i18n/locales/en.json medium The upstream diff is mostly alphabetical re-sorting plus a few new keys. Applied only the net additions visible in the diff: 'Boolean' (placed after 'Body param'; downstream has a fork-added 'AstraFlow' key between 'Body param' and 'Border radius', which is why the hunk failed), 'Choose another file', 'Choose file', and 'Drop a JavaScript plugin file here'. The pure-reorder hunks ('Bind task plugins', 'Built-in v / marketplace v' / 'Updates with the system', 'Disable task plugins?') were skipped because those keys do not exist downstream at all — a move has zero net effect, and adding them would introduce unreferenced keys. Note: the upstream diff was truncated mid-line on 'Drop a JavaScript plugin f...'; I completed it as 'Drop a JavaScript plugin file here' following this file's key==value convention, so that single entry is lower confidence. There may also be additional upstream changes past the truncation point that could not be applied. (applied 4 targeted edits)
relay/channel/deepseek/adaptor.go high upstream diff applied directly via git apply
relay/channel/openai/adaptor.go high upstream diff applied directly via git apply
relay/channel/volcengine/adaptor.go high upstream diff applied directly via git apply
relay/channel/xai/adaptor.go high upstream diff applied directly via git apply
relay/common/relay_info.go high upstream diff applied directly via git apply
relay/helper/model_modifier.go high upstream diff applied directly via git apply
relay/helper/reasoning_suffix.go high upstream diff applied directly via git apply
relaykit/relayconvert/internal/shared/claude/reasoning.go high upstream diff applied directly via git apply
relaykit/relayconvert/internal/shared/gemini/request.go high upstream diff applied directly via git apply
relaykit/relayconvert/reasoning/intent.go high upstream diff applied directly via git apply
relaykit/relayconvert/reasoning/intent_test.go high upstream diff applied directly via git apply
AGENTS.md high upstream diff applied directly via git apply
relay/channel/openai/constant.go high upstream diff applied directly via git apply
setting/billing_setting/builtin_billing.go high upstream diff applied directly via git apply
setting/billing_setting/builtin_billing_test.go high upstream diff applied directly via git apply
setting/billing_setting/tiered_billing.go high upstream diff applied directly via git apply
controller/option.go high The apply failed only because the downstream import block differs (no strconv, extra pluginruntime/setting imports) — the GetOptions body matches upstream context. Applied the four upstream hunks verbatim: added the slices import, extended the theme.frontend skip to the two billing_setting keys, replaced the manual loop with slices.Contains, and appended the effective billing mode/expr options after the OptionMap iteration. billing_setting and common.Marshal are already imported/used downstream, so no additional adaptation was needed. (applied 4 targeted edits)
common/copy.go high upstream diff applied directly via git apply
relay/request_clone_test.go high upstream diff applied directly via git apply
controller/channel_test_request_test.go high upstream diff applied directly via git apply
relay/channel/openai/adaptor.go high upstream diff applied directly via git apply
relaykit/dto/openai_request.go high upstream diff applied directly via git apply
relaykit/dto/openai_request_zero_value_test.go high upstream diff applied directly via git apply
controller/access_token.go high upstream diff applied directly via git apply
controller/access_token_audit_test.go high upstream diff applied directly via git apply
controller/audit.go high upstream diff applied directly via git apply
controller/billing_option_test.go high upstream diff applied directly via git apply
controller/channel_task_plugin_bind_test.go high upstream diff applied directly via git apply
controller/channel_test_internal_test.go high upstream diff applied directly via git apply
controller/model_list_test.go high upstream diff applied directly via git apply
controller/relay.go high upstream diff applied directly via git apply
controller/secure_verification.go high upstream diff applied directly via git apply
controller/subscription.go high upstream diff applied directly via git apply
controller/twofa.go high upstream diff applied directly via git apply
controller/user.go high upstream diff applied directly via git apply
controller/user_manage_test.go high upstream diff applied directly via git apply
go.sum high upstream diff applied directly via git apply
middleware/audit.go high upstream diff applied directly via git apply
middleware/auth.go high upstream diff applied directly via git apply
middleware/auth_test.go high upstream diff applied directly via git apply
model/audit_log.go high upstream diff applied directly via git apply
model/audit_other.go high upstream diff applied directly via git apply
model/main.go high upstream diff applied directly via git apply
router/plugin_router_test.go high upstream diff applied directly via git apply
service/authz/authz_test.go high upstream diff applied directly via git apply
service/authz/resources_audit.go high upstream diff applied directly via git apply
web/src/components/layout/components/mobile-drawer.tsx high upstream diff applied directly via git apply
web/src/components/profile-dropdown.tsx high upstream diff applied directly via git apply
web/src/features/auth/secure-verification/components/secure-verification-dialog.tsx high upstream diff applied directly via git apply
web/src/features/profile/__tests__/settings.test.tsx high upstream diff applied directly via git apply
web/src/features/profile/api.ts high upstream diff applied directly via git apply
web/src/features/profile/components/__tests__/login-session-utils.test.ts high upstream diff applied directly via git apply
web/src/features/profile/components/dialogs/access-token-dialog.tsx high upstream diff applied directly via git apply
web/src/features/profile/components/dialogs/change-password-dialog.tsx high upstream diff applied directly via git apply
web/src/features/profile/components/dialogs/delete-account-dialog.tsx high upstream diff applied directly via git apply
web/src/features/profile/components/dialogs/email-bind-dialog.tsx high upstream diff applied directly via git apply
web/src/features/profile/components/dialogs/telegram-bind-dialog.tsx high upstream diff applied directly via git apply
web/src/features/profile/components/dialogs/two-fa-backup-dialog.tsx high upstream diff applied directly via git apply
web/src/features/profile/components/dialogs/two-fa-disable-dialog.tsx high upstream diff applied directly via git apply
web/src/features/profile/components/dialogs/two-fa-setup-dialog.tsx high upstream diff applied directly via git apply
web/src/features/profile/components/dialogs/wechat-bind-dialog.tsx high upstream diff applied directly via git apply
web/src/features/profile/components/login-session-dialogs.tsx high upstream diff applied directly via git apply
web/src/features/profile/components/login-session-item.tsx high upstream diff applied directly via git apply
web/src/features/profile/components/login-session-utils.ts high upstream diff applied directly via git apply
web/src/features/profile/components/login-sessions-card.tsx high upstream diff applied directly via git apply
web/src/features/profile/components/passkey-card.tsx high upstream diff applied directly via git apply
web/src/features/profile/components/profile-security-card.tsx high upstream diff applied directly via git apply
web/src/features/profile/components/profile-settings-card.tsx high upstream diff applied directly via git apply
web/src/features/profile/components/sidebar-modules-card.tsx high upstream diff applied directly via git apply
web/src/features/profile/components/two-fa-card.tsx high upstream diff applied directly via git apply
web/src/features/profile/hooks/index.ts high upstream diff applied directly via git apply
web/src/features/profile/hooks/use-access-token.ts high upstream diff applied directly via git apply
web/src/features/profile/hooks/use-two-fa.ts high upstream diff applied directly via git apply
web/src/features/profile/lib/user-settings.ts high upstream diff applied directly via git apply
web/src/features/profile/types.ts high upstream diff applied directly via git apply
web/src/features/security/__tests__/page.test.tsx high upstream diff applied directly via git apply
web/src/features/security/api.ts high upstream diff applied directly via git apply
web/src/features/security/components/__tests__/access-token-card.test.tsx high upstream diff applied directly via git apply
web/src/features/security/components/__tests__/login-session-utils.test.ts high upstream diff applied directly via git apply
web/src/features/security/components/__tests__/privacy-card.test.tsx high upstream diff applied directly via git apply
web/src/features/security/components/access-token-card.tsx high upstream diff applied directly via git apply
web/src/features/security/components/account-action-card.tsx high upstream diff applied directly via git apply
web/src/features/security/components/account-bindings.tsx high upstream diff applied directly via git apply
web/src/features/security/components/dialogs/access-token-dialog.tsx high upstream diff applied directly via git apply
web/src/features/security/components/dialogs/change-password-dialog.tsx high upstream diff applied directly via git apply
web/src/features/security/components/dialogs/delete-account-dialog.tsx high upstream diff applied directly via git apply
web/src/features/security/components/dialogs/email-bind-dialog.tsx high upstream diff applied directly via git apply
web/src/features/security/components/dialogs/telegram-bind-dialog.tsx high upstream diff applied directly via git apply
web/src/features/security/components/dialogs/two-fa-backup-dialog.tsx high upstream diff applied directly via git apply
web/src/features/security/components/dialogs/two-fa-disable-dialog.tsx high upstream diff applied directly via git apply
web/src/features/security/components/dialogs/two-fa-setup-dialog.tsx high upstream diff applied directly via git apply
web/src/features/security/components/dialogs/wechat-bind-dialog.tsx high upstream diff applied directly via git apply
web/src/features/security/components/login-session-dialogs.tsx high upstream diff applied directly via git apply
web/src/features/security/components/login-session-item.tsx high upstream diff applied directly via git apply
web/src/features/security/components/login-session-utils.ts high upstream diff applied directly via git apply
web/src/features/security/components/login-sessions-card.tsx high upstream diff applied directly via git apply
web/src/features/security/components/passkey-card.tsx high upstream diff applied directly via git apply
web/src/features/security/components/privacy-card.tsx high upstream diff applied directly via git apply
web/src/features/security/components/two-fa-card.tsx high upstream diff applied directly via git apply
web/src/features/security/hooks/use-access-token.ts high upstream diff applied directly via git apply
web/src/features/security/hooks/use-two-fa.ts high upstream diff applied directly via git apply
web/src/features/security/index.tsx high upstream diff applied directly via git apply
web/src/features/system-settings/maintenance/config.ts high upstream diff applied directly via git apply
web/src/features/system-settings/maintenance/sidebar-modules-section.tsx high upstream diff applied directly via git apply
web/src/features/usage-logs/audit/__tests__/details.test.tsx high upstream diff applied directly via git apply
web/src/features/usage-logs/audit/__tests__/viewer.test.tsx high upstream diff applied directly via git apply
web/src/features/usage-logs/audit/api.ts high upstream diff applied directly via git apply
web/src/features/usage-logs/audit/components/audit-detail-fields.tsx high upstream diff applied directly via git apply
web/src/features/usage-logs/audit/components/audit-detail-value.tsx high upstream diff applied directly via git apply
web/src/features/usage-logs/audit/components/audit-log-columns.tsx high upstream diff applied directly via git apply
web/src/features/usage-logs/audit/components/audit-log-details-dialog.tsx high upstream diff applied directly via git apply
web/src/features/usage-logs/audit/components/audit-log-filter-bar.tsx high upstream diff applied directly via git apply
web/src/features/usage-logs/audit/components/audit-log-viewer.tsx high upstream diff applied directly via git apply
web/src/features/usage-logs/audit/index.tsx high upstream diff applied directly via git apply
web/src/features/usage-logs/audit/lib/audit-details.ts high upstream diff applied directly via git apply
web/src/features/usage-logs/components/__tests__/log-type-filter.test.tsx high upstream diff applied directly via git apply
web/src/features/usage-logs/components/common-logs-filter-bar.tsx high upstream diff applied directly via git apply
web/src/features/usage-logs/components/compact-date-time-range-picker.tsx high upstream diff applied directly via git apply
web/src/features/usage-logs/components/dialogs/details-dialog.tsx high upstream diff applied directly via git apply
web/src/features/usage-logs/components/dialogs/log-detail-layout.tsx high upstream diff applied directly via git apply
web/src/features/usage-logs/constants.ts high upstream diff applied directly via git apply
web/src/features/usage-logs/index.tsx high upstream diff applied directly via git apply
web/src/features/usage-logs/lib/format.ts high upstream diff applied directly via git apply
web/src/features/users/components/__tests__/permissions.test.tsx high upstream diff applied directly via git apply
web/src/features/users/components/users-mutate-drawer.tsx high upstream diff applied directly via git apply
web/src/hooks/__tests__/sidebar-config.test.tsx high upstream diff applied directly via git apply
web/src/hooks/use-sidebar-config.ts high upstream diff applied directly via git apply
web/src/i18n/static-keys.ts high upstream diff applied directly via git apply
web/src/lib/__tests__/http-cache.test.ts high upstream diff applied directly via git apply
web/src/lib/admin-permissions.ts high upstream diff applied directly via git apply
web/src/lib/auth-session.ts high upstream diff applied directly via git apply
web/src/lib/http-client.ts high upstream diff applied directly via git apply
web/src/routes/_authenticated/security/index.tsx high upstream diff applied directly via git apply
web/src/routes/_authenticated/usage-logs/audit.tsx high upstream diff applied directly via git apply
go.mod high The patch failed only because the downstream indirect-require block contains fork-added entries (KyleBanks/depth, gorilla/sessions, smartwalle/*, etc.) that break the upstream hunk context. Every version bump and the go.yaml.in/yaml/v3 insertion maps 1:1 to lines present in the downstream file; each old line is unique. The new go.yaml.in/yaml/v3 entry is inserted after go.opentelemetry.io/otel/trace, matching the upstream placement. No fork conventions conflict — go.mod is shared sync surface. (applied 11 targeted edits)
router/api-router.go high The apply failed only because upstream's context differs slightly: downstream refactored SetApiRouter into registerApiRoutes (called for the /api, /api/v1, /api/v2 triple prefix), but the route bodies are otherwise identical. Applied all four upstream hunks at their corresponding downstream locations: (1) AccessTokenAudit middleware after gzip inside registerApiRoutes — note this makes it run for all three prefix registrations, matching upstream's single /api group semantics; (2) DisableCache() added to selfRoute.Use; (3) new token status/POST/DELETE self routes inserted after the existing GET /token; (4) audit routes added immediately before the /log group, as upstream. authz is already imported downstream (used by authz.TaskPluginBind and authz.ChannelWrite), so no import change is needed. Assumed controller.GetAccessTokenStatus / RevokeAccessToken / GetAuditLogs, middleware.AccessTokenAudit, and authz.AuditRead are added by other files in the same upstream commit. (applied 4 targeted edits)
router/main.go medium Upstream added middleware.AccessTokenAudit() to the NoRoute redirect chain after middleware.RouteTag("web"). Downstream diverged: the route tag is set inline via c.Set(middleware.RouteTagKey, "web") inside the final handler, and a fork-added relayV1CompatRedirect middleware sits between pluginDispatcher and the handler. Applied the same intent by inserting middleware.AccessTokenAudit() into the NoRoute middleware chain, positioned just before the final redirect handler so it runs after routing/tagging and before the redirect, mirroring upstream's ordering. Assumes middleware.AccessTokenAudit() is (or will be) provided by the rest of this upstream feature port. (applied 1 targeted edits)
router/web-router.go high The upstream intent is to insert middleware.AccessTokenAudit() between the gzip handler and GlobalWebRateLimit in the NoRoute middleware chain. The apply failed because the downstream chain has an extra relayV1CompatRedirect line (fork-specific), shifting context. The relevant lines are identical downstream, so the middleware is inserted at the same logical position. This assumes middleware.AccessTokenAudit exists (or will be added by other files in this commit) in the downstream middleware package. (applied 1 targeted edits)
web/src/features/profile/index.tsx high Upstream moved the security-related cards (ProfileSecurityCard, LoginSessionsCard, PasskeyCard, TwoFACard) out of the profile page into the new dedicated /security center. Downstream had fork-specific gating around PasskeyCard (SHOW_PASSKEY_CARD flag + explanatory comment) and SidebarModulesCard; the passkey card is removed entirely per upstream intent, so the SHOW_PASSKEY_CARD import is dropped too (SHOW_SIDEBAR_MODULES_CARD stays since SidebarModulesCard remains). The SHOW_PASSKEY_CARD constant itself can be cleaned up later in features/profile/constants.ts, which is outside this file's scope. The Passkey/WebAuthn and 2FA components/backends remain intact — only their placement on the profile page changes, matching the upstream move to the security center. (applied 3 targeted edits)
web/src/hooks/use-sidebar-data.ts high The patch failed because downstream drifted context: Task Logs has extra activeUrls/configUrls lines and the Personal group starts with Wallet. The import { type SidebarData } → import type part of the upstream diff is already applied downstream, so it was skipped. Inserted the two new icon imports (ClipboardList, ShieldCheck) alphabetically in the same positions, added the 'Audit Logs' sidebar item after 'Usage Logs' in the General group, and added 'Security & Access' after 'Profile' in the Personal group — matching the upstream intent exactly. No role gating is added since upstream added none and the backend enforces authorization. (applied 4 targeted edits)
web/src/routeTree.gen.ts medium The apply failed due to context drift: downstream has extra fork routes (plugins, ops/campaign, ops/invite-history) that shifted line numbers, but the insertion anchors exist verbatim. Applied the upstream intent — registering the new '/security/' and '/usage-logs/audit' routes — via 8 targeted edits: 2 imports, 2 route const definitions, and entries in FileRoutesByFullPath and FileRoutesByTo. CAVEAT: the downstream file view is truncated at line 553 of 1437; the upstream diff also adds entries to FileRoutesById, the routeTree/rootRouteChildren registration, and possibly addChildren calls, which live beyond the visible region and could not be edited per the truncation rule. Since this is a TanStack Router auto-generated file, running the route codegen (e.g. the TanStack Router plugin/CLI on dev/build) after adding the new route files will regenerate these sections consistently; alternatively a follow-up manual edit is needed to add AuthenticatedSecurityIndexRoute and AuthenticatedUsageLogsAuditRoute to FileRoutesById and the root route children. (applied 8 targeted edits)
AGENTS.md high upstream diff applied directly via git apply
go.mod high upstream diff applied directly via git apply
go.sum high upstream diff applied directly via git apply
model/main.go high upstream diff applied directly via git apply
model/migration_dialector.go high upstream diff applied directly via git apply
model/migration_dialector_test.go high upstream diff applied directly via git apply
model/user_session_migration_test.go high upstream diff applied directly via git apply

⚠️ Conflicts

  • relay/helper/price_test.go (): Resolve call failed: Anthropic API error after 3 retries:
<title>504 Gateway Time-out</title>

504 Gateway Time-out

- **`relay/helper/reasoning_suffix_test.go`** (): Resolve call failed: Anthropic API error after 3 retries: <title>504 Gateway Time-out</title>

504 Gateway Time-out

- **`web/src/i18n/locales/fr.json`** (entire file web/src/i18n/locales/fr.json (absent downstream by design)): Upstream modified web/src/i18n/locales/fr.json, but this fork intentionally deleted all fr/ru/ja/vi locales during the CubeRouter rebrand (supported set is en/zh/zh-TW only, and conventions forbid restoring them). A human should confirm this file is simply skipped/excluded from the sync rather than recreated. No content needs to be applied. - **`web/src/i18n/locales/ja.json`** (): resolve returned neither edits nor content - **`web/src/i18n/locales/ru.json`** (): resolve returned neither edits nor content - **`web/src/i18n/locales/vi.json`** (): resolve returned neither edits nor content - **`web/src/i18n/locales/zh-TW.json`** (): Resolve call failed: Anthropic API error after 3 retries: <title>504 Gateway Time-out</title>

504 Gateway Time-out

- **`web/src/i18n/locales/zh.json`** (): Resolve call failed: Anthropic API error after 3 retries: <title>504 Gateway Time-out</title>

504 Gateway Time-out

- **`model/log.go`** (): Resolve call failed: Anthropic API error after 3 retries: <title>504 Gateway Time-out</title>

504 Gateway Time-out

- **`model/user.go`** (): Resolve call failed: Anthropic API error after 3 retries: <title>504 Gateway Time-out</title>

504 Gateway Time-out

- **`web/src/features/profile/components/tabs/account-bindings-tab.tsx`** (entire file (upstream: full deletion); fork-specific region: DialogKey type, PhoneBindDialog import, phone binding item in the bindings useMemo, Phone Bind Dialog JSX): Upstream deleted account-bindings-tab.tsx (bindings UI relocated in the security-center restructure), but the downstream copy contains fork-only phone-binding code (PhoneBindDialog, 'phone' DialogKey, phone binding row with Change/Bound logic) backing the ported campaign system's phone_filled trigger. A human must: (1) locate the new upstream home of the account bindings UI, (2) re-add the phone binding entry and PhoneBindDialog wiring there using the fork's profile.phone accessor pattern, (3) confirm no remaining imports of this file (profile tabs index, dialogs), then (4) delete this file. Do NOT delete it before step (2), or the phone_filled campaign trigger loses its only UI entry point. - **`web/src/features/profile/components/tabs/notification-tab.tsx`** (): Resolve call failed: Anthropic API error after 3 retries: <title>504 Gateway Time-out</title>

504 Gateway Time-out

- **`web/src/i18n/locales/en.json`** (): LLM edits did not apply: edit 4: 'old' block not found in file: ' "All requests must include": "All requests must include",\\n "All Status": ' - **`web/src/i18n/locales/fr.json`** (): resolve returned neither edits nor content - **`web/src/i18n/locales/ja.json`** (): resolve returned neither edits nor content - **`web/src/i18n/locales/ru.json`** (): resolve returned neither edits nor content - **`web/src/i18n/locales/vi.json`** (): resolve returned neither edits nor content - **`web/src/i18n/locales/zh-TW.json`** (): Resolve call failed: Anthropic API error after 3 retries: <title>504 Gateway Time-out</title>

504 Gateway Time-out

- **`web/src/i18n/locales/zh.json`** (): Resolve call failed: Anthropic API error after 3 retries: <title>504 Gateway Time-out</title>

504 Gateway Time-out

❌ Unresolved Build Failures

  • relay/helper/price_test.go: Resolve call failed: Anthropic API error after 3 retries:
<title>504 Gateway Time-out</title>

504 Gateway Time-out

— _Suggestion: Resolve manually — see the conflict summary in this PR._ - **`relay/helper/reasoning_suffix_test.go`**: Resolve call failed: Anthropic API error after 3 retries: <title>504 Gateway Time-out</title>

504 Gateway Time-out

— _Suggestion: Resolve manually — see the conflict summary in this PR._ - **`web/src/i18n/locales/fr.json`**: Upstream modified web/src/i18n/locales/fr.json, but this fork intentionally deleted all fr/ru/ja/vi locales during the CubeRouter rebrand (supported set is en/zh/zh-TW only, and conventions forbid restoring them). A human should confirm this file is simply skipped/excluded from the sync rather than recreated. No content needs to be applied. — _Suggestion: Resolve manually — see the conflict summary in this PR._ - **`web/src/i18n/locales/ja.json`**: resolve returned neither edits nor content — _Suggestion: Resolve manually — see the conflict summary in this PR._ - **`web/src/i18n/locales/ru.json`**: resolve returned neither edits nor content — _Suggestion: Resolve manually — see the conflict summary in this PR._ - **`web/src/i18n/locales/vi.json`**: resolve returned neither edits nor content — _Suggestion: Resolve manually — see the conflict summary in this PR._ - **`web/src/i18n/locales/zh-TW.json`**: Resolve call failed: Anthropic API error after 3 retries: <title>504 Gateway Time-out</title>

504 Gateway Time-out

— _Suggestion: Resolve manually — see the conflict summary in this PR._ - **`web/src/i18n/locales/zh.json`**: Resolve call failed: Anthropic API error after 3 retries: <title>504 Gateway Time-out</title>

504 Gateway Time-out

— _Suggestion: Resolve manually — see the conflict summary in this PR._ - **`model/log.go`**: Resolve call failed: Anthropic API error after 3 retries: <title>504 Gateway Time-out</title>

504 Gateway Time-out

— _Suggestion: Resolve manually — see the conflict summary in this PR._ - **`model/user.go`**: Resolve call failed: Anthropic API error after 3 retries: <title>504 Gateway Time-out</title>

504 Gateway Time-out

— _Suggestion: Resolve manually — see the conflict summary in this PR._ - **`web/src/features/profile/components/tabs/account-bindings-tab.tsx`**: Upstream deleted account-bindings-tab.tsx (bindings UI relocated in the security-center restructure), but the downstream copy contains fork-only phone-binding code (PhoneBindDialog, 'phone' DialogKey, phone binding row with Change/Bound logic) backing the ported campaign system's phone_filled trigger. A human must: (1) locate the new upstream home of the account bindings UI, (2) re-add the phone binding entry and PhoneBindDialog wiring there using the fork's profile.phone accessor pattern, (3) confirm no remaining imports of this file (profile tabs index, dialogs), then (4) delete this file. Do NOT delete it before step (2), or the phone_filled campaign trigger loses its only UI entry point. — _Suggestion: Resolve manually — see the conflict summary in this PR._ - **`web/src/features/profile/components/tabs/notification-tab.tsx`**: Resolve call failed: Anthropic API error after 3 retries: <title>504 Gateway Time-out</title>

504 Gateway Time-out

— _Suggestion: Resolve manually — see the conflict summary in this PR._ - **`web/src/i18n/locales/en.json`**: LLM edits did not apply: edit 4: 'old' block not found in file: ' "All requests must include": "All requests must include",\\n "All Status": ' — _Suggestion: Resolve manually — see the conflict summary in this PR._ - **`web/src/i18n/locales/fr.json`**: resolve returned neither edits nor content — _Suggestion: Resolve manually — see the conflict summary in this PR._ - **`web/src/i18n/locales/ja.json`**: resolve returned neither edits nor content — _Suggestion: Resolve manually — see the conflict summary in this PR._ - **`web/src/i18n/locales/ru.json`**: resolve returned neither edits nor content — _Suggestion: Resolve manually — see the conflict summary in this PR._ - **`web/src/i18n/locales/vi.json`**: resolve returned neither edits nor content — _Suggestion: Resolve manually — see the conflict summary in this PR._ - **`web/src/i18n/locales/zh-TW.json`**: Resolve call failed: Anthropic API error after 3 retries: <title>504 Gateway Time-out</title>

504 Gateway Time-out

— _Suggestion: Resolve manually — see the conflict summary in this PR._ - **`web/src/i18n/locales/zh.json`**: Resolve call failed: Anthropic API error after 3 retries: <title>504 Gateway Time-out</title>

504 Gateway Time-out

— _Suggestion: Resolve manually — see the conflict summary in this PR._

🤖 Created by upstream-semantic-sync

@coderabbitai

coderabbitai Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Ignore keyword(s) in the title.

⛔ Ignored keywords (1)
  • sync(upstream)

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository: suanova/cuberouter/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 46f53019-af1b-477a-b640-46e5c323f003

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

@clyang82
clyang82 force-pushed the sync/upstream-32c261923a97-9a8674425c5a branch 2 times, most recently from e659901 to 487ad8b Compare September 24, 2026 00:36
mergify Bot pushed a commit that referenced this pull request Sep 24, 2026
* Port from develop 9525343+3fc95ec: aggregated API create-user remark support

Port the remark field for the aggregated create-user API from the
searouter-isuanova develop branch:

- 9525343 feat(#88): 聚合API创建用户支持 remark 字段
- 3fc95ec fix(#89): remark 拼接超长时截断为 255 字符

- AggregatedCreateUserRequest: new remark field (max 255 chars,
  TrimSpace'd); written to User.Remark at insert time
- buildCreateUserRemark: combines user remark with user_validity as
  "remark;账户有效期至 YYYY-MM-DD" without overwriting user remark
- capRemarkRunes: truncates the combined value to 255 runes so the
  varchar(255) column is never exceeded (#89, decision: truncate,
  do not reject)
- Ported unit tests (controller/aggregated_api_remark_test.go)
- Swagger artifacts regenerated (docs.go/swagger.json/swagger.yaml)

Verified with go build + controller tests (TestBuildCreateUserRemark,
swagger gate tests).

Co-Authored-By: Claude <[email protected]>

* Port from develop 43ef0df: unify username/email 50-char limit with per-layer checks

Port Issue #91 from the searouter-isuanova develop branch:

- AggregatedCreateUser: reject username/email over 50 chars
- SendEmailVerification / SendPasswordResetEmail: email max=50 with
  user.email_too_long i18n error (adapting to this repo's
  NormalizeEmail + ApiErrorI18n style)
- EmailBind: length check before verification-code validation
- Frontend: maxLength={50} on sign-up email, forgot-password email,
  email-bind dialog email, and admin user create/edit username inputs

The model-layer validate:"max=50" baseline already exists in this
repo (User.Username/User.Email); this commit adds the controller-layer
early rejection and the frontend input constraints.

Verified with go build + controller tests + tsgo typecheck.

Co-Authored-By: Claude <[email protected]>

* Port from develop 4233420: token quota input uses native quota directly

Port Issue #96 from the searouter-isuanova develop branch: the API key
create/edit quota input now takes the native quota number directly
instead of a currency amount converted client-side.

- api-key-form.ts: form field remain_quota_dollars -> remain_quota
  (non-negative integer, default 0); payload sends the raw value
  (backend already accepts native remain_quota); edit-mode prefill
  reads apiKey.remain_quota as-is; removed parseQuotaFromDollars /
  quotaUnitsToDollars conversion
- api-keys-mutate-drawer.tsx: quota label/placeholder/description
  switched to native-token wording, input min=0 step=1; removed the
  currency display logic
- i18n: added native-quota keys to en/zh/zh-TW (obfuscated
  footer.newapi attribution key untouched)

Related items from the same source batch verified as already covered
in this codebase, no changes needed:
- #82 (dd740a8, no converted-amount hint under the quota input): this
  drawer never rendered such a hint
- #87 (7877fc3, hide group selector, token defaults to user group):
  SHOW_KEY_GROUP_SELECTOR is already false with DEFAULT_GROUP = '',
  and the token auth middleware falls back to the account group when
  token.Group is empty

Verified with tsgo typecheck + keys feature tests (29 passed).

Co-Authored-By: Claude <[email protected]>

* Port from develop 954b714: billing report API user param username -> user_id

Port the breaking API change from the searouter-isuanova develop branch:
GET /data/billing and GET /ops/data/billing now take ?user_id=<bigint>
instead of ?username=<string>.

- parseBillingUserId helper: empty/non-integer/non-positive -> 400
- GetUserBillingReport / GetOpsBillingReport: resolve the user by ID
  (primary-key lookup); ops permission check (inviter only) unchanged
- GetUserBillingAgg: filter logs by user_id instead of username
  (index-friendly; avoids same-username ambiguity)
- Ported model test (in-memory SQLite): same-username-different-ID
  filtering and invalid-ID cases; adapted to this repo's Log model
  (no CacheTokens column, matching the existing 0 AS cache_tokens
  select)

BREAKING CHANGE: callers must switch ?username=xxx to ?user_id=123

Verified with go build + model billing tests.

Co-Authored-By: Claude <[email protected]>

* Port from develop 0fb2d5d: ops read-only access to user management and logs (backend)

Port the backend half of the ops-readonly feature from the
searouter-isuanova develop branch:

- User management routes split into a read group (OpsAuth) and a
  write group (AdminAuth): ops can list/search/view users, topups,
  columns, invitees, quota-dates, oauth bindings and 2FA stats;
  create/manage/update/delete/export/2FA-disable remain admin-only
- Log read routes (GET /, /stat, /channel_affinity_usage_cache)
  opened to OpsAuth for read-only ops auditing; /search stays
  admin-only (this repo has no log DELETE route; log cleanup goes
  through the performance route)

Frontend half (route guard, read-only users page, sidebar entry,
usage-logs full-data mode for ops) to follow in a separate commit.

Verified with go build + router/middleware tests.

Co-Authored-By: Claude <[email protected]>

* Port from develop 3eb59a8: dashboard model consumption charts use native quota, drop statistical-quota card

Source commit: 3eb59a8 (searouter-isuanova develop, feat(#84): 数据看板改为原生额度显示并移除统计额度卡片)

Changes in this shadcn codebase:
- New hook useSubscriptionNativeQuota (dashboard/hooks): sums
  remain/used native quota over ACTIVE subscriptions; self endpoint
  (/api/subscription/self) vs admin endpoint
  (/api/subscription/admin/users/:id/subscriptions). Exported for
  subscription-quota display and the upcoming summary revamp.
- lib/charts.ts processChartData: model consumption distribution
  bar/area charts now plot raw quota values (y-axis, tooltips and the
  total header use thousands-separated native numbers); the currency
  conversion for these charts is removed. processUserChartData keeps
  its currency display (out of scope, unchanged).
- use-dashboard-config: removed the "Total Quota" (统计额度) stat card
  from the model analytics stat row (5 -> 4 cards); log-stat-cards and
  the index.tsx fallback grid follow (grid-cols-5 -> grid-cols-4).

Notes:
- The source commit also switched the account-data cards (当前余额/
  历史消耗) to native quota; that intermediate state was reverted by
  #95 (ff211b1) back to wallet-amount display. The target SummaryCards
  already display wallet quota via formatQuota (amount), so no
  account-card change is made here (see the #95 port commit).
- The source commit's UserDataDashboard isViewingOtherUser wiring has
  no counterpart in the target dashboard architecture (there is no
  per-user data-dashboard section); the hook covers the admin path via
  its userId parameter.

Co-Authored-By: Claude <[email protected]>

* Port from develop 7d8bf54: dashboard current-balance card topup button — already equivalent, no change

Source commit: 7d8bf54 (searouter-isuanova develop, fix: 数据看板当前余额项移除充值按钮 (#85))

The source commit removed the 充值 (top-up) Tag rendered next to the
当前余额 card in StatsCards, plus its navigation to /console/topup and
the now-unused showTopupAction prop.

Already equivalently covered in the target: the redesigned dashboard's
balance surfaces (overview SummaryCards / Credit remaining panel) never
had a top-up action — the only nearby control is the "Wallet" link
button, a section link rather than a top-up CTA. No code change.

Co-Authored-By: Claude <[email protected]>

* Port from develop ff211b1: dashboard account-data amount display + resource-consumption subscription cards — already equivalent / not applicable

Source commit: ff211b1 (searouter-isuanova develop, feat(#95): 数据看板账户数据改按金额显示,资源消耗新增订阅原生额度卡片)

- Account data (当前余额/历史消耗) switched to the user's wallet quota
  (quota/used_quota) converted to money via renderQuota: already
  equivalent in the target — the overview SummaryCards render wallet
  quota/used via formatQuota, the project-standard currency conversion
  honoring display_in_currency. No change.
- Resource-consumption section: the source added two subscription
  native-quota cards (当前余额/历史消耗, raw numbers from
  useSubscriptionNativeQuota). Not applicable to the target
  architecture: the redesigned dashboard has no resource-consumption
  block (account surfaces live in the overview SummaryCards), and the
  source itself removed that block entirely in the later adec8c7
  revamp, replacing it with the 订阅余额 (converted value) card. The
  subscription data is available via useSubscriptionNativeQuota
  (ported in 5fb530f, extended in the adec8c7 hook port below) for
  the future summary revamp. No change.

Co-Authored-By: Claude <[email protected]>

* Port from develop adec8c7: subscription native quota hook adds plan-price remaining value

Source commit: adec8c7 (searouter-isuanova develop, feat: 模型价格支持缓存命中价设置,订阅余额按套餐价折算展示) — dashboard data-layer part only:
the useSubscriptionNativeQuota remainValue aggregation (套餐现价 × 剩余/总量).
The rest of the source commit (cache-hit pricing UI, dashboard layout
revamp, topup page, docs page) is out of scope for this port.

useSubscriptionNativeQuota now additionally returns:
- totalQuota: sum of amount_total over active finite-quota subscriptions
- remainValue: sum of planPrice x (remain / total) over those
  subscriptions (USD), i.e. the subscription balance converted at the
  plan's current price
- hasActive: whether the user has any active subscription

Implementation note (target adaptation): the source backend attaches
plan_price_amount to each SubscriptionSummary (adec8c7 backend change in
model/subscription.go). The target's SubscriptionSummary does not carry
the plan price and the backend is owned by another workstream, so the
hook resolves current plan prices client-side from
GET /api/subscription/plans (enabled plans, UserAuth) and joins by
plan_id. Edge-case difference: subscriptions whose plan is disabled no
longer appear in /api/subscription/plans, so their remaining value
contributes 0 (source would still resolve the disabled plan's price).

Co-Authored-By: Claude <[email protected]>

* Port from develop fbdf945 5ad7ee0: subscription overdraw + pre-consume audit trail (backend)

Port the subscription overdraw feature and the pre-consume
calculation audit trail from the searouter-isuanova develop branch
(#98):

Overdraw (fbdf945):
- PostConsumeUserSubscriptionDelta no longer rejects settle deltas
  that push amount_used above amount_total; the excess is recorded as
  a negative balance (remain = total - used < 0) and the pre-consume
  check naturally blocks further requests on that subscription
- Refund path keeps the used >= 0 clamp
- Consumption logs record subscription_remain as a true negative
  (no more clamp to 0)

Pre-consume audit trail (fbdf945):
- PriceData gains PreConsumeDetail (estimated prompt tokens, floor,
  request max_tokens, model/group ratios, final quota) filled by
  ModelPriceHelper
- Token estimation records a breakdown (text tokens, message/tool/
  name overhead, base overhead, media tokens, method); the relay
  handler attaches it to the detail; GenerateTextOtherInfo emits
  other["pre_consume_detail"] so logs can trace how the
  pre-consumed quota was derived
- New service/token_estimate_breakdown.go with the last-estimate
  record (mutex-guarded, returned by copy)

Adaptations: the breakdown recording lives in CountRequestToken
(develop had it in EstimateRequestToken); tests adapted to this
repo's package layout (relaykit/types alias, local SQLite test DB
helper).

Verified with go build + full model/service/relay-helper test suites.

Co-Authored-By: Claude <[email protected]>

* Port from develop 0fb2d5d: ops read-only access to user management and logs (web, part 1)

Frontend half of the ops-readonly feature, first batch:

- /users route guard: ops (and above) may now open the user
  management page (was admin-only); the page-level read-only
  treatment of actions/buttons follows in part 2
- usage-logs view scope: ops may view all users' logs (full-data
  branch: endpoint, columns, filters, detail fields); the log table
  has no write actions so the access is read-only by construction
- Sidebar ops section: new Users entry (/users, ops and above); the
  existing invite-history entry is relabeled Invite History to match
  its page title (previously mislabeled User Management)

Verified with usage-logs tests (23 passed) + tsgo typecheck.

Co-Authored-By: Claude <[email protected]>

* Port from develop 51b3f79 58cf985 2c55d2e f951584 9df4a57: user list quota columns switch to effective-subscription basis

User list (admin) and ops invitee list quota columns now use the
effective-subscription token basis instead of the wallet quota.

- model/user.go: non-persistent User fields (subscription_total_quota /
  subscription_remain_quota / subscription_used_quota /
  subscription_unlimited / subscription_remain_value) plus
  FillUsersSubscriptionQuotaStats, a single GROUP BY (user_id, plan_id)
  aggregate over user_subscriptions (status=active AND end_time > now):
  remain = SUM(max(0, amount_total-amount_used)) for amount_total>0 only,
  used = SUM(amount_used) (includes unlimited-subscription usage), total =
  SUM(amount_total) for amount_total>0 only, unlimited = any
  amount_total<=0 active sub, remain value = SUM(plan price x remain/total)
  with plan prices batch-fetched through the getSubscriptionPlanByIdTx
  cache (same source as the plan_price_amount summary field).
- controller/user.go: GetAllUsers/SearchUsers fill the stats before
  responding (51b3f79/#86).
- controller/user_ops.go: invitee list/search/CSV export fill the stats;
  CSV total/used quota columns output the subscription basis, unlimited
  total renders the localized string (new i18n key ops.export.unlimited in
  en/zh-CN/zh-TW).
- controller/user_columns.go + ops_user_columns.go: column metadata final
  state (58cf985/#94, 2c55d2e) — quota relabeled Remaining/Total Quota,
  new money_balance column Subscription Balance (plan-price-converted
  remaining value), the standalone ops used_quota column removed (used
  quota moves into the quota column tooltip), no history-money column.
- web users/ops-users: UserQuotaCell now renders the subscription basis
  (total is the subscription total - remain is clamped per subscription so
  used+remaining is not the total) with Unlimited support; new
  SubscriptionBalanceCell renders the plan-price-converted remaining value
  (USD) plus remaining percentage, '-' without an active subscription,
  Unlimited for unlimited subs, tooltip with the token breakdown;
  User/OpsUser types gain the 5 optional subscription stats fields.
- i18n: Remaining/Total Quota + Subscription Balance added to en/zh/zh-TW
  in place (zero reordering).
- Tests: FillUsersSubscriptionQuotaStats (no-active / single / mixed /
  empty, plus opt-in PostgreSQL dialect check gated on TEST_PG_DSN) and
  column metadata order/label tests for both tables.

Note: the aggregate uses CAST(... AS FLOAT8), valid on PostgreSQL/SQLite;
on MySQL the query errors and the function silently degrades to zero
values (same behavior as the source, kept as-is). The admin user CSV
export keeps the wallet basis, matching the source.

Co-Authored-By: Claude <[email protected]>

* Port from develop fbdf945 5ad7ee0: subscription overdraw (web)

Frontend half of the #98 overdraw port:

- Log details: subscription settlement now shows a single
  Final Consumed row (develop 5ad7ee0: only the final deduction is
  shown, pre-consume/post-delta stay log-only for auditing); falls
  back to pre-consume + post-delta for old logs missing
  subscription_consumed. The pre-consume detail / estimate
  breakdown recorded in the log (backend commit) are intentionally
  not rendered (develop: stored for auditing, not shown in UI)
- Subscription plans card: remaining amount no longer clamped at
  zero, so overdrawn subscriptions show a true negative balance
  (Usage percent text may exceed 100%, matching develop)

Verified with usage-logs + wallet tests (28 passed) + tsgo typecheck.

Co-Authored-By: Claude <[email protected]>

* Port from develop adec8c7: dashboard subscription balance card

Port the display half of adec8c7 (subscription remaining value at
plan price): the overview "Usage at a glance" panel gains a
Subscription balance cell under the wallet credit block, fed by the
useSubscriptionNativeQuota hook (added with the #84 port):

- no active subscription -> None; any unlimited active
  subscription -> Unlimited; otherwise the remaining value
  (sum of plan price x remain/total over active subscriptions, USD)
  formatted in the display currency (or native quota when currency
  display is disabled)
- sub-value: remaining percent (remain/total over finite
  subscriptions), matching the develop dashboard
- i18n: Subscription balance key in en/zh/zh-TW (obfuscated
  footer.newapi attribution key untouched)

Verified with tsgo typecheck + dashboard tests (39 passed).

Co-Authored-By: Claude <[email protected]>

* Port from develop 0fb2d5d: ops read-only access to user management and logs (web, part 2)

Users management page read-only treatment for ops viewers:

- Primary buttons (Add User / Export All): hidden for ops
- Bulk actions toolbar (export selected): hidden for ops
- Row actions (edit / enable / disable / promote / demote / 2FA
  reset / passkey / delete): not rendered for ops

Read data (user list, search, detail, columns) stays fully
available; the backend enforces the same split (write endpoints
admin-only, see the backend half of this port).

Verified with tsgo typecheck + users feature tests.

Co-Authored-By: Claude <[email protected]>

* Address CodeRabbit review comments on PR #110

- model/log_billing.go: format the dayKey calendar date in UTC — west-of-UTC
  time zones no longer shift the billing day back one day (Major, outside diff)
- controller/user.go: EmailBind counts Unicode characters instead of bytes,
  consistent with the aggregated create-user entry point
- model/user.go: portable (amount_total - amount_used) * 1.0 / amount_total
  division replaces the PG/SQLite-only FLOAT8 cast; valid on SQLite/MySQL/PG
- controller: GetUser and GetUserOAuthBindingsByAdmin read scope decoupled
  from the canManageTargetRole write policy — ops may read any user detail
  and OAuth bindings, consistent with GetAllUsers; write checks unchanged
- service/token_estimate_breakdown: request-scoped via gin context
  (constant.ContextKeyTokenEstimateBreakdown) instead of a package-level
  last-estimate; concurrent requests no longer overwrite each other and
  requests that skip counting cannot reuse another request's breakdown
- tests: converted 10 test files to testify require/assert per repository
  guidelines (require for setup/fatal/type assertions, assert for value
  checks; RedisEnabled saved and restored via t.Cleanup)
- web: api-key quota default 5,000,000 (the former $10 default in native
  units) instead of 0; "Native Quota" wording without token units + locales;
  explicit ids on the ops-users subscription columns so column-visibility
  metadata resolves; usage-logs scope is category-aware (ops pinned to the
  self tier on drawing/task views whose read endpoints are AdminAuth);
  username 50-codepoint schema refine (HTML maxLength counts UTF-16 units)

Verified: go build ./... + go test (controller/model/service/relay/helper),
billing date tests under TZ=America/New_York and TZ=Asia/Shanghai, tsgo
typecheck, 138 web test files / 1080 tests.

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
@clyang82
clyang82 force-pushed the sync/upstream-32c261923a97-9a8674425c5a branch from 487ad8b to 9568781 Compare September 28, 2026 00:48
… claiming task plugin (and pointing to disabling/overriding it) when a plugin-claimed model has no enabled channel, instead of the generic 'no available channel' text

Upstream-commit: 32c2619
…nt_tokens endpoint by commenting out its route registration (with TODO to re-enable), and removes the test asserting its registration.

Upstream-commit: 3a9f41e
… trailing @key:value modifier syntax (thinking/effort/temperature/topp) with a canonical billing-identity ladder, while narrowing legacy thinking/effort alias parsing to whitelisted model families and dropping the OpenRouter '*-thinking' alias.

Upstream-commit: 7c044d7
… suffixes during relay: when a model is flagged to preserve its thinking suffix, adaptors and format converters now pass the user's original reasoning intent through unchanged instead of silently rewriting it.

Upstream-commit: 6b659fd
… new built-in model prices to be defined as self-contained billing expressions in setting/billing_setting/builtin_billing.go (real USD per million tokens), rather than in legacy ratio tables, while preserving admin overrides and only migrating legacy prices on explicit request.

Upstream-commit: d580353
…e new gpt-6-astra model and expose the effective billing mode/expression settings (including non-persisted built-in defaults) via the options API.

Upstream-commit: eb99ab1
…pies json.RawMessage fields via bytes.Clone (through a copier TypeConverter) instead of per-byte reflection, speeding up request deep copies while preserving independent storage; adds extensive clone regression tests.

Upstream-commit: 2cf177a
…on_tokens, temperature/top_p/logprobs stripping) from the literal 'gpt-5' prefix to all gpt-<n> models with n >= 5, so gpt-6 and later generations stop being rejected with 400s and channel tests pass.

Upstream-commit: 49ec469
…rading the SQLite GORM driver and adding a migration dialector that normalizes equivalent MySQL decimal defaults and PostgreSQL CHAR metadata during schema comparison

Upstream-commit: 9a86744
@clyang82
clyang82 force-pushed the sync/upstream-32c261923a97-9a8674425c5a branch from 9568781 to 7daf72a Compare October 1, 2026 01:30
@mergify

mergify Bot commented Nov 11, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant