mirror of
https://github.com/stablyai/orca.git
synced 2026-11-18 11:54:46 +00:00
Merge pull request #828 from nwparker/cloud/local-commands-sharing-hold
feat(cloud): TEAM-SHARING-HOLD no sharing mentions in local commands
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { useCloudTeamSharingEnabled } from '@/lib/orca-cloud/cloud-team-sharing-flag'
|
||||
import { TriangleAlert } from 'lucide-react'
|
||||
import { toast } from 'sonner'
|
||||
import { Button } from '@/components/ui/button'
|
||||
@@ -54,6 +55,7 @@ export function LocalCommandApprovalDialogView({
|
||||
/** Denies this request and turns local commands off for the workspace. */
|
||||
onTurnOff: () => void
|
||||
}): React.JSX.Element {
|
||||
const teamSharing = useCloudTeamSharingEnabled()
|
||||
const t = useTranslate()
|
||||
// A long command must be scrolled to its end before it can be allowed: nothing stays out of view.
|
||||
const [readToEnd, setReadToEnd] = useState(false)
|
||||
@@ -164,7 +166,8 @@ export function LocalCommandApprovalDialogView({
|
||||
)}
|
||||
</p>
|
||||
) : null}
|
||||
{prompt.shared ? (
|
||||
{/* TEAM-SHARING-HOLD: no teammates can message while sharing is held. */}
|
||||
{prompt.shared && teamSharing ? (
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{t(
|
||||
'localCommands.prompt.shared',
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
// @vitest-environment happy-dom
|
||||
// TEAM-SHARING-HOLD: the approval dialog says nothing about teammates while team sharing is held.
|
||||
import { act } from 'react'
|
||||
import { createRoot, type Root } from 'react-dom/client'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const teamSharing = vi.hoisted(() => ({ on: false }))
|
||||
vi.mock('@/lib/orca-cloud/cloud-team-sharing-flag', () => ({
|
||||
cloudTeamSharingEnabled: () => teamSharing.on,
|
||||
useCloudTeamSharingEnabled: () => teamSharing.on
|
||||
}))
|
||||
|
||||
import { Dialog } from '@/components/ui/dialog'
|
||||
import { TooltipProvider } from '@/components/ui/tooltip'
|
||||
import { LocalCommandApprovalDialogView } from './LocalCommandApprovalDialog'
|
||||
|
||||
globalThis.IS_REACT_ACT_ENVIRONMENT = true
|
||||
let root: Root | null = null
|
||||
afterEach(async () => {
|
||||
await act(async () => root?.unmount())
|
||||
root = null
|
||||
document.body.innerHTML = ''
|
||||
})
|
||||
|
||||
async function show(): Promise<string> {
|
||||
const container = document.createElement('div')
|
||||
document.body.appendChild(container)
|
||||
root = createRoot(container)
|
||||
const prompt = {
|
||||
requestId: 'r1',
|
||||
workspace: 'web',
|
||||
command: 'ls -la',
|
||||
cwd: '/tmp',
|
||||
shared: true,
|
||||
timeoutSeconds: 120
|
||||
}
|
||||
await act(async () =>
|
||||
root!.render(
|
||||
<TooltipProvider>
|
||||
<Dialog open>
|
||||
<LocalCommandApprovalDialogView
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the view reads only these prompt fields here.
|
||||
prompt={prompt as never}
|
||||
waitingCount={0}
|
||||
ready
|
||||
busy={false}
|
||||
onDecide={() => {}}
|
||||
onTurnOff={() => {}}
|
||||
/>
|
||||
</Dialog>
|
||||
</TooltipProvider>
|
||||
)
|
||||
)
|
||||
return document.body.textContent ?? ''
|
||||
}
|
||||
|
||||
describe('the teammates note on a local command request', () => {
|
||||
it('held: no mention of teammates', async () => {
|
||||
teamSharing.on = false
|
||||
expect(await show()).not.toContain('Teammates share this workspace')
|
||||
})
|
||||
|
||||
it('sharing on: says a teammate may have led to it', async () => {
|
||||
teamSharing.on = true
|
||||
expect(await show()).toContain('Teammates share this workspace')
|
||||
})
|
||||
})
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { cloudTeamSharingEnabled } from '@/lib/orca-cloud/cloud-team-sharing-flag'
|
||||
import { SquareTerminal } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { InlineError } from '@/components/ui/inline-error'
|
||||
@@ -20,16 +21,22 @@ import { LocalCommandText } from '../../local-commands/LocalCommandText'
|
||||
|
||||
const AUDIT_ROWS = 20
|
||||
|
||||
function workspaceDetail(row: LocalCommandWorkspaceRow, t: Translate): string {
|
||||
function workspaceDetail(
|
||||
row: LocalCommandWorkspaceRow,
|
||||
t: Translate,
|
||||
teamSharing = cloudTeamSharingEnabled()
|
||||
): string {
|
||||
// TEAM-SHARING-HOLD: no mention of sharing while team sharing is held.
|
||||
const shared = teamSharing && row.shared
|
||||
if (row.isOwner === false) {
|
||||
return t('localCommands.settings.notOwner', 'Only the workspace owner can turn this on.')
|
||||
}
|
||||
if (!row.enabled) {
|
||||
return row.shared
|
||||
return shared
|
||||
? t('localCommands.settings.offShared', 'Off · Shared with your team')
|
||||
: t('localCommands.settings.off', 'Off')
|
||||
}
|
||||
const sharing = row.shared
|
||||
const sharing = shared
|
||||
? ` · ${t('localCommands.settings.sharedOn', 'Shared with your team')}`
|
||||
: ''
|
||||
return row.connected
|
||||
@@ -318,7 +325,12 @@ export function OrcaCloudLocalCommandsPane(): React.JSX.Element {
|
||||
surface: 'security',
|
||||
initialFocus: 'cancel'
|
||||
})
|
||||
if (enabling && row.shared && !(allowShared = await confirmShared())) {
|
||||
if (
|
||||
enabling &&
|
||||
row.shared &&
|
||||
cloudTeamSharingEnabled() &&
|
||||
!(allowShared = await confirmShared())
|
||||
) {
|
||||
return
|
||||
}
|
||||
setPendingSandboxId(row.sandboxId)
|
||||
|
||||
Reference in New Issue
Block a user