From 02bc806feccf87809893938519585bbd93e69602 Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 10 Nov 2026 16:49:06 -0800 Subject: [PATCH] fix(cloud): theme-offer tests; state word's separator only when a branch follows (RA-6) --- .../host/WorktreeCardHostMark.tsx | 6 +- .../claude-theme-sync-offer.test.ts | 69 +++++++++++++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 src/renderer/src/components/terminal-pane/provider-notices/claude-theme-sync/claude-theme-sync-offer.test.ts diff --git a/src/renderer/src/components/sidebar/workspace-card/host/WorktreeCardHostMark.tsx b/src/renderer/src/components/sidebar/workspace-card/host/WorktreeCardHostMark.tsx index 801b1880938..2726b59d242 100644 --- a/src/renderer/src/components/sidebar/workspace-card/host/WorktreeCardHostMark.tsx +++ b/src/renderer/src/components/sidebar/workspace-card/host/WorktreeCardHostMark.tsx @@ -1,5 +1,6 @@ import React from 'react' import { useAppStore } from '@/store' +import { findWorktreeById } from '@/store/github/refresh/worktree-refresh' import { useTranslate } from '@/i18n/use-translate' import { cn } from '@/lib/utils' import { HostGlyph, vmStateToDot } from '@/components/host-row-icon' @@ -87,6 +88,8 @@ export function WorktreeCardHostStateWord({ ? vmStateToDot(selectEphemeralVmWorkspaceState(state, worktreeId)) : null ) + // The separator only when line 2 goes on (a branch); "Asleep ·" alone reads as cut off. + const hasBranch = useAppStore((state) => Boolean(findWorktreeById(state, worktreeId)?.branch)) const t = useTranslate() const state = cloud.isCloud ? cloud.state : vmDot // Unknown is not a state to name (the panel shows a placeholder until the first read). @@ -101,7 +104,8 @@ export function WorktreeCardHostStateWord({ PROBLEM.has(state) ? 'text-destructive' : 'text-muted-foreground' )} > - {cloudStateLabel(state, t)} · + {cloudStateLabel(state, t)} + {hasBranch ? ' ·' : null} ) } diff --git a/src/renderer/src/components/terminal-pane/provider-notices/claude-theme-sync/claude-theme-sync-offer.test.ts b/src/renderer/src/components/terminal-pane/provider-notices/claude-theme-sync/claude-theme-sync-offer.test.ts new file mode 100644 index 00000000000..10d3f6c3b03 --- /dev/null +++ b/src/renderer/src/components/terminal-pane/provider-notices/claude-theme-sync/claude-theme-sync-offer.test.ts @@ -0,0 +1,69 @@ +// @vitest-environment happy-dom + +import { act, cleanup, renderHook } from '@testing-library/react' +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' + +const toast = vi.hoisted(() => Object.assign(vi.fn(), { success: vi.fn(), error: vi.fn() })) +vi.mock('sonner', () => ({ toast })) +vi.mock('@/lib/desktop-window-chrome', () => ({ isPairedWebClientWindow: () => false })) + +import { useAppStore } from '@/store/index' +import { seedCloudWorkspaceSnapshot } from '@/lib/orca-cloud/orca-cloud-workspace-store' +import { useClaudeThemeSyncOffer } from './claude-theme-sync-offer' + +const initial = useAppStore.getState() + +function seed(active: { id: string; host: string | null }): void { + useAppStore.setState({ + settings: { + ...initial.settings, + claudeCodeThemeSyncOffer: 'pending' + } as typeof initial.settings, + updateSettings: vi.fn(async () => undefined) as unknown as typeof initial.updateSettings, + activeWorktreeId: active.id, + activeWorkspaceExecutionHostId: active.host as typeof initial.activeWorkspaceExecutionHostId, + activePendingCreationId: null, + tabsByWorktree: { + [active.id]: [{ id: 'tab-1', launchAgent: 'claude' }] + } as unknown as typeof initial.tabsByWorktree + }) +} + +beforeEach(() => toast.mockClear()) +afterEach(() => { + cleanup() + seedCloudWorkspaceSnapshot({}) + useAppStore.setState(initial, true) +}) + +describe('Claude Code theme-sync offer (RA-6)', () => { + it('holds the offer while Claude runs in an Orca Cloud workspace, then makes it on a local one', () => { + seedCloudWorkspaceSnapshot({ ids: new Set(['cloud-ws']), idsLoaded: true }) + seed({ id: 'cloud-ws', host: 'runtime:env-a' }) + renderHook(() => useClaudeThemeSyncOffer()) + expect(toast).not.toHaveBeenCalled() + + act(() => { + useAppStore.setState({ + activeWorktreeId: 'local-ws', + activeWorkspaceExecutionHostId: 'local' + }) + }) + expect(toast).toHaveBeenCalledTimes(1) + expect(toast.mock.calls[0]?.[0]).toBe('Match Claude Code to your Orca theme?') + }) + + it('holds it for a brand-new cloud workspace that is not in the cloud id list yet', () => { + seedCloudWorkspaceSnapshot({ ids: new Set(), idsLoaded: true }) + seed({ id: 'new-cloud-ws', host: 'runtime:env-b' }) + renderHook(() => useClaudeThemeSyncOffer()) + expect(toast).not.toHaveBeenCalled() + }) + + it('offers right away when Claude runs on this computer', () => { + seedCloudWorkspaceSnapshot({ ids: new Set(), idsLoaded: true }) + seed({ id: 'local-ws', host: 'local' }) + renderHook(() => useClaudeThemeSyncOffer()) + expect(toast).toHaveBeenCalledTimes(1) + }) +})