mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
Merge pull request #319 from nwparker/cloud/ra5-agent-accounts-polish
fix(cloud): RA-5 — Agent accounts polish from the real-app re-check
This commit is contained in:
@@ -90,6 +90,18 @@ export const overview = defineFixture({
|
||||
)
|
||||
})
|
||||
|
||||
/** RA-5: the Needs attention filter with nothing in it says so instead of an empty table. */
|
||||
export const nothingNeedsAttention = defineFixture({
|
||||
width: 860,
|
||||
render: () => (
|
||||
<Frame
|
||||
{...BASE}
|
||||
initialFilter="attention"
|
||||
rows={overviewRows({ hosts: [LOCAL], probes: OVERVIEW_PROBES, cloud: CLOUD })}
|
||||
/>
|
||||
)
|
||||
})
|
||||
|
||||
export const needsAttention = defineFixture({
|
||||
width: 860,
|
||||
render: () => (
|
||||
|
||||
@@ -14,6 +14,7 @@ import { agentName, keyPhrase, productName, setupFailureCopy } from './orca-clou
|
||||
import type { OrcaCloudAccountsActions } from './orca-cloud-accounts-types'
|
||||
import { ActiveRow, ChoiceRow } from './OrcaCloudActiveRow'
|
||||
import { SetupRow } from './OrcaCloudSetupRow'
|
||||
import { RemoveConfirmRow, RowRemoveMenu } from './OrcaCloudRemoveRow'
|
||||
|
||||
export function AccountRow({
|
||||
agent,
|
||||
@@ -61,7 +62,20 @@ export function AccountRow({
|
||||
{useAccount}
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
>
|
||||
{/* The paste path stays reachable without waiting for the browser (RA-5). */}
|
||||
{agent === 'claude' ? (
|
||||
<Button
|
||||
type="button"
|
||||
variant="link-muted"
|
||||
size="statusAction"
|
||||
className="-ml-1"
|
||||
onClick={actions.usePaste}
|
||||
>
|
||||
{t('orcaCloudAccounts.pasteTokenInstead', 'Paste a token instead')}
|
||||
</Button>
|
||||
) : null}
|
||||
</RowShell>
|
||||
)
|
||||
break
|
||||
case 'setup':
|
||||
@@ -107,7 +121,14 @@ export function AccountRow({
|
||||
)
|
||||
break
|
||||
case 'expired':
|
||||
content = (
|
||||
content = confirmRemove ? (
|
||||
<RemoveConfirmRow
|
||||
agent={agent}
|
||||
actions={actions}
|
||||
setConfirmRemove={setConfirmRemove}
|
||||
setRowError={setRowError}
|
||||
/>
|
||||
) : (
|
||||
<RowShell
|
||||
agent={agent}
|
||||
tone="warning"
|
||||
@@ -127,9 +148,17 @@ export function AccountRow({
|
||||
)
|
||||
}
|
||||
actions={
|
||||
<Button type="button" variant="outline" size="sm" onClick={() => actions.start(agent)}>
|
||||
{t('orcaCloudAccounts.renew', 'Renew')}
|
||||
</Button>
|
||||
<>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => actions.start(agent)}
|
||||
>
|
||||
{t('orcaCloudAccounts.renew', 'Renew')}
|
||||
</Button>
|
||||
<RowRemoveMenu agent={agent} onRemove={() => setConfirmRemove(true)} />
|
||||
</>
|
||||
}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -151,6 +151,13 @@ export const removeConfirm = fixture({ claude: CLAUDE_ACTIVE, codex: CODEX_TEAM
|
||||
confirmRemove: 'claude'
|
||||
})
|
||||
|
||||
/** RA-5: Remove… from an expired row's ⋯ confirms like the active row. */
|
||||
export const expiredRemoveConfirm = fixture(
|
||||
{ claude: { kind: 'expired', keyKind: null, covered: false }, codex: CODEX_TEAM },
|
||||
READY,
|
||||
{ confirmRemove: 'claude' }
|
||||
)
|
||||
|
||||
export const killSwitch = fixture({
|
||||
claude: CLAUDE_ACTIVE,
|
||||
codex: { kind: 'killSwitch' }
|
||||
|
||||
@@ -118,6 +118,30 @@ describe('OrcaCloudAccountsView', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('offers Paste a token instead on the not-set-up Claude row only (RA-5)', () => {
|
||||
const handlers = view({ claude: NOT_SET_UP, codex: NOT_SET_UP })
|
||||
const paste = screen.getAllByRole('button', { name: 'Paste a token instead' })
|
||||
expect(paste).toHaveLength(1)
|
||||
fireEvent.click(paste[0])
|
||||
expect(handlers.usePaste).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('an expired row offers Renew and a ⋯ with Remove, which confirms first (RA-5)', async () => {
|
||||
const handlers = view({
|
||||
claude: { kind: 'expired', keyKind: null, covered: false },
|
||||
codex: NOT_SET_UP
|
||||
})
|
||||
expect(screen.getByRole('button', { name: 'Renew' })).toBeTruthy()
|
||||
expect(screen.queryByRole('button', { name: /Sign in again/ })).toBeNull()
|
||||
const menu = screen.getByRole('button', { name: 'Claude account options' })
|
||||
fireEvent.pointerDown(menu, { button: 0, ctrlKey: false })
|
||||
fireEvent.click(await screen.findByRole('menuitem', { name: 'Remove…' }))
|
||||
const remove = await screen.findByRole('button', { name: 'Remove' })
|
||||
expect(handlers.remove).not.toHaveBeenCalled()
|
||||
fireEvent.click(remove)
|
||||
await waitFor(() => expect(handlers.remove).toHaveBeenCalledWith('claude'))
|
||||
})
|
||||
|
||||
it('shows the kill switch as info with no action, and signed out with Sign in', () => {
|
||||
view({ claude: { kind: 'killSwitch' }, codex: NOT_SET_UP })
|
||||
expect(screen.getByText('Signs in for each cloud workspace')).toBeTruthy()
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
productName
|
||||
} from './orca-cloud-accounts-copy'
|
||||
import type { OrcaCloudAccountsActions } from './orca-cloud-accounts-types'
|
||||
import { RemoveConfirmRow } from './OrcaCloudRemoveRow'
|
||||
|
||||
export function ActiveRow({
|
||||
agent,
|
||||
@@ -52,46 +53,11 @@ export function ActiveRow({
|
||||
}
|
||||
if (confirmRemove) {
|
||||
return (
|
||||
<RowShell
|
||||
<RemoveConfirmRow
|
||||
agent={agent}
|
||||
tone="warning"
|
||||
title={t(
|
||||
'orcaCloudAccounts.removeConfirm',
|
||||
'Remove your {{product}} account from Orca? Cloud workspaces use the team key, or ask you to sign in.',
|
||||
{ product }
|
||||
)}
|
||||
actions={
|
||||
<>
|
||||
<Button
|
||||
type="button"
|
||||
variant="destructive"
|
||||
size="sm"
|
||||
disabled={busy}
|
||||
aria-busy={busy || undefined}
|
||||
autoFocus
|
||||
onClick={() =>
|
||||
void run(async () => {
|
||||
const error = await actions.remove(agent)
|
||||
if (!error) {
|
||||
setConfirmRemove(false)
|
||||
}
|
||||
return error
|
||||
})
|
||||
}
|
||||
>
|
||||
{t('orcaCloudAccounts.remove', 'Remove')}
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
disabled={busy}
|
||||
onClick={() => setConfirmRemove(false)}
|
||||
>
|
||||
{t('orcaCloudAccounts.cancel', 'Cancel')}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
actions={actions}
|
||||
setConfirmRemove={setConfirmRemove}
|
||||
setRowError={setRowError}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
// Remove… for a saved Orca-account credential: the confirm row (active and expired rows) and the
|
||||
// expired row's ⋯ menu that opens it (RA-5).
|
||||
import type React from 'react'
|
||||
import { useState } from 'react'
|
||||
import { MoreHorizontal } from 'lucide-react'
|
||||
import { useTranslate } from '@/i18n/use-translate'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger
|
||||
} from '@/components/ui/dropdown-menu'
|
||||
import type {
|
||||
OrcaCloudAccountAgent,
|
||||
OrcaCloudAgentsErrorCode
|
||||
} from '../../../../../shared/orca-cloud-agents/orca-cloud-agents-wire'
|
||||
import { RowShell } from './orca-cloud-account-row-shell'
|
||||
import { agentName, productName } from './orca-cloud-accounts-copy'
|
||||
import type { OrcaCloudAccountsActions } from './orca-cloud-accounts-types'
|
||||
|
||||
export function RemoveConfirmRow({
|
||||
agent,
|
||||
actions,
|
||||
setConfirmRemove,
|
||||
setRowError
|
||||
}: {
|
||||
agent: OrcaCloudAccountAgent
|
||||
actions: OrcaCloudAccountsActions
|
||||
setConfirmRemove: (open: boolean) => void
|
||||
setRowError: (error: OrcaCloudAgentsErrorCode | null) => void
|
||||
}): React.JSX.Element {
|
||||
const t = useTranslate()
|
||||
const [busy, setBusy] = useState(false)
|
||||
const product = productName(agent, t)
|
||||
const remove = async (): Promise<void> => {
|
||||
setBusy(true)
|
||||
const error = await actions.remove(agent)
|
||||
setBusy(false)
|
||||
setRowError(error)
|
||||
if (!error) {
|
||||
setConfirmRemove(false)
|
||||
}
|
||||
}
|
||||
return (
|
||||
<RowShell
|
||||
agent={agent}
|
||||
tone="warning"
|
||||
title={t(
|
||||
'orcaCloudAccounts.removeConfirm',
|
||||
'Remove your {{product}} account from Orca? Cloud workspaces use the team key, or ask you to sign in.',
|
||||
{ product }
|
||||
)}
|
||||
actions={
|
||||
<>
|
||||
<Button
|
||||
type="button"
|
||||
variant="destructive"
|
||||
size="sm"
|
||||
disabled={busy}
|
||||
aria-busy={busy || undefined}
|
||||
autoFocus
|
||||
onClick={() => void remove()}
|
||||
>
|
||||
{t('orcaCloudAccounts.remove', 'Remove')}
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
disabled={busy}
|
||||
onClick={() => setConfirmRemove(false)}
|
||||
>
|
||||
{t('orcaCloudAccounts.cancel', 'Cancel')}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export function RowRemoveMenu({
|
||||
agent,
|
||||
onRemove
|
||||
}: {
|
||||
agent: OrcaCloudAccountAgent
|
||||
onRemove: () => void
|
||||
}): React.JSX.Element {
|
||||
const t = useTranslate()
|
||||
return (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon-sm"
|
||||
aria-label={t('orcaCloudAccounts.rowMenu', '{{agent}} account options', {
|
||||
agent: agentName(agent, t)
|
||||
})}
|
||||
>
|
||||
<MoreHorizontal aria-hidden />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem onSelect={onRemove}>
|
||||
{t('orcaCloudAccounts.removeEllipsis', 'Remove…')}
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
)
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
// @vitest-environment happy-dom
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
|
||||
import { AgentAccountsOverview } from './AgentAccountsOverview'
|
||||
import type { OverviewRow } from './agent-accounts-overview-model'
|
||||
|
||||
const CLOUD: OverviewRow = {
|
||||
id: 'cloud',
|
||||
hostId: null,
|
||||
label: 'Orca Cloud',
|
||||
kind: 'cloud',
|
||||
availability: 'available',
|
||||
cells: { claude: { kind: 'cloudAccount' }, codex: { kind: 'cloudAccount' } },
|
||||
attention: false,
|
||||
action: null
|
||||
}
|
||||
|
||||
function overview(rows: readonly OverviewRow[]): void {
|
||||
render(
|
||||
<AgentAccountsOverview
|
||||
rows={rows}
|
||||
signedOutOfOrca={false}
|
||||
summary=""
|
||||
onOpenRow={vi.fn()}
|
||||
onAction={vi.fn()}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
describe('AgentAccountsOverview (RA-5)', () => {
|
||||
afterEach(cleanup)
|
||||
|
||||
it('says nothing needs attention instead of an empty table', () => {
|
||||
overview([CLOUD])
|
||||
fireEvent.click(screen.getByRole('radio', { name: 'Needs attention · 0' }))
|
||||
expect(screen.getByText('Nothing needs attention.')).toBeTruthy()
|
||||
expect(screen.queryByRole('table')).toBeNull()
|
||||
})
|
||||
|
||||
it('never truncates the Orca Cloud name away: it keeps a minimum width', () => {
|
||||
overview([CLOUD])
|
||||
const name = screen.getByText('Orca Cloud', { selector: 'span' })
|
||||
expect(name.className).toContain('min-w-[6rem]')
|
||||
expect(screen.getByText('all your cloud workspaces').className).toContain('truncate')
|
||||
})
|
||||
})
|
||||
+12
-3
@@ -28,6 +28,8 @@ export type AgentAccountsOverviewProps = {
|
||||
summary: string
|
||||
onOpenRow: (row: OverviewRow) => void
|
||||
onAction: (row: OverviewRow, action: OverviewAction) => void
|
||||
/** Fixtures only: the filter the list opens on. */
|
||||
initialFilter?: 'all' | 'attention'
|
||||
}
|
||||
|
||||
function actionLabel(action: OverviewAction, t: Translate): string {
|
||||
@@ -99,15 +101,18 @@ function HostHeader({ row }: { row: OverviewRow }): React.JSX.Element {
|
||||
return (
|
||||
<span className="flex min-w-0 items-center gap-2">
|
||||
<HostGlyph kind={GLYPH[row.kind]} size={14} />
|
||||
<span className="truncate text-foreground">{name}</span>
|
||||
{detail ? <span className="shrink-0 text-xs text-muted-foreground">{detail}</span> : null}
|
||||
{/* The name keeps room for "Orca Cloud"; the muted detail gives way first (RA-5). */}
|
||||
<span className="min-w-[6rem] truncate text-foreground">{name}</span>
|
||||
{detail ? (
|
||||
<span className="min-w-0 truncate text-xs text-muted-foreground">{detail}</span>
|
||||
) : null}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
export function AgentAccountsOverview(props: AgentAccountsOverviewProps): React.JSX.Element {
|
||||
const t = useTranslate()
|
||||
const [filter, setFilter] = useState<'all' | 'attention'>('all')
|
||||
const [filter, setFilter] = useState<'all' | 'attention'>(props.initialFilter ?? 'all')
|
||||
const attention = props.rows.filter((row) => row.attention).length
|
||||
const shown = filter === 'attention' ? props.rows.filter((row) => row.attention) : props.rows
|
||||
const onlyLocal = !props.loading && props.rows.every((row) => row.kind === 'local')
|
||||
@@ -155,6 +160,10 @@ export function AgentAccountsOverview(props: AgentAccountsOverviewProps): React.
|
||||
<Skeleton key={line} shape="small" className="h-3 w-3/5" />
|
||||
))}
|
||||
</div>
|
||||
) : shown.length === 0 ? (
|
||||
<p role="status" className="px-4 py-3 text-sm text-muted-foreground">
|
||||
{t('agentAccountsOverview.nothingNeedsAttention', 'Nothing needs attention.')}
|
||||
</p>
|
||||
) : (
|
||||
<table className="w-full table-fixed border-collapse text-start">
|
||||
<thead>
|
||||
|
||||
@@ -36,6 +36,9 @@ const buttonVariants = cva(
|
||||
quiet:
|
||||
'text-muted-foreground hover:bg-accent hover:text-foreground dark:hover:bg-accent/50',
|
||||
link: 'text-primary underline-offset-4 hover:underline focus-visible:underline',
|
||||
// A secondary escape hatch under a row's detail (e.g. "Paste a token instead"): muted, link-styled.
|
||||
'link-muted':
|
||||
'text-muted-foreground underline-offset-4 hover:text-foreground hover:underline focus-visible:underline',
|
||||
'menu-launch':
|
||||
'min-w-0 flex-1 justify-start rounded-l-[7px] rounded-r-none text-foreground',
|
||||
'menu-segment': 'rounded-l-none border-l border-border',
|
||||
|
||||
+1
-1
@@ -163,7 +163,7 @@ function Trailing({
|
||||
case 'expired':
|
||||
return (
|
||||
<Button type="button" size="xs" onClick={actions.setUp}>
|
||||
{t('vmBuildAgents.signInAgain', 'Sign in again')}
|
||||
{t('vmBuildAgents.renew', 'Renew')}
|
||||
</Button>
|
||||
)
|
||||
case 'killSwitch':
|
||||
|
||||
+2
-2
@@ -129,8 +129,8 @@ export function buildAgentsRowText(
|
||||
agent: agentName(model.agent, t)
|
||||
}),
|
||||
detail: t(
|
||||
'vmBuildAgents.expiredDetail',
|
||||
'Sign in again once. Every cloud workspace picks it up.'
|
||||
'vmBuildAgents.expiredDetailRenew',
|
||||
'Renew once. Every cloud workspace picks it up.'
|
||||
)
|
||||
}
|
||||
case 'killSwitch':
|
||||
|
||||
@@ -27886,7 +27886,9 @@
|
||||
"copyAndOpen": "Copy code and open",
|
||||
"unavailable": "Signs in for each cloud workspace",
|
||||
"unavailableDetail": "Signing in once with your {{product}} account isn’t available in Orca Cloud yet. Each new cloud workspace asks you to sign in.",
|
||||
"allUnavailable": "Claude and Codex sign in for each cloud workspace for now."
|
||||
"allUnavailable": "Claude and Codex sign in for each cloud workspace for now.",
|
||||
"pasteTokenInstead": "Paste a token instead",
|
||||
"rowMenu": "{{agent}} account options"
|
||||
},
|
||||
"vmBuildAgents": {
|
||||
"menu": {
|
||||
@@ -27909,7 +27911,6 @@
|
||||
"pasteToken": "Paste token",
|
||||
"tryAgain": "Try again",
|
||||
"dismiss": "Dismiss",
|
||||
"signInAgain": "Sign in again",
|
||||
"signInHere": "Sign in for this workspace",
|
||||
"checking": "Checking agent sign-in",
|
||||
"readyDetail": "Every cloud workspace uses it. Nothing to do here.",
|
||||
@@ -27933,7 +27934,6 @@
|
||||
"offerDetail": "Sign in to {{agents}} once. Every cloud workspace uses it.",
|
||||
"stillOpens": "The workspace still opens.",
|
||||
"expired": "Your {{agent}} sign-in for Orca Cloud expired",
|
||||
"expiredDetail": "Sign in again once. Every cloud workspace picks it up.",
|
||||
"agentSignIn": "{{agent}} sign-in",
|
||||
"paused": "Orca account sign-in is paused",
|
||||
"pausedDetail": "This sign-in stays with this workspace.",
|
||||
@@ -27941,7 +27941,8 @@
|
||||
"errorDetail": "The workspace still opens. Agents can sign in later.",
|
||||
"groupAccount": "{{agents}} from your Orca account",
|
||||
"groupKey": "{{agents}} with {{key}}",
|
||||
"notOffered": "Signs in for each cloud workspace for now"
|
||||
"notOffered": "Signs in for each cloud workspace for now",
|
||||
"expiredDetailRenew": "Renew once. Every cloud workspace picks it up."
|
||||
},
|
||||
"agentAccountsOverview": {
|
||||
"action": {
|
||||
@@ -27980,7 +27981,8 @@
|
||||
"cloudNotSetUp": "Not set up",
|
||||
"cloudPaused": "Each workspace signs in (temporarily)",
|
||||
"apiKeyOverrides": "API key overrides sign-in"
|
||||
}
|
||||
},
|
||||
"nothingNeedsAttention": "Nothing needs attention."
|
||||
},
|
||||
"agentSignInStrip": {
|
||||
"sandbox": "the sandbox",
|
||||
|
||||
Reference in New Issue
Block a user