mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-08-25 00:14:40 +00:00
fix(claude): support Windows Desktop sessions via APPDATA (#615)
* fix(claude): use APPDATA for Windows Desktop sessions * test(claude): harden withPlatform mock against cross-file leak The process.platform mock omitted configurable:true and never restored the value when the property had no own descriptor, leaving win32 mocked for later tests on the same Vitest worker. Add configurable + an else branch that deletes the override to expose the real inherited value. --------- Co-authored-by: AgentSeal <hello@agentseal.org>
This commit is contained in:
parent
4ef32c27cb
commit
e2d006be9d
2 changed files with 50 additions and 3 deletions
|
|
@ -105,7 +105,10 @@ export function getDesktopSessionsDir(): string {
|
|||
const override = process.env['CODEBURN_DESKTOP_SESSIONS_DIR']
|
||||
if (override) return override
|
||||
if (process.platform === 'darwin') return join(homedir(), 'Library', 'Application Support', 'Claude', 'local-agent-mode-sessions')
|
||||
if (process.platform === 'win32') return join(homedir(), 'AppData', 'Roaming', 'Claude', 'local-agent-mode-sessions')
|
||||
if (process.platform === 'win32') {
|
||||
const appData = process.env['APPDATA']?.trim()
|
||||
return join(appData || join(homedir(), 'AppData', 'Roaming'), 'Claude', 'local-agent-mode-sessions')
|
||||
}
|
||||
return join(homedir(), '.config', 'Claude', 'local-agent-mode-sessions')
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +1,32 @@
|
|||
import { mkdtemp, mkdir, rm, writeFile } from 'fs/promises'
|
||||
import { delimiter as pathDelimiter, join } from 'path'
|
||||
import { tmpdir, homedir } from 'os'
|
||||
import { homedir, tmpdir } from 'os'
|
||||
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
||||
|
||||
import { claude } from '../../src/providers/claude.js'
|
||||
import { claude, getDesktopSessionsDir } from '../../src/providers/claude.js'
|
||||
import { clearSessionCache, filterProjectsByClaudeConfigSource, parseAllSessions } from '../../src/parser.js'
|
||||
|
||||
let tmpRoot: string
|
||||
const savedEnv = {
|
||||
CLAUDE_CONFIG_DIR: process.env['CLAUDE_CONFIG_DIR'],
|
||||
CLAUDE_CONFIG_DIRS: process.env['CLAUDE_CONFIG_DIRS'],
|
||||
CODEBURN_DESKTOP_SESSIONS_DIR: process.env['CODEBURN_DESKTOP_SESSIONS_DIR'],
|
||||
APPDATA: process.env['APPDATA'],
|
||||
HOME: process.env['HOME'],
|
||||
}
|
||||
|
||||
function withPlatform<T>(platform: typeof process.platform, run: () => T): T {
|
||||
const descriptor = Object.getOwnPropertyDescriptor(process, 'platform')
|
||||
Object.defineProperty(process, 'platform', { value: platform, enumerable: true, configurable: true })
|
||||
try {
|
||||
return run()
|
||||
} finally {
|
||||
if (descriptor) Object.defineProperty(process, 'platform', descriptor)
|
||||
else delete (process as { platform?: NodeJS.Platform }).platform
|
||||
}
|
||||
}
|
||||
|
||||
beforeEach(async () => {
|
||||
clearSessionCache()
|
||||
tmpRoot = await mkdtemp(join(tmpdir(), 'codeburn-claude-multi-'))
|
||||
|
|
@ -24,6 +37,8 @@ beforeEach(async () => {
|
|||
await mkdir(process.env['HOME'], { recursive: true })
|
||||
delete process.env['CLAUDE_CONFIG_DIR']
|
||||
delete process.env['CLAUDE_CONFIG_DIRS']
|
||||
delete process.env['CODEBURN_DESKTOP_SESSIONS_DIR']
|
||||
delete process.env['APPDATA']
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
|
|
@ -202,6 +217,35 @@ describe('claude provider — CLAUDE_CONFIG_DIRS discovery', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('claude provider — Desktop sessions dir', () => {
|
||||
it('uses APPDATA as the Windows Claude Desktop sessions root', () => {
|
||||
const appData = join(tmpRoot, 'roaming-profile')
|
||||
process.env['APPDATA'] = appData
|
||||
|
||||
withPlatform('win32', () => {
|
||||
expect(getDesktopSessionsDir()).toBe(join(appData, 'Claude', 'local-agent-mode-sessions'))
|
||||
})
|
||||
})
|
||||
|
||||
it('falls back to the legacy Windows roaming profile path when APPDATA is unset', () => {
|
||||
delete process.env['APPDATA']
|
||||
|
||||
withPlatform('win32', () => {
|
||||
expect(getDesktopSessionsDir()).toBe(join(homedir(), 'AppData', 'Roaming', 'Claude', 'local-agent-mode-sessions'))
|
||||
})
|
||||
})
|
||||
|
||||
it('keeps CODEBURN_DESKTOP_SESSIONS_DIR ahead of Windows APPDATA discovery', () => {
|
||||
const override = join(tmpRoot, 'desktop-override')
|
||||
process.env['CODEBURN_DESKTOP_SESSIONS_DIR'] = override
|
||||
process.env['APPDATA'] = join(tmpRoot, 'roaming-profile')
|
||||
|
||||
withPlatform('win32', () => {
|
||||
expect(getDesktopSessionsDir()).toBe(override)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('claude provider — config.json claudeConfigDirs (menubar-driven)', () => {
|
||||
async function writeConfigJson(value: unknown): Promise<void> {
|
||||
const dir = join(process.env['HOME']!, '.config', 'codeburn')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue