1. 16 Mar, 2026 5 commits
    • erio's avatar
      feat(dashboard): add per-user drill-down for group, model, and endpoint distributions · 4b41e898
      erio authored
      Click on a group name, model name, or endpoint name in the distribution
      tables to expand and show per-user usage breakdown (requests, tokens,
      actual cost, standard cost).
      
      Backend: new GET /admin/dashboard/user-breakdown API with group_id,
      model, endpoint, endpoint_type filters.
      Frontend: clickable rows with expand/collapse sub-table in all three
      distribution charts.
      4b41e898
    • erio's avatar
      fix(i18n): correct usage label from "Total" to "Last 30d" · d45cc231
      erio authored
      The usage stats query defaults to a 30-day rolling window, but the
      UI label said "Total"/"累计" implying lifetime aggregation. Rename
      to "Last 30d"/"近30天" so the label matches the actual query semantics.
      
      Closes #1060
      d45cc231
    • Ethan0x0000's avatar
      fix: always show usage stats for OpenAI OAuth and hide zero-value badges · 1acfc46f
      Ethan0x0000 authored
      - Simplify OpenAI rendering: always fetch /usage, prefer fetched data over
        codex snapshot (snapshot serves as loading placeholder only)
      - Remove dead code: preferFetchedOpenAIUsage, isOpenAICodexSnapshotStale,
        and unreachable template branch
      - Add today-stats support for key accounts (req/tokens/A/U badges)
      - Use formatCompactNumber for consistent number formatting
      - Add A/U badge titles for clarity
      - Filter zero-value window stats in UsageProgressBar to avoid empty badges
      - Update tests to match new fetched-data-first behavior
      1acfc46f
    • Ethan0x0000's avatar
      feat: add today-stats and manual refresh token propagation to usage cells · fbffb08a
      Ethan0x0000 authored
      - Pass todayStats/todayStatsLoading to AccountUsageCell for key accounts
      - Propagate usageManualRefreshToken to force usage reload on explicit refresh
      - Refresh today stats when toggling usage/today_stats columns visible
      fbffb08a
    • Ethan0x0000's avatar
      refactor: extract formatCompactNumber util and add last_used_at to refresh key · 8640a623
      Ethan0x0000 authored
      - Add formatCompactNumber() for consistent large-number formatting (K/M/B)
      - Include last_used_at in OpenAI usage refresh key for better change detection
      - Add .gitattributes eol=lf rules for frontend source files
      8640a623
  2. 15 Mar, 2026 14 commits
    • erio's avatar
      refactor: replace sync.Map credits state with AICredits rate limit key · 8a260def
      erio authored
      Replace process-memory sync.Map + per-model runtime state with a single
      "AICredits" key in model_rate_limits, making credits exhaustion fully
      isomorphic with model-level rate limiting.
      
      Scheduler: rate-limited accounts with overages enabled + credits available
      are now scheduled instead of excluded.
      
      Forwarding: when model is rate-limited + credits available, inject credits
      proactively without waiting for a 429 round trip.
      
      Storage: credits exhaustion stored as model_rate_limits["AICredits"] with
      5h duration, reusing SetModelRateLimit/isRateLimitActiveForKey.
      
      Frontend: show credits_active (yellow ) when model rate-limited but
      credits available, credits_exhausted (red) when AICredits key active.
      
      Tests: add unit tests for shouldMarkCreditsExhausted, injectEnabledCreditTypes,
      clearCreditsExhausted, and update existing overages tests.
      8a260def
    • SilentFlower's avatar
    • SilentFlower's avatar
    • SilentFlower's avatar
    • SilentFlower's avatar
      feat: implement resolveCreditsOveragesModelKey function to stabilize model key... · 17e40333
      SilentFlower authored
      feat: implement resolveCreditsOveragesModelKey function to stabilize model key resolution for credit overages
      17e40333
    • Peter's avatar
      8147866c
    • shaw's avatar
      fix: 恢复 UsageProgressBar 中被意外移除的窗口统计数据展示 · 220fbe65
      shaw authored
      commit 0debe0a8 在修复 OpenAI WS 用量窗口刷新问题时,意外删除了
      UsageProgressBar 中的 window stats 渲染逻辑和格式化函数。
      
      恢复进度条上方的统计行(requests, tokens, account cost, user cost)
      及对应的 4 个格式化 computed 属性。
      220fbe65
    • shaw's avatar
      ae44a943
    • IanShaw027's avatar
      fix: 修复批量编辑账号时模型白名单显示与实际不一致的问题 #982 · 19d3ecc7
      IanShaw027 authored
      修复批量编辑账号时,UI 显示的是 plain 模型名(如 GPT-5),但实际落库的是 dated 模型名的问题。
      
      核心改动:
      1. 批量编辑白名单不再使用 BulkEditAccountModal.vue 中手写的过期模型列表
         - 移除了 allModels 和 presetMappings 的硬编码列表(共 200+ 行)
         - 直接复用 ModelWhitelistSelector.vue 组件
      
      2. ModelWhitelistSelector 组件支持多平台联合过滤
         - 新增 platforms 属性支持传入多个平台
         - 添加 normalizedPlatforms 计算属性统一处理单平台和多平台场景
         - availableOptions 根据选中的多个平台动态联合过滤模型列表
         - fillRelated 功能支持一次性填充多个平台的相关模型
      
      3. 模型映射预设改为动态生成
         - filteredPresets 改用 getPresetMappingsByPlatform 从统一模型源按平台动态生成
         - 不再依赖弹窗中的手写预设列表
      
      现在的行为:
      - UI 显示什么模型,勾选什么模型,传给后端的就是什么模型
      - 彻底解决了批量编辑链路上"显示与实际不一致"的问题
      - 模型列表和映射预设始终与系统定义保持同步
      19d3ecc7
    • IanShaw027's avatar
      fix: 兼容部分限额字段为空的情况 #1021 · c31974c9
      IanShaw027 authored
      修复在填写限额时,如果不填写完整的三个限额额度(日限额、周限额、月限额)就会报错的问题。
      
      变更内容:
      - 后端:添加 optionalLimitField 类型处理空值和空字符串,兼容部分限额字段为空的情况
      - 前端:添加 normalizeOptionalLimit 函数规范化限额输入,将空值、空字符串和无效数字统一处理为 null
      c31974c9
    • erio's avatar
      fix(i18n): correct insufficient balance error hint text · 6177fa5d
      erio authored
      Remove misleading "upstream" wording - the error is about client API key
      user balance, not upstream account balance.
      6177fa5d
    • erio's avatar
      feat(ops): add ignore insufficient balance errors toggle and extract error constants · cfe72159
      erio authored
      - Add 5th error filter switch IgnoreInsufficientBalanceErrors to suppress
        upstream insufficient balance / insufficient_quota errors from ops log
      - Extract hardcoded error strings into package-level constants for
        shouldSkipOpsErrorLog, normalizeOpsErrorType, classifyOpsPhase, and
        classifyOpsIsBusinessLimited
      - Define ErrNoAvailableAccounts sentinel error and replace all
        errors.New("no available accounts") call sites
      - Update tests to use require.ErrorIs with the sentinel error
      cfe72159
    • erio's avatar
      fix(billing): allow clearing group quota limits and treat 0 as zero-limit · 5899784a
      erio authored
      Previously, v-model.number produced "" when input was cleared, causing
      JSON decode errors on the backend. Also, normalizeLimit treated 0 as
      "unlimited" which prevented setting a zero quota. Now "" is converted
      to null (unlimited) in frontend, and 0 is preserved as a valid limit.
      
      Closes Wei-Shaw/sub2api#1021
      5899784a
    • Ethan0x0000's avatar
      feat: 完善使用记录端点可观测性与分布统计 · eefab159
      Ethan0x0000 authored
      将入站、上游与路径三类端点分布统一到使用记录页的一致化卡片交互中,并补齐端点元数据与统计链路,提升排障与流量分析效率。
      eefab159
  3. 14 Mar, 2026 5 commits
    • SsageParuders's avatar
      fix: Bedrock 账户配额限制不生效,配额计数器始终为 $0.00 · 37c044fb
      SsageParuders authored
      applyUsageBillingEffects() 中配额更新条件仅检查了 AccountTypeAPIKey,
      遗漏了 AccountTypeBedrock,导致 Bedrock 账户的配额计数器永远不递增。
      扩展条件以同时支持 APIKey 和 Bedrock 类型。
      
      同时在前端账户筛选下拉框中添加 AWS Bedrock 选项。
      37c044fb
    • shaw's avatar
      fix(frontend): 修复运维设置对话框保存按钮始终禁用的问题 · 6da5fa01
      shaw authored
      后端默认 alert.enabled=true 但 recipients 为空,前端验证将其视为
      错误并阻断保存按钮。移除该阻断性验证,改为保存时自动禁用无收件人
      的邮件通知配置。
      6da5fa01
    • shaw's avatar
      refactor(frontend): 将备份和数据管理页面合并为设置页的标签页 · 616930f9
      shaw authored
      将独立的 /admin/backup 和 /admin/data-management 页面整合到设置页,
      作为「备份」和「Sora 存储」标签页,减少侧边栏条目,集中管理配置。
      
      - 移除 BackupView 和 DataManagementView 的 AppLayout 包装
      - 在 SettingsView 中以子组件形式嵌入,使用 v-show 切换标签
      - 删除独立路由和侧边栏菜单入口
      - 备份/数据标签页下隐藏主保存按钮(各自有独立保存)
      - 优化标签栏样式适配7个标签,PC端支持细滚动条
      - 清理未使用的图标组件和 i18n 键
      616930f9
    • Rose Ding's avatar
      fix: 按 review 意见重构数据库备份服务(安全性 + 架构 + 健壮性) · 1047f973
      Rose Ding authored
      
      
      1. S3 凭证加密存储:使用 SecretEncryptor (AES-256-GCM) 加密 SecretAccessKey,
         防止备份文件中泄露 S3 凭证,兼容旧的未加密数据
      2. 修复 saveRecord 竞态条件:添加 recordsMu 互斥锁保护 records 的 load/save
      3. 恢复操作增加服务端验证:handler 层要求重新输入管理员密码,通过 bcrypt
         校验,前端弹出密码输入框
      4. pg_dump/psql/S3 操作抽象为接口:定义 DBDumper 和 BackupObjectStore 接口,
         实现放入 repository 层,遵循项目依赖注入架构规范
      5. 改为流式处理避免大数据库 OOM:备份时 pg_dump stdout -> gzip -> io.Pipe ->
         S3 upload;恢复时 S3 download -> gzip reader -> psql stdin,不再全量加载
      6. loadRecords 区分"无数据"和"数据损坏"场景:JSON 解析失败返回明确错误
      7. 添加 18 个核心逻辑单元测试:覆盖加密、并发、流式备份/恢复、错误处理等
      Co-Authored-By: default avatarClaude Opus 4.6 <noreply@anthropic.com>
      1047f973
    • SsageParuders's avatar
      refactor: merge bedrock-apikey into bedrock with auth_mode credential · 4644af2c
      SsageParuders authored
      Consolidate two separate channel types (bedrock + bedrock-apikey) into
      a single "AWS Bedrock" channel. Authentication mode is now distinguished
      by credentials.auth_mode ("sigv4" | "apikey") instead of separate types.
      
      Backend:
      - Remove AccountTypeBedrockAPIKey constant
      - IsBedrock() simplified; IsBedrockAPIKey() checks auth_mode
      - Add IsAPIKeyOrBedrock() helper to eliminate repeated type checks
      - Extend pool mode, quota scheduling, and billing to bedrock
      - Add RetryableOnSameAccount to handleBedrockUpstreamErrors
      - Add "bedrock" scope to Beta Policy for independent control
      
      Frontend:
      - Merge two buttons into one "AWS Bedrock" with auth mode radio
      - Badge displays "Anthropic | AWS"
      - Pool mode and quota limit UI available for bedrock
      - Quota display in account list (usage bars, capacity badges, reset)
      - Remove all bedrock-apikey type references
      4644af2c
  4. 13 Mar, 2026 7 commits
    • erio's avatar
      feat(antigravity): add 403 forbidden status detection, classification and display · 6344fa2a
      erio authored
      Backend:
      - Detect and classify 403 responses into three types:
        validation (account needs Google verification),
        violation (terms of service / banned),
        forbidden (generic 403)
      - Extract verification/appeal URLs from 403 response body
        (structured JSON parsing with regex fallback)
      - Add needs_verify, is_banned, needs_reauth, error_code fields
        to UsageInfo (omitempty for zero impact on other platforms)
      - Handle 403 in request path: classify and permanently set account error
      - Save validation_url in error_message for degraded path recovery
      - Enrich usage with account error on both success and degraded paths
      - Add singleflight dedup for usage requests with independent context
      - Differentiate cache TTL: success/403 → 3min, errors → 1min
      - Return degraded UsageInfo instead of HTTP 500 on quota fetch errors
      
      Frontend:
      - Display forbidden status badges with color coding (red for banned,
        amber for needs verification, gray for generic)
      - Show clickable verification/appeal URL links
      - Display needs_reauth and degraded error states in usage cell
      - Add Antigravity tier label badge next to platform type
      
      Tests:
      - Comprehensive unit tests for classifyForbiddenType (7 cases)
      - Unit tests for extractValidationURL (8 cases including unicode escapes)
      - Integration test for FetchQuota forbidden path
      6344fa2a
    • Peter's avatar
      feat(ops): allow hiding alert events · 29b0e4a8
      Peter authored
      29b0e4a8
    • Peter's avatar
      fix(admin): default dashboard date range to today · 27ff222c
      Peter authored
      27ff222c
    • Ylarod's avatar
      sub2api: add bedrock support · 11f7b835
      Ylarod authored
      11f7b835
    • wucm667's avatar
      feat: 账号配额支持固定时间重置模式 · 5b850059
      wucm667 authored
      - 后端新增 rolling/fixed 两种配额重置模式,支持日配额和周配额
      - fixed 模式下可配置重置时刻(小时)、重置星期几(周配额)及时区(IANA)
      - 在 account_repo.go 中使用 SQL 表达式适配两种模式的过期判断与重置时间推进
      - 新增 ComputeQuotaResetAt / ValidateQuotaResetConfig 等辅助函数
      - DTO 层新增相关字段并在 mappers 中完整映射
      - 前端 QuotaLimitCard 新增 rolling/fixed 切换 UI、时区选择器
      - CreateAccountModal / EditAccountModal 透传新配置字段
      - i18n(zh/en)同步新增相关翻译词条
      5b850059
    • haruka's avatar
      fix: 管理员重置配额补全 monthly 字段并修复 ristretto 缓存异步问题 · e73531ce
      haruka authored
      
      
      - 后端 handler:ResetSubscriptionQuotaRequest 新增 Monthly 字段,
        验证逻辑扩展为 daily/weekly/monthly 至少一项为 true
      - 后端 service:AdminResetQuota 新增 resetMonthly 参数,
        调用 ResetMonthlyUsage;重置后追加 subCacheL1.Wait(),
        保证 ristretto Del() 的异步删除立即生效,消除重置后
        /v1/usage 返回旧用量数据的竞态窗口
      - 后端测试:更新存量测试用例匹配新签名,补充
        TestAdminResetQuota_ResetMonthlyOnly /
        TestAdminResetQuota_ResetMonthlyUsageError 两个新用例
      - 前端 API:resetQuota options 类型新增 monthly: boolean
      - 前端视图:confirmResetQuota 改为同时重置 daily/weekly/monthly
      - i18n:中英文确认提示文案更新,提及每月配额
      Co-Authored-By: default avatarClaude Sonnet 4.6 <noreply@anthropic.com>
      e73531ce
    • Rose Ding's avatar
      feat: 数据库定时备份与恢复(S3 兼容存储,支持 Cloudflare R2) · 53ad1645
      Rose Ding authored
      
      
      新增管理员专属的数据库备份与恢复功能:
      - 全量 PostgreSQL 备份(pg_dump),gzip 压缩后上传到 S3 兼容存储
      - 支持手动备份和 cron 定时备份
      - 支持从备份恢复(psql --single-transaction)
      - 备份文件自动过期清理(默认 14 天)
      - 前端完整管理页面(S3 配置、定时配置、备份列表、恢复/下载/删除)
      - 内置 Cloudflare R2 配置教程弹窗
      - Dockerfile 从 postgres 镜像多阶段复制 pg_dump/psql,确保版本一致
      Co-Authored-By: default avatarClaude Opus 4.6 <noreply@anthropic.com>
      53ad1645
  5. 12 Mar, 2026 5 commits
    • Peter's avatar
      feat(ops): make openai token stats optional · af9c4a7d
      Peter authored
      af9c4a7d
    • Peter's avatar
      80d8d6c3
    • erio's avatar
      feat(groups): add rate multipliers management modal · d6488112
      erio authored
      Add a dedicated modal in group management for viewing, adding, editing,
      and deleting per-user rate multipliers within a group.
      
      Backend:
      - GET /admin/groups/:id/rate-multipliers - list entries with user details
      - PUT /admin/groups/:id/rate-multipliers - batch sync (full replace)
      - DELETE /admin/groups/:id/rate-multipliers - clear all entries
      - Repository: GetByGroupID, SyncGroupRateMultipliers methods on
        user_group_rate_multipliers table (same table as user-side rates)
      
      Frontend:
      - New GroupRateMultipliersModal component with:
        - User search and add with email autocomplete
        - Editable rate column with local edit mode (cancel/save)
        - Batch adjust: multiply all rates by a factor
        - Clear all (local operation, requires save to persist)
        - Pagination (10/20/50 per page)
        - Platform icon with brand colors in group info bar
        - Unsaved changes indicator with revert option
      - Unit tests for all three backend endpoints
      d6488112
    • QTom's avatar
      a63de121
    • wanXcode's avatar
      69cafe86
  6. 11 Mar, 2026 4 commits
    • John Doe's avatar
      feat: add Backend Mode toggle to disable user self-service · 6826149a
      John Doe authored
      
      
      Add a system-wide "Backend Mode" that disables user self-registration
      and self-service while keeping admin panel and API gateway fully
      functional. When enabled, only admin can log in; all user-facing
      routes return 403.
      
      Backend:
      - New setting key `backend_mode_enabled` with atomic cached reads (60s TTL)
      - BackendModeUserGuard middleware blocks non-admin authenticated routes
      - BackendModeAuthGuard middleware blocks registration/password-reset auth routes
      - Login/Login2FA/RefreshToken handlers reject non-admin when enabled
      - TokenPairWithUser struct for role-aware token refresh
      - 20 unit tests (middleware + service layer)
      
      Frontend:
      - Router guards redirect unauthenticated users to /login
      - Admin toggle in Settings page
      - Login page hides register link and footer in backend mode
      - 9 unit tests for router guard logic
      - i18n support (en/zh)
      
      27 files changed, 833 insertions(+), 17 deletions(-)
      Co-Authored-By: default avatarClaude Opus 4.6 <noreply@anthropic.com>
      6826149a
    • Rose Ding's avatar
      3fcefe6c
    • Rose Ding's avatar
      feat: add gemini image test preview · bf6585a4
      Rose Ding authored
      bf6585a4
    • Peter's avatar
      feat(admin): add metric toggle to usage charts · 0ddaef3c
      Peter authored
      0ddaef3c