From 056e8f86d857bf2848b61a6d8352da3aeca3a5d9 Mon Sep 17 00:00:00 2001 From: Neil Date: Sun, 15 Nov 2026 23:47:42 -0800 Subject: [PATCH] feat(cloud): SHARE-LINKS-HOLD cloud workspace share links off for this release (capability flag) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Neil: hold share links this release, keep the code. Every way to produce a link is behind the account capability flag `cloudShareLinks` (capabilities.flags, the existing server-driven pattern), so it's off unless the control plane turns it on: - sidebar right-click Copy › "Link to W-n" / "Workspace link": hidden; - the cloud workspace list's ⋯ "Copy link to W-n" and "Copy link to this chat/terminal": hidden; - ⌘⌥⇧L: does nothing (global and in the list row), and is gone from Settings › Shortcuts and its search; - copyCloudWorkspaceLink itself returns false with no clipboard write or toast, so the private-link toast (#815) can't be reached from anywhere. Unchanged: opening incoming orca://cloud links, and Share with team / Make private (access, not the link). --- .../cloud-workspaces/CloudWorkspaceRow.tsx | 2 ++ .../CloudWorkspaceRowMenu.tsx | 25 +++++++++------- .../cloud-workspaces/cloud-workspace-links.ts | 2 ++ .../cloud-workspace-share-link.test.ts | 4 +++ .../cloud-workspace-share-link.ts | 5 ++++ .../open-cloud-workspace-copy-link.test.ts | 15 ++++++++++ .../orca-cloud/CloudWorkspaceMenuItems.tsx | 5 +++- .../settings/shortcuts/shortcut-groups.ts | 8 +++++ .../shortcut-share-link-hold.test.ts | 30 +++++++++++++++++++ .../settings/shortcuts/shortcuts-search.ts | 7 ++++- .../lib/orca-cloud/cloud-share-links-flag.ts | 22 ++++++++++++++ 11 files changed, 113 insertions(+), 12 deletions(-) create mode 100644 src/renderer/src/components/settings/shortcuts/shortcut-share-link-hold.test.ts create mode 100644 src/renderer/src/lib/orca-cloud/cloud-share-links-flag.ts diff --git a/src/renderer/src/components/cloud-workspaces/CloudWorkspaceRow.tsx b/src/renderer/src/components/cloud-workspaces/CloudWorkspaceRow.tsx index 59535571a87..450d133bab8 100644 --- a/src/renderer/src/components/cloud-workspaces/CloudWorkspaceRow.tsx +++ b/src/renderer/src/components/cloud-workspaces/CloudWorkspaceRow.tsx @@ -1,4 +1,5 @@ import { CloudStatusGlyph } from '@/components/orca-cloud/CloudStatusGlyph' +import { cloudShareLinksEnabled } from '@/lib/orca-cloud/cloud-share-links-flag' import React, { useId, useState } from 'react' import { GitBranch, Loader2 } from 'lucide-react' import { Button } from '@/components/ui/button' @@ -150,6 +151,7 @@ export function CloudWorkspaceRow({ return } if ( + cloudShareLinksEnabled() && keybindingMatchesAction( 'cloudWorkspace.copyLink', event.nativeEvent, diff --git a/src/renderer/src/components/cloud-workspaces/CloudWorkspaceRowMenu.tsx b/src/renderer/src/components/cloud-workspaces/CloudWorkspaceRowMenu.tsx index 79ac25e6a85..edbbb57a334 100644 --- a/src/renderer/src/components/cloud-workspaces/CloudWorkspaceRowMenu.tsx +++ b/src/renderer/src/components/cloud-workspaces/CloudWorkspaceRowMenu.tsx @@ -1,4 +1,5 @@ import React, { useRef } from 'react' +import { useCloudShareLinksEnabled } from '@/lib/orca-cloud/cloud-share-links-flag' import { ArchiveSnapshotTooltip } from '@/components/orca-cloud/ArchiveSnapshotTooltip' import { Archive, @@ -111,6 +112,7 @@ export function CloudWorkspaceRowMenu({ const t = useTranslate() const keybindings = useAppStore((state) => state.keybindings) const copyShortcut = formatOptionalPrimaryShortcutLabel('cloudWorkspace.copyLink', keybindings) + const shareLinks = useCloudShareLinksEnabled() // Read when the menu renders (it re-renders on open), not kept: focus moves between opens. const focused = open ? (actions.focusedItem?.(w) ?? null) : null const teammatesHere = canOpen @@ -185,16 +187,19 @@ export function CloudWorkspaceRowMenu({ ↵ )} - actions.copyLink(w)}> - - {w.number - ? t('auto.components.cloudWorkspaces.copyLinkTo', 'Copy link to {{number}}', { - number: formatWorkspaceNumber(w.number) - }) - : t('auto.components.cloudWorkspaces.copyLink', 'Copy link')} - {copyShortcut ? {copyShortcut} : null} - - {focused ? ( + {/* SHARE-LINKS-HOLD: the Copy link items only while share links are on. */} + {shareLinks ? ( + actions.copyLink(w)}> + + {w.number + ? t('auto.components.cloudWorkspaces.copyLinkTo', 'Copy link to {{number}}', { + number: formatWorkspaceNumber(w.number) + }) + : t('auto.components.cloudWorkspaces.copyLink', 'Copy link')} + {copyShortcut ? {copyShortcut} : null} + + ) : null} + {shareLinks && focused ? ( actions.copyWorkspaceLink(w)}> {focused === 'terminal' ? : } {focused === 'terminal' diff --git a/src/renderer/src/components/cloud-workspaces/cloud-workspace-links.ts b/src/renderer/src/components/cloud-workspaces/cloud-workspace-links.ts index 36d0b9a22b2..c94f69cc47f 100644 --- a/src/renderer/src/components/cloud-workspaces/cloud-workspace-links.ts +++ b/src/renderer/src/components/cloud-workspaces/cloud-workspace-links.ts @@ -1,5 +1,6 @@ // App-level wiring for team cloud workspaces: orca://cloud links, presence for the workspace in // front, and the copy-link shortcut. Installed once from main.tsx; no React tree needed. +import { cloudShareLinksEnabled } from '@/lib/orca-cloud/cloud-share-links-flag' import { toast } from 'sonner' import { useAppStore } from '@/store' import { getShortcutPlatform } from '@/lib/keyboard/shortcut-platform' @@ -232,6 +233,7 @@ export function installCloudWorkspaceLinks(): () => void { const target = event.target instanceof HTMLElement ? event.target : null if ( !event.defaultPrevented && + cloudShareLinksEnabled() && !shortcutOwnedElsewhere(target) && keybindingMatchesAction( 'cloudWorkspace.copyLink', diff --git a/src/renderer/src/components/cloud-workspaces/cloud-workspace-share-link.test.ts b/src/renderer/src/components/cloud-workspaces/cloud-workspace-share-link.test.ts index a1d37a91d5a..5c0737bc6a2 100644 --- a/src/renderer/src/components/cloud-workspaces/cloud-workspace-share-link.test.ts +++ b/src/renderer/src/components/cloud-workspaces/cloud-workspace-share-link.test.ts @@ -4,6 +4,10 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' const toasts = vi.hoisted(() => ({ success: vi.fn(), warning: vi.fn(), error: vi.fn() })) vi.mock('sonner', () => ({ toast: toasts })) +const shareLinks = vi.hoisted(() => ({ on: true })) +vi.mock('@/lib/orca-cloud/cloud-share-links-flag', () => ({ + cloudShareLinksEnabled: () => shareLinks.on +})) import { copyCloudWorkspaceLink } from './cloud-workspace-share-link' import { rememberCloudWorkspaces } from './cloud-workspace-identity' diff --git a/src/renderer/src/components/cloud-workspaces/cloud-workspace-share-link.ts b/src/renderer/src/components/cloud-workspaces/cloud-workspace-share-link.ts index 887d3f4a1d8..d488375eb9a 100644 --- a/src/renderer/src/components/cloud-workspaces/cloud-workspace-share-link.ts +++ b/src/renderer/src/components/cloud-workspaces/cloud-workspace-share-link.ts @@ -1,4 +1,5 @@ // A cloud workspace's share link: the org slug + W-number link when known, else the sandbox-id form. +import { cloudShareLinksEnabled } from '@/lib/orca-cloud/cloud-share-links-flag' import { toast } from 'sonner' import { translate } from '@/i18n/i18n' import { @@ -47,6 +48,10 @@ export async function copyCloudWorkspaceLink( chatId?: string | null, options: { quiet?: boolean } = {} ): Promise { + // SHARE-LINKS-HOLD: nothing is copied while share links are held. + if (!cloudShareLinksEnabled()) { + return false + } const link = await shareLinkFor(id, chatId) try { // Why: main-process clipboard, like every other renderer copy. navigator.clipboard needs a diff --git a/src/renderer/src/components/cloud-workspaces/open-cloud-workspace-copy-link.test.ts b/src/renderer/src/components/cloud-workspaces/open-cloud-workspace-copy-link.test.ts index f8411a89ea0..b0fc7e11ef4 100644 --- a/src/renderer/src/components/cloud-workspaces/open-cloud-workspace-copy-link.test.ts +++ b/src/renderer/src/components/cloud-workspaces/open-cloud-workspace-copy-link.test.ts @@ -2,6 +2,10 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' const toast = vi.hoisted(() => ({ error: vi.fn(), success: vi.fn() })) vi.mock('sonner', () => ({ toast })) +const shareLinks = vi.hoisted(() => ({ on: true })) +vi.mock('@/lib/orca-cloud/cloud-share-links-flag', () => ({ + cloudShareLinksEnabled: () => shareLinks.on +})) import { copyCloudWorkspaceLink, shareLinkFor } from './open-cloud-workspace' import { rememberCloudWorkspaces } from './cloud-workspace-identity' @@ -86,4 +90,15 @@ describe('copy cloud workspace link', () => { expect(toast.error).toHaveBeenCalledTimes(1) warn.mockRestore() }) + + it('SHARE-LINKS-HOLD: with share links held, nothing is copied and no toast shows', async () => { + shareLinks.on = false + try { + await expect(copyCloudWorkspaceLink('sbx_held')).resolves.toBe(false) + expect(writeClipboardText).not.toHaveBeenCalled() + expect(toast.success).not.toHaveBeenCalled() + } finally { + shareLinks.on = true + } + }) }) diff --git a/src/renderer/src/components/orca-cloud/CloudWorkspaceMenuItems.tsx b/src/renderer/src/components/orca-cloud/CloudWorkspaceMenuItems.tsx index 11e46733bc3..e69d9b5f5a3 100644 --- a/src/renderer/src/components/orca-cloud/CloudWorkspaceMenuItems.tsx +++ b/src/renderer/src/components/orca-cloud/CloudWorkspaceMenuItems.tsx @@ -1,4 +1,5 @@ import React, { useContext } from 'react' +import { useCloudShareLinksEnabled } from '@/lib/orca-cloud/cloud-share-links-flag' import { ArchiveSnapshotTooltip } from './ArchiveSnapshotTooltip' import { toast } from 'sonner' import { @@ -202,7 +203,9 @@ export function CloudCopyWorkspaceLinkItem({ }): React.JSX.Element | null { const t = useTranslate() const { workspace } = useCloudWorkspaceRecord(worktreeId, hostId ?? null) - if (!workspace) { + // SHARE-LINKS-HOLD: no way to produce a share link while it's held. + const shareLinks = useCloudShareLinksEnabled() + if (!workspace || !shareLinks) { return null } return ( diff --git a/src/renderer/src/components/settings/shortcuts/shortcut-groups.ts b/src/renderer/src/components/settings/shortcuts/shortcut-groups.ts index ba6479e55d9..92343aa6bfa 100644 --- a/src/renderer/src/components/settings/shortcuts/shortcut-groups.ts +++ b/src/renderer/src/components/settings/shortcuts/shortcut-groups.ts @@ -2,6 +2,10 @@ import { KEYBINDING_DEFINITIONS, agentTabActionId } from '../../../../../shared/keybindings/definitions' +import { + CLOUD_SHARE_LINK_ACTION_ID, + cloudShareLinksEnabled +} from '@/lib/orca-cloud/cloud-share-links-flag' import type { KeybindingActionId, KeybindingDefinition @@ -31,6 +35,10 @@ export function groupDefinitions( const hiddenAgentActionIds = new Set( disabledAgentTabActionIds(disabledTuiAgents) ) + // SHARE-LINKS-HOLD: no ⌘⌥⇧L entry while share links are held. + if (!cloudShareLinksEnabled()) { + hiddenAgentActionIds.add(CLOUD_SHARE_LINK_ACTION_ID) + } const groups = new Map() for (const definition of [...KEYBINDING_DEFINITIONS, ...additionalDefinitions]) { if (hiddenAgentActionIds.has(definition.id)) { diff --git a/src/renderer/src/components/settings/shortcuts/shortcut-share-link-hold.test.ts b/src/renderer/src/components/settings/shortcuts/shortcut-share-link-hold.test.ts new file mode 100644 index 00000000000..81e4db4f363 --- /dev/null +++ b/src/renderer/src/components/settings/shortcuts/shortcut-share-link-hold.test.ts @@ -0,0 +1,30 @@ +// SHARE-LINKS-HOLD: ⌘⌥⇧L (Copy cloud workspace link) is listed in Settings › Shortcuts and its +// search only while share links are on. +import { describe, expect, it, vi } from 'vitest' + +const shareLinks = vi.hoisted(() => ({ on: false })) +vi.mock('@/lib/orca-cloud/cloud-share-links-flag', () => ({ + CLOUD_SHARE_LINK_ACTION_ID: 'cloudWorkspace.copyLink', + cloudShareLinksEnabled: () => shareLinks.on +})) + +import { groupDefinitions } from './shortcut-groups' +import { getShortcutsPaneSearchEntries } from './shortcuts-search' + +const listed = (): string[] => + groupDefinitions([]).flatMap((group) => group.items.map((item) => item.id)) +const searched = (): string[] => getShortcutsPaneSearchEntries().map((entry) => entry.title) + +describe('the share-link shortcut in Settings', () => { + it('held: not listed and not searchable', () => { + shareLinks.on = false + expect(listed()).not.toContain('cloudWorkspace.copyLink') + expect(searched()).not.toContain('Copy cloud workspace link') + }) + + it('on: listed and searchable', () => { + shareLinks.on = true + expect(listed()).toContain('cloudWorkspace.copyLink') + expect(searched()).toContain('Copy cloud workspace link') + }) +}) diff --git a/src/renderer/src/components/settings/shortcuts/shortcuts-search.ts b/src/renderer/src/components/settings/shortcuts/shortcuts-search.ts index 12b874588c8..d8f05637a18 100644 --- a/src/renderer/src/components/settings/shortcuts/shortcuts-search.ts +++ b/src/renderer/src/components/settings/shortcuts/shortcuts-search.ts @@ -1,4 +1,8 @@ import { KEYBINDING_DEFINITIONS } from '../../../../../shared/keybindings/definitions' +import { + CLOUD_SHARE_LINK_ACTION_ID, + cloudShareLinksEnabled +} from '@/lib/orca-cloud/cloud-share-links-flag' import type { SettingsSearchEntry } from '../search/settings-search' import { translate } from '@/i18n/i18n' import { translateSearchKeyword } from '../search/settings-search-keywords' @@ -62,7 +66,8 @@ export function getShortcutsPaneSearchEntries(options?: { ({ actionId }) => (includeManagedBrowser || (actionId !== 'tab.newBrowser' && actionId !== 'tab.newBrowserSplitRight')) && - (includeMobileEmulator || actionId !== 'tab.newSimulator') + (includeMobileEmulator || actionId !== 'tab.newSimulator') && + (actionId !== CLOUD_SHARE_LINK_ACTION_ID || cloudShareLinksEnabled()) ) .map(({ searchEntry }) => searchEntry), getTerminalShortcutPolicySearchEntry() diff --git a/src/renderer/src/lib/orca-cloud/cloud-share-links-flag.ts b/src/renderer/src/lib/orca-cloud/cloud-share-links-flag.ts new file mode 100644 index 00000000000..70abe34e6f5 --- /dev/null +++ b/src/renderer/src/lib/orca-cloud/cloud-share-links-flag.ts @@ -0,0 +1,22 @@ +// SHARE-LINKS-HOLD (Neil): cloud workspace share links are held for this release. The code stays; +// every way to produce a link (Copy › Workspace link / chat link, the cloud list's Copy link items, +// ⌘⌥⇧L and its Settings entry) is off unless the account's capabilities turn on `cloudShareLinks`. +// Opening an orca://cloud link someone already has still works. Share with team (visibility) stays. +import { useAppStore } from '@/store' +import type { OrcaProfileAuthStatus } from '../../../../shared/orca-profiles' + +export const CLOUD_SHARE_LINKS_FLAG = 'cloudShareLinks' +export const CLOUD_SHARE_LINK_ACTION_ID = 'cloudWorkspace.copyLink' + +function enabledFor(status: OrcaProfileAuthStatus | null | undefined): boolean { + return status?.capabilities?.flags[CLOUD_SHARE_LINKS_FLAG] === true +} + +/** Outside React (keyboard handlers, the copy itself, Settings' shortcut list). */ +export function cloudShareLinksEnabled(): boolean { + return enabledFor(useAppStore.getState().orcaProfileAuthStatus) +} + +export function useCloudShareLinksEnabled(): boolean { + return useAppStore((state) => enabledFor(state.orcaProfileAuthStatus)) +}