Skip to content
This repository was archived by the owner on May 2, 2026. It is now read-only.

feat: implement parseMessage for BacklogAdapter (PC-28)#27

Open
amotarao wants to merge 3 commits into
mainfrom
amon/pc-28-implement-parsemessage-for-backlogadapter
Open

feat: implement parseMessage for BacklogAdapter (PC-28)#27
amotarao wants to merge 3 commits into
mainfrom
amon/pc-28-implement-parsemessage-for-backlogadapter

Conversation

@amotarao

@amotarao amotarao commented Apr 19, 2026

Copy link
Copy Markdown
Member

Summary

  • BacklogRawMessage 型を追加(BacklogComment + issueKey/spaceKey/projectKey)
  • BacklogAdapterparseMessage を実装し、Backlog API コメントオブジェクトを Chat SDK の Message に変換
  • created !== updated で編集済み判定、BacklogFormatConverter.toAst でマークアップ変換

Test plan

  • parseMessage の全フィールドが正しくマッピングされること
  • 編集済み(created ≠ updated)の検出
  • Backlog マークアップ変換(''bold''bold
  • null コンテンツを空文字列として処理

Resolves PC-28

🤖 Generated with Claude Code

Summary by CodeRabbit

リリースノート

  • 新機能
    • Backlogアダプターのメッセージ解析機能を実装しました。コメント内容の変換、編集状態の検出、テキスト形式の変換に対応しています。

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>
@coderabbitai

coderabbitai Bot commented Apr 19, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@amotarao has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 7 minutes and 14 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 88e6876e-90a8-46de-844d-9063080d79a7

📥 Commits

Reviewing files that changed from the base of the PR and between 132ead2 and c3332a9.

📒 Files selected for processing (1)
  • .changeset/pc-28-implement-parsemessage.md

説明

Backlog アダプターに parseMessage メソッドを実装するための変更セットが追加されました。新しい BacklogRawMessage 型を定義し、Backlog API コメントオブジェクトを Chat SDK Message インスタンスに変換するロジックが導入されました。

変更内容

コホート / ファイル 概要
型定義とエクスポート
packages/chat-adapter-backlog/src/types.ts, packages/chat-adapter-backlog/src/index.ts
新しい BacklogRawMessage インターフェースを定義し、BacklogComment を再エクスポート。BacklogRawMessage をパッケージの公開 API に追加。
アダプター実装
packages/chat-adapter-backlog/src/adapter.ts
BacklogAdapterBacklogRawMessage 型で厳密型化。parseMessage メソッドを実装し、コメントから threadId、テキスト、著者情報、メタデータを派生させる。作成時刻と更新時刻の比較で編集状態を判定。
テストスイート
packages/chat-adapter-backlog/src/adapter.test.ts
makeRawMessage() ヘルパー関数を追加。parseMessage の動作を検証するテストブロックを実装し、空コメント処理、Backlog マークアップ変換、編集フラグの設定を確認。
リリースノート
.changeset/pc-28-implement-parsemessage.md
マイナーバージョンリリースの変更セットを宣言。parseMessage 実装と新しい型の導入を記録。

推定レビュー工数

🎯 3 (中程度) | ⏱️ ~20 分

🐰 バックログのメッセージを変える魔法が
AST と型でしっかり守られて
テストも完璧、編集も映る
コメントたちは華麗に踊る ✨
新しい parseMessage の世界へ

🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: implement parseMessage for BacklogAdapter (PC-28)' directly and accurately summarizes the main change: implementing the parseMessage method for BacklogAdapter.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch amon/pc-28-implement-parsemessage-for-backlogadapter

Comment @coderabbitai help to get the list of available commands and usage tips.

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

🧹 Nitpick comments (1)
packages/chat-adapter-backlog/src/adapter.ts (1)

151-175: handleWebhookparseMessage のメッセージ組み立てを一本化したいです。

現在は変換ロジックが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

📥 Commits

Reviewing files that changed from the base of the PR and between 887fdeb and 132ead2.

📒 Files selected for processing (5)
  • .changeset/pc-28-implement-parsemessage.md
  • packages/chat-adapter-backlog/src/adapter.test.ts
  • packages/chat-adapter-backlog/src/adapter.ts
  • packages/chat-adapter-backlog/src/index.ts
  • packages/chat-adapter-backlog/src/types.ts

amotarao and others added 2 commits April 19, 2026 11:33
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant