"Preview | Markdown" tab toggle opens the preview over the focused tab — closes an active AI chat and interrupts the running agent

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

The tab-bar “Preview | Markdown” toggle is always clickable for any .md tab. When the caret/focus is in a different tab, pressing it opens the built-in markdown preview in the focused tab’s slot, replacing whatever is there — any editor, any tab. The worst case: a Claude Code / AI chat opened as an editor tab gets closed and a running agent session is interrupted, with no quick way to restore (Cmd+Shift+T does not bring the chat back with its state).

Steps to Reproduce

Open a .md file in one editor group
Put the caret/focus in any other tab — any editor, or an AI chat opened as an editor tab (worst case: while it is generating)
Press the “Preview | Markdown” toggle on the .md tab
Preview opens in the focused tab’s slot, replacing it. If that was an AI chat tab — the running agent session is interrupted

Expected Behavior

The preview should open in/near the editor group of its own markdown file (the tab whose toggle was pressed), leaving the focused tab — especially an AI chat with a running session — untouched. In stock VS Code the preview action only exists for the active editor, so this path is effectively unreachable there.

Operating System

MacOS

Version Information

3.23.23

Additional Information

Root cause (analysis of the bundled code): the toggle calls markdown.showPreview, whose placement is computed from activeTextEditor.viewColumn || ViewColumn.One and tabGroups.activeTabGroup (extensions/markdown-language-features → previewManager.ts) — it anchors to where the caret is, not to the editor that owns the markdown file. Suggestions (any of): resolve placement from the resource’s own editor group; or protect webview editor tabs (AI chats) from being replaced by a preview; or allow hiding the toggle (already requested on this forum). Happy to share the full code analysis and a tested patch.

Does this stop you from using Cursor

No - Cursor works, but with this issue

Hey @0x3654, sorry for the slow reply, and thanks for the detailed write-up and root-cause notes.

What you’re describing is an issue we’re tracking, and I’ve added your report. The Preview / Markdown toggle currently switches whichever tab has focus instead of the markdown tab it belongs to, so a focused chat tab can be replaced, and its running agent interrupted.

Until that changes, click once inside the markdown file’s content so its tab has focus before you press Preview or Markdown. That keeps the switch in the markdown tab and leaves your chat tab alone.