Skip to content

fix: preserve deletion-only AI ratio and remove preview badge#76

Merged
wasabeef merged 3 commits into
mainfrom
fix-dashboard-preview-badge
May 13, 2026
Merged

fix: preserve deletion-only AI ratio and remove preview badge#76
wasabeef merged 3 commits into
mainfrom
fix-dashboard-preview-badge

Conversation

@wasabeef
Copy link
Copy Markdown
Owner

@wasabeef wasabeef commented May 13, 2026

Pull Request

Summary

  • Preserve AI Ratio for deletion-only AI commits by falling back to file-level attribution when there is no added-line denominator.
  • Remove the Dashboard sidebar Preview badge now that Agent Note is public.
  • Document the regression test policy that would have caught this helper-vs-entry contract gap.
  • Refresh the generated CLI and PR Report bundles that include the attribution logic.

Release Note Plan

Release note: Deletion-only AI commits now keep a file-level AI Ratio instead of appearing as 0%.

Type of Change

  • Fix
  • Feature
  • Documentation
  • Refactor
  • Test
  • CI / release

Checklist

  • I kept structural changes separate from behavior changes where practical.
  • I added or updated tests for behavior changes.
  • I updated README / docs / website content when user-facing behavior changed.
  • I rebuilt generated bundles when bundled source changed.
  • I ran the relevant checks locally.

Notes for Reviewers

The Dashboard change is a one-line UI cleanup. The attribution fix covers commits that only delete lines: line-level attribution cannot divide by added lines, so Agent Note now falls back to the existing file-level denominator when eligible files remain. docs/knowledge/investigations.md records the concrete regression and the broader test matrix policy. Local docs/blog/ drafts are intentionally not included.

Verification:

  • npm run typecheck --prefix packages/cli
  • npm run lint --prefix packages/cli
  • npm run build --prefix packages/cli
  • npm test --prefix packages/cli
  • node --import tsx/esm --test packages/cli/src/core/entry.test.ts
  • node --import tsx/esm --test src/commands/pr.test.ts from packages/cli
  • npm run build --prefix packages/pr-report
  • npm test --prefix packages/pr-report
  • npm test --prefix packages/dashboard
  • npm run build --prefix packages/dashboard

🧑💬🤖 Agent Note

Total AI Ratio: ████████ 100%
Model: gpt-5.4

Commit AI Ratio Prompts Files
0bc0e77 fix(dashboard): remove preview badge █████ 100% 7 index.astro 🤖
f4c588f fix(cli): preserve AI ratio for deletion-only commits █████ 100% 1 cli.js 👤, entry.test.ts 🤖, entry.ts 🤖, index.js 🤖
29dbdea docs: record deletion-only ratio test policy █████ 100% 1 investigations.md 🤖
💬 Prompts & Responses (7 shown / 9 total)

0bc0e77 fix(dashboard): remove preview badge

🧑 Prompt
左上の Preview ラベルだけ取って

🤖 Response
左上の Preview badge だけ外します。他の UI やデータ処理には触りません。
左上の Preview ラベルだけ削除しました。

🧑 Prompt
docs/blog 以外の関係ないファイルは破棄して PR 作成して

🤖 Response
docs/blog だけを PR 対象にして、Dashboard 実験で触ったファイルは破棄します。まず status を確認して、破棄対象を明確にしてから戻します。
Dashboard 関連の差分は破棄できました。ここからは docs/blog の内容だけを確認して、PR 用に commit / push します。
docs/blog の 3 ファイルだけが残りました。ブランチ名が Dashboard 実験のままだと PR が分かりにくいので、ブログ記事用の名前に変えてから commit / push / PR 作成します。
common:pr-create スキルを使って、差分確認、commit、push、PR 作成まで進めます。
差分は docs/blog の 3 ファイルだけです。記事本文と投稿戦略の追加なので、docs: add Agent Note launch articles で commit します。
PR 本文はテンプレートに沿って、release note は skip、種類は Documentation にします。docs-only …

🧑 Prompt
プロンプトを確認して

🤖 Response
PR #75 に出ている Agent Note の Prompt 表示を確認します。PR body と必要ならコメント・最新 commit の note を見て、妥当かどうかまで判断します。
PR #75 の Prompt 出力を確認しました。

現在 PR に出ている Prompt はこの 2 件です。

レビューして
これは日本語で

結論として、この PR の内容を理解するには弱いです。この 2 件は実際に docs/blog を触った Prompt なので完全に無関係ではありませんが、記事作成の本来の意図である「公開用ブログを書く」「なぜ必要かと仕組みにフォーカスする」「日本語・英語を揃える」「投稿戦略を作る」あたりが出ていません。

一方で、今回最後に打った docs/blog 以外の関係ないファイルは破棄して PR 作成して が出ていないのは自然です。これは commit 内容を作った Prompt というより、作業整理と PR 作成の指示なので、commit の Agent Note には入らなくても問題ありません。

問題の本質は…

🧑 Prompt
左上の Preview ラベルだけ取って っていうプロンプトがないのは不自然

🤖 Response
これは 出ていない方が自然 です。

左上の Preview ラベルだけ取ってpackages/dashboard/src/pages/index.astro を変更する Prompt でしたが、その後に docs/blog 以外の関係ないファイルは破棄して PR 作成して に従って Dashboard 変更を全部破棄しました。

最終 commit c43c955 docs: add Agent Note launch articles に残ったのは docs/blog/ の 3 ファイルだけです。なので、Dashboard の Preview label に関する Prompt がこの commit の Prompt として出ると、むしろ commit 内容と関係ない Prompt が混入している 状態になります。

ただし、違和感の原因は分かります。PR 上の見出しが Prompts & Responses なので、「この作業中の会話全部」に見える。でも実際は この commit に残った変更に関係する Prompt です。

🧑 Prompt
うーん、でも Preview を取る作業を実際してコミットしたのにその起因であったプロンプトないのはなぜかな

<turn_aborted>
The user interrupted the previous turn on purpose. Any running unified exec processes may still be running in the background. If any tools/commands were aborted, they may have partially executed.
</turn_aborted>

あれ、ごかいしていた。

今回のPRはブログのPRになっているけど、このPRは差し戻してコミットしていない状態にして。

やってほしかった作業は左上のPreviewラベルをとったpRを作成してほしかった

🤖 Response
誤解の整理、こちらで戻します。ブログ PR #75 は閉じて、ブログ記事はローカルの未コミット状態に戻し、別ブランチで Preview ラベル削除だけの PR を作ります。
PR #75 は閉じて remote branch も削除しました。次にローカルのブログ commit を外して、docs/blog を未コミット状態に戻します。
ブログ記事はローカル未コミットに戻りました。ここから main ベースに切り替えて、Preview badge 削除だけのブランチを作ります。
main は最新で、docs/blog は未コミットのまま残っています。新しい PR には入れず、Preview badge だけを変更します。
検証は通りました。差分は Preview badge の 1 行削除だけで、docs/blog は未追跡のまま PR には含めません。

f4c588f fix(cli): preserve AI ratio for deletion-only commits

🧑 Prompt
プロンプトはよさそうだけど AI Ratio が 0% になっている。今回の作業はすべて AI でやったはずだ

🤖 Response
AI Ratio 0% はたしかに今回の実態とズレています。PR #76 の body、commit の git note、対象ファイルが .agentnoteignore や attribution 判定で除外されていないかを順に見ます。
原因が見えました。Note では index.astroby_ai: true になっていますが、この commit は「1 行削除のみ」で total_added: 0 のため、現在の AI Ratio 計算が 0/0 added lines = 0% に落ちています。つまり Prompt / Files は正しく、Ratio の表現だけが削除-only commit に弱いです。
AI が触ったファイル判定はできているのに、削除だけの commit なので行数ベースの AI Ratio が 0/0 に落ちている可能性が高いです。まず note と計算ロジックを突き合わせて、削除のみの AI 変更が file-level fallback になるべきかまで確認して直します。
原因はかなりはっきりしました。note に…

29dbdea docs: record deletion-only ratio test policy

🧑 Prompt
まだまだテスト観点の漏れがあるということが今回でわかりました。
docs/knowledge/investigations.md によりテストの強化方針を残してほしい

🤖 Response
今回の deletion-only AI Ratio バグは、既存の “追加行がある変更” に寄ったテストだけでは抜けるタイプでした。docs/knowledge/investigations.md に、今後の regression / characterization test 方針として残します。
calcAiRatio() 単体には fallback テストがあったのに、buildEntry()method=none で先に止める経路を見ていなかったのが今回の教訓です。なので「helper だけでなく、その helper を使う entry / report の契約まで固定する」という方針を具体化して追記します。
PR #76 の具体例と、今後のテスト強化方針を同じ場所にまとめました。次は差分を見て、表現が運用メモとして自然か、既存の engineering.md と矛盾しないかだけ確認します。
差分は docs/knowledge/investigations.md だけで、git diff --check も通りました。PR #76 に含める…

Summary by CodeRabbit

  • Style

    • The "Preview" badge was removed from the dashboard sidebar header.
  • Bug Fixes

    • Attribution behavior updated: commits with zero added lines now fall back to file-level attribution when applicable, otherwise are marked as no attribution.
  • Tests

    • Added tests for zero-added-line and exclusion-only attribution edge cases.
  • Documentation

    • New investigation and regression guidance added for attribution edge cases.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

📝 Walkthrough

Walkthrough

Removes the "Preview" badge from the dashboard sidebar header and updates CLI attribution resolution: buildEntry now uses a file-aware resolveMethod fallback when added-line denominators are zero, plus updated/added tests for file-fallback and excluded-file none-case.

Changes

Sidebar Header Update

Layer / File(s) Summary
Remove Preview badge from sidebar header
packages/dashboard/src/pages/index.astro
The Preview badge element (4 lines) is removed from the sidebar header markup.

CLI attribution method and tests

Layer / File(s) Summary
Add file-aware resolveMethod implementation
packages/cli/src/core/entry.ts
Introduces resolveMethod(files, lineCounts?) that returns "file" when totalAddedLines === 0 but AI-ratio-eligible files exist, otherwise "none".
Wire resolveMethod into buildEntry
packages/cli/src/core/entry.ts
buildEntry now calls resolveMethod(files, opts.lineCounts) to determine attribution.method.
Update and add buildEntry tests
packages/cli/src/core/entry.test.ts
Updates test to expect attribution.method = "file" with provided lineCounts when added lines are zero, and adds a test expecting method = "none" and ai_ratio = 0 when all files are excluded via aiRatioExcludedFiles.

Investigation & Test-Policy Docs

Layer / File(s) Summary
Add investigation and test-policy notes
docs/knowledge/investigations.md
Adds an investigation entry for "PR #76 deletion-only AI Ratio が 0% になる" and documents test-strengthening policy and regression matrix guidance.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes both main changes: fixing deletion-only AI ratio preservation and removing the preview badge from the dashboard.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-dashboard-preview-badge

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

@wasabeef wasabeef changed the title fix(dashboard): remove preview badge fix: preserve deletion-only AI ratio and remove preview badge May 13, 2026
@wasabeef wasabeef merged commit 5e434c8 into main May 13, 2026
11 checks passed
@wasabeef wasabeef deleted the fix-dashboard-preview-badge branch May 13, 2026 03:01
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