feat: implement parseMessage for BacklogAdapter (PC-28)#27
Conversation
Adds BacklogRawMessage type and parseMessage to convert Backlog API comment objects to Chat SDK Message instances, with edited detection and Backlog markup conversion. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 7 minutes and 14 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
説明Backlog アダプターに 変更内容
推定レビュー工数🎯 3 (中程度) | ⏱️ ~20 分 詩
🚥 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)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/chat-adapter-backlog/src/adapter.ts (1)
151-175:handleWebhookとparseMessageのメッセージ組み立てを一本化したいです。現在は変換ロジックが2箇所にあり、今後の仕様変更時に乖離リスクがあります。
handleWebhook側でBacklogRawMessageを構築してthis.parseMessage(raw)を使う形に寄せると保守性が上がります。差分イメージ
+ private toRawMessageFromWebhook(payload: BacklogWebhookPayload): BacklogRawMessage { + const spaceKey = this.config.host.split(".")[0]; + const projectKey = payload.project.projectKey; + const issueKey = `${projectKey}-${payload.content.key_id}`; + return { + spaceKey, + projectKey, + issueKey, + comment: { + id: payload.content.comment!.id, + content: payload.content.comment!.content, + created: payload.created, + updated: payload.created, + createdUser: payload.createdUser, + }, + }; + } async handleWebhook(request: Request, options?: WebhookOptions): Promise<Response> { @@ - const spaceKey = this.config.host.split(".")[0]; - const projectKey = payload.project.projectKey; - const issueKey = `${projectKey}-${payload.content.key_id}`; - const threadId = this.encodeThreadId({ spaceKey, projectKey, issueKey }); - - const comment = payload.content.comment; - // content is verified non-null by the guard above - const formatted = this.formatConverter.toAst(comment.content!); - - const message = new Message({ - id: String(comment.id), - threadId, - text: toPlainText(formatted), - formatted, - raw: payload, - author: { - userId: String(payload.createdUser.id), - userName: payload.createdUser.userId, - fullName: payload.createdUser.name, - isBot: false, - isMe: false, - }, - metadata: { - dateSent: new Date(payload.created), - edited: false, - }, - attachments: [], - }); + const raw = this.toRawMessageFromWebhook(payload); + const message = this.parseMessage(raw); + const threadId = message.threadId; this.chat?.processMessage(this, threadId, message, options);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/chat-adapter-backlog/src/adapter.ts` around lines 151 - 175, handleWebhook と parseMessage でメッセージ組み立てが重複しているため、handleWebhook 側で BacklogRawMessage を構築して this.parseMessage(raw) を呼ぶよう集約してください; 具体的には handleWebhook 内のコメント/ユーザー/issueKey/spaceKey/projectKey/created/updated 等を使って BacklogRawMessage を作成し(parseMessage が期待する形に合わせる)、既存の parseMessage メソッド(使用箇所: parseMessage、encodeThreadId、formatConverter.toAst)で一元的に Message を生成するよう置き換え、重複ロジックは削除して parseMessage を唯一の変換経路にしてください。
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/chat-adapter-backlog/src/adapter.ts`:
- Around line 151-175: handleWebhook と parseMessage
でメッセージ組み立てが重複しているため、handleWebhook 側で BacklogRawMessage を構築して
this.parseMessage(raw) を呼ぶよう集約してください; 具体的には handleWebhook
内のコメント/ユーザー/issueKey/spaceKey/projectKey/created/updated 等を使って BacklogRawMessage
を作成し(parseMessage が期待する形に合わせる)、既存の parseMessage メソッド(使用箇所:
parseMessage、encodeThreadId、formatConverter.toAst)で一元的に Message
を生成するよう置き換え、重複ロジックは削除して parseMessage を唯一の変換経路にしてください。
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9823a5b0-1daf-42a3-9a09-b63b82dd1c62
📒 Files selected for processing (5)
.changeset/pc-28-implement-parsemessage.mdpackages/chat-adapter-backlog/src/adapter.test.tspackages/chat-adapter-backlog/src/adapter.tspackages/chat-adapter-backlog/src/index.tspackages/chat-adapter-backlog/src/types.ts
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
BacklogRawMessage型を追加(BacklogComment+ issueKey/spaceKey/projectKey)BacklogAdapterのparseMessageを実装し、Backlog API コメントオブジェクトを Chat SDK のMessageに変換created !== updatedで編集済み判定、BacklogFormatConverter.toAstでマークアップ変換Test plan
parseMessageの全フィールドが正しくマッピングされること''bold''→bold)nullコンテンツを空文字列として処理Resolves PC-28
🤖 Generated with Claude Code
Summary by CodeRabbit
リリースノート