Repository navigation
fix(terminal): reveal Markdown links at target lines - #9518
Conversation
📝 WalkthroughWalkthroughTerminal file opening now computes the detected language once and, for Markdown line links, resolves the active file ID, switches the Markdown view to source mode, and attaches that ID to the pending editor reveal. Tests add Markdown-aware store mocks and verify file-targeted line navigation. A conformance fixture covers relative Markdown paths with line numbers. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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 |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/renderer/src/components/terminal-pane/terminal-file-open-routing.ts (1)
186-208: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winScope line reveals to the exact editor tab for all file types.
The PR summary mentions scoping line reveals to the actual opened editor tab (which is crucial for owner-qualified tabs, like remote files). However,
fileIdis currently only extracted and passed tosetPendingEditorRevealiflanguage === 'markdown'. For other file types,fileIdwill beundefined, which may cause line reveals in owner-qualified tabs to break or target the wrong tab iffilePathalone isn't unique.Consider moving the
fileIdresolution outside theif (language === 'markdown')block so that all line-targeted files benefit from exact tab targeting. Note: this will require updating any existing terminal link tests for non-Markdown files to expect thefileIdproperty in thesetPendingEditorRevealmock payload.🐛 Proposed fix
- if (line !== null) { - let fileId: string | undefined - if (language === 'markdown') { - const openedStore = useAppStore.getState() - fileId = openedStore.activeFileIdByWorktree[worktreeId] ?? filePath - // Why: rich Markdown has no line-based reveal consumer; line links must mount Monaco. - openedStore.setMarkdownViewMode(fileId, 'source') - } + if (line !== null) { + const openedStore = useAppStore.getState() + const fileId = openedStore.activeFileIdByWorktree[worktreeId || ''] ?? filePath + + if (language === 'markdown') { + // Why: rich Markdown has no line-based reveal consumer; line links must mount Monaco. + openedStore.setMarkdownViewMode(fileId, 'source') + } const targetColumn = column ?? 1 store.setPendingEditorReveal(null) schedulePendingEditorReveal(() => { if (requestId !== latestOpenDetectedFilePathRequestId) { return } store.setPendingEditorReveal({ filePath, - ...(fileId ? { fileId } : {}), + fileId, line, column: targetColumn, matchLength: 0 }) }) }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: c5262fcf-ac81-47c8-9069-60d67477441f
📥 Commits
Reviewing files that changed from the base of the PR and between a02389c and 61ff8884d59d1075a76335690aed923ec35a4d5e.
📒 Files selected for processing (3)
src/renderer/src/components/terminal-pane/terminal-file-open-routing.tssrc/renderer/src/components/terminal-pane/terminal-link-handlers.test.tssrc/shared/terminal-file-link-conformance.ts
f5b9181 to
1660457
Compare
1660457 to
a766324
Compare
* fix(terminal): reveal Markdown links at target lines * fix(terminal): scope line reveals to opened tabs --------- Co-authored-by: kaynan <[email protected]>
Summary
Clicking a terminal file link with a line number (e.g.
docs/guide.md:230) now navigates to that exact line instead of opening the Markdown file at the top.ELI5
When you click a file link in the terminal that points to a specific line, Orca now jumps you straight to that line — even for Markdown files, which previously just opened at the beginning.
Root cause & fix
Terminal links already parsed the
:linesuffix, but the pending line reveal is consumed by Monaco, and Markdown files opened in Orca's rich (non-Monaco) view — so nothing honored the reveal. The fix, interminal-file-open-routing.ts, switches Markdown line targets to source mode viasetMarkdownViewMode(fileId, 'source')so Monaco mounts and can navigate. It also scopes the reveal to the opened editor tab'sfileId(resolved fromactiveFileIdByWorktree[worktreeId], falling back tofilePath) so owner-qualified tabs across local/SSH/runtime contexts get the reveal instead of an ambiguous path key.terminal-file-link-conformance.tsadds a "relative markdown path with line" parser case.Evidence
Validated & rebased onto latest main during a bug-bash triage on 2026-07-23.
src/renderer/src/components/terminal-pane/terminal-link-handlers.test.tssetPendingEditorRevealcall is missing"fileId": "/tmp/src/second.ts", and the new Markdown test'ssetMarkdownViewMode(fileId, 'source')is never called.oxlinton both fix files reports no findings.Trade-offs
None — pure fix. Markdown links without a line target, non-Markdown files, and HTML/system-default opens are unchanged.
Regression risk
Zero-regression: only the line-carrying branch of
openDetectedFilePathchanges, and only Markdown-with-line paths gain the view-mode switch. Non-affected paths remain byte-identical, and the 73 unrelated tests pass on both branch and reverted states. No new filesystem, IPC, or network calls; authorization and stat checks still run unchanged.Credit to @kaynansc for the original fix. Validated, rebased, and (where applicable) hardened via automated bug-bash review; original fix design preserved.