mirror of
https://github.com/stablyai/orca.git
synced 2026-11-17 03:15:01 +00:00
Merge remote-tracking branch 'private/cloud/integration' into cloud/dev-seed-gate
# Conflicts: # cloud/apps/sandbox-control/src/index.ts
This commit is contained in:
@@ -15,7 +15,8 @@ import { memberNamesFor } from './member-names'
|
||||
import { effectiveSecrets } from './secrets'
|
||||
import { getSandbox, type SandboxRow } from './store'
|
||||
import { agentCredentialState, isUsable } from './agent-credentials'
|
||||
import { accountProvider, isSharedWorkspace } from './account-providers'
|
||||
import { accountProvider } from './account-providers'
|
||||
import { sharedWorkspaceMode } from './shared-workspace'
|
||||
|
||||
export type AgentSource = 'sign-in' | 'key'
|
||||
type OfferAnswer = 'unanswered' | 'accepted' | 'declined'
|
||||
@@ -157,7 +158,7 @@ export async function agentSourcesView(
|
||||
owner = { userId: row.user_id, displayName: names.get(row.user_id) ?? null, isCaller: row.user_id === caller.userId }
|
||||
}
|
||||
// D13: personal accounts never apply in a workspace shared with teammates.
|
||||
const sharedWorkspace = row ? isSharedWorkspace(row) : false
|
||||
const sharedWorkspace = row ? await sharedWorkspaceMode(db, row) : false
|
||||
return { defaults, inWorkspace, workspace, effective: resolved, coveredByKey: covered, signInOffer, owner, sharedWorkspace }
|
||||
}
|
||||
|
||||
@@ -236,6 +237,7 @@ export async function agentModesFor(
|
||||
const inWorkspace = inWorkspaceAgents(rows)
|
||||
const covered = coveredByKey(new Set(Object.keys(env)))
|
||||
const modes = {} as Record<CredentialAgent, AgentMode>
|
||||
const shared = await sharedWorkspaceMode(db, row)
|
||||
for (const agent of CREDENTIAL_AGENTS) {
|
||||
if (!workspace[agent] && inWorkspace[agent]) {
|
||||
// Nothing of Orca's for this agent: no placeholder, no key, no egress route, so the login the person
|
||||
@@ -255,7 +257,7 @@ export async function agentModesFor(
|
||||
} else if (!enabled) {
|
||||
// Kill switch (or no provider yet): the agent signs in inside the sandbox; keys stay out (Rule 3).
|
||||
modes[agent] = 'omit'
|
||||
} else if (usable && options.accountsUsable && !isSharedWorkspace(row)) {
|
||||
} else if (usable && options.accountsUsable && !shared) {
|
||||
modes[agent] = 'account'
|
||||
} else {
|
||||
// Expired/revoked, placeholders off, or a shared workspace (D13): the winning key, if any.
|
||||
|
||||
@@ -41,6 +41,8 @@ export type Env = {
|
||||
/** GH-AS-MEMBER: how long a shared workspace's latest sender keeps acting after their last send (default 60; `0`: no cap). */
|
||||
MEMBER_GIT_SHARED_MAX_MINUTES?: string
|
||||
/** GH-AS-MEMBER: `on` lets gh in workspaces act as the attested sender (off by default). */
|
||||
/** TEAM-SHARING hold (team-sharing.ts): `on` lets workspaces be shared with the team; anything else holds it. */
|
||||
TEAM_SHARING?: string
|
||||
GH_AS_MEMBER?: string
|
||||
/**
|
||||
* Who sees a member's daily activity heatmap on their profile. `opt_in` (default): only members
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
// DELETE /v1/team/workspaces/:id/grants/:grantId grantee, workspace owner or org admin
|
||||
// Revocation removes the device from orcad's registry (orca-sandbox-revoke); while the sandbox is
|
||||
// not running it is queued and applied at the next boot before orcad starts.
|
||||
import { teamSharingEnabled } from './team-sharing'
|
||||
import { z } from 'zod'
|
||||
import type { SandboxCaller } from './auth'
|
||||
import { isDeviceSessionLive } from './device-sessions'
|
||||
@@ -268,6 +269,40 @@ export async function revokeForAccessChange(
|
||||
return revokeGrants(deps, row, results, { by, reason: mode === 'non_owner' ? 'workspace_private' : 'owner_changed' })
|
||||
}
|
||||
|
||||
/**
|
||||
* TEAM-SHARING hold (team-sharing.ts): while sharing is held, a workspace stored as `team` acts private, so
|
||||
* every device grant but its owner's goes, the way making it private revokes them (reason team_sharing_held).
|
||||
* Transferred workspaces keep their own rules. Bounded per run; the next run takes the rest.
|
||||
*/
|
||||
export async function sweepHeldTeamGrants(deps: LifecycleDeps): Promise<{ workspaces: number; revoked: number; queued: number }> {
|
||||
const out = { workspaces: 0, revoked: 0, queued: 0 }
|
||||
if (teamSharingEnabled()) {
|
||||
return out
|
||||
}
|
||||
const { results } = await deps.db
|
||||
.prepare(
|
||||
`SELECT g.* FROM workspace_grants g JOIN sandboxes s ON s.id = g.sandbox_id
|
||||
WHERE g.status IN ('issuing', 'active') AND g.user_id <> s.user_id AND s.visibility = 'team' AND s.ownership_transferred_at IS NULL AND s.status <> 'destroyed'
|
||||
ORDER BY g.sandbox_id LIMIT 500`
|
||||
)
|
||||
.all<GrantRow>()
|
||||
const bySandbox = new Map<string, GrantRow[]>()
|
||||
for (const grant of results) {
|
||||
bySandbox.set(grant.sandbox_id, [...(bySandbox.get(grant.sandbox_id) ?? []), grant])
|
||||
}
|
||||
for (const [sandboxId, grants] of bySandbox) {
|
||||
const row = await getSandbox(deps.db, sandboxId)
|
||||
if (!row) {
|
||||
continue
|
||||
}
|
||||
const result = await revokeGrants(deps, row, grants, { by: 'system', reason: 'team_sharing_held' }).catch(() => ({ revoked: 0, queued: 0 }))
|
||||
out.workspaces++
|
||||
out.revoked += result.revoked
|
||||
out.queued += result.queued
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
/** A member left the org (auth push) or a phone session ended (W8): revoke everywhere. */
|
||||
async function revokeWhere(deps: LifecycleDeps, where: string, binds: (string | number)[], audit: { by: string; reason: string }) {
|
||||
const { results } = await deps.db
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
// Public share links (src/share-gateway.ts): /s/<token>/*, plus the root-path cookie fallback
|
||||
// Vercel network-policy forwardURL target (Vercel sandbox OIDC): /v1/egress/proxy
|
||||
import { devOnly } from './dev-only'
|
||||
import { configureTeamSharing, teamSharingEnabled } from './team-sharing'
|
||||
import { purgeTeamSecrets, teamDeleteRoute, teamWorkspaceCount } from './team-delete'
|
||||
import { ReadSnapshotRouteError, getReadSnapshot, handleReaderKeysRoute, pruneReadSnapshotToOwner, revokeDeviceSessionReaderKeys } from './read-snapshots'
|
||||
import { refreshEnvironment, refreshStaleEnvironments, type GoldenRefreshOptions } from './environment-golden-refresh'
|
||||
@@ -138,7 +139,8 @@ import { pushCredentialToSandbox, refreshAfterSecretChange, refreshSandboxEnv }
|
||||
import { credentialPushTargets, markCredentialChanged, pushCredentialChange, pushPendingCredentialChanges, type CredentialChange, type PushDeps } from './credential-outbox'
|
||||
import { markExpiredAccountCredentials, refreshGitHubUserTokens } from './credential-refresh'
|
||||
import type { CredentialAgent } from './agent-credential-names'
|
||||
import { ACCOUNT_PROVIDERS, accountProvider, claudeAccount, isSharedWorkspace } from './account-providers'
|
||||
import { ACCOUNT_PROVIDERS, accountProvider, claudeAccount } from './account-providers'
|
||||
import { sharedWorkspaceMode } from './shared-workspace'
|
||||
import { handleAccountRequestSucceeded, handleAccountUnauthorized, runScheduledAccountChecks, verifyAccountCredential } from './agent-credential-checks'
|
||||
import { codexBrokerTick, handleCodexBrokerRoute, type BrokerDeps } from './codex-broker'
|
||||
import { codexAccount, parseStoredCodex, refreshCodexLeases, storeCodexLogin } from './codex-credentials'
|
||||
@@ -208,7 +210,8 @@ import {
|
||||
recordOwnerDeviceForCreate,
|
||||
revokeForAccessChange,
|
||||
revokeGrantsForDeviceSession,
|
||||
revokeOne
|
||||
revokeOne,
|
||||
sweepHeldTeamGrants
|
||||
} from './grants'
|
||||
import { getOrgPrompts, putOrgPrompts } from './org-prompts'
|
||||
import {
|
||||
@@ -476,7 +479,7 @@ function egressRoutes(env: Env, deps: Deps): (row: SandboxRow, host: string) =>
|
||||
scheduleEnvRefresh(env, deps, row)
|
||||
return signedOut('account_owner_changed')
|
||||
}
|
||||
if (isSharedWorkspace(row)) {
|
||||
if (await sharedWorkspaceMode(env.SANDBOX_DB, row)) {
|
||||
scheduleEnvRefresh(env, deps, row)
|
||||
return signedOut('account_not_shared')
|
||||
}
|
||||
@@ -1356,6 +1359,7 @@ async function shareGateway(request: Request, url: URL, env: Env, deps: Deps): P
|
||||
}
|
||||
|
||||
export async function handleRequest(request: Request, env: Env, deps: Deps = {}): Promise<Response> {
|
||||
configureTeamSharing(env)
|
||||
try {
|
||||
return await routeRequest(request, env, deps)
|
||||
} catch (error) {
|
||||
@@ -2436,7 +2440,8 @@ async function workspaceRoute(request: Request, url: URL, env: Env, deps: Deps,
|
||||
const route = `${request.method} ${action ?? ''}${grantId ? ' :grant' : ''}`
|
||||
const view = async (r = row) => (await workspaceViews(db, caller, [r], clock(), githubActingOptions(env)))[0]
|
||||
if (route === 'GET ') {
|
||||
return json({ workspace: await view() })
|
||||
// TEAM-SHARING hold: the capability rides on the single-workspace answer too (panels and link opens read it).
|
||||
return json({ workspace: await view(), teamSharing: teamSharingEnabled() })
|
||||
}
|
||||
if (route === 'GET read-snapshot') {
|
||||
try {
|
||||
@@ -2800,11 +2805,15 @@ function errorResponse(error: unknown): Response {
|
||||
return fail('internal_error', 500)
|
||||
}
|
||||
|
||||
/** TEAM-SHARING hold: whether this isolate has run the held-grants sweep yet (a value, never a promise). */
|
||||
let heldSweepRan = false
|
||||
|
||||
export default {
|
||||
fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
|
||||
return handleRequest(request, env, { waitUntil: (work) => ctx.waitUntil(work.catch(() => undefined)) })
|
||||
},
|
||||
async scheduled(controller: ScheduledController, env: Env, ctx: ExecutionContext): Promise<void> {
|
||||
configureTeamSharing(env)
|
||||
// Every minute: routines (schedule slots, run polling). Every fifth minute: everything else.
|
||||
ctx.waitUntil(
|
||||
lifecycleDeps(env, {}).then(async (life) => {
|
||||
@@ -2835,6 +2844,17 @@ export default {
|
||||
)
|
||||
const fifthMinute = new Date(controller.scheduledTime).getUTCMinutes() % 5 === 0
|
||||
ctx.waitUntil(credentialTick(env, fifthMinute))
|
||||
// TEAM-SHARING hold: every fifth minute, and on an isolate's first run (so right after a deploy).
|
||||
if (!teamSharingEnabled() && (fifthMinute || !heldSweepRan)) {
|
||||
heldSweepRan = true
|
||||
ctx.waitUntil(
|
||||
lifecycleDeps(env, {}).then(async (life) => {
|
||||
const swept = life ? await sweepHeldTeamGrants(life).catch(() => null) : null
|
||||
// Counts only.
|
||||
console.log(JSON.stringify({ event: 'team_sharing_held_sweep', ...(swept ?? { failed: true }) }))
|
||||
})
|
||||
)
|
||||
}
|
||||
if (env.AGENT_ACCOUNTS_CODEX === 'on') {
|
||||
ctx.waitUntil(codexTick(env, fifthMinute))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Sandbox lifecycle: one persistent provider sandbox per Orca workspace, with an Orca-owned lease,
|
||||
// a forced stop before the provider's 24h cap, usage metering and write-ahead rows.
|
||||
import { teamSharingEnabled } from './team-sharing'
|
||||
import { accountProvider } from './account-providers'
|
||||
import { readUsableAgentCredential } from './agent-credentials'
|
||||
import { CODEX_FIREWALL_ALL_PATHS, CODEX_FIREWALL_PATHS } from './codex-paths'
|
||||
@@ -7,7 +8,7 @@ import { codexPlaceholder } from './codex-credentials'
|
||||
/** Where Codex refreshes its ChatGPT login. */
|
||||
export const CODEX_AUTH_HOST = 'auth.openai.com'
|
||||
import { parseStoredCodex } from './codex-credentials'
|
||||
import { isSharedWorkspace } from './shared-workspace'
|
||||
import { sharedWorkspaceMode } from './shared-workspace'
|
||||
import { deleteAgentSourcesForSandbox } from './agent-sources'
|
||||
import { signOutAgentsBeforeDelete } from './agent-signout'
|
||||
import type { EntitlementClient, MachineSize } from './entitlements'
|
||||
@@ -428,11 +429,12 @@ export async function firewallInputsFor(deps: LifecycleDeps, row: SandboxRow): P
|
||||
}
|
||||
const keyring = deps.secrets.keyring
|
||||
const accounts: FirewallAccount[] = []
|
||||
const shared = await sharedWorkspaceMode(deps.db, row)
|
||||
for (const route of egressAccountRoutes(row)) {
|
||||
if (!classes.has(route.agent)) {
|
||||
continue
|
||||
}
|
||||
const applies = route.owner === row.user_id && !isSharedWorkspace(row) && Boolean(deps.secrets.accountProviders?.[route.agent])
|
||||
const applies = route.owner === row.user_id && !shared && Boolean(deps.secrets.accountProviders?.[route.agent])
|
||||
const stored = applies ? await readUsableAgentCredential(deps.db, keyring, row.user_id, route.agent, deps.now()).catch(() => null) : null
|
||||
if (route.agent === 'codex') {
|
||||
const tokens = stored ? parseStoredCodex(stored) : null
|
||||
@@ -1456,8 +1458,9 @@ export async function createSandbox(
|
||||
source_snapshot_id: bootSnapshotId,
|
||||
repo_branch: request.repo?.ref ?? null,
|
||||
name: request.title ?? null,
|
||||
// A personal account has no team: its workspaces are always private.
|
||||
visibility: request.visibility === 'team' && caller.accountId.includes('org:') ? 'team' : 'private',
|
||||
// A personal account has no team: its workspaces are always private. So is every one while team sharing
|
||||
// is held (team-sharing.ts).
|
||||
visibility: request.visibility === 'team' && caller.accountId.includes('org:') && teamSharingEnabled() ? 'team' : 'private',
|
||||
section: request.section ?? null,
|
||||
ownership_transferred_at: request.ownershipTransferredAt ?? null
|
||||
},
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
// the control plane at runtime chooses the recipient keys and drives the VM, so it is trusted not to
|
||||
// add its own key (same as relaying grant keys). Access mirrors canOpen at read time, and pruning
|
||||
// (removal, private, revoke) deletes wrapped keys at once, without the VM.
|
||||
import { effectiveVisibility } from './team-sharing'
|
||||
import { z } from 'zod'
|
||||
import type { SandboxCaller } from './auth'
|
||||
import { ensureEntryPoints } from './golden-images'
|
||||
@@ -202,7 +203,7 @@ export async function readerKeysFor(db: D1Database, row: SandboxRow, now: number
|
||||
if (row.archived_at !== null) {
|
||||
return []
|
||||
}
|
||||
const team = row.visibility === 'team'
|
||||
const team = effectiveVisibility(row) === 'team'
|
||||
const { results } = await db
|
||||
.prepare(
|
||||
`SELECT k.id, k.public_key FROM reader_keys k
|
||||
@@ -340,7 +341,7 @@ export async function captureReadSnapshot(deps: LifecycleDeps, row: SandboxRow,
|
||||
await deps.db.batch(statements)
|
||||
// The workspace may have been made private while sealing: re-apply the current rule.
|
||||
const current = await deps.db.prepare('SELECT * FROM sandboxes WHERE id = ?').bind(row.id).first<SandboxRow>()
|
||||
if (current && current.visibility !== 'team') {
|
||||
if (current && effectiveVisibility(current) !== 'team') {
|
||||
await pruneReadSnapshotToOwner(deps.db, current)
|
||||
}
|
||||
return done({
|
||||
@@ -387,7 +388,7 @@ export async function readSnapshotTimes(db: D1Database, ids: readonly string[]):
|
||||
|
||||
export async function getReadSnapshot(db: D1Database, caller: SandboxCaller, row: SandboxRow, keyId: string | null, now: number) {
|
||||
// Belt and braces over canOpen: a private workspace's snapshot opens only for its owner.
|
||||
if (!canOpen(caller, row) || (row.visibility !== 'team' && !isOwner(caller, row))) {
|
||||
if (!canOpen(caller, row) || (effectiveVisibility(row) !== 'team' && !isOwner(caller, row))) {
|
||||
throw new WorkspaceError('not_found')
|
||||
}
|
||||
if (!keyId || !KEY_ID.test(keyId)) {
|
||||
|
||||
@@ -13,7 +13,7 @@ import { createKeyring, type Keyring, type SealFormat, type SecretBinding } from
|
||||
import { createKekUnwrapper, SecretsKmsError } from './secrets-kms'
|
||||
import { AUTH_IAT_BACKDATE_MS } from './member-changes'
|
||||
import { BASE_URL_NAMES, baseUrlHost } from './provider-env'
|
||||
import { isSharedWorkspace } from './shared-workspace'
|
||||
import { isSharedWorkspace, sharedWorkspaceMode } from './shared-workspace'
|
||||
import type { SandboxRow } from './store'
|
||||
import { secretLog } from './secret-log'
|
||||
import {
|
||||
@@ -196,12 +196,15 @@ function repoOwner(accountId: string, repo: string): string {
|
||||
* never its owner's personal ones, the same rule as personal accounts (D13). Fails closed: only a row
|
||||
* known to be private counts as unshared.
|
||||
*/
|
||||
export function ownersForSandbox(row: Pick<SandboxRow, 'account_id' | 'user_id' | 'repo_url' | 'visibility' | 'ownership_transferred_at'>) {
|
||||
export function ownersForSandbox(
|
||||
row: Pick<SandboxRow, 'account_id' | 'user_id' | 'repo_url' | 'visibility' | 'ownership_transferred_at'>,
|
||||
shared: boolean = isSharedWorkspace(row)
|
||||
) {
|
||||
const repo = normalizeRepo(row.repo_url)
|
||||
return {
|
||||
org: ORG_ACCOUNT.test(row.account_id) ? row.account_id : null,
|
||||
// The one definition of "shared" (visibility, or ever transferred to another owner).
|
||||
personal: isSharedWorkspace(row) ? null : personalOwner(row.user_id, row.account_id.startsWith('dev:')),
|
||||
personal: shared ? null : personalOwner(row.user_id, row.account_id.startsWith('dev:')),
|
||||
repo: repo ? repoOwner(row.account_id, repo) : null
|
||||
}
|
||||
}
|
||||
@@ -362,7 +365,7 @@ export async function resolveSandboxSecrets(
|
||||
keyring: Keyring,
|
||||
row: Pick<SandboxRow, 'id' | 'account_id' | 'user_id' | 'repo_url' | 'visibility' | 'ownership_transferred_at'>
|
||||
): Promise<ResolvedSecrets> {
|
||||
const owners = ownersForSandbox(row)
|
||||
const owners = ownersForSandbox(row, await sharedWorkspaceMode(db, row))
|
||||
const pairs: [SecretScope, string][] = []
|
||||
if (owners.personal) {
|
||||
pairs.push(['personal', owners.personal])
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// What counts as a shared workspace when deciding whose credentials a session may carry. One
|
||||
// definition, used by secrets, agent accounts, the egress proxy and the member git rules.
|
||||
import type { SandboxRow } from './store'
|
||||
import { teamSharingEnabled } from './team-sharing'
|
||||
|
||||
/**
|
||||
* D13: a workspace shared with teammates never uses a personal account. Fails closed: only a row
|
||||
@@ -12,3 +13,43 @@ import type { SandboxRow } from './store'
|
||||
export function isSharedWorkspace(row: Pick<SandboxRow, 'visibility' | 'ownership_transferred_at'>): boolean {
|
||||
return row.visibility !== 'private' || row.ownership_transferred_at != null
|
||||
}
|
||||
|
||||
/**
|
||||
* The rule above, precisely, for callers that can read the database (all of them today). TEAM-SHARING hold: a
|
||||
* workspace stored as `team` acts private while sharing is held, but keeps shared mode until no one but its
|
||||
* owner holds a device grant on it (the hold's sweep revokes them, grants.ts sweepHeldTeamGrants), and none was
|
||||
* revoked during the current session (what a teammate started there may still run): personal credentials never
|
||||
* reach a VM a teammate may still be paired to or running in. Fails closed on a failed read.
|
||||
*/
|
||||
export async function sharedWorkspaceMode(
|
||||
db: D1Database,
|
||||
row: Pick<SandboxRow, 'id' | 'user_id' | 'visibility' | 'ownership_transferred_at'>
|
||||
): Promise<boolean> {
|
||||
if (row.ownership_transferred_at != null) {
|
||||
return true
|
||||
}
|
||||
if (row.visibility !== 'private' && (teamSharingEnabled() || row.visibility !== 'team')) {
|
||||
return true
|
||||
}
|
||||
// Private, or `team` while held: shared only while a teammate's grant is live or was revoked this session
|
||||
// (Make private and the hold's sweep alike).
|
||||
// Review M1: a revoke closes a teammate's connections, not what they left running in this session's
|
||||
// terminals. A grant revoked during the current session keeps it shared until the next boot.
|
||||
// The session start is read here, not from the caller's row (which may be a partial or older copy). A revoke
|
||||
// queued while the workspace slept (no session) counts for nothing: the next boot applies it before orcad
|
||||
// accepts a sign-in, and that boot's processes are all new, so its session can be private. Its revoked_at
|
||||
// is when it was queued (revokeGrants; markRevoked keeps it), so it never reads as "revoked this session".
|
||||
// Unknown (null) falls back to the apply time there.
|
||||
const others = await db
|
||||
.prepare(
|
||||
`SELECT COUNT(*) AS n FROM workspace_grants g JOIN sandboxes s ON s.id = g.sandbox_id WHERE g.sandbox_id = ? AND g.user_id <> ?
|
||||
AND (g.status IN ('issuing', 'active')
|
||||
OR (g.status = 'revoking' AND s.session_started_at IS NOT NULL)
|
||||
OR (s.session_started_at IS NOT NULL AND g.revoked_at IS NOT NULL AND g.revoked_at >= s.session_started_at))`
|
||||
)
|
||||
.bind(row.id, row.user_id)
|
||||
.first<{ n: number }>()
|
||||
.catch(() => null)
|
||||
return !others || others.n > 0
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
// TEAM-SHARING hold: team workspace sharing ships in a later release. TEAM_SHARING=on turns it on; anything else
|
||||
// (the default) holds it. While held, a workspace stored as `team` acts private everywhere access is decided
|
||||
// (owner only, plus org admins' metadata as before): the column and its data stay, so turning it on restores
|
||||
// each workspace's own setting. Set from the Worker's env at the start of every request and scheduled run (the
|
||||
// same value for the whole isolate: no per-request state).
|
||||
import type { SandboxRow } from './store'
|
||||
|
||||
let enabled = false
|
||||
|
||||
export function configureTeamSharing(env: { TEAM_SHARING?: string }): void {
|
||||
enabled = env.TEAM_SHARING === 'on'
|
||||
}
|
||||
|
||||
export function teamSharingEnabled(): boolean {
|
||||
return enabled
|
||||
}
|
||||
|
||||
/** The visibility access rules use: the stored one with sharing on, else always private. */
|
||||
export function effectiveVisibility(row: Pick<SandboxRow, 'visibility'>): 'private' | 'team' {
|
||||
return enabled && row.visibility === 'team' ? 'team' : 'private'
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
// visible to the whole team). A private workspace's only viewer is its owner, so a teammate's old
|
||||
// follow of a workspace that turned private is never shown and never counts. Archived workspaces
|
||||
// may still be followed: they stay browsable.
|
||||
import { effectiveVisibility } from './team-sharing'
|
||||
import type { SandboxCaller } from './auth'
|
||||
import type { SandboxRow } from './store'
|
||||
|
||||
@@ -42,7 +43,7 @@ export function visibleFollowers(
|
||||
if (!seen) {
|
||||
return []
|
||||
}
|
||||
return row.visibility === 'team' ? [...followers] : followers.filter((id) => id === row.user_id)
|
||||
return effectiveVisibility(row) === 'team' ? [...followers] : followers.filter((id) => id === row.user_id)
|
||||
}
|
||||
|
||||
/** The caller must be able to see the row (the route checks canSee first). */
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
// Access rule: a workspace is visible to its owner, and to every member of the owning org when
|
||||
// visibility is `team`. Org owners/admins additionally see private rows' metadata (scope=all) so a
|
||||
// departed member's workspaces can be reassigned or archived — metadata only, never access.
|
||||
import { effectiveVisibility, teamSharingEnabled } from './team-sharing'
|
||||
import { githubActingViews, type GithubActingOptions, type GithubActingView } from './git-actor'
|
||||
import type { TeamMembershipCheck } from './team-membership'
|
||||
import { z } from 'zod'
|
||||
@@ -63,7 +64,7 @@ export function canSee(caller: SandboxCaller, row: SandboxRow): boolean {
|
||||
if (row.account_id !== caller.accountId || row.status === 'destroyed') {
|
||||
return false
|
||||
}
|
||||
return row.user_id === caller.userId || (row.visibility === 'team' && caller.orgId !== undefined)
|
||||
return row.user_id === caller.userId || (effectiveVisibility(row) === 'team' && caller.orgId !== undefined)
|
||||
}
|
||||
|
||||
/** Can the caller pair a device with it (grant) or keep it awake (lease)? */
|
||||
@@ -231,7 +232,8 @@ export async function workspaceViews(
|
||||
// The link to copy: org slug + number when both exist, else the sandbox id form.
|
||||
link: workspaceLink(row, slug),
|
||||
repo: repoView(row),
|
||||
visibility: row.visibility,
|
||||
// TEAM-SHARING hold: what access actually follows (stored `team` reads private while held).
|
||||
visibility: effectiveVisibility(row),
|
||||
section: row.section,
|
||||
archivedAt: row.archived_at,
|
||||
createdBy: row.created_by ?? row.user_id,
|
||||
@@ -315,6 +317,8 @@ export async function listWorkspaces(db: D1Database, caller: SandboxCaller, url:
|
||||
])
|
||||
return {
|
||||
workspaces: views.map((view, i) => ({ ...view, routineName: routineNames.get(rows[i]!.id) ?? null })),
|
||||
// TEAM-SHARING hold: whether workspaces can be shared with the team on this control plane (older ones omit it).
|
||||
teamSharing: teamSharingEnabled(),
|
||||
// Home: offer the Routine runs switch only when the team has routines, and say what it hides
|
||||
// (its count and hours still belong in the team's totals).
|
||||
routineRuns: {
|
||||
@@ -393,6 +397,10 @@ export async function patchWorkspace(
|
||||
if (patch.archived === true) {
|
||||
throw new WorkspaceError('invalid_request', 'archive_via_lifecycle')
|
||||
}
|
||||
if (patch.visibility === 'team' && !teamSharingEnabled()) {
|
||||
// TEAM-SHARING hold (team-sharing.ts): sharing with the team isn't available yet.
|
||||
throw new WorkspaceError('invalid_request', 'team_sharing_unavailable')
|
||||
}
|
||||
if (patch.visibility === 'team' && !row.account_id.includes('org:')) {
|
||||
// A personal account has no team to share with.
|
||||
throw new WorkspaceError('invalid_request', 'personal_account')
|
||||
|
||||
@@ -61,6 +61,8 @@ export async function createHarness(overrides: Partial<Env> = {}, extraDeps: Par
|
||||
VERCEL_PROJECT_ID: 'prj_orca',
|
||||
// Off unless a test turns it on (auto-environments.test.ts): it starts builds behind creates.
|
||||
AUTO_ENVIRONMENTS: 'off',
|
||||
// Team sharing is on for the suite (its behavior is what most team tests cover); test/team-sharing-hold.test.ts holds it.
|
||||
TEAM_SHARING: 'on',
|
||||
...overrides
|
||||
}
|
||||
// No live github.com from tests: repos count as public unless a test says otherwise.
|
||||
|
||||
@@ -0,0 +1,212 @@
|
||||
// TEAM-SHARING hold (team-sharing.ts): with TEAM_SHARING off, nothing can be shared with the team, and a
|
||||
// workspace already stored as `team` acts private everywhere (owner only, plus org admins' metadata).
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { generateGrantRecipientKey } from '../../../../src/main/cloud-workspaces/sealed-grant-node'
|
||||
import { sweepHeldTeamGrants } from '../src/grants'
|
||||
import { lifecycleDeps } from '../src/index'
|
||||
import { resolveSandboxSecrets } from '../src/secrets'
|
||||
import { sharedWorkspaceMode } from '../src/shared-workspace'
|
||||
import { getSandbox } from '../src/store'
|
||||
import { configureTeamSharing } from '../src/team-sharing'
|
||||
import { createHarness } from './harness'
|
||||
|
||||
async function held(teamSharing: 'off' | undefined = 'off') {
|
||||
const h = await createHarness({ PUBLIC_API_URL: 'https://api.test', ...(teamSharing ? { TEAM_SHARING: teamSharing } : { TEAM_SHARING: undefined }) })
|
||||
const token = (sub: string, role: 'member' | 'admin' = 'member') => h.token(sub, 'acme', 'sandbox', { org_role: role })
|
||||
const created = await h.call('POST', '/v1/sandboxes', {
|
||||
bearer: await token('alice'),
|
||||
body: { workspaceId: 'ws-1', machineSize: 'standard', title: 'Fix login', repo: { url: 'https://github.com/acme/app' }, visibility: 'team' }
|
||||
})
|
||||
expect(created.status).toBe(200)
|
||||
return { h, token, id: created.body.sandbox.id as string }
|
||||
}
|
||||
|
||||
describe('TEAM_SHARING held (the default)', () => {
|
||||
it('a create asking for team is private, a PATCH to team is refused, and the list says sharing is off', async () => {
|
||||
for (const setting of ['off', undefined] as const) {
|
||||
const t = await held(setting)
|
||||
expect(t.h.raw.prepare('SELECT visibility FROM sandboxes WHERE id = ?').get(t.id)).toEqual({ visibility: 'private' })
|
||||
const patch = await t.h.call('PATCH', `/v1/team/workspaces/${t.id}`, { bearer: await t.token('alice'), body: { visibility: 'team' } })
|
||||
expect(patch.status).toBe(400)
|
||||
expect(patch.body).toEqual({ error: 'invalid_request', reason: 'team_sharing_unavailable' })
|
||||
const list = await t.h.call('GET', '/v1/team/workspaces', { bearer: await t.token('alice') })
|
||||
expect(list.body.teamSharing).toBe(false)
|
||||
// Other edits still work, and making it private is always allowed.
|
||||
expect((await t.h.call('PATCH', `/v1/team/workspaces/${t.id}`, { bearer: await t.token('alice'), body: { visibility: 'private', section: 'Auth' } })).status).toBe(200)
|
||||
}
|
||||
})
|
||||
|
||||
it('a workspace already stored as team acts private: owner only, admins see metadata, teammates nothing', async () => {
|
||||
const t = await held()
|
||||
t.h.raw.prepare("UPDATE sandboxes SET visibility = 'team' WHERE id = ?").run(t.id)
|
||||
const bob = await t.token('bob')
|
||||
// Team registry: not listed, not addressable, no grant, no follow.
|
||||
expect((await t.h.call('GET', '/v1/team/workspaces?scope=team', { bearer: bob })).body.workspaces).toEqual([])
|
||||
expect((await t.h.call('GET', `/v1/team/workspaces/${t.id}`, { bearer: bob })).status).toBe(404)
|
||||
const grant = await t.h.call('POST', `/v1/team/workspaces/${t.id}/grants`, {
|
||||
bearer: bob,
|
||||
body: { recipientPublicKeyB64: generateGrantRecipientKey().publicKeyB64, deviceLabel: 'b', deviceKind: 'desktop' }
|
||||
})
|
||||
expect(grant.status).toBe(404)
|
||||
expect((await t.h.call('PUT', `/v1/team/workspaces/${t.id}/follow`, { bearer: bob })).status).toBe(404)
|
||||
// Public API and MCP's rule (api/access.ts): nothing for a teammate.
|
||||
expect((await t.h.call('GET', '/v1/workspaces', { bearer: bob })).body.workspaces).toEqual([])
|
||||
expect((await t.h.call('GET', `/v1/workspaces/${t.id}`, { bearer: bob })).status).toBe(404)
|
||||
expect((await t.h.call('POST', `/v1/workspaces/${t.id}/messages`, { bearer: bob, body: { text: 'hi' } })).status).toBe(404)
|
||||
// The owner sees it as private (what access follows); the stored value is kept for when sharing ships.
|
||||
const own = await t.h.call('GET', `/v1/team/workspaces/${t.id}`, { bearer: await t.token('alice') })
|
||||
expect(own.body.workspace).toMatchObject({ visibility: 'private', access: 'owner' })
|
||||
expect(own.body.teamSharing).toBe(false)
|
||||
expect(t.h.raw.prepare('SELECT visibility FROM sandboxes WHERE id = ?').get(t.id)).toEqual({ visibility: 'team' })
|
||||
// An admin keeps today's management view (scope=all metadata), not the teammate view.
|
||||
const admin = await t.token('carol', 'admin')
|
||||
const all = await t.h.call('GET', '/v1/team/workspaces?scope=all', { bearer: admin })
|
||||
expect(all.body.workspaces.map((w: { id: string; visibility: string; access: string }) => [w.id, w.visibility, w.access])).toEqual([[t.id, 'private', 'none']])
|
||||
expect((await t.h.call('GET', '/v1/team/workspaces?scope=team', { bearer: admin })).body.workspaces).toEqual([])
|
||||
})
|
||||
|
||||
it('TEAM_SHARING=on restores each workspace’s own setting', async () => {
|
||||
const h = await createHarness()
|
||||
const alice = await h.token('alice', 'acme', 'sandbox', { org_role: 'member' })
|
||||
const created = await h.call('POST', '/v1/sandboxes', {
|
||||
bearer: alice,
|
||||
body: { workspaceId: 'ws-1', machineSize: 'standard', repo: { url: 'https://github.com/acme/app' }, visibility: 'team' }
|
||||
})
|
||||
const bob = await h.token('bob', 'acme', 'sandbox', { org_role: 'member' })
|
||||
const list = await h.call('GET', '/v1/team/workspaces?scope=team', { bearer: bob })
|
||||
expect(list.body.teamSharing).toBe(true)
|
||||
expect(list.body.workspaces.map((w: { id: string; visibility: string }) => [w.id, w.visibility])).toEqual([[created.body.sandbox.id, 'team']])
|
||||
})
|
||||
|
||||
it('the sweep revokes teammates’ grants on a held team workspace; credentials stay shared until it has', async () => {
|
||||
// Shared while sharing was on: Bob holds a device grant.
|
||||
const h = await createHarness({ SECRETS_KEK: Buffer.alloc(32, 7).toString('base64') })
|
||||
const alice = await h.token('alice', 'acme', 'sandbox', { org_role: 'member' })
|
||||
const created = await h.call('POST', '/v1/sandboxes', {
|
||||
bearer: alice,
|
||||
body: { workspaceId: 'ws-1', machineSize: 'standard', repo: { url: 'https://github.com/acme/app' }, visibility: 'team' }
|
||||
})
|
||||
const id = created.body.sandbox.id as string
|
||||
const grant = await h.call('POST', `/v1/team/workspaces/${id}/grants`, {
|
||||
bearer: await h.token('bob', 'acme', 'sandbox', { org_role: 'member' }),
|
||||
body: { recipientPublicKeyB64: generateGrantRecipientKey().publicKeyB64, deviceLabel: 'b', deviceKind: 'desktop' }
|
||||
})
|
||||
expect(grant.status).toBe(200)
|
||||
// Now held.
|
||||
h.env.TEAM_SHARING = undefined
|
||||
configureTeamSharing(h.env)
|
||||
const db = h.env.SANDBOX_DB
|
||||
const row = (await getSandbox(db, id))!
|
||||
// Bob's grant is still active: shared mode (no personal credentials), though it acts private.
|
||||
expect(await sharedWorkspaceMode(db, row)).toBe(true)
|
||||
expect((await h.call('PUT', '/v1/secrets/personal/MY_TOKEN', { bearer: alice, body: { value: 'personal-value' } })).status).toBe(200)
|
||||
const life = (await lifecycleDeps(h.env, h.deps))!
|
||||
const keyring = await life.secrets!.keyring
|
||||
expect((await resolveSandboxSecrets(db, keyring, row)).env.MY_TOKEN).toBeUndefined()
|
||||
expect(await sweepHeldTeamGrants(life)).toEqual({ workspaces: 1, revoked: 1, queued: 0 })
|
||||
expect(h.raw.prepare('SELECT status, revoke_reason FROM workspace_grants WHERE user_id = ?').get('bob')).toEqual({ status: 'revoked', revoke_reason: 'team_sharing_held' })
|
||||
// Review M1: revoked during this session, so what Bob started may still run: shared until the next boot.
|
||||
expect(await sharedWorkspaceMode(db, row)).toBe(true)
|
||||
expect((await resolveSandboxSecrets(db, keyring, row)).env.MY_TOKEN).toBeUndefined()
|
||||
// A new session (restart): the owner's alone, so it acts private for credentials too.
|
||||
h.advance(1_000)
|
||||
expect((await h.call('POST', `/v1/sandboxes/${id}/restart`, { bearer: alice })).status).toBe(200)
|
||||
expect(await sharedWorkspaceMode(db, row)).toBe(false)
|
||||
expect((await resolveSandboxSecrets(db, keyring, row)).env.MY_TOKEN).toBe('personal-value')
|
||||
// Nothing left to sweep; and with sharing on again, nothing is swept at all.
|
||||
expect(await sweepHeldTeamGrants(life)).toEqual({ workspaces: 0, revoked: 0, queued: 0 })
|
||||
configureTeamSharing({ TEAM_SHARING: 'on' })
|
||||
expect(await sharedWorkspaceMode(db, row)).toBe(true)
|
||||
})
|
||||
|
||||
it('review L1: the sweep leaves private workspaces alone', async () => {
|
||||
const t = await held()
|
||||
t.h.raw
|
||||
.prepare(`INSERT INTO workspace_grants (id, sandbox_id, account_id, user_id, device_kind, device_label, status, created_at) VALUES ('grt_p', ?, 'org:acme', 'bob', 'desktop', 'b', 'active', 1)`)
|
||||
.run(t.id)
|
||||
expect(await sweepHeldTeamGrants((await lifecycleDeps(t.h.env, t.h.deps))!)).toEqual({ workspaces: 0, revoked: 0, queued: 0 })
|
||||
})
|
||||
|
||||
it('review L2: concurrent sweeps revoke each grant once and agree on the end state', async () => {
|
||||
const h = await createHarness()
|
||||
const alice = await h.token('alice', 'acme', 'sandbox', { org_role: 'member' })
|
||||
const created = await h.call('POST', '/v1/sandboxes', {
|
||||
bearer: alice,
|
||||
body: { workspaceId: 'ws-1', machineSize: 'standard', repo: { url: 'https://github.com/acme/app' }, visibility: 'team' }
|
||||
})
|
||||
const id = created.body.sandbox.id as string
|
||||
for (const who of ['bob', 'dan']) {
|
||||
const g = await h.call('POST', `/v1/team/workspaces/${id}/grants`, {
|
||||
bearer: await h.token(who, 'acme', 'sandbox', { org_role: 'member' }),
|
||||
body: { recipientPublicKeyB64: generateGrantRecipientKey().publicKeyB64, deviceLabel: who, deviceKind: 'desktop' }
|
||||
})
|
||||
expect(g.status).toBe(200)
|
||||
}
|
||||
h.env.TEAM_SHARING = undefined
|
||||
configureTeamSharing(h.env)
|
||||
const life = (await lifecycleDeps(h.env, h.deps))!
|
||||
const [a, b] = await Promise.all([sweepHeldTeamGrants(life), sweepHeldTeamGrants(life)])
|
||||
expect(a.revoked + a.queued + b.revoked + b.queued).toBeGreaterThanOrEqual(2)
|
||||
expect(h.raw.prepare(`SELECT user_id, status, revoke_reason FROM workspace_grants WHERE user_id <> 'alice' ORDER BY user_id`).all()).toEqual([
|
||||
{ user_id: 'bob', status: 'revoked', revoke_reason: 'team_sharing_held' },
|
||||
{ user_id: 'dan', status: 'revoked', revoke_reason: 'team_sharing_held' }
|
||||
])
|
||||
expect(await sweepHeldTeamGrants(life)).toEqual({ workspaces: 0, revoked: 0, queued: 0 })
|
||||
})
|
||||
})
|
||||
|
||||
describe('Make private keeps shared credential mode until the next boot (same rule as the sweep)', () => {
|
||||
it('a teammate revoked by Make private leaves this session shared; a fresh boot is private', async () => {
|
||||
const h = await createHarness({ SECRETS_KEK: Buffer.alloc(32, 7).toString('base64') })
|
||||
const alice = await h.token('alice', 'acme', 'sandbox', { org_role: 'member' })
|
||||
const created = await h.call('POST', '/v1/sandboxes', {
|
||||
bearer: alice,
|
||||
body: { workspaceId: 'ws-1', machineSize: 'standard', repo: { url: 'https://github.com/acme/app' }, visibility: 'team' }
|
||||
})
|
||||
const id = created.body.sandbox.id as string
|
||||
const g = await h.call('POST', `/v1/team/workspaces/${id}/grants`, {
|
||||
bearer: await h.token('bob', 'acme', 'sandbox', { org_role: 'member' }),
|
||||
body: { recipientPublicKeyB64: generateGrantRecipientKey().publicKeyB64, deviceLabel: 'b', deviceKind: 'desktop' }
|
||||
})
|
||||
expect(g.status).toBe(200)
|
||||
expect((await h.call('PATCH', `/v1/team/workspaces/${id}`, { bearer: alice, body: { visibility: 'private' } })).status).toBe(200)
|
||||
const db = h.env.SANDBOX_DB
|
||||
expect(h.raw.prepare('SELECT status FROM workspace_grants WHERE user_id = ?').get('bob')).toEqual({ status: 'revoked' })
|
||||
const row = (await getSandbox(db, id))!
|
||||
expect(row.visibility).toBe('private')
|
||||
expect(await sharedWorkspaceMode(db, row)).toBe(true)
|
||||
h.advance(1_000)
|
||||
expect((await h.call('POST', `/v1/sandboxes/${id}/restart`, { bearer: alice })).status).toBe(200)
|
||||
expect(await sharedWorkspaceMode(db, (await getSandbox(db, id))!)).toBe(false)
|
||||
})
|
||||
|
||||
it('a revoke queued while the workspace slept leaves its next session private (no lost sign-in after the deploy sweep)', async () => {
|
||||
const h = await createHarness({ SECRETS_KEK: Buffer.alloc(32, 7).toString('base64') })
|
||||
const alice = await h.token('alice', 'acme', 'sandbox', { org_role: 'member' })
|
||||
const created = await h.call('POST', '/v1/sandboxes', {
|
||||
bearer: alice,
|
||||
body: { workspaceId: 'ws-1', machineSize: 'standard', repo: { url: 'https://github.com/acme/app' }, visibility: 'team' }
|
||||
})
|
||||
const id = created.body.sandbox.id as string
|
||||
const g = await h.call('POST', `/v1/team/workspaces/${id}/grants`, {
|
||||
bearer: await h.token('bob', 'acme', 'sandbox', { org_role: 'member' }),
|
||||
body: { recipientPublicKeyB64: generateGrantRecipientKey().publicKeyB64, deviceLabel: 'b', deviceKind: 'desktop' }
|
||||
})
|
||||
expect(g.status).toBe(200)
|
||||
expect((await h.call('POST', `/v1/sandboxes/${id}/suspend`, { bearer: alice })).status).toBe(200)
|
||||
h.env.TEAM_SHARING = undefined
|
||||
configureTeamSharing(h.env)
|
||||
const life = (await lifecycleDeps(h.env, h.deps))!
|
||||
// Asleep: queued, not applied.
|
||||
expect(await sweepHeldTeamGrants(life)).toEqual({ workspaces: 1, revoked: 0, queued: 1 })
|
||||
const db = h.env.SANDBOX_DB
|
||||
const queuedAt = (h.raw.prepare('SELECT revoked_at FROM workspace_grants WHERE user_id = ?').get('bob') as { revoked_at: number }).revoked_at
|
||||
expect(await sharedWorkspaceMode(db, (await getSandbox(db, id))!)).toBe(false)
|
||||
h.advance(60_000)
|
||||
expect((await h.call('POST', `/v1/sandboxes/${id}/resume`, { bearer: alice })).status).toBe(200)
|
||||
// Applied at boot, still stamped with the queue time; the new session is private.
|
||||
expect(h.raw.prepare('SELECT status, revoked_at FROM workspace_grants WHERE user_id = ?').get('bob')).toEqual({ status: 'revoked', revoked_at: queuedAt })
|
||||
expect(await sharedWorkspaceMode(db, (await getSandbox(db, id))!)).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// PARITY-FOLLOW: the people on the cloud workspace in front, beside its W-123 chip: its creator,
|
||||
// its followers and who is here now, then Follow. Nothing for a local workspace, a personal
|
||||
// account, or a workspace only you are on and nobody else could follow.
|
||||
import { useCloudTeamSharingEnabled } from '@/lib/orca-cloud/cloud-team-sharing-flag'
|
||||
import React, { useState } from 'react'
|
||||
import { toast } from 'sonner'
|
||||
import { useAppStore } from '@/store'
|
||||
@@ -47,7 +48,9 @@ export function CloudWorkspacePeople({
|
||||
const { directory } = useMemberDirectory(orgId ?? undefined, workspace ? [workspace] : [])
|
||||
// The live list row carries githubActing / you already.
|
||||
const actingLine = gitActingLine(workspace, t)
|
||||
if (!workspace) {
|
||||
// TEAM-SHARING-HOLD: followers and who's here only exist on a shared workspace.
|
||||
const teamSharing = useCloudTeamSharingEnabled()
|
||||
if (!workspace || !teamSharing) {
|
||||
return null
|
||||
}
|
||||
const following = followOffer(workspace, selfId)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// "Open cloud workspace…": cloud workspaces this computer's sidebar doesn't show, as the same rows
|
||||
// (and ⋯ menu) the team list had. Open goes through openCloudWorkspace and closes the picker.
|
||||
import { cloudTeamSharingEnabled } from '@/lib/orca-cloud/cloud-team-sharing-flag'
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import { RefreshCw, Search } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
@@ -55,10 +56,16 @@ function pickerCopy(
|
||||
case 'open':
|
||||
return {
|
||||
title: t('components.cloudWorkspaces.picker.title', 'Open cloud workspace'),
|
||||
description: t(
|
||||
'components.cloudWorkspaces.picker.description',
|
||||
'Cloud workspaces that aren’t in your sidebar: shared by teammates, or started on another computer.'
|
||||
)
|
||||
// TEAM-SHARING-HOLD: nothing is shared by teammates while sharing is held.
|
||||
description: cloudTeamSharingEnabled()
|
||||
? t(
|
||||
'components.cloudWorkspaces.picker.description',
|
||||
'Cloud workspaces that aren’t in your sidebar: shared by teammates, or started on another computer.'
|
||||
)
|
||||
: t(
|
||||
'components.cloudWorkspaces.picker.descriptionOwn',
|
||||
'Your cloud workspaces that aren’t in your sidebar, such as ones started on another computer.'
|
||||
)
|
||||
}
|
||||
case 'teammate':
|
||||
return {
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { CloudStatusGlyph } from '@/components/orca-cloud/CloudStatusGlyph'
|
||||
import { cloudShareLinksEnabled } from '@/lib/orca-cloud/cloud-share-links-flag'
|
||||
import {
|
||||
cloudTeamSharingEnabled,
|
||||
useCloudTeamSharingEnabled
|
||||
} from '@/lib/orca-cloud/cloud-team-sharing-flag'
|
||||
import React, { useId, useState } from 'react'
|
||||
import { GitBranch, Loader2 } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
@@ -113,6 +116,7 @@ export function CloudWorkspaceRow({
|
||||
hours,
|
||||
defaultValue_one: '{{hours}} sandbox hour'
|
||||
})
|
||||
const teamSharing = useCloudTeamSharingEnabled()
|
||||
const lastActive = formatRelative(w.lastActivityAt, now, t, intlLocale)
|
||||
const presence = presenceSummary(
|
||||
presentMembers(w.presence, selfId),
|
||||
@@ -151,7 +155,7 @@ export function CloudWorkspaceRow({
|
||||
return
|
||||
}
|
||||
if (
|
||||
cloudShareLinksEnabled() &&
|
||||
cloudTeamSharingEnabled() &&
|
||||
keybindingMatchesAction(
|
||||
'cloudWorkspace.copyLink',
|
||||
event.nativeEvent,
|
||||
@@ -272,12 +276,15 @@ export function CloudWorkspaceRow({
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<PresenceStack
|
||||
presence={w.presence}
|
||||
directory={directory}
|
||||
selfId={selfId}
|
||||
onGoToChat={canOpen ? (member) => actions.goToChat(w, member) : undefined}
|
||||
/>
|
||||
{/* TEAM-SHARING-HOLD: who's here only exists on a shared workspace. */}
|
||||
{teamSharing ? (
|
||||
<PresenceStack
|
||||
presence={w.presence}
|
||||
directory={directory}
|
||||
selfId={selfId}
|
||||
onGoToChat={canOpen ? (member) => actions.goToChat(w, member) : undefined}
|
||||
/>
|
||||
) : null}
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<span className="w-28 text-right text-xs tabular-nums text-muted-foreground">
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// The small marks after a cloud workspace's title in Open cloud workspace…: private, started by a
|
||||
// routine, and its W-number (shown on hover or focus; its space is held so nothing shifts).
|
||||
import { useCloudTeamSharingEnabled } from '@/lib/orca-cloud/cloud-team-sharing-flag'
|
||||
import React from 'react'
|
||||
import { CalendarClock, Lock } from 'lucide-react'
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
|
||||
@@ -23,9 +24,11 @@ export function CloudWorkspaceRowBadges({
|
||||
}): React.JSX.Element {
|
||||
const t = useTranslate()
|
||||
const revealOpen = revealNumber
|
||||
// TEAM-SHARING-HOLD: every workspace is private while sharing is held; no badge says so.
|
||||
const teamSharing = useCloudTeamSharingEnabled()
|
||||
return (
|
||||
<>
|
||||
{w.visibility === 'private' && (
|
||||
{teamSharing && w.visibility === 'private' && (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Lock
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useRef } from 'react'
|
||||
import { useCloudShareLinksEnabled } from '@/lib/orca-cloud/cloud-share-links-flag'
|
||||
import { useCloudTeamSharingEnabled } from '@/lib/orca-cloud/cloud-team-sharing-flag'
|
||||
import { ArchiveSnapshotTooltip } from '@/components/orca-cloud/ArchiveSnapshotTooltip'
|
||||
import {
|
||||
Archive,
|
||||
@@ -112,7 +112,7 @@ export function CloudWorkspaceRowMenu({
|
||||
const t = useTranslate()
|
||||
const keybindings = useAppStore((state) => state.keybindings)
|
||||
const copyShortcut = formatOptionalPrimaryShortcutLabel('cloudWorkspace.copyLink', keybindings)
|
||||
const shareLinks = useCloudShareLinksEnabled()
|
||||
const teamSharing = useCloudTeamSharingEnabled()
|
||||
// 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
|
||||
@@ -187,8 +187,8 @@ export function CloudWorkspaceRowMenu({
|
||||
<DropdownMenuShortcut>↵</DropdownMenuShortcut>
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
{/* SHARE-LINKS-HOLD: the Copy link items only while share links are on. */}
|
||||
{shareLinks ? (
|
||||
{/* TEAM-SHARING-HOLD: share links only while team sharing is on. */}
|
||||
{teamSharing ? (
|
||||
<DropdownMenuItem onSelect={() => actions.copyLink(w)}>
|
||||
<Link2 />
|
||||
{w.number
|
||||
@@ -199,7 +199,7 @@ export function CloudWorkspaceRowMenu({
|
||||
{copyShortcut ? <DropdownMenuShortcut>{copyShortcut}</DropdownMenuShortcut> : null}
|
||||
</DropdownMenuItem>
|
||||
) : null}
|
||||
{shareLinks && focused ? (
|
||||
{teamSharing && focused ? (
|
||||
<DropdownMenuItem onSelect={() => actions.copyWorkspaceLink(w)}>
|
||||
{focused === 'terminal' ? <SquareTerminal /> : <MessageSquare />}
|
||||
{focused === 'terminal'
|
||||
@@ -248,7 +248,8 @@ export function CloudWorkspaceRowMenu({
|
||||
{canManage && (
|
||||
<>
|
||||
<DropdownMenuSeparator />
|
||||
{w.visibility === 'private' ? (
|
||||
{/* TEAM-SHARING-HOLD: no Share with team / Make private while sharing is held. */}
|
||||
{!teamSharing ? null : w.visibility === 'private' ? (
|
||||
<DropdownMenuItem onSelect={() => actions.patch(w, { visibility: 'team' })}>
|
||||
<Users />
|
||||
{t('auto.components.cloudWorkspaces.shareWithTeam', 'Share with team')}
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
const teamSharing = vi.hoisted(() => ({ on: true }))
|
||||
vi.mock('@/lib/orca-cloud/cloud-team-sharing-flag', () => ({
|
||||
CLOUD_SHARE_LINK_ACTION_ID: 'cloudWorkspace.copyLink',
|
||||
cloudTeamSharingEnabled: () => teamSharing.on,
|
||||
useCloudTeamSharingEnabled: () => teamSharing.on
|
||||
}))
|
||||
import {
|
||||
cloudWorkspaceActionGroups,
|
||||
type CloudWorkspaceActionInput
|
||||
@@ -51,4 +57,20 @@ describe('one action list for every surface (JA-14)', () => {
|
||||
it('a teammate who cannot manage it only opens and copies links', () => {
|
||||
expect(flat({ canManage: false })).toEqual(['open:open,copyLink,copyWorkspaceLink'])
|
||||
})
|
||||
|
||||
it('TEAM-SHARING-HOLD: no Share with team or Make private while sharing is held', () => {
|
||||
teamSharing.on = false
|
||||
try {
|
||||
for (const visibility of ['private', 'team'] as const) {
|
||||
const actions = cloudWorkspaceActionGroups({ ...base, visibility }).flatMap(
|
||||
(g) => g.actions
|
||||
)
|
||||
expect(actions).not.toContain('share')
|
||||
expect(actions).not.toContain('makePrivate')
|
||||
expect(actions).toContain('archive')
|
||||
}
|
||||
} finally {
|
||||
teamSharing.on = true
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// workspace…" list's ⋯ menu and the sidebar's context menu both render these groups, in this order:
|
||||
// Open, Share, Lifecycle, Danger. Each surface leaves out only what it already shows elsewhere (the
|
||||
// sidebar row *is* the open workspace; the list has no local-only items) and never invents its own.
|
||||
import { cloudTeamSharingEnabled } from '@/lib/orca-cloud/cloud-team-sharing-flag'
|
||||
import type { CloudWorkspace } from '../../../../shared/cloud-workspaces/cloud-workspaces-wire'
|
||||
|
||||
export type CloudWorkspaceAction =
|
||||
@@ -37,6 +38,8 @@ export type CloudWorkspaceActionInput = Pick<
|
||||
canRestart: boolean
|
||||
/** Teammates to hand it to (the list only). */
|
||||
hasMembers?: boolean
|
||||
/** TEAM-SHARING-HOLD: Share with team / Make private offered (default: the account's capability). */
|
||||
teamSharing?: boolean
|
||||
}
|
||||
|
||||
export function cloudWorkspaceActionGroups(
|
||||
@@ -54,8 +57,10 @@ export function cloudWorkspaceActionGroups(
|
||||
open.push('copyWorkspaceLink')
|
||||
|
||||
const share: CloudWorkspaceAction[] = []
|
||||
if (input.canManage) {
|
||||
if (input.canManage && (input.teamSharing ?? cloudTeamSharingEnabled())) {
|
||||
share.push(input.visibility === 'private' ? 'share' : 'makePrivate')
|
||||
}
|
||||
if (input.canManage) {
|
||||
if (list && input.hasMembers) {
|
||||
share.push('reassignOwner')
|
||||
}
|
||||
|
||||
@@ -1,6 +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 { cloudTeamSharingEnabled } from '@/lib/orca-cloud/cloud-team-sharing-flag'
|
||||
import { toast } from 'sonner'
|
||||
import { useAppStore } from '@/store'
|
||||
import { getShortcutPlatform } from '@/lib/keyboard/shortcut-platform'
|
||||
@@ -233,7 +233,7 @@ export function installCloudWorkspaceLinks(): () => void {
|
||||
const target = event.target instanceof HTMLElement ? event.target : null
|
||||
if (
|
||||
!event.defaultPrevented &&
|
||||
cloudShareLinksEnabled() &&
|
||||
cloudTeamSharingEnabled() &&
|
||||
!shortcutOwnedElsewhere(target) &&
|
||||
keybindingMatchesAction(
|
||||
'cloudWorkspace.copyLink',
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
const teamSharing = vi.hoisted(() => ({ on: true }))
|
||||
vi.mock('@/lib/orca-cloud/cloud-team-sharing-flag', () => ({
|
||||
CLOUD_SHARE_LINK_ACTION_ID: 'cloudWorkspace.copyLink',
|
||||
cloudTeamSharingEnabled: () => teamSharing.on,
|
||||
useCloudTeamSharingEnabled: () => teamSharing.on
|
||||
}))
|
||||
import {
|
||||
initialPickerControls,
|
||||
pickerListQuery,
|
||||
@@ -110,4 +116,18 @@ describe('what the picker lists', () => {
|
||||
expect(rows(`W-${mine.number}`)).toEqual(['Mine here'])
|
||||
expect(rows('nothing like this')).toEqual([])
|
||||
})
|
||||
|
||||
it('TEAM-SHARING-HOLD: no Team scope on a team while sharing is held; Open lists your own', () => {
|
||||
teamSharing.on = false
|
||||
try {
|
||||
expect(initialPickerControls(true).scope).toBe('mine')
|
||||
expect(pickerShowsScope({ kind: 'open' }, true)).toBe(false)
|
||||
expect(
|
||||
pickerListQuery({ kind: 'open' }, { scope: 'team', archived: false, search: '' }, true)
|
||||
.scope
|
||||
).toBe('mine')
|
||||
} finally {
|
||||
teamSharing.on = true
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// What "Open cloud workspace…" reads and lists for each focus. Pure, so the rules are tested apart
|
||||
// from the dialog.
|
||||
import { cloudTeamSharingEnabled } from '@/lib/orca-cloud/cloud-team-sharing-flag'
|
||||
import type {
|
||||
CloudWorkspace,
|
||||
CloudWorkspaceListQuery
|
||||
@@ -14,14 +15,22 @@ export type CloudWorkspacePickerControls = {
|
||||
search: string
|
||||
}
|
||||
|
||||
/**
|
||||
* TEAM-SHARING-HOLD: with sharing held there is nothing of a teammate's to open, so "Open cloud
|
||||
* workspace…" has no Team scope and lists your own.
|
||||
*/
|
||||
function teamScope(hasOrg: boolean): boolean {
|
||||
return hasOrg && cloudTeamSharingEnabled()
|
||||
}
|
||||
|
||||
export function initialPickerControls(hasOrg: boolean): CloudWorkspacePickerControls {
|
||||
// On a team, what you can't open from the sidebar is mostly what teammates shared.
|
||||
return { scope: hasOrg ? 'team' : 'mine', archived: false, search: '' }
|
||||
return { scope: teamScope(hasOrg) ? 'team' : 'mine', archived: false, search: '' }
|
||||
}
|
||||
|
||||
/** Which controls the picker offers: a focused list (limit, teammate, team delete) is fixed. */
|
||||
export function pickerShowsScope(focus: CloudWorkspacePickerFocus, hasOrg: boolean): boolean {
|
||||
return focus.kind === 'open' && hasOrg
|
||||
return focus.kind === 'open' && teamScope(hasOrg)
|
||||
}
|
||||
|
||||
export function pickerShowsArchived(focus: CloudWorkspacePickerFocus): boolean {
|
||||
@@ -36,7 +45,7 @@ export function pickerListQuery(
|
||||
switch (focus.kind) {
|
||||
case 'open':
|
||||
return {
|
||||
scope: hasOrg ? controls.scope : 'mine',
|
||||
scope: teamScope(hasOrg) ? controls.scope : 'mine',
|
||||
archived: controls.archived ? 'only' : 'exclude'
|
||||
}
|
||||
case 'teammate':
|
||||
|
||||
@@ -5,8 +5,8 @@ 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
|
||||
vi.mock('@/lib/orca-cloud/cloud-team-sharing-flag', () => ({
|
||||
cloudTeamSharingEnabled: () => shareLinks.on
|
||||
}))
|
||||
|
||||
import { copyCloudWorkspaceLink } from './cloud-workspace-share-link'
|
||||
|
||||
@@ -1,5 +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 { cloudTeamSharingEnabled } from '@/lib/orca-cloud/cloud-team-sharing-flag'
|
||||
import { toast } from 'sonner'
|
||||
import { translate } from '@/i18n/i18n'
|
||||
import {
|
||||
@@ -49,7 +49,7 @@ export async function copyCloudWorkspaceLink(
|
||||
options: { quiet?: boolean } = {}
|
||||
): Promise<boolean> {
|
||||
// SHARE-LINKS-HOLD: nothing is copied while share links are held.
|
||||
if (!cloudShareLinksEnabled()) {
|
||||
if (!cloudTeamSharingEnabled()) {
|
||||
return false
|
||||
}
|
||||
const link = await shareLinkFor(id, chatId)
|
||||
|
||||
@@ -3,8 +3,8 @@ 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
|
||||
vi.mock('@/lib/orca-cloud/cloud-team-sharing-flag', () => ({
|
||||
cloudTeamSharingEnabled: () => shareLinks.on
|
||||
}))
|
||||
|
||||
import { copyCloudWorkspaceLink, shareLinkFor } from './open-cloud-workspace'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useContext } from 'react'
|
||||
import { useCloudShareLinksEnabled } from '@/lib/orca-cloud/cloud-share-links-flag'
|
||||
import { useCloudTeamSharingEnabled } from '@/lib/orca-cloud/cloud-team-sharing-flag'
|
||||
import { ArchiveSnapshotTooltip } from './ArchiveSnapshotTooltip'
|
||||
import { toast } from 'sonner'
|
||||
import {
|
||||
@@ -204,7 +204,7 @@ export function CloudCopyWorkspaceLinkItem({
|
||||
const t = useTranslate()
|
||||
const { workspace } = useCloudWorkspaceRecord(worktreeId, hostId ?? null)
|
||||
// SHARE-LINKS-HOLD: no way to produce a share link while it's held.
|
||||
const shareLinks = useCloudShareLinksEnabled()
|
||||
const shareLinks = useCloudTeamSharingEnabled()
|
||||
if (!workspace || !shareLinks) {
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -29,6 +29,12 @@ const mocks = vi.hoisted(() => {
|
||||
return { state, open: vi.fn(), sleep: vi.fn(), archive: vi.fn() }
|
||||
})
|
||||
|
||||
const teamSharing = vi.hoisted(() => ({ on: true }))
|
||||
vi.mock('@/lib/orca-cloud/cloud-team-sharing-flag', () => ({
|
||||
CLOUD_SHARE_LINK_ACTION_ID: 'cloudWorkspace.copyLink',
|
||||
cloudTeamSharingEnabled: () => teamSharing.on,
|
||||
useCloudTeamSharingEnabled: () => teamSharing.on
|
||||
}))
|
||||
vi.mock('@/store', () => ({
|
||||
useAppStore: Object.assign(
|
||||
(selector: (s: typeof mocks.state) => unknown) => selector(mocks.state),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Settings › Workspaces: every cloud workspace on the team, for owners and admins to manage
|
||||
// (Neil, HOME-1: the listing comes back only here). Open, Sleep and Archive use the same flows as
|
||||
// the sidebar and "Open cloud workspace…"; an action the control plane would refuse is not shown.
|
||||
import { useCloudTeamSharingEnabled } from '@/lib/orca-cloud/cloud-team-sharing-flag'
|
||||
import React, { useEffect, useMemo, useState } from 'react'
|
||||
import { toast } from 'sonner'
|
||||
import { Lock, RefreshCw, Users } from 'lucide-react'
|
||||
@@ -49,6 +50,7 @@ const TEAM_QUERY = { scope: 'team', archived: 'include' } as const
|
||||
|
||||
export function TeamWorkspacesSettings({ orgId }: { orgId: string | null }): React.JSX.Element {
|
||||
const t = useTranslate()
|
||||
const teamSharing = useCloudTeamSharingEnabled()
|
||||
const intlLocale = useIntlLocale()
|
||||
const cloud = useAppStore((s) => s.orcaProfileAuthStatus?.cloud)
|
||||
const signIn = useAppStore((s) => s.connectCurrentOrcaProfile)
|
||||
@@ -147,7 +149,7 @@ export function TeamWorkspacesSettings({ orgId }: { orgId: string | null }): Rea
|
||||
<col className="w-36" />
|
||||
<col className="w-32" />
|
||||
<col className="w-20" />
|
||||
<col className="w-20" />
|
||||
{teamSharing ? <col className="w-20" /> : null}
|
||||
<col className="w-10" />
|
||||
</colgroup>
|
||||
<thead className="border-b border-border/60 text-left text-muted-foreground">
|
||||
@@ -167,9 +169,12 @@ export function TeamWorkspacesSettings({ orgId }: { orgId: string | null }): Rea
|
||||
<th className="px-2 py-2 font-medium">
|
||||
{t('settings.teamWorkspaces.colLastActive', 'Last active')}
|
||||
</th>
|
||||
<th className="px-2 py-2 font-medium">
|
||||
{t('settings.teamWorkspaces.colAccess', 'Access')}
|
||||
</th>
|
||||
{/* TEAM-SHARING-HOLD: no Access column while sharing is held (all private). */}
|
||||
{teamSharing ? (
|
||||
<th className="px-2 py-2 font-medium">
|
||||
{t('settings.teamWorkspaces.colAccess', 'Access')}
|
||||
</th>
|
||||
) : null}
|
||||
<th className="px-2 py-2">
|
||||
<span className="sr-only">
|
||||
{t('settings.teamWorkspaces.colActions', 'Actions')}
|
||||
@@ -219,18 +224,20 @@ export function TeamWorkspacesSettings({ orgId }: { orgId: string | null }): Rea
|
||||
<td className="px-2 py-2 text-muted-foreground tabular-nums">
|
||||
{formatRelative(w.lastActivityAt, now, t, intlLocale)}
|
||||
</td>
|
||||
<td className="px-2 py-2 text-muted-foreground">
|
||||
<span className="flex items-center gap-1">
|
||||
{w.visibility === 'private' ? (
|
||||
<Lock className="size-3 shrink-0" aria-hidden />
|
||||
) : (
|
||||
<Users className="size-3 shrink-0" aria-hidden />
|
||||
)}
|
||||
{w.visibility === 'private'
|
||||
? t('auto.components.cloudWorkspaces.private', 'Private')
|
||||
: t('settings.teamWorkspaces.shared', 'Shared')}
|
||||
</span>
|
||||
</td>
|
||||
{teamSharing ? (
|
||||
<td className="px-2 py-2 text-muted-foreground">
|
||||
<span className="flex items-center gap-1">
|
||||
{w.visibility === 'private' ? (
|
||||
<Lock className="size-3 shrink-0" aria-hidden />
|
||||
) : (
|
||||
<Users className="size-3 shrink-0" aria-hidden />
|
||||
)}
|
||||
{w.visibility === 'private'
|
||||
? t('auto.components.cloudWorkspaces.private', 'Private')
|
||||
: t('settings.teamWorkspaces.shared', 'Shared')}
|
||||
</span>
|
||||
</td>
|
||||
) : null}
|
||||
<td className="px-2 py-2 text-right">
|
||||
<RowActionsMenu
|
||||
workspace={w}
|
||||
|
||||
@@ -4,8 +4,8 @@ import {
|
||||
} from '../../../../../shared/keybindings/definitions'
|
||||
import {
|
||||
CLOUD_SHARE_LINK_ACTION_ID,
|
||||
cloudShareLinksEnabled
|
||||
} from '@/lib/orca-cloud/cloud-share-links-flag'
|
||||
cloudTeamSharingEnabled
|
||||
} from '@/lib/orca-cloud/cloud-team-sharing-flag'
|
||||
import type {
|
||||
KeybindingActionId,
|
||||
KeybindingDefinition
|
||||
@@ -36,7 +36,7 @@ export function groupDefinitions(
|
||||
disabledAgentTabActionIds(disabledTuiAgents)
|
||||
)
|
||||
// SHARE-LINKS-HOLD: no ⌘⌥⇧L entry while share links are held.
|
||||
if (!cloudShareLinksEnabled()) {
|
||||
if (!cloudTeamSharingEnabled()) {
|
||||
hiddenAgentActionIds.add(CLOUD_SHARE_LINK_ACTION_ID)
|
||||
}
|
||||
const groups = new Map<string, KeybindingDefinition[]>()
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const shareLinks = vi.hoisted(() => ({ on: false }))
|
||||
vi.mock('@/lib/orca-cloud/cloud-share-links-flag', () => ({
|
||||
vi.mock('@/lib/orca-cloud/cloud-team-sharing-flag', () => ({
|
||||
CLOUD_SHARE_LINK_ACTION_ID: 'cloudWorkspace.copyLink',
|
||||
cloudShareLinksEnabled: () => shareLinks.on
|
||||
cloudTeamSharingEnabled: () => shareLinks.on
|
||||
}))
|
||||
|
||||
import { groupDefinitions } from './shortcut-groups'
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { KEYBINDING_DEFINITIONS } from '../../../../../shared/keybindings/definitions'
|
||||
import {
|
||||
CLOUD_SHARE_LINK_ACTION_ID,
|
||||
cloudShareLinksEnabled
|
||||
} from '@/lib/orca-cloud/cloud-share-links-flag'
|
||||
cloudTeamSharingEnabled
|
||||
} from '@/lib/orca-cloud/cloud-team-sharing-flag'
|
||||
import type { SettingsSearchEntry } from '../search/settings-search'
|
||||
import { translate } from '@/i18n/i18n'
|
||||
import { translateSearchKeyword } from '../search/settings-search-keywords'
|
||||
@@ -67,7 +67,7 @@ export function getShortcutsPaneSearchEntries(options?: {
|
||||
(includeManagedBrowser ||
|
||||
(actionId !== 'tab.newBrowser' && actionId !== 'tab.newBrowserSplitRight')) &&
|
||||
(includeMobileEmulator || actionId !== 'tab.newSimulator') &&
|
||||
(actionId !== CLOUD_SHARE_LINK_ACTION_ID || cloudShareLinksEnabled())
|
||||
(actionId !== CLOUD_SHARE_LINK_ACTION_ID || cloudTeamSharingEnabled())
|
||||
)
|
||||
.map(({ searchEntry }) => searchEntry),
|
||||
getTerminalShortcutPolicySearchEntry()
|
||||
|
||||
@@ -24143,6 +24143,7 @@
|
||||
"picker": {
|
||||
"title": "Open cloud workspace",
|
||||
"description": "Cloud workspaces that aren’t in your sidebar: shared by teammates, or started on another computer.",
|
||||
"descriptionOwn": "Your cloud workspaces that aren’t in your sidebar, such as ones started on another computer.",
|
||||
"teammateTitle": "{{name}}’s cloud workspaces",
|
||||
"teammateDescription": "The ones they own or started that you can see.",
|
||||
"runningTitle": "Your running cloud workspaces",
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
// 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))
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// TEAM-SHARING-HOLD (Neil): sharing cloud workspaces with the team is held for a future release. The
|
||||
// code stays; the desktop offers none of it unless the account's capabilities turn on
|
||||
// `cloudTeamSharing` (absent = off, so an older or unaware control plane never brings it back):
|
||||
// - Share with team / Make private (sidebar, the cloud list, the workspace panel);
|
||||
// - the private/shared badges and Settings' visibility labels;
|
||||
// - the "Team" scope of Open cloud workspace…, and the people chip on a workspace;
|
||||
// - share links (Copy › Workspace link / chat link, the list's Copy link items, ⌘⌥⇧L and its
|
||||
// Settings entry), since a link only helps someone else open a shared workspace.
|
||||
// Opening an orca://cloud link still works; one to a workspace you can't open shows the usual
|
||||
// no-access message.
|
||||
import { useAppStore } from '@/store'
|
||||
import type { OrcaProfileAuthStatus } from '../../../../shared/orca-profiles'
|
||||
|
||||
export const CLOUD_TEAM_SHARING_FLAG = 'cloudTeamSharing'
|
||||
export const CLOUD_SHARE_LINK_ACTION_ID = 'cloudWorkspace.copyLink'
|
||||
|
||||
function enabledFor(status: OrcaProfileAuthStatus | null | undefined): boolean {
|
||||
return status?.capabilities?.flags[CLOUD_TEAM_SHARING_FLAG] === true
|
||||
}
|
||||
|
||||
/** Outside React (keyboard handlers, the copy itself, action groups, Settings' shortcut list). */
|
||||
export function cloudTeamSharingEnabled(): boolean {
|
||||
return enabledFor(useAppStore.getState().orcaProfileAuthStatus)
|
||||
}
|
||||
|
||||
export function useCloudTeamSharingEnabled(): boolean {
|
||||
return useAppStore((state) => enabledFor(state.orcaProfileAuthStatus))
|
||||
}
|
||||
Reference in New Issue
Block a user