Skip to content

Release v0.9.14: New features and improvements - #2134

Closed
nick3 wants to merge 44 commits into
QuantumNous:mainfrom
nick3:alpha
Closed

Release v0.9.14: New features and improvements#2134
nick3 wants to merge 44 commits into
QuantumNous:mainfrom
nick3:alpha

Conversation

@nick3

@nick3 nick3 commented Oct 30, 2025

Copy link
Copy Markdown

This PR includes the latest features and fixes for the v0.9.14 release. Includes:

  • Japanese language support
  • New translations for 'The Unified' and 'LLM API Gateway'
  • Usage log improvements
  • Claude streaming log fixes
  • Docker image updates
  • Other bug fixes and improvements

Signed-off-by: nick3 nick3@example.com

Summary by CodeRabbit

Release Notes

  • New Features

    • Configurable detailed log retention with preset options (1, 3, 7, 30, 90 days) or custom values
    • Enhanced log viewer with detail drawer to inspect request and response payloads
  • Improvements

    • Log retention cleanup performance optimization
  • Changes

    • Removed IP logging setting from user account settings

* 修改了 GitHub Actions 工作流中的 Docker 镜像名称
* 适用于 `docker-image-alpha.yml` 和 `docker-image-arm64.yml`
* 在 `common` 包中添加了日志捕获功能,用于存储请求和响应体的预览。
* 更新了多个控制器以捕获和记录请求和响应体。
* 新增 `LogDetail` 结构体以支持详细日志记录。
* 修改数据库迁移以包含 `LogDetail` 表。
* 新增 `UsageLogDetailDrawer` 组件,用于展示请求和响应的详细信息。
* 在 `UsageLogsColumnDefs` 中添加操作列,允许用户查看日志详情。
* 更新 `UsageLogsTable` 和 `useUsageLogsData` 以支持新功能。
* 通过 `openDetailDrawer` 函数管理抽屉的打开和关闭状态。
* 删除对 `common.AppendPayloadChunkForLog` 的调用,以避免不必要的重复日志记录。
* 改进数据处理逻辑,确保更高效的资源使用。
* 新增 `DetailedLogRetentionDays` 常量,默认值为 30 天。
* 实现日志清理机制,定期删除过期日志记录。
* 更新前端设置界面,允许用户自定义日志保留天数。
* 添加多语言支持,更新相关翻译文件。
* 新增 `DetailedLogRetentionDays` 常量,默认值为 30 天。
* 实现日志清理机制,定期删除过期日志记录。
* 更新前端设置界面,允许用户自定义日志保留天数。
* 添加多语言支持,更新相关翻译文件。
* 在 `LogDetail` 结构体的 `created_at` 字段上添加索引,避免全表扫描。
* 新增数据库迁移脚本 `bin/add_log_detail_index.sql`,支持 MySQL、PostgreSQL 和 SQLite。
* 改进日志清理策略,使用索引优化删除操作,并添加批次间延迟以减少数据库负载。
feat(logs): ✨ 添加详细日志保留设置功能
* 删除用户设置中的 `recordIpLog` 字段,简化用户设置结构。
* 更新相关的日志记录函数,确保不再依赖该字段。
* 调整前端组件以反映设置的变化,移除不必要的隐私设置选项。
Signed-off-by: Nick Liu <imjustanemail@gmail.com>
* 更新 `payload_log.go` 和 `log_retention.go` 中的导入路径
* 确保引用的常量和日志模块来自正确的 GitHub 仓库
nick3 and others added 14 commits October 15, 2025 11:54
* 将 `docker-compose.yml` 中 `new-api.image` 从 `calciumion/new-api:latest` 替换为 `nick3/new-api:latest`。
Signed-off-by: Nick Liu <imjustanemail@gmail.com>
- Add /.spec-workflow to ignored paths
- Prevent spec workflow files from being tracked by git

This change ensures that files generated by the spec workflow tool don't get accidentally committed to the repository.
- Modify aggregateOpenAIStreamChunks function to concatenate content fragments
  instead of treating them as separate array items
- This prevents each SSE token from being displayed on separate lines in the
  usage log request detail panel
- Maintain proper handling of tool calls and reasoning content during aggregation

This fixes the issue where streaming LLM responses were showing each token
on a separate line instead of as a continuous response in the "使用日志" page.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
@coderabbitai

coderabbitai Bot commented Oct 30, 2025

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Walkthrough

This PR implements log detail retention optimization with configurable retention policies, enhanced payload capture for requests and responses, removes IP logging settings from user preferences, updates Docker image repository references, and adds a detailed log viewing UI with streaming response parsing capabilities.

Changes

Cohort / File(s) Summary
Docker & CI/CD
.github/workflows/docker-image-alpha.yml, docker-image-arm64.yml
Updated Docker image repository references from calciumion/new-api to nick3/new-api and replaced env.GHCR_REPOSITORY with github.repository in build tags and manifest creation steps.
Configuration & Documentation
.gitignore, AGENTS.md, RELEASE_NOTES.md, VERSION, docker-compose.yml
Added .spec-workflow and .serena to .gitignore; introduced contributor guidelines in AGENTS.md; documented v0.9.8 and v0.9.7-patch.1 releases in RELEASE_NOTES.md; bumped version to v0.9.8; updated Docker Compose image reference.
Log Detail Infrastructure
bin/add_log_detail_index.sql, docs/log_detail_optimization.md
Added SQL migration script to create idx_log_details_created_at index and documented log retention optimization with indexing, migration, and cleanup workflow improvements.
Core Model & Migration Layer
model/log.go, model/log_retention.go, model/main.go, model/option.go
Introduced LargeText GORM type, LogDetail model with separation of request/response bodies, LogDetail table relations, batch cleanup with context cancellation support, updated migrations, and added DetailedLogRetentionDays option handling.
Constants & Options
common/constants.go, controller/option.go
Added DetailedLogRetentionDays global configuration (default 30 days) and validation/parsing logic in option updates.
Payload Capture & Logging
common/gin.go, common/payload_log.go, controller/relay.go, relay/helper/common.go, service/http.go
Reworked request body caching with payload logging; added comprehensive payload capture utilities with truncation, binary detection, and context-based storage; integrated payload logging in relay error handlers and HTTP response handling.
Log Recording
controller/channel-test.go, main.go
Added ResponseBodyPreview field to RecordConsumeLogParams and initialized StartLogDetailRetentionCleaner() in main.
User Settings - Removal
controller/user.go, dto/user_settings.go, web/src/components/settings/PersonalSetting.jsx, web/src/components/settings/personal/cards/NotificationSettings.jsx
Removed RecordIpLog field from user settings across backend DTO/controller and frontend UI components; removed privacy tab from notification settings.
Frontend - Log Retention Settings
web/src/components/settings/SystemSetting.jsx
Added UI for configurable log retention with preset options (1, 3, 7, 30, 90 days), custom value input, and server synchronization via updateOptions.
Frontend - Log Detail Viewing
web/src/components/table/usage-logs/UsageLogDetailDrawer.jsx, UsageLogsColumnDefs.jsx, UsageLogsTable.jsx, index.jsx
Introduced UsageLogDetailDrawer component with JSON/streaming response parsing, message segment rendering (text, reasoning, tool calls, results), formatted/raw view modes, and admin-only detail viewing action button.
Frontend - Logs Hook & State
web/src/hooks/usage-logs/useUsageLogsData.jsx
Extended hook with detail drawer visibility state, view mode toggling, selected log detail tracking, admin-only ACTION column visibility, and drawer open/close handlers.
Frontend - Translations
web/src/i18n/locales/en.json, fr.json, ru.json, zh.json
Added translations for "工具调用" (Tool call) and "工具结果" (Tool result) across English, French, Russian, and Chinese locales.

Sequence Diagram(s)

sequenceDiagram
    participant User as User/Request
    participant Handler as HTTP Handler
    participant PayloadLog as Payload Log Util
    participant Context as Gin Context
    participant DB as Database
    participant Cleaner as Retention Cleaner

    User->>Handler: Request with body
    Handler->>PayloadLog: CapturePayloadForLog(ctx, key, data)
    PayloadLog->>PayloadLog: Check if binary, format, truncate
    PayloadLog->>Context: Store preview & full payload
    PayloadLog-->>Handler: Return formatted preview
    
    Handler->>DB: CreateLog(requestPreview, responsePreview)
    Handler->>DB: PersistLogDetail(logId, requestBody, responseBody)
    
    Note over Cleaner: Background task runs periodically
    Cleaner->>DB: Query LogDetails older than retention days
    Cleaner->>DB: Delete batch with ORDER BY created_at ASC
    Cleaner->>Cleaner: Sleep 100ms between batches
    Cleaner->>Cleaner: Check context cancellation
Loading
sequenceDiagram
    participant Admin as Admin User
    participant LogsUI as Logs Table UI
    participant DetailDrawer as Detail Drawer
    participant PayloadParser as Payload Parser
    participant Display as Rendered View

    Admin->>LogsUI: View usage logs table
    LogsUI->>LogsUI: Render ACTION column (admin-only)
    Admin->>LogsUI: Click eye icon on log row
    LogsUI->>DetailDrawer: openDetailDrawer(selectedLog)
    DetailDrawer->>PayloadParser: Parse request/response bodies
    PayloadParser->>PayloadParser: Handle streaming responses
    PayloadParser->>PayloadParser: Build message segments (text/tool_call/reasoning)
    PayloadParser-->>Display: Render formatted or raw view
    Admin->>Display: Toggle between formatted & raw modes
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

This PR spans multiple interconnected systems with varying complexity:

  • Database & Model Layer: New LogDetail model, LargeText type, and retention cleanup logic with batch processing and context cancellation handling require careful review of data model changes and deletion logic.
  • Payload Capture: New comprehensive payload_log.go with truncation, binary detection, and context-based storage across multiple helper functions introduces logic density requiring verification of edge cases.
  • Frontend Detail Component: UsageLogDetailDrawer.jsx is substantial with numerous parsing utilities for streaming responses, message aggregation, and multiple rendering modes—requires careful review of JSON parsing, Unicode handling, and segment construction logic.
  • Configuration Changes: Cross-layer impacts of DetailedLogRetentionDays configuration across controller, model, and frontend layers need verification for consistency.
  • User Settings Removal: Changes to IP logging across backend and frontend require verification that all references are properly cleaned up.

Areas requiring extra attention:

  • Payload truncation and binary detection logic in common/payload_log.go for correctness
  • Streaming response aggregation and message parsing in UsageLogDetailDrawer.jsx (particularly aggregateOpenAIStreamChunks and aggregateClaudeStreamEvents)
  • Batch deletion logic in model/log_retention.go with ORDER BY and context cancellation
  • Consistency of RecordIpLog removal across all affected files
  • Impact of LogDetail separation on existing log retrieval and display performance
  • Admin-only visibility guards for ACTION column in useUsageLogsData

Possibly related PRs

Suggested reviewers

  • Calcium-Ion
  • creamlike1024
  • seefs001

Poem

🐰 A rabbit hops through logs so deep,
With payloads captured, clean and neat,
Old IP records fade away,
While details bloom in structured display,
Retention policies keep the peace,
As database indexes bring sweet release! 🌿✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f1ac560 and ee06c5f.

📒 Files selected for processing (37)
  • .github/workflows/docker-image-alpha.yml (3 hunks)
  • .github/workflows/docker-image-arm64.yml (3 hunks)
  • .gitignore (1 hunks)
  • AGENTS.md (1 hunks)
  • RELEASE_NOTES.md (1 hunks)
  • VERSION (1 hunks)
  • bin/add_log_detail_index.sql (1 hunks)
  • common/constants.go (1 hunks)
  • common/gin.go (1 hunks)
  • common/payload_log.go (1 hunks)
  • constant/context_key.go (1 hunks)
  • controller/channel-test.go (1 hunks)
  • controller/option.go (2 hunks)
  • controller/relay.go (2 hunks)
  • controller/user.go (0 hunks)
  • docker-compose.yml (1 hunks)
  • docs/log_detail_optimization.md (1 hunks)
  • dto/user_settings.go (0 hunks)
  • main.go (1 hunks)
  • model/log.go (7 hunks)
  • model/log_retention.go (1 hunks)
  • model/main.go (3 hunks)
  • model/option.go (3 hunks)
  • relay/helper/common.go (4 hunks)
  • service/http.go (2 hunks)
  • web/src/components/settings/PersonalSetting.jsx (0 hunks)
  • web/src/components/settings/SystemSetting.jsx (7 hunks)
  • web/src/components/settings/personal/cards/NotificationSettings.jsx (2 hunks)
  • web/src/components/table/usage-logs/UsageLogDetailDrawer.jsx (1 hunks)
  • web/src/components/table/usage-logs/UsageLogsColumnDefs.jsx (5 hunks)
  • web/src/components/table/usage-logs/UsageLogsTable.jsx (2 hunks)
  • web/src/components/table/usage-logs/index.jsx (2 hunks)
  • web/src/hooks/usage-logs/useUsageLogsData.jsx (8 hunks)
  • web/src/i18n/locales/en.json (1 hunks)
  • web/src/i18n/locales/fr.json (1 hunks)
  • web/src/i18n/locales/ru.json (1 hunks)
  • web/src/i18n/locales/zh.json (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nick3 nick3 closed this Oct 30, 2025
@nick3
nick3 deleted the alpha branch October 30, 2025 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant