Skip to content

Respect Markdown Viewer setting for .md links in AI rules/facts panel#9699

Merged
vorporeal merged 1 commit intowarpdotdev:masterfrom
anshul-garg27:fix/8998-md-viewer-ai-panel
May 4, 2026
Merged

Respect Markdown Viewer setting for .md links in AI rules/facts panel#9699
vorporeal merged 1 commit intowarpdotdev:masterfrom
anshul-garg27:fix/8998-md-viewer-ai-panel

Conversation

@anshul-garg27
Copy link
Copy Markdown
Contributor

Closes #8998.

Description

Clicking a .md file 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 .md links inside terminal output blocks.

Root cause

Workspace::handle_ai_fact_view_event (app/src/workspace/view.rs:5618) handled AIFactViewEvent::OpenFile by calling self.open_code(CodeSource::Link { … }) directly. open_code always routes the file into the Warp Code Editor — it never consults EditorSettings::prefer_markdown_viewer or open_file_editor. The buggy path is also reachable from RuleViewEvent::OpenFile, which app/src/ai/facts/view/mod.rs:132-133 re-emits as AIFactViewEvent::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) calls resolve_file_target and emits Event::OpenFileWithTarget, which the workspace then dispatches through Workspace::open_file_with_target — that helper has explicit branches for MarkdownViewer, EnvEditor, CodeEditor, SystemGeneric, and ExternalEditor. The AI panels were skipping all of that.

Fix

In the AIFactViewEvent::OpenFile arm:

  1. Compute the appropriate FileTarget via resolve_file_target_with_editor_choice (already imported in the file at view.rs:111), feeding in open_file_editor, prefer_markdown_viewer, and open_file_layout from EditorSettings.
  2. Dispatch through Workspace::open_file_with_target with CodeSource::Link { … } as the source — same shape used by the existing view.rs:6424 (tab-config-template open) and view.rs:19882 (toast file-open) call sites.

That single change covers both RuleViewEvent::OpenFile and AIFactViewEvent::OpenFile because 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, including test_resolve_file_target_markdown_viewer_precedence which directly covers the .md + prefer_markdown_viewer = true → FileTarget::MarkdownViewer decision this fix relies on.

Server API

  • Yes
  • No

Agent Mode

  • Yes
  • No

Changelog Entries

CHANGELOG-BUG-FIX: Clicking a .md file 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.

@cla-bot cla-bot Bot added the cla-signed label May 1, 2026
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 1, 2026

@anshul-garg27

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 /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

…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.
@anshul-garg27 anshul-garg27 force-pushed the fix/8998-md-viewer-ai-panel branch from 1eced97 to fbc0a1c Compare May 3, 2026 20:58
@captainsafia captainsafia requested review from a team and vorporeal and removed request for a team May 4, 2026 00:15
Copy link
Copy Markdown
Contributor

@vorporeal vorporeal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the fix!

Copy link
Copy Markdown
Contributor

@vorporeal vorporeal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the fix!

Copy link
Copy Markdown
Contributor

@vorporeal vorporeal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the fix!

Copy link
Copy Markdown
Contributor

@vorporeal vorporeal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the fix!

@vorporeal
Copy link
Copy Markdown
Contributor

oh boy thanks github

@vorporeal vorporeal merged commit 3023721 into warpdotdev:master May 4, 2026
24 checks passed
wolverine2k pushed a commit to wolverine2k/warp that referenced this pull request May 5, 2026
…warpdotdev#9699)

Closes warpdotdev#8998.

### Description

Clicking a `.md` file 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 `.md` links inside terminal
output blocks.

### Root cause

`Workspace::handle_ai_fact_view_event`
(`app/src/workspace/view.rs:5618`) handled `AIFactViewEvent::OpenFile`
by calling `self.open_code(CodeSource::Link { … })` directly.
`open_code` always routes the file into the Warp Code Editor — it never
consults `EditorSettings::prefer_markdown_viewer` or `open_file_editor`.
The buggy path is also reachable from `RuleViewEvent::OpenFile`, which
`app/src/ai/facts/view/mod.rs:132-133` re-emits as
`AIFactViewEvent::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`) calls
`resolve_file_target` and emits `Event::OpenFileWithTarget`, which the
workspace then dispatches through `Workspace::open_file_with_target` —
that helper has explicit branches for `MarkdownViewer`, `EnvEditor`,
`CodeEditor`, `SystemGeneric`, and `ExternalEditor`. The AI panels were
skipping all of that.

### Fix

In the `AIFactViewEvent::OpenFile` arm:

1. Compute the appropriate `FileTarget` via
`resolve_file_target_with_editor_choice` (already imported in the file
at `view.rs:111`), feeding in `open_file_editor`,
`prefer_markdown_viewer`, and `open_file_layout` from `EditorSettings`.
2. Dispatch through `Workspace::open_file_with_target` with
`CodeSource::Link { … }` as the source — same shape used by the existing
`view.rs:6424` (tab-config-template open) and `view.rs:19882` (toast
file-open) call sites.

That single change covers both `RuleViewEvent::OpenFile` and
`AIFactViewEvent::OpenFile` because 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**, including
`test_resolve_file_target_markdown_viewer_precedence` which directly
covers the `.md + prefer_markdown_viewer = true →
FileTarget::MarkdownViewer` decision this fix relies on.

### Server API

- [ ] Yes
- [x] No

### Agent Mode

- [ ] Yes
- [x] No

### Changelog Entries

`CHANGELOG-BUG-FIX`: Clicking a `.md` file 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.

Co-authored-by: anshul-garg27 <[email protected]>
Leejaywell pushed a commit to Leejaywell/warp that referenced this pull request May 5, 2026
…warpdotdev#9699)

Closes warpdotdev#8998.

### Description

Clicking a `.md` file 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 `.md` links inside terminal
output blocks.

### Root cause

`Workspace::handle_ai_fact_view_event`
(`app/src/workspace/view.rs:5618`) handled `AIFactViewEvent::OpenFile`
by calling `self.open_code(CodeSource::Link { … })` directly.
`open_code` always routes the file into the Warp Code Editor — it never
consults `EditorSettings::prefer_markdown_viewer` or `open_file_editor`.
The buggy path is also reachable from `RuleViewEvent::OpenFile`, which
`app/src/ai/facts/view/mod.rs:132-133` re-emits as
`AIFactViewEvent::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`) calls
`resolve_file_target` and emits `Event::OpenFileWithTarget`, which the
workspace then dispatches through `Workspace::open_file_with_target` —
that helper has explicit branches for `MarkdownViewer`, `EnvEditor`,
`CodeEditor`, `SystemGeneric`, and `ExternalEditor`. The AI panels were
skipping all of that.

### Fix

In the `AIFactViewEvent::OpenFile` arm:

1. Compute the appropriate `FileTarget` via
`resolve_file_target_with_editor_choice` (already imported in the file
at `view.rs:111`), feeding in `open_file_editor`,
`prefer_markdown_viewer`, and `open_file_layout` from `EditorSettings`.
2. Dispatch through `Workspace::open_file_with_target` with
`CodeSource::Link { … }` as the source — same shape used by the existing
`view.rs:6424` (tab-config-template open) and `view.rs:19882` (toast
file-open) call sites.

That single change covers both `RuleViewEvent::OpenFile` and
`AIFactViewEvent::OpenFile` because 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**, including
`test_resolve_file_target_markdown_viewer_precedence` which directly
covers the `.md + prefer_markdown_viewer = true →
FileTarget::MarkdownViewer` decision this fix relies on.

### Server API

- [ ] Yes
- [x] No

### Agent Mode

- [ ] Yes
- [x] No

### Changelog Entries

`CHANGELOG-BUG-FIX`: Clicking a `.md` file 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.

Co-authored-by: anshul-garg27 <[email protected]>
Leejaywell added a commit to Leejaywell/warp that referenced this pull request May 5, 2026
Cherry-picked from upstream:
- fix: highlight C++ header extensions (warpdotdev#9388)
- Run executable shell scripts in the terminal (warpdotdev#9503)
- Revert schema generator binary recompilation fix (warpdotdev#9676)
- Remove stray backticks from Windows installer README (warpdotdev#9691)
- Fix chord shortcuts on Windows non-Latin keyboard layouts (warpdotdev#9476)
- Scroll output with Page Up/Down from prompt (warpdotdev#9624)
- Respect Markdown Viewer setting for .md links in AI rules/facts panel (warpdotdev#9699)
- fix: disable reset grid checks for restored blocks on Windows (warpdotdev#9987)
- add RedirectionGuard=no to windows-installer.iss (warpdotdev#9863)
- Windows quake mode window correctly sized (warpdotdev#9891)
- fix: update rand to 0.9.4 (GHSA-cq8v-f236-94qc) (warpdotdev#10060)
- Fix diff button when Show code review button toggle is off (warpdotdev#9600)
- Fix freshly cloned repo stuck in loading state (warpdotdev#9998)
- Fix terminal text selection not auto-scrolling when dragging (warpdotdev#9448)
- Resolve conflict markers from 3f0ac51 and edac651
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug Report: “.md” file links in agent conversation panel ignore Markdown Viewer setting

2 participants