From 24e9355dec8f7fd7e5e2d474b7cd2774a0a4f46a Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Fri, 20 Jun 2025 13:01:41 +0200 Subject: [PATCH 1/3] create - force `--no-open` when inside Posit Workbench --- src/command/create/cmd.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/command/create/cmd.ts b/src/command/create/cmd.ts index 79447d525fa..f737fb8bcc2 100644 --- a/src/command/create/cmd.ts +++ b/src/command/create/cmd.ts @@ -8,7 +8,10 @@ import { extensionArtifactCreator } from "./artifacts/extension.ts"; import { projectArtifactCreator } from "./artifacts/project.ts"; import { kEditorInfos, scanForEditors } from "./editor.ts"; -import { isInteractiveTerminal } from "../../core/platform.ts"; +import { + isInteractiveTerminal, + isRStudioWorkbench, +} from "../../core/platform.ts"; import { runningInCI } from "../../core/ci-info.ts"; import { Command } from "cliffy/command/mod.ts"; @@ -56,6 +59,16 @@ export const createCommand = new Command() const isInteractive = isInteractiveTerminal() && !runningInCI(); const allowPrompt = isInteractive && !!options.prompt && !options.json; + // Specific case where opening automatically in an editor is not allowed + if (options.open !== false && isRStudioWorkbench()) { + if (options.open !== undefined) { + info( + `The --open option is not supported in Posit Workbench - ignoring`, + ); + } + options.open = false; + } + // Resolve the type into an artifact const resolved = await resolveArtifact( type, From 18c12f5354a882d5ed00ec477d1e830268ba36aa Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Fri, 20 Jun 2025 17:36:59 +0200 Subject: [PATCH 2/3] rename isRStudioWorkbench to isPositWorkbench --- src/command/create/cmd.ts | 4 ++-- src/command/preview/preview.ts | 4 ++-- src/core/platform.ts | 4 ++-- src/core/previewurl.ts | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/command/create/cmd.ts b/src/command/create/cmd.ts index f737fb8bcc2..9eb37bb9de0 100644 --- a/src/command/create/cmd.ts +++ b/src/command/create/cmd.ts @@ -10,7 +10,7 @@ import { kEditorInfos, scanForEditors } from "./editor.ts"; import { isInteractiveTerminal, - isRStudioWorkbench, + isPositWorkbench, } from "../../core/platform.ts"; import { runningInCI } from "../../core/ci-info.ts"; @@ -60,7 +60,7 @@ export const createCommand = new Command() const allowPrompt = isInteractive && !!options.prompt && !options.json; // Specific case where opening automatically in an editor is not allowed - if (options.open !== false && isRStudioWorkbench()) { + if (options.open !== false && isPositWorkbench()) { if (options.open !== undefined) { info( `The --open option is not supported in Posit Workbench - ignoring`, diff --git a/src/command/preview/preview.ts b/src/command/preview/preview.ts index 6cb9e7ce8ee..aab909630b1 100644 --- a/src/command/preview/preview.ts +++ b/src/command/preview/preview.ts @@ -76,8 +76,8 @@ import { safeExistsSync, } from "../../core/path.ts"; import { + isPositWorkbench, isRStudio, - isRStudioWorkbench, isServerSession, isVSCodeServer, vsCodeServerProxyUri, @@ -872,7 +872,7 @@ function pdfFileRequestHandler( const onRequest = pdfOptions.onRequest; pdfOptions.onRequest = async (req: Request) => { if (new URL(req.url).pathname === "/") { - const url = isRStudioWorkbench() + const url = isPositWorkbench() ? await rswURL(port, kPdfJsInitialPath) : isVSCodeServer() ? vsCodeServerProxyUri()!.replace("{{port}}", `${port}`) + diff --git a/src/core/platform.ts b/src/core/platform.ts index 63c0f9517e7..7d48cdff27c 100644 --- a/src/core/platform.ts +++ b/src/core/platform.ts @@ -34,7 +34,7 @@ export function isVSCodeServer() { return !!vsCodeServerProxyUri(); } -export function isRStudioWorkbench() { +export function isPositWorkbench() { // RS_SERVER_URL e.g. https://daily-rsw.soleng.rstudioservices.com/ // RS_SESSION_URL e.g. /s/eae053c9ab5a71168ee19/ return !!Deno.env.get("RS_SERVER_URL") && !!Deno.env.get("RS_SESSION_URL"); @@ -50,7 +50,7 @@ export function isPositronTerminal() { } export function isServerSession() { - return isRStudioServer() || isRStudioWorkbench() || isJupyterServer() || + return isRStudioServer() || isPositWorkbench() || isJupyterServer() || isJupyterHubServer() || isVSCodeServer(); } diff --git a/src/core/previewurl.ts b/src/core/previewurl.ts index b79b4ba4abe..70eba8401cd 100644 --- a/src/core/previewurl.ts +++ b/src/core/previewurl.ts @@ -10,8 +10,8 @@ import * as colors from "fmt/colors"; import { isJupyterHubServer, isJupyterServer, + isPositWorkbench, isRStudioServer, - isRStudioWorkbench, isVSCodeServer, isVSCodeTerminal, jupyterHubHttpReferrer, @@ -58,7 +58,7 @@ export async function printBrowsePreviewMessage( path: string, ) { if ( - (isJupyterServer() || isVSCodeTerminal()) && isRStudioWorkbench() + (isJupyterServer() || isVSCodeTerminal()) && isPositWorkbench() ) { const url = await rswURL(port, path); info(`\nPreview server: ${previewURL(host, port, path = "")}`); From 49f6f9e86dfcec72364d676d23eef93f339e1fa2 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Fri, 20 Jun 2025 18:48:44 +0200 Subject: [PATCH 3/3] Add to changelog [skip ci] --- news/changelog-1.8.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/news/changelog-1.8.md b/news/changelog-1.8.md index e704845551b..847cd6be53d 100644 --- a/news/changelog-1.8.md +++ b/news/changelog-1.8.md @@ -75,6 +75,10 @@ All changes included in 1.8: - ([#12627](https://github.com/quarto-dev/quarto-cli/issues/12627)): Don't actually install extension when user responds `yes` to first prompt but `no` to second. +### `create` + +- ([#12965](https://github.com/quarto-dev/quarto-cli/issues/12965)): Prevent automatic opening of new editor sessions when creating projects in Posit Workbench context. The `--open` flag is now ignored in this environment to avoid issues with Workbench session management. + ## Engines ### `jupyter`