Skip to content

fix(editor): apply Rich mode to the source tab opened from a diff - #34898

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/editor-diff-rich-selection
Oct 29, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/editor-diff-rich-selection

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​106 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​106
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 0

Problem

Clicking Rich Editor from a Markdown diff calls openFile for the source file, then sets the editor and Markdown view-mode preferences keyed by activeFile.filePath. openFile returns the actual tab ID, and that ID is owner-scoped for remote runtime/SSH files, for the same path open in another worktree, and for restored scoped tabs. In those cases:

  • the source tab opens in Source or Changes mode instead of Rich, and
  • when another owner's tab uses the bare path as its ID, its mode preferences are overwritten.

Fix

Use the file ID returned by openFile when calling setEditorViewMode and setMarkdownViewMode. If the existing tab's ID is the bare path, the returned ID is that same path, so behavior there does not change.

Tests

EditorPanel.diff-rich-owner.test.tsx uses the real store and real openFile ID resolution:

  • existing scoped source tab: it gets Rich mode, and the same-path tab in another worktree keeps its modes
  • new remote-runtime source tab: it gets Rich mode, and the other owner is untouched

Both cases fail on main. pnpm check:changed passes.

@OrcaWin
OrcaWin force-pushed the OrcaWin/editor-diff-rich-selection branch from f89fd97 to f29a0d8 Compare October 28, 2026 23:21
@OrcaWin
OrcaWin marked this pull request as ready for review October 29, 2026 00:08
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 7 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6fea2ade-8861-4aa4-be7c-89f6e0057c05
Commits

Reviewing files that changed from the base of the PR and between b2feed0 and 9b39b96.

Files selected for processing: 2
  • src/renderer/src/components/editor/EditorPanel.diff-rich-owner.test.tsx
  • src/renderer/src/components/editor/EditorPanel.tsx
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge.

Summary

Applies Rich mode to the source tab returned by openFile, rather than using the diff’s file path.

  • Rich mode follows the source tab opened from a diff.

Reviews (2) · Last reviewed commit: "fix(editor): apply diff Rich mode to the..." · Reviewed by Greptile

handleOpenDiffTargetFile keyed editor/markdown view-mode preferences by
the raw file path, but openFile returns owner-scoped IDs for remote
runtime files and same-path tabs in other worktrees, so Rich mode was
lost or written onto another owner's tab.
@OrcaWin
OrcaWin force-pushed the OrcaWin/editor-diff-rich-selection branch from f29a0d8 to 9b39b96 Compare October 29, 2026 00:27
@OrcaWin
OrcaWin merged commit 1bd7f54 into main Oct 29, 2026
35 checks passed
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