From bfd50797c383832ce09b65cd6a19e5e0f98c1553 Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 10 Nov 2026 20:07:06 -0800 Subject: [PATCH 01/32] fix(cloud): first-prompt hold says workspace, not worktree, on Orca Cloud creates (JA-25 glossary) --- .../PendingNativeChatCreation.tsx | 28 ++++++++++++++----- src/renderer/src/i18n/locales/en.json | 6 ++++ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/renderer/src/components/worktree-creation/PendingNativeChatCreation.tsx b/src/renderer/src/components/worktree-creation/PendingNativeChatCreation.tsx index 1cb9539469c..825401a4a29 100644 --- a/src/renderer/src/components/worktree-creation/PendingNativeChatCreation.tsx +++ b/src/renderer/src/components/worktree-creation/PendingNativeChatCreation.tsx @@ -29,6 +29,7 @@ import type { NativeChatMessage } from '../../../../shared/native-chat/native-ch import { deriveNativeChatRowContent } from '../../../../shared/native-chat/transcript/native-chat-row-content' import WorktreeCreationTabStrip from './WorktreeCreationTabStrip' import { WorktreeSetupSteps } from './WorktreeSetupSteps' +import { isOrcaCloudBuild } from './vm-build-steps' import { deriveWorktreeSetupSteps } from './worktree-setup-steps' import { useWorktreeCreationClock } from './worktree-creation-clock' import { getRepoMainWorktreeId } from '../../../../shared/worktree/id' @@ -84,6 +85,8 @@ export default function PendingNativeChatCreation({ const handedOff = entry?.chatInputHandedOff === true const heldMessage = entry ? pendingCreationHeldChatMessage(entry) : null const held = heldMessage !== null + // Glossary: cloud copy says workspace, never worktree (JA-25). + const cloud = entry ? isOrcaCloudBuild(entry) : false // Like t3code, progress shows only in the steps card after a send, never above the composer. const now = useWorktreeCreationClock(status === 'creating' && held) const suppressFocus = entry?.request.suppressTerminalFocusOnCompletion === true @@ -96,15 +99,25 @@ export default function PendingNativeChatCreation({ 'Opening chat…' ) : status === 'error' - ? translate( - 'auto.components.worktree.creation.PendingNativeChatCreation.sendBlockedFailed', - 'Retry creating the worktree to send' - ) - : held + ? cloud ? translate( - 'auto.components.worktree.creation.PendingNativeChatCreation.sendBlockedHeld', - 'Sends when the worktree is ready' + 'components.worktreeCreation.pendingNativeChat.sendBlockedFailedCloud', + 'Retry creating the workspace to send' ) + : translate( + 'auto.components.worktree.creation.PendingNativeChatCreation.sendBlockedFailed', + 'Retry creating the worktree to send' + ) + : held + ? cloud + ? translate( + 'components.worktreeCreation.pendingNativeChat.sendBlockedHeldCloud', + 'Sends when the workspace is ready' + ) + : translate( + 'auto.components.worktree.creation.PendingNativeChatCreation.sendBlockedHeld', + 'Sends when the worktree is ready' + ) : undefined return { capturePresentation: () => () => true, @@ -147,6 +160,7 @@ export default function PendingNativeChatCreation({ runtimeEnvironmentId: null } }, [ + cloud, creationId, handedOff, held, diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index 3193a98dc26..aa4242fd021 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -23622,6 +23622,12 @@ "cloudWorkspaces": { "emptyMineStartBody": "Start one and it keeps running while your laptop sleeps.", "newCloudWorkspace": "New cloud workspace" + }, + "worktreeCreation": { + "pendingNativeChat": { + "sendBlockedFailedCloud": "Retry creating the workspace to send", + "sendBlockedHeldCloud": "Sends when the workspace is ready" + } } }, "dashboardPopout": { From 01fafa1fe5d3109fab23d6e81464703b353e0f25 Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 10 Nov 2026 20:14:09 -0800 Subject: [PATCH 02/32] test(cloud): glossary string lint for Orca Cloud surfaces (design-squad spec); 'Claude' not 'Claude Code' in MCP sync (JA-25) --- .../cloud-mcp/cloud-mcp-sync-copy.ts | 2 +- .../src/i18n/en-runtime-required.json | 1 + .../orca-cloud/cloud-glossary-allowlist.json | 9 + .../orca-cloud/cloud-glossary-lint.test.ts | 185 ++++++++++++++++++ 4 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 src/renderer/src/lib/orca-cloud/cloud-glossary-allowlist.json create mode 100644 src/renderer/src/lib/orca-cloud/cloud-glossary-lint.test.ts diff --git a/src/renderer/src/components/settings/runtime-environments/cloud-mcp/cloud-mcp-sync-copy.ts b/src/renderer/src/components/settings/runtime-environments/cloud-mcp/cloud-mcp-sync-copy.ts index 3f1fbd77de1..efe62bf195f 100644 --- a/src/renderer/src/components/settings/runtime-environments/cloud-mcp/cloud-mcp-sync-copy.ts +++ b/src/renderer/src/components/settings/runtime-environments/cloud-mcp/cloud-mcp-sync-copy.ts @@ -28,7 +28,7 @@ export function mcpSyncSummary(status: McpSyncStatus, t: Translate = translate): if (status.rows.length === 0) { return t( 'cloudMcpSync.summary.none', - 'None found in Claude Code or Codex on this computer. Servers you add there show up here.' + 'None found in Claude or Codex on this computer. Servers you add there show up here.' ) } if (status.error === 'host-outdated' && status.lastSyncedAt === null) { diff --git a/src/renderer/src/i18n/en-runtime-required.json b/src/renderer/src/i18n/en-runtime-required.json index 671c08689c0..501157fa702 100644 --- a/src/renderer/src/i18n/en-runtime-required.json +++ b/src/renderer/src/i18n/en-runtime-required.json @@ -1525,6 +1525,7 @@ "found": "{{count}} found", "found_one": "{{count}} found", "found_other": "{{count}} found", + "none": "None found in Claude Code or Codex on this computer. Servers you add there show up here.", "notSynced": "{{count}} found, not synced yet", "notSynced_one": "{{count}} found, not synced yet", "notSynced_other": "{{count}} found, not synced yet", diff --git a/src/renderer/src/lib/orca-cloud/cloud-glossary-allowlist.json b/src/renderer/src/lib/orca-cloud/cloud-glossary-allowlist.json new file mode 100644 index 00000000000..d1541f22e7c --- /dev/null +++ b/src/renderer/src/lib/orca-cloud/cloud-glossary-allowlist.json @@ -0,0 +1,9 @@ +[ + { "path": "src/renderer/src/components/cloud-environment/EnvironmentForm.tsx", "line": 127, "term": "container", "reason": "\"dev container\" is the Dev Containers spec name (an import source), not the sandbox." }, + { "path": "src/renderer/src/components/settings/virtual-machines/runtimes/CloudVmSetupGuide.tsx", "line": 20, "term": "VM", "reason": "BYOC / recipe-VM settings (Custom environments), where the glossary allows VM." }, + { "path": "src/renderer/src/components/worktree-creation/VmBuildFailureActions.tsx", "line": 365, "term": "VM", "reason": "Recipe-VM branch; the Orca Cloud branch says \"Delete sandbox\"." }, + { "path": "src/renderer/src/components/worktree-creation/VmBuildFailureCard.tsx", "line": 143, "term": "VM", "reason": "Recipe-VM branch; Orca Cloud renders BlockedSandboxHoursNote instead." }, + { "path": "src/renderer/src/components/worktree-creation/VmDeleteConfirmDialog.tsx", "line": 38, "term": "VM", "reason": "Recipe-VM branch; the Orca Cloud branch says \"Delete this sandbox?\"." }, + { "path": "src/renderer/src/components/worktree-creation/VmDeleteConfirmDialog.tsx", "line": 49, "term": "VM", "reason": "Recipe-VM branch; the Orca Cloud branch says the sandbox is deleted." }, + { "path": "src/renderer/src/components/worktree-creation/VmDeleteConfirmDialog.tsx", "line": 63, "term": "VM", "reason": "Recipe-VM branch; the Orca Cloud branch says \"Delete sandbox\"." } +] diff --git a/src/renderer/src/lib/orca-cloud/cloud-glossary-lint.test.ts b/src/renderer/src/lib/orca-cloud/cloud-glossary-lint.test.ts new file mode 100644 index 00000000000..25f028b1897 --- /dev/null +++ b/src/renderer/src/lib/orca-cloud/cloud-glossary-lint.test.ts @@ -0,0 +1,185 @@ +// Cloud glossary lint (design-squad spec, JA-25): user-visible strings on Orca Cloud surfaces must +// use the glossary's words (.context/cloud/specs/glossary.md). Scans translate()/t() fallbacks, +// i18n plural defaults, JSX text and user-facing JSX attributes; never identifiers or imports. +import { readFileSync } from 'node:fs' +import path from 'node:path' +import ts from 'typescript-api' +import { globSync } from 'glob' +import { describe, expect, it } from 'vitest' +import allowlist from './cloud-glossary-allowlist.json' + +const ROOT = path.resolve(__dirname, '../../../../..') + +const SCOPE = [ + 'src/renderer/src/components/**/{orca-cloud,cloud,billing,hosted-sandbox}*/**/*.{ts,tsx}', + 'src/renderer/src/components/settings/**/{OrcaCloud,Cloud,PlanBilling,AgentAccounts,Accounts}*.tsx', + 'src/renderer/src/components/worktree-creation/Vm*.tsx', + 'src/renderer/src/components/worktree-creation/*Cloud*.tsx', + 'src/renderer/src/lib/*cloud*.ts', + 'mobile/src/**/*{Cloud,cloud}*.tsx' +] +const EXCLUDE = ['**/__tests__/**', '**/*.test.*', '**/*.fixture.tsx', '**/*.stories.tsx'] + +type Rule = { term: string; pattern: RegExp; use: string; row: string } + +const RULES: Rule[] = [ + { term: 'VM', pattern: /\bVMs?\b|virtual machine/i, use: 'sandbox', row: 'The machine' }, + { term: 'worktree', pattern: /\bworktrees?\b/i, use: 'workspace', row: 'Unit of work' }, + { term: 'Claude Code', pattern: /\bClaude Code\b/i, use: 'Claude', row: 'Agent source' }, + { term: 'suspend', pattern: /\bsuspend(ed|s|ing)?\b/i, use: 'asleep / go to sleep', row: 'Lifecycle verbs' }, + { term: 'hibernate', pattern: /\bhibernat/i, use: 'asleep / go to sleep', row: 'Lifecycle verbs' }, + { + term: 'per hour', + pattern: /\/hr\b|\$\d+(\.\d+)?\/hour|(? span.literal.text)].join(' ') + } + return null +} + +/** User-visible strings in one file, with their 1-based lines. */ +export function visibleStrings(file: string, source: string): { line: number; text: string }[] { + const sf = ts.createSourceFile(file, source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX) + const out: { line: number; text: string }[] = [] + const push = (node: ts.Node, text: string | null): void => { + if (text && /[A-Za-z]/.test(text)) { + out.push({ line: sf.getLineAndCharacterOfPosition(node.getStart(sf)).line + 1, text }) + } + } + const visit = (node: ts.Node): void => { + if (ts.isJsxText(node)) { + push(node, node.text.trim()) + } else if (ts.isJsxAttribute(node) && node.initializer) { + const name = node.name.getText(sf) + if (TEXT_ATTRIBUTES.has(name)) { + const init = node.initializer + push( + init, + ts.isJsxExpression(init) && init.expression + ? stringValue(init.expression) + : stringValue(init) + ) + } + } else if (ts.isCallExpression(node)) { + const callee = node.expression + const name = ts.isIdentifier(callee) + ? callee.text + : ts.isPropertyAccessExpression(callee) + ? callee.name.text + : '' + if (TRANSLATE_CALLEES.has(name) && node.arguments.length >= 2) { + push(node.arguments[1], stringValue(node.arguments[1])) + const options = node.arguments[2] + if (options && ts.isObjectLiteralExpression(options)) { + for (const prop of options.properties) { + if ( + ts.isPropertyAssignment(prop) && + /^defaultValue/.test(prop.name.getText(sf).replace(/['"]/g, '')) + ) { + push(prop.initializer, stringValue(prop.initializer)) + } + } + } + } + } + ts.forEachChild(node, visit) + } + visit(sf) + return out +} + +function scopeFiles(): string[] { + return [...new Set(SCOPE.flatMap((g) => globSync(g, { cwd: ROOT, ignore: EXCLUDE })))].sort() +} + +function findHits(): Hit[] { + const hits: Hit[] = [] + for (const file of scopeFiles()) { + const source = readFileSync(path.join(ROOT, file), 'utf8') + for (const { line, text } of visibleStrings(file, source)) { + for (const rule of RULES) { + if (rule.pattern.test(text)) { + hits.push({ file, line, term: rule.term, text, rule }) + } + } + } + } + return hits +} + +const ALLOW = allowlist as AllowEntry[] +const allowKey = (e: { path: string; line: number; term: string }): string => + `${e.path}:${e.line}:${e.term}` + +describe('cloud glossary lint', () => { + const hits = findHits() + + it('scans a real scope', () => { + expect(scopeFiles().length).toBeGreaterThan(20) + }) + + it('every allowlist entry has a reason and still matches a string', () => { + const live = new Set(hits.map((h) => allowKey({ path: h.file, line: h.line, term: h.term }))) + const problems = ALLOW.filter((e) => !e.reason?.trim() || !live.has(allowKey(e))).map( + (e) => `stale or unexplained allowlist entry: ${allowKey(e)}` + ) + expect(problems).toEqual([]) + }) + + it('cloud strings use glossary words', () => { + const allowed = new Set(ALLOW.map(allowKey)) + const failures = hits + .filter((h) => !allowed.has(allowKey({ path: h.file, line: h.line, term: h.term }))) + .map( + (h) => + `cloud glossary: "${h.term}" at ${h.file}:${h.line}; use "${h.rule.use}" (glossary row: ${h.rule.row}). ` + + `Allowlist with a reason only if this string is not shown in Orca Cloud. Text: ${JSON.stringify(h.text.slice(0, 120))}` + ) + expect(failures).toEqual([]) + }) +}) From 6902aba99c9348ac074f36ff4476da8251159079 Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 10 Nov 2026 20:18:22 -0800 Subject: [PATCH 03/32] test(cloud): glossary lint scans every copy literal + vm-*.ts copy tables; Claude not Claude Code in MCP panel; Dev Container; recipe 'VM is running until you choose' (design-squad rulings) --- .../cloud-environment/EnvironmentForm.tsx | 2 +- .../cloud-mcp/CloudMcpSyncPanel.tsx | 3 +- .../worktree-creation/VmBuildFailureCard.tsx | 4 +- .../src/i18n/en-runtime-required.json | 4 + src/renderer/src/i18n/locales/en.json | 3 +- .../orca-cloud/cloud-glossary-allowlist.json | 133 +++++++++++++++++- .../orca-cloud/cloud-glossary-lint.test.ts | 69 ++++++++- 7 files changed, 204 insertions(+), 14 deletions(-) diff --git a/src/renderer/src/components/cloud-environment/EnvironmentForm.tsx b/src/renderer/src/components/cloud-environment/EnvironmentForm.tsx index fc7fb97d2fc..c31b1d202ec 100644 --- a/src/renderer/src/components/cloud-environment/EnvironmentForm.tsx +++ b/src/renderer/src/components/cloud-environment/EnvironmentForm.tsx @@ -124,7 +124,7 @@ export function EnvironmentForm({ {t( 'cloudEnvironment.form.importHint', - 'Reads Conductor and dev container setup from a local project.' + 'Reads Conductor and Dev Container setup from a local project.' )} {importProjects.map((project) => ( diff --git a/src/renderer/src/components/settings/runtime-environments/cloud-mcp/CloudMcpSyncPanel.tsx b/src/renderer/src/components/settings/runtime-environments/cloud-mcp/CloudMcpSyncPanel.tsx index ef2ecb15032..d6ffb508ff8 100644 --- a/src/renderer/src/components/settings/runtime-environments/cloud-mcp/CloudMcpSyncPanel.tsx +++ b/src/renderer/src/components/settings/runtime-environments/cloud-mcp/CloudMcpSyncPanel.tsx @@ -22,7 +22,8 @@ import { mcpSyncTimeLabel } from './cloud-mcp-sync-copy' -const AGENT_LABEL = { claude: 'Claude Code', codex: 'Codex' } as const +// Glossary: the catalog name is "Claude", never "Claude Code". +const AGENT_LABEL = { claude: 'Claude', codex: 'Codex' } as const export type CloudMcpSyncPanelProps = { status: McpSyncStatus diff --git a/src/renderer/src/components/worktree-creation/VmBuildFailureCard.tsx b/src/renderer/src/components/worktree-creation/VmBuildFailureCard.tsx index dc7e71887db..68b455047af 100644 --- a/src/renderer/src/components/worktree-creation/VmBuildFailureCard.tsx +++ b/src/renderer/src/components/worktree-creation/VmBuildFailureCard.tsx @@ -133,8 +133,8 @@ export function VmBuildFailureCard({ ) : (

{t( - 'auto.components.worktree.creation.VmBuildFailureCard.stillRunningLocal', - 'The VM is running and using hours until you choose.' + 'auto.components.worktree.creation.VmBuildFailureCard.stillRunningLocal2', + 'The VM is running until you choose.' )}

) diff --git a/src/renderer/src/i18n/en-runtime-required.json b/src/renderer/src/i18n/en-runtime-required.json index 501157fa702..181e3d98c3e 100644 --- a/src/renderer/src/i18n/en-runtime-required.json +++ b/src/renderer/src/i18n/en-runtime-required.json @@ -1357,6 +1357,7 @@ "checksCountTitleVm_other": "The VM is up, but {{count}} environment checks failed", "memberLimitBodyCount_one": "You can run {{count}} sandbox at once. Put it to sleep or delete it, then try again. Nothing was created, and you weren’t charged.", "memberLimitBodyCount_other": "You can run {{count}} sandboxes at once. Put one to sleep or delete it, then try again. Nothing was created, and you weren’t charged.", + "stillRunningLocal": "The VM is running and using hours until you choose.", "teamLimitBodyCount_one": "Your team can run {{count}} sandbox at once ({{value1}} per seat). Put it to sleep or delete it, then try again. Nothing was created, and you weren’t charged.", "teamLimitBodyCount_other": "Your team can run {{count}} sandboxes at once ({{value1}} per seat). Put one to sleep or delete it, then try again. Nothing was created, and you weren’t charged." }, @@ -1513,6 +1514,9 @@ } }, "cloudEnvironment": { + "form": { + "importHint": "Reads Conductor and dev container setup from a local project." + }, "staleness": { "branchMovedInRepo_one": "{{branch}} in {{repo}} is {{count}} commit ahead of build #{{number}}", "branchMovedInRepo_other": "{{branch}} in {{repo}} is {{count}} commits ahead of build #{{number}}", diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index aa4242fd021..b1a84bc6961 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -4313,7 +4313,8 @@ "startAgain": "Start again", "cloudUnusableTitle": "This sandbox can’t open your workspace", "cloudUnusableDeletedBody": "The sandbox was deleted. Start again to try a new one.", - "cloudUnusableBody": "Start again on a new sandbox, or delete this one." + "cloudUnusableBody": "Start again on a new sandbox, or delete this one.", + "stillRunningLocal2": "The VM is running until you choose." }, "VmBuildLog": { "jumpToError": "Jump to first error", diff --git a/src/renderer/src/lib/orca-cloud/cloud-glossary-allowlist.json b/src/renderer/src/lib/orca-cloud/cloud-glossary-allowlist.json index d1541f22e7c..5f7f7951cc3 100644 --- a/src/renderer/src/lib/orca-cloud/cloud-glossary-allowlist.json +++ b/src/renderer/src/lib/orca-cloud/cloud-glossary-allowlist.json @@ -1,9 +1,128 @@ [ - { "path": "src/renderer/src/components/cloud-environment/EnvironmentForm.tsx", "line": 127, "term": "container", "reason": "\"dev container\" is the Dev Containers spec name (an import source), not the sandbox." }, - { "path": "src/renderer/src/components/settings/virtual-machines/runtimes/CloudVmSetupGuide.tsx", "line": 20, "term": "VM", "reason": "BYOC / recipe-VM settings (Custom environments), where the glossary allows VM." }, - { "path": "src/renderer/src/components/worktree-creation/VmBuildFailureActions.tsx", "line": 365, "term": "VM", "reason": "Recipe-VM branch; the Orca Cloud branch says \"Delete sandbox\"." }, - { "path": "src/renderer/src/components/worktree-creation/VmBuildFailureCard.tsx", "line": 143, "term": "VM", "reason": "Recipe-VM branch; Orca Cloud renders BlockedSandboxHoursNote instead." }, - { "path": "src/renderer/src/components/worktree-creation/VmDeleteConfirmDialog.tsx", "line": 38, "term": "VM", "reason": "Recipe-VM branch; the Orca Cloud branch says \"Delete this sandbox?\"." }, - { "path": "src/renderer/src/components/worktree-creation/VmDeleteConfirmDialog.tsx", "line": 49, "term": "VM", "reason": "Recipe-VM branch; the Orca Cloud branch says the sandbox is deleted." }, - { "path": "src/renderer/src/components/worktree-creation/VmDeleteConfirmDialog.tsx", "line": 63, "term": "VM", "reason": "Recipe-VM branch; the Orca Cloud branch says \"Delete sandbox\"." } + { + "path": "src/renderer/src/components/cloud-environment/EnvironmentForm.tsx", + "line": 127, + "term": "container", + "reason": "Dev Containers spec name" + }, + { + "path": "src/renderer/src/components/settings/virtual-machines/runtimes/CloudVmSetupGuide.tsx", + "line": 20, + "term": "VM", + "reason": "BYOC recipe VMs (experimental), not Orca Cloud" + }, + { + "path": "src/renderer/src/components/worktree-creation/VmBuildFailureActions.tsx", + "line": 365, + "term": "VM", + "reason": "recipe-VM branch; cloud branch says sandbox" + }, + { + "path": "src/renderer/src/components/worktree-creation/VmBuildFailureCard.tsx", + "line": 143, + "term": "VM", + "reason": "recipe-VM branch; cloud branch says sandbox" + }, + { + "path": "src/renderer/src/components/worktree-creation/VmDeleteConfirmDialog.tsx", + "line": 38, + "term": "VM", + "reason": "recipe-VM branch; cloud branch says sandbox" + }, + { + "path": "src/renderer/src/components/worktree-creation/VmDeleteConfirmDialog.tsx", + "line": 49, + "term": "VM", + "reason": "recipe-VM branch; cloud branch says sandbox" + }, + { + "path": "src/renderer/src/components/worktree-creation/VmDeleteConfirmDialog.tsx", + "line": 63, + "term": "VM", + "reason": "recipe-VM branch; cloud branch says sandbox" + }, + { + "path": "src/renderer/src/components/worktree-creation/vm-build-failure-copy.ts", + "line": 85, + "term": "VM", + "reason": "recipe-VM branch; cloud branch says sandbox" + }, + { + "path": "src/renderer/src/components/worktree-creation/vm-build-failure-copy.ts", + "line": 89, + "term": "VM", + "reason": "recipe-VM branch; cloud branch says sandbox" + }, + { + "path": "src/renderer/src/components/worktree-creation/vm-build-failure-copy.ts", + "line": 92, + "term": "VM", + "reason": "recipe-VM branch; cloud branch says sandbox" + }, + { + "path": "src/renderer/src/components/worktree-creation/vm-build-recipe-failure-copy.ts", + "line": 15, + "term": "VM", + "reason": "recipe-VM branch; cloud branch says sandbox" + }, + { + "path": "src/renderer/src/components/worktree-creation/vm-build-recipe-failure-copy.ts", + "line": 19, + "term": "VM", + "reason": "recipe-VM branch; cloud branch says sandbox" + }, + { + "path": "src/renderer/src/components/worktree-creation/vm-build-recipe-failure-copy.ts", + "line": 25, + "term": "VM", + "reason": "recipe-VM branch; cloud branch says sandbox" + }, + { + "path": "src/renderer/src/components/worktree-creation/vm-build-recipe-failure-copy.ts", + "line": 29, + "term": "VM", + "reason": "recipe-VM branch; cloud branch says sandbox" + }, + { + "path": "src/renderer/src/components/worktree-creation/vm-build-sheet-copy.ts", + "line": 10, + "term": "VM", + "reason": "recipe-VM branch; cloud branch says sandbox" + }, + { + "path": "src/renderer/src/components/worktree-creation/vm-build-sheet-copy.ts", + "line": 69, + "term": "VM", + "reason": "recipe-VM branch; cloud branch says sandbox" + }, + { + "path": "src/renderer/src/components/worktree-creation/vm-build-sheet-copy.ts", + "line": 74, + "term": "VM", + "reason": "recipe-VM branch; cloud branch says sandbox" + }, + { + "path": "src/renderer/src/components/worktree-creation/vm-build-sheet-copy.ts", + "line": 79, + "term": "VM", + "reason": "recipe-VM branch; cloud branch says sandbox" + }, + { + "path": "src/renderer/src/components/worktree-creation/vm-build-sheet-copy.ts", + "line": 84, + "term": "VM", + "reason": "recipe-VM branch; cloud branch says sandbox" + }, + { + "path": "src/renderer/src/components/orca-cloud/use-cloud-terminal-error-override.ts", + "line": 13, + "term": "VM", + "reason": "Matcher for older builds' saved terminal errors so they stay hidden; never displayed" + }, + { + "path": "src/renderer/src/components/orca-cloud/use-cloud-terminal-error-override.ts", + "line": 14, + "term": "VM", + "reason": "Matcher for older builds' saved terminal errors so they stay hidden; never displayed" + } ] diff --git a/src/renderer/src/lib/orca-cloud/cloud-glossary-lint.test.ts b/src/renderer/src/lib/orca-cloud/cloud-glossary-lint.test.ts index 25f028b1897..f89e041067f 100644 --- a/src/renderer/src/lib/orca-cloud/cloud-glossary-lint.test.ts +++ b/src/renderer/src/lib/orca-cloud/cloud-glossary-lint.test.ts @@ -15,6 +15,8 @@ const SCOPE = [ 'src/renderer/src/components/settings/**/{OrcaCloud,Cloud,PlanBilling,AgentAccounts,Accounts}*.tsx', 'src/renderer/src/components/worktree-creation/Vm*.tsx', 'src/renderer/src/components/worktree-creation/*Cloud*.tsx', + // Copy tables behind the Vm* components (design-squad scope fix). + 'src/renderer/src/components/worktree-creation/vm-*.ts', 'src/renderer/src/lib/*cloud*.ts', 'mobile/src/**/*{Cloud,cloud}*.tsx' ] @@ -82,6 +84,58 @@ function stringValue(node: ts.Node): string | null { return null } +const SKIP_ATTRIBUTES = /^(className|class|id|key|testId|data-.*|href|src|role|type|name|variant|size|side|align)$/ +const SKIP_PROPERTIES = /^(className|id|key|testId|kind|type|variant|status|state|icon|href|path|url|pane|section|sectionId)$/ + +/** A string literal that could be user-visible copy: has a space, isn't a key, import or styling. */ +function isCopyLiteral(node: ts.Node): boolean { + if ( + !ts.isStringLiteral(node) && + !ts.isNoSubstitutionTemplateLiteral(node) && + !ts.isTemplateExpression(node) + ) { + return false + } + const text = stringValue(node) ?? '' + if (!/\s/.test(text.trim()) || !/[A-Za-z]/.test(text)) { + return false // pure identifiers, ids and paths + } + const parent = node.parent + if ( + ts.isImportDeclaration(parent) || + ts.isExportDeclaration(parent) || + ts.isExternalModuleReference(parent) || + ts.isLiteralTypeNode(parent) + ) { + return false + } + if (ts.isPropertyAssignment(parent) && parent.name === node) { + return false // object keys + } + if (ts.isPropertyAssignment(parent) && SKIP_PROPERTIES.test(parent.name.getText().replace(/['"]/g, ''))) { + return false + } + const attr = ts.isJsxAttribute(parent) + ? parent + : ts.isJsxExpression(parent) && ts.isJsxAttribute(parent.parent) + ? parent.parent + : null + if (attr && SKIP_ATTRIBUTES.test(attr.name.getText())) { + return false + } + // cn()/clsx() class lists and translation keys (the first argument of t()). + if (ts.isCallExpression(parent)) { + const callee = parent.expression.getText() + if (/^(cn|clsx|cva|twMerge)$/.test(callee)) { + return false + } + if (TRANSLATE_CALLEES.has(callee.split('.').pop() ?? '') && parent.arguments[0] === node) { + return false + } + } + return true +} + /** User-visible strings in one file, with their 1-based lines. */ export function visibleStrings(file: string, source: string): { line: number; text: string }[] { const sf = ts.createSourceFile(file, source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX) @@ -92,7 +146,10 @@ export function visibleStrings(file: string, source: string): { line: number; te } } const visit = (node: ts.Node): void => { - if (ts.isJsxText(node)) { + if (isCopyLiteral(node)) { + // Copy tables, object-literal values and template parts: anywhere these terms can hide. + push(node, stringValue(node)) + } else if (ts.isJsxText(node)) { push(node, node.text.trim()) } else if (ts.isJsxAttribute(node) && node.initializer) { const name = node.name.getText(sf) @@ -130,7 +187,15 @@ export function visibleStrings(file: string, source: string): { line: number; te ts.forEachChild(node, visit) } visit(sf) - return out + const seen = new Set() + return out.filter((entry) => { + const key = `${entry.line}:${entry.text}` + if (seen.has(key)) { + return false + } + seen.add(key) + return true + }) } function scopeFiles(): string[] { From a7e46748b02def1d12fff80c71add227cb41ea61 Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 10 Nov 2026 20:20:42 -0800 Subject: [PATCH 04/32] test(cloud): assert the legacy 'VM' sleep-error patterns are never rendered (glossary allowlist guard) --- .../use-cloud-terminal-error-override.test.tsx | 14 ++++++++++++++ .../lib/orca-cloud/cloud-glossary-allowlist.json | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/components/orca-cloud/use-cloud-terminal-error-override.test.tsx b/src/renderer/src/components/orca-cloud/use-cloud-terminal-error-override.test.tsx index 1269ffd960e..72562a2a0be 100644 --- a/src/renderer/src/components/orca-cloud/use-cloud-terminal-error-override.test.tsx +++ b/src/renderer/src/components/orca-cloud/use-cloud-terminal-error-override.test.tsx @@ -73,4 +73,18 @@ describe('terminal error toast on an Orca Cloud workspace that sleeps', () => { const unrelated = render(toast('ws', 'spawn failed: ENOENT')) expect(unrelated.container.querySelector('[data-terminal-error-toast]')).not.toBeNull() }) + + // Glossary lint allowlists these two "VM" match patterns because they are never rendered. If + // that ever changes, this fails before the banned word reaches a cloud user. + it('never renders the legacy "VM" sleep errors it matches (glossary allowlist)', () => { + seed('sleeping') + for (const error of [ + "This workspace's VM is asleep", + "This workspace's VM could not wake up" + ]) { + const { container, unmount } = render(toast('ws', error)) + expect(container.textContent).not.toMatch(/\bVM\b/) + unmount() + } + }) }) diff --git a/src/renderer/src/lib/orca-cloud/cloud-glossary-allowlist.json b/src/renderer/src/lib/orca-cloud/cloud-glossary-allowlist.json index 5f7f7951cc3..e39cfa66bfd 100644 --- a/src/renderer/src/lib/orca-cloud/cloud-glossary-allowlist.json +++ b/src/renderer/src/lib/orca-cloud/cloud-glossary-allowlist.json @@ -117,12 +117,12 @@ "path": "src/renderer/src/components/orca-cloud/use-cloud-terminal-error-override.ts", "line": 13, "term": "VM", - "reason": "Matcher for older builds' saved terminal errors so they stay hidden; never displayed" + "reason": "match pattern for older builds' saved terminal errors; never rendered" }, { "path": "src/renderer/src/components/orca-cloud/use-cloud-terminal-error-override.ts", "line": 14, "term": "VM", - "reason": "Matcher for older builds' saved terminal errors so they stay hidden; never displayed" + "reason": "match pattern for older builds' saved terminal errors; never rendered" } ] From c5725b02c3384ce885cde8bb384c1620d67e4ee1 Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 10 Nov 2026 20:36:37 -0800 Subject: [PATCH 05/32] fix(cloud-auth): Cancel always ends a pending Orca sign-in; a second click replaces it; calm timeout (JA-02) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Main: Cancel aborts the attempt at any stage and clears progress at once; a newer sign-in cancels the older one (its loopback listener closes); sign-out cancels a pending sign-in; a timeout says 'Sign-in didn't finish. Try again.' instead of an error toast. - Setup page: a cancelled/timed-out/replaced sign-in no longer falls back to opening a second sign-in (the root cause of the stuck 'Signing in…'); the waiting row has Cancel; Back cancels a sign-in the page started. - Sign in buttons stay clickable while a sign-in is pending. --- .../orca-profile-auth-status-broadcast.ts | 6 +- .../orca-profiles/profile-cloud-pkce.test.ts | 59 +++++- src/main/orca-profiles/profile-cloud-pkce.ts | 18 +- ...file-cloud-service-connect-overlap.test.ts | 5 +- ...ofile-cloud-service-sign-in-cancel.test.ts | 168 ++++++++++++++++++ .../orca-profiles/profile-cloud-service.ts | 36 ++-- .../profile-cloud-sign-in-progress.test.ts | 73 ++++++++ .../profile-cloud-sign-in-progress.ts | 42 ++++- src/preload/api/orca-profile-api.ts | 4 +- src/preload/api/orca-profiles-bridge.ts | 10 +- .../src/components/OrcaSignInProgress.tsx | 67 +++---- .../billing/checkout/use-checkout-flow.ts | 2 +- .../orca-cloud-setup/CloudSetupPage.tsx | 28 ++- .../orca-cloud-setup/use-cloud-setup-flow.ts | 55 +++++- .../orca-profile-auth-ipc-bridge.test.ts | 30 +++- .../orca-profile-auth-ipc-bridge.ts | 8 +- src/renderer/src/i18n/locales/en.json | 12 +- .../orca-cloud/cloud-setup-session-seam.ts | 14 +- .../orca-cloud/cloud-setup-session.test.ts | 4 + .../src/lib/orca-cloud/cloud-setup-session.ts | 14 +- .../create-orca-profiles-slice.ts | 4 + .../orca-profiles-auth-actions.ts | 8 +- src/shared/orca-profiles.ts | 3 + 23 files changed, 578 insertions(+), 92 deletions(-) create mode 100644 src/main/orca-profiles/profile-cloud-service-sign-in-cancel.test.ts create mode 100644 src/main/orca-profiles/profile-cloud-sign-in-progress.test.ts diff --git a/src/main/ipc/profiles/orca-profile-auth-status-broadcast.ts b/src/main/ipc/profiles/orca-profile-auth-status-broadcast.ts index efee902a662..b88fc0aa0b6 100644 --- a/src/main/ipc/profiles/orca-profile-auth-status-broadcast.ts +++ b/src/main/ipc/profiles/orca-profile-auth-status-broadcast.ts @@ -2,6 +2,7 @@ import { BrowserWindow } from 'electron' import { ORCA_PROFILE_AUTH_STATUS_CHANGED_CHANNEL, ORCA_PROFILE_SIGN_IN_PROGRESS_CHANGED_CHANNEL, + type OrcaCloudSignInEnd, type OrcaCloudSignInProgress } from '../../../shared/orca-profiles' @@ -23,7 +24,8 @@ export function broadcastOrcaProfileAuthStatusChanged(): void { } export function broadcastOrcaProfileSignInProgressChanged( - progress: OrcaCloudSignInProgress | null + progress: OrcaCloudSignInProgress | null, + end?: OrcaCloudSignInEnd ): void { - broadcast(ORCA_PROFILE_SIGN_IN_PROGRESS_CHANGED_CHANNEL, progress) + broadcast(ORCA_PROFILE_SIGN_IN_PROGRESS_CHANGED_CHANNEL, progress, end ?? null) } diff --git a/src/main/orca-profiles/profile-cloud-pkce.test.ts b/src/main/orca-profiles/profile-cloud-pkce.test.ts index ca13f97a480..747b3bb3843 100644 --- a/src/main/orca-profiles/profile-cloud-pkce.test.ts +++ b/src/main/orca-profiles/profile-cloud-pkce.test.ts @@ -6,7 +6,11 @@ import { afterEach, describe, expect, it, vi } from 'vitest' vi.mock('electron', () => ({ app: { isPackaged: false }, shell: { openExternal: vi.fn() } })) import type { OrcaCloudAuthConfig } from './profile-cloud-auth-config' -import { beginOrcaCloudPkceFlow } from './profile-cloud-pkce' +import { + beginOrcaCloudPkceFlow, + ORCA_CLOUD_SIGN_IN_TIMEOUT_MS, + orcaCloudSignInTimeoutMs +} from './profile-cloud-pkce' const base = 'https://auth.test' const config: OrcaCloudAuthConfig = { @@ -27,6 +31,7 @@ const config: OrcaCloudAuthConfig = { afterEach(() => { delete process.env.ORCA_CLOUD_DEV_OPEN_URL_FILE + delete process.env.ORCA_CLOUD_SIGN_IN_TIMEOUT_MS }) describe('PKCE loopback for cloud setup', () => { @@ -76,3 +81,55 @@ describe('PKCE loopback for cloud setup', () => { expect((await browser).status).toBe(200) }) }) + +describe('PKCE loopback cancel and timeout', () => { + async function start(signal?: AbortSignal): Promise<{ + flow: Promise + redirect: URL + }> { + process.env.ORCA_CLOUD_DEV_OPEN_URL_FILE = join(mkdtempSync(join(tmpdir(), 'pkce-')), 'urls') + let authorize = '' + const flow = beginOrcaCloudPkceFlow(config, 'profile-1', { + onAuthorizeUrl: (url) => (authorize = url), + ...(signal ? { signal } : {}) + }) + flow.catch(() => undefined) + await vi.waitFor(() => expect(authorize).not.toBe('')) + return { flow, redirect: new URL(new URL(authorize).searchParams.get('redirect_uri')!) } + } + + it('Cancel rejects the wait and closes the loopback listener', async () => { + const abort = new AbortController() + const { flow, redirect } = await start(abort.signal) + abort.abort() + await expect(flow).rejects.toThrow('orca_cloud_auth_cancelled') + // A late browser callback finds nothing listening. + await expect(fetch(redirect)).rejects.toThrow() + }) + + it('an already-cancelled attempt never opens a listener', async () => { + const abort = new AbortController() + abort.abort() + const onAuthorizeUrl = vi.fn() + await expect( + beginOrcaCloudPkceFlow(config, 'profile-1', { signal: abort.signal, onAuthorizeUrl }) + ).rejects.toThrow('orca_cloud_auth_cancelled') + expect(onAuthorizeUrl).not.toHaveBeenCalled() + }) + + it('times out a sign-in the browser never finishes', async () => { + process.env.ORCA_CLOUD_SIGN_IN_TIMEOUT_MS = '1000' + const { flow, redirect } = await start() + await expect(flow).rejects.toThrow('orca_cloud_auth_timeout') + await expect(fetch(redirect)).rejects.toThrow() + }) + + it('waits five minutes by default; only unpackaged dev runs may shorten it', () => { + expect(ORCA_CLOUD_SIGN_IN_TIMEOUT_MS).toBe(300_000) + expect(orcaCloudSignInTimeoutMs({}, false)).toBe(300_000) + expect(orcaCloudSignInTimeoutMs({ ORCA_CLOUD_SIGN_IN_TIMEOUT_MS: '60000' }, false)).toBe(60_000) + expect(orcaCloudSignInTimeoutMs({ ORCA_CLOUD_SIGN_IN_TIMEOUT_MS: '60000' }, true)).toBe(300_000) + expect(orcaCloudSignInTimeoutMs({ ORCA_CLOUD_SIGN_IN_TIMEOUT_MS: '10' }, false)).toBe(300_000) + expect(orcaCloudSignInTimeoutMs({ ORCA_CLOUD_SIGN_IN_TIMEOUT_MS: 'x' }, false)).toBe(300_000) + }) +}) diff --git a/src/main/orca-profiles/profile-cloud-pkce.ts b/src/main/orca-profiles/profile-cloud-pkce.ts index be85d68036f..43127271205 100644 --- a/src/main/orca-profiles/profile-cloud-pkce.ts +++ b/src/main/orca-profiles/profile-cloud-pkce.ts @@ -24,7 +24,17 @@ export type OrcaCloudAuthorizationCode = { /** How long a held browser tab waits for the caller before it gets the "signed in" page. */ const HOLD_BROWSER_MS = 30_000 -const AUTH_TIMEOUT_MS = 5 * 60 * 1000 +/** A sign-in the browser never answers ends after this, with "Sign-in didn’t finish. Try again." */ +export const ORCA_CLOUD_SIGN_IN_TIMEOUT_MS = 5 * 60 * 1000 + +/** Dev automation only (unpackaged): ORCA_CLOUD_SIGN_IN_TIMEOUT_MS shortens the wait for a test run. */ +export function orcaCloudSignInTimeoutMs( + env: NodeJS.ProcessEnv = process.env, + packaged: boolean = app.isPackaged +): number { + const override = packaged ? Number.NaN : Number(env.ORCA_CLOUD_SIGN_IN_TIMEOUT_MS) + return Number.isFinite(override) && override >= 1_000 ? override : ORCA_CLOUD_SIGN_IN_TIMEOUT_MS +} function base64Url(buffer: Buffer): string { return buffer.toString('base64').replaceAll('+', '-').replaceAll('/', '_').replaceAll('=', '') @@ -159,7 +169,7 @@ export function beginOrcaCloudPkceFlow( const timeout = setTimeout(() => { rejectFlow(new Error('orca_cloud_auth_timeout')) - }, AUTH_TIMEOUT_MS) + }, orcaCloudSignInTimeoutMs()) const cancel = (): void => rejectFlow(new Error('orca_cloud_auth_cancelled')) options.signal?.addEventListener('abort', cancel, { once: true }) server.once('close', () => { @@ -167,6 +177,10 @@ export function beginOrcaCloudPkceFlow( options.signal?.removeEventListener('abort', cancel) }) server.once('error', rejectFlow) + if (options.signal?.aborted) { + cancel() + return + } server.listen(0, '127.0.0.1', () => { const address = server.address() if (!address || typeof address === 'string') { diff --git a/src/main/orca-profiles/profile-cloud-service-connect-overlap.test.ts b/src/main/orca-profiles/profile-cloud-service-connect-overlap.test.ts index 04dd63f7e67..4417aad27a3 100644 --- a/src/main/orca-profiles/profile-cloud-service-connect-overlap.test.ts +++ b/src/main/orca-profiles/profile-cloud-service-connect-overlap.test.ts @@ -184,7 +184,8 @@ describe('Orca cloud overlapping connect', () => { redirectUri: 'http://127.0.0.1:4100/auth/callback', state: 'earlier-state' }) - await expect(earlier).resolves.toMatchObject({ status: 'connected' }) + // The later sign-in replaced the earlier one, so the earlier callback can't link anything. + await expect(earlier).resolves.toMatchObject({ status: 'cancelled' }) await expect(signOutCurrentOrcaProfile(userDataPath)).resolves.toMatchObject({ status: 'signed-out' }) @@ -196,7 +197,7 @@ describe('Orca cloud overlapping connect', () => { state: 'later-state' }) await expect(later).resolves.toMatchObject({ status: 'cancelled' }) - expect(exchangeOrcaCloudAuthCodeMock).toHaveBeenCalledTimes(1) + expect(exchangeOrcaCloudAuthCodeMock).not.toHaveBeenCalled() expect(getCurrentOrcaProfileAuthStatus(userDataPath)).toMatchObject({ state: 'local' }) }) }) diff --git a/src/main/orca-profiles/profile-cloud-service-sign-in-cancel.test.ts b/src/main/orca-profiles/profile-cloud-service-sign-in-cancel.test.ts new file mode 100644 index 00000000000..8e590b412bb --- /dev/null +++ b/src/main/orca-profiles/profile-cloud-service-sign-in-cancel.test.ts @@ -0,0 +1,168 @@ +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { mkdtempSync, rmSync } from 'node:fs' +import { tmpdir } from 'node:os' +import { join } from 'node:path' +import type { OrcaCloudSignInEnd, OrcaProfileCloudSummary } from '../../shared/orca-profiles' + +const { beginOrcaCloudPkceFlowMock, exchangeOrcaCloudAuthCodeMock, safeStorageMock } = vi.hoisted( + () => ({ + beginOrcaCloudPkceFlowMock: vi.fn(), + exchangeOrcaCloudAuthCodeMock: vi.fn(), + safeStorageMock: { + decryptString: vi.fn((value: Buffer) => value.toString('utf-8')), + encryptString: vi.fn((value: string) => Buffer.from(value, 'utf-8')), + isEncryptionAvailable: vi.fn(() => true) + } + }) +) + +let userDataPath = '' + +vi.mock('electron', () => ({ + app: { getPath: () => userDataPath }, + safeStorage: safeStorageMock +})) + +vi.mock('./profile-cloud-pkce', () => ({ + beginOrcaCloudPkceFlow: beginOrcaCloudPkceFlowMock +})) + +vi.mock('./profile-cloud-client', () => ({ + createOrcaCloudProfile: vi.fn(), + exchangeOrcaCloudAuthCode: exchangeOrcaCloudAuthCodeMock, + revokeOrcaCloudSession: vi.fn(async () => undefined), + selectOrcaCloudOrg: vi.fn() +})) + +import { connectCurrentOrcaProfile, getCurrentOrcaProfileAuthStatus } from './profile-cloud-service' +import { + cancelOrcaCloudSignIn, + getOrcaCloudSignInProgress, + onOrcaCloudSignInProgressChanged, + resetOrcaCloudSignInProgressForTests +} from './profile-cloud-sign-in-progress' + +const cloud: OrcaProfileCloudSummary = { + cloudProfileId: 'cloud-profile-1', + userId: 'user-1', + email: 'nina@example.com', + displayName: 'Nina', + linkedAt: 10 +} + +const code = { + code: 'the-code', + codeVerifier: 'verifier', + nonce: 'nonce', + redirectUri: 'http://127.0.0.1:4100/auth/callback', + state: 'state' +} + +/** Waits for the browser like the real loopback: rejects when the attempt is aborted. */ +function pendingBrowser(): { + answer: (value: typeof code) => void + fail: (error: Error) => void +} { + const handle = { + answer: (_value: typeof code): void => undefined, + fail: (_error: Error): void => undefined + } + beginOrcaCloudPkceFlowMock.mockImplementationOnce( + (_config: unknown, _profile: string, options: { signal?: AbortSignal }) => + new Promise((resolve, reject) => { + handle.answer = resolve + handle.fail = reject + options.signal?.addEventListener('abort', () => + reject(new Error('orca_cloud_auth_cancelled')) + ) + }) + ) + return handle +} + +describe('Orca Cloud sign-in cancel, supersede and timeout', () => { + beforeEach(() => { + userDataPath = mkdtempSync(join(tmpdir(), 'orca-cloud-sign-in-cancel-')) + beginOrcaCloudPkceFlowMock.mockReset() + exchangeOrcaCloudAuthCodeMock.mockReset() + exchangeOrcaCloudAuthCodeMock.mockResolvedValue({ + accessToken: 'access-token', + refreshToken: 'refresh-token', + expiresAt: Date.now() + 3_600_000, + cloud, + organizations: [], + capabilities: { flags: {}, refreshedAt: 1 } + }) + vi.stubEnv('ORCA_CLOUD_API_URL', 'https://orca-cloud.example') + vi.stubEnv('ORCA_CLOUD_CLIENT_ID', 'desktop-client') + }) + + afterEach(() => { + resetOrcaCloudSignInProgressForTests() + rmSync(userDataPath, { recursive: true, force: true }) + vi.unstubAllEnvs() + }) + + it('Cancel while the browser is open ends the sign-in and clears progress', async () => { + pendingBrowser() + const connect = connectCurrentOrcaProfile(userDataPath) + await vi.waitFor(() => expect(getOrcaCloudSignInProgress()).not.toBeNull()) + cancelOrcaCloudSignIn() + expect(getOrcaCloudSignInProgress()).toBeNull() + await expect(connect).resolves.toMatchObject({ status: 'cancelled' }) + expect(getCurrentOrcaProfileAuthStatus(userDataPath).state).not.toBe('connected') + }) + + it('Cancel after the browser answered still wins: the session is not saved', async () => { + const browser = pendingBrowser() + let finishExchange!: () => void + exchangeOrcaCloudAuthCodeMock.mockImplementationOnce(async () => { + await new Promise((resolve) => (finishExchange = resolve)) + return { + accessToken: 'access-token', + refreshToken: 'refresh-token', + expiresAt: Date.now() + 3_600_000, + cloud, + organizations: [], + capabilities: { flags: {}, refreshedAt: 1 } + } + }) + const connect = connectCurrentOrcaProfile(userDataPath) + await vi.waitFor(() => expect(beginOrcaCloudPkceFlowMock).toHaveBeenCalled()) + browser.answer(code) + await vi.waitFor(() => expect(exchangeOrcaCloudAuthCodeMock).toHaveBeenCalled()) + cancelOrcaCloudSignIn() + finishExchange() + await expect(connect).resolves.toMatchObject({ status: 'cancelled' }) + expect(getCurrentOrcaProfileAuthStatus(userDataPath).state).not.toBe('connected') + }) + + it('a second sign-in replaces the first: the first closes, the second signs in', async () => { + pendingBrowser() + const second = pendingBrowser() + const first = connectCurrentOrcaProfile(userDataPath) + const later = connectCurrentOrcaProfile(userDataPath) + await expect(first).resolves.toMatchObject({ status: 'cancelled' }) + expect(getOrcaCloudSignInProgress()).not.toBeNull() + second.answer(code) + await expect(later).resolves.toMatchObject({ status: 'connected' }) + expect(getOrcaCloudSignInProgress()).toBeNull() + expect(getCurrentOrcaProfileAuthStatus(userDataPath).cloud?.email).toBe('nina@example.com') + }) + + it('a timed-out sign-in clears progress and says it did not finish', async () => { + const ends: (OrcaCloudSignInEnd | undefined)[] = [] + onOrcaCloudSignInProgressChanged((progress, end) => { + if (!progress) { + ends.push(end) + } + }) + const browser = pendingBrowser() + const connect = connectCurrentOrcaProfile(userDataPath) + await vi.waitFor(() => expect(beginOrcaCloudPkceFlowMock).toHaveBeenCalled()) + browser.fail(new Error('orca_cloud_auth_timeout')) + await expect(connect).resolves.toMatchObject({ status: 'timed-out' }) + expect(getOrcaCloudSignInProgress()).toBeNull() + expect(ends).toEqual(['timed-out']) + }) +}) diff --git a/src/main/orca-profiles/profile-cloud-service.ts b/src/main/orca-profiles/profile-cloud-service.ts index 4bd70e0412f..804acb76019 100644 --- a/src/main/orca-profiles/profile-cloud-service.ts +++ b/src/main/orca-profiles/profile-cloud-service.ts @@ -39,6 +39,7 @@ import { import { getOrcaProfileAuthStatusFromProfile } from './profile-cloud-auth-status' import { selectCloudOrg } from './profile-cloud-org-selection' import { + cancelOrcaCloudSignIn, endOrcaCloudSignInProgress, setOrcaCloudSignInLink, startOrcaCloudSignInProgress @@ -53,7 +54,8 @@ let linkedCloudConnectAttempt = 0 function invalidateOutstandingCloudConnectAttempts(): void { nextCloudConnectAttempt += 1 linkedCloudConnectAttempt = nextCloudConnectAttempt - endOrcaCloudSignInProgress() + // Also closes the pending loopback listener, so a late browser callback has nowhere to land. + cancelOrcaCloudSignIn() } function activeAuth( @@ -100,23 +102,26 @@ export async function connectCurrentOrcaProfile( } const attempt = ++nextCloudConnectAttempt - const browserWait = new AbortController() - startOrcaCloudSignInProgress(attempt, () => browserWait.abort()) + // Cancel (or a newer attempt) aborts this one at any stage before the session is saved. + const attemptAbort = new AbortController() + const cancelled = (): ConnectCurrentOrcaProfileResult => ({ + status: 'cancelled', + auth: getCurrentOrcaProfileAuthStatus(userDataPath) + }) + let end: 'timed-out' | undefined + startOrcaCloudSignInProgress(attempt, () => attemptAbort.abort()) let finishBrowser: ((location: string | null) => void) | undefined try { const code = await beginOrcaCloudPkceFlow(configState.config, active.profile.id, { - signal: browserWait.signal, + signal: attemptAbort.signal, onAuthorizeUrl: (link) => setOrcaCloudSignInLink(attempt, link), ...(setup ? { authorizeParams: setup.authorizeParams, holdBrowser: true } : {}) }) finishBrowser = code.finishBrowser // The callback listener has closed, so its browser link is dead. setOrcaCloudSignInLink(attempt, null) - if (attempt < linkedCloudConnectAttempt) { - return { - status: 'cancelled', - auth: getCurrentOrcaProfileAuthStatus(userDataPath) - } + if (attempt < linkedCloudConnectAttempt || attemptAbort.signal.aborted) { + return cancelled() } const exchange = await exchangeOrcaCloudAuthCode(configState.config, { code: code.code, @@ -126,11 +131,8 @@ export async function connectCurrentOrcaProfile( state: code.state, localProfileId: active.profile.id }) - if (attempt < linkedCloudConnectAttempt) { - return { - status: 'cancelled', - auth: getCurrentOrcaProfileAuthStatus(userDataPath) - } + if (attempt < linkedCloudConnectAttempt || attemptAbort.signal.aborted) { + return cancelled() } signInCloudSession(active.profile.id, userDataPath, exchange) const list = linkOrcaProfileToCloud(active.profile.id, exchange.cloud, userDataPath) @@ -147,8 +149,12 @@ export async function connectCurrentOrcaProfile( profiles: list.profiles } } catch (error) { + if (attemptAbort.signal.aborted) { + return cancelled() + } const message = error instanceof Error ? error.message : String(error) if (message === 'orca_cloud_auth_timeout' && attempt === nextCloudConnectAttempt) { + end = 'timed-out' return { status: 'timed-out', auth: getCurrentOrcaProfileAuthStatus(userDataPath) @@ -171,7 +177,7 @@ export async function connectCurrentOrcaProfile( } } finally { finishBrowser?.(null) - endOrcaCloudSignInProgress(attempt) + endOrcaCloudSignInProgress(attempt, end) } } diff --git a/src/main/orca-profiles/profile-cloud-sign-in-progress.test.ts b/src/main/orca-profiles/profile-cloud-sign-in-progress.test.ts new file mode 100644 index 00000000000..2e4135c9cb7 --- /dev/null +++ b/src/main/orca-profiles/profile-cloud-sign-in-progress.test.ts @@ -0,0 +1,73 @@ +import { afterEach, describe, expect, it, vi } from 'vitest' +import type { OrcaCloudSignInEnd, OrcaCloudSignInProgress } from '../../shared/orca-profiles' +import { + cancelOrcaCloudSignIn, + endOrcaCloudSignInProgress, + getOrcaCloudSignInProgress, + onOrcaCloudSignInProgressChanged, + resetOrcaCloudSignInProgressForTests, + setOrcaCloudSignInLink, + startOrcaCloudSignInProgress +} from './profile-cloud-sign-in-progress' + +afterEach(() => resetOrcaCloudSignInProgressForTests()) + +function record(): [OrcaCloudSignInProgress | null, OrcaCloudSignInEnd | undefined][] { + const events: [OrcaCloudSignInProgress | null, OrcaCloudSignInEnd | undefined][] = [] + onOrcaCloudSignInProgressChanged((progress, end) => events.push([progress, end])) + return events +} + +describe('Orca Cloud sign-in progress', () => { + it('Cancel aborts the pending attempt and clears progress at once', () => { + const events = record() + const abort = vi.fn() + startOrcaCloudSignInProgress(1, abort) + setOrcaCloudSignInLink(1, 'https://auth.test/authorize') + cancelOrcaCloudSignIn() + expect(abort).toHaveBeenCalledOnce() + expect(getOrcaCloudSignInProgress()).toBeNull() + expect(events.at(-1)).toEqual([null, undefined]) + // The aborted attempt ending later changes nothing. + endOrcaCloudSignInProgress(1) + expect(events).toHaveLength(3) + }) + + it('clears progress even when aborting throws', () => { + startOrcaCloudSignInProgress(1, () => { + throw new Error('already closed') + }) + expect(() => cancelOrcaCloudSignIn()).not.toThrow() + expect(getOrcaCloudSignInProgress()).toBeNull() + }) + + it('a second sign-in replaces the first and cancels it', () => { + const first = vi.fn() + const second = vi.fn() + startOrcaCloudSignInProgress(1, first) + setOrcaCloudSignInLink(1, 'https://auth.test/one') + startOrcaCloudSignInProgress(2, second) + expect(first).toHaveBeenCalledOnce() + expect(second).not.toHaveBeenCalled() + expect(getOrcaCloudSignInProgress()).toEqual({ link: null }) + // The replaced attempt can neither set its link nor end the newer one. + setOrcaCloudSignInLink(1, 'https://auth.test/stale') + endOrcaCloudSignInProgress(1) + expect(getOrcaCloudSignInProgress()).toEqual({ link: null }) + setOrcaCloudSignInLink(2, 'https://auth.test/two') + expect(getOrcaCloudSignInProgress()).toEqual({ link: 'https://auth.test/two' }) + }) + + it('says when a sign-in timed out', () => { + const events = record() + startOrcaCloudSignInProgress(3, vi.fn()) + endOrcaCloudSignInProgress(3, 'timed-out') + expect(events.at(-1)).toEqual([null, 'timed-out']) + }) + + it('Cancel with nothing pending is a no-op', () => { + const events = record() + cancelOrcaCloudSignIn() + expect(events).toHaveLength(0) + }) +}) diff --git a/src/main/orca-profiles/profile-cloud-sign-in-progress.ts b/src/main/orca-profiles/profile-cloud-sign-in-progress.ts index 88cb98cc23d..5c33fb6873c 100644 --- a/src/main/orca-profiles/profile-cloud-sign-in-progress.ts +++ b/src/main/orca-profiles/profile-cloud-sign-in-progress.ts @@ -1,8 +1,9 @@ -import type { OrcaCloudSignInProgress } from '../../shared/orca-profiles' +import type { OrcaCloudSignInEnd, OrcaCloudSignInProgress } from '../../shared/orca-profiles' -type ProgressListener = (progress: OrcaCloudSignInProgress | null) => void +type ProgressListener = (progress: OrcaCloudSignInProgress | null, end?: OrcaCloudSignInEnd) => void -// Only the newest attempt owns progress; late updates from older attempts are ignored. +// One sign-in at a time: a newer attempt cancels the older one (its loopback listener closes), and +// Cancel clears the pending state at once, so nothing can leave the app stuck on "Signing in…". let current: { attempt: number; link: string | null; cancel: () => void } | null = null const listeners = new Set() @@ -10,18 +11,26 @@ function snapshot(): OrcaCloudSignInProgress | null { return current ? { link: current.link } : null } -function update(next: typeof current): void { +function update(next: typeof current, end?: OrcaCloudSignInEnd): void { current = next const progress = snapshot() for (const listener of listeners) { try { - listener(progress) + listener(progress, end) } catch (error) { console.warn('[orca-profiles] Sign-in progress listener failed:', error) } } } +function cancelQuietly(cancel: () => void): void { + try { + cancel() + } catch (error) { + console.warn('[orca-profiles] Cancelling a sign-in failed:', error) + } +} + export function getOrcaCloudSignInProgress(): OrcaCloudSignInProgress | null { return snapshot() } @@ -33,8 +42,13 @@ export function onOrcaCloudSignInProgressChanged(listener: ProgressListener): () } } +/** Starts tracking `attempt`; an older pending attempt is cancelled (a second click supersedes it). */ export function startOrcaCloudSignInProgress(attempt: number, cancel: () => void): void { + const previous = current update({ attempt, link: null, cancel }) + if (previous && previous.attempt !== attempt) { + cancelQuietly(previous.cancel) + } } export function setOrcaCloudSignInLink(attempt: number, link: string | null): void { @@ -43,12 +57,24 @@ export function setOrcaCloudSignInLink(attempt: number, link: string | null): vo } } -export function endOrcaCloudSignInProgress(attempt?: number): void { +export function endOrcaCloudSignInProgress(attempt?: number, end?: OrcaCloudSignInEnd): void { if (current && (attempt === undefined || current.attempt === attempt)) { - update(null) + update(null, end) } } +/** Cancel: aborts the pending attempt (closing its loopback listener) and clears progress now. */ export function cancelOrcaCloudSignIn(): void { - current?.cancel() + const pending = current + if (!pending) { + return + } + update(null) + cancelQuietly(pending.cancel) +} + +/** Test-only. */ +export function resetOrcaCloudSignInProgressForTests(): void { + current = null + listeners.clear() } diff --git a/src/preload/api/orca-profile-api.ts b/src/preload/api/orca-profile-api.ts index 47a945f946b..c8b62b804e8 100644 --- a/src/preload/api/orca-profile-api.ts +++ b/src/preload/api/orca-profile-api.ts @@ -10,6 +10,7 @@ import type { OrcaProfileOrgLeaveArgs } from '../../shared/orca-org-management' import type { + OrcaCloudSignInEnd, OrcaCloudSignInProgress, ConnectCurrentOrcaProfileResult, CreateCloudLinkedOrcaProfileArgs, @@ -67,7 +68,8 @@ export type OrcaProfileApi = { connectCurrent: () => Promise signInProgress: () => Promise onSignInProgressChanged: ( - callback: (progress: OrcaCloudSignInProgress | null) => void + /** `end` says why a sign-in stopped when the UI should tell the user (it timed out). */ + callback: (progress: OrcaCloudSignInProgress | null, end: OrcaCloudSignInEnd | null) => void ) => () => void cancelSignIn: () => Promise refreshAuth: () => Promise diff --git a/src/preload/api/orca-profiles-bridge.ts b/src/preload/api/orca-profiles-bridge.ts index d9f5adb506f..349947683ca 100644 --- a/src/preload/api/orca-profiles-bridge.ts +++ b/src/preload/api/orca-profiles-bridge.ts @@ -3,6 +3,7 @@ import type { PreloadApi } from '../api-types' import { ORCA_PROFILE_AUTH_STATUS_CHANGED_CHANNEL, ORCA_PROFILE_SIGN_IN_PROGRESS_CHANGED_CHANNEL, + type OrcaCloudSignInEnd, type OrcaCloudSignInProgress, type OrcaProfileListResult, type SwitchOrcaProfileResult, @@ -29,10 +30,13 @@ export const orcaProfilesApi = { return () => ipcRenderer.removeListener(ORCA_PROFILE_AUTH_STATUS_CHANGED_CHANNEL, listener) }, onSignInProgressChanged: ( - callback: (progress: OrcaCloudSignInProgress | null) => void + callback: (progress: OrcaCloudSignInProgress | null, end: OrcaCloudSignInEnd | null) => void ): (() => void) => { - const listener = (_event: unknown, progress: OrcaCloudSignInProgress | null): void => - callback(progress) + const listener = ( + _event: unknown, + progress: OrcaCloudSignInProgress | null, + end?: OrcaCloudSignInEnd | null + ): void => callback(progress, end ?? null) ipcRenderer.on(ORCA_PROFILE_SIGN_IN_PROGRESS_CHANGED_CHANNEL, listener) return () => ipcRenderer.removeListener(ORCA_PROFILE_SIGN_IN_PROGRESS_CHANGED_CHANNEL, listener) }, diff --git a/src/renderer/src/components/OrcaSignInProgress.tsx b/src/renderer/src/components/OrcaSignInProgress.tsx index 10caa6e6dae..7d196c2687e 100644 --- a/src/renderer/src/components/OrcaSignInProgress.tsx +++ b/src/renderer/src/components/OrcaSignInProgress.tsx @@ -18,43 +18,46 @@ async function copySignInLink(link: string): Promise { } } +/** + * Stays clickable while a sign-in is pending: another click starts a fresh sign-in in the browser + * and replaces the pending one (main cancels it), so a closed or lost tab never strands the user. + */ export function OrcaSignInButton({ children, - disabled, ...props }: Omit, 'onClick' | 'type'>): React.JSX.Element { - const t = useTranslate() const connect = useAppStore((state) => state.connectCurrentOrcaProfile) - const signingIn = useAppStore((state) => Boolean(state.orcaProfileSignInProgress)) return ( - ) } +function cancelSignIn(): void { + void window.api.orcaProfiles.cancelSignIn().catch(() => {}) +} + export function OrcaSignInWaitNotice({ className }: { className?: string }): React.JSX.Element | null { const t = useTranslate() - const link = useAppStore((state) => state.orcaProfileSignInProgress?.link) - if (!link) { - return null + const progress = useAppStore((state) => state.orcaProfileSignInProgress) + const timedOut = useAppStore((state) => state.orcaProfileSignInEnd === 'timed-out') + const signedIn = useAppStore((state) => state.orcaProfileAuthStatus?.state === 'connected') + if (!progress) { + if (!timedOut || signedIn) { + return null + } + return ( +

+ {t('auto.components.OrcaSignInProgress.didNotFinish', 'Sign-in didn’t finish. Try again.')} +

+ ) } + const link = progress.link return (
+ - {t('auto.components.OrcaSignInProgress.waiting', 'Waiting for sign-in in your browser')} + {link + ? t('auto.components.OrcaSignInProgress.waiting', 'Waiting for sign-in in your browser') + : t('auto.components.OrcaSignInProgress.signingIn', 'Signing in…')} + {link ? ( + <> + · + + + ) : null} · - - · -
diff --git a/src/renderer/src/components/billing/checkout/use-checkout-flow.ts b/src/renderer/src/components/billing/checkout/use-checkout-flow.ts index 753c6b2afff..b4b983241bf 100644 --- a/src/renderer/src/components/billing/checkout/use-checkout-flow.ts +++ b/src/renderer/src/components/billing/checkout/use-checkout-flow.ts @@ -66,7 +66,7 @@ export function useCheckoutFlow({ onPaid }: { onPaid: (seats: number) => void }) // O1: a plan always lands on a team. The browser makes or picks the team, then Checkout; // the setup session switches this profile to that team when it's there. const started = await startCloudSetupSession({ needs: ['team', 'plan'], chooseTeam: true }) - return started ? { status: 'opened' } : result + return started && 'sessionId' in started ? { status: 'opened' } : result }) .then((result) => { if (id === runId.current) { diff --git a/src/renderer/src/components/orca-cloud-setup/CloudSetupPage.tsx b/src/renderer/src/components/orca-cloud-setup/CloudSetupPage.tsx index d9dabad6168..d63b115239f 100644 --- a/src/renderer/src/components/orca-cloud-setup/CloudSetupPage.tsx +++ b/src/renderer/src/components/orca-cloud-setup/CloudSetupPage.tsx @@ -95,6 +95,11 @@ function BrowserWaiting({ flow }: { flow: CloudSetupFlow }): React.JSX.Element { {t('cloudSetupPage.waitingBrowser', 'Waiting for your browser…')} + {flow.signingIn ? ( + + ) : null} {flow.copyLink ? ( diff --git a/src/renderer/src/components/orca-cloud-setup/use-cloud-setup-flow.ts b/src/renderer/src/components/orca-cloud-setup/use-cloud-setup-flow.ts index 165dbd03b21..e564ddef6ce 100644 --- a/src/renderer/src/components/orca-cloud-setup/use-cloud-setup-flow.ts +++ b/src/renderer/src/components/orca-cloud-setup/use-cloud-setup-flow.ts @@ -3,6 +3,7 @@ // one-trip setup session (#255) with its deep-link return (#257), B2's team switch, and the // tracker's error parsing (#260). Only the UI moved: from a card in the dialog to this page. import { useCallback, useEffect, useMemo, useRef, useState } from 'react' +import { useAppStore } from '@/store' import { claimOrcaCloudTrial } from '@/components/billing/claim-trial' import { invalidateOrcaCloudBilling, @@ -80,6 +81,13 @@ function useLiveAvailability( export type CloudSetupFlow = CloudSetupPageModel & { /** True from the click until the browser opens or the trial answers. */ busy: boolean + /** This page's browser sign-in is pending: the page offers Cancel and keeps Reopen browser live. */ + signingIn: boolean + /** The last sign-in stopped on its own (it timed out): "Sign-in didn’t finish. Try again." */ + signInDidNotFinish: boolean + cancelSignIn: () => void + /** Leaving setup (Back): cancels a sign-in this page started. */ + abandon: () => void /** The browser trip is open: the current step reads "Waiting for your browser". */ inBrowser: boolean error: ReturnType @@ -166,6 +174,12 @@ export function useCloudSetupFlow( [access, availability] ) + const runRef = useRef(0) + const [startedSignIn, setStartedSignIn] = useState(false) + const signInPending = useAppStore((state) => Boolean(state.orcaProfileSignInProgress)) + const signInTimedOut = useAppStore((state) => state.orcaProfileSignInEnd === 'timed-out') + const signingIn = busy && startedSignIn && signInPending + // One browser trip for everything still open from here (sign-in, team, trial or Checkout, GitHub). const continueInBrowser = useCallback(() => { const needs = sessionNeedsFrom(stepsRef.current) @@ -180,9 +194,19 @@ export function useCloudSetupFlow( fallback() return } + // Each click is a new run. An older run that ends late (its sign-in was replaced or cancelled) + // must not touch the page or open anything. + const run = ++runRef.current + const isCurrent = (): boolean => run === runRef.current setBusy(true) + setBrowserStep(null) + setStartedSignIn(cloudSetupPageModel(stepsRef.current).current?.id === 'account') void start({ repoId: request.repoId, needs }) .then((opened) => { + if (!isCurrent() || (opened && 'cancelled' in opened)) { + // Cancelled, timed out or replaced: back to the step's own button; nothing reopens. + return + } markInBrowser() if (opened) { setSessionId(opened.sessionId) @@ -190,10 +214,31 @@ export function useCloudSetupFlow( fallback() } }) - .catch(() => fallback()) - .finally(() => setBusy(false)) + .catch(() => { + if (isCurrent()) { + fallback() + } + }) + .finally(() => { + if (isCurrent()) { + setBusy(false) + setStartedSignIn(false) + } + }) }, [fallback, markInBrowser, openInstall, request.repoId]) + const cancelSignIn = useCallback(() => { + void window.api.orcaProfiles.cancelSignIn().catch(() => {}) + }, []) + + const abandon = useCallback(() => { + if (busy && startedSignIn) { + // Back means "not now": the tab this page opened must not sign in behind the user's back. + runRef.current++ + cancelSignIn() + } + }, [busy, cancelSignIn, startedSignIn]) + const startTrial = useCallback(() => { setBusy(true) void claimOrcaCloudTrial() @@ -226,7 +271,11 @@ export function useCloudSetupFlow( return { ...model, - busy, + busy: busy && !signingIn, + signingIn, + signInDidNotFinish: !busy && signInTimedOut && model.action === 'sign-in', + cancelSignIn, + abandon, inBrowser: browserStep !== null && (sessionId !== null || model.current?.id === browserStep), error, canManageBilling: access.state === 'no-plan' ? access.canManageBilling : true, diff --git a/src/renderer/src/hooks/ipc-events/orca-profile-auth-ipc-bridge.test.ts b/src/renderer/src/hooks/ipc-events/orca-profile-auth-ipc-bridge.test.ts index ee223e3dd19..bb214773b5c 100644 --- a/src/renderer/src/hooks/ipc-events/orca-profile-auth-ipc-bridge.test.ts +++ b/src/renderer/src/hooks/ipc-events/orca-profile-auth-ipc-bridge.test.ts @@ -1,5 +1,5 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' -import type { OrcaCloudSignInProgress } from '../../../../shared/orca-profiles' +import type { OrcaCloudSignInEnd, OrcaCloudSignInProgress } from '../../../../shared/orca-profiles' import { createTestStore } from '../../store/testing/app-store-test-fixture' type TestStore = ReturnType @@ -11,8 +11,10 @@ const { storeHolder } = vi.hoisted((): { storeHolder: { current: TestStore | nul vi.mock('../../store', () => ({ useAppStore: { getState: () => storeHolder.current?.getState(), - setState: (partial: { orcaProfileSignInProgress: OrcaCloudSignInProgress | null }) => - storeHolder.current?.setState(partial) + setState: (partial: { + orcaProfileSignInProgress: OrcaCloudSignInProgress | null + orcaProfileSignInEnd?: OrcaCloudSignInEnd | null + }) => storeHolder.current?.setState(partial) } })) @@ -23,7 +25,10 @@ vi.mock('sonner', () => ({ import { registerOrcaProfileAuthIpcBridge } from './orca-profile-auth-ipc-bridge' describe('orca profile sign-in progress IPC bridge', () => { - let emitProgress: (progress: OrcaCloudSignInProgress | null) => void + let emitProgress: ( + progress: OrcaCloudSignInProgress | null, + end?: OrcaCloudSignInEnd | null + ) => void const snapshots: ((progress: OrcaCloudSignInProgress | null) => void)[] = [] const WAITING = { link: 'https://login.example/authorize?state=a' } @@ -34,7 +39,10 @@ describe('orca profile sign-in progress IPC bridge', () => { api: { orcaProfiles: { onSignInProgressChanged: ( - callback: (progress: OrcaCloudSignInProgress | null) => void + callback: ( + progress: OrcaCloudSignInProgress | null, + end?: OrcaCloudSignInEnd | null + ) => void ) => { emitProgress = callback return () => {} @@ -59,4 +67,16 @@ describe('orca profile sign-in progress IPC bridge', () => { await new Promise((resolve) => setTimeout(resolve, 0)) expect(progress()).toBeNull() }) + + it('keeps the timed-out note until the next sign-in starts', () => { + registerOrcaProfileAuthIpcBridge([]) + const end = (): OrcaCloudSignInEnd | null => + storeHolder.current?.getState().orcaProfileSignInEnd ?? null + emitProgress(WAITING, null) + emitProgress(null, 'timed-out') + expect(progress()).toBeNull() + expect(end()).toBe('timed-out') + emitProgress({ link: null }, null) + expect(end()).toBeNull() + }) }) diff --git a/src/renderer/src/hooks/ipc-events/orca-profile-auth-ipc-bridge.ts b/src/renderer/src/hooks/ipc-events/orca-profile-auth-ipc-bridge.ts index 7d7ba00f5a0..b77d59958ae 100644 --- a/src/renderer/src/hooks/ipc-events/orca-profile-auth-ipc-bridge.ts +++ b/src/renderer/src/hooks/ipc-events/orca-profile-auth-ipc-bridge.ts @@ -12,9 +12,13 @@ export function registerOrcaProfileAuthIpcBridge(unsubs: (() => void)[]): void { if (typeof api?.onSignInProgressChanged === 'function') { // Why: a sign-in can already be in flight when this window loads; a later event or teardown wins. let ignoreSnapshot = false - const unsubscribe = api.onSignInProgressChanged((progress) => { + const unsubscribe = api.onSignInProgressChanged((progress, end) => { ignoreSnapshot = true - useAppStore.setState({ orcaProfileSignInProgress: progress }) + // A new sign-in (or one that finished) clears the "didn't finish" note; a timeout sets it. + useAppStore.setState({ + orcaProfileSignInProgress: progress, + orcaProfileSignInEnd: end ?? null + }) }) unsubs.push(() => { ignoreSnapshot = true diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index 2785e394006..d8f56eff789 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -1770,7 +1770,8 @@ "7d4bc516ee": "Failed to switch profile", "f518e89aa5": "Project already exists in that profile", "f03ae7f27b": "Failed to transfer project", - "signInTimedOut": "Sign-in timed out" + "signInTimedOut": "Sign-in timed out", + "signInDidNotFinish": "Sign-in didn’t finish. Try again." } }, "runtime": { @@ -20395,7 +20396,8 @@ "copied": "Sign-in link copied", "copyFailed": "Could not copy the link.", "signingIn": "Signing in…", - "cancel": "Cancel" + "cancel": "Cancel", + "didNotFinish": "Sign-in didn’t finish. Try again." }, "plainSshTerminal": { "open": "Open plain SSH terminal", @@ -28047,7 +28049,8 @@ "signIn": { "lead": "Orca Cloud runs your agents in a cloud workspace, so they keep going with your laptop closed. Sign in or create an account in your browser. We’ll make a team for you.", "note": "New teams get a trial with no card needed. This page picks up each step on its own.", - "title": "Sign in to Orca" + "title": "Sign in to Orca", + "didNotFinish": "Sign-in didn’t finish. Try again." }, "starting": "Starting…", "startsAfter": "Starts when setup is done", @@ -28075,6 +28078,7 @@ "lead_other": "{{hours}} sandbox hours to try Orca Cloud. No card needed." }, "untitled": "New cloud workspace", - "waitingBrowser": "Waiting for your browser…" + "waitingBrowser": "Waiting for your browser…", + "cancelSignIn": "Cancel" } } diff --git a/src/renderer/src/lib/orca-cloud/cloud-setup-session-seam.ts b/src/renderer/src/lib/orca-cloud/cloud-setup-session-seam.ts index e92b0addc43..d0ae500d0a3 100644 --- a/src/renderer/src/lib/orca-cloud/cloud-setup-session-seam.ts +++ b/src/renderer/src/lib/orca-cloud/cloud-setup-session-seam.ts @@ -42,8 +42,13 @@ export type CloudSetupStartRequest = { /** The rows still open when the user clicked (account, team, plan, github). */ needs: CloudSetupStep['id'][] } -/** Null when the session couldn't open; the composer then falls back to today's actions. */ -type SessionStarter = (request: CloudSetupStartRequest) => Promise<{ sessionId: string } | null> +/** + * Null when the session couldn't open; the composer then falls back to today's actions. + * `cancelled` when the user cancelled the sign-in: no fallback, nothing else opens. + */ +type SessionStarter = ( + request: CloudSetupStartRequest +) => Promise<{ sessionId: string } | { cancelled: true } | null> let source: SessionSource | null = null let starter: SessionStarter | null = null @@ -71,10 +76,7 @@ export function readCloudSetupSession(sessionId: string | null): CloudSetupSessi // Bumped on every change, so a read is cached per (session, revision): useSyncExternalStore needs // the same object back until something changed. let revision = 0 -const cachedReads = new Map< - string, - { revision: number; value: CloudSetupSessionSnapshot | null } ->() +const cachedReads = new Map() /** Call after each poll so open composers re-read their session. */ export function notifyCloudSetupSessionChanged(): void { diff --git a/src/renderer/src/lib/orca-cloud/cloud-setup-session.test.ts b/src/renderer/src/lib/orca-cloud/cloud-setup-session.test.ts index 0a0c7c08411..4a9b5046fad 100644 --- a/src/renderer/src/lib/orca-cloud/cloud-setup-session.test.ts +++ b/src/renderer/src/lib/orca-cloud/cloud-setup-session.test.ts @@ -126,6 +126,10 @@ describe('cloud setup session (renderer)', () => { it('stops on an expired session and returns null when setup cannot open', async () => { cloudSetupStart.mockResolvedValueOnce({ status: 'signed-out' }) expect(await startCloudSetupSession({ needs: ['plan'] })).toBeNull() + // A cancelled (or timed-out, or replaced) sign-in is not a failure: callers must not fall back + // to another browser trip. + cloudSetupStart.mockResolvedValueOnce({ status: 'cancelled' }) + expect(await startCloudSetupSession({ needs: ['plan'] })).toEqual({ cancelled: true }) cloudSetupGet.mockResolvedValue({ status: 'not-found' }) await refreshCloudSetupSession(ID) diff --git a/src/renderer/src/lib/orca-cloud/cloud-setup-session.ts b/src/renderer/src/lib/orca-cloud/cloud-setup-session.ts index d4bd4812bee..51199abb3fd 100644 --- a/src/renderer/src/lib/orca-cloud/cloud-setup-session.ts +++ b/src/renderer/src/lib/orca-cloud/cloud-setup-session.ts @@ -172,12 +172,18 @@ export function stopWatchingCloudSetupSession(sessionId: string): void { entries.delete(sessionId) } -/** "Set up and start": opens the one browser tab and starts polling. Null when it couldn't. */ +/** + * What "Set up and start" got back: the session it opened, `cancelled` when the user cancelled the + * sign-in (or it timed out, or a newer one replaced it), or null when setup couldn't open. + */ +export type CloudSetupSessionStart = { sessionId: string } | { cancelled: true } | null + +/** "Set up and start": opens the one browser tab and starts polling. */ export async function startCloudSetupSession(request: { repo?: string needs: CloudSetupNeed[] chooseTeam?: boolean -}): Promise<{ sessionId: string } | null> { +}): Promise { let result: CloudSetupStartResult try { result = await window.api.orcaProfiles.cloudSetupStart({ @@ -188,6 +194,10 @@ export async function startCloudSetupSession(request: { } catch { return null } + if (result.status === 'cancelled') { + // The user stopped the sign-in: nothing else may open a browser on their behalf. + return { cancelled: true } + } if (result.status !== 'opened') { return null } diff --git a/src/renderer/src/store/slices/orca-profiles/create-orca-profiles-slice.ts b/src/renderer/src/store/slices/orca-profiles/create-orca-profiles-slice.ts index 8bf623831b0..c87919d7bb4 100644 --- a/src/renderer/src/store/slices/orca-profiles/create-orca-profiles-slice.ts +++ b/src/renderer/src/store/slices/orca-profiles/create-orca-profiles-slice.ts @@ -2,6 +2,7 @@ import type { StateCreator } from 'zustand' import { toast } from 'sonner' import { translate } from '@/i18n/i18n' import type { + OrcaCloudSignInEnd, OrcaCloudSignInProgress, OrcaProfileAuthStatus, OrcaProfileSummary, @@ -20,6 +21,8 @@ export type OrcaProfilesSlice = OrcaProfilesAuthActions & { activeOrcaProfileId: string | null orcaProfileAuthStatus: OrcaProfileAuthStatus | null orcaProfileSignInProgress: OrcaCloudSignInProgress | null + /** Set when the last sign-in stopped without finishing (it timed out); cleared by the next one. */ + orcaProfileSignInEnd: OrcaCloudSignInEnd | null orcaProfilesMultiProfileUi: boolean orcaProfilesLoading: boolean orcaProfileSwitching: boolean @@ -41,6 +44,7 @@ export const createOrcaProfilesSlice: StateCreator Date: Tue, 10 Nov 2026 20:40:13 -0800 Subject: [PATCH 06/32] fix(cloud-auth): pending Sign in reads Reopen browser and reopens the same link; no timeout toast while the inline note shows (design-squad) --- .../src/components/OrcaSignInProgress.tsx | 31 +++++++++-- .../orca/OrcaAccountSettingsPane.fixture.tsx | 35 +++++++++++- src/renderer/src/i18n/locales/en.json | 3 +- .../orca-cloud/sign-in-notice-visibility.ts | 19 +++++++ ...orca-profiles-auth-actions-timeout.test.ts | 55 +++++++++++++++++++ .../orca-profiles-auth-actions.ts | 5 +- 6 files changed, 137 insertions(+), 11 deletions(-) create mode 100644 src/renderer/src/lib/orca-cloud/sign-in-notice-visibility.ts create mode 100644 src/renderer/src/store/slices/orca-profiles/orca-profiles-auth-actions-timeout.test.ts diff --git a/src/renderer/src/components/OrcaSignInProgress.tsx b/src/renderer/src/components/OrcaSignInProgress.tsx index 7d196c2687e..55fcbd11d2d 100644 --- a/src/renderer/src/components/OrcaSignInProgress.tsx +++ b/src/renderer/src/components/OrcaSignInProgress.tsx @@ -1,5 +1,7 @@ -import { Loader2 } from 'lucide-react' +import { useEffect } from 'react' +import { ExternalLink, Loader2 } from 'lucide-react' import { toast } from 'sonner' +import { registerSignInNotice } from '@/lib/orca-cloud/sign-in-notice-visibility' import { Button } from './ui/button' import { translate } from '@/i18n/i18n' import { useTranslate } from '@/i18n/use-translate' @@ -19,17 +21,34 @@ async function copySignInLink(link: string): Promise { } /** - * Stays clickable while a sign-in is pending: another click starts a fresh sign-in in the browser - * and replaces the pending one (main cancels it), so a closed or lost tab never strands the user. + * Never disabled by a pending sign-in, so a closed or lost tab can't strand the user. While the + * browser is out it reads "Reopen browser" and reopens the same sign-in link; otherwise a click + * starts a sign-in, replacing any pending one (main cancels it). */ export function OrcaSignInButton({ children, ...props }: Omit, 'onClick' | 'type'>): React.JSX.Element { + const t = useTranslate() const connect = useAppStore((state) => state.connectCurrentOrcaProfile) + const link = useAppStore((state) => state.orcaProfileSignInProgress?.link ?? null) + const onClick = (): void => { + if (!link) { + void connect() + return + } + void window.api.shell.openUrl(link).catch(() => void connect()) + } return ( - ) } @@ -47,6 +66,8 @@ export function OrcaSignInWaitNotice({ const progress = useAppStore((state) => state.orcaProfileSignInProgress) const timedOut = useAppStore((state) => state.orcaProfileSignInEnd === 'timed-out') const signedIn = useAppStore((state) => state.orcaProfileAuthStatus?.state === 'connected') + // While this is on screen a timeout is said here, not in a toast. + useEffect(() => registerSignInNotice(), []) if (!progress) { if (!timedOut || signedIn) { return null diff --git a/src/renderer/src/components/settings/accounts/orca/OrcaAccountSettingsPane.fixture.tsx b/src/renderer/src/components/settings/accounts/orca/OrcaAccountSettingsPane.fixture.tsx index 3c5a6bc38fe..623e53f1ad2 100644 --- a/src/renderer/src/components/settings/accounts/orca/OrcaAccountSettingsPane.fixture.tsx +++ b/src/renderer/src/components/settings/accounts/orca/OrcaAccountSettingsPane.fixture.tsx @@ -1,13 +1,27 @@ import { defineFixture } from '../../../../component-fixtures/component-fixture' -import type { OrcaProfileAuthStatus } from '../../../../../../shared/orca-profiles' +import type { + OrcaCloudSignInEnd, + OrcaCloudSignInProgress, + OrcaProfileAuthStatus +} from '../../../../../../shared/orca-profiles' import { OrcaAccountSettingsPane } from './OrcaAccountSettingsPane' const width = 760 -function pane(status: OrcaProfileAuthStatus) { +function pane( + status: OrcaProfileAuthStatus, + signIn: { + progress?: OrcaCloudSignInProgress | null + end?: OrcaCloudSignInEnd | null + } = {} +) { return defineFixture({ width, - store: { orcaProfileAuthStatus: status }, + store: { + orcaProfileAuthStatus: status, + orcaProfileSignInProgress: signIn.progress ?? null, + orcaProfileSignInEnd: signIn.end ?? null + }, // The pane re-reads auth status on mount; answer with the same state so the frame holds it. setup: () => { Object.assign(window.api.orcaProfiles, { authStatus: () => Promise.resolve(status) }) @@ -31,3 +45,18 @@ export const reconnectRequired = pane({ state: 'reconnect-required', persistence: 'encrypted' }) + +const signedOutStatus: OrcaProfileAuthStatus = { + activeProfileId: 'default', + configured: true, + state: 'local', + persistence: 'none' +} + +/** Waiting on the browser: the primary stays live as "Reopen browser"; the line offers Cancel. */ +export const signInPending = pane(signedOutStatus, { + progress: { link: 'https://auth.example/v1/desktop/auth/authorize?state=preview' } +}) + +/** The browser never came back: a calm inline note, and Sign in to Orca again. */ +export const signInTimedOut = pane(signedOutStatus, { end: 'timed-out' }) diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index d8f56eff789..6921fa2719b 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -20397,7 +20397,8 @@ "copyFailed": "Could not copy the link.", "signingIn": "Signing in…", "cancel": "Cancel", - "didNotFinish": "Sign-in didn’t finish. Try again." + "didNotFinish": "Sign-in didn’t finish. Try again.", + "reopenBrowser": "Reopen browser" }, "plainSshTerminal": { "open": "Open plain SSH terminal", diff --git a/src/renderer/src/lib/orca-cloud/sign-in-notice-visibility.ts b/src/renderer/src/lib/orca-cloud/sign-in-notice-visibility.ts new file mode 100644 index 00000000000..921f75a1d71 --- /dev/null +++ b/src/renderer/src/lib/orca-cloud/sign-in-notice-visibility.ts @@ -0,0 +1,19 @@ +// Whether an inline Orca sign-in notice is on screen. A sign-in that didn't finish is said inline +// where one is shown; the toast is only for sign-ins started from a surface without one. +let mounted = 0 + +/** Call from an inline notice's mount effect; the returned function unregisters it. */ +export function registerSignInNotice(): () => void { + mounted += 1 + let registered = true + return () => { + if (registered) { + registered = false + mounted -= 1 + } + } +} + +export function isSignInNoticeVisible(): boolean { + return mounted > 0 +} diff --git a/src/renderer/src/store/slices/orca-profiles/orca-profiles-auth-actions-timeout.test.ts b/src/renderer/src/store/slices/orca-profiles/orca-profiles-auth-actions-timeout.test.ts new file mode 100644 index 00000000000..d874665ad57 --- /dev/null +++ b/src/renderer/src/store/slices/orca-profiles/orca-profiles-auth-actions-timeout.test.ts @@ -0,0 +1,55 @@ +import { beforeEach, describe, expect, it, vi } from 'vitest' +import type { + ConnectCurrentOrcaProfileResult, + OrcaProfileAuthStatus +} from '../../../../../shared/orca-profiles' +import { registerSignInNotice } from '@/lib/orca-cloud/sign-in-notice-visibility' +import { createTestStore } from '../../testing/app-store-test-fixture' + +const { toastMock } = vi.hoisted(() => { + const toastMock = Object.assign(vi.fn(), { + error: vi.fn(), + info: vi.fn(), + success: vi.fn(), + warning: vi.fn() + }) + return { toastMock } +}) + +vi.mock('sonner', () => ({ toast: toastMock })) + +const signedOut: OrcaProfileAuthStatus = { + activeProfileId: 'local-default', + configured: true, + state: 'local', + persistence: 'none' +} +const timedOut: ConnectCurrentOrcaProfileResult = { status: 'timed-out', auth: signedOut } +const connectCurrent = vi.fn() + +describe('a sign-in that times out', () => { + beforeEach(() => { + vi.resetAllMocks() + vi.stubGlobal('window', { api: { orcaProfiles: { connectCurrent } } }) + connectCurrent.mockResolvedValue(timedOut) + }) + + it('says so calmly in a toast when no inline notice is on screen', async () => { + const store = createTestStore() + await store.getState().connectCurrentOrcaProfile() + expect(toastMock).toHaveBeenCalledWith('Sign-in didn’t finish. Try again.') + expect(toastMock.error).not.toHaveBeenCalled() + }) + + it('leaves it to the inline notice when one is on screen', async () => { + const unregister = registerSignInNotice() + try { + const store = createTestStore() + await store.getState().connectCurrentOrcaProfile() + expect(toastMock).not.toHaveBeenCalled() + expect(toastMock.error).not.toHaveBeenCalled() + } finally { + unregister() + } + }) +}) diff --git a/src/renderer/src/store/slices/orca-profiles/orca-profiles-auth-actions.ts b/src/renderer/src/store/slices/orca-profiles/orca-profiles-auth-actions.ts index f3c107b54d4..913fd4c684d 100644 --- a/src/renderer/src/store/slices/orca-profiles/orca-profiles-auth-actions.ts +++ b/src/renderer/src/store/slices/orca-profiles/orca-profiles-auth-actions.ts @@ -1,6 +1,7 @@ import type { StateCreator } from 'zustand' import { toast } from 'sonner' import { translate } from '@/i18n/i18n' +import { isSignInNoticeVisible } from '@/lib/orca-cloud/sign-in-notice-visibility' import type { ConnectCurrentOrcaProfileResult, CreateCloudLinkedOrcaProfileResult, @@ -108,8 +109,8 @@ export const createOrcaProfilesAuthActions: StateCreator< description: result.auth.setupMessage } ) - } else if (result.status === 'timed-out' && !alreadyConnected) { - // Calm, not an error: nothing broke, the browser just never came back. + } else if (result.status === 'timed-out' && !alreadyConnected && !isSignInNoticeVisible()) { + // Calm, not an error. Said inline where a sign-in notice is on screen; toast otherwise. toast( translate( 'auto.store.slices.orca.profiles.signInDidNotFinish', From 9c0c8098c88d3cde13324392327e1b6c1c98a287 Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 10 Nov 2026 20:43:37 -0800 Subject: [PATCH 07/32] fix(cloud): archived dates past a month, archived Files panel says archived, workspace (not sandbox) is asleep (DS-g, DS-h, DS-i) --- .../remote-desktop-guest.test.ts | 2 +- .../remote-desktop-pause-copy.ts | 4 +- .../CloudRemoteDesktopToast.tsx | 4 +- .../RemoteDesktopPauseCard.fixture.tsx | 2 +- .../offline/CloudAsleepFilesPanel.test.tsx | 31 ++++++++ .../offline/CloudAsleepFilesPanel.tsx | 73 +++++++++++++++---- .../offline/use-asleep-cloud-workspace-id.ts | 16 +++- .../tree/FileExplorerFilesTreePane.tsx | 8 +- src/renderer/src/i18n/locales/en.json | 14 +++- .../orca-cloud-workspace-state.test.ts | 15 ++++ .../orca-cloud/orca-cloud-workspace-state.ts | 11 ++- src/shared/worktree/removal.ts | 2 +- 12 files changed, 151 insertions(+), 31 deletions(-) diff --git a/src/main/hosted-sandbox/remote-desktop-guest.test.ts b/src/main/hosted-sandbox/remote-desktop-guest.test.ts index e7ca3436614..c890b016f2b 100644 --- a/src/main/hosted-sandbox/remote-desktop-guest.test.ts +++ b/src/main/hosted-sandbox/remote-desktop-guest.test.ts @@ -175,7 +175,7 @@ describe('remote desktop page driver', () => { failMint('asleep') guest.ask('ticket') await flush() - expect(guest.calls.at(-2)).toContain('This sandbox is asleep.') + expect(guest.calls.at(-2)).toContain('This workspace is asleep.') // Open remote desktop again: main wakes the paused page. registerRemoteDesktopSession( { diff --git a/src/main/hosted-sandbox/remote-desktop-pause-copy.ts b/src/main/hosted-sandbox/remote-desktop-pause-copy.ts index bd50b2619d0..65056218d02 100644 --- a/src/main/hosted-sandbox/remote-desktop-pause-copy.ts +++ b/src/main/hosted-sandbox/remote-desktop-pause-copy.ts @@ -7,7 +7,7 @@ export function remoteDesktopPauseMessage(reason: RemoteDesktopPauseReason): str case 'asleep': return translateMain( 'components.cloudRemoteDesktop.pageAsleep', - 'This sandbox is asleep. Wake it in Orca, then reconnect.' + 'This workspace is asleep. Wake it in Orca, then reconnect.' ) case 'archived': return translateMain( @@ -17,7 +17,7 @@ export function remoteDesktopPauseMessage(reason: RemoteDesktopPauseReason): str case 'starting': return translateMain( 'components.cloudRemoteDesktop.pageStarting', - 'The sandbox is starting or waking. Reconnect in a moment.' + 'The workspace is starting or waking. Reconnect in a moment.' ) case 'signed_out': return translateMain( diff --git a/src/renderer/src/components/cloud-remote-desktop/CloudRemoteDesktopToast.tsx b/src/renderer/src/components/cloud-remote-desktop/CloudRemoteDesktopToast.tsx index 3477fad70f5..fc0b1405a1a 100644 --- a/src/renderer/src/components/cloud-remote-desktop/CloudRemoteDesktopToast.tsx +++ b/src/renderer/src/components/cloud-remote-desktop/CloudRemoteDesktopToast.tsx @@ -48,7 +48,7 @@ export function failureCopy(t: Translate, code: CloudRemoteDesktopToastFailure): } case 'not_running': return { - title: t('components.cloudRemoteDesktop.asleepTitle', 'This sandbox is asleep.'), + title: t('components.cloudRemoteDesktop.asleepTitle', 'This workspace is asleep.'), detail: t( 'components.cloudRemoteDesktop.asleepDetail', 'Wake it to open the remote desktop. Your files are safe.' @@ -77,7 +77,7 @@ export function failureCopy(t: Translate, code: CloudRemoteDesktopToastFailure): return { title: t( 'components.cloudRemoteDesktop.startingTitle', - 'The sandbox is still starting or waking.' + 'The workspace is still starting or waking.' ), detail: t( 'components.cloudRemoteDesktop.startingDetail', diff --git a/src/renderer/src/components/cloud-remote-desktop/RemoteDesktopPauseCard.fixture.tsx b/src/renderer/src/components/cloud-remote-desktop/RemoteDesktopPauseCard.fixture.tsx index 24226ec4f64..fdbd2a86daf 100644 --- a/src/renderer/src/components/cloud-remote-desktop/RemoteDesktopPauseCard.fixture.tsx +++ b/src/renderer/src/components/cloud-remote-desktop/RemoteDesktopPauseCard.fixture.tsx @@ -50,7 +50,7 @@ export const pausedDisconnected = pauseFixture( 'error' ) export const pausedAsleep = pauseFixture( - 'This sandbox is asleep. Wake it in Orca, then reconnect.', + 'This workspace is asleep. Wake it in Orca, then reconnect.', 'neutral' ) export const pausedArchived = pauseFixture( diff --git a/src/renderer/src/components/orca-cloud/offline/CloudAsleepFilesPanel.test.tsx b/src/renderer/src/components/orca-cloud/offline/CloudAsleepFilesPanel.test.tsx index 9e59f5470ca..cc50e09c7bf 100644 --- a/src/renderer/src/components/orca-cloud/offline/CloudAsleepFilesPanel.test.tsx +++ b/src/renderer/src/components/orca-cloud/offline/CloudAsleepFilesPanel.test.tsx @@ -114,4 +114,35 @@ describe('asleep Files tab (RA-10)', () => { container.querySelector('[data-cloud-asleep-files]')?.getAttribute('data-cloud-asleep-files') ).toBe('none') }) + + it('archived: says "archived", never "went to sleep", and offers no Wake (DS-h)', async () => { + serve( + snapshot({ + branch: 'master', + head: 'abc', + at: NOW - 47_000, + changeCount: 1, + changes: [{ path: 'README.md', status: 'M', area: 'unstaged' }], + commits: [] + }) + ) + const { container } = render() + await waitFor(() => expect(container.textContent).toContain('README.md')) + const text = container.textContent ?? '' + expect(text).toContain('Changed files when this workspace was archived · 47s ago') + expect(text).toContain('Unarchive the workspace to browse all its files.') + expect(text).not.toContain('sleep') + expect(container.querySelector('button')).toBeNull() + }) + + it('archived without a snapshot: the archived note, no Wake', async () => { + serve(null) + const { container } = render() + await waitFor(() => + expect(container.textContent).toContain( + 'Files aren’t available while the workspace is archived.' + ) + ) + expect(container.querySelector('button')).toBeNull() + }) }) diff --git a/src/renderer/src/components/orca-cloud/offline/CloudAsleepFilesPanel.tsx b/src/renderer/src/components/orca-cloud/offline/CloudAsleepFilesPanel.tsx index 97910b16f5e..a38262eecbc 100644 --- a/src/renderer/src/components/orca-cloud/offline/CloudAsleepFilesPanel.tsx +++ b/src/renderer/src/components/orca-cloud/offline/CloudAsleepFilesPanel.tsx @@ -35,17 +35,23 @@ export function formatWhen(at: number, now: number, locale: string, t: Translate */ export function CloudAsleepFilesPanel({ workspaceId, - waking = false + waking = false, + archived = false }: { workspaceId: string /** Opening an asleep workspace wakes it: the files arrive when it is up, nothing to press. */ waking?: boolean + /** + * Archived, not asleep (DS-h): the copy says "archived", and there is no Wake here, since the + * archived view beside it already has Unarchive as its one action. + */ + archived?: boolean }): React.JSX.Element { const t = useTranslate() const { snapshot } = useCloudOfflineData(workspaceId, true) const now = useNow(30_000) const git = snapshot?.git ?? null - const wake = waking ? ( + const wake = archived ? null : waking ? (