Files
orca/src/main/startup/dev-instance-identity.test.ts
T
NeilandOrca fda3c1f778 fix(dev): stabilize macOS safeStorage Keychain key name across dev branches
The Keychain item is named "<app.getName()> Safe Storage". In dev, setName
used a per-branch name ("Orca: <branch>"), so every dev branch created a new
Keychain key and re-prompted, and 'Always Allow' never stuck. Add a stable
appName ('Orca Dev' in dev, 'Orca' in prod) and setName that instead, so all
dev branches share one key. The per-branch label still shows via window title,
renderer identity, and the app-menu label passed to registerAppMenu. Prod is
unchanged (app name stays 'Orca').

Co-authored-by: Orca <help@stably.ai>
2026-07-19 20:36:55 -07:00

71 lines
2.5 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { getDevInstanceIdentity } from './dev-instance-identity'
describe('dev-instance-identity', () => {
it('keeps packaged identity stable', () => {
expect(getDevInstanceIdentity(false, {})).toMatchObject({
name: 'Orca',
appName: 'Orca',
isDev: false,
devLabel: null,
dockBadgeLabel: null,
appUserModelId: 'com.stablyai.orca'
})
})
it('pins a stable dev appName across branches so the safeStorage key does not churn', () => {
const a = getDevInstanceIdentity(true, { ORCA_DEV_BRANCH: 'feature/a' })
const b = getDevInstanceIdentity(true, { ORCA_DEV_BRANCH: 'feature/b' })
// Per-branch label differs (window title / app menu)...
expect(a.name).not.toBe(b.name)
// ...but the Keychain-driving appName is identical and distinct from prod.
expect(a.appName).toBe('Orca Dev')
expect(b.appName).toBe('Orca Dev')
expect(a.appName).not.toBe('Orca')
})
it('derives a readable dev label from worktree and branch env', () => {
const identity = getDevInstanceIdentity(true, {
ORCA_DEV_REPO_ROOT: '/repo/worktrees/dev-indicator',
ORCA_DEV_WORKTREE_NAME: 'dev-indicator',
ORCA_DEV_BRANCH: 'nwparker/dev-indicator'
})
expect(identity).toMatchObject({
isDev: true,
devLabel: 'dev-indicator',
devBranch: 'nwparker/dev-indicator',
devWorktreeName: 'dev-indicator',
devRepoRoot: '/repo/worktrees/dev-indicator'
})
expect(identity.name).toBe('Orca: nwparker/dev-indicator')
expect(identity.dockBadgeLabel).toBeNull()
expect(identity.appUserModelId).toMatch(/^com\.stablyai\.orca\.dev\.[a-f0-9]{10}$/)
})
it('includes the branch when it differs from the worktree basename', () => {
const identity = getDevInstanceIdentity(true, {
ORCA_DEV_REPO_ROOT: '/repo/worktrees/payment-ui',
ORCA_DEV_WORKTREE_NAME: 'payment-ui',
ORCA_DEV_BRANCH: 'feature/billing-shell'
})
expect(identity.devLabel).toBe('payment-ui @ feature/billing-shell')
expect(identity.name).toBe('Orca: feature/billing-shell')
expect(identity.dockBadgeLabel).toBeNull()
})
it('allows an explicit label override', () => {
const identity = getDevInstanceIdentity(true, {
ORCA_DEV_INSTANCE_LABEL: 'manual label',
ORCA_DEV_WORKTREE_NAME: 'dev-indicator',
ORCA_DEV_BRANCH: 'feature/other'
})
expect(identity.devLabel).toBe('manual label')
expect(identity.name).toBe('Orca: feature/other')
expect(identity.dockBadgeLabel).toBeNull()
})
})