Respect Markdown Viewer setting for .md links in AI rules/facts panel#9699
Open
anshul-garg27 wants to merge 1 commit intowarpdotdev:masterfrom
Open
Respect Markdown Viewer setting for .md links in AI rules/facts panel#9699anshul-garg27 wants to merge 1 commit intowarpdotdev:masterfrom
anshul-garg27 wants to merge 1 commit intowarpdotdev:masterfrom
Conversation
…facts panel Closes warpdotdev#8998. `Workspace::handle_ai_fact_view_event` was calling `self.open_code` directly for `AIFactViewEvent::OpenFile`, which always routes the file into the Warp Code Editor and ignores `EditorSettings::prefer_markdown_viewer` along with the user's `open_file_editor` choice. The same path is reachable from `RuleViewEvent::OpenFile` (`app/src/ai/facts/view/mod.rs:132-133`), which re-emits the same event, so both surfaces showed the same regression: a `.md` file path clicked in the AI rules/facts panel opens in the code editor (or terminal at the parent directory) instead of the Markdown Viewer even when the user has explicitly enabled it. Switch the handler to compute a `FileTarget` via `resolve_file_target_with_editor_choice` and dispatch through `Workspace::open_file_with_target`, which already has the per-target branches for `MarkdownViewer`, `EnvEditor`, `CodeEditor`, and `SystemGeneric`. This is the same pattern used at `view.rs:6424` (open new tab config) and `view.rs:19882` (toast file open), and matches how `Terminal::open_file_path` (`terminal/view.rs:17061`) already routes file-link clicks from terminal blocks.
Contributor
|
I'm starting a first review of this pull request. You can view the conversation on Warp. I reviewed this pull request and requested human review from: @warpdotdev/oss-maintainers. Comment Powered by Oz |
Contributor
There was a problem hiding this comment.
Overview
This PR routes AI rules/facts panel file opens through the existing file-target resolution path so Markdown viewer, editor choice, and layout settings are respected consistently with terminal output links.
Concerns
- No blocking correctness or security concerns found in the changed hunk.
Verdict
Found: 0 critical, 0 important, 0 suggestions
Approve
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #8998.
Description
Clicking a
.mdfile link in the agent conversation / AI rules / AI facts panel was opening the Warp Code Editor (or a new terminal at the parent directory) even when the user had enabled Settings → Features → General → Open Markdown files in Warp's Markdown viewer by default. The same setting was already respected for.mdlinks inside terminal output blocks.Root cause
Workspace::handle_ai_fact_view_event(app/src/workspace/view.rs:5618) handledAIFactViewEvent::OpenFileby callingself.open_code(CodeSource::Link { … })directly.open_codealways routes the file into the Warp Code Editor — it never consultsEditorSettings::prefer_markdown_vieweroropen_file_editor. The buggy path is also reachable fromRuleViewEvent::OpenFile, whichapp/src/ai/facts/view/mod.rs:132-133re-emits asAIFactViewEvent::OpenFile, so the rules and facts panels share the regression.The terminal-block path uses a different (correct) routing chain:
Terminal::open_file_path(app/src/terminal/view.rs:17061) callsresolve_file_targetand emitsEvent::OpenFileWithTarget, which the workspace then dispatches throughWorkspace::open_file_with_target— that helper has explicit branches forMarkdownViewer,EnvEditor,CodeEditor,SystemGeneric, andExternalEditor. The AI panels were skipping all of that.Fix
In the
AIFactViewEvent::OpenFilearm:FileTargetviaresolve_file_target_with_editor_choice(already imported in the file atview.rs:111), feeding inopen_file_editor,prefer_markdown_viewer, andopen_file_layoutfromEditorSettings.Workspace::open_file_with_targetwithCodeSource::Link { … }as the source — same shape used by the existingview.rs:6424(tab-config-template open) andview.rs:19882(toast file-open) call sites.That single change covers both
RuleViewEvent::OpenFileandAIFactViewEvent::OpenFilebecause they converge on the same handler.Testing
cargo fmt -p warp -- --check— passes.cargo check --features=gui --bin=warp-oss— passes (full re-check after edit).cargo nextest run --features=gui -p warp -E 'test(test_resolve_file_target_markdown_viewer_precedence) | test(test_resolve_file_target_warp_uses_default_layout) | test(test_resolve_file_target_binary_is_system_generic) | test(test_resolve_file_target_binary_uses_env_editor)'— 4 tests run: 4 passed, includingtest_resolve_file_target_markdown_viewer_precedencewhich directly covers the.md + prefer_markdown_viewer = true → FileTarget::MarkdownViewerdecision this fix relies on.Server API
Agent Mode
Changelog Entries
CHANGELOG-BUG-FIX: Clicking a.mdfile link from the AI rules/facts panel now opens it in Warp's Markdown Viewer when "Open Markdown files in Warp's Markdown viewer by default" is enabled, matching the behaviour for terminal output block links.