Conversation
既存の FileViewer ペインを再利用する経路で、options.viewMode が未指定 かつ diffCategory が "conflicted" の場合、これまではペインの既存 viewMode を保持していたため、マージ前に raw で開いていたファイルが コンフリクト発生後もそのまま raw viewer で表示されていた。 applyFileViewerOpenOptionsToPane とプレビューペイン再利用パスのフォ ールバックを "conflict" に切り替え、diffCategory が conflicted であれ ば明示的な viewMode が無い限り ConflictViewer を確実に表示する。
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
📝 WalkthroughWalkthrough衝突diff のファイル選択時に、デフォルトでコンフリクトビューモードを強制するロジックを追加しました。 Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/desktop/src/renderer/stores/tabs/store.ts (1)
968-975: ロジック重複の整理を検討(任意)
utils.tsのapplyFileViewerOpenOptionsToPaneと同一の「conflicted ならフォールバックを"conflict"」判定がここにも複製されています。動作は正しく本 PR では問題ありませんが、将来ルール(例えば conflict 以外の強制モード)が増えた際に同期漏れが起きやすい形です。余裕があれば、フォールバック決定を共通ヘルパ(例:
resolveReusePaneViewMode(options, existingFileViewer))としてutils.tsに切り出し、両経路から参照する形が望ましいです。♻️ 参考リファクタ案
- // Conflicted files must default to the conflict viewer even - // when callers do not pass an explicit viewMode. - const conflictFallbackViewMode = - options.diffCategory === "conflicted" - ? "conflict" - : existingFileViewer.viewMode; - const nextViewMode = options.viewMode ?? conflictFallbackViewMode; + const nextViewMode = + options.viewMode ?? + (options.diffCategory === "conflicted" + ? "conflict" + : existingFileViewer.viewMode);(もしくは
utils.tsに共通ヘルパを切り出し)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/desktop/src/renderer/stores/tabs/store.ts` around lines 968 - 975, This duplicates the "conflicted -> fallback to 'conflict'" logic already present in utils.ts's applyFileViewerOpenOptionsToPane; extract that decision into a shared helper (e.g., resolveReusePaneViewMode(options, existingFileViewer)) in utils.ts and replace the inline block in store.ts (the code computing conflictFallbackViewMode / nextViewMode) to call the new helper so both code paths use the same logic; update any callers (applyFileViewerOpenOptionsToPane and the reuse-pane branch in store.ts) to import and use resolveReusePaneViewMode(options, existingFileViewer).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@apps/desktop/src/renderer/stores/tabs/store.ts`:
- Around line 968-975: This duplicates the "conflicted -> fallback to
'conflict'" logic already present in utils.ts's
applyFileViewerOpenOptionsToPane; extract that decision into a shared helper
(e.g., resolveReusePaneViewMode(options, existingFileViewer)) in utils.ts and
replace the inline block in store.ts (the code computing
conflictFallbackViewMode / nextViewMode) to call the new helper so both code
paths use the same logic; update any callers (applyFileViewerOpenOptionsToPane
and the reuse-pane branch in store.ts) to import and use
resolveReusePaneViewMode(options, existingFileViewer).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d6a74d33-5fa2-49db-a97d-9a48c5f6cd28
📒 Files selected for processing (3)
apps/desktop/src/renderer/stores/tabs/store.tsapps/desktop/src/renderer/stores/tabs/utils.test.tsapps/desktop/src/renderer/stores/tabs/utils.ts
概要
Issue #248 の修正。Git タブの Conflicts セクションからコンフリクトファイルを開いたときに、通常のファイルビュワー(raw)ではなく ConflictViewer が確実に表示されるようにする。
原因
addFileViewerPaneで既存ペインを再利用するとき、options.viewModeが未指定だとペインの既存 viewMode を保持するロジックになっていた。そのため次のような順序だと raw viewer のまま表示されてしまう:file.txtを raw で開く (viewMode: "raw"、diffCategory: undefined)。file.txtがコンフリクト状態になる。file.txtをクリック。handleFileOpenPaneは viewMode: "conflict" を渡すが、プレビューペイン再利用パス(store.tsのisSameFile判定)では diffCategory 不一致で "different file - replace" に進むケースと進まないケースがあり、キャッシュされた viewMode が残る経路があった。さらに
applyFileViewerOpenOptionsToPaneも同様の問題を持っており、diffCategory: \"conflicted\"なのに viewMode が raw のままで据え置かれるケースが発生しうる。修正内容
applyFileViewerOpenOptionsToPane(apps/desktop/src/renderer/stores/tabs/utils.ts):options.diffCategory === \"conflicted\"のときのフォールバック viewMode を "conflict" にする。options.viewModeが明示指定されていればそれを優先する。apps/desktop/src/renderer/stores/tabs/store.tsの isSameFile 分岐): 同様に conflicted のフォールバックを "conflict" に変更。applyFileViewerOpenOptionsToPaneのユニットテストを2件追加(フォールバックで conflict に戻ること、明示 viewMode が尊重されること)。createFileViewerPaneは既にresolveFileViewerMode経由で conflicted → "conflict" を解決しているため変更不要。テスト計画
bun test apps/desktop/src/renderer/stores/tabs/utils.test.ts— 49 tests passbun run lintbun run typecheck関連
Closes #248
Summary by CodeRabbit
リリースノート