posit-dev / positron

Positron, a next-generation data science IDE
https://positron.posit.co
Other
2.83k stars 91 forks source link

Run App button incorrectly treats .qmd as FastAPI #5323

Open jthomasmock opened 2 weeks ago

jthomasmock commented 2 weeks ago

System details:

Positron and OS details:

Positron Version: 2024.11.0 (Universal) build 140 Code - OSS Version: 1.93.0 Commit: e0d844b031f95acbf89f234a2cce2af9b6721f6c Date: 2024-10-31T14:24:19.540Z Electron: 30.4.0 Chromium: 124.0.6367.243 Node.js: 20.15.1 V8: 12.4.254.20-electron.0 OS: Darwin arm64 24.0.0

Interpreter details:

Python 3.12.0 in a Py script and a .qmd

Describe the issue:

When a FastAPI and a Quarto document exist in the same folder, Positron can keep the Run App button in focus and prefer it over the Quarto Preview button when moving from an example FastAPI (ie example.py) and a Quarto .qmd document.

https://github.com/user-attachments/assets/c968882e-8ee2-4d17-9c4d-582010e5b092

Steps to reproduce the issue:

  1. Create a minimal FastAPI example.py and a minimal .qmd document
from fastapi import FastAPI

app = FastAPI()

@app.get("/")
async def root():
    return {"message": "Hello World"}

@app.get("/items/{item_id}")
async def read_item(item_id: int):
    return {"item_id": item_id}
---
title: "Example"
format: html
jupyter: python3
---

```{python}
5+5


2. Focus on `example.py`, notice the "Run FastAPI in Terminal" as the first option in the play button.
3. Move focus to the Quarto document and notice that the Preview icon has been replaced with a Run App button, and Preview is actually below the "Run FastAPI in Terminal" as the first option

## Expected or desired behavior:

Quarto should not be treated as FastAPI and the Preview button should not be overwritten

## Were there any error messages in the UI, Output panel, or Developer Tools console?

<!--

- Open the Developer Tools console by running the `Developer: Toggle Developer Tools` command from the Command Palette
- Open the relevant Output Channel logs by utilizing this guide: https://positron.posit.co/troubleshooting.html

-->