Skip to content

fix(desktop): コンフリクトファイルを ConflictViewer で開くよう viewMode を強制 (#248)#253

Merged
MocA-Love merged 1 commit intomainfrom
fix/issue-248-conflict-viewer-view-mode-fallback
Apr 17, 2026
Merged

fix(desktop): コンフリクトファイルを ConflictViewer で開くよう viewMode を強制 (#248)#253
MocA-Love merged 1 commit intomainfrom
fix/issue-248-conflict-viewer-view-mode-fallback

Conversation

@MocA-Love
Copy link
Copy Markdown
Owner

@MocA-Love MocA-Love commented Apr 16, 2026

概要

Issue #248 の修正。Git タブの Conflicts セクションからコンフリクトファイルを開いたときに、通常のファイルビュワー(raw)ではなく ConflictViewer が確実に表示されるようにする。

原因

addFileViewerPane で既存ペインを再利用するとき、options.viewMode が未指定だとペインの既存 viewMode を保持するロジックになっていた。そのため次のような順序だと raw viewer のまま表示されてしまう:

  1. ユーザーがファイルエクスプローラ経由で file.txt を raw で開く (viewMode: "raw"、diffCategory: undefined)。
  2. マージ操作で file.txt がコンフリクト状態になる。
  3. Git タブ → Conflicts から file.txt をクリック。
  4. handleFileOpenPane は viewMode: "conflict" を渡すが、プレビューペイン再利用パス(store.tsisSameFile 判定)では 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 pass
  • bun run lint
  • bun run typecheck
  • Desktop アプリを立ち上げて手動検証(マージコンフリクトを発生させ、Git タブから該当ファイルをクリックして ConflictViewer が開くこと)

関連

Closes #248

Summary by CodeRabbit

リリースノート

  • バグ修正
    • コンフリクトされたファイルを開く際、ビューモードが明示的に指定されていない場合、自動的に「コンフリクト」モードで表示されるようになりました。

既存の FileViewer ペインを再利用する経路で、options.viewMode が未指定
かつ diffCategory が "conflicted" の場合、これまではペインの既存
viewMode を保持していたため、マージ前に raw で開いていたファイルが
コンフリクト発生後もそのまま raw viewer で表示されていた。

applyFileViewerOpenOptionsToPane とプレビューペイン再利用パスのフォ
ールバックを "conflict" に切り替え、diffCategory が conflicted であれ
ば明示的な viewMode が無い限り ConflictViewer を確実に表示する。
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 16, 2026

📝 Walkthrough

Walkthrough

衝突diff のファイル選択時に、デフォルトでコンフリクトビューモードを強制するロジックを追加しました。diffCategory"conflicted" の場合、明示的な viewMode 指定がなければ "conflict" モードをフォールバック値として使用するように applyFileViewerOpenOptionsToPaneaddFileViewerPane を修正し、対応するテストケースを追加しました。

Changes

Cohort / File(s) Summary
コンフリクトビューモード初期化
apps/desktop/src/renderer/stores/tabs/utils.ts, apps/desktop/src/renderer/stores/tabs/store.ts
diffCategory === "conflicted" の場合、明示的な viewMode 指定がなければ fallbackViewMode"conflict" に強制し、既存ペイン再利用時の nextViewMode 選択ロジックを更新。
テストケース追加
apps/desktop/src/renderer/stores/tabs/utils.test.ts
衝突ファイル処理の2つのテストケースを追加:(1) 明示的な viewMode なしの場合は "conflict" に強制、(2) 明示的な viewMode ありの場合はその値を保持。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 衝突も怖くない、ビューを正しく!
マーカーを見つめ、両陣営の声を聞き、
ボタンひとつで、平和が訪れる 🌿
バグもさようなら、修正完了だ!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed プルリクエストのタイトルは「fix(desktop): コンフリクトファイルを ConflictViewer で開くよう viewMode を強制」で、Issue #248 の修正内容を正確かつ簡潔に説明しており、変更の主要な目的を明確に示している。
Description check ✅ Passed プルリクエスト説明は概要、原因、修正内容、テスト計画を含んでおり、テンプレートの主要セクションがカバーされている。ただし「Type of Change」フィールドが記入されていない。
Linked Issues check ✅ Passed 変更内容は Issue #248 の目標を完全に達成している。applyFileViewerOpenOptionsToPane および isSameFile 分岐で、options.diffCategory === "conflicted" のときのフォールバック viewMode を "conflict" に設定し、ConflictViewer が確実に表示されるようになった。
Out of Scope Changes check ✅ Passed すべての変更は Issue #248 の修正目標に直接関連している。applyFileViewerOpenOptionsToPane とプレビューペイン再利用パスの修正、および対応するユニットテストの追加のみであり、スコープ外の変更は検出されない。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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/issue-248-conflict-viewer-view-mode-fallback

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 and usage tips.

@MocA-Love MocA-Love self-assigned this Apr 16, 2026
@MocA-Love
Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

ℹ️ 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".

@MocA-Love
Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 16, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@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.

🧹 Nitpick comments (1)
apps/desktop/src/renderer/stores/tabs/store.ts (1)

968-975: ロジック重複の整理を検討(任意)

utils.tsapplyFileViewerOpenOptionsToPane と同一の「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

📥 Commits

Reviewing files that changed from the base of the PR and between 703b976 and 9a97d99.

📒 Files selected for processing (3)
  • apps/desktop/src/renderer/stores/tabs/store.ts
  • apps/desktop/src/renderer/stores/tabs/utils.test.ts
  • apps/desktop/src/renderer/stores/tabs/utils.ts

@MocA-Love MocA-Love merged commit e894178 into main Apr 17, 2026
6 checks passed
@MocA-Love MocA-Love deleted the fix/issue-248-conflict-viewer-view-mode-fallback branch April 17, 2026 00:03
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.

[bug] コンフリクト発生時、Gitタブのdiffsからコンフリクトビュワーではなく通常のファイルビュワーで開かれる

1 participant