fix: address PR #492 review comments (Y.Xml extract, testConnection, useRef)#493
Conversation
- Hocuspocus: extract inline mark elements (bold, etc.) without spurious newlines; add extractPlainTextFromYXml module + tests (Gemini review). - aiClient: allow claude-code branch when API key is empty (CodeRabbit review). - AIChatWikiLink: useRef initial values for React 19 types (CodeRabbit review). Made-with: Cursor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Code Review
This pull request refactors plain text extraction from Y.Xml structures to improve formatting, adds support for 'claude-code' as an AI provider that does not require an API key, and updates test coverage. The review identified a performance issue in the text extraction loop due to O(N^2) complexity and a potential database constraint violation in the content preview truncation logic. I have included the suggested improvements to address these issues.
| for (let i = 0; i < node.length; i++) { | ||
| const child = node.get(i); | ||
| if (child instanceof Y.XmlText) { | ||
| text += child.toString(); | ||
| } else if (child instanceof Y.XmlElement) { | ||
| const inner = extractTextFromYXml(child); | ||
| const suffix = isInlineXmlElement(child) ? " " : "\n"; | ||
| text += inner + suffix; | ||
| } | ||
| } |
There was a problem hiding this comment.
Yjsの共有型(XmlFragmentやXmlElement)において、node.length と node.get(i) を組み合わせたループは length と get の両方が内部の連結リストを走査するためです。ドキュメントが大きくなった際のパフォーマンス低下を避けるため、node.toArray() を使用して配列に変換してからループを回すか、firstChild と nextSibling を使用したイテレーションを推奨します。
for (const child of node.toArray()) {
if (child instanceof Y.XmlText) {
text += child.toString();
} else if (child instanceof Y.XmlElement) {
const inner = extractTextFromYXml(child);
const suffix = isInlineXmlElement(child) ? " " : "\n";
text += inner + suffix;
}
}| export function buildContentPreview(text: string): string { | ||
| const trimmed = text.trim().replace(/\s+/g, " "); | ||
| if (trimmed.length <= CONTENT_PREVIEW_MAX_LENGTH) return trimmed; | ||
| return trimmed.slice(0, CONTENT_PREVIEW_MAX_LENGTH).trim() + "..."; |
There was a problem hiding this comment.
DBの content_preview カラムのサイズ制限が120文字である場合、現在の実装では slice(0, 120) の後に ... を付与しているため、合計で最大123文字になります。これにより保存時にデータ切り詰めやエラーが発生する可能性があります。制限が厳密に120文字である場合は、省略記号を含めて120文字に収まるように調整(例:slice(0, CONTENT_PREVIEW_MAX_LENGTH - 3))することを検討してください。
| return trimmed.slice(0, CONTENT_PREVIEW_MAX_LENGTH).trim() + "..."; | |
| return trimmed.slice(0, CONTENT_PREVIEW_MAX_LENGTH - 3).trim() + "..."; |
概要
PR #492(develop → main)に付いたインラインレビューへの対応です。develop へ直接 push せず、本ブランチ経由で取り込みます。
Addresses inline review comments on release PR #492; merged via this branch.
変更点
テスト
関連
チェックリスト