feat(managed-agents): Agents 列表 Created 过滤器支持自定义日期范围 - #111
Conversation
|
Warning Review limit reached
Next review available in: 15 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe managed-agent Created filter now supports structured presets and custom calendar ranges, inclusive API bounds, localized labels, stable request identities, and draft Apply behavior. A shared calendar component, dependency updates, page integration, design documentation, and automated coverage were added. ChangesCreated-date filtering
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant CreatedFilterDropdown
participant AgentsResourcePage
participant listAgents
participant AgentAPI
User->>CreatedFilterDropdown: select preset or draft calendar range
CreatedFilterDropdown->>AgentsResourcePage: commit filter on preset or Apply
AgentsResourcePage->>listAgents: request using created-filter key
listAgents->>AgentAPI: send inclusive created_at bounds
AgentAPI-->>listAgents: return matching agents
Possibly related issues
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/src/features/managed-agents/labels.ts`:
- Around line 114-124: Update formatCustomCreatedRange to parse filter.from and
filter.to with date-fns parseISO instead of Date.parse, adding parseISO to the
existing date-fns imports. Preserve the existing invalid-date fallback and
range-label formatting behavior.
In `@web/src/shared/ui/calendar.tsx`:
- Around line 132-139: Remove the local ref and the useEffect focus logic from
the calendar button component; rely on react-day-picker’s built-in roving
tabindex and keyboard navigation while preserving the existing Button rendering
and props.
🪄 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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: b532321a-d57b-4123-88cf-75fad433b508
⛔ Files ignored due to path filters (1)
web/bun.lockis excluded by!**/*.lock
📒 Files selected for processing (9)
web/package.jsonweb/src/features/managed-agents/ManagedAgentsPage.agents.suite.tsxweb/src/features/managed-agents/agents/AgentsResourcePage.tsxweb/src/features/managed-agents/agents/CreatedFilterDropdown.tsxweb/src/features/managed-agents/agents/model.tsxweb/src/features/managed-agents/api.tsweb/src/features/managed-agents/labels.tsweb/src/features/managed-agents/types.tsweb/src/shared/ui/calendar.tsx
There was a problem hiding this comment.
DuckPR reviewer: opencode
Model: anthropic/glm-5.2
Important
有两处需要修正的问题:package.json 中引入了未使用的 radix-ui 依赖;labels.ts 中 Custom Range 的日期标签在非 UTC 时区下会出现跨日偏差。具体位置及修改建议见行内评论。
Reviewed changes — 本次 PR 为 Agents 列表的「Created」过滤器实现了 Custom Range 自定义日期区间,并将 AgentCreatedFilter 重构为 discriminated union,同时新增 CreatedFilterDropdown 与 shadcn Calendar 组件。
AgentCreatedFilter改为{ kind }discriminated union,支持all/last7/last30与{ kind: 'custom'; from: string; to: string }。createdFilterRange将 custom 日期映射为created_at[gte]与created_at[lte]的 UTC 日边界。CreatedFilterDropdown用 Popover +react-day-picker实现 preset 即时选择与 Custom Range 折叠面板。web/src/shared/ui/calendar.tsx新增 shadcn 风格Calendar组件。ManagedAgentsPage.agents.suite.tsx同步将 filter 断言从menuitemradio调整为radio。
anthropic/glm-5.2 | 𝕏
There was a problem hiding this comment.
整体方向没问题,类型和 API 上下界这条链路也已经接起来了。我在 PR head 上跑了完整前端测试、build、format、naming、complexity 和 duplicates,都是通过的。这里先 request changes,主要是几个现有测试没有覆盖到的问题:
1.日期标签的时区和多语言
2.Custom Range 的实际交互测试
3.RadioGroup 键盘行为,以及未使用依赖。
#109 里写到的 URL 恢复可以拆到后续 PR;如果这次不做,麻烦建一个跟踪 issue,并同步调整 #109 的验收范围和本 PR 描述,避免看起来已经完整交付。这个改动也请补一下对应的 design 文档。另:CalendarDayButton 的 ref/effect 我对过 react-day-picker 10.0.1 的上游实现,默认 DayButton 本身就是同样的逻辑,这条不需要按 bot 建议删除。修完后请再跑一遍现有门禁,并手动检查一下键盘方向键选择和 UTC− 时区下的日期显示。
响应 superduck-ai#111 review (@jh0904) 的 request changes: - labels.ts:custom range 解析改用 date-fns parseISO(yyyy-MM-dd 按本地日), 修复 Date.parse 当 UTC 导致 UTC− 时区标签偏移一天;抽出 locale-aware 的 formatCreatedRange / formatCreatedRangeDay(基于 Intl.DateTimeFormat), trigger 与 draft 共用,中文界面不再固定英文月份 - CreatedFilterDropdown:preset 列表改用项目共享 RadioGroup(@base-ui)+ Radio.Root,获得方向键选择与 roving tabindex,样式保持整行选项; trigger 与 draft label 传 locale - package.json:移除未使用的 radix-ui 直接依赖并重新生成 bun.lock, 避免带入整套 @radix-ui/* 元包 - 测试:labels.test.ts 在 TZ=America/Los_Angeles 下覆盖 UTC− 时区 / locale / invalid fallback / range 折叠;suite 新增 Custom Range 端到端(Apply 前 不发请求、Apply 后同时带 created_at[gte]/[lte]、上下界值正确)与 zh-CN locale 用例 - docs/design/fe/agents-created-filter.md:补充设计文档(类型/UI/API 边界 /时区/键盘可达性/测试计划) - calendar.tsx 的 DayButton ref 按 review 结论保留(与上游 react-day-picker 默认实现一致) URL 序列化与刷新恢复按 review 共识拆到 superduck-ai#135 单独跟踪;本 PR 不含。
|
@jh0904 感谢,request changes 都处理了:
|
There was a problem hiding this comment.
DuckPR reviewer: opencode
Model: anthropic/glm-5.2
✅ No new issues found.
Reviewed changes — 本次增量 review 覆盖自 f95f16f 至 4566cde 的新提交,重点验证上轮 Pullfrog review 提出的问题是否已修复。
- 移除未使用依赖 —
web/package.json中已删除radix-ui,并重新生成web/bun.lock。 - 修复 Custom Range 时区偏移 —
web/src/features/managed-agents/labels.ts改用date-fns的parseISO解析yyyy-MM-dd,并新增formatCreatedRange/formatCreatedRangeDay两个基于Intl.DateTimeFormat的本地化 helper,避免 UTC− 时区下标签早一天。 - preset 列表 RadioGroup 化 —
CreatedFilterDropdown的 preset 选项改为使用共享RadioGroup(Base UI),获得方向键导航与 roving tabindex。 - 补齐交互与时区测试 — 新增
labels.test.ts(UTC− 时区回归)以及ManagedAgentsPage.agents.suite.tsx中 Custom Range 端到端测试和 zh-CN 本地化断言。 - 新增设计文档 —
docs/design/fe/agents-created-filter.md记录了类型模型、UI 状态、API 边界、时区策略、键盘可达性与测试计划。
anthropic/glm-5.2 | 𝕏
|
@jh0904 已按你上一轮的四点逐一修复完毕(commit 4566cde):
另外补了设计文档 现有门禁(build/format/naming/complexity/duplicates)和 CI 全部通过,DuckPR 增量 review 也确认 "No new issues found"。麻烦复核一下,谢谢! |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
internal/messages/handler.go (1)
96-125: 🚀 Performance & Scalability | 🔵 TrivialOperational note: every OAuth code-session Messages request now fully buffers its body in memory.
readGatewayCandidatemust read the full request body (up tomaxRequestBodyBytes/32MiB) to detect JSON and route to the gateway, whereas previously the body streamed straight to the upstream. This is a reasonable tradeoff for the feature, but worth keeping in mind for memory/latency under high code-session traffic with large payloads (e.g., long conversation histories) that never end up using web search.Also applies to: 159-190
🤖 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 `@internal/messages/handler.go` around lines 96 - 125, Review the OAuth code-session path in the Messages handler, especially readGatewayCandidate and the corresponding handling around lines 159-190, to account for full request-body buffering up to maxRequestBodyBytes (32 MiB). Preserve gateway detection and body restoration for non-gateway requests, while ensuring the implementation’s memory and latency impact is intentional and bounded.
🤖 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/design/fe/agents-created-filter.md`:
- Around line 76-87: 修正文档中 custom 日期范围的 API 边界契约,使其与用户选择并展示的本地日历日一致:不要固定使用 UTC
午夜和日末;应明确将本地日边界按指定时区转换为 UTC,或统一改为 UTC 日历日并同步调整展示与序列化说明。更新“时区与本地化”及表格中的 from/to
示例,确保整日过滤范围在非 UTC 时区下仍覆盖用户选中的日期。
In `@internal/messages/gateway.go`:
- Around line 304-314: Update gatewayToolResult to serialize successful
[]websearch.Result values before assigning them to tool_result.content. Use JSON
or the established typed text-content block format, ensuring the resulting
content conforms to Anthropic’s accepted string or content-block shape while
preserving the existing error response.
In `@web/src/features/managed-agents/labels.test.ts`:
- Around line 10-18: Update the afterAll cleanup for process.env.TZ to restore
the original state: assign previousTimezone when it was previously defined,
otherwise delete process.env.TZ so the environment variable remains unset.
In `@web/src/features/managed-agents/ManagedAgentsPage.agents.suite.tsx`:
- Around line 1687-1695: Update the clickDay helper in the ManagedAgentsPage
test to locate DayPicker dates using its actual day-button selector or
accessible role, rather than constructing button[data-day] values in M/D/YYYY
format. Preserve the existing assertions and clicks for the first and fifteenth
days.
---
Nitpick comments:
In `@internal/messages/handler.go`:
- Around line 96-125: Review the OAuth code-session path in the Messages
handler, especially readGatewayCandidate and the corresponding handling around
lines 159-190, to account for full request-body buffering up to
maxRequestBodyBytes (32 MiB). Preserve gateway detection and body restoration
for non-gateway requests, while ensuring the implementation’s memory and latency
impact is intentional and bounded.
🪄 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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 2ffc4064-ad26-42d9-b02c-13e671d05a15
⛔ Files ignored due to path filters (1)
web/bun.lockis excluded by!**/*.lock
📒 Files selected for processing (18)
.env.example.gitignoredocs/design/be/messages-proxy.mddocs/design/fe/agents-created-filter.mdinternal/config/config.gointernal/config/config_test.gointernal/messages/gateway.gointernal/messages/gateway_test.gointernal/messages/handler.gointernal/websearch/provider.gointernal/websearch/tavily.gointernal/websearch/tavily_test.gotests/messages_api_test.goweb/package.jsonweb/src/features/managed-agents/ManagedAgentsPage.agents.suite.tsxweb/src/features/managed-agents/agents/CreatedFilterDropdown.tsxweb/src/features/managed-agents/labels.test.tsweb/src/features/managed-agents/labels.ts
💤 Files with no reviewable changes (1)
- web/package.json
🚧 Files skipped from review as they are similar to previous changes (1)
- web/src/features/managed-agents/agents/CreatedFilterDropdown.tsx
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/config/config_test.go (1)
484-517: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a default-config assertion to catch missing
WebSearch.Timeoutdefault.Both new tests explicitly set
timeoutin the YAML override, so neither exercises the no-override path. Adding a case for the omitted-timeout default would have caught thatdefaultConfig()currently leavesWebSearch.Timeoutat zero (see comment oninternal/config/defaults.go).🤖 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 `@internal/config/config_test.go` around lines 484 - 517, Add a test case near TestLoadWebSearchConfiguration that loads configuration without a web_search.timeout override and asserts cfg.WebSearch.Timeout equals the documented default from defaultConfig. Use the existing prepareLoadTest and loadConfigTestYAML helpers, while preserving the current explicit-timeout coverage.
🤖 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.
Nitpick comments:
In `@internal/config/config_test.go`:
- Around line 484-517: Add a test case near TestLoadWebSearchConfiguration that
loads configuration without a web_search.timeout override and asserts
cfg.WebSearch.Timeout equals the documented default from defaultConfig. Use the
existing prepareLoadTest and loadConfigTestYAML helpers, while preserving the
current explicit-timeout coverage.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 8db1331e-e00b-4772-911e-734c5e344ccd
📒 Files selected for processing (14)
.gitignoredocs/configuration-reference.yamldocs/design/be/messages-proxy.mdinternal/config/config_test.gointernal/config/defaults.gointernal/config/types.gointernal/config/yaml_types.gointernal/messages/gateway.gointernal/messages/gateway_test.gointernal/messages/handler.goscripts/tests/generate-code-session-jwt-key_test.shscripts/tests/generate-upstream-proxy-ca-key_test.shtests/messages_api_test.goweb/src/features/managed-agents/types.ts
🚧 Files skipped from review as they are similar to previous changes (7)
- .gitignore
- web/src/features/managed-agents/types.ts
- tests/messages_api_test.go
- docs/design/be/messages-proxy.md
- internal/messages/gateway_test.go
- internal/messages/handler.go
- internal/messages/gateway.go
- Refactor AgentCreatedFilter into a discriminated union supporting
custom {from, to} ranges (yyyy-MM-dd).
- Add CreatedFilterDropdown (Popover + react-day-picker range Calendar);
presets apply immediately, custom range commits on Apply.
- listAgents sends both created_at[gte] and [lte] (backend already parses
both); client-side filter mirrors the range.
- Add shadcn Calendar plus react-day-picker and date-fns dependencies.
- Update affected filter tests to the new Popover/radio interaction.
Refs superduck-ai#109
响应 superduck-ai#111 review (@jh0904) 的 request changes: - labels.ts:custom range 解析改用 date-fns parseISO(yyyy-MM-dd 按本地日), 修复 Date.parse 当 UTC 导致 UTC− 时区标签偏移一天;抽出 locale-aware 的 formatCreatedRange / formatCreatedRangeDay(基于 Intl.DateTimeFormat), trigger 与 draft 共用,中文界面不再固定英文月份 - CreatedFilterDropdown:preset 列表改用项目共享 RadioGroup(@base-ui)+ Radio.Root,获得方向键选择与 roving tabindex,样式保持整行选项; trigger 与 draft label 传 locale - package.json:移除未使用的 radix-ui 直接依赖并重新生成 bun.lock, 避免带入整套 @radix-ui/* 元包 - 测试:labels.test.ts 在 TZ=America/Los_Angeles 下覆盖 UTC− 时区 / locale / invalid fallback / range 折叠;suite 新增 Custom Range 端到端(Apply 前 不发请求、Apply 后同时带 created_at[gte]/[lte]、上下界值正确)与 zh-CN locale 用例 - docs/design/fe/agents-created-filter.md:补充设计文档(类型/UI/API 边界 /时区/键盘可达性/测试计划) - calendar.tsx 的 DayButton ref 按 review 结论保留(与上游 react-day-picker 默认实现一致) URL 序列化与刷新恢复按 review 共识拆到 superduck-ai#135 单独跟踪;本 PR 不含。
e7c37d5 to
12e9e39
Compare
There was a problem hiding this comment.
DuckPR reviewer: opencode
Model: anthropic/glm-5.2
Important
本次增量提交修改了 Custom Range 测试的 clickDay 选择器,但选择器与 Calendar 组件实际渲染的 data-day 属性既不匹配格式也不匹配结构,会导致 commits a custom created range with inclusive gte/lte bounds 测试在 clickDay(1) 处失败。
Reviewed changes — 本次增量 review 覆盖自上次 Pullfrog review(4566cde)之后的新提交 12e9e39,该提交将 Custom Range 的 API 边界从 UTC 日始 / 日末改为本地日历日日始 / 日末转 UTC。
- 修正 Custom Range 日期边界语义 —
web/src/features/managed-agents/api.ts的createdFilterRange改用date-fnsstartOfDay(parseISO(filter.from))/endOfDay(parseISO(filter.to)),将用户本地时区的日始 / 日末转为 UTC,确保过滤范围覆盖界面所选的完整本地日,而非 UTC 日历日。 - 同步测试断言 —
labels.test.ts新增createdFilterRange单测(TZ=America/Los_Angeles 下验证本地日始转 UTC),并修正afterAll对process.env.TZ的清理(原先未定义时也会写入空值)。 - 更新 Custom Range 测试选择器与断言 —
ManagedAgentsPage.agents.suite.tsx的clickDay改为按 ISOyyyy-MM-dd构造选择器并查询[data-day="..."] button;gte/lte 断言改用本地new Date(...)转 ISO。 - 同步设计文档 —
docs/design/fe/agents-created-filter.md将 API 边界说明从「UTC 日始 / 日末」改为「本地日历日日始 / 日末转 UTC」。
anthropic/glm-5.2 | 𝕏
|
@jh0904 你在 changes requested 中列出的事项现已全部处理:日期标签与 UTC 边界改为 locale-safe 解析;Custom Range 增加真实交互测试;preset 使用共享 RadioGroup;未使用依赖已移除;设计文档、PR 正文和 #135 的 URL 恢复拆分已同步。刚补的日历定位问题也已修为稳定的 YYYY-MM-DD data-day 合同。当前 139 条 ManagedAgentsPage 测试、build、Prettier、naming、duplicates、complexity 和 CI 均通过,所有 review thread 已 resolve。请方便时重新 review。 |
There was a problem hiding this comment.
DuckPR reviewer: opencode
Model: anthropic/glm-5.2
✅ No new issues found.
Reviewed changes — 本次增量 review 覆盖自上次 Pullfrog review(12e9e39)之后的新提交 823e14a,该提交将 Calendar 组件的 data-day 属性改为稳定的本地 yyyy-MM-dd,并同步修正测试选择器,解决了上轮 review 指出的选择器与组件属性不匹配问题。
- 稳定化
data-day标识 —web/src/shared/ui/calendar.tsx新增calendarDayKey(date)helper,用本地getFullYear()/getMonth()/getDate()生成yyyy-MM-dd,替换原先 locale 相关的day.date.toLocaleDateString(),使data-day不再依赖运行时 locale。 - 对齐测试选择器 —
ManagedAgentsPage.agents.suite.tsx的clickDay选择器从后代组合[data-day="..."] button改为button[data-day="..."],与data-day实际挂在<Button>上的 DOM 结构一致;isoDay的yyyy-MM-dd构造与calendarDayKey格式完全对齐。
验证:ManagedAgentsPage.test.tsx 139 条测试(含 commits a custom created range with inclusive gte/lte bounds)与 labels.test.ts 10 条测试(TZ=America/Los_Angeles)全绿。
| View workflow run | Using anthropic/glm-5.2 | 𝕏
anthropic/glm-5.2 | 𝕏

背景
#109
Agents 列表页(
/workspaces/default/agents)的「Created」过滤器切到 Custom Range 时缺少日期选择控件,本 PR 实现完整的自定义日期区间过滤。实现
AgentCreatedFilter重构为可辨识联合,preset(all / last7 / last30)与 custom({ from, to },yyyy-MM-dd)统一表达。CreatedFilterDropdown(Popover + shadcnCalendar,基于react-day-pickerv10mode="range")。preset 列表改用项目共享的RadioGroup(@base-ui),获得方向键选择与 roving tabindex;样式保持整行选项。preset 点击即时生效;Custom range 为折叠入口,点开后用日历选from → to,Apply 后提交;当前值已是 custom 时打开默认展开,便于编辑。listAgents同时发送created_at[gte]与created_at[lte](custom 的两个日期映射为 UTC 日始 / 日末);客户端过滤agentMatchesClientFilters同步支持上下界。后端internal/agents/handler.go已解析[gte]/[lte],无需后端改动。labels.ts改用date-fnsparseISO解析yyyy-MM-dd(修复Date.parse当 UTC 导致 UTC− 时区 off-by-one 的标签偏移);trigger 与 draft 共用 locale-aware 的formatCreatedRange/formatCreatedRangeDay(基于Intl.DateTimeFormat(locale)),中文界面不再固定英文月份。react-day-picker、date-fns与 shadcnCalendar组件;移除误加的未使用radix-ui直接依赖。改动文件
web/src/features/managed-agents/types.ts、labels.ts(含新增formatCreatedRange/formatCreatedRangeDay)、api.ts、agents/model.tsxweb/src/features/managed-agents/agents/AgentsResourcePage.tsx(改用CreatedFilterDropdown)web/src/features/managed-agents/agents/CreatedFilterDropdown.tsx(新增 / RadioGroup 化)web/src/shared/ui/calendar.tsx(shadcn 新增)web/src/features/managed-agents/ManagedAgentsPage.agents.suite.tsx(适配新交互 + 新增 Custom Range 端到端与 zh-CN locale 测试)web/src/features/managed-agents/labels.test.ts(新增:UTC− 时区 / locale / invalid fallback / range 折叠)docs/design/fe/agents-created-filter.md(设计文档)验证
bun run build(tsc + vite)通过bun test:含 labels.test.ts(TZ=America/Los_Angeles)与 suite 新增用例,全绿from → to后 Apply,列表按区间刷新;键盘方向键可在 preset 与日历间移动;UTC− 时区下 trigger 标签与选中日一致不在本期范围
Custom Range 的 URL 序列化与刷新恢复(
#109验收计划中提及)拆到后续 issue #135 单独跟踪;本 PR 选择范围不持久化到 URL,刷新会回到 All time。#109 的验收范围相应调整为「preset + Custom Range 选择与 API 边界」,URL 恢复由 #135 承接。关联
实现 #109;URL 恢复后续见 #135。设计细节见
docs/design/fe/agents-created-filter.md。Summary by CodeRabbit
New Features
Bug Fixes