mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 10:58:10 +00:00
Keep optional title account lookup from blocking chat naming
This commit is contained in:
@@ -18,25 +18,30 @@ export const captureClaudeConversationTitleOwner =
|
||||
const { connection, acquisitionGeneration, fence, providerSessionId, initialization } = session
|
||||
const boundary = record.providerContextBoundary?.operationId
|
||||
const account = () => {
|
||||
const policy = getClaudeProfileRouter()?.preparation()
|
||||
const recipe = initialization.accountRecipe
|
||||
if (policy) {
|
||||
if ((recipe?.route ?? initialization.account) === 'managed') {
|
||||
if (
|
||||
!policy.provenance.startsWith('profile:') ||
|
||||
(recipe?.route === 'managed' && policy.provenance !== `profile:${recipe.accountId}`) ||
|
||||
resolve(initialization.cwd, policy.configDir) !== initialization.claudeConfigDir
|
||||
) {
|
||||
try {
|
||||
const policy = getClaudeProfileRouter()?.preparation()
|
||||
const recipe = initialization.accountRecipe
|
||||
if (policy) {
|
||||
if ((recipe?.route ?? initialization.account) === 'managed') {
|
||||
if (
|
||||
!policy.provenance.startsWith('profile:') ||
|
||||
(recipe?.route === 'managed' &&
|
||||
policy.provenance !== `profile:${recipe.accountId}`) ||
|
||||
resolve(initialization.cwd, policy.configDir) !== initialization.claudeConfigDir
|
||||
) {
|
||||
return null
|
||||
}
|
||||
} else if (policy.provenance !== 'system') {
|
||||
return null
|
||||
}
|
||||
} else if (policy.provenance !== 'system') {
|
||||
return null
|
||||
}
|
||||
return JSON.stringify([
|
||||
policy?.provenance,
|
||||
policy?.provenance.startsWith('profile:') ? policy.configDir : null
|
||||
])
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
return JSON.stringify([
|
||||
policy?.provenance,
|
||||
policy?.provenance.startsWith('profile:') ? policy.configDir : null
|
||||
])
|
||||
}
|
||||
const selectedAccount = account()
|
||||
const isCurrent: NonNullable<
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ClaudeProfileRouter } from '../../../claude-accounts/claude-profile-router'
|
||||
import {
|
||||
acquired,
|
||||
fakeClaude,
|
||||
@@ -416,3 +417,54 @@ it('discards a retired CLI result and publishes only independent fallback text',
|
||||
cli.dispose()
|
||||
}
|
||||
})
|
||||
|
||||
it.each(['capture', 'pending result'] as const)(
|
||||
'keeps the seed and existing naming failure when account lookup fails at %s',
|
||||
async (stage) => {
|
||||
const cli = fakeClaude()
|
||||
const adapter = await acquired(cli)
|
||||
const state = rig()
|
||||
const naming = automaticNaming(state)
|
||||
const router = new ClaudeProfileRouter({
|
||||
getSettings: () => ({
|
||||
claudeManagedAccounts: [],
|
||||
activeClaudeManagedAccountId: null,
|
||||
agentStatusHooksEnabled: false,
|
||||
disabledTuiAgents: []
|
||||
}),
|
||||
dataRoot: '/isolated',
|
||||
userHome: '/users/test',
|
||||
env: {}
|
||||
})
|
||||
const preparation = vi.spyOn(router, 'preparation')
|
||||
installClaudeProfileRouter(router)
|
||||
const unavailable = () => {
|
||||
throw new Error('Selected account folder missing')
|
||||
}
|
||||
const pending = Promise.withResolvers<string>()
|
||||
const started = Promise.withResolvers<void>()
|
||||
cli.connections[0]!.generateSessionTitle = async () => {
|
||||
started.resolve()
|
||||
return pending.promise
|
||||
}
|
||||
mocks.titleOwner.mockImplementation((record) => adapter.captureConversationTitleOwner(record))
|
||||
state.runtime.resolveNamingEnvironment.mockImplementation(async () => unavailable())
|
||||
try {
|
||||
if (stage === 'capture') {
|
||||
preparation.mockImplementation(unavailable)
|
||||
}
|
||||
naming.start()
|
||||
if (stage === 'pending result') {
|
||||
await started.promise
|
||||
preparation.mockImplementation(unavailable)
|
||||
pending.resolve('Unusable account title')
|
||||
}
|
||||
await vi.waitFor(() => expect(naming.handler.activeSessionIds()).toEqual([]))
|
||||
expect(naming.record().conversationName).toBe('Repair login')
|
||||
expect(naming.handler.failure('session-1')?.messageCode).toBe('agentNotRun')
|
||||
} finally {
|
||||
await adapter.closeAll()
|
||||
cli.dispose()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user