From 294b7086aa1d2ed0528cd7ad3c0ecfbb940b075b Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Thu, 5 Nov 2026 13:01:05 +0000 Subject: [PATCH] feat(cli): suggest known instance URLs in workspace add (#12234) * feat(cli): suggest known instance URLs in workspace add Co-Authored-By: Claude Opus 5.5 * ci: retry bun setup in cli tests after a release download outage Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Claude Opus 5.5 --- .github/workflows/cli-tests.yml | 41 ++++++++++++++++++++ cli/src/commands/workspace/workspace.ts | 50 +++++++++++++++++++++++-- 2 files changed, 88 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cli-tests.yml b/.github/workflows/cli-tests.yml index 19afa777ae..0db89d496b 100644 --- a/.github/workflows/cli-tests.yml +++ b/.github/workflows/cli-tests.yml @@ -47,7 +47,22 @@ jobs: with: node-version: "20" + # setup-bun downloads from GitHub releases on every run and gives up after + # ~40s of 504s; outages last longer, so each job retries once after a pause. - name: Setup Bun + id: setup-bun + continue-on-error: true + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + + - name: Wait before retrying Bun setup + if: steps.setup-bun.outcome == 'failure' + shell: bash + run: sleep 60 + + - name: Setup Bun (retry) + if: steps.setup-bun.outcome == 'failure' uses: oven-sh/setup-bun@v2 with: bun-version: latest @@ -94,6 +109,19 @@ jobs: node-version: "20" - name: Setup Bun + id: setup-bun + continue-on-error: true + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + + - name: Wait before retrying Bun setup + if: steps.setup-bun.outcome == 'failure' + shell: bash + run: sleep 60 + + - name: Setup Bun (retry) + if: steps.setup-bun.outcome == 'failure' uses: oven-sh/setup-bun@v2 with: bun-version: latest @@ -148,6 +176,19 @@ jobs: node-version: "20" - name: Setup Bun + id: setup-bun + continue-on-error: true + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + + - name: Wait before retrying Bun setup + if: steps.setup-bun.outcome == 'failure' + shell: bash + run: sleep 60 + + - name: Setup Bun (retry) + if: steps.setup-bun.outcome == 'failure' uses: oven-sh/setup-bun@v2 with: bun-version: latest diff --git a/cli/src/commands/workspace/workspace.ts b/cli/src/commands/workspace/workspace.ts index caac17136a..a638d7139d 100644 --- a/cli/src/commands/workspace/workspace.ts +++ b/cli/src/commands/workspace/workspace.ts @@ -184,6 +184,47 @@ export async function setActiveWorkspace( await writeFile(file, workspaceName, "utf-8"); } +const CLOUD_REMOTE = "https://app.windmill.dev/"; + +// Cliffy's list only previews the highlighted entry: Enter submits the typed +// text (empty, so the default) unless Tab was pressed first. +class PickableInput extends Input { + protected override getValue(): string { + const highlighted = this.suggestions[this.suggestionsIndex]; + if (!this.inputValue && highlighted !== undefined) { + return highlighted.toString(); + } + return super.getValue(); + } +} + +async function knownRemotes( + opts: GlobalOptions +): Promise<{ suggestions: string[]; defaultRemote: string }> { + const remotes: string[] = []; + for (const w of await allWorkspaces(opts.configDir)) { + try { + const remote = new URL(w.remote).toString(); + if (!remotes.includes(remote)) remotes.push(remote); + } catch { + // skip a malformed profile + } + } + const active = await getActiveWorkspace(opts); + let defaultRemote = CLOUD_REMOTE; + try { + if (active) defaultRemote = new URL(active.remote).toString(); + } catch { + // keep the cloud default + } + const suggestions = [ + defaultRemote, + ...remotes.filter((r) => r !== defaultRemote), + ]; + if (!suggestions.includes(CLOUD_REMOTE)) suggestions.push(CLOUD_REMOTE); + return { suggestions, defaultRemote }; +} + export async function add( opts: GlobalOptions & { create: boolean; @@ -225,11 +266,14 @@ export async function add( remote = url.toString(); } catch { // not a url + const { suggestions, defaultRemote } = await knownRemotes(opts); remote = new URL( - await Input.prompt({ + await PickableInput.prompt({ message: "Enter the Remote URL", - suggestions: ["https://app.windmill.dev/"], - default: "https://app.windmill.dev/", + suggestions, + list: suggestions.length > 1, + info: suggestions.length > 1, + default: defaultRemote, }) ).toString(); }