Conversation
📝 Walkthrough演进说明在英文、日文、俄文、中文等五个语言文件中的 OpenCode npm 安装部分添加了新的 变更摘要
评估代码审查工作量🎯 2 (Simple) | ⏱️ ~10 分钟 可能相关的 PR
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro Cache: Disabled due to Reviews > Disable Cache setting 📒 Files selected for processing (8)
🧰 Additional context used📓 Path-based instructions (4)**/*.{js,ts,tsx,jsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.{ts,tsx,jsx,js}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.test.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.{tsx,jsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧠 Learnings (2)📓 Common learnings📚 Learning: 2026-01-07T17:05:37.171ZApplied to files:
🧬 Code graph analysis (1)src/app/[locale]/usage-doc/page.tsx (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
🔇 Additional comments (11)
Comment |
Summary of ChangesHello @ding113, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the OpenCode installation documentation by adding a crucial warning about the use of npm mirror registries, which can lead to dependency issues. The change is fully internationalized across five languages and integrated into the user interface, ensuring that users receive clear guidance regardless of their locale. Additionally, the update includes improvements to the testing suite for robustness. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds an important note to the OpenCode installation documentation regarding the use of npm mirror registries, and correctly updates the i18n files and unit tests to reflect this change. The changes are logical and well-executed. Additionally, a test file was refactored to improve how document.cookie is mocked. My review includes a couple of suggestions for improving maintainability: one to reduce code duplication on the documentation page, and another to make the test mocking more idiomatic using Vitest's built-in features.
| <CodeBlock language="powershell" code={`npm install -g opencode-ai`} /> | ||
| </div> | ||
|
|
||
| <p className="text-sm text-muted-foreground">{t("opencode.installation.npm.note")}</p> |
There was a problem hiding this comment.
While this change is correct, I noticed that the entire npm installation section, including this new note, is duplicated for Windows (here) and for macOS/Linux (around line 1049). This duplication can make future updates more difficult and error-prone.
To improve maintainability, consider refactoring the npm installation UI into a separate component that accepts the shell language (powershell or bash) as a prop. This would centralize the logic and markup for this section.
For example:
const NpmInstallSection = ({ lang }: { lang: 'powershell' | 'bash' }) => {
const t = useTranslations("usage");
return (
<>
<div className="space-y-3">
<h5 className="font-semibold text-foreground">
{t("opencode.installation.npm.title")}
</h5>
<p>{t("opencode.installation.npm.description")}</p>
<CodeBlock language={lang} code={'npm install -g opencode-ai'} />
</div>
<p className="text-sm text-muted-foreground">{t("opencode.installation.npm.note")}</p>
</>
);
}While a full refactor is outside the scope of this PR, it's a good improvement to keep in mind for the future.
| Object.defineProperty(document, "cookie", { | ||
| configurable: true, | ||
| get: () => "auth-token=test-token", | ||
| }); |
There was a problem hiding this comment.
Using Object.defineProperty is a good improvement for mocking document.cookie. To make the test more idiomatic with Vitest, consider using vi.spyOn. It provides a clear API for mocking and restoring spies. You can then replace the manual cleanup on line 80 with cookieSpy.mockRestore().
const cookieSpy = vi
.spyOn(document, "cookie", "get")
.mockReturnValue("auth-token=test-token");
|
|
||
| await unmount(); | ||
|
|
||
| Reflect.deleteProperty(document, "cookie"); |
🧪 测试结果
总体结果: ✅ 所有测试通过 |
There was a problem hiding this comment.
Code Review Summary
No significant issues identified in this PR.
PR Size: S
- Lines changed: 26
- Files changed: 8
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
There was a problem hiding this comment.
- Identified PR
#586(docs: add npm registry note for OpenCode):+20/-6across8files → Size S. - Applied PR label
size/S. - Reviewed the diff across all changed files with the 6 required perspectives; no issues met the reporting threshold (confidence
< 80), so no inline comments were posted. - Submitted the required PR review summary via
gh pr review.
Summary
Add a warning note to the OpenCode npm installation section advising users to avoid npm mirror registries (e.g., Taobao, cnpm), which may cause missing dependencies.
Problem
Users installing opencode-ai via third-party npm mirror registries may encounter missing dependency issues, leading to installation failures or runtime errors. This is a common issue in regions where npm mirrors are frequently used.
Related Issues:
Solution
Add a prominent note in the OpenCode installation section warning users about potential npm mirror registry issues:
Changes
Core Changes
src/app/[locale]/usage-doc/page.tsx- Add npm registry warning note displayi18n Changes
messages/en/usage.json- Add English translation for npm.note keymessages/zh-CN/usage.json- Add Simplified Chinese translationmessages/zh-TW/usage.json- Add Traditional Chinese translationmessages/ja/usage.json- Add Japanese translationmessages/ru/usage.json- Add Russian translationTest Changes
tests/unit/usage-doc/opencode-usage-doc.test.tsx- Add test for npm mirror warning text and i18n key presencetests/unit/usage-doc/usage-doc-page.test.tsx- Fix flaky test with improved cookie mockingTesting
Automated Tests
Pre-commit Checklist
bun run lint- Passedbun run typecheck- Passedbun run test- Passedbun run test:coverage- Passedbun run build- PassedChecklist
Description enhanced by Claude AI