From 79bb08d97d8a147272956f641909a1aab8a2f122 Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 12 Nov 2026 09:50:32 -0800 Subject: [PATCH] =?UTF-8?q?feat(cloud):=20CHAT-BANNERS=20B2=20a=20running?= =?UTF-8?q?=20structured=20chat=20on=20Orca=20Cloud=20shows=20sign-in=20ex?= =?UTF-8?q?pired=20=C2=B7=20Renew,=20and=20its=20401=20card=20points=20at?= =?UTF-8?q?=20Renew?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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). --- .../CloudChatRunning.fixture.tsx | 105 +++++++++++++ .../CloudStructuredChatBanners.tsx | 14 +- .../cloud-chat-running-strip.test.tsx | 141 ++++++++++++++++++ .../cloud-chat-sign-in-notice.test.tsx | 66 ++++++++ .../cloud-chat-sign-in-notice.tsx | 47 ++++++ .../cloud-running-strip-model.ts | 25 ++++ .../cloud-structured-chat-banners.test.tsx | 3 +- .../use-cloud-chat-running-strip.ts | 108 ++++++++++++++ .../components/native-chat/NativeChatView.tsx | 5 +- .../messages/notices/NativeChatNoticeRow.tsx | 10 +- .../pane/actions/NativeChatPaneHeader.tsx | 2 + src/renderer/src/i18n/locales/en.json | 5 + .../cloud-running-agent-signout.test.ts | 32 ++++ .../orca-cloud/cloud-running-agent-signout.ts | 11 +- 14 files changed, 565 insertions(+), 9 deletions(-) create mode 100644 src/renderer/src/components/agent-sign-in-strip/CloudChatRunning.fixture.tsx create mode 100644 src/renderer/src/components/agent-sign-in-strip/cloud-chat-running-strip.test.tsx create mode 100644 src/renderer/src/components/agent-sign-in-strip/cloud-chat-sign-in-notice.test.tsx create mode 100644 src/renderer/src/components/agent-sign-in-strip/cloud-chat-sign-in-notice.tsx create mode 100644 src/renderer/src/components/agent-sign-in-strip/use-cloud-chat-running-strip.ts diff --git a/src/renderer/src/components/agent-sign-in-strip/CloudChatRunning.fixture.tsx b/src/renderer/src/components/agent-sign-in-strip/CloudChatRunning.fixture.tsx new file mode 100644 index 00000000000..34b2d65e794 --- /dev/null +++ b/src/renderer/src/components/agent-sign-in-strip/CloudChatRunning.fixture.tsx @@ -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 + +function Chat({ + phase, + card, + width +}: { + phase: 'expired' | 'renewed' | null + card: boolean + width: number +}): React.JSX.Element { + const fact = agentSessionFailureFact('notSignedIn', { account: 'system' }) + return ( + +
+
+
+ {phase ? ( + + ) : null} +
+
+
Fix the flaky auth test
+ {card ? ( + + ) : null} +
+
+ {translate( + 'components.native-chat.composer.placeholder', + 'Ask anything, @ to mention files, / for commands' + )} +
+
+
+
+ ) +} + +const fixture = (phase: 'expired' | 'renewed' | null, card: boolean, width = 760) => + defineFixture({ + width: width + 40, + store, + render: () => + }) + +/** 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) diff --git a/src/renderer/src/components/agent-sign-in-strip/CloudStructuredChatBanners.tsx b/src/renderer/src/components/agent-sign-in-strip/CloudStructuredChatBanners.tsx index 40ae6939b94..2855c360398 100644 --- a/src/renderer/src/components/agent-sign-in-strip/CloudStructuredChatBanners.tsx +++ b/src/renderer/src/components/agent-sign-in-strip/CloudStructuredChatBanners.tsx @@ -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 (
- {strip ? : null} + {shown ? : null}
) } diff --git a/src/renderer/src/components/agent-sign-in-strip/cloud-chat-running-strip.test.tsx b/src/renderer/src/components/agent-sign-in-strip/cloud-chat-running-strip.test.tsx new file mode 100644 index 00000000000..a53c70fc85f --- /dev/null +++ b/src/renderer/src/components/agent-sign-in-strip/cloud-chat-running-strip.test.tsx @@ -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()), + 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( + + + + ) + +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() + }) +}) diff --git a/src/renderer/src/components/agent-sign-in-strip/cloud-chat-sign-in-notice.test.tsx b/src/renderer/src/components/agent-sign-in-strip/cloud-chat-sign-in-notice.test.tsx new file mode 100644 index 00000000000..2128cd1eabb --- /dev/null +++ b/src/renderer/src/components/agent-sign-in-strip/cloud-chat-sign-in-notice.test.tsx @@ -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( + + + + + + ) +} + +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() + }) +}) diff --git a/src/renderer/src/components/agent-sign-in-strip/cloud-chat-sign-in-notice.tsx b/src/renderer/src/components/agent-sign-in-strip/cloud-chat-sign-in-notice.tsx new file mode 100644 index 00000000000..7da2cdc2648 --- /dev/null +++ b/src/renderer/src/components/agent-sign-in-strip/cloud-chat-sign-in-notice.tsx @@ -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 {children} +} + +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] } + ) +} diff --git a/src/renderer/src/components/agent-sign-in-strip/cloud-running-strip-model.ts b/src/renderer/src/components/agent-sign-in-strip/cloud-running-strip-model.ts index 93c9f4f14ae..449aeb18ded 100644 --- a/src/renderer/src/components/agent-sign-in-strip/cloud-running-strip-model.ts +++ b/src/renderer/src/components/agent-sign-in-strip/cloud-running-strip-model.ts @@ -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 } + ) + } +} diff --git a/src/renderer/src/components/agent-sign-in-strip/cloud-structured-chat-banners.test.tsx b/src/renderer/src/components/agent-sign-in-strip/cloud-structured-chat-banners.test.tsx index 0925868d724..2d3248d3239 100644 --- a/src/renderer/src/components/agent-sign-in-strip/cloud-structured-chat-banners.test.tsx +++ b/src/renderer/src/components/agent-sign-in-strip/cloud-structured-chat-banners.test.tsx @@ -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( - + ) diff --git a/src/renderer/src/components/agent-sign-in-strip/use-cloud-chat-running-strip.ts b/src/renderer/src/components/agent-sign-in-strip/use-cloud-chat-running-strip.ts new file mode 100644 index 00000000000..ef46a8abf49 --- /dev/null +++ b/src/renderer/src/components/agent-sign-in-strip/use-cloud-chat-running-strip.ts @@ -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 } +} diff --git a/src/renderer/src/components/native-chat/NativeChatView.tsx b/src/renderer/src/components/native-chat/NativeChatView.tsx index 335a5de869b..c5cc7ac05bd 100644 --- a/src/renderer/src/components/native-chat/NativeChatView.tsx +++ b/src/renderer/src/components/native-chat/NativeChatView.tsx @@ -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} > - + + + diff --git a/src/renderer/src/components/native-chat/messages/notices/NativeChatNoticeRow.tsx b/src/renderer/src/components/native-chat/messages/notices/NativeChatNoticeRow.tsx index 9e569b40797..57134a4a836 100644 --- a/src/renderer/src/components/native-chat/messages/notices/NativeChatNoticeRow.tsx +++ b/src/renderer/src/components/native-chat/messages/notices/NativeChatNoticeRow.tsx @@ -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({
{Icon ?