Skip to content

feat: enable request replay by default - #1384

Merged
ding113 merged 1 commit into
devfrom
replay-default-enabled
Aug 2, 2026
Merged

feat: enable request replay by default#1384
ding113 merged 1 commit into
devfrom
replay-default-enabled

Conversation

@ding113

@ding113 ding113 commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • Enable Request Replay by default when ENABLE_REQUEST_REPLAY is unset.
  • Pass the effective env fallback into the settings UI so a nullable persisted override renders correctly.
  • Keep explicit false overrides and untouched null saves intact.
  • Update all five settings translations and add regression coverage for the backend default and frontend tri-state behavior.

Validation

  • bunx vitest run tests/unit/lib/env-request-replay.test.ts tests/unit/settings/system-settings-form-replay-cache-toggles.test.tsx --configLoader bundle
  • bun run lint:fix
  • bun run lint
  • bun run typecheck
  • bun run test (845 files passed, 2 skipped; 8211 tests passed, 13 skipped)
  • bun run build
  • Authenticated browser check of /zh-CN/settings/config: Request Replay renders enabled with a null persisted override and the enabled env default.

No database schema or migration changes are required because replay_enabled remains nullable and NULL continues to follow the environment default.

Greptile Summary

The PR enables request replay when ENABLE_REQUEST_REPLAY is unset while preserving explicit environment and persisted overrides.

  • Passes the effective environment fallback to the settings form so nullable overrides display correctly.
  • Preserves untouched null values and explicit boolean selections during saves.
  • Updates all five localized descriptions and adds backend-default and frontend tri-state regression tests.

Confidence Score: 5/5

The PR appears safe to merge with no actionable correctness or security defects identified.

The backend default, runtime fallback, displayed switch state, and persisted tri-state semantics remain aligned, while replay attachment stays scoped by authenticated API-key identity.

Important Files Changed

Filename Overview
src/lib/config/env.schema.ts Changes the unset request-replay default to enabled while preserving explicit false values through the existing boolean transform.
src/app/[locale]/settings/config/page.tsx Reads the environment configuration once and passes the effective replay fallback into the client form.
src/app/[locale]/settings/config/_components/system-settings-form.tsx Uses the environment fallback only for rendering nullable replay state while retaining null for untouched submissions.
tests/unit/lib/env-request-replay.test.ts Covers the enabled default and explicit true and false environment values.
tests/unit/settings/system-settings-form-replay-cache-toggles.test.tsx Covers enabled and disabled fallbacks, untouched null persistence, and explicit toggle persistence.

Reviews (1): Last reviewed commit: "feat: enable request replay by default" | Re-trigger Greptile

Context used:

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Replay 的环境默认值改为启用。设置页面将该值传递给表单。表单在未保存显式值时使用环境默认值。相关类型说明、五种语言文案和测试已同步更新。

Changes

Replay 默认值

Layer / File(s) Summary
环境默认值与配置契约
src/lib/config/env.schema.ts, src/types/system-config.ts, tests/unit/lib/env-request-replay.test.ts
ENABLE_REQUEST_REPLAY 未设置时默认为 true。类型说明和测试覆盖默认值及显式字符串转换。
设置页面与表单状态
src/app/[locale]/settings/config/page.tsx, src/app/[locale]/settings/config/_components/system-settings-form.tsx, tests/unit/settings/system-settings-form-replay-cache-toggles.test.tsx
设置页面传递环境默认值。表单在 replayEnablednull 时使用该值,用户切换后保存显式值。测试覆盖默认开启、默认关闭和保存行为。
本地化默认状态说明
messages/en/settings/config.json, messages/ja/settings/config.json, messages/ru/settings/config.json, messages/zh-CN/settings/config.json, messages/zh-TW/settings/config.json
五种语言的 Replay 默认状态描述从关闭更新为开启。

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: brisbanehuang, tesgth032

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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.
Title check ✅ Passed 标题准确概括了在未设置 ENABLE_REQUEST_REPLAY 时默认启用 Request Replay 的主要变更。
Description check ✅ Passed 描述与变更内容相关,说明了默认值、设置界面行为、持久化逻辑、翻译更新和测试验证。
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch replay-default-enabled

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

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 `@messages/zh-CN/settings/config.json`:
- Line 98: 统一 Replay 描述措辞:在 messages/zh-CN/settings/config.json
第98行,将“直接跟尾在途流”改为“直接加入在途流”并使用中文标点;在 messages/zh-TW/settings/config.json
第174行,将“直接跟尾在途串流”改为“直接加入進行中的串流”并使用中文标点。
🪄 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 Plus

Run ID: c7b942f3-f4e7-43fa-8d48-96770a88f240

📥 Commits

Reviewing files that changed from the base of the PR and between 5dd805e and 12cd367.

📒 Files selected for processing (11)
  • messages/en/settings/config.json
  • messages/ja/settings/config.json
  • messages/ru/settings/config.json
  • messages/zh-CN/settings/config.json
  • messages/zh-TW/settings/config.json
  • src/app/[locale]/settings/config/_components/system-settings-form.tsx
  • src/app/[locale]/settings/config/page.tsx
  • src/lib/config/env.schema.ts
  • src/types/system-config.ts
  • tests/unit/lib/env-request-replay.test.ts
  • tests/unit/settings/system-settings-form-replay-cache-toggles.test.tsx

},
"replayEnabled": "请求 Replay",
"replayEnabledDesc": "缓存上游响应并复用上游连接:并发或断线重连的相同请求直接跟尾在途流,不再重复请求供应商。保存前跟随环境变量 ENABLE_REQUEST_REPLAY,默认关闭。",
"replayEnabledDesc": "缓存上游响应并复用上游连接:并发或断线重连的相同请求直接跟尾在途流,不再重复请求供应商。保存前跟随环境变量 ENABLE_REQUEST_REPLAY,默认开启。",

Copy link
Copy Markdown

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

统一中文 Replay 描述的措辞。

两种中文翻译都使用了“跟尾在途流/串流”。该表达不够自然,可能使用户无法明确理解请求会加入现有的 in-flight stream。

  • messages/zh-CN/settings/config.json#L98-L98:将“直接跟尾在途流”改为“直接加入在途流”,并使用中文标点。
  • messages/zh-TW/settings/config.json#L174-L174:将“直接跟尾在途串流”改为“直接加入進行中的串流”,并使用中文标点。
📍 Affects 2 files
  • messages/zh-CN/settings/config.json#L98-L98 (this comment)
  • messages/zh-TW/settings/config.json#L174-L174
🤖 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 `@messages/zh-CN/settings/config.json` at line 98, 统一 Replay 描述措辞:在
messages/zh-CN/settings/config.json 第98行,将“直接跟尾在途流”改为“直接加入在途流”并使用中文标点;在
messages/zh-TW/settings/config.json 第174行,将“直接跟尾在途串流”改为“直接加入進行中的串流”并使用中文标点。

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

🧪 测试结果

测试类型 状态
代码质量
单元测试
集成测试
API 测试

总体结果: ✅ 所有测试通过

@ding113
ding113 marked this pull request as ready for review August 2, 2026 06:55
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@github-actions github-actions Bot added the size/S Small PR (< 200 lines) label Aug 2, 2026
@ding113
ding113 merged commit 21c97e8 into dev Aug 2, 2026
21 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Claude Code Hub Roadmap Aug 2, 2026
@github-actions github-actions Bot added size/M Medium PR (< 500 lines) and removed size/S Small PR (< 200 lines) labels Aug 2, 2026

@github-actions github-actions 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.

Code Review Summary

No significant issues identified in this PR.

PR Size: M

  • Lines changed: 62
  • Files changed: 11

Review Coverage

  • Logic and correctness - Clean
  • Security (OWASP Top 10) - Clean
  • Error handling - Clean
  • Type safety - Clean
  • Documentation accuracy - Clean
  • Test coverage - Adequate
  • Code clarity - Good

Automated review by Codex AI

@github-actions github-actions 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.

Reviewed PR #1384 (feat: enable request replay by default) and submitted the GitHub review.

  • Applied the size/M label based on 62 changed lines across 11 files.
  • Checked the diff from the required perspectives: logic/correctness, security, error handling, type safety, comments/docs, tests, and simplification.
  • No inline comments were posted because no issue in the modified lines survived full-context validation at the required confidence threshold.
  • Posted the summary review comment on the PR with that outcome.
  • Local test reruns were not possible in this runner because bun and node_modules were unavailable, so the review relied on the diff, surrounding code, test additions, and existing PR CI signals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Medium PR (< 500 lines)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant