Skip to content

[codex] feat(logs): filter model test logs in admin view - #6314

Closed
IQZZ020501 wants to merge 3 commits into
QuantumNous:mainfrom
IQZZ020501:codex/new-feature
Closed

[codex] feat(logs): filter model test logs in admin view#6314
IQZZ020501 wants to merge 3 commits into
QuantumNous:mainfrom
IQZZ020501:codex/new-feature

Conversation

@IQZZ020501

@IQZZ020501 IQZZ020501 commented Jul 19, 2026

Copy link
Copy Markdown

⚠️ 提交说明 / PR Notice

Important

  • 请提供人工撰写的简洁摘要,避免直接粘贴未经整理的 AI 输出。

📝 变更描述 / Description

管理员通用日志目前会混入渠道模型测试产生的消费日志,影响日常请求排查和统计阅读。本次改动使用模型测试日志已有的稳定标识,在管理员日志列表和统计查询中默认排除这类记录,并在筛选栏提供“排除/包含模型测试日志”切换。个人日志查询保持原有行为。

本次代码与 PR 描述由 Codex AI 辅助生成,提交者需人工复核后再合并。

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix) - 请关联对应 Issue,避免将设计取舍、理解偏差或预期不一致直接归类为 bug
  • ✨ 新功能 (New feature) - 重大特性建议先通过 Issue 沟通
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 IssuesPRs,确认不是重复提交。PR 检索未发现相同改动;Issues 检索因 GitHub API 间歇性连接失败未完成。
  • Bug fix 说明: 若此 PR 标记为 Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。本 PR 不标记为 Bug fix。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • 本地验证: 已在本地运行并通过测试或手动验证,维护者可以据此复核结果。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

  • go test ./model -run TestAdminLogQueriesExcludeChannelTestsByDefault -count=1
  • go test ./controller -run '^$' -count=1
  • bun run typecheck
  • 相关前端文件定向 oxlint 通过;仓库现有 usage-logs/api.tslib/utils.ts 循环依赖规则未纳入本次范围
  • bun run i18n:sync
  • bun run build
  • jq empty docs/openapi/api.json

Summary by CodeRabbit

  • New Features

    • Administrators can include or exclude model test logs when viewing usage logs and statistics.
    • Added localized labels for the new log filtering options.
    • Task Logs navigation is now shown only to administrators.
  • Bug Fixes

    • Corrected log and quota calculations so model test entries are excluded by default.
    • Improved filter state handling across desktop and mobile views.
  • Documentation

    • Added project architecture, billing, development, frontend, feature, and request-flow documentation.

…n user role

- Created project function and design documentation in `docs/project/README.md`, `docs/project/architecture.md`, `docs/project/billing-and-data.md`, `docs/project/development-guide.md`, `docs/project/frontend-design.md`, `docs/project/relay-pipeline.md`, and `docs/project/features.md`.
- Implemented a `.gitignore` file for CodeGraph data files.
- Updated `SiderBar.jsx` to conditionally display the task item based on user role and local storage setting.
- Enhanced `use-sidebar-data.ts` to include task logs visibility for admin users only.
feat(web): show task logs only to administrators
@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The change adds project design documentation and introduces administrator-controlled filtering of model test logs across backend queries, API contracts, usage-log UI state, navigation visibility, and localization.

Changes

Model Test Log Filtering

Layer / File(s) Summary
Project documentation and contribution rules
.codegraph/.gitignore, AGENTS.md, docs/project/*
Adds project documentation covering architecture, billing, development, frontend conventions, features, relay flow, and documentation update rules.
Backend model-test log filtering
controller/channel-test.go, controller/log.go, model/log.go, model/log_filter_test.go, docs/openapi/api.json
Adds a shared model-test log label and excludes those logs by default from log listings and statistics, with an include_model_test API option and coverage tests.
Task-log navigation access
web/classic/src/components/layout/SiderBar.jsx, web/default/src/hooks/use-sidebar-data.ts
Restricts task-log navigation to administrators in both frontend themes.
Usage-log filter state and UI
web/default/src/features/usage-logs/..., web/default/src/routes/..., web/default/src/i18n/locales/*
Adds administrator-only model-test inclusion controls, URL state handling, API parameter generation, mobile filter support, and translations.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Admin as Administrator
  participant UsageLogs as Usage-log UI
  participant API as Log API
  participant Model as Log model
  Admin->>UsageLogs: Select include model test logs
  UsageLogs->>API: Send include_model_test=true
  API->>Model: Query logs and statistics
  Model-->>API: Return matching results
  API-->>UsageLogs: Render filtered logs and statistics
Loading

Possibly related PRs

Suggested reviewers: calcium-ion

Poem

I’m a rabbit with logs in my hat,
Filtering test trails—just like that.
Admins choose what they see,
Clean queries hop free,
And docs grow ears where they sat.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding model test log filtering to the administrator log view.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/project/features.md`:
- Line 34: Update the “日志与统计” entry to specify that administrator log-list and
statistical queries exclude model-test logs by default, only administrators can
control their inclusion or exclusion, and personal-log queries retain their
existing behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 39207cc9-f3a6-493e-ad40-0dfd199b77a2

📥 Commits

Reviewing files that changed from the base of the PR and between 5a6c53d and d0a1c87.

📒 Files selected for processing (27)
  • .codegraph/.gitignore
  • AGENTS.md
  • controller/channel-test.go
  • controller/log.go
  • docs/openapi/api.json
  • docs/project/README.md
  • docs/project/architecture.md
  • docs/project/billing-and-data.md
  • docs/project/development-guide.md
  • docs/project/features.md
  • docs/project/frontend-design.md
  • docs/project/relay-pipeline.md
  • model/log.go
  • model/log_filter_test.go
  • web/classic/src/components/layout/SiderBar.jsx
  • web/default/src/features/usage-logs/components/common-logs-filter-bar.tsx
  • web/default/src/features/usage-logs/lib/utils.ts
  • web/default/src/features/usage-logs/types.ts
  • web/default/src/hooks/use-sidebar-data.ts
  • web/default/src/i18n/locales/en.json
  • web/default/src/i18n/locales/fr.json
  • web/default/src/i18n/locales/ja.json
  • web/default/src/i18n/locales/ru.json
  • web/default/src/i18n/locales/vi.json
  • web/default/src/i18n/locales/zh-TW.json
  • web/default/src/i18n/locales/zh.json
  • web/default/src/routes/_authenticated/usage-logs/$section.tsx

Comment thread docs/project/features.md
| 计费 | 模型倍率、固定价格、动态表达式计费、预扣、实际用量结算、失败退款和违规费用 | `relay/helper/price.go`、`service/billing_session.go`、`service/quota.go`、`pkg/billingexpr/` | 定价、钱包、日志和系统计费设置 |
| 钱包与充值 | 余额、兑换码、充值订单、邀请额度转移及多支付渠道 | `controller/topup*.go`、`controller/redemption.go`、`model/topup.go` | `features/wallet/`、`features/redemption-codes/` |
| 订阅 | 订阅计划、用户订阅、周期额度重置、余额/支付渠道购买及资金来源偏好 | `controller/subscription*.go`、`service/subscription_reset_task.go`、`model/subscription.go` | `features/subscriptions/`、`features/wallet/` |
| 日志与统计 | 请求日志、任务日志、用户/管理员统计、排行榜、渠道亲和统计和用量聚合;管理员通用日志默认排除渠道模型测试日志,可按需包含 | `controller/log.go`、`controller/usedata.go`、`controller/rankings.go`、`model/log.go` | `features/usage-logs/`、`features/dashboard/`、`features/rankings/` |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Document the filter scope and permission boundary precisely.

This entry only says that administrator logs can optionally include model-test logs. State that administrator list and statistical queries exclude them by default, the include/exclude control is administrator-only, and personal-log queries retain their existing behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/project/features.md` at line 34, Update the “日志与统计” entry to specify
that administrator log-list and statistical queries exclude model-test logs by
default, only administrators can control their inclusion or exclusion, and
personal-log queries retain their existing behavior.

Source: Coding guidelines

@IQZZ020501
IQZZ020501 marked this pull request as ready for review July 31, 2026 06:14
@IQZZ020501 IQZZ020501 closed this Jul 31, 2026
@IQZZ020501
IQZZ020501 deleted the codex/new-feature branch July 31, 2026 06:14
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