"backend/internal/vscode:/vscode.git/clone" did not exist on "3cdd5754df652e04253adf721e8ecb67a02e1c5f"
  1. 14 Apr, 2026 21 commits
    • erio's avatar
      fix: flaky WebSocket test, usage request queue, and test improvements · 3fa5b8bc
      erio authored
      - Fix flaky WebSocket passthrough test: allow StatusNormalClosure after
        client close instead of requiring NoError (race condition fix)
      - Fix ratelimit 401 test: use PlatformOpenAI instead of PlatformGemini
        for OAuth token cache invalidation scenario (more accurate)
      - Add usageLoadQueue: Anthropic OAuth/setup-token accounts sharing the
        same proxy exit are serialized with 1-2s jitter to prevent upstream 429
      - AccountUsageCell: add module-level usage cache (5min TTL), unmounted
        safety guard, and integrate enqueueUsageRequest for throttled fetching
      3fa5b8bc
    • erio's avatar
      refactor: extract CapacityBadge component from AccountCapacityCell · a56151fe
      erio authored
      Extract repeated badge template (SVG icon + current/max display) into
      a reusable CapacityBadge component. Reduces AccountCapacityCell from
      ~300 lines to ~180 lines with identical behavior.
      a56151fe
    • erio's avatar
      fix: merge general improvements from release branch · 63f539b3
      erio authored
      Backend:
      - gateway_handler: pass subject.UserID instead of int64(0) for user-level routing
      - setting_handler: add missing BalanceLowNotifyRechargeURL to UpdateSettings response
      - openai_gateway_service: use applyAccountStatsCost for account stats pricing integration
      - embed_on: add local file override (data/public/) for embedded frontend assets
      
      Frontend:
      - useTableSelection: add batchUpdate method for batch operations
      - AccountsView: virtual scrolling params, Set-based isSelected, swipe virtualization
      - ProxiesView: add batchUpdate to selection and swipe-select
      - BulkEditAccountModal: fix submit handler to prevent event object as argument
      - SettingsView: move payload construction outside try block
      - i18n: add general translation keys (saved, deleted, view, validation, allowUserRefund)
      - api/client: reorder error fields for consistency
      - stores/payment: clarify pollOrderStatus JSDoc
      63f539b3
    • erio's avatar
      fix: round-2 audit fixes — security, code quality, and UI improvements · a9880ee7
      erio authored
      Security (HIGH):
      - Normalize all Redis cache keys to lowercase (verifyCode, passwordReset)
      - Fix verify code TTL renewal on failed attempts: use remaining TTL via
        ExpiresAt field instead of resetting to full 15-minute window
      - Add 3 missing fields to diffSettings audit log (promo_code, invitation_code,
        custom_endpoints)
      
      Code quality (MEDIUM):
      - Extract filterVerifiedEmails shared helper (balance_notify_service.go)
      - Add Pricing array non-empty validation for channel pricing rules
      - Add platform token semantics comment in gateway_service.go
      - Complete validatePlanPatch test coverage (+10 test cases)
      - Replace string types with QuotaThresholdType/QuotaResetMode across frontend
      - Remove duplicate getPlatformTextColor/getRateBadgeClass in ChannelsView
      - Return EMAIL_NOT_FOUND error on RemoveNotifyEmail miss
      
      UI improvements:
      - Reorder cost tooltip: user billing above separator, account billing below
      - Add NaN guard to accountBilled function
      - Move timezone selector inline into reset-mode row (no longer standalone)
      a9880ee7
    • erio's avatar
      refactor: M5 useQuotaNotifyState composable + H14 Vue file splits · 1b7c2951
      erio authored
      M5: New composable frontend/src/composables/useQuotaNotifyState.ts
        - Replaces 9 individual refs in both Create/Edit modals with reactive state
        - Provides loadFromExtra/writeToExtra/reset helpers
        - Eliminates ~120 lines of duplicated code across the two modals
      
      H14: Vue file length violations fixed
        - AdminPaymentPlansView.vue: 325 → 183 lines (extracted PlanEditDialog.vue)
        - QuotaLimitCard.vue: 327 → 268 lines (extracted QuotaDimensionRow.vue)
        - PlanEditDialog.vue: 181 lines (new, plan create/edit form)
        - QuotaDimensionRow.vue: 108 lines (new, single quota dimension row)
      1b7c2951
    • erio's avatar
      fix: batch 2 audit fixes — diffSettings notify fields, slog migration, frontend constants · 9d319cfa
      erio authored
      H5: diffSettings now tracks 5 balance/quota notify fields in audit log
      M15: log.Printf audit log migrated to slog.Info, removed "log" import
      M14: New frontend/src/constants/account.ts with shared constants
           QuotaNotifyToggle.vue uses QUOTA_THRESHOLD_TYPE_FIXED/PERCENTAGE
      L2: UsageTable.vue uses BILLING_MODE_TOKEN/IMAGE from billingMode.ts
      9d319cfa
    • erio's avatar
      fix: batch 1 audit fixes — quota SQL fixed mode, public recharge URL,... · ed8a9d97
      erio authored
      fix: batch 1 audit fixes — quota SQL fixed mode, public recharge URL, WebSearch bool fallback, UpdatePlan validation
      
      H1: incrementUsageBillingAccountQuota now uses shared dailyExpiredExpr/weeklyExpiredExpr
          constants (supporting fixed reset mode) instead of hardcoded '24 hours'/'168 hours'
      H4: public settings endpoint now maps balance_low_notify_recharge_url
      H6: GetWebSearchEmulationMode tolerates legacy bool values (true→enabled)
      H7: UpdatePlan validates non-nil patch fields (rejects negative price, empty name, etc.)
      H8: UsageTable accountBilled() helper with total_cost ?? 0 null guard
      H9: AdminUsageLog TS type adds channel_id + billing_tier
      M2: account.go "fixed" literals replaced with thresholdTypeFixed constant
      M13: SystemSettings TS type adds web_search_emulation_enabled
      UI: QuotaLimitCard title labels now use flex-1 to align with flex-1 input boxes
      ed8a9d97
    • erio's avatar
      fix(accounts): unify modal width, add notify props to create, fix quota layout · a43da622
      erio authored
      - EditAccountModal width changed from "normal" to "wide" (match CreateAccountModal)
      - CreateAccountModal now passes all quota notify props to QuotaLimitCard
      - QuotaLimitCard: when global notify disabled, hide title row, input takes full width
      - Quota alert email: show remaining quota + threshold (fixed/$, percentage/%) instead of usage trigger point
      a43da622
    • erio's avatar
    • erio's avatar
      fix: change quota notify threshold semantics to "remaining quota" · 216bda58
      erio authored
      Threshold now represents remaining quota instead of usage amount:
      - Fixed ($): threshold=400, limit=1000 → alert when remaining drops to $400
        (i.e., usage reaches $600)
      - Percentage (%): threshold=30%, limit=1000 → alert when remaining drops
        to 30% (i.e., usage reaches $700)
      
      Also:
      - Rename 告警阈值 → 提醒阈值 in i18n
      - Widen type dropdown to w-16 for proper $ / % display
      216bda58
    • erio's avatar
      fix(frontend): place quota notify toggle inline with limit input · 7141dcee
      erio authored
      Move QuotaNotifyToggle to the same row as the limit $ input for all
      three dimensions (daily/weekly/total), significantly reducing card height.
      7141dcee
    • erio's avatar
      fix(frontend): collapsible quota card and compact notify layout · ac554432
      erio authored
      - QuotaLimitCard: add collapse/expand toggle (chevron icon + click header)
      - QuotaNotifyToggle: show $ or % suffix in threshold input
      - Reduce vertical spacing between reset mode hint and notify toggle
      ac554432
    • erio's avatar
      fix(frontend): quota notify UI improvements · 2066c478
      erio authored
      - QuotaNotifyToggle: add $ or % suffix to threshold input based on type
      - QuotaLimitCard: combine reset mode and notify toggle on same row
        to reduce vertical height for daily/weekly sections
      - Remove redundant ml-4 indentation from QuotaNotifyToggle
      2066c478
    • erio's avatar
      fix(frontend): simplify websearch select labels and reduce width · 245f47ce
      erio authored
      - "默认(跟随渠道)" → "默认", "Default (follow channel)" → "Default"
      - Move "follows channel config" info to description text
      - Reduce select width from w-32 to w-24 in both Edit and Create modals
      245f47ce
    • erio's avatar
      fix(frontend): hide quota notify toggle when global setting is disabled · 48e8efe3
      erio authored
      QuotaLimitCard now requires quotaNotifyGlobalEnabled prop to control
      visibility of QuotaNotifyToggle components. When the global account
      quota notification is disabled in admin settings, per-account threshold
      toggles are hidden in both Edit and Create account modals.
      48e8efe3
    • erio's avatar
      feat: WebSearch tri-state, account stats pricing fix, quota cache fix, usage tooltip · 1262654d
      erio authored
      WebSearch tri-state switch:
      - Account-level web_search_emulation changed from bool to tri-state
        string: "default" (follow channel) / "enabled" / "disabled"
      - shouldEmulateWebSearch checks channel config when account is "default"
      - SQL migration converts old bool values
      - Frontend select replaces toggle in Edit/CreateAccountModal
      
      Account stats pricing:
      - resolveAccountStatsCost uses upstream model (post-mapping) for matching
      - Priority: custom rules → model pricing file (when toggle on) → default
      - Custom rules always configurable, independent of toggle
      - Account ID field changed to searchable selector filtered by platform
      - Description updated to reflect new behavior
      
      Quota notification cache fix:
      - CheckAccountQuotaAfterIncrement fetches real-time account from DB
      - Reconstructs pre-increment usage for accurate threshold crossing detection
      - New AccountQuotaReader interface (minimal: GetByID only)
      
      Usage tooltip:
      - Per-request/image billing shows per-request price instead of $0 token price
      - Token billing continues to show input/output price per million tokens
      1262654d
    • erio's avatar
      feat(notify): add global toggles, percentage threshold, and visibility control · eba289a7
      erio authored
      - Add global toggle for account quota notification in admin settings
      - Add percentage-based threshold type for per-account quota alerts
      - Hide balance notify card on user profile when global toggle is off
      - Expose balance_low_notify_enabled and account_quota_notify_enabled in PublicSettings
      - Add threshold type (fixed/percentage) to QuotaNotifyToggle with $ / % switcher
      eba289a7
    • erio's avatar
      fix(websearch): improve settings UI and hide config when globally disabled · 889b5b4f
      erio authored
      - API Key show/copy buttons moved inside input field (inline icons)
      - Proxy selector and test button on same row to save vertical space
      - Test opens a dialog modal instead of inline display
      - Hide all websearch config in channels/accounts when global toggle is off
      889b5b4f
    • erio's avatar
      fix(notify): address review findings - accountCost formula, dedup, refactor · c3812ce1
      erio authored
      - Fix accountCost calculation in finalizePostUsageBilling to match
        postUsageBilling (always multiply by AccountRateMultiplier)
      - Use strings.EqualFold for email dedup in collectBalanceNotifyRecipients
      - Extract CheckAccountQuotaAfterIncrement into smaller functions:
        buildQuotaDims + asyncSendQuotaAlert (< 30 lines each)
      - Add "not splittable" comments for HTML template functions
      - Extract QuotaNotifyToggle.vue sub-component to reduce
        QuotaLimitCard.vue from 404 to 339 lines
      c3812ce1
    • erio's avatar
      feat(notify): add balance low & account quota notification system · b32d1a2c
      erio authored
      - User balance low notification: email alert when balance drops below
        configurable threshold (user email + verified extra emails)
      - Account quota notification: broadcast email to admin-configured
        recipients when daily/weekly/total quota usage exceeds alert threshold
      - Admin settings: global enable/disable, default threshold, quota
        notification email list (Email Settings tab)
      - User profile: enable/disable, custom threshold, add/remove extra
        notification emails with verification code flow
      - Account quota: per-dimension alert toggle and threshold in quota
        control card
      - Trigger logic: first-crossing only (old >= threshold && new < threshold
        for balance; old < threshold && new >= threshold for quota), naturally
        prevents duplicate notifications without Redis dedup
      b32d1a2c
    • erio's avatar
      feat(gateway): add web search emulation for Anthropic API Key accounts · 1b53ffca
      erio authored
      Inject web search capability for Claude Console (API Key) accounts that
      don't natively support Anthropic's web_search tool. When a pure
      web_search request is detected, the gateway calls Brave Search or Tavily
      API directly and constructs an Anthropic-protocol-compliant SSE/JSON
      response without forwarding to upstream.
      
      Backend:
      - New `pkg/websearch/` SDK: Brave and Tavily provider implementations
        with io.LimitReader, proxy support, and Redis-based quota tracking
        (Lua atomic INCR + TTL, DECR rollback on failure)
      - Global config via `settings.web_search_emulation_config` (JSON) with
        in-process cache + singleflight, input validation, API key merge on
        save, and sanitized API responses
      - Channel-level toggle via `channels.features_config` JSONB column
        (DB migration 101)
      - Account-level toggle via `accounts.extra.web_search_emulation`
      - Request interception in `Forward()` with SSE streaming response
        construction using json.Marshal (no manual string concatenation)
      - Manager hot-reload: `RebuildWebSearchManager()` called on config save
        and startup via `SetWebSearchRedisClient()`
      - 70 unit tests covering providers, manager, config validation,
        sanitization, tool detection, query extraction, and response building
      
      Frontend:
      - Settings → Gateway tab: Web Search Emulation config card with global
        toggle, provider list (add/remove, API key, priority, quota, proxy)
      - Channels → Anthropic tab: web search emulation toggle with global
        state linkage (disabled when global off)
      - Account Create/Edit modals: web search emulation toggle for API Key
        type with Toggle component
      - Full i18n coverage (zh + en)
      1b53ffca
  2. 12 Apr, 2026 1 commit
  3. 05 Apr, 2026 4 commits
  4. 30 Mar, 2026 1 commit
  5. 27 Mar, 2026 1 commit
    • shaw's avatar
      feat(tls-fingerprint): 新增 TLS 指纹 Profile 数据库管理及代码质量优化 · 1854050d
      shaw authored
      新增功能:
      - 新增 TLS 指纹 Profile CRUD 管理(Ent schema + 迁移 + Admin API + 前端管理界面)
      - 支持账号绑定数据库中的自定义 TLS Profile,或随机选择(profile_id=-1)
      - HTTPUpstream.DoWithTLS 接口从 bool 改为 *tlsfingerprint.Profile,支持按账号指定 Profile
      - AccountUsageService 注入 TLSFingerprintProfileService,统一 usage 场景与网关的 Profile 解析逻辑
      
      代码优化:
      - 删除已被 TLSFingerprintProfileService 完全取代的 registry.go 死代码(418 行)
      - 提取 3 个 dialer 的重复 TLS 握手逻辑为 performTLSHandshake() 共用函数
      - 修复 GetTLSFingerprintProfileID 缺少 json.Number 处理的 bug
      - gateway_service.Forward 中 ResolveTLSProfile 从重试循环内重复调用改为预解析局部变量
      - 删除冗余的 buildClientHelloSpec() 单行 wrapper 和 int64(e.ID) 无效转换
      - tls_fingerprint_profile_cache.go 日志从 log.Printf 改为 slog 结构化日志
      - dialer_capture_test.go 添加 //go:build integration 标签,防止 CI 失败
      - 去重 TestProfileExpectation 类型至共享 test_types_test.go
      - 修复 9 个测试文件缺少 tlsfingerprint import 的编译错误
      - 修复 error_policy_integration_test.go 中 handleError 回调签名被错误替换的问题
      1854050d
  6. 24 Mar, 2026 1 commit
  7. 23 Mar, 2026 2 commits
  8. 19 Mar, 2026 2 commits
    • shaw's avatar
      feat: Anthropic 账号被动用量采样,页面默认展示被动数据 · 525cdb88
      shaw authored
      从上游 /v1/messages 响应头被动采集 5h/7d utilization 并存储到
      Account.Extra,页面加载时直接读取本地数据而非调用外部 Usage API。
      用户可点击"查询"按钮主动拉取最新数据,主动查询结果自动回写被动缓存。
      
      后端:
      - UpdateSessionWindow 合并采集 5h + 7d headers 为单次 DB 写入
      - 新增 GetPassiveUsage 从 Extra 构建 UsageInfo (复用 estimateSetupTokenUsage)
      - GetUsage 主动查询后 syncActiveToPassive 回写被动缓存
      - passive_usage_ 前缀注册为 scheduler-neutral
      
      前端:
      - Anthropic 账号 mount/refresh 默认 source=passive
      - 新增"被动采样"标签和"查询"按钮 (带 loading 动画)
      525cdb88
    • Wang Lvyuan's avatar
  9. 17 Mar, 2026 3 commits
  10. 16 Mar, 2026 3 commits
    • Elysia's avatar
      fix(usage): use real reset header for session window instead of prediction · 668e1647
      Elysia authored
      
      
      The 5h window reset time displayed for Setup Token accounts was inaccurate
      because UpdateSessionWindow predicted the window end as "current hour + 5h"
      instead of reading the actual `anthropic-ratelimit-unified-5h-reset` response
      header. This caused the countdown to differ from the official Claude page.
      
      Backend: parse the reset header (Unix timestamp) and use it as the real
      window end, falling back to the hour-truncated prediction only when the
      header is absent. Also correct stale predictions when a subsequent request
      provides the real reset time.
      
      Frontend: add a reactive 60s timer so the reset countdown in
      UsageProgressBar ticks down in real-time instead of freezing at the
      initial value.
      Co-Authored-By: default avatarClaude Opus 4.6 <noreply@anthropic.com>
      668e1647
    • Ethan0x0000's avatar
    • 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
  11. 15 Mar, 2026 1 commit
    • 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