Skip to content

Cscitech#1

Merged
CSCITech merged 4 commits into
mainfrom
cscitech
Jun 27, 2026
Merged

Cscitech#1
CSCITech merged 4 commits into
mainfrom
cscitech

Conversation

@CSCITech

Copy link
Copy Markdown
Contributor

⚠️ 提交说明 / PR Notice

Important

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

📝 变更描述 / Description

(简述:做了什么?为什么这样改能生效?请基于你对代码逻辑的理解来写,避免粘贴未经整理的内容)

🚀 变更类型 / Type of change

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

🔗 关联任务 / Related Issue

  • Closes # (如有)

✅ 提交前检查项 / Checklist

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

📸 运行证明 / Proof of Work

(请在此粘贴截图、关键日志或测试报告,以证明变更生效)

@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: d38a1a0d-8607-49f0-a502-3ae849690a11

📥 Commits

Reviewing files that changed from the base of the PR and between 50d2917 and 2db0d1e.

📒 Files selected for processing (6)
  • controller/relay.go
  • model/log_test.go
  • service/log_info_generate.go
  • web/default/src/features/usage-logs/components/common-logs-filter-bar.tsx
  • web/default/src/features/usage-logs/constants.ts
  • web/default/src/routes/_authenticated/usage-logs/$section.tsx
📜 Recent review details
🔇 Additional comments (6)
web/default/src/features/usage-logs/constants.ts (1)

119-121: LGTM!

web/default/src/features/usage-logs/components/common-logs-filter-bar.tsx (1)

44-44: LGTM!

Also applies to: 61-64

web/default/src/routes/_authenticated/usage-logs/$section.tsx (1)

22-35: LGTM!

service/log_info_generate.go (1)

36-45: LGTM!

Also applies to: 72-72

controller/relay.go (1)

390-390: LGTM!

model/log_test.go (1)

5-5: LGTM!

Also applies to: 23-131


📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added a Retry option to usage-log filtering, including matching search behavior and API/query support.
    • Channel “Models” can now be added as custom entries, and all model badges display inline without truncation/tooltips.
  • Bug Fixes

    • Retry-related logs are now filtered consistently across usage log list and statistics views.
    • Retry marker details are generated and attached more reliably when channels use multiple paths.

Walkthrough

Adds retry log marking and retry-aware filtering through backend query handlers, model helpers, and usage-log frontend validation, query encoding, and row matching. Channel models now render fully inline, and the model selector supports custom creation.

Changes

Retry Log Filter

Layer / File(s) Summary
Retry log marking
service/log_info_generate.go, controller/relay.go, service/log_info_generate_test.go
GenerateTextOtherInfo and processChannelError populate retry log metadata from use_channel, and tests cover multi- and single-channel cases.
Model filter helpers and signatures
model/log.go, model/log_test.go
Adds LogFilterRetry, log-type/filter helpers, updated query signatures, and tests that seed and verify retry-filtered log queries and quota stats.
Controller log_filter passthrough
controller/log.go
All usage-log list and stat handlers read log_filter and pass it to the model layer.
Frontend filter contracts
web/default/src/features/usage-logs/types.ts, web/default/src/features/usage-logs/constants.ts, web/default/src/routes/_authenticated/usage-logs/$section.tsx, web/default/src/features/usage-logs/components/common-logs-filter-bar.tsx
Adds retry-related log types, request fields, filter values, route validation, and filter-bar value validation.
Frontend log filter utilities
web/default/src/features/usage-logs/lib/utils.ts, web/default/src/features/usage-logs/lib/utils.test.ts, web/default/src/features/usage-logs/components/columns/common-logs-columns.tsx
Adds retry-aware query encoding and row matching helpers, plus tests for retry precedence and matching behavior. The common logs column filterFn now uses the shared matcher.

Channel UI Changes

Layer / File(s) Summary
Channel models column and drawer
web/default/src/features/channels/components/channels-columns.tsx, web/default/src/features/channels/components/drawers/channel-mutate-drawer.tsx
The models column renders all badges inline, and the channel model selector allows custom model creation.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐇 I hop through logs with retry in sight,
Two channels twinkle, marked just right.
The filter says “retry,” the rows agree,
And badges bloom wide in the UI tree.

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (1 warning, 2 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.68% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is too vague and does not describe the actual code changes in the pull request. Replace it with a concise, specific title that names the main change, such as the new retry log filtering support.
Description check ❓ Inconclusive The description is a generic template and does not provide concrete information about the changeset. Write a brief human-authored summary of what changed, why, and any validation performed.
✅ Passed checks (2 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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cscitech

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
web/default/src/features/channels/components/channels-columns.tsx (1)

840-850: 🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win

Restore a bounded models preview in the table.

Line 850 now renders every model badge inline, so a channel with a long/custom model list can expand one row into dozens of wrapped badges and make the table hard to scan and heavier to render. Keep the full list accessible, but cap the in-row badges and show the remainder behind a +N more affordance or tooltip.

Proposed fix
-        const modelBadges = modelArray.map((model, idx) => (
+        const visibleModels = modelArray.slice(0, 2)
+        const hiddenCount = Math.max(0, modelArray.length - visibleModels.length)
+
+        const modelBadges = visibleModels.map((model, idx) => (
           <StatusBadge
             key={idx}
             label={model}
             autoColor={model}
             size='sm'
             className='font-mono'
           />
         ))
 
-        return <div className='flex max-w-full flex-wrap gap-1'>{modelBadges}</div>
+        return (
+          <div className='flex max-w-full flex-wrap gap-1'>
+            {modelBadges}
+            {hiddenCount > 0 && (
+              <StatusBadge
+                label={`+${hiddenCount} more`}
+                size='sm'
+                variant='neutral'
+                copyable={false}
+              />
+            )}
+          </div>
+        )
🤖 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 `@web/default/src/features/channels/components/channels-columns.tsx` around
lines 840 - 850, The channel models cell currently renders the entire modelArray
as inline StatusBadge items in the table, which can blow up row height and hurt
performance. Update the models preview logic in channels-columns.tsx so the
in-row display is bounded to a small fixed count, and expose any remaining
models through a “+N more” indicator, tooltip, or similar affordance. Keep the
existing modelBadges rendering pattern in place for the visible subset, and
preserve access to the full list via the same cell/component.
🤖 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 `@controller/relay.go`:
- Around line 390-394: Deduplicate the retry metadata assembly currently in the
relay flow by extracting the shared use_channel/retry_log logic into a common
helper used by controller relay handling and service/log_info_generate.go, or
add a regression test that covers the error path as well. Update the
controller/relay.go block around useChannel and retry_log so it delegates to the
same logic as GenerateTextOtherInfo, keeping success and error log metadata in
sync.

In `@model/log_test.go`:
- Around line 22-81: The retry-filter coverage is incomplete because this test
only exercises GetAllLogs, while the PR also changes GetUserLogs and
SumUsedQuota with separate query paths. Add focused regression tests for those
two entrypoints using the same LogFilterRetry contract and representative log
rows so the filter behavior is verified across all query builders, not just
GetAllLogs.

In `@model/log.go`:
- Around line 80-85: The retry filter in applyRetryLogFilter is scanning the
unindexed logs.other JSON blob with leading-wildcard LIKE predicates, which will
not scale for list and stat queries. Update the retry marker handling in
applyRetryLogFilter and the related query paths to use a dedicated indexed
column or a generated/indexed expression for the retry flag, and keep the filter
logic pointed at that searchable field instead of logs.other.

In `@web/default/src/features/usage-logs/components/common-logs-filter-bar.tsx`:
- Around line 60-70: The allowed log-type tuple is duplicated in
common-logs-filter-bar and the authenticated usage-logs route, which can drift
from the existing selectable options source. Move the permitted values into a
shared exported constant in usage-logs/constants and update both the
logTypeValues usage in common-logs-filter-bar and the route’s validation to
reference that single tuple instead of hardcoding their own copies.

---

Outside diff comments:
In `@web/default/src/features/channels/components/channels-columns.tsx`:
- Around line 840-850: The channel models cell currently renders the entire
modelArray as inline StatusBadge items in the table, which can blow up row
height and hurt performance. Update the models preview logic in
channels-columns.tsx so the in-row display is bounded to a small fixed count,
and expose any remaining models through a “+N more” indicator, tooltip, or
similar affordance. Keep the existing modelBadges rendering pattern in place for
the visible subset, and preserve access to the full list via the same
cell/component.
🪄 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: ASSERTIVE

Plan: Pro Plus

Run ID: 65960301-b3ae-45b6-bc7e-7dee16333d9b

📥 Commits

Reviewing files that changed from the base of the PR and between 8519b9b and 50d2917.

📒 Files selected for processing (15)
  • controller/log.go
  • controller/relay.go
  • model/log.go
  • model/log_test.go
  • service/log_info_generate.go
  • service/log_info_generate_test.go
  • web/default/src/features/channels/components/channels-columns.tsx
  • web/default/src/features/channels/components/drawers/channel-mutate-drawer.tsx
  • web/default/src/features/usage-logs/components/columns/common-logs-columns.tsx
  • web/default/src/features/usage-logs/components/common-logs-filter-bar.tsx
  • web/default/src/features/usage-logs/constants.ts
  • web/default/src/features/usage-logs/lib/utils.test.ts
  • web/default/src/features/usage-logs/lib/utils.ts
  • web/default/src/features/usage-logs/types.ts
  • web/default/src/routes/_authenticated/usage-logs/$section.tsx
💤 Files with no reviewable changes (1)
  • web/default/src/features/channels/components/drawers/channel-mutate-drawer.tsx
📜 Review details
🔇 Additional comments (9)
service/log_info_generate.go (1)

61-65: LGTM!

service/log_info_generate_test.go (1)

13-32: LGTM!

Also applies to: 34-50

controller/log.go (1)

18-28: LGTM!

Also applies to: 72-80, 160-168, 189-196

web/default/src/features/usage-logs/types.ts (1)

131-132: LGTM!

Also applies to: 305-305, 336-336

web/default/src/features/usage-logs/constants.ts (1)

69-69: LGTM!

Also applies to: 110-110

web/default/src/routes/_authenticated/usage-logs/$section.tsx (1)

27-27: LGTM!

web/default/src/features/usage-logs/lib/utils.ts (1)

31-35: LGTM!

Also applies to: 44-44, 98-116, 205-230, 248-270, 279-279

web/default/src/features/usage-logs/components/columns/common-logs-columns.tsx (1)

55-55: LGTM!

Also applies to: 297-297

web/default/src/features/usage-logs/lib/utils.test.ts (1)

23-125: LGTM!

Comment thread controller/relay.go Outdated
Comment thread model/log_test.go
Comment thread model/log.go
Comment on lines +80 to +85
func applyRetryLogFilter(tx *gorm.DB) *gorm.DB {
retryPatterns := []string{
`%"retry_log":true%`,
`%"empty_retry":true%`,
}
return tx.Where("(logs.other LIKE ? OR logs.other LIKE ?)", retryPatterns[0], retryPatterns[1])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🚀 Performance & Scalability | 🔵 Trivial

Plan for a searchable retry flag.

logs.other is an unindexed text field here, and the new retry filter uses leading-wildcard LIKE predicates on it in both list and stat queries. If this filter is expected to see real usage at scale, consider materializing the retry marker into a dedicated column or indexed/generated expression instead of scanning JSON blobs.

🤖 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 `@model/log.go` around lines 80 - 85, The retry filter in applyRetryLogFilter
is scanning the unindexed logs.other JSON blob with leading-wildcard LIKE
predicates, which will not scale for list and stat queries. Update the retry
marker handling in applyRetryLogFilter and the related query paths to use a
dedicated indexed column or a generated/indexed expression for the retry flag,
and keep the filter logic pointed at that searchable field instead of
logs.other.

Comment thread web/default/src/features/usage-logs/components/common-logs-filter-bar.tsx Outdated
@CSCITech
CSCITech merged commit 7da36ae into main Jun 27, 2026
3 checks passed
This was referenced Jul 1, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Jul 18, 2026
11 tasks
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