mirror of
https://github.com/stablyai/orca.git
synced 2026-10-30 16:47:34 +00:00
fix(ai-vault): list Claude sessions under a CLAUDE_CONFIG_DIR exported only by the login shell (#33506)
Claude history, usage, native-chat lookup and worktree-retirement discovery now include the user's own CLAUDE_CONFIG_DIR read from the login shell, so sessions in a custom config folder show up even when Orca was launched from the Dock. Refs #23505
This commit is contained in:
@@ -54,7 +54,9 @@ export function withClaudeProfileTerminalEnv<Env extends Record<string, string>
|
||||
return profileEnv ? { ...env, ...profileEnv } : env
|
||||
}
|
||||
|
||||
/** Include account history only where setup could not link it into System default. */
|
||||
/** Account homes plus the user's CLAUDE_CONFIG_DIR, which a Dock launch only learns from the login shell. */
|
||||
export function claudeProfileHistoryDirs(surface: 'projects' | 'transcripts'): string[] {
|
||||
return (installed?.accountHomes() ?? []).map((home) => join(home, surface)).filter(isDirectory)
|
||||
const userConfigDir = installed?.userConfigDir()
|
||||
const homes = [...(userConfigDir ? [userConfigDir] : []), ...(installed?.accountHomes() ?? [])]
|
||||
return homes.map((home) => join(home, surface)).filter(isDirectory)
|
||||
}
|
||||
|
||||
@@ -547,4 +547,12 @@ describe('ClaudeProfileRouter', () => {
|
||||
expect(claudeProfileHistoryDirs('projects')).toEqual([join(f.home('a'), 'projects')])
|
||||
}
|
||||
)
|
||||
|
||||
it('lists history under the CLAUDE_CONFIG_DIR only the login shell exports', () => {
|
||||
const configDir = join(tmpdir(), `claude-router-own-${process.pid}`)
|
||||
roots.push(configDir)
|
||||
mkdirSync(join(configDir, 'projects'), { recursive: true })
|
||||
installClaudeProfileRouter(fixture({ CLAUDE_CONFIG_DIR: configDir }).router)
|
||||
expect(claudeProfileHistoryDirs('projects')).toEqual([join(configDir, 'projects')])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -45,7 +45,7 @@ export function claudeProfileTranscriptDirs(): string[] {
|
||||
export async function listClaudeTranscriptFiles(
|
||||
profileDirs = claudeProfileTranscriptDirs()
|
||||
): Promise<string[]> {
|
||||
const roots = [CLAUDE_PROJECTS_DIR, CLAUDE_TRANSCRIPTS_DIR, ...profileDirs]
|
||||
const files = await Promise.all(roots.map((root) => walkJsonlFiles(root)))
|
||||
const roots = new Set([CLAUDE_PROJECTS_DIR, CLAUDE_TRANSCRIPTS_DIR, ...profileDirs])
|
||||
const files = await Promise.all([...roots].map((root) => walkJsonlFiles(root)))
|
||||
return [...new Set(files.flat())].sort()
|
||||
}
|
||||
|
||||
@@ -116,10 +116,10 @@ async function claudeProjectsSources(args: {
|
||||
let complete = true
|
||||
const hostParents = encodeParents(args.workspaceRoots)
|
||||
if (hostParents.length > 0) {
|
||||
for (const projectsDir of [
|
||||
for (const projectsDir of new Set([
|
||||
getClaudeProjectsDir(args.home ?? homedir(), args.env ?? process.env),
|
||||
...claudeProfileHistoryDirs('projects')
|
||||
]) {
|
||||
])) {
|
||||
sources.push({ projectsDir, encodedParents: hostParents })
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user