Skip to content

fix(media): 詳細画面の遷移後に古いメディアが残る問題を修正 - #609

Merged
hmjn023 merged 1 commit into
developfrom
fix/media-detail-stale-navigation
Jul 17, 2026
Merged

fix(media): 詳細画面の遷移後に古いメディアが残る問題を修正#609
hmjn023 merged 1 commit into
developfrom
fix/media-detail-stale-navigation

Conversation

@hmjn023

@hmjn023 hmjn023 commented Jul 17, 2026

Copy link
Copy Markdown
Owner

概要

メディア詳細から一覧へ戻り、別のメディアを開いた際に最初の詳細が表示され続ける問題を修正します。

変更内容

  • 現在のrouter stateからアクティブなメディアIDを追跡
  • 詳細クエリと表示ツリーを新しいメディアデータへ切り替え
  • メディア配信と画像取得をno-store化
  • 新しい画像の読み込み開始時に旧Blob表示をクリア
  • ソース一覧と検索一覧の戻る遷移をE2Eで検証

検証

  • dev E2E: ソース一覧と検索一覧の遷移ケース成功
  • fresh production build E2E: ソース一覧の遷移ケース成功
  • Server/UI typecheck成功
  • lint成功
  • 全体typecheckは既存のTauri ImportMetaEnv.DEVおよびCSS型宣言エラーのみ残存

Summary by CodeRabbit

  • 改善
    • メディア表示時に常に最新のファイルを取得するようになり、古いキャッシュ画像が表示されにくくなりました。
    • メディアを切り替えた際、前の画像が一時的に残らず、正しい画像が表示されるようになりました。
    • 一覧や検索結果へ戻った後、別のメディアを開いても対象の画像が正しく表示されるようになりました。
    • メディア詳細画面での遷移や再読み込み時の表示が安定しました。

Track active route params reactively, remount detail content for new media, and disable stale media response caching. Add browser regressions for source and search navigation.
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

メディア詳細ルートの識別子解決をloaderデータと現在のルート状態に変更し、Accessor対応の表示・クエリ更新を追加した。メディア取得にはno-storeを指定し、画像切り替えとキャッシュ無効化をE2Eで検証する。

Changes

メディア詳細ルートと表示状態

Layer / File(s) Summary
ルートパラメータとAccessorの受け渡し
apps/server/src/routes/sources/..., apps/tauri/src/routes/sources/...
loaderデータと現在のルートマッチからmediaSourceId/mediaIdを解決し、AccessorとしてMediaDetailScreenへ渡す。
詳細画面のリアクティブ更新
packages/ui/src/screens/media-detail-screen.tsx, packages/ui/src/media-viewer.tsx
Accessorの現在値をクエリ、無効化、イベント照合に使用し、データ切り替え前に既存のメディアURLをクリアする。
メディア取得のキャッシュ無効化とE2E検証
apps/server/src/components/media/media-viewer.tsx, apps/server/src/routes/api/..., apps/tauri/src/components/media/media-viewer.tsx, apps/server/src/tests/e2e/*
メディア取得とAPI応答にno-storeを指定し、異なる画像表示とcache-controlヘッダーをE2Eで検証する。

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 遷移後に古いメディアが残る問題という主旨が、ルーター追跡とキャッシュ無効化による修正内容に一致しています。
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.
✨ 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/media-detail-stale-navigation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@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)
apps/server/src/tests/e2e/media-detail-manager-config.responsive.spec.ts (1)

46-46: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

テストの安定性向上:画像の中央からピクセルをサンプリングする

現在の (128, 64) という固定座標でのサンプリングは、将来的にテスト用の画像サイズがそれより小さいものに変更された場合、キャンバスの範囲外(透明な黒)を取得してしまい、比較テストが常に一致して成功してしまうなどのリスクがあります。

画像のサイズに依存せず確実にピクセル情報を取得するため、画像の中央座標を動的に計算してサンプリングすることを推奨します。

💡 推奨されるリファクタリング
-		return [...context.getImageData(128, 64, 1, 1).data];
+		const x = Math.floor(element.naturalWidth / 2);
+		const y = Math.floor(element.naturalHeight / 2);
+		return [...context.getImageData(x, y, 1, 1).data];
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/server/src/tests/e2e/media-detail-manager-config.responsive.spec.ts` at
line 46, Update the pixel sampling logic around context.getImageData to derive
the sample coordinates from the canvas dimensions, using its center rather than
fixed coordinates (128, 64). Keep the existing returned pixel-data format
unchanged and ensure the computed coordinates remain within the canvas bounds.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@apps/server/src/tests/e2e/media-detail-manager-config.responsive.spec.ts`:
- Line 46: Update the pixel sampling logic around context.getImageData to derive
the sample coordinates from the canvas dimensions, using its center rather than
fixed coordinates (128, 64). Keep the existing returned pixel-data format
unchanged and ensure the computed coordinates remain within the canvas bounds.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a3f672e2-22f2-4f0f-986e-1ced49a81549

📥 Commits

Reviewing files that changed from the base of the PR and between 09f9f90 and 30e6267.

📒 Files selected for processing (8)
  • apps/server/src/components/media/media-viewer.tsx
  • apps/server/src/routes/api/sources.$mediaSourceId.$mediaId.ts
  • apps/server/src/routes/sources/$mediaSourceId/$mediaId/index.tsx
  • apps/server/src/tests/e2e/media-detail-manager-config.responsive.spec.ts
  • apps/tauri/src/components/media/media-viewer.tsx
  • apps/tauri/src/routes/sources/$mediaSourceId/$mediaId/index.tsx
  • packages/ui/src/media-viewer.tsx
  • packages/ui/src/screens/media-detail-screen.tsx

@hmjn023
hmjn023 merged commit d57bae9 into develop Jul 17, 2026
1 check passed
@hmjn023
hmjn023 deleted the fix/media-detail-stale-navigation branch July 17, 2026 16:27
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