From 6ffbee1e241d93400171e8e5687659d6ef4361d3 Mon Sep 17 00:00:00 2001 From: Oleg Isonen Date: Mon, 30 Nov 2026 13:29:02 +0000 Subject: [PATCH] feat: Add instance link shortcut (#6736) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a keyboard shortcut to the existing “Copy link to instance” action. It copies a link to the current page and selected instance without a success toast, matching other copy actions. The Navigator context-menu item shows ⌘+L on macOS and Ctrl+L elsewhere through the shared `Kbd` primary-modifier mapping. The Vercel preview and fixture workflow no longer runs for feature-branch pushes before a PR exists. Opening or updating a PR runs the workflow; pushes to `main` and `*.staging` keep their existing behavior. We want to push freely while working and spend CI resources only after opening a PR. - [x] Reuse the existing context-menu copy behavior for the shortcut. - [x] Show the platform shortcut hint on the existing Navigator menu item. - [x] Keep copy feedback consistent with other copy actions: no success toast. - [x] Restrict workflow pushes to `main` and `*.staging`, and run it for PRs. - [x] Update the Navigator and shortcuts documentation. - [x] Run focused checks: 59 Builder tests passed; formatting passed. - [x] Verify Ctrl+L in the live Builder on macOS Chrome; it copied the instance link. - [ ] Verify the hint and shortcut behavior in a Windows browser. Windows is unavailable here; Chrome on Windows reserves Ctrl+L for the address bar. - [x] Documentation impact reviewed; no other docs need changes. - [x] Trace the shared E2E failures on shards 2, 3, and 5 to the expired HTTPS certificate used by the dedicated Builder test server. The server now allows this certificate for OAuth token exchanges; all three affected E2E tests pass locally. Ref #4364 --- .github/workflows/vercel-deploy-staging.yml | 18 ++++++++----- apps/builder/app/builder/shared/commands.ts | 21 +++++++++++++++ .../builder/shared/instance-context-menu.tsx | 27 ++++++++----------- apps/builder/e2e/serve-built-remix.ts | 4 +++ docs/university/foundations/navigator.md | 9 ++++--- docs/university/foundations/shortcuts.md | 1 + packages/design-system/src/components/kbd.tsx | 1 + 7 files changed, 55 insertions(+), 26 deletions(-) diff --git a/.github/workflows/vercel-deploy-staging.yml b/.github/workflows/vercel-deploy-staging.yml index b69aa441fe..1800daec07 100644 --- a/.github/workflows/vercel-deploy-staging.yml +++ b/.github/workflows/vercel-deploy-staging.yml @@ -2,6 +2,10 @@ name: Vercel Deploy Staging on: push: + branches: + - main + - "*.staging" + pull_request: workflow_call: # cancel in-progress runs on new commits to same PR (gitub.event.number) @@ -19,6 +23,7 @@ jobs: deployment: # Execute development and staging on staging branches # Execute only development on all other branches + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false strategy: matrix: environment: @@ -40,7 +45,7 @@ jobs: steps: - uses: actions/checkout@v5 with: - ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.sha }} + ref: ${{ github.event.pull_request.head.sha || github.sha }} allow-unsafe-pr-checkout: ${{ github.event_name == 'pull_request_target' && github.event.action == 'labeled' && github.event.label.name == 'safe-to-deploy' }} - uses: ./.github/actions/submodules-checkout @@ -61,8 +66,8 @@ jobs: vercel-token: ${{ secrets.VERCEL_TOKEN }} vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} - ref-name: ${{ github.event_name == 'pull_request_target' && format('pr-{0}', github.event.pull_request.number) || github.ref_name }} - sha: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.sha }} + ref-name: ${{ github.event.pull_request && format('pr-{0}', github.event.pull_request.number) || github.ref_name }} + sha: ${{ github.event.pull_request.head.sha || github.sha }} environment: ${{ matrix.environment }} production-staged: ${{ github.event_name == 'push' && matrix.environment == 'staging' && startsWith(github.ref_name, 'release-') && endsWith(github.ref_name, '.staging') }} PUBLIC_COLLAB_RELAY_URL: ${{ vars.PUBLIC_COLLAB_RELAY_URL }} @@ -102,19 +107,20 @@ jobs: builder-host: "${{ steps.vercel.outputs.alias }}.${{ matrix.environment }}.webstudio.is" deployment-host: + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false runs-on: ubuntu-latest outputs: development-builder-host: ${{ steps.host.outputs.value }} steps: - uses: actions/checkout@v5 with: - ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.sha }} + ref: ${{ github.event.pull_request.head.sha || github.sha }} allow-unsafe-pr-checkout: ${{ github.event_name == 'pull_request_target' && github.event.action == 'labeled' && github.event.label.name == 'safe-to-deploy' }} - id: host shell: bash env: - REF_NAME: ${{ github.event_name == 'pull_request_target' && format('pr-{0}', github.event.pull_request.number) || github.ref_name }} + REF_NAME: ${{ github.event.pull_request && format('pr-{0}', github.event.pull_request.number) || github.ref_name }} run: | clean_name=$(.github/actions/vercel/deployment-alias.sh "${REF_NAME}") echo "value=${clean_name}.development.webstudio.is" >> "$GITHUB_OUTPUT" @@ -136,4 +142,4 @@ jobs: needs: fixtures-test uses: ./.github/workflows/delete-github-deployments.yml with: - ref: ${{ github.event_name == 'pull_request_target' && format('pr-{0}', github.event.pull_request.number) || github.ref_name }} + ref: ${{ github.event.pull_request && format('pr-{0}', github.event.pull_request.number) || github.ref_name }} diff --git a/apps/builder/app/builder/shared/commands.ts b/apps/builder/app/builder/shared/commands.ts index 7cd8708fbc..763dea2e10 100644 --- a/apps/builder/app/builder/shared/commands.ts +++ b/apps/builder/app/builder/shared/commands.ts @@ -105,6 +105,7 @@ import { emitPaste, cutInstance, } from "~/shared/copy-paste/copy-paste"; +import { getInstanceLink } from "~/shared/instance-utils/link"; import { getDeletablePageActionTarget, getPageActionTarget, @@ -935,6 +936,26 @@ export const { emitCommand, subscribeCommands } = createCommandsEmitter({ void copyInstance(); }, }, + { + name: "copyInstanceLink", + hidden: true, + category: "Navigator", + defaultHotkeys: ["meta+l", "ctrl+l"], + disableOnInputLikeControls: true, + handler: async () => { + const link = getInstanceLink( + $selectedInstancePath.get()?.[0]?.instanceSelector + ); + if (link === undefined) { + return; + } + try { + await navigator.clipboard.writeText(link); + } catch { + toast.error("Could not copy link"); + } + }, + }, { name: "paste", description: "Paste copied instance(s)", diff --git a/apps/builder/app/builder/shared/instance-context-menu.tsx b/apps/builder/app/builder/shared/instance-context-menu.tsx index 2eef2caa0e..1946b738ce 100644 --- a/apps/builder/app/builder/shared/instance-context-menu.tsx +++ b/apps/builder/app/builder/shared/instance-context-menu.tsx @@ -14,7 +14,6 @@ import { theme, Kbd, Box, - toast, } from "@webstudio-is/design-system"; import { showAttribute } from "@webstudio-is/react-sdk"; import { emitCommand, instanceMoveCommandMetas } from "./commands"; @@ -34,10 +33,7 @@ import { type InstancePath, } from "@webstudio-is/project-build/runtime"; import { canDeleteInstanceInContentMode } from "@webstudio-is/project-build/runtime"; -import { - getInstanceLink, - getDeepLinkedInstanceSelection, -} from "~/shared/instance-utils/link"; +import { getDeepLinkedInstanceSelection } from "~/shared/instance-utils/link"; import { $instances, $pages, $project } from "~/shared/sync/data-stores"; import { isComponentDetachable, @@ -205,20 +201,19 @@ export const MenuItems = () => { { - const link = getInstanceLink(instanceSelector); - if (link === undefined) { - return; - } - try { - await navigator.clipboard.writeText(link); - toast.success("Link copied"); - } catch { - toast.error("Could not copy link"); - } + onSelect={() => { + emitCommand("copyInstanceLink"); }} > Copy link to instance + + + { // Resource E2E fixtures use loopback URLs. Keep this exception limited to // the dedicated test server; production uses the public-address guard. process.env.E2E_ALLOW_LOCAL_RESOURCE_URLS = "true"; + // Allow the dedicated E2E server's local HTTPS certificate for loopback + // service-to-service fetches such as oauth.ws.token, matching vite.config.ts + // and e2e/setup.ts. + process.env.NODE_TLS_REJECT_UNAUTHORIZED ??= "0"; const serverDirectory = path.resolve("build/server"); const builds = await Promise.all( readdirSync(serverDirectory, { withFileTypes: true }) diff --git a/docs/university/foundations/navigator.md b/docs/university/foundations/navigator.md index 2166f58e5e..06e2e44101 100644 --- a/docs/university/foundations/navigator.md +++ b/docs/university/foundations/navigator.md @@ -37,10 +37,11 @@ keeps the remaining selection intact. ### Link to a selected instance -Right-click an instance and choose **Copy link to instance** to copy its full -Builder URL to the clipboard. Share the link to open the same page and select -the same instance, including its location inside a shared Slot. Select one -instance at a time; this action is unavailable for Global Root. +Right-click an instance and choose **Copy link to instance** +(`⌘ + L` on macOS, `Ctrl + L` on Windows when not intercepted by the browser) +to copy its full Builder URL to the clipboard. Share the link to open the same +page and select the same instance, including its location inside a shared Slot. +Select one instance at a time; this action is unavailable for Global Root. The recipient needs access to the project. If you opened the Builder through a share link, the copied URL keeps that share link’s access token. diff --git a/docs/university/foundations/shortcuts.md b/docs/university/foundations/shortcuts.md index 82b3543864..3cf0eed478 100644 --- a/docs/university/foundations/shortcuts.md +++ b/docs/university/foundations/shortcuts.md @@ -30,6 +30,7 @@ icon: command ## **Sidebar Left** - Copy: `⌘ + c` +- Copy link to instance: `⌘ + l` (macOS) / `Ctrl + l` (Windows, when not intercepted by the browser) - Cut: `⌘ + x` - Paste: `⌘ + v` - Duplicate: `⌘ + d` diff --git a/packages/design-system/src/components/kbd.tsx b/packages/design-system/src/components/kbd.tsx index 5d4cacd425..e156f18ea0 100644 --- a/packages/design-system/src/components/kbd.tsx +++ b/packages/design-system/src/components/kbd.tsx @@ -4,6 +4,7 @@ const isMac = typeof navigator === "object" ? /mac/i.test(navigator.platform) : false; const shortcutSymbolMap: Record = { + // Cross-platform primary modifier: ⌘ on macOS, Ctrl elsewhere. meta: isMac ? "⌘" : "Ctrl", shift: "⇧", alt: isMac ? "⌥" : "Alt",