Skip to content

fix(web): refresh default usage log date range#6251

Draft
worryzyy wants to merge 1 commit into
QuantumNous:mainfrom
worryzyy:fix/usage-log-date-rollover
Draft

fix(web): refresh default usage log date range#6251
worryzyy wants to merge 1 commit into
QuantumNous:mainfrom
worryzyy:fix/usage-log-date-rollover

Conversation

@worryzyy

@worryzyy worryzyy commented Jul 16, 2026

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

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

Summary by CodeRabbit

  • Bug Fixes

    • Improved usage-log time-range filtering and display behavior.
    • Preserved explicitly selected historical ranges and partial time ranges.
    • Resetting filters now clears custom time ranges instead of restoring defaults.
    • Improved query parameter handling, including empty and zero-valued parameters.
  • Tests

    • Added coverage for default, explicit, and partial time-range filtering scenarios.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Usage-log query construction was moved to a dedicated module. Shared time-range helpers now preserve explicit boundaries and dynamic defaults, while both log filter bars use the new model for display, updates, reset behavior, and active-filter detection.

Changes

Usage-log filtering

Layer / File(s) Summary
Query utility extraction
web/default/src/features/usage-logs/lib/query.ts, web/default/src/features/usage-logs/lib/index.ts, web/default/src/features/usage-logs/lib/utils.ts, web/default/src/features/usage-logs/api.ts
buildQueryParams now lives in lib/query, with updated exports and API imports.
Time-range filter model
web/default/src/features/usage-logs/lib/filter.ts, web/default/src/features/usage-logs/lib/utils.ts, web/default/src/features/usage-logs/lib/filter.test.ts
Time-range helpers preserve explicit boundaries, support injectable defaults, adjust timestamp handling, and test default, historical, and partial ranges.
Filter-bar integration
web/default/src/features/usage-logs/components/*-logs-filter-bar.tsx
Both filter bars derive display ranges from filters, handle picker changes through callbacks, reset empty filters, and mark only explicit ranges as active.

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

Suggested reviewers: t0ng7u

Poem

I’m a rabbit with filters, hopping through time,
Defaults stay fresh and explicit dates align.
Queries pack neatly, blank fields take flight,
Reset clears the burrow and ranges show right.
Nibble, test, merge—what a delightful sight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: refreshing the default usage log date range behavior in the web app.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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 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 `@web/default/src/features/usage-logs/lib/filter.test.ts`:
- Around line 19-20: Replace the node:test and node:assert/strict imports in
web/default/src/features/usage-logs/lib/filter.test.ts:19-20 with Vitest’s
describe, test, and expect imports. Migrate assert.equal and assert.deepEqual
assertions at lines 42-53 and 65-71 to expect(...).toBe(...) and
expect(...).toEqual(...), and update lines 84-89 to the appropriate Vitest
matcher such as toBeUndefined().
🪄 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: 031a073f-5671-4df7-9b70-53b68a46867a

📥 Commits

Reviewing files that changed from the base of the PR and between a63364d and 4ec848e.

📒 Files selected for processing (8)
  • web/default/src/features/usage-logs/api.ts
  • web/default/src/features/usage-logs/components/common-logs-filter-bar.tsx
  • web/default/src/features/usage-logs/components/task-logs-filter-bar.tsx
  • web/default/src/features/usage-logs/lib/filter.test.ts
  • web/default/src/features/usage-logs/lib/filter.ts
  • web/default/src/features/usage-logs/lib/index.ts
  • web/default/src/features/usage-logs/lib/query.ts
  • web/default/src/features/usage-logs/lib/utils.ts

Comment on lines +19 to +20
import assert from 'node:assert/strict'
import { describe, test } from 'node:test'

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 | 🟠 Major | ⚡ Quick win

Use Vitest instead of Node's test runner.

As per coding guidelines, unit tests for utility functions and pure logic must be written with Vitest. The shared root cause here is the use of node:test and node:assert/strict instead of Vitest's describe, test, and expect APIs.

  • web/default/src/features/usage-logs/lib/filter.test.ts#L19-L20: Replace node:test and node:assert/strict imports with import { describe, test, expect } from 'vitest'.
  • web/default/src/features/usage-logs/lib/filter.test.ts#L42-L53: Rewrite these assert.equal and assert.deepEqual assertions to use Vitest's expect(...).toBe(...) and expect(...).toEqual(...).
  • web/default/src/features/usage-logs/lib/filter.test.ts#L65-L71: Migrate these assertions to Vitest's expect API.
  • web/default/src/features/usage-logs/lib/filter.test.ts#L84-L89: Migrate these assertions to Vitest's expect API (e.g., using expect(...).toBeUndefined()).
📍 Affects 1 file
  • web/default/src/features/usage-logs/lib/filter.test.ts#L19-L20 (this comment)
  • web/default/src/features/usage-logs/lib/filter.test.ts#L42-L53
  • web/default/src/features/usage-logs/lib/filter.test.ts#L65-L71
  • web/default/src/features/usage-logs/lib/filter.test.ts#L84-L89
🤖 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/usage-logs/lib/filter.test.ts` around lines 19 - 20,
Replace the node:test and node:assert/strict imports in
web/default/src/features/usage-logs/lib/filter.test.ts:19-20 with Vitest’s
describe, test, and expect imports. Migrate assert.equal and assert.deepEqual
assertions at lines 42-53 and 65-71 to expect(...).toBe(...) and
expect(...).toEqual(...), and update lines 84-89 to the appropriate Vitest
matcher such as toBeUndefined().

Source: Coding guidelines

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