Skip to content

fix: 通知内容の見直し・改善 (#96)#99

Merged
limit7412 merged 2 commits into
masterfrom
fix/notification-content-improvements
Jul 14, 2026
Merged

fix: 通知内容の見直し・改善 (#96)#99
limit7412 merged 2 commits into
masterfrom
fix/notification-content-improvements

Conversation

@limit7412

Copy link
Copy Markdown
Owner

概要

issue #96 を解決する。通知の文面・情報量・リンクを見直し、「なぜ通知されたか」「どの対象か」が分かりやすい通知にする。送信先非依存の Notify::Message + アダプタ構成は維持し、組み立て側(Github::Notification / Github::Usecase / Notify::Usecase)に変更を集中させた。Slack / Discord アダプタは変更していない。

変更内容

1. reason ベースの通知文言

update? による「更新があったみたいです」一辺倒だと通知理由が伝わらないため、reason(mention / review_requested / assign …)を pretext に反映する。

  • Github::Notification#reason_message / #pretext を追加。[<type>] <reason 文言> 形式(例: [PullRequest] レビューを依頼されました
  • 未知の reason は汎用文言にフォールバック(GitHub 側の reason 追加に耐える)

2. メンション対象の絞り込み → 見送り

issue コメントの「一旦現状を維持する方針」に従い、MENTION_REASONS は変更しない。

3. title の情報量アップ + リンクのフォールバック

  • title を owner/repo#番号 タイトル 形式にして対象を一目で分かるようにする(Notification#display_title)。番号は subject.url 末尾から取得し、数値でない(Commit の SHA 等)場合はタイトルのみ(Subject#number
  • title_link をコメント html_url → リポジトリ html_url にフォールバックし、リンク無し通知を無くす(Notification#link

4. 本文の切り詰め + 取得失敗時の表示文言

  • コメント本文を BODY_LIMIT(500)字 + で切り詰め(全文はリンク先で読む前提)。組み立て側で行い Slack / Discord 共通
  • コメント取得失敗時は内部エラー文字列(comments api return client error: ...)ではなく「(本文を取得できませんでした)」を本文に出し、エラー詳細はログのみに残す。コメントが無い通知(CI 完了等)は本文を付けない

表示イメージ(実ペイロード / Discord)

pretext:    [PullRequest] レビューを依頼されました
title:      octocat/Hello-World#128 Fix the thing
title_link: https://github.com/octocat/Hello-World/pull/128#issuecomment-1
text.size:  501   (500字 + …)

テスト

  • spec/github/models_spec.cr: reason_message(既知/未知フォールバック)、pretextSubject#numberdisplay_titlelink を追加
  • spec/github/usecase_spec.cr(新規): build_message の title 形式・リンクフォールバック・本文切り詰め・本文無しを検証
  • crystal spec 54 examples 0 failures / ameba 0 failures / crystal build src/main.cr 成功

補足

  • Subject#update? / UPDATE_TYPES は本 PR では未使用になるが、モデルの述語として妥当かつ既存 spec もあるため残置した。
  • メンション条件(項目2)は方針に従い変更していない。

Closes #96

🤖 Generated with Claude Code

- pretext を reason(なぜ通知されたか)を反映した文言にする。未知の reason は
  汎用文言にフォールバック(Notification#reason_message / #pretext)
- title を `owner/repo#番号 タイトル` 形式にして対象を一目で分かるようにする。
  番号が取れない(Commit 等)場合はタイトルのみ(Subject#number / #display_title)
- title_link をコメント html_url → リポジトリ html_url にフォールバックし、
  リンク無し通知を無くす(Notification#link)
- コメント本文を BODY_LIMIT(500)字で切り詰め、Slack/Discord 共通で長文が流れる
  のを防ぐ(Github::Usecase#truncate_body)
- コメント取得失敗時は内部エラー文字列ではなく表示用文言を本文に出し、詳細は
  ログのみに残す
- build_message が pretext を内部生成するよう整理し引数を廃止
- spec 追加(reason 文言 / number / display_title / link / build_message)

メンション対象の絞り込み(issue の項目2)は「現状維持」の方針コメントに従い
本 PR では変更しない。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request enhances GitHub notification formatting and robustness by mapping notification reasons to user-friendly Japanese messages, formatting titles with issue/PR numbers, truncating long comment bodies, and falling back to repository links when comment links are missing. It also refactors comment fetching to return a placeholder message on API errors. The review feedback suggests handling trailing slashes when extracting issue/PR numbers from URLs, adding corresponding test cases, and wrapping the HTTP request in a rescue block to gracefully handle network errors.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/github/models.cr
Comment thread spec/github/models_spec.cr
Comment thread src/github/repository.cr Outdated

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7443ba457e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/github/repository.cr
Comment thread src/github/models.cr
- Subject#number を末尾スラッシュに強くし(chomp)、#番号が意味を持つ type
  (Issue/PullRequest/Discussion)に限定。Release/CheckSuite 等の数値 ID を
  誤って #番号 表示しない
- コメント URL が無い通知では body を持つ type(Issue/PullRequest)のみ
  subject.url へフォールバックし、CI 完了等(CheckSuite/Commit)には本文を
  付けない(comment_url が空を返す)
- find_comment_by_url の GET をネットワーク例外含め握りつぶし、1件の取得失敗が
  他通知の送信を巻き添えにしないようにする
- spec 追加(末尾スラッシュ / 非番号 type / body 非対象 type の comment_url)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@limit7412 limit7412 merged commit 98ca9ef into master Jul 14, 2026
2 checks passed
@limit7412 limit7412 deleted the fix/notification-content-improvements branch July 14, 2026 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

改めての通知内容の見直し、改善

1 participant