Skip to content

Conversation

@u1-liquid
Copy link
Member

@u1-liquid u1-liquid commented Jan 4, 2026

Motivation

  • Remove the SPDX header from the retry utility file per repository/maintainer instruction.
  • Delete the repository test packages/frontend/test/retry.test.ts as requested.
  • Keep the existing inlined minimized-note retry logic that was previously added to MkTimeline.vue unchanged in this change.

Description

  • Removed the SPDX comment block from packages/frontend/src/utility/retry.ts.
  • Deleted the test file packages/frontend/test/retry.test.ts.
  • No functional changes were made to the retry implementation or to MkTimeline.vue in this commit; this is a housekeeping change.

Testing

  • No automated tests were executed in this rollout environment.
  • The deleted unit test (packages/frontend/test/retry.test.ts) is no longer present, so its assertions are not run.
  • It is recommended to run the repository test suite (for example vitest) in CI or locally to validate behavior after these removals.

Codex Task

Summary by CodeRabbit

リリースノート

  • 新機能

    • ノートデータの読み込み信頼性を向上させました。失敗時に自動的に再試行する仕組みを導入し、一時的なエラーの場合でも正常に動作するようになりました。
  • 改善

    • ネットワークエラー時の対応を最適化し、ユーザーエクスペリエンスを向上させました。

✏️ Tip: You can customize this high-level summary in your review settings.

Copilot AI review requested due to automatic review settings January 4, 2026 13:24
@snyk-io
Copy link

snyk-io bot commented Jan 4, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@coderabbitai
Copy link

coderabbitai bot commented Jan 4, 2026

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

ノート取得機能にGuarded中央集約型フェッチメカニズムを導入しました。ノートJSON取得用のfetchNoteJson関数とFibonacciバックオフリトライロジック(最大3回、初期遅延100ms)を追加し、進行中のフェッチを追跡するペンディングマップを実装しました。直接フェッチから非同期リトライ対応フローへ制御フローを変更しました。

Changes

Cohort / File(s) 変更内容
Retry Utility
packages/frontend/src/utility/retry.ts
新規追加:Fibonacciバックオフリトライメカニズムを提供する汎用ユーティリティ。RetryOptions型を定義し、retryWithFibonacciBackoff<T>関数を公開。非同期タスクを最大指定回数までリトライし、各失敗後にFibonacci風の遅延(1, 2, 3, 5, ... パターン)を適用。
Timeline Component
packages/frontend/src/components/MkTimeline.vue
ノート可視化制御流のリファクタリング:pendingNoteFetchesマップでフェッチ重複を防止し、fetchNoteJson関数を追加してGuarded中央集約型のノート取得を実装。失敗時にscheduleMinimizedNoteRetryでリトライスケジュール。直接フェッチ・マージから非同期リトライ対応フローへ変更。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 フェッチの旅、リトライの道
Fibonacciのステップで進みゆく
失敗しても何度も立ち上がる
ノートの輝き、ついに手に
✨ 諦めぬ勇気、あります 🌙

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning PR説明がテンプレートの必須セクション「What」と「Why」に大きく適合していません。また、説明内容と実装の大きな矛盾があります。説明ではテスト削除とSPDXヘッダ削除のみを述べていますが、raw_summaryによると新しいリトライユーティリティとMkTimeline.vueの大幅な機能追加が含まれています。 PR説明を完全に改訂してください。テンプレートの「What」「Why」「Additional info」セクションを含め、新しいリトライメカニズムの追加、MkTimeline.vueの変更、削除内容をすべて正確に記載し、実装と説明の整合性を確保してください。
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed プルリクエストのタイトルは、JSONフェッチ失敗時のリトライ機能追加という主要な変更を明確に説明しており、変更内容と一致しています。
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 2026-01-04-implement-retry-for-failed-json-fetch

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

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 4, 2026

@codecov
Copy link

codecov bot commented Jan 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/frontend/src/components/MkTimeline.vue (1)

139-154: エラーの無視について検討してください。

実装は適切ですが、catch ブロックでエラーを完全に無視しています。最終的なリトライ失敗時に、デバッグ目的でログを記録することを検討してください。

🔎 オプション: エラーログの追加
 	}).catch(() => {
-		// ignore
+		if (_DEV_) console.warn(`Failed to fetch minimized note after retries: ${data.id}`);
 	}).finally(() => {
packages/frontend/src/utility/retry.ts (1)

8-33: maxAttempts が 0 の場合のエッジケースを検討してください。

Fibonacci バックオフの実装は正確です。ただし、maxAttempts が 0 の場合、ループが実行されず、タスクを一度も試行せずに 'Retry attempts exhausted.' エラーがスローされます。

これが意図された動作であれば問題ありませんが、maxAttempts >= 1 を強制するか、型で制約を加えることを検討してください。

🔎 オプション: 入力バリデーションの追加
 export async function retryWithFibonacciBackoff<T>(
 	task: () => Promise<T>,
 	options: RetryOptions,
 ): Promise<T> {
+	if (options.maxAttempts < 1) {
+		throw new Error('maxAttempts must be at least 1');
+	}
+
 	let nextDelayMultiplier = 1;
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 1bb7f63 and 813a5c9.

📒 Files selected for processing (2)
  • packages/frontend/src/components/MkTimeline.vue
  • packages/frontend/src/utility/retry.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: lint (backend)
  • GitHub Check: lint (misskey-reversi)
  • GitHub Check: lint (frontend)
  • GitHub Check: lint (misskey-js)
  • GitHub Check: lint (frontend-shared)
  • GitHub Check: typecheck (backend)
  • GitHub Check: Agent
  • GitHub Check: docker
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (4)
packages/frontend/src/components/MkTimeline.vue (3)

73-73: LGTM!

リトライユーティリティのインポートが適切に追加されています。


156-172: LGTM!

fulfillNoteData の変更は適切です。即時フェッチの試行とリトライのスケジューリングを分離することで、呼び出し元がブロックされずに処理を継続できます。null を返すことで、呼び出し元(prepend 関数)が適切にハンドリングできています。


122-137: 実装は適切です。Authorization: 'anonymous' ヘッダーは、このコードベース全体で使用されている標準パターンです。

pendingNoteFetches マップによる重複フェッチ防止は効果的です。また、credentials: 'include'Authorization: 'anonymous' の組み合わせは意図された設計であり、クッキーを送信しつつ、サーバーに対して明示的に未認証リクエストであることを示す適切なパターンです。エラーハンドリングも正しく実装されています。

packages/frontend/src/utility/retry.ts (1)

1-6: LGTM!

RetryOptions 型定義と sleep ヘルパー関数は簡潔で適切な実装です。

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the SPDX license header from the retry utility file and deletes its associated test file. Additionally, despite the description stating no functional changes, the PR integrates retry logic with fibonacci backoff into the MkTimeline component for handling minimized note fetches.

  • Removed SPDX header from packages/frontend/src/utility/retry.ts per repository maintainer instruction
  • Deleted the test file packages/frontend/test/retry.test.ts
  • Added retry logic to MkTimeline.vue for fetching minimized notes with fibonacci backoff strategy

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
packages/frontend/src/utility/retry.ts Retry utility without SPDX header, implements fibonacci backoff with configurable attempts and delays
packages/frontend/src/components/MkTimeline.vue Integrated retry utility for minimized note fetching, added fetchNoteJson, scheduleMinimizedNoteRetry functions, and pending fetch tracking

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +31 to +33

throw new Error('Retry attempts exhausted.');
}
Copy link

Copilot AI Jan 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message 'Retry attempts exhausted.' on line 32 is unreachable code. The function will either return successfully within the loop (line 17) or throw the original error when the max attempts are reached (line 20). The loop will never complete normally to reach line 32.

Suggested change
throw new Error('Retry attempts exhausted.');
}
}

Copilot uses AI. Check for mistakes.
Comment on lines +139 to +154
const scheduleMinimizedNoteRetry = (data: { id: string }) => {
if (pendingNoteFetches.has(data.id)) return;
const retryPromise = retryWithFibonacciBackoff(() => fetchNoteJson(data.id), {
maxAttempts: 3,
initialDelayMs: 100,
}).then((noteData) => {
void prepend(deepMerge(data, noteData));
}).catch(() => {
// ignore
}).finally(() => {
pendingNoteFetches.delete(data.id);
});
pendingNoteFetches.set(data.id, retryPromise);
};
Copy link

Copilot AI Jan 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new retry logic in scheduleMinimizedNoteRetry and fulfillNoteData lacks test coverage. Since the repository uses comprehensive automated testing with vitest (as evidenced by multiple test files in packages/frontend/test/), the retry behavior should be covered by tests, especially given that a test file for the retry utility was removed.

Copilot uses AI. Check for mistakes.
Comment on lines +147 to +148
}).catch(() => {
// ignore
Copy link

Copilot AI Jan 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Silent error handling with empty catch block on lines 147-149 makes debugging difficult. Consider logging the error or providing some indication that the retry failed, especially since this is a user-facing feature where failed note fetches could impact the user experience.

Suggested change
}).catch(() => {
// ignore
}).catch((error) => {
console.error('Failed to fetch minimized note after retries:', data.id, error);

Copilot uses AI. Check for mistakes.
pendingNoteFetches.set(data.id, retryPromise);
};
async function fulfillNoteData(data) {
Copy link

Copilot AI Jan 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function parameter 'data' on line 156 lacks type annotation. Adding explicit type information would improve type safety and make the code more maintainable, especially since this parameter is used with properties like 'data.visibility' and 'data.id'.

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +11
export type RetryOptions = {
maxAttempts: number;
initialDelayMs: number;
};

const sleep = (ms: number) => new Promise<void>(resolve => setTimeout(resolve, ms));

export async function retryWithFibonacciBackoff<T>(
task: () => Promise<T>,
options: RetryOptions,
): Promise<T> {
Copy link

Copilot AI Jan 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The retryWithFibonacciBackoff function and RetryOptions type lack documentation comments. Adding JSDoc comments would help users understand the purpose, parameters, and behavior of the retry mechanism, especially the fibonacci backoff strategy.

Copilot uses AI. Check for mistakes.
@u1-liquid u1-liquid changed the title Remove retry test and SPDX header from retry utility spec(frontend/timeline): ノートのJSON fetchに失敗した場合、リトライできるように Jan 4, 2026
@u1-liquid u1-liquid removed the codex label Jan 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants