mirror of
https://github.com/stablyai/orca.git
synced 2026-11-18 03:45:08 +00:00
feat(cloud): CHAT-BANNERS B2 a running structured chat on Orca Cloud shows sign-in expired · Renew, and its 401 card points at Renew
- RA-11's running strip on a structured chat (useCloudChatRunningStrip,
mounted in CloudStructuredChatBanners): expired shows Renew; renewed only
confirms ("Your next message uses it.") with a dismiss, no Restart - the
chat's next message goes out with the renewed sign-in (the proxy swaps it in
per request; live-checked). A held launch's strip wins.
- cloudRunningStrip: turnEndedFallback for structured chats (their status has
no turnEndedAt; done-since dates the clean turn), terminal panes unchanged.
- On an Orca Cloud chat, the agent's not-signed-in card says "Renew it above,
then send your message again." instead of the CLI login advice and its
terminal Sign in button (private cloud-chat-sign-in-notice + a render-time
hook in NativeChatNoticeRow; shared copy untouched).
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
// CHAT-BANNERS B2: a structured chat on Orca Cloud whose agent was running when its Orca-account
|
||||
// sign-in expired: the strip at the top of the chat (expired → Renew; renewed → confirm and dismiss,
|
||||
// no Restart), and the agent's 401 card, which on Orca Cloud points at Renew instead of the CLI login.
|
||||
import React from 'react'
|
||||
import { defineFixture } from '../../component-fixtures/component-fixture'
|
||||
import { translate } from '@/i18n/i18n'
|
||||
import type { AppState } from '@/store/types'
|
||||
import { agentSessionFailureFact } from '../../../../shared/agent-session/failures/agent-session-failure'
|
||||
import { agentSessionFailureWords } from '../../../../shared/agent-session/failures/agent-session-failure-words'
|
||||
import { NativeChatNoticeRow } from '../native-chat/messages/notices/NativeChatNoticeRow'
|
||||
import {
|
||||
CloudAgentSignInStrip,
|
||||
cloudStripWidth,
|
||||
type CloudStripActions
|
||||
} from './CloudAgentSignInStrip'
|
||||
import { cloudChatRunningStripModel } from './cloud-running-strip-model'
|
||||
import { CloudChatHostProvider } from './cloud-chat-sign-in-notice'
|
||||
|
||||
const noop = (): void => {}
|
||||
const ACTIONS: CloudStripActions = {
|
||||
primary: noop,
|
||||
submitCode: noop,
|
||||
pasteCode: noop,
|
||||
useCode: noop,
|
||||
useApiKey: noop,
|
||||
cancel: noop
|
||||
}
|
||||
const ENV = 'fixture-cloud-env'
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the fixture seeds only the runtime environment the cloud check reads.
|
||||
const store = {
|
||||
runtimeEnvironments: [{ id: ENV, name: 'Hello-World sandbox a1b2c3d4', source: 'ephemeral-vm' }]
|
||||
} as unknown as Partial<AppState>
|
||||
|
||||
function Chat({
|
||||
phase,
|
||||
card,
|
||||
width
|
||||
}: {
|
||||
phase: 'expired' | 'renewed' | null
|
||||
card: boolean
|
||||
width: number
|
||||
}): React.JSX.Element {
|
||||
const fact = agentSessionFailureFact('notSignedIn', { account: 'system' })
|
||||
return (
|
||||
<CloudChatHostProvider target={{ kind: 'environment', environmentId: ENV }}>
|
||||
<div className="bg-background p-4">
|
||||
<div
|
||||
className="relative flex h-[380px] flex-col overflow-hidden rounded-md border border-border bg-chat-canvas"
|
||||
style={{ width }}
|
||||
>
|
||||
<div data-cloud-chat-banners="" className="shrink-0">
|
||||
{phase ? (
|
||||
<CloudAgentSignInStrip
|
||||
model={cloudChatRunningStripModel(
|
||||
phase === 'expired'
|
||||
? { phase, agent: 'claude' }
|
||||
: { phase, agent: 'claude', resumable: true },
|
||||
translate
|
||||
)}
|
||||
prompt={null}
|
||||
width={cloudStripWidth(width)}
|
||||
actions={ACTIONS}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="flex min-h-0 flex-1 flex-col gap-3 px-4 py-3 text-sm">
|
||||
<div className="self-end rounded-lg bg-muted px-3 py-2">Fix the flaky auth test</div>
|
||||
{card ? (
|
||||
<NativeChatNoticeRow
|
||||
agentName="Claude"
|
||||
block={{
|
||||
type: 'text',
|
||||
tone: 'failure',
|
||||
...agentSessionFailureWords(fact, { agentName: 'Claude', surface: 'row' })
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="m-3 rounded-lg border border-border bg-card px-3 py-2 text-sm text-muted-foreground">
|
||||
{translate(
|
||||
'components.native-chat.composer.placeholder',
|
||||
'Ask anything, @ to mention files, / for commands'
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</CloudChatHostProvider>
|
||||
)
|
||||
}
|
||||
|
||||
const fixture = (phase: 'expired' | 'renewed' | null, card: boolean, width = 760) =>
|
||||
defineFixture({
|
||||
width: width + 40,
|
||||
store,
|
||||
render: () => <Chat phase={phase} card={card} width={width} />
|
||||
})
|
||||
|
||||
/** RA-11 on a running structured chat: expired, with the agent's 401 card pointing at Renew. */
|
||||
export const runningExpired = fixture('expired', true)
|
||||
export const runningExpiredNarrow = fixture('expired', true, 420)
|
||||
/** Renewed: confirms; the chat's next message uses it (no Restart), × dismisses. */
|
||||
export const runningRenewed = fixture('renewed', false)
|
||||
export const runningRenewedNarrow = fixture('renewed', false, 420)
|
||||
/** The 401 card alone on Orca Cloud. */
|
||||
export const signInCard = fixture(null, true)
|
||||
@@ -4,6 +4,7 @@ import { useAppStore } from '@/store'
|
||||
import { readCloudAgentHold, releaseCloudAgentHold } from '@/lib/orca-cloud/cloud-agent-launch-hold'
|
||||
import { CloudAgentSignInStrip } from './CloudAgentSignInStrip'
|
||||
import { useCloudHeldStrip } from './use-cloud-held-strip'
|
||||
import { useCloudChatRunningStrip } from './use-cloud-chat-running-strip'
|
||||
import './cloud-chat-banner-slot.css'
|
||||
|
||||
const ABANDON_CHECK_MS = 1_000
|
||||
@@ -15,16 +16,23 @@ function tabStillOpen(tabId: string): boolean {
|
||||
|
||||
/**
|
||||
* CHAT-BANNERS (PR-B): a structured chat's cloud strip, at the top of its column under the header,
|
||||
* the same strip a terminal pane shows: "Set up once" or Renew while its launch is held.
|
||||
* the same strips a terminal pane shows: "Set up once" or Renew while its launch is held, and
|
||||
* RA-11's "sign-in expired · Renew" while its agent runs (B2).
|
||||
*/
|
||||
export function CloudStructuredChatBanners({
|
||||
tabId,
|
||||
paneKey
|
||||
paneKey,
|
||||
statusKey
|
||||
}: {
|
||||
tabId: string
|
||||
/** The launch-hold key (from the session id). */
|
||||
paneKey: string
|
||||
/** The agent-status key (tab and session): the running strip (B2) reads the agent through it. */
|
||||
statusKey: string
|
||||
}): React.JSX.Element {
|
||||
const { key, active, strip } = useCloudHeldStrip(paneKey, null)
|
||||
const running = useCloudChatRunningStrip({ tabId, statusKey, holdKey: paneKey })
|
||||
const shown = strip ?? running
|
||||
useEffect(() => {
|
||||
if (!active) {
|
||||
return
|
||||
@@ -40,7 +48,7 @@ export function CloudStructuredChatBanners({
|
||||
}, [active, key, tabId])
|
||||
return (
|
||||
<div data-cloud-chat-banners="" className="shrink-0">
|
||||
{strip ? <CloudAgentSignInStrip {...strip} width="wide" /> : null}
|
||||
{shown ? <CloudAgentSignInStrip {...shown} width="wide" /> : null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
// @vitest-environment happy-dom
|
||||
// CHAT-BANNERS B2: RA-11's running strip on a structured chat. Expired shows Renew; renewed confirms
|
||||
// with no Restart (the chat's next message uses the renewed sign-in) and its × dismisses; a held
|
||||
// launch's strip wins over it.
|
||||
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { TooltipProvider } from '@/components/ui/tooltip'
|
||||
|
||||
const TAB_ID = 'structured-agent-session-claude_1'
|
||||
const STATUS_KEY = `${TAB_ID}:5b1d2c3e-aaaa-4bbb-accc-0123456789ab`
|
||||
const HOLD_KEY = `${TAB_ID}:11111111-2222-4333-a444-555555555555`
|
||||
|
||||
type Strip =
|
||||
| { phase: 'expired'; agent: 'claude' }
|
||||
| { phase: 'renewed'; agent: 'claude'; resumable: boolean }
|
||||
|
||||
const stub = vi.hoisted(() => {
|
||||
const state: {
|
||||
strip: Strip | null
|
||||
held: boolean
|
||||
cleared: string[]
|
||||
calls: { paneKey: string; turnEndedFallback?: boolean }[]
|
||||
openedSettings: number
|
||||
} = { strip: null, held: false, cleared: [], calls: [], openedSettings: 0 }
|
||||
return state
|
||||
})
|
||||
|
||||
vi.mock('@/store', () => {
|
||||
const state = {
|
||||
unifiedTabsByWorktree: {
|
||||
'wt-1': [{ id: TAB_ID, executionHostId: 'runtime:env-cloud', contentType: 'agent-session' }]
|
||||
},
|
||||
agentStatusByPaneKey: {
|
||||
[STATUS_KEY]: { agentType: 'claude', state: 'working', paneKey: STATUS_KEY }
|
||||
},
|
||||
openSettingsTarget: () => undefined,
|
||||
openSettingsPage: () => {
|
||||
stub.openedSettings += 1
|
||||
}
|
||||
}
|
||||
const useAppStore = (selector: (s: typeof state) => unknown): unknown => selector(state)
|
||||
useAppStore.getState = () => state
|
||||
return { useAppStore }
|
||||
})
|
||||
vi.mock('@/lib/orca-cloud/orca-cloud-environment-id', () => ({
|
||||
isOrcaCloudEnvironmentId: (id: string) => id === 'env-cloud'
|
||||
}))
|
||||
vi.mock('@/lib/orca-cloud/orca-cloud-agent-accounts-store', () => ({
|
||||
orcaCloudAgentAccountsLoadedAt: () => 1,
|
||||
useOrcaCloudAgentAccounts: () => ({
|
||||
load: { kind: 'loading' },
|
||||
keyKinds: {},
|
||||
setups: { claude: { phase: 'idle' }, codex: { phase: 'idle' } }
|
||||
})
|
||||
}))
|
||||
vi.mock('@/lib/orca-cloud/cloud-running-agent-signout', () => ({
|
||||
clearCloudRunningSignout: (key: string) => {
|
||||
stub.cleared.push(key)
|
||||
},
|
||||
cloudRunningStrip: (args: { paneKey: string; held: boolean; turnEndedFallback?: boolean }) => {
|
||||
stub.calls.push({ paneKey: args.paneKey, turnEndedFallback: args.turnEndedFallback })
|
||||
return args.held ? null : stub.strip
|
||||
},
|
||||
useCloudRunningAccountReads: () => undefined,
|
||||
useCloudRunningSignoutVersion: () => 0,
|
||||
useWorkspaceUsesAccount: () => true
|
||||
}))
|
||||
vi.mock('@/lib/orca-cloud/cloud-agent-launch-hold', async (importOriginal) => ({
|
||||
...(await importOriginal<object>()),
|
||||
useCloudAgentHold: (key: string) =>
|
||||
key === HOLD_KEY && stub.held ? { agent: 'claude', reason: 'notSetUp', prompt: null } : null,
|
||||
readCloudAgentHold: () => null
|
||||
}))
|
||||
vi.mock('@/lib/agent-sign-in/agent-sign-in-gate-store', () => ({ useAgentSignInGate: () => null }))
|
||||
vi.mock('../agent-sign-in/AgentSignInPanePortals', () => ({
|
||||
agentSignInCardActions: () => ({
|
||||
copyText: () => undefined,
|
||||
openLink: () => undefined,
|
||||
signIn: () => undefined,
|
||||
retry: () => undefined,
|
||||
useCode: () => undefined,
|
||||
submitCode: () => undefined,
|
||||
cancel: () => undefined
|
||||
})
|
||||
}))
|
||||
Object.defineProperty(window, 'api', { configurable: true, value: { orcaCloudAgents: {} } })
|
||||
vi.stubGlobal(
|
||||
'ResizeObserver',
|
||||
class {
|
||||
observe(): void {}
|
||||
unobserve(): void {}
|
||||
disconnect(): void {}
|
||||
}
|
||||
)
|
||||
|
||||
const { CloudStructuredChatBanners } = await import('./CloudStructuredChatBanners')
|
||||
|
||||
const mount = () =>
|
||||
render(
|
||||
<TooltipProvider>
|
||||
<CloudStructuredChatBanners tabId={TAB_ID} paneKey={HOLD_KEY} statusKey={STATUS_KEY} />
|
||||
</TooltipProvider>
|
||||
)
|
||||
|
||||
beforeEach(() => {
|
||||
stub.strip = null
|
||||
stub.held = false
|
||||
stub.cleared = []
|
||||
stub.calls = []
|
||||
stub.openedSettings = 0
|
||||
})
|
||||
afterEach(() => cleanup())
|
||||
|
||||
describe('the running strip on a structured chat (B2)', () => {
|
||||
it('expired: "sign-in expired" with Renew, read through the chat status key', () => {
|
||||
stub.strip = { phase: 'expired', agent: 'claude' }
|
||||
mount()
|
||||
expect(screen.getAllByText(/Claude sign-in expired/).length).toBeGreaterThan(0)
|
||||
fireEvent.click(screen.getByRole('button', { name: /Renew/ }))
|
||||
expect(stub.openedSettings).toBe(1)
|
||||
expect(stub.calls.at(-1)).toEqual({ paneKey: STATUS_KEY, turnEndedFallback: true })
|
||||
})
|
||||
|
||||
it('renewed: confirms with no Restart, and × dismisses it', () => {
|
||||
stub.strip = { phase: 'renewed', agent: 'claude', resumable: true }
|
||||
mount()
|
||||
expect(screen.getAllByText(/Claude sign-in renewed/).length).toBeGreaterThan(0)
|
||||
expect(screen.getAllByText(/Your next message uses it/).length).toBeGreaterThan(0)
|
||||
expect(screen.queryByRole('button', { name: /Restart/ })).toBeNull()
|
||||
fireEvent.keyDown(screen.getByRole('region'), { key: 'Escape' })
|
||||
expect(stub.cleared).toEqual([STATUS_KEY])
|
||||
})
|
||||
|
||||
it("a held launch's strip shows instead", () => {
|
||||
stub.strip = { phase: 'expired', agent: 'claude' }
|
||||
stub.held = true
|
||||
mount()
|
||||
expect(screen.getByRole('button', { name: 'Set up once' })).toBeTruthy()
|
||||
expect(screen.queryByRole('button', { name: /Renew/ })).toBeNull()
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,66 @@
|
||||
// @vitest-environment happy-dom
|
||||
// CHAT-BANNERS B2: on an Orca Cloud chat, the agent's "not signed in" card points at the strip's
|
||||
// Renew, not at the CLI's login and its terminal Sign in button. Elsewhere the card is unchanged.
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
import { cleanup, render, screen } from '@testing-library/react'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { agentSessionFailureFact } from '../../../../shared/agent-session/failures/agent-session-failure'
|
||||
import { agentSessionFailureWords } from '../../../../shared/agent-session/failures/agent-session-failure-words'
|
||||
import { NativeChatHostSetupContext } from '../native-chat/host-access/native-chat-host-setup'
|
||||
import { NativeChatNoticeRow } from '../native-chat/messages/notices/NativeChatNoticeRow'
|
||||
import { CloudChatHostProvider, cloudChatSignInContent } from './cloud-chat-sign-in-notice'
|
||||
|
||||
const cloud = vi.hoisted(() => ({ on: true }))
|
||||
vi.mock('@/lib/orca-cloud/orca-cloud-environment-id', () => ({
|
||||
isOrcaCloudEnvironmentId: () => cloud.on
|
||||
}))
|
||||
|
||||
afterEach(() => cleanup())
|
||||
|
||||
const signIn = { signIn: vi.fn(), pending: false, failureKinds: ['notSignedIn'] }
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the row reads only signIn's action fields.
|
||||
const SETUP = { signIn: signIn as never, install: null }
|
||||
|
||||
function card(agentName: string) {
|
||||
const fact = agentSessionFailureFact('notSignedIn', { account: 'system' })
|
||||
return render(
|
||||
<CloudChatHostProvider target={{ kind: 'environment', environmentId: 'env-1' }}>
|
||||
<NativeChatHostSetupContext.Provider value={SETUP}>
|
||||
<NativeChatNoticeRow
|
||||
agentName={agentName}
|
||||
block={{
|
||||
type: 'text',
|
||||
tone: 'failure',
|
||||
...agentSessionFailureWords(fact, { agentName, surface: 'row' })
|
||||
}}
|
||||
/>
|
||||
</NativeChatHostSetupContext.Provider>
|
||||
</CloudChatHostProvider>
|
||||
)
|
||||
}
|
||||
|
||||
describe('the not-signed-in card on an Orca Cloud chat', () => {
|
||||
it('says Renew above, with no CLI login advice and no Sign in button', () => {
|
||||
cloud.on = true
|
||||
card('Claude')
|
||||
expect(screen.getByText(/Renew it above, then send your message again/)).toBeInTheDocument()
|
||||
expect(screen.queryByText(/claude auth login/)).toBeNull()
|
||||
expect(screen.queryByRole('button', { name: 'Sign in' })).toBeNull()
|
||||
})
|
||||
|
||||
it('off Orca Cloud the card keeps its own words', () => {
|
||||
cloud.on = false
|
||||
card('Claude')
|
||||
expect(screen.queryByText(/Renew it above/)).toBeNull()
|
||||
expect(screen.getByText(/claude auth login/)).toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
|
||||
describe('cloudChatSignInContent', () => {
|
||||
it('only for Claude or Codex not-signed-in on Orca Cloud', () => {
|
||||
expect(cloudChatSignInContent(true, 'notSignedIn', 'Codex')).toMatch(/Your Codex sign-in/)
|
||||
expect(cloudChatSignInContent(false, 'notSignedIn', 'Claude')).toBeUndefined()
|
||||
expect(cloudChatSignInContent(true, 'usageLimitReached', 'Claude')).toBeUndefined()
|
||||
expect(cloudChatSignInContent(true, 'notSignedIn', 'Antigravity')).toBeUndefined()
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,47 @@
|
||||
// CHAT-BANNERS B2: in a structured chat on Orca Cloud, a 401 from the agent ("not signed in") is the
|
||||
// Orca-account sign-in, which the strip above renews. The generic card's advice (run the CLI's login,
|
||||
// a Sign in button that opens a terminal on the host) points at the wrong fix there; this replaces it.
|
||||
import { createContext, useContext, type ReactNode } from 'react'
|
||||
import type React from 'react'
|
||||
import { translate } from '@/i18n/i18n'
|
||||
import type { Translate } from '@/i18n/use-translate'
|
||||
import type { RuntimeClientTarget } from '../../../../shared/runtime-client-target'
|
||||
import { isOrcaCloudEnvironmentId } from '@/lib/orca-cloud/orca-cloud-environment-id'
|
||||
import { agentSessionSetupFor } from '../../../../shared/agent-session/lifecycle/agent-session-setup-commands'
|
||||
import { HOST_AGENT_SIGN_IN_AGENT_NAME } from '../../../../shared/host-agent-sign-in-status'
|
||||
|
||||
const CloudChatHostContext = createContext(false)
|
||||
|
||||
/** Marks a structured chat that runs on an Orca Cloud host. */
|
||||
export function CloudChatHostProvider({
|
||||
target,
|
||||
children
|
||||
}: {
|
||||
target: RuntimeClientTarget
|
||||
children: ReactNode
|
||||
}): React.JSX.Element {
|
||||
const cloud = target.kind === 'environment' && isOrcaCloudEnvironmentId(target.environmentId)
|
||||
return <CloudChatHostContext.Provider value={cloud}>{children}</CloudChatHostContext.Provider>
|
||||
}
|
||||
|
||||
export function useCloudChatHost(): boolean {
|
||||
return useContext(CloudChatHostContext)
|
||||
}
|
||||
|
||||
/** The sign-in card's words on an Orca Cloud chat, or undefined to keep the card as it is. */
|
||||
export function cloudChatSignInContent(
|
||||
cloudHost: boolean,
|
||||
failureKind: string | undefined,
|
||||
agentName: string | undefined,
|
||||
t: Translate = translate
|
||||
): string | undefined {
|
||||
const agent = agentSessionSetupFor(agentName)?.agent
|
||||
if (!cloudHost || failureKind !== 'notSignedIn' || (agent !== 'claude' && agent !== 'codex')) {
|
||||
return undefined
|
||||
}
|
||||
return t(
|
||||
'orcaCloud.chatSignIn.renewAbove',
|
||||
'Your {{agent}} sign-in for Orca Cloud didn’t work. Renew it above, then send your message again.',
|
||||
{ agent: HOST_AGENT_SIGN_IN_AGENT_NAME[agent] }
|
||||
)
|
||||
}
|
||||
@@ -120,3 +120,28 @@ export function cloudRestartFreshModel(
|
||||
announcement: `${title} ${detail}`
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* CHAT-BANNERS B2: a structured chat needs no restart after a renewal. Its next message goes out with
|
||||
* the renewed sign-in (the proxy swaps it in per request), so "renewed" only confirms and dismisses.
|
||||
*/
|
||||
export function cloudChatRunningStripModel(
|
||||
strip: CloudRunningStrip,
|
||||
t: Translate
|
||||
): CloudStripModel {
|
||||
const model = cloudRunningStripModel(strip, t)
|
||||
if (strip.phase !== 'renewed') {
|
||||
return model
|
||||
}
|
||||
const agent = HOST_AGENT_SIGN_IN_AGENT_NAME[strip.agent]
|
||||
return {
|
||||
...model,
|
||||
detail: t('agentSignInStrip.renewedChat', 'Your next message uses it.'),
|
||||
primary: null,
|
||||
announcement: t(
|
||||
'agentSignInStrip.renewedChatAnnounce',
|
||||
'{{agent}} sign-in renewed. Your next message uses it.',
|
||||
{ agent }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -39,6 +39,7 @@ vi.mock('@/lib/agent-sign-in/agent-sign-in-gate-store', () => ({
|
||||
useAgentSignInGate: () => null
|
||||
}))
|
||||
vi.mock('@/lib/orca-cloud/orca-cloud-agent-accounts-store', () => ({
|
||||
orcaCloudAgentAccountsLoadedAt: () => 0,
|
||||
useOrcaCloudAgentAccounts: () => ({
|
||||
load: { kind: 'loading' },
|
||||
keyKinds: {},
|
||||
@@ -73,7 +74,7 @@ const { CloudStructuredChatBanners } = await import('./CloudStructuredChatBanner
|
||||
const mount = () =>
|
||||
render(
|
||||
<TooltipProvider>
|
||||
<CloudStructuredChatBanners tabId={TAB_ID} paneKey={PANE_KEY} />
|
||||
<CloudStructuredChatBanners tabId={TAB_ID} paneKey={PANE_KEY} statusKey={PANE_KEY} />
|
||||
</TooltipProvider>
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
// CHAT-BANNERS B2: RA-11's running strip for a structured chat on Orca Cloud. When the person's
|
||||
// Orca-account sign-in expires while the chat's agent runs, the chat shows "sign-in expired · Renew";
|
||||
// after Renew it confirms and dismisses. A structured chat needs no Restart: its next message goes out
|
||||
// with the renewed sign-in.
|
||||
import { useAppStore } from '@/store'
|
||||
import { useTranslate } from '@/i18n/use-translate'
|
||||
import type { HostAgentSignInAgent } from '../../../../shared/host-agent-sign-in-status'
|
||||
import { parseExecutionHostId } from '../../../../shared/execution-host'
|
||||
import { useCloudAgentHold } from '@/lib/orca-cloud/cloud-agent-launch-hold'
|
||||
import {
|
||||
orcaCloudAgentAccountsLoadedAt,
|
||||
useOrcaCloudAgentAccounts
|
||||
} from '@/lib/orca-cloud/orca-cloud-agent-accounts-store'
|
||||
import { isOrcaCloudEnvironmentId } from '@/lib/orca-cloud/orca-cloud-environment-id'
|
||||
import {
|
||||
clearCloudRunningSignout,
|
||||
cloudRunningStrip,
|
||||
useCloudRunningAccountReads,
|
||||
useCloudRunningSignoutVersion,
|
||||
useWorkspaceUsesAccount
|
||||
} from '@/lib/orca-cloud/cloud-running-agent-signout'
|
||||
import type { CloudStripActions } from './CloudAgentSignInStrip'
|
||||
import type { CloudHeldStrip } from './use-cloud-held-strip'
|
||||
import { cloudChatRunningStripModel } from './cloud-running-strip-model'
|
||||
|
||||
function openAccounts(): void {
|
||||
const store = useAppStore.getState()
|
||||
store.openSettingsTarget({ pane: 'accounts', repoId: null, sectionId: 'orca-cloud' })
|
||||
store.openSettingsPage()
|
||||
}
|
||||
|
||||
/** The Orca Cloud environment a structured chat's tab runs on, or null. */
|
||||
function useChatEnvironmentId(tabId: string): string | null {
|
||||
return useAppStore((state) => {
|
||||
for (const tabs of Object.values(state.unifiedTabsByWorktree ?? {})) {
|
||||
const tab = tabs?.find((candidate) => candidate.id === tabId)
|
||||
if (tab) {
|
||||
const host = parseExecutionHostId(tab.executionHostId)
|
||||
return host?.kind === 'runtime' ? host.environmentId : null
|
||||
}
|
||||
}
|
||||
return null
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* statusKey: the chat's agent-status key (its tab and session); holdKey: its launch-hold key. A held
|
||||
* launch shows the held strip instead.
|
||||
*/
|
||||
export function useCloudChatRunningStrip(args: {
|
||||
tabId: string
|
||||
statusKey: string
|
||||
holdKey: string
|
||||
}): CloudHeldStrip | null {
|
||||
const t = useTranslate()
|
||||
const revision = useCloudRunningSignoutVersion()
|
||||
const environmentId = useChatEnvironmentId(args.tabId)
|
||||
const cloud = environmentId !== null && isOrcaCloudEnvironmentId(environmentId)
|
||||
const entry = useAppStore((state) =>
|
||||
cloud ? (state.agentStatusByPaneKey[args.statusKey] ?? null) : null
|
||||
)
|
||||
const agent: HostAgentSignInAgent | null =
|
||||
entry?.agentType === 'claude' ? 'claude' : entry?.agentType === 'codex' ? 'codex' : null
|
||||
const running = cloud && agent !== null
|
||||
useCloudRunningAccountReads(running)
|
||||
const accounts = useOrcaCloudAgentAccounts(running)
|
||||
// D13: only a workspace that runs the agent on the person's own account (never shared or keyed).
|
||||
const credential =
|
||||
agent && accounts.load.kind === 'ready' ? accounts.load.status.credentials[agent] : null
|
||||
const expired =
|
||||
credential !== null &&
|
||||
credential.state !== 'active' &&
|
||||
credential.state !== 'expiring' &&
|
||||
credential.state !== 'none'
|
||||
const usesAccount = useWorkspaceUsesAccount(
|
||||
running ? environmentId : null,
|
||||
agent,
|
||||
expired,
|
||||
orcaCloudAgentAccountsLoadedAt()
|
||||
)
|
||||
const held = useCloudAgentHold(args.holdKey) !== null
|
||||
if (!running) {
|
||||
return null
|
||||
}
|
||||
const strip = cloudRunningStrip({
|
||||
paneKey: args.statusKey,
|
||||
entry,
|
||||
accounts,
|
||||
held,
|
||||
now: orcaCloudAgentAccountsLoadedAt(),
|
||||
usesAccount,
|
||||
revision,
|
||||
turnEndedFallback: true
|
||||
})
|
||||
if (!strip) {
|
||||
return null
|
||||
}
|
||||
const actions: CloudStripActions = {
|
||||
primary: (action) => (action.kind === 'renew' ? openAccounts() : undefined),
|
||||
submitCode: () => undefined,
|
||||
pasteCode: () => undefined,
|
||||
useCode: () => undefined,
|
||||
useApiKey: () => undefined,
|
||||
// Expired has no ×; renewed's × dismisses.
|
||||
cancel: () => (strip.phase === 'renewed' ? clearCloudRunningSignout(args.statusKey) : undefined)
|
||||
}
|
||||
return { model: cloudChatRunningStripModel(strip, t), prompt: null, actions }
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import { NativeChatVisualOwnerProvider } from './media/visuals/native-chat-visua
|
||||
import { NativeChatFileLinkExistenceProvider } from './links/actions/use-native-chat-file-link-existence'
|
||||
import { NativeChatMarkdownImageOwnerProvider } from './media/images/native-chat-markdown-image-owner'
|
||||
import { CloudChatBannerSlot } from '../agent-sign-in-strip/CloudChatBannerSlot'
|
||||
import { CloudChatHostProvider } from '../agent-sign-in-strip/cloud-chat-sign-in-notice'
|
||||
|
||||
export default function NativeChatView(props: NativeChatViewProps): React.JSX.Element {
|
||||
return (
|
||||
@@ -25,7 +26,9 @@ export default function NativeChatView(props: NativeChatViewProps): React.JSX.El
|
||||
isVisible={props.isVisible}
|
||||
sessionId={props.sessionId}
|
||||
>
|
||||
<NativeChatStructuredSession {...props} />
|
||||
<CloudChatHostProvider target={props.target}>
|
||||
<NativeChatStructuredSession {...props} />
|
||||
</CloudChatHostProvider>
|
||||
</NativeChatMarkdownImageOwnerProvider>
|
||||
</NativeChatFileLinkExistenceProvider>
|
||||
</NativeChatVisualOwnerProvider>
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import {
|
||||
cloudChatSignInContent,
|
||||
useCloudChatHost
|
||||
} from '../../../agent-sign-in-strip/cloud-chat-sign-in-notice'
|
||||
import {
|
||||
CLAUDE_MODEL_FALLBACK_COPY,
|
||||
claudeModelFallbackLabels
|
||||
@@ -87,6 +91,7 @@ export function NativeChatNoticeRow({
|
||||
const t = useTranslate()
|
||||
useTranslation()
|
||||
const orcaStopView = useNativeChatOrcaStopView()
|
||||
const cloudHost = useCloudChatHost()
|
||||
const openForkSource = useContext(NativeChatForkedFromContext)
|
||||
|
||||
if (block.presentation === PULL_REQUEST_EVENT_PRESENTATION) {
|
||||
@@ -234,6 +239,7 @@ export function NativeChatNoticeRow({
|
||||
failure?.account,
|
||||
t
|
||||
)
|
||||
const cloudSignIn = cloudChatSignInContent(cloudHost, failure?.kind, agentName, t)
|
||||
const usageLimitContinue =
|
||||
block.usageLimitTurnItemId !== undefined &&
|
||||
block.usageLimitTurnItemId === orcaStopView.usageLimitTurnItemId
|
||||
@@ -314,7 +320,7 @@ export function NativeChatNoticeRow({
|
||||
<div className="flex items-start gap-2">
|
||||
{Icon ? <Icon aria-hidden="true" className="mt-0.5 size-4 shrink-0" /> : null}
|
||||
<p className="min-w-0 flex-1 whitespace-pre-wrap break-words">
|
||||
{antigravitySignInContent ?? text}
|
||||
{cloudSignIn ?? antigravitySignInContent ?? text}
|
||||
</p>
|
||||
{continueOffered ? (
|
||||
<NativeChatInterruptedContinueButton onContinue={orcaStopView.continueNow} />
|
||||
@@ -330,7 +336,7 @@ export function NativeChatNoticeRow({
|
||||
{usageLimitContinue && orcaStopView.usageLimitAutoContinue ? (
|
||||
<NativeChatUsageLimitAutoContinue state={orcaStopView.usageLimitAutoContinue} />
|
||||
) : null}
|
||||
<NativeChatSetupButton failureKind={block.failure?.kind} />
|
||||
{cloudSignIn ? null : <NativeChatSetupButton failureKind={block.failure?.kind} />}
|
||||
{block.providerFrame || detail ? (
|
||||
<ProviderFrameRow
|
||||
block={block}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Fragment } from 'react'
|
||||
import { CloudStructuredChatBanners } from '../../../agent-sign-in-strip/CloudStructuredChatBanners'
|
||||
import { structuredCloudHoldKey } from '@/lib/orca-cloud/cloud-structured-launch-hold'
|
||||
import { structuredAgentSessionPaneKey } from '../../../../../../shared/agent-session/view/structured-agent-session-projection'
|
||||
import { MessageSquarePlus, SquareSplitVertical } from 'lucide-react'
|
||||
import { ShortcutKeyCombo } from '@/components/ShortcutKeyCombo'
|
||||
import { Button } from '@/components/ui/button'
|
||||
@@ -150,6 +151,7 @@ export function nativeChatPaneHeader(
|
||||
<CloudStructuredChatBanners
|
||||
tabId={view.tabId}
|
||||
paneKey={structuredCloudHoldKey(view.sessionId)}
|
||||
statusKey={structuredAgentSessionPaneKey(view.tabId, view.sessionId)}
|
||||
/>
|
||||
)
|
||||
const header =
|
||||
|
||||
@@ -28233,6 +28233,9 @@
|
||||
"notSetUp": "{{agent}} isn’t set up for Orca Cloud",
|
||||
"expired": "{{agent}} sign-in expired"
|
||||
},
|
||||
"chatSignIn": {
|
||||
"renewAbove": "Your {{agent}} sign-in for Orca Cloud didn’t work. Renew it above, then send your message again."
|
||||
},
|
||||
"chatHold": {
|
||||
"notSetUp": "Set up {{agent}} above to start",
|
||||
"expired": "Renew {{agent}} sign-in above to start",
|
||||
@@ -28880,6 +28883,8 @@
|
||||
"renewed": "{{agent}} sign-in renewed",
|
||||
"renewedResume": "Restart {{agent}} to pick up where you left off.",
|
||||
"renewedFresh": "Starts a new conversation.",
|
||||
"renewedChat": "Your next message uses it.",
|
||||
"renewedChatAnnounce": "{{agent}} sign-in renewed. Your next message uses it.",
|
||||
"restart": "Restart",
|
||||
"dismiss": "Dismiss",
|
||||
"renewedAnnounce": "{{agent}} sign-in renewed. Restart {{agent}} to use it.",
|
||||
|
||||
@@ -99,6 +99,38 @@ describe('cloudRunningStrip (RA-11)', () => {
|
||||
expect(strip(accounts({ state: 'active' }), RUNNING, 3_000, 'tab:d')).toBeNull()
|
||||
})
|
||||
|
||||
it('a structured chat (no turnEndedAt) clears after a clean turn by its done-since time; a pane does not', () => {
|
||||
const chat = (entry: Parameters<typeof cloudRunningStrip>[0]['entry'], paneKey: string) =>
|
||||
cloudRunningStrip({
|
||||
paneKey,
|
||||
entry,
|
||||
accounts: accounts({ state: 'active' }),
|
||||
held: false,
|
||||
now: 2_000,
|
||||
usesAccount: true,
|
||||
revision: 0,
|
||||
turnEndedFallback: true
|
||||
})
|
||||
strip(accounts({ state: 'revoked' }), RUNNING, 1_000, 'chat:a')
|
||||
expect(chat(RUNNING, 'chat:a')?.phase).toBe('renewed')
|
||||
// Done since before the renewal: that turn is the one that failed, not a recovery.
|
||||
expect(chat({ ...RUNNING, state: 'done', stateStartedAt: 1_500 }, 'chat:a')?.phase).toBe(
|
||||
'renewed'
|
||||
)
|
||||
expect(chat({ ...RUNNING, state: 'done', stateStartedAt: 3_000 }, 'chat:a')).toBeNull()
|
||||
// A terminal pane keeps needing turnEndedAt.
|
||||
strip(accounts({ state: 'revoked' }), RUNNING, 1_000, 'tab:e')
|
||||
expect(strip(accounts({ state: 'active' }), RUNNING, 2_000, 'tab:e')?.phase).toBe('renewed')
|
||||
expect(
|
||||
strip(
|
||||
accounts({ state: 'active' }),
|
||||
{ ...RUNNING, state: 'done', stateStartedAt: 3_000 },
|
||||
2_000,
|
||||
'tab:e'
|
||||
)?.phase
|
||||
).toBe('renewed')
|
||||
})
|
||||
|
||||
it('shows nothing new under the kill switch, for a held launch, or without a running account agent', () => {
|
||||
expect(
|
||||
strip(
|
||||
|
||||
@@ -74,6 +74,7 @@ export function cloudRunningStrip(args: {
|
||||
AgentStatusEntry,
|
||||
'agentType' | 'state' | 'turnEndedAt' | 'mainAgent' | 'interrupted'
|
||||
> & {
|
||||
stateStartedAt?: number
|
||||
providerSession?: unknown
|
||||
})
|
||||
| null
|
||||
@@ -90,6 +91,11 @@ export function cloudRunningStrip(args: {
|
||||
* module's memory) re-decides; the React Compiler memoizes this call on its inputs.
|
||||
*/
|
||||
revision: number
|
||||
/**
|
||||
* A structured chat's status never records turnEndedAt: its "done since" (stateStartedAt) dates
|
||||
* the clean turn end instead (CHAT-BANNERS B2).
|
||||
*/
|
||||
turnEndedFallback?: boolean
|
||||
}): CloudRunningStrip | null {
|
||||
const { paneKey, entry, accounts } = args
|
||||
const remembered = signedOut.get(paneKey)
|
||||
@@ -120,7 +126,8 @@ export function cloudRunningStrip(args: {
|
||||
if (
|
||||
entry &&
|
||||
entry.state === 'done' &&
|
||||
(entry.turnEndedAt ?? 0) > renewedAt &&
|
||||
(entry.turnEndedAt ?? (args.turnEndedFallback ? entry.stateStartedAt : undefined) ?? 0) >
|
||||
renewedAt &&
|
||||
!agentTurnEndedUncleanly(entry)
|
||||
) {
|
||||
signedOut.delete(paneKey)
|
||||
@@ -220,7 +227,7 @@ function subscribeRuntimes(listener: () => void): () => void {
|
||||
runtimesListeners.add(listener)
|
||||
if (runtimesListeners.size === 1) {
|
||||
stopRuntimesWatch =
|
||||
window.api.ephemeralVm?.onRuntimesChanged?.(() => {
|
||||
window.api?.ephemeralVm?.onRuntimesChanged?.(() => {
|
||||
runtimesRevision += 1
|
||||
for (const each of runtimesListeners) {
|
||||
each()
|
||||
|
||||
Reference in New Issue
Block a user